Home | History | Annotate | only in /src/sys/dev/pci
History log of /src/sys/dev/pci
RevisionDateAuthorComments
 1.16 15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.15 12-Dec-2018  maxv Retire the LMC driver, and its associated lmcconfig tool. LMC has been
mentioned repeatedly as a non-MP-safe driver that is hard to maintain,
and no one is taking care of it.

LMC was removed from OpenBSD three years ago, and from FreeBSD a few
months ago.
 1.14 28-Mar-2015  msaitoh branches: 1.14.16; 1.14.18;
Remove hdaudio subdir.
 1.13 16-Sep-2009  sborrill branches: 1.13.22; 1.13.40;
Install hdaudio includes required by upcoming userland toolS
 1.12 23-Jul-2006  bouyer branches: 1.12.58; 1.12.70; 1.12.78;
Add a /dev/amr* control file for amr(4) devices, which allows sending raw
commands to the controller.
Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and individual
drives).
From FreeBSD, with some adjustements by Andrew Doran and me.
 1.11 06-Dec-2005  skrll branches: 1.11.4; 1.11.8;
Correct the includes for lmc.
 1.10 25-Sep-2003  thorpej branches: 1.10.14; 1.10.16;
Install twereg.h and tweio.h
 1.9 13-Sep-2001  thorpej branches: 1.9.18;
Install pcidevs.h, pcidevs_data.h, pciio.h, pcireg.h.
 1.8 30-Jul-2001  ad branches: 1.8.2;
Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.7 11-Apr-2001  jdolecek branches: 1.7.2;
Only install headers which are actually used by our userland. This
saves about 2.2MB under /usr/include/dev/. Discussed on tech-kern@
recently.

I HOPE to get the list right. The headers I left in are ones
used for MI tools and those whose usage I discovered by grep over tree sources.
Feel free to put needed includes back in if you encounter anything which
should not be removed from lists.
 1.6 20-Jun-1999  pk branches: 1.6.2; 1.6.12; 1.6.14;
Remove dead file; alphabetize
 1.5 20-Jun-1999  pk Remove dead file
 1.4 25-Mar-1999  explorer branches: 1.4.4;
install if_lmc*.h
 1.3 16-Jun-1998  cgd Point people to the correct Makefiles to build generated headers.
(Suggested by Manuel Bouyer.)
 1.2 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.1 18-Jun-1995  cgd learn about some PCI vendor and product numbers. not yet used
 1.4.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.6.14.3 21-Sep-2001  nathanw Catch up to -current.
 1.6.14.2 24-Aug-2001  nathanw Catch up with -current.
 1.6.14.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.12.2 26-Oct-2001  jhawk Pull up via patch (requested by windsor):
Move mlxio.h and mlxreg.h from dev/pci/Makefile to dev/ic/Makefile
 1.6.12.1 25-Oct-2001  he Apply patch (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.6.2.1 21-Apr-2001  bouyer Sync with HEAD
 1.7.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.1 03-Aug-2001  lukem update to -current
 1.8.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.9.18.4 11-Dec-2005  christos Sync with head.
 1.9.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.18.1 03-Aug-2004  skrll Sync with HEAD
 1.10.16.2 30-Dec-2006  yamt sync with head.
 1.10.16.1 21-Jun-2006  yamt sync with head.
 1.10.14.1 30-Jul-2006  tron Apply patch (requested by bouyer in ticket #1431):
- Add a /dev/amr* control file for amr(4) devices, which allows sending
raw commands to the controller.
- Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and
individual drives).
 1.11.8.1 11-Aug-2006  yamt sync with head
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.78.1 21-Apr-2010  matt sync to netbsd-5
 1.12.70.1 18-Oct-2009  snj Pull up following revision(s) (requested by sborrill in ticket #1101):
sys/dev/pci/Makefile: revision 1.13
sys/dev/pci/hdaudio/Makefile: revision 1.1
Install hdaudio includes required by userland tools
 1.12.58.1 11-Mar-2010  yamt sync with head
 1.13.40.1 06-Apr-2015  skrll Sync with HEAD
 1.13.22.1 03-Dec-2017  jdolecek update from HEAD
 1.14.18.1 10-Jun-2019  christos Sync with HEAD
 1.14.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7 26-Oct-2016  pgoyette Update the devlist2h.awk script to track the maximum lengths of vendor
and product strings, and report the max values at end of the run.

Update the Makefiles.{pci,usb,hdaudio}devs to point users at the places
which might need to be updated if the maximum lengths get larger.

Since this commit makes no changes to the generated files, we don't
need to regenerate them now.
 1.6 21-Sep-2014  christos branches: 1.6.2; 1.6.4;
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.5 19-Oct-2008  apb branches: 1.5.38;
Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
 1.4 11-Dec-2005  christos branches: 1.4.70; 1.4.74; 1.4.80;
merge ktrace-lwp.
 1.3 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.2 16-Mar-1999  mjacob branches: 1.2.42;
Tron whacked my you-know-what because I didn't follow procedure.
So I insered his description of the 'procedure' in the most likely
place a developer will find it.
 1.1 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.2.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.42.1 03-Aug-2004  skrll Sync with HEAD
 1.4.80.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.74.1 04-May-2009  yamt sync with head.
 1.4.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.5.38.1 03-Dec-2017  jdolecek update from HEAD
 1.6.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.6.2.1 05-Dec-2016  skrll Sync with HEAD
 1.3 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.2 27-Oct-1994  cgd new RCS ID format.
 1.1 09-Aug-1994  mycroft Add PCI autoconfiguration support.
 1.42 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.41 24-Apr-2021  thorpej Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.40 09-Dec-2018  jdolecek branches: 1.40.14;
use pci_intr_establish_xname() everywhere
 1.39 15-Oct-2018  uwe Add Adaptec RAID 2445 and 2805.
From Dima Veselov.
 1.38 27-Sep-2016  pgoyette branches: 1.38.8; 1.38.14; 1.38.16;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.37 07-Jul-2016  msaitoh branches: 1.37.2;
KNF. Remove extra spaces. No functional change.
 1.36 29-Mar-2014  christos branches: 1.36.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.35 27-Oct-2012  chs branches: 1.35.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.34 23-Sep-2012  chs match some more devices.
 1.33 29-Sep-2011  is branches: 1.33.2; 1.33.8; 1.33.12;
Use symbolic constants for SUNs version of ADP2_ASR2200S.
 1.32 18-Feb-2011  jmcneill add Adaptec RAID 3405
 1.31 07-May-2010  is branches: 1.31.2; 1.31.4;
SUN X4140's version of this board. From FreeBSD.
 1.30 26-Nov-2009  njoly branches: 1.30.2; 1.30.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.29 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.28 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.27 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.26 02-Jan-2009  briggs branches: 1.26.2;
Allocate enough space for the aac_pci_softc, not just the aac_softc.
 1.25 08-May-2008  sborrill branches: 1.25.6; 1.25.8;
Add support for IBM ServeRAID 8k (and 8k-l)
 1.24 28-Apr-2008  martin branches: 1.24.2;
Remove clause 3 and 4 from TNF licenses
 1.23 10-Apr-2008  cegger branches: 1.23.2; 1.23.4;
use aprint_*_dev and device_xname
 1.22 19-Oct-2007  ad branches: 1.22.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.21 05-Jun-2007  briggs branches: 1.21.6; 1.21.8; 1.21.12;
Bring in changes from FreeBSD...
* Allocate commands on-demand.
* Update a bunch of constants and some structures.
* Use __attribute__ ((__packed__)) instead of __packed to be consistent.
* Support more commands for devices that can apparently handle them.
* Support a "new comm. interface" present in more recent Adaptec
firmware. This reduces the amount of PCI bus traffic in handling
commands.
* Support larger commands going to the adapter--if the adapter can
support them.
* Support 64-bit commands for archs where sizeof(bus_addr_t) > 4 and
for adapters that advertise SGMAP64.
* Handle the WINDOW4G option and NO4GB quirk by excluding 2G-4G window
unless we have the WINDOW4G capability without the NO4GB quirk.
* Ask the adapter more about its capabilities and try to use those if
they seem sane.
* Do our bus_dmamap_sync() inside dequeue_fib instead of following,
since we have the information that we need there.
* Provide access functions for some adapters that I haven't seen yet
(MIPS-based "Rocket" adapters). Not yet used.
 1.20 10-Mar-2007  christos branches: 1.20.2;
PR/35970: Todd Kover: Add support for HP ML110 G2 / Adaptec 2610SA
 1.19 16-Nov-2006  christos branches: 1.19.2; 1.19.4; 1.19.8; 1.19.10;
__unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 28-Aug-2006  christos branches: 1.17.2; 1.17.4;
static comes first.
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.8;
merge ktrace-lwp.
 1.15 28-Jun-2005  thorpej branches: 1.15.2;
Use ANSI function decls and static.
 1.14 06-Apr-2005  martti Added support for Dell CERC SATA RAID 1.5/6ch
 1.13 19-Mar-2005  tron Use PCI id symbol for the Adaptec ASR-2410SA instead of hardcoding
the number.
 1.12 01-Mar-2005  briggs branches: 1.12.2;
* Remove aif_get_mailboxstatus() from the aac_interface structure. Replace
with aif_get_mailbox(). Make it return uint32_t instead of 'int'.
* Add an AAC_GET_MAILBOX() macro and change AAC_GET_MAILBOXSTATUS() to use
that.
* Update the Dell PERC 2QC quirk code to use AAC_GET_MAILBOX instead of the
StrongARM-specific code. While StrongARM access is correct for that card,
it's a bad example of how to access the mailbox registers.
* Add the GETINFO command and use it to get and display the card's
supported options at a verbose level during attachment.
 1.11 27-Feb-2005  perry nuke trailing whitespace
 1.10 10-May-2004  gendalia branches: 1.10.4; 1.10.6;
Add support for Adaptec AAR 2810SA raid controller.
 1.9 06-May-2004  jdolecek match Adaptec 2410SA
XXX we should probably match all cards with product ID ASR2200S
 1.8 26-Mar-2004  gendalia branches: 1.8.2;
Add support for Adaptec 2200S (Vulcan 2M) and Dell PERC 320/DC
 1.7 31-Jan-2003  thorpej branches: 1.7.2;
Use aprint_*().
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 02-Aug-2002  ad PR 17719 from Mark Davies: Additional Adaptec RAID controller types.
 1.2 15-May-2002  augustss branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Adapt to new bridge name.
 1.1 26-Apr-2002  ad Add a driver for Adaptec FSA RAID controllers, as often found in Dell
servers. Based on the FreeBSD/OpenBSD versions.
 1.2.8.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 15-May-2002  jdolecek file aac_pci.c was added on branch kqueue on 2002-06-23 17:47:32 +0000
 1.2.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.3 13-Aug-2002  nathanw Catch up to -current.
 1.2.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.2.6.1 15-May-2002  nathanw file aac_pci.c was added on branch nathanw_sa on 2002-06-20 03:45:19 +0000
 1.2.4.5 01-Jun-2005  riz Pull up revision 1.13 (requested by tron in ticket #5721):
Use PCI id symbol for the Adaptec ASR-2410SA instead of hardcoding
the number.
 1.2.4.4 19-Mar-2005  tron Pull up revision 1.10 (requested by he in ticket #1755):
Add support for Adaptec AAR 2810SA raid controller.
 1.2.4.3 19-Mar-2005  tron Pull up revision 1.9 (requested by he in ticket #1755):
match Adaptec 2410SA
XXX we should probably match all cards with product ID ASR2200S
 1.2.4.2 19-Mar-2005  tron Pull up revision 1.8 (requested by he in ticket #1755):
Add support for Adaptec 2200S (Vulcan 2M) and Dell PERC 320/DC
 1.2.4.1 16-Nov-2002  he Pull up revision 1.3 (requested by ad in ticket #646):
Add additional Adaptec RAID controller types.
Fixes PR#17719.
 1.2.2.1 29-Aug-2002  gehenna catch up with -current.
 1.7.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.5 01-Apr-2005  skrll Sync with HEAD.
 1.7.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.2.2 08-Oct-2004  jmc branches: 1.8.2.2.2;
Pullup rev 1.10 (requested by he in ticket #896)

Add support for Adaptec AAR 2810SA raid controller.
 1.8.2.1 10-May-2004  tron Pull up revision 1.9 (requested by jdolecek in ticket #274):
match Adaptec 2410SA
XXX we should probably match all cards with product ID ASR2200S
 1.8.2.2.2.1 11-May-2005  riz Pull up revision 1.14 (requested by martti in ticket #1402):
Added support for Dell CERC SATA RAID 1.5/6ch
 1.10.6.2 26-Mar-2005  yamt sync with head.
 1.10.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.12.2.2 07-Apr-2005  jmc Pullup rev 1.13 (requested by tron in ticket #15)

Add missing PCI id for Adaptec ASR-2410SA.
 1.12.2.1 07-Apr-2005  tron Pull up revision 1.14 (requested by martti in ticket #116):
Added support for Dell CERC SATA RAID 1.5/6ch
 1.15.2.3 27-Oct-2007  yamt sync with head.
 1.15.2.2 03-Sep-2007  yamt sync with head.
 1.15.2.1 30-Dec-2006  yamt sync with head.
 1.16.8.1 03-Sep-2006  yamt sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.17.4.2 10-Dec-2006  yamt sync with head.
 1.17.4.1 22-Oct-2006  yamt sync with head
 1.17.2.1 18-Nov-2006  ad Sync with head.
 1.19.10.3 03-Jun-2008  skrll Sync with netbsd-4.
 1.19.10.2 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.19.10.1 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.19.8.3 23-Oct-2007  ad Sync with head.
 1.19.8.2 09-Jun-2007  ad Sync with head.
 1.19.8.1 13-Mar-2007  ad Sync with head.
 1.19.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.2.4 16-Jan-2009  bouyer Pull up following revision(s) (requested by briggs in ticket #1255):
sys/dev/pci/aac_pci.c: revision 1.26
Allocate enough space for the aac_pci_softc, not just the aac_softc.
 1.19.2.3 17-May-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1143):
sys/dev/pci/aac_pci.c: revision 1.25 via patch
share/man/man4/aac.4: revision 1.13 via patch
sys/dev/pci/pcidevs: revision 1.939 via patch
Add support for IBM ServeRAID 8k (and 8k-l)
 1.19.2.2 25-Nov-2007  xtraeme branches: 1.19.2.2.2;
Pull up following revision(s) (requested by briggs in ticket #990):
sys/dev/ic/aac_tables.h: revision 1.5 (patch)
sys/dev/ic/aac.c: revision 1.31 (patch)
sys/dev/ic/aac.c: revision 1.32 (patch)
sys/dev/ic/aac.c: revision 1.33 (patch)
sys/dev/ic/aac.c: revision 1.34 (patch)
sys/arch/amd64/conf/INSTALL: revision 1.70 (patch)
sys/dev/ic/aac.c: revision 1.37 (patch)
sys/dev/ic/aacreg.h: revision 1.6 (patch)
sys/dev/ic/aacreg.h: revision 1.7 (patch)
sys/dev/ic/aacreg.h: revision 1.8 (patch)
sys/dev/ic/aacreg.h: revision 1.9 (patch)
sys/dev/pci/aac_pci.c: revision 1.21 (patch)
sys/dev/ic/aacvar.h: revision 1.10 (patch)
sys/dev/ic/aacvar.h: revision 1.9 (patch)
sys/arch/amd64/conf/GENERIC: revision 1.144 (patch)
sys/dev/ic/ld_aac.c: revision 1.14 (patch)
sys/dev/ic/ld_aac.c: revision 1.15 (patch)
Compile and run on amd64 and on >2GB RAM.
 1.19.2.1 07-Oct-2007  xtraeme Pull up following revision(s) (requested by christos in ticket #923):
sys/dev/pci/aac_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.872
PR/35970: Todd Kover: Add support for HP ML110 G2 / Adaptec 2610SA
 1.19.2.2.2.1 16-Jan-2009  bouyer Pull up following revision(s) (requested by briggs in ticket #1255):
sys/dev/pci/aac_pci.c: revision 1.26
Allocate enough space for the aac_pci_softc, not just the aac_softc.
 1.20.2.1 11-Jul-2007  mjf Sync with head.
 1.21.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.21.8.1 06-Nov-2007  matt sync with HEAD
 1.21.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.22.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.4.5 11-Aug-2010  yamt sync with head.
 1.23.4.4 11-Mar-2010  yamt sync with head
 1.23.4.3 16-May-2009  yamt sync with head
 1.23.4.2 04-May-2009  yamt sync with head.
 1.23.4.1 16-May-2008  yamt sync with head.
 1.23.2.1 18-May-2008  yamt sync with head.
 1.24.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.8.2 20-Nov-2010  riz Pull up following revision(s) (requested by is in ticket #1394):
sys/dev/pci/aac_pci.c: revision 1.31
SUN X4140's version of this board. From FreeBSD.
 1.25.8.1 08-Jan-2009  snj Pull up following revision(s) (requested by briggs in ticket #224):
sys/dev/pci/aac_pci.c: revision 1.26
Allocate enough space for the aac_pci_softc, not just the aac_softc.
 1.25.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.4.2 05-Mar-2011  rmind sync with head
 1.30.4.1 30-May-2010  rmind sync with head
 1.30.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.31.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.31.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.33.12.3 03-Dec-2017  jdolecek update from HEAD
 1.33.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.33.8.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #691):
sys/dev/pci/aac_pci.c: revision 1.34
sys/dev/pci/if_sip.c: revision 1.155
sys/dev/pci/if_tlp_pci.c: revision 1.122
sys/dev/pci/if_an_pci.c: revision 1.34
match some more devices.
 1.33.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.2.1 30-Oct-2012  yamt sync with head
 1.35.2.1 18-May-2014  rmind sync with head
 1.36.6.2 05-Oct-2016  skrll Sync with HEAD
 1.36.6.1 09-Jul-2016  skrll Sync with HEAD
 1.37.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.38.16.1 10-Jun-2019  christos Sync with HEAD
 1.38.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.38.14.1 20-Oct-2018  pgoyette Sync with head
 1.38.8.1 17-Oct-2018  martin Pull up following revision(s) (requested by uwe in ticket #1064):

sys/dev/pci/aac_pci.c: revision 1.39
sys/dev/pci/pcidevs: revision 1.1348

Add Adaptec RAID 2445 and 2805.
From Dima Veselov.
 1.40.14.1 28-Mar-2021  thorpej Correct the names of the arguments passed to the rescan function.
 1.32 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.31 07-Oct-2013  jakllsch branches: 1.31.18;
Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.30 31-Jul-2012  bouyer branches: 1.30.2; 1.30.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.29 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.28 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.27 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.26 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.25 04-Apr-2011  dyoung branches: 1.25.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.24 05-Nov-2010  jakllsch branches: 1.24.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.23 14-May-2008  tsutsui branches: 1.23.18; 1.23.20;
Normalize my licenses.
 1.22 18-Mar-2008  cube branches: 1.22.2; 1.22.4; 1.22.6;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.21 09-Feb-2007  ad branches: 1.21.20; 1.21.36; 1.21.40;
Merge newlock2 to head.
 1.20 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.19 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.18 11-Dec-2005  christos branches: 1.18.20; 1.18.22;
merge ktrace-lwp.
 1.17 24-May-2005  tsutsui branches: 1.17.2;
ATP865 chips support Ultra133, so correct attach messages as well.
 1.16 24-May-2005  lukem add __KERNEL_RCSID
 1.15 08-May-2005  tsutsui ACARD ATP865-A (used on AEC-6280/6880) supports UltraDMA/133 too.
 1.14 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.13 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.12 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.11 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.10 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.9 02-Aug-2004  bouyer branches: 1.9.2;
If acknowledge "bogus" interrupts (that is, interrupts that have happened
according to the controller-dependant registers while wdc was not waiting for
an interrupt). A reset can generate spurious interrupts (or even a flow of
spurious interrupts on the promise) that needs to be properly acknowledged.
 1.8 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.7 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.6 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.5 24-Oct-2003  tsutsui Add support for Acard ATP865/A Ultra100 IDE Controllers. From Tsubai Masanari.
 1.4 24-Oct-2003  tsutsui Remove trailing whitespace.
 1.3 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.9.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.9.2.2 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 02-Aug-2004  skrll file acardide.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.17.2.3 24-Mar-2008  yamt sync with head.
 1.17.2.2 26-Feb-2007  yamt sync with head.
 1.17.2.1 30-Dec-2006  yamt sync with head.
 1.18.22.2 10-Dec-2006  yamt sync with head.
 1.18.22.1 22-Oct-2006  yamt sync with head
 1.18.20.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.18.20.1 18-Nov-2006  ad Sync with head.
 1.21.40.2 02-Jun-2008  mjf Sync with HEAD.
 1.21.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.36.1 24-Mar-2008  keiichi sync with head.
 1.21.20.1 23-Mar-2008  matt sync with HEAD
 1.22.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.4.1 16-May-2008  yamt sync with head.
 1.22.2.1 18-May-2008  yamt sync with head.
 1.23.20.2 21-Apr-2011  rmind sync with head
 1.23.20.1 05-Mar-2011  rmind sync with head
 1.23.18.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.24.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.4.1 30-Oct-2012  yamt sync with head
 1.30.4.1 18-May-2014  rmind sync with head
 1.30.2.3 03-Dec-2017  jdolecek update from HEAD
 1.30.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.31.18.1 05-Aug-2017  jdolecek kill dead code
 1.39 03-Oct-2025  thorpej Use device_{get,set}prop_bool() for "ali1543-ide-force-compat-mode".
 1.38 20-Dec-2020  jdolecek disable (U)DMA for ATAPI on aceride(4), the chip doesn't support it
PR port-sparc64/55540
 1.37 21-Jul-2017  nakayama branches: 1.37.18;
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.

The patch is from port-sparc64@.
 1.36 07-Oct-2013  jakllsch branches: 1.36.4; 1.36.6; 1.36.22;
Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.35 31-Jul-2012  bouyer branches: 1.35.2; 1.35.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.34 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.33 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.32 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.31 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.30 04-Apr-2011  dyoung branches: 1.30.4; 1.30.10;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.29 05-Nov-2010  jakllsch branches: 1.29.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.28 03-Nov-2010  nakayama Add a workaround for 48-bit LBA DMA access bug on M5229 rev. <= 0xc4.
- use DMA in 28-bit LBA addressing.
- use PIO in 48-bit LBA addressing.

Idea and message are from FreeBSD, and tested on M5229 rev. 0xc3 in
my Sun Netra X1 with 160GB drive.
 1.27 08-May-2010  nakayama PCI-ISA Bridge paired with M5229 UDMA IDE Controller rev. 0xC3 is
M1533.

Follow the fix in rev 1.1004 of pcidevs.
 1.26 19-Oct-2009  bouyer branches: 1.26.2; 1.26.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.25 18-Mar-2008  cube branches: 1.25.4; 1.25.14;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.24 01-Jan-2008  chris branches: 1.24.2; 1.24.6;
Add property to aceride to allow the forcing of compat mode.

This allows cats to override the BIOS (aka ABLE) settings, which enable
native mode, but doesn't route the interrupts correctly.

Discussed last year on tech-kern and port-cats.
 1.23 09-Feb-2007  ad branches: 1.23.20; 1.23.26; 1.23.32;
Merge newlock2 to head.
 1.22 27-Nov-2006  christos PR/35136: Gary Duzan: Enable Ultra/133 on newer aceride
 1.21 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 11-Dec-2005  christos branches: 1.19.20; 1.19.22;
merge ktrace-lwp.
 1.18 07-Aug-2005  bouyer To disable a channel we need to clear bit 2 or 3, not all other bits but
bit 2 or 3. Thanks to Takeshi Nakayama for catching it.
(With this mistake the code was still working for the first channel, because
the reset of the second channel would disable/enable the first one).
 1.17 06-Aug-2005  bouyer remove debug printf
 1.16 06-Aug-2005  bouyer Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
 1.15 24-May-2005  lukem branches: 1.15.2;
add __KERNEL_RCSID
 1.14 27-Feb-2005  perry branches: 1.14.2;
nuke trailing whitespace
 1.13 21-Aug-2004  thorpej branches: 1.13.4; 1.13.6;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.12 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.11 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.10 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.9 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.8 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.7 02-Aug-2004  bouyer branches: 1.7.2;
If acknowledge "bogus" interrupts (that is, interrupts that have happened
according to the controller-dependant registers while wdc was not waiting for
an interrupt). A reset can generate spurious interrupts (or even a flow of
spurious interrupts on the promise) that needs to be properly acknowledged.
 1.6 03-Jan-2004  thorpej branches: 1.6.4;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.5 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.4 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.3 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.6.4.2 07-Aug-2005  riz Pull up revision 1.18 (requested by bouyer in ticket #5555):
To disable a channel we need to clear bit 2 or 3, not all other bits but
bit 2 or 3. Thanks to Takeshi Nakayama for catching it.
(With this mistake the code was still working for the first channel, because
the reset of the second channel would disable/enable the first one).
 1.6.4.1 07-Aug-2005  riz Pull up revisions 1.16-1.17 via patch (requested by bouyer in ticket #5555):
Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
 1.7.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 02-Aug-2004  skrll file aceride.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.13.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.4.1 29-Apr-2005  kent sync with -current
 1.14.2.3 18-Aug-2005  tron Pull up revision 1.18 (requested by bouyer in ticket #653):
To disable a channel we need to clear bit 2 or 3, not all other bits but
bit 2 or 3. Thanks to Takeshi Nakayama for catching it.
(With this mistake the code was still working for the first channel, because
the reset of the second channel would disable/enable the first one).
 1.14.2.2 18-Aug-2005  tron Pull up revision 1.17 (requested by bouyer in ticket #653):
remove debug printf
 1.14.2.1 18-Aug-2005  tron Pull up revision 1.16 (requested by bouyer in ticket #653):
Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
 1.15.2.5 24-Mar-2008  yamt sync with head.
 1.15.2.4 21-Jan-2008  yamt sync with head
 1.15.2.3 26-Feb-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.19.22.2 10-Dec-2006  yamt sync with head.
 1.19.22.1 22-Oct-2006  yamt sync with head
 1.19.20.3 06-Feb-2007  ad Quiten noisy boot messages.
 1.19.20.2 12-Jan-2007  ad Sync with head.
 1.19.20.1 18-Nov-2006  ad Sync with head.
 1.23.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.23.20.2 23-Mar-2008  matt sync with HEAD
 1.23.20.1 09-Jan-2008  matt sync with HEAD
 1.24.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.2.1 24-Mar-2008  keiichi sync with head.
 1.25.14.1 21-Nov-2010  riz Pull up following revision(s) (requested by nakayama in ticket #1471):
sys/dev/pci/aceride.c: revision 1.28
Add a workaround for 48-bit LBA DMA access bug on M5229 rev. <= 0xc4.
- use DMA in 28-bit LBA addressing.
- use PIO in 48-bit LBA addressing.
Idea and message are from FreeBSD, and tested on M5229 rev. 0xc3 in
my Sun Netra X1 with 160GB drive.
 1.25.4.2 11-Aug-2010  yamt sync with head.
 1.25.4.1 11-Mar-2010  yamt sync with head
 1.26.4.3 21-Apr-2011  rmind sync with head
 1.26.4.2 05-Mar-2011  rmind sync with head
 1.26.4.1 30-May-2010  rmind sync with head
 1.26.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.26.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.29.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.10.1 23-Jul-2017  snj Pull up following revision(s) (requested by nakayama in ticket #1463):
sys/dev/pci/aceride.c: revision 1.37
sys/dev/pci/pciide_acer_reg.h: revision 1.13
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.
The patch is from port-sparc64@.
 1.30.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.30.4.1 30-Oct-2012  yamt sync with head
 1.35.4.1 18-May-2014  rmind sync with head
 1.35.2.3 03-Dec-2017  jdolecek update from HEAD
 1.35.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.36.22.1 25-Jul-2017  snj Pull up following revision(s) (requested by nakayama in ticket #153):
sys/dev/pci/aceride.c: revision 1.37
sys/dev/pci/pciide_acer_reg.h: revision 1.13
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.
The patch is from port-sparc64@.
 1.36.6.1 28-Aug-2017  skrll Sync with HEAD
 1.36.4.1 26-Jul-2017  snj Pull up following revision(s) (requested by nakayama in ticket #1458):
sys/dev/pci/aceride.c: revision 1.37
sys/dev/pci/pciide_acer_reg.h: revision 1.13
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.
The patch is from port-sparc64@.
 1.37.18.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.31 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.30 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.29 18-Oct-2014  snj branches: 1.29.18; 1.29.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.28 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.27 27-Oct-2012  chs branches: 1.27.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.26 26-Nov-2009  njoly branches: 1.26.12; 1.26.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.25 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.24 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.23 28-Apr-2008  martin branches: 1.23.14;
Remove clause 3 and 4 from TNF licenses
 1.22 10-Apr-2008  cegger branches: 1.22.2; 1.22.4;
use aprint_*_dev and device_xname
 1.21 19-Oct-2007  ad branches: 1.21.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.20 16-Nov-2006  christos branches: 1.20.8; 1.20.22; 1.20.24; 1.20.28;
__unused removal on arguments; approved by core.
 1.19 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.18 11-Dec-2005  christos branches: 1.18.20; 1.18.22;
merge ktrace-lwp.
 1.17 28-Jun-2005  thorpej branches: 1.17.2;
Use ANSI function decls and static.
 1.16 27-Feb-2005  perry nuke trailing whitespace
 1.15 04-Feb-2005  perry de-__P
 1.14 31-Jan-2003  thorpej branches: 1.14.2; 1.14.10; 1.14.12;
Use aprint_*().
 1.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.9 13-Nov-2001  lukem add RCSID
 1.8 28-Dec-2000  sommerfeld branches: 1.8.2; 1.8.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.7 12-Jun-1999  dante branches: 1.7.2;
Move chip version check from advlib.c to adv_pci.c
 1.6 25-Feb-1999  dante branches: 1.6.4;
Fix AdvanSys Narrow driver to work on Alpha
 1.5 26-Sep-1998  dante Remove Wide boards references
Update supported boards list
 1.4 31-Aug-1998  dante Remove __BROKEN_INDIRECT_CONFIG
Correct currently known boards
 1.3 29-Aug-1998  dante Adjust copyright justification
 1.2 29-Aug-1998  dante Add rcs id
 1.1 26-Aug-1998  dante Add AdvanSys 930U and 940U SCSI controllers
 1.6.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.8.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.8.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.8.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.14.12.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.12.1 12-Feb-2005  yamt sync with head.
 1.14.10.1 29-Apr-2005  kent sync with -current
 1.14.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.17.2.2 27-Oct-2007  yamt sync with head.
 1.17.2.1 30-Dec-2006  yamt sync with head.
 1.18.22.2 10-Dec-2006  yamt sync with head.
 1.18.22.1 22-Oct-2006  yamt sync with head
 1.18.20.1 18-Nov-2006  ad Sync with head.
 1.20.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.20.24.1 06-Nov-2007  matt sync with HEAD
 1.20.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.20.8.1 23-Oct-2007  ad Sync with head.
 1.21.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.4.3 11-Mar-2010  yamt sync with head
 1.22.4.2 16-May-2009  yamt sync with head
 1.22.4.1 16-May-2008  yamt sync with head.
 1.22.2.1 18-May-2008  yamt sync with head.
 1.23.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.22.3 03-Dec-2017  jdolecek update from HEAD
 1.26.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.26.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.12.1 30-Oct-2012  yamt sync with head
 1.27.2.1 18-May-2014  rmind sync with head
 1.29.20.1 10-Jun-2019  christos Sync with HEAD
 1.29.18.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.30 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.29 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.28 18-Oct-2014  snj branches: 1.28.18; 1.28.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.27 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.26 27-Oct-2012  chs branches: 1.26.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.25 26-Nov-2009  njoly branches: 1.25.12; 1.25.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.24 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.23 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.22 28-Apr-2008  martin branches: 1.22.14;
Remove clause 3 and 4 from TNF licenses
 1.21 10-Apr-2008  cegger branches: 1.21.2; 1.21.4;
use aprint_*_dev and device_xname
 1.20 19-Oct-2007  ad branches: 1.20.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.19 16-Nov-2006  christos branches: 1.19.8; 1.19.22; 1.19.24; 1.19.28;
__unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 11-Dec-2005  christos branches: 1.17.20; 1.17.22;
merge ktrace-lwp.
 1.16 28-Jun-2005  thorpej branches: 1.16.2;
Use ANSI function decls and static.
 1.15 04-Feb-2005  perry de-__P
 1.14 31-Jan-2003  thorpej branches: 1.14.2; 1.14.10; 1.14.12;
Use aprint_*().
 1.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.9 13-Nov-2001  lukem add RCSID
 1.8 28-Dec-2000  sommerfeld branches: 1.8.2; 1.8.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.7 26-May-2000  dante Fix a bug introduced in last commit which caused a painc due to
re-enqueueing an already free ccb.
Prepare the background to have a unique initialization function for
all of the supported host adapters.
Rename a lot of #define in a more sane way.
Move Carriers initialization and defines in adwmcode.{c,h}
Don't lose Carrier nodes in case of a BUS/Chip reset explicitly invoked
after a DMA failure.

XXX - DMA failure still arise when AdvanSys U[2]W host adapters are used
in conjunction with Intel 82443BX Host Bridge/Controller (rev. 0x03).
!?!Have to understand why!?!
 1.6 08-May-2000  dante Minor changes to PCI configuration
 1.5 30-Apr-2000  dante Add new microcode for all of the supported boards.
Fix minor glitches.
Add preliminary support for ASB-3940U3W host adapters; it might work w/ autotermination on.
ASB-3940U3W support is not yet tested due to lack of board.
 1.4 04-Feb-2000  dante Add a list of all the currently supported boards
 1.3 03-Feb-2000  dante Add AdvanSys U2W (LVD) boards support
 1.2 26-Sep-1998  dante branches: 1.2.12;
Change sources to be KNF
 1.1 26-Sep-1998  dante Add support for AdvanSys Ultra Wide boards ABP-9xxUW
 1.2.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.8.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.8.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.14.12.1 12-Feb-2005  yamt sync with head.
 1.14.10.1 29-Apr-2005  kent sync with -current
 1.14.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.16.2.2 27-Oct-2007  yamt sync with head.
 1.16.2.1 30-Dec-2006  yamt sync with head.
 1.17.22.2 10-Dec-2006  yamt sync with head.
 1.17.22.1 22-Oct-2006  yamt sync with head
 1.17.20.1 18-Nov-2006  ad Sync with head.
 1.19.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.19.24.1 06-Nov-2007  matt sync with HEAD
 1.19.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.19.8.1 23-Oct-2007  ad Sync with head.
 1.20.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.21.4.3 11-Mar-2010  yamt sync with head
 1.21.4.2 16-May-2009  yamt sync with head
 1.21.4.1 16-May-2008  yamt sync with head.
 1.21.2.1 18-May-2008  yamt sync with head.
 1.22.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.22.3 03-Dec-2017  jdolecek update from HEAD
 1.25.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.25.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.12.1 30-Oct-2012  yamt sync with head
 1.26.2.1 18-May-2014  rmind sync with head
 1.28.20.1 10-Jun-2019  christos Sync with HEAD
 1.28.18.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.88 22-May-2022  andvar fix various small typos, mainly in comments.
 1.87 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.86 15-Oct-2019  msaitoh Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.
 1.85 27-Aug-2018  riastradh branches: 1.85.6;
Fill struct agp_info::ai_devid with the PCI id.
 1.84 27-Feb-2017  msaitoh branches: 1.84.12; 1.84.14;
Decode AGP capability.
 1.83 25-Jul-2014  dholland branches: 1.83.4; 1.83.8; 1.83.12;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.82 12-Jun-2014  riastradh Extend agp_generic_bind_memory with bounds to check.

New routine agp_generic_bind_memory_bounded.

Use it in agp_i810 to replace the pile of code I wrote as a
replacement which is apparently broken.
 1.81 16-Mar-2014  dholland branches: 1.81.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.80 06-Apr-2012  plunky branches: 1.80.2; 1.80.4;
device_pmf_is_registered() is not required
 1.79 04-Apr-2011  dyoung branches: 1.79.4; 1.79.8;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.78 24-Feb-2011  matt Add Intel Pineview support
 1.77 15-Feb-2011  jmcneill add AGP v3 support to agp_generic_enable from FreeBSD
 1.76 13-Nov-2010  uebayasi branches: 1.76.2; 1.76.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.75 10-Oct-2010  christos restore binary compatibility for amd64; requested by joerg.
 1.74 02-Oct-2010  jym Revert christos@ fix for the i386 paddr_t change and agp_allocate.

Make 'physical' element of the struct agp_allocate an uint32_t. This
is similar to what other kernels do (at least Solaris and Linux).

This patch should make xserver work again within an i386 userland in a
64 bits paddr_t world.

Thanks to Iain Hibbert for reporting the break, and providing initial hints.

See http://mail-index.netbsd.org/current-users/2010/09/27/msg014418.html
 1.73 28-Sep-2010  christos make this compile.
 1.72 28-Sep-2010  christos - fixes from Jean-Yves Migeon
- handle transitional paddr_t period for i386
 1.71 27-Sep-2010  christos move all the compat code here, and #ifdef __i386__ from mrg.
 1.70 27-Sep-2010  christos backwards compat code for paddr_t being 32 bits.
 1.69 16-Jun-2010  riz Add AGP support for a number of Intel onboard devices, including
82G41, 82B43, E7221, 82965GME, and "Iron Lake". Device
types (i915, i965, G33, and G4X variants) from the Linux Intel AGP
driver, and (for 82G41) from Henry Bent in PR#42906.

There are a few more varieties that should be relatively low-hanging
fruit ("Pineview" and "Sandy Bridge"), but will require a little bit
of rejiggering of the "chiptype".

OK mrg@
 1.68 24-Feb-2010  dyoung branches: 1.68.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.67 24-Feb-2010  jym - Use ctob() instead of ptoa() to obtain physical addresses from frame
numbers. Using ptoa() will cast to vaddr_t, which might no be adequate
for architectures where sizeof(paddr_t) > sizeof(vaddr_t) (like i386 PAE).

- small fix inside AGP heuristics to avoid masking high order bits for
systems with more than 4GB.

Reviewed by bouyer@.

See also http://mail-index.netbsd.org/tech-kern/2010/02/22/msg007373.html
 1.66 08-Jan-2010  dyoung branches: 1.66.2;
Expand PMF_FN_* macros.
 1.65 27-Jan-2009  markd Add some more Intel G4X class chipsets. Also fix gtt_size for G4X chipsets.
Partially from FreeBSD. There is still an issue here as G4X chipsets
report an aperture size of 0.
 1.64 29-Nov-2008  christos Add support for the Intel G45 AGP. From Arnaud Lacombe
 1.63 08-Nov-2008  christos Support for Intel G35 as found on Asus P5E-VM HDMI motherboard from
Milos Negovanovic
 1.62 17-Oct-2008  christos branches: 1.62.2; 1.62.4; 1.62.8;
add missing free.
 1.61 22-Aug-2008  tnn AGP support for Intel 945GME chipset, found on Acer Aspire One.
 1.60 19-Aug-2008  matthias Add agp support for Intel 946gz.
 1.59 09-Jun-2008  freza branches: 1.59.4;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.58 08-Jun-2008  tsutsui Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
 1.57 19-Apr-2008  njoly branches: 1.57.2; 1.57.4;
Add missing agp support for ALI M1689 chipset, for PR/35416.
 1.56 10-Apr-2008  cegger branches: 1.56.2;
use aprint_*_dev and device_xname
 1.55 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.54 09-Dec-2007  jmcneill branches: 1.54.6; 1.54.10;
Merge jmcneill-pm branch.
 1.53 05-Dec-2007  ad branches: 1.53.2;
Match the docs: MUTEX_DRIVER/SPIN are now only for porting code written
for Solaris.
 1.52 24-Nov-2007  markd branches: 1.52.2;
Add agp support for Intel Q35/G33/Q33.
 1.51 12-Nov-2007  joerg Merge bunch of AGP changes from jmcneill-pm.
 1.50 30-Oct-2007  jnemeth branches: 1.50.2;
PR/37201 - Yasushi Oshima -- Intel 82965G chipset support
 1.49 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.48 15-Aug-2007  markd branches: 1.48.2; 1.48.6;
Add agp support for i965Q.

Based on a patch for FreeBSD by Eric Anholt.
OKed on tech-kern some months ago.
 1.47 04-Aug-2007  kiyohara branches: 1.47.2;
Add support agp_amd64. Imported from FreeBSD.
 1.46 06-Mar-2007  xtraeme branches: 1.46.2; 1.46.10; 1.46.14;
Use a mutex rather than lockmgr. Approved by Andrew Doran.
 1.45 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.44 18-Dec-2006  christos branches: 1.44.2;
Don't cleanup memory mappings twice. From Blair Sadewitz
 1.43 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.42 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.41 27-Aug-2006  christos branches: 1.41.2; 1.41.4;
complete initialization
 1.40 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.39 30-Jul-2006  simonb Add support for 82945GM and (untested) 82945P AGP. FreeBSD and
Linux both treat the 945 series exactly the same as the 915 series
for AGP, so just match a few extra device IDs.
 1.38 27-Jun-2006  tron Make this build with GCC 4.x.
 1.37 16-Jan-2006  christos branches: 1.37.2; 1.37.6; 1.37.14;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.36 11-Dec-2005  christos branches: 1.36.2;
merge ktrace-lwp.
 1.35 28-Jun-2005  thorpej branches: 1.35.2;
Use ANSI function decls and static.
 1.34 27-Feb-2005  perry branches: 1.34.2;
nuke trailing whitespace
 1.33 30-Aug-2004  drochner branches: 1.33.4; 1.33.6;
Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.32 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.31 26-Aug-2003  tron Add support for i865G integrated graphics support to agp(4). Patches
contributed by Michael D. Allen in PR port-i386/22600.
 1.30 24-Aug-2003  tron Add a missing blank line between two functions.
 1.29 20-Jul-2003  hannken Add support for i855 agp. From FreeBSD.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.28 29-Jun-2003  fvdl branches: 1.28.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.27 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.26 24-Feb-2003  tron Don't match a PCI graphics card in a system which supports an AGP.
Patch supplied by Quentin Garnier in PR kern/19256.
 1.25 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.24 31-Jan-2003  thorpej Use aprint_*().
 1.23 13-Dec-2002  scw Add support for i830/i845 agp. From Shingo WATANABE (on tech-x11) and
FreeBSD, with cleanup/KNF by me.

Note: These chipsets are not well supported by the i810 driver in
NetBSD's in-tree xsrc (based on XFree86 4.2.1 at this time). However,
the driver works perfectly using bleeding-edge XFree86-current on my
Omnibook's i830MG with these agp changes.
 1.22 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.21 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.20 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.19 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.18 19-Sep-2002  nathanw Slight wording cleanup in a comment.
 1.17 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.16 11-Aug-2002  drochner -avoid lock leak in error case
-Free AGP memory on close, to avoid a memory leak in case
the X server doesn't free it explicitely.
(It appears that the X server never calls AGPIOC_DEALLOCATE.)
Fixes PR kern/17869 by Emmanuel Dreyfus.
 1.15 27-Jun-2002  drochner Only allow the bus_dmamem_alloc() code to sleep if no physically contigous
pages are insisted in.
Atm, the pglistalloc code does the same automatically, but this might change.
 1.14 22-Jan-2002  augustss branches: 1.14.8; 1.14.10;
Don't pretend we can handle i830; it needs a somewhat different AGP driver.
(I added i830 to quickly.)
 1.13 14-Jan-2002  augustss Add i830M to agp chip tables.
 1.12 13-Nov-2001  lukem add RCSID
 1.11 01-Oct-2001  fvdl Don't map the aperture into KVA, it isn't needed.
 1.10 16-Sep-2001  thorpej branches: 1.10.2; 1.10.4;
agp_generic_bind_memory(): Don't return NULL if we can't malloc
memory, return ENOMEM.
 1.9 15-Sep-2001  thorpej agpopen(): check for NULL softc before dereferencing it.
 1.8 15-Sep-2001  drochner normalize error message if agp_map_aperture() fails
 1.7 15-Sep-2001  thorpej Give each AGP controller its own attribute, and let the "agpbus"
device (rather, the device that carries that attribute) also
carry one or more attributes indicating which type of controller
it might be.

This will allow systems that might have AGP, but would never have
e.g. an Intel PCI-Host bridge, to trim out code that won't be used.
 1.6 15-Sep-2001  thorpej Use bus_space_mmap() to mmap the aperture.
 1.5 15-Sep-2001  thorpej Clean up the AGP match/attach code somewhat.
 1.4 14-Sep-2001  drochner -plug some resource leaks
-don't clear memory ranges on "release"

The X server survives a screen switch now.
 1.3 13-Sep-2001  drochner -allocate DMA maps as large as necessary in the worst case
-allocate space for DMA segments as much as necessary
-fix format warnings in a debug output
-don't try to access AGP capability stuff in the PCI config header
if it doesn't exist (as on the i810)
 1.2 11-Sep-2001  fvdl branches: 1.2.2;
Fix i810/other intel chipsets attach mishap.
 1.1 10-Sep-2001  fvdl AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.2.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.2.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.2.1 11-Sep-2001  thorpej file agp.c was added on branch kqueue on 2001-09-13 01:15:49 +0000
 1.10.4.4 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.10.4.3 10-Oct-2001  fvdl Convert all remaining devices.
 1.10.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.10.4.1 16-Sep-2001  fvdl file agp.c was added on branch thorpej-devvp on 2001-10-01 12:45:50 +0000
 1.10.2.11 19-Dec-2002  thorpej Sync with HEAD.
 1.10.2.10 11-Nov-2002  nathanw Catch up to -current
 1.10.2.9 18-Oct-2002  nathanw Catch up to -current.
 1.10.2.8 17-Sep-2002  nathanw Catch up to -current.
 1.10.2.7 13-Aug-2002  nathanw Catch up to -current.
 1.10.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.10.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.10.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.10.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.10.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.10.2.1 16-Sep-2001  nathanw file agp.c was added on branch nathanw_sa on 2001-09-21 22:35:52 +0000
 1.14.10.3 16-Jun-2003  grant Pull up revision 1.26 (requested by tron in ticket #1181):

Don't match a PCI graphics card in a system which supports an AGP.
Patch supplied by Quentin Garnier in PR kern/19256.
 1.14.10.2 28-Jan-2003  jmc Pullup revisions 1.14-1.15 (requested by manu in ticket #1073. Missed in
initial pullup)
Only allow the bus_dmamem_alloc() code to sleep if no physically
contigous pages are insisted in.
 1.14.10.1 26-Jan-2003  jmc Pullup revisions 1.15-1.16 (requested by manu in ticket #1073)
-avoid lock leak in error case
-Free AGP memory on close, to avoid a memory leak in case
the X server doesn't free it explicitely.
(It appears that the X server never calls AGPIOC_DEALLOCATE.)
 1.14.8.3 29-Aug-2002  gehenna catch up with -current.
 1.14.8.2 15-Jul-2002  gehenna catch up with -current.
 1.14.8.1 16-May-2002  gehenna Add the character device switch.
 1.28.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.28.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.28.2.3 03-Sep-2004  skrll Sync with HEAD
 1.28.2.2 03-Aug-2004  skrll Sync with HEAD
 1.28.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.33.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.33.4.1 29-Apr-2005  kent sync with -current
 1.34.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.35.2.8 17-Mar-2008  yamt sync with head.
 1.35.2.7 21-Jan-2008  yamt sync with head
 1.35.2.6 07-Dec-2007  yamt sync with head
 1.35.2.5 15-Nov-2007  yamt sync with head.
 1.35.2.4 27-Oct-2007  yamt sync with head.
 1.35.2.3 03-Sep-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.36.2.1 01-Feb-2006  yamt sync with head.
 1.37.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.37.6.2 03-Sep-2006  yamt sync with head.
 1.37.6.1 11-Aug-2006  yamt sync with head
 1.37.2.1 09-Sep-2006  rpaulo sync with head
 1.41.4.3 21-Dec-2006  yamt sync with head.
 1.41.4.2 10-Dec-2006  yamt sync with head.
 1.41.4.1 22-Oct-2006  yamt sync with head
 1.41.2.2 12-Jan-2007  ad Sync with head.
 1.41.2.1 18-Nov-2006  ad Sync with head.
 1.44.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.46.14.12 09-Dec-2007  jmcneill Sync with HEAD.
 1.46.14.11 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.46.14.10 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.46.14.9 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.46.14.8 31-Oct-2007  joerg Sync with HEAD.
 1.46.14.7 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.14.6 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.46.14.5 06-Sep-2007  jmcneill agp(4) products list ordering fix, from Nicholas Joly on current-users.
 1.46.14.4 27-Aug-2007  jmcneill Add 965PM support.
 1.46.14.3 16-Aug-2007  jmcneill Sync with HEAD.
 1.46.14.2 06-Aug-2007  jmcneill Move agp_i810_power to agp, since it does nothing specific to the i810
hardware. Allow agp front-ends to override the default power handler if
specific configuration needs to take place, and expose agp_power via
agpvar.h so the front-ends can call back to it to do generic initialization.
 1.46.14.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.46.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.46.2.2 23-Oct-2007  ad Sync with head.
 1.46.2.1 20-Aug-2007  ad Sync with HEAD.
 1.47.2.2 04-Aug-2007  kiyohara Add support agp_amd64. Imported from FreeBSD.
 1.47.2.1 04-Aug-2007  kiyohara file agp.c was added on branch matt-mips64 on 2007-08-04 09:33:06 +0000
 1.48.6.2 13-Nov-2007  bouyer Sync with HEAD
 1.48.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.48.2.3 23-Mar-2008  matt sync with HEAD
 1.48.2.2 09-Jan-2008  matt sync with HEAD
 1.48.2.1 06-Nov-2007  matt sync with HEAD
 1.50.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.50.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.50.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.52.2.2 26-Dec-2007  ad Sync with head.
 1.52.2.1 08-Dec-2007  ad Sync with head.
 1.53.2.1 11-Dec-2007  yamt sync with head.
 1.54.10.6 17-Jan-2009  mjf Sync with HEAD.
 1.54.10.5 28-Sep-2008  mjf Sync with HEAD.
 1.54.10.4 29-Jun-2008  mjf Sync with HEAD.
 1.54.10.3 02-Jun-2008  mjf Sync with HEAD.
 1.54.10.2 03-Apr-2008  mjf Sync with HEAD.
 1.54.10.1 29-Mar-2008  mjf - etc/devfsd.conf: Add some rules to give nodes like /dev/tty and
/dev/null better default modes, i.e. 0666.

- sbin/init: Run devfsd -s before going to multiuser.

- sys/arch: Provide arm32, i386, sparc with a mem_init() function to request
device nodes for /dev/null, /dev/zero, etc.

- sys/dev: Convert rnd, wd, agp, raid, cd, sd, wsdisplay, wskbd, wsmouse,
wsmux, tty, bpf, swap to devfs New World Order.

- sys/fs/devfs: Make the visibility attribute of device nodes configurable.
Also provide a function to mount a devfs on boot.

- sys/kern: Add a new boot flag, -n. This disables devfs support. Unless
the -n flag is specified the kernel will mount a devfs file
system on boot.
 1.54.6.1 24-Mar-2008  keiichi sync with head.
 1.56.2.2 17-Jun-2008  yamt sync with head.
 1.56.2.1 18-May-2008  yamt sync with head.
 1.57.4.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.57.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.57.2.3 11-Aug-2010  yamt sync with head.
 1.57.2.2 11-Mar-2010  yamt sync with head
 1.57.2.1 04-May-2009  yamt sync with head.
 1.59.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.59.4.1 19-Oct-2008  haad Sync with HEAD.
 1.62.8.1 21-Apr-2010  matt sync to netbsd-5
 1.62.4.2 19-May-2011  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1560):
sys/sys/agpio.h: revision 1.10
sys/dev/pci/agp_via.c: revision 1.21
sys/dev/pci/agp.c: revision 1.77
add AGP v3 support to agp_generic_enable from FreeBSD
 1.62.4.1 05-May-2009  bouyer Pull up following revision(s) (requested by snj in ticket #737):
sys/arch/x86/pci/pchb.c: revisions 1.15 - 1.17
sys/dev/pci/agp.c: revisions 1.63 - 1.65
sys/dev/pci/agp_i810.c: revisions 1.57 - 1.64
sys/dev/pci/pcidevs: revisions 1.965, 1.967 via patch
sys/dev/pci/agpreg.h: revision 1.20
Add AGP support for Intel G35, G45, and Q45.
 1.62.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.62.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.66.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.66.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.66.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.68.2.3 21-Apr-2011  rmind sync with head
 1.68.2.2 05-Mar-2011  rmind sync with head
 1.68.2.1 03-Jul-2010  rmind sync with head
 1.76.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.76.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.76.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.79.8.1 29-Apr-2012  mrg sync to latest -current.
 1.79.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.79.4.1 17-Apr-2012  yamt sync with head
 1.80.4.1 18-May-2014  rmind sync with head
 1.80.2.2 03-Dec-2017  jdolecek update from HEAD
 1.80.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.81.2.1 10-Aug-2014  tls Rebase.
 1.83.12.1 21-Apr-2017  bouyer Sync with HEAD
 1.83.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.83.4.1 28-Aug-2017  skrll Sync with HEAD
 1.84.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.84.14.1 10-Jun-2019  christos Sync with HEAD
 1.84.12.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.85.6.1 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #672):

sys/dev/ic/tulip.c: revision 1.198
sys/dev/pci/if_jme.c: revision 1.45
sys/dev/pci/agp.c: revision 1.86
sys/dev/pci/if_lii.c: revision 1.27
sys/dev/acpi/thinkpad_acpi.c: revision 1.47
sys/dev/scsipi/scsipi_base.c: revision 1.183
sys/dev/ic/aic6915reg.h: revision 1.6

Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.

Use unsigned when initialize the transmit completion ring to avoid undefined
behavior. Found by kUBSan.

Avoid undefined behavior when setting multicast address. found by kUBSan.

Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.

Avoid undefined behavior in jme_mii_write(). Found by kUBSan.

Use unsigned to avoid undefined behavior in lii_setmulti().

Use unsigned to avoid undefined behavior in scsipi_{get,put}_tag().

Found by kUBSan.
 1.17 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.16 13-Nov-2010  uebayasi branches: 1.16.60;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.15 09-Jun-2008  freza branches: 1.15.20;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.14 13-Apr-2008  njoly branches: 1.14.2; 1.14.4; 1.14.6;
Fix infinite loop with AGP on Ali M1689 (from PR/38269 and PR/35416),
by disallowing aperture size values below 1MB.
 1.13 04-Jan-2008  ad branches: 1.13.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.12 19-Oct-2007  ad branches: 1.12.2; 1.12.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 16-Nov-2006  christos branches: 1.11.2; 1.11.8; 1.11.16; 1.11.22; 1.11.24; 1.11.28;
__unused removal on arguments; approved by core.
 1.10 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9 16-Jan-2006  christos branches: 1.9.18; 1.9.20;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.8 11-Dec-2005  christos branches: 1.8.2;
merge ktrace-lwp.
 1.7 28-Jun-2005  thorpej branches: 1.7.2;
Use ANSI function decls and static.
 1.6 27-Feb-2005  perry branches: 1.6.2;
nuke trailing whitespace
 1.5 02-Jun-2004  christos branches: 1.5.4; 1.5.6;
Apply patch from "pandre" at netbsd.ports.i386, stops panic during attachment.
 1.4 31-Jan-2003  thorpej branches: 1.4.2;
Use aprint_*().
 1.3 13-Nov-2001  lukem add RCSID
 1.2 15-Sep-2001  thorpej branches: 1.2.2; 1.2.4;
Clean up the AGP match/attach code somewhat.
 1.1 10-Sep-2001  fvdl branches: 1.1.2;
AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.1.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.2.1 10-Sep-2001  thorpej file agp_ali.c was added on branch kqueue on 2001-09-13 01:15:50 +0000
 1.2.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.1 15-Sep-2001  fvdl file agp_ali.c was added on branch thorpej-devvp on 2001-10-01 12:45:50 +0000
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 15-Sep-2001  nathanw file agp_ali.c was added on branch nathanw_sa on 2001-09-21 22:35:52 +0000
 1.4.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.4.1 29-Apr-2005  kent sync with -current
 1.6.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.7.2.3 21-Jan-2008  yamt sync with head
 1.7.2.2 27-Oct-2007  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.8.2.1 01-Feb-2006  yamt sync with head.
 1.9.20.2 10-Dec-2006  yamt sync with head.
 1.9.20.1 22-Oct-2006  yamt sync with head
 1.9.18.1 18-Nov-2006  ad Sync with head.
 1.11.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.24.2 09-Jan-2008  matt sync with HEAD
 1.11.24.1 06-Nov-2007  matt sync with HEAD
 1.11.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.16.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.11.8.1 23-Oct-2007  ad Sync with head.
 1.11.2.1 19-Apr-2008  bouyer Pull up following revision(s) (requested by njoly in ticket #1125):
sys/dev/pci/agp_ali.c: revision 1.14
Fix infinite loop with AGP on Ali M1689 (from PR/38269 and PR/35416),
by disallowing aperture size values below 1MB.
 1.12.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.12.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.13.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.4.1 04-May-2009  yamt sync with head.
 1.14.2.1 17-Jun-2008  yamt sync with head.
 1.15.20.1 05-Mar-2011  rmind sync with head
 1.16.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.21 13-Nov-2010  uebayasi branches: 1.21.60;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.20 09-Jun-2008  freza branches: 1.20.20;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.19 04-Jan-2008  ad branches: 1.19.6; 1.19.8; 1.19.10; 1.19.12;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.18 04-Mar-2007  christos branches: 1.18.16; 1.18.22; 1.18.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 16-Nov-2006  christos branches: 1.17.4;
__unused removal on arguments; approved by core.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 11-Apr-2006  rpaulo branches: 1.15.8; 1.15.10;
Coverity ID 2313: free ``asc'' on error.
 1.14 16-Jan-2006  christos branches: 1.14.2; 1.14.4; 1.14.6; 1.14.8; 1.14.10;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.13 11-Dec-2005  christos branches: 1.13.2;
merge ktrace-lwp.
 1.12 28-Jun-2005  thorpej branches: 1.12.2;
Use ANSI function decls and static.
 1.11 27-Feb-2005  perry branches: 1.11.2;
nuke trailing whitespace
 1.10 20-Oct-2004  xtraeme branches: 1.10.4; 1.10.6;
Add another case to match "PCI_PRODUCT_AMD_SC761_SC" (AMD761 System
Controller) in agp_amd_match().

Ok'ed by christos@
 1.9 31-Jan-2003  thorpej branches: 1.9.2; 1.9.4;
Use aprint_*().
 1.8 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.7 13-Nov-2001  lukem add RCSID
 1.6 06-Oct-2001  thorpej Remove and unnecessary cast, and avoid a memory leak in the event
allocation of the GATT fails.
 1.5 01-Oct-2001  fvdl Don't map the aperture into KVA, it isn't needed.
 1.4 01-Oct-2001  fvdl Fix bogus vdir offset calculation.
 1.3 16-Sep-2001  thorpej branches: 1.3.2; 1.3.4;
AGP registers are in memory space on the AMD-751.
 1.2 15-Sep-2001  thorpej Clean up the AGP match/attach code somewhat.
 1.1 10-Sep-2001  fvdl branches: 1.1.2;
AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.1.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.2.1 10-Sep-2001  thorpej file agp_amd.c was added on branch kqueue on 2001-09-13 01:15:50 +0000
 1.3.4.3 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.3.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.3.4.1 16-Sep-2001  fvdl file agp_amd.c was added on branch thorpej-devvp on 2001-10-01 12:45:50 +0000
 1.3.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.5 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.4 22-Oct-2001  nathanw Catch up to -current.
 1.3.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.3.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.3.2.1 16-Sep-2001  nathanw file agp_amd.c was added on branch nathanw_sa on 2001-09-21 22:35:52 +0000
 1.9.4.1 12-Nov-2004  jmc Pullup rev 1.10 (requested by xtraeme in ticket #948)

Add another case to match "PCI_PRODUCT_AMD_SC761_SC" (AMD761 System
Controller) in agp_amd_match().
 1.9.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.2.1 02-Nov-2004  skrll Sync with HEAD.
 1.10.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.11.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.12.2.3 21-Jan-2008  yamt sync with head
 1.12.2.2 03-Sep-2007  yamt sync with head.
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.13.2.1 01-Feb-2006  yamt sync with head.
 1.14.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.8.1 19-Apr-2006  elad sync with head.
 1.14.6.1 24-May-2006  yamt sync with head.
 1.14.4.1 22-Apr-2006  simonb Sync with head.
 1.14.2.1 09-Sep-2006  rpaulo sync with head
 1.15.10.2 10-Dec-2006  yamt sync with head.
 1.15.10.1 22-Oct-2006  yamt sync with head
 1.15.8.1 18-Nov-2006  ad Sync with head.
 1.17.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.28.1 08-Jan-2008  bouyer Sync with HEAD
 1.18.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.16.1 09-Jan-2008  matt sync with HEAD
 1.19.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.19.10.1 04-May-2009  yamt sync with head.
 1.19.8.1 17-Jun-2008  yamt sync with head.
 1.19.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.20.20.1 05-Mar-2011  rmind sync with head
 1.21.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.8 04-Apr-2015  riastradh branches: 1.8.18;
Fix error branches in agp_amd64.c.

- agp_generic_detach always.
- Free asc if it was allocated. (Found by Brainy, noted by maxv@.)
- Free the GATT if it was allocated.
 1.7 25-Feb-2012  tsutsui branches: 1.7.2; 1.7.14; 1.7.16;
- make agp_amd64_attach() also checks AMD64 Family 10h CPU's
misc configuration devices
- print proper error message if no misc configuration device is found

Fixes kernel crash right after starting Xserver with radeondrm
on ASRock AM2NF3-VSTA (AM2 + nForce3 250 AGP) with Athlon II X2 CPU.
 1.6 13-Nov-2010  uebayasi branches: 1.6.8; 1.6.12; 1.6.14;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.5 28-Mar-2008  kiyohara branches: 1.5.26;
Fix ugly format in aprint_normal{,_dev}.
 1.4 27-Mar-2008  kiyohara Split device_t/softc.
 1.3 04-Jan-2008  ad branches: 1.3.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.2 19-Oct-2007  ad branches: 1.2.2; 1.2.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.1 04-Aug-2007  kiyohara branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.14; 1.1.16;
Add support agp_amd64. Imported from FreeBSD.
 1.1.16.2 04-Aug-2007  kiyohara Add support agp_amd64. Imported from FreeBSD.
 1.1.16.1 04-Aug-2007  kiyohara file agp_amd64.c was added on branch matt-mips64 on 2007-08-04 09:33:06 +0000
 1.1.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.10.4 21-Jan-2008  yamt sync with head
 1.1.10.3 27-Oct-2007  yamt sync with head.
 1.1.10.2 03-Sep-2007  yamt sync with head.
 1.1.10.1 04-Aug-2007  yamt file agp_amd64.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:17 +0000
 1.1.8.2 09-Jan-2008  matt sync with HEAD
 1.1.8.1 06-Nov-2007  matt sync with HEAD
 1.1.6.3 23-Oct-2007  ad Sync with head.
 1.1.6.2 20-Aug-2007  ad Sync with HEAD.
 1.1.6.1 04-Aug-2007  ad file agp_amd64.c was added on branch vmlocking on 2007-08-20 22:07:03 +0000
 1.1.4.2 15-Aug-2007  skrll Sync with HEAD.
 1.1.4.1 04-Aug-2007  skrll file agp_amd64.c was added on branch nick-csl-alignment on 2007-08-15 13:48:27 +0000
 1.1.2.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.2.2 04-Aug-2007  jmcneill Sync with HEAD.
 1.1.2.1 04-Aug-2007  jmcneill file agp_amd64.c was added on branch jmcneill-pm on 2007-08-04 12:33:09 +0000
 1.2.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.26.1 05-Mar-2011  rmind sync with head
 1.6.14.1 08-Mar-2012  riz Pull up following revision(s) (requested by tsutsui in ticket #95):
sys/dev/pci/agp_amd64.c: revision 1.7
- make agp_amd64_attach() also checks AMD64 Family 10h CPU's
misc configuration devices
- print proper error message if no misc configuration device is found
Fixes kernel crash right after starting Xserver with radeondrm
on ASRock AM2NF3-VSTA (AM2 + nForce3 250 AGP) with Athlon II X2 CPU.
 1.6.12.1 04-Mar-2012  mrg sync to latest -current.
 1.6.8.1 17-Apr-2012  yamt sync with head
 1.7.16.1 06-Apr-2015  skrll Sync with HEAD
 1.7.14.1 23-Apr-2015  snj Pull up following revision(s) (requested by mrg in ticket #718):
sys/arch/x86/include/pmap.h: revision 1.56
sys/arch/x86/x86/pmap.c: revision 1.188
sys/dev/pci/agp_amd64.c: revision 1.8
sys/dev/pci/agp_i810.c: revision 1.118
sys/external/bsd/drm2/dist/drm/i915/i915_dma.c: revision 1.16
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.29
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c: revision 1.4
sys/external/bsd/drm2/dist/drm/radeon/atombios_crtc.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_agp.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_display.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_crtc.c: revision 1.2
sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c: revisions 1.7-1.10
sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c: revision 1.5
sys/external/bsd/drm2/i915drm/intelfb.c: revision 1.13
sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h: revisions 1.12, 1.13
sys/external/bsd/drm2/include/linux/mm.h: revision 1.5
sys/external/bsd/drm2/include/linux/pci.h: revisions 1.16, 1.17
sys/external/bsd/drm2/nouveau/nouveaufb.c: revision 1.2
sys/external/bsd/drm2/radeon/radeon_pci.c: revisions 1.8, 1.9
sys/uvm/uvm_init.c: revision 1.46
Hack against the blank console problem:
Leave the CLUT alone on ancient cards. At least this leaves us with a
semi working console (red and blue are flipped). Leave an example of what
seems to be happening but disable it because colors are better than 444 bit
greyscale.
--
Initialize P->V tracking for unmanaged device pages in uvm_init.

Conditional on __HAVE_PMAP_PV_TRACK until we add it to all pmaps.

MI part of pmap_pv(9) change proposed on tech-kern:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html
--
Implement pmap_pv(9) for x86 for P->V tracking of unmanaged pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html
--
Use pmap_pv(9) to remove mappings of Intel graphics aperture pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html

Further background at:

https://mail-index.netbsd.org/tech-kern/2014/07/23/msg017392.html
--
Use pmap_pv(9) to remove mappings of device pages in TTM.

Adapt nouveau and radeon to do pmap_pv_track for their device pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html

Further background at:

https://mail-index.netbsd.org/tech-kern/2014/07/23/msg017392.html
--
Fix error branches in agp_amd64.c.

- agp_generic_detach always.
- Free asc if it was allocated. (Found by Brainy, noted by maxv@.)
- Free the GATT if it was allocated.
--
pmf_device_register returns false on failure, not true
--
In DRM_SPIN_WAIT_ON, don't stop after waiting only one tick.

Continue the loop to recheck the condition and count the whole
duration.
--
Don't use the video BIOS memory as an i915 flush page!
--
Don't let anyone else allocate the video BIOS either.
--
Missed a zero: it's 0x100000, not 0x10000.
--
Don't reserve if atomic -- caller must have pre-pinned the buffer.
--
Don't reserve if atomic -- caller must have pre-pinned the buffer.
--
almost add radeondrmkms suspend/resume support. it unfortunately doesn't work.
--
Need the page's uvm object lock to do pmap_page_protect.
--
Use KASSERTMSG to show bad base/offset.
--
KASSERT about page-alignment on initialization too.
--
Don't break when hardclock_ticks wraps around.

Since we now only count time spent in wait, rather than determining
the end time and checking whether we've passed it, timeouts might be
marginally longer in effect. Unlikely to be an issue.
--
Remove broken drm2 vm_mmap stub. Can't possibly have ever worked.
--
apply some of the additional changes from Arto Huusko in PR#49645:
- call pmf_device_deregister on detach.

i've kept the "resume = true" for radeon_resume_kms() call as it
seems to work for me (indeed, code inspection shows it is unused
on netbsd :-)

my old nforce4 box that can resume old drm (or could, last i tried
several years ago) while X and GL apps were running, can at least
survive a resume if X hasn't started. my one attempt so far with
X exited, but having run, did not work.
--
First attempt to make ttm_buffer_object_transfer less bogus.
--
Make sure mem.bus.is_iomem is initialized. PR 49833
 1.7.2.1 03-Dec-2017  jdolecek update from HEAD
 1.8.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.7 02-Nov-2014  christos branches: 1.7.20;
make the apple code compile again.
 1.6 13-Nov-2010  uebayasi branches: 1.6.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.5 09-Jun-2008  freza branches: 1.5.20;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.4 29-Apr-2008  martin branches: 1.4.2;
Convert to new 2 clause license
 1.3 04-Jan-2008  ad branches: 1.3.6; 1.3.8; 1.3.10;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.2 19-Oct-2007  ad branches: 1.2.2; 1.2.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.1 25-Mar-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8; 1.1.14; 1.1.16; 1.1.18; 1.1.22;
very experimental Apple UniNorth AGP support
 1.1.22.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.18.4 21-Jan-2008  yamt sync with head
 1.1.18.3 27-Oct-2007  yamt sync with head.
 1.1.18.2 03-Sep-2007  yamt sync with head.
 1.1.18.1 25-Mar-2007  yamt file agp_apple.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:18 +0000
 1.1.16.2 09-Jan-2008  matt sync with HEAD
 1.1.16.1 06-Nov-2007  matt sync with HEAD
 1.1.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.8.2 11-Jul-2007  mjf Sync with head.
 1.1.8.1 25-Mar-2007  mjf file agp_apple.c was added on branch mjf-ufs-trans on 2007-07-11 20:06:56 +0000
 1.1.6.2 15-Apr-2007  yamt sync with head.
 1.1.6.1 25-Mar-2007  yamt file agp_apple.c was added on branch yamt-idlelwp on 2007-04-15 16:03:23 +0000
 1.1.2.3 23-Oct-2007  ad Sync with head.
 1.1.2.2 10-Apr-2007  ad Sync with head.
 1.1.2.1 25-Mar-2007  ad file agp_apple.c was added on branch vmlocking on 2007-04-10 13:24:23 +0000
 1.2.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.2.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.10.2 04-May-2009  yamt sync with head.
 1.3.10.1 16-May-2008  yamt sync with head.
 1.3.8.2 17-Jun-2008  yamt sync with head.
 1.3.8.1 18-May-2008  yamt sync with head.
 1.3.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.3.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.20.1 05-Mar-2011  rmind sync with head
 1.6.18.1 03-Dec-2017  jdolecek update from HEAD
 1.7.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.126 29-Jan-2024  riastradh agp_i810(4): Use ipi(9) for chipset flush on all CPUs, not xcall(9).

i915 now calls into this with a spin lock held, so we have to use
ipi(9), which spin-waits for the other CPUs to complete, rather than
xcall(9), which may sleep-wait.

Fortunately, this is just to execute WBINVD on x86 (and if this code
ever runs on other architectures, which it probably doesn't, it'll be
a similar barrier instruction), so spinning to wait for that on all
CPUs isn't too costly.

PR kern/57878

XXX pullup-10
 1.125 17-Jul-2022  riastradh branches: 1.125.4;
agp(4): Use bus_space_barrier, not membar_producer.
 1.124 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.123 27-Aug-2018  riastradh Restore gtt page table control register on resume.

Additional subroutine agp_i810_reset is used by i915drmkms to make
sure it happens early enough, since i915drmkms resumes before agp.

XXX pullup-7
XXX pullup-8
 1.122 01-May-2016  nonaka branches: 1.122.10; 1.122.16; 1.122.18;
kern/50453: Separate Pineview chipset from i915-family chipset support.

Should use AGP_I965_IFPADDR instead AGP_I915_IFPADDR in Pineview, becuase
AGP_I915_IFPADDR is used as PCIEXBAR.
 1.121 21-Oct-2015  christos Fix typo
 1.120 21-Oct-2015  christos CID 1328433: Anding with 0 and comparing != 0 will not work very will.
 1.119 13-Oct-2015  riastradh Fix mapping Intel graphics device registers.

- Accept either 32-bit or 64-bit mappings for all devices.
- Let the device always dictate size of the mapping.
- Explain why we don't have a statically fixed mapping size.

Fixes the main part of PR kern/50060. Still a display mode issue
from one submitter, but it is almost certainly an unrelated issue.
 1.118 05-Apr-2015  riastradh Don't use the video BIOS memory as an i915 flush page!
 1.117 06-Mar-2015  riastradh Pass cache-related flags through to the GTT on pre-SNB devices.

I had assumed for ages this would increase the amount of caching and
thereby increase the chance of stale caches leading to rendering
glitches. But apparently I was wrong, and failing to pass these
through was causing all sorts of problems!
 1.116 26-Feb-2015  riastradh Include <sys/atomic.h> for membar_producer.

(Why didn't this fail in my build?)
 1.115 26-Feb-2015  riastradh Issue a write barrier after updating the GTT.

Linux never used to do this...until a month:

https://bugs.freedesktop.org/show_bug.cgi?id=88191

commit 983d308cb8f602d1920a8c40196eb2ab6cc07bd2
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Jan 26 10:47:10 2015 +0000

agp/intel: Serialise after GTT updates
 1.114 24-Aug-2014  riastradh branches: 1.114.2;
Use the right BAR for MMIO register sizing on i810.
 1.113 22-Aug-2014  riastradh Revert to mapping the whole GTTMMADR region all at once for now.

This was split up so we could map the GTT prefetchable without
interfering with the MMIO registers, but it interferes with old drm
which tries to map the whole region and which is still hooked up for
the moment.

Once we unhook old drm for good we can put this back.
 1.112 25-Jul-2014  riastradh branches: 1.112.2;
Mark isc __diagused in agp_i810_unbind_memory.
 1.111 23-Jul-2014  riastradh Tweak style, make it compile...oops.
 1.110 23-Jul-2014  riastradh For the unbind code to work the bind code must set the offset.
 1.109 23-Jul-2014  riastradh Also unbind the right offset.
 1.108 23-Jul-2014  riastradh Bind i810 dcache pages at the requested offset, not at VA start.

From John D Baker in PR xsrc/48344.

XXX pullup to 6 (by patch)
 1.107 01-Jul-2014  riastradh Tweak debug printf directives.
 1.106 27-Jun-2014  riastradh Collect `#ifdef AGP_DEBUG printf(...)' into local DPRINTF macro.
 1.105 25-Jun-2014  riastradh No, that should be unsigned.
 1.104 25-Jun-2014  riastradh Fix integer type mismatch in debug printf.
 1.103 12-Jun-2014  riastradh Get GTT size from PGTBL_CTL on G4X chipsets.
 1.102 12-Jun-2014  riastradh Fix MMIO registers sizes for pre-Ironlake chipsets.
 1.101 12-Jun-2014  riastradh Extend agp_generic_bind_memory with bounds to check.

New routine agp_generic_bind_memory_bounded.

Use it in agp_i810 to replace the pile of code I wrote as a
replacement which is apparently broken.
 1.100 12-Jun-2014  riastradh Fix type in cast too, after changing type of gtt_off.
 1.99 12-Jun-2014  riastradh Check bounds in agp_i810_borrow.

Out of paranoia, do a bus_space_subregion in case the old drm code
tries sizes that the agp_i810 code doesn't agree with.
 1.98 12-Jun-2014  riastradh Use correct type for gtt_off, an offset relative to a bus address.
 1.97 12-Jun-2014  riastradh Ensure we map all the MMIO registers.

For i8xx chipsets, the GTT is in the middle of the MMIO space, so we
can't map it separately. Use a subregion instead.
 1.96 12-Jun-2014  christos Giving a 0 gtt_size for G4X causes a panic when you try to bus map 0 size.
Give it 256, like the default aperture size for it. Now it works again.
 1.95 11-Jun-2014  riastradh Fix fencepost.
 1.94 11-Jun-2014  riastradh Fix various mistakes in yesterday's commit.

- Set mem->am_nseg, particularly before trying to use it.
- Avoid error-prone local copies in agp_i810_bind_memory_main.
- Omit missing DMA unload/free in agp_i810_unbind_memory.
 1.93 11-Jun-2014  riastradh Ignore result of agp_i810_unbind_page in agp_i810_unbind_memory.
 1.92 11-Jun-2014  riastradh Back out previous mistake.

If you mixed `cvs diff' and `cvs commit' in your shell history,
remember to hit C-p the right number of times before RET. Oops.
 1.91 11-Jun-2014  riastradh Add missing bus_dmamap_destroy.
 1.90 11-Jun-2014  riastradh Add missing bus_dmamap_destroy.
 1.89 11-Jun-2014  riastradh Check bounds more carefully to avoid integer overflow.
 1.88 11-Jun-2014  riastradh Don't trust the MSAC register after all; use the GMADR BAR size.

Previously this read the MSAC register from the wrong PCI device.
Experiments reveal that even on the right PCI device, per the
datasheet, the GMADR BAR size is correct.

Not clear that the driver has any business reading any of these GMCH
registers to discern the aperture size -- seems to me they are meant
to be written by the BIOS to determine the GMADR BAR size. Lacking a
variety of hardware to test, though, I'll leave this as is for now...
 1.87 11-Jun-2014  riastradh Fix sense of conditional for GTTMMADR size.
 1.86 10-Jun-2014  riastradh Rework agp_i810 memory binding.

Principal reason is that the GTT size is not necessarily the same as
the aperture size: the GPU may have a bigger virtual address space
than the CPU can see through the aperture.

While here, factor the code a little more legibly and name some magic
constants.
 1.85 10-Jun-2014  riastradh Another round of weed-whacking for agp_i810.

- Make struct agp_i810_softc::gatt specific to i810 chipsets; use other
members of struct agp_i810_softc for non-i810 chipsets.

- agp_i810_init detects and sets isc->gtt_size.

- Map GTT based on the GTT size detected by agp_i810_init.

- Sprinkle some comments particularly about questionable calculations.
 1.84 28-May-2014  riastradh Cosmetic changes require testing too...oops.
 1.83 28-May-2014  riastradh Cosmetics: long lines, needless variables, PCI parameter verbiage.
 1.82 28-May-2014  riastradh Rationalize agp_i810 aprint output. Fix agp_i810_init error branches.
 1.81 28-May-2014  riastradh Oops -- gtt_off is relative to mmadr, not absolute.
 1.80 27-May-2014  riastradh Suppress uninitialized variable warnings in older and dumber GCC.
 1.79 27-May-2014  riastradh Rework agp_i810 attachment code a little.

- Fix up error branches in agp_i810_attach.

- Use a separate bus space handle for the GTT, whether it is in a
separate BAR or a subregion of the MMIO device registers, so that

(a) agp_i810_write_gtt_entry and agp_i810_post_gtt_entry are easier to
follow, and

(b) we can map the GTT prefetchable eventually.
 1.78 26-May-2014  riastradh Use correct address for 64-bit flush page config register.
 1.77 26-May-2014  riastradh Avoid xcall(9) while cold.
 1.76 24-May-2014  riastradh Handle 64-bit paddr registers delicately for non-PAE i386.
 1.75 23-May-2014  riastradh Implement Intel AGP chipset flush.

While here, fix the use of the I915 PCI MSAC register: it lies on the
bridge device (bus 0 dev 0 func 0), not the graphics device (bus 0
dev 2 func 0). I'm not sure we ever need to consult this register,
really -- the PCI BARs should be sized. But I'll leave a rototill of
this mess for another day.
 1.74 18-Mar-2014  riastradh branches: 1.74.2;
Merge riastradh-drm2 to HEAD.
 1.73 04-Apr-2011  dyoung branches: 1.73.4; 1.73.10; 1.73.14; 1.73.16; 1.73.18; 1.73.24; 1.73.26;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.72 24-Feb-2011  matt Add Intel Pineview support
 1.71 30-Jan-2011  gsutre Enable 36-bit addressing for chipsets that support it. While there,
factorize offset computation. Inspired from OpenBSD and Intel docs.

Note: agp_i810_bind/unbind_page will now fail with EINVAL if the
physical address is too large for the chipset (instead of silently
truncating it).

ok jmcneill@
 1.70 25-Jan-2011  gsutre Typos, fix memory binding for memory type 2, and add consistency checks.
From OpenBSD.

ok jmcneill@
 1.69 13-Nov-2010  uebayasi branches: 1.69.2; 1.69.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.68 16-Jun-2010  riz Add AGP support for a number of Intel onboard devices, including
82G41, 82B43, E7221, 82965GME, and "Iron Lake". Device
types (i915, i965, G33, and G4X variants) from the Linux Intel AGP
driver, and (for 82G41) from Henry Bent in PR#42906.

There are a few more varieties that should be relatively low-hanging
fruit ("Pineview" and "Sandy Bridge"), but will require a little bit
of rejiggering of the "chiptype".

OK mrg@
 1.67 04-Apr-2010  jakllsch Add (non-IGP) AGP port support for Intel 82855GM.
agp_intel tested with radeondrm(4). agp_i810 tested with i915drm(4).
 1.66 24-Feb-2010  dyoung branches: 1.66.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.65 08-Jan-2010  dyoung branches: 1.65.2;
Expand PMF_FN_* macros.
 1.64 04-May-2009  markd Treat G4X like I915 and G33 for MSAC. Fixes aperture setting.
Has been working successfully for me and snj for the last few months.
 1.63 19-Feb-2009  markd Add missing break.
 1.62 27-Jan-2009  markd branches: 1.62.2;
Add some more Intel G4X class chipsets. Also fix gtt_size for G4X chipsets.
Partially from FreeBSD. There is still an issue here as G4X chipsets
report an aperture size of 0.
 1.61 13-Dec-2008  sketch Fix PGTBL sizes.
 1.60 10-Dec-2008  christos fix PGTBL size detection on the intel 965GM. From Anon Ymous.
 1.59 04-Dec-2008  alc Fix regression introducted by the previous commit.

i915 and G33 Intel chipset family need special handling when writing an entry
to the GTT.

reported by: <tnn> [0]
tested by: <tnn>

[0]: http://mail-index.netbsd.org/tech-x11/2008/12/03/msg000276.html
 1.58 29-Nov-2008  christos Add support for the Intel G45 AGP. From Arnaud Lacombe
 1.57 08-Nov-2008  christos Support for Intel G35 as found on Asus P5E-VM HDMI motherboard from
Milos Negovanovic
 1.56 22-Aug-2008  tnn branches: 1.56.2; 1.56.4; 1.56.8;
AGP support for Intel 945GME chipset, found on Acer Aspire One.
 1.55 19-Aug-2008  matthias Add agp support for Intel 946gz.
 1.54 09-Jun-2008  freza branches: 1.54.4;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.53 10-May-2008  jmcneill Don't use aprint_error in the success path.
 1.52 10-Apr-2008  cegger branches: 1.52.2; 1.52.4; 1.52.6;
use aprint_*_dev and device_xname
 1.51 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.50 26-Feb-2008  drochner -Now that the address space conflict is solved, we can re-enable that old
workaround for some VESA BIOS which overwrites PGTBL_CTL. Pointed out
by Yorick Hardy.
-make two variables introduced in the last commit static
 1.49 22-Feb-2008  drochner Add a horrible hack to allow the DRM driver to get at the bus_space_handle
allocated by the AGP driver in the case of Intel chipset graphics.
This is different from the patch by Yorick Hardy circulated a while ago
in that it doesn't change the semantics of reference counting within
the (3rd-party) DRM code -- it just bypasses it.
Needless to say that it is uglier, but it eases future updates to
the DRM code because the change there is just 2 LOC.

Imo, a cleaner solution for all that would be to attach "agp" to "vga"
in the intel chipset graphics case, which better reflects how the hardware
is structured. This would still need a hack to the DRM code, but
it would be confined to childs of the "vga" device, without need for
global variables.
Since there is a variety of intel chipsets with AGP and/or builtin
graphics options, this would need a considerable testing effort.
 1.48 04-Jan-2008  ad branches: 1.48.2; 1.48.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.47 09-Dec-2007  jmcneill branches: 1.47.2;
Merge jmcneill-pm branch.
 1.46 24-Nov-2007  markd branches: 1.46.2; 1.46.4;
Add agp support for Intel Q35/G33/Q33.
 1.45 12-Nov-2007  joerg Merge bunch of AGP changes from jmcneill-pm.
 1.44 30-Oct-2007  jnemeth branches: 1.44.2;
PR/37201 - Yasushi Oshima -- Intel 82965G chipset support
 1.43 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.42 15-Aug-2007  markd branches: 1.42.2; 1.42.6;
Add agp support for i965Q.

Based on a patch for FreeBSD by Eric Anholt.
OKed on tech-kern some months ago.
 1.41 20-Jun-2007  sborrill branches: 1.41.2; 1.41.6;
Support more i915 stolen memory configurations (previous limit was 8MB,
some configurations steal up to 64MB). OK christos@
 1.40 24-Mar-2007  christos comment out unmap; breaks X.
 1.39 23-Mar-2007  drochner simplify previous: no need to call pci_mapreg_info()
 1.38 23-Mar-2007  jmcneill Initialize mmadrsize in the non-i910 case, otherwise we end up passing an
uninitialized variable to bus_space_unmap.
 1.37 20-Mar-2007  drochner Import DRM drivers, brought into shape by Yorick Hardy, posted to tech-x11.
Minor modifications by me:
-use an mi device major number
-(coarsly) divided into pci card specific and less specific parts, moved
the latter to dev/drm
-renamed autoconf attributes to reflect this
Todo:
-adapt all card frontends but i915 to drm include file location
-review the mtrr change
-make the change to agp_i810.c coexist with the fix for buggy VESA
BIOSes which is commented out temporarily
-RCS IDs etc style stuff
-LKM support (rescan support for vga)
-test
 1.36 04-Mar-2007  christos branches: 1.36.2; 1.36.4; 1.36.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 16-Nov-2006  christos branches: 1.35.4;
__unused removal on arguments; approved by core.
 1.34 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.33 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.32 30-Jul-2006  simonb branches: 1.32.4; 1.32.6;
Add support for 82945GM and (untested) 82945P AGP. FreeBSD and
Linux both treat the 945 series exactly the same as the 915 series
for AGP, so just match a few extra device IDs.
 1.31 27-Jun-2006  tron Make this build with GCC 4.x.
 1.30 14-May-2006  elad branches: 1.30.4;
integrate kauth.
 1.29 15-Apr-2006  rpaulo s/#ifdef DEBUG/#ifdef AGP_DEBUG/
 1.28 16-Jan-2006  christos branches: 1.28.2; 1.28.4; 1.28.6; 1.28.8; 1.28.10;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.27 11-Dec-2005  christos branches: 1.27.2;
merge ktrace-lwp.
 1.26 28-Jun-2005  thorpej branches: 1.26.2;
Use ANSI function decls and static.
 1.25 27-Feb-2005  perry branches: 1.25.2;
nuke trailing whitespace
 1.24 27-Jan-2005  jmcneill Add agp_i810 powerhook, from Kentaro A. Kurahone
 1.23 06-Nov-2004  xtraeme branches: 1.23.4; 1.23.6;
Add another case to match "PCI_PRODUCT_INTEL_82815_FULL_HUB"
(Intel 82815 Hub) in agp_i810_attach(), closes PR 27863.

Ok'ed christos@
 1.22 20-Mar-2004  jdolecek branches: 1.22.2;
eliminate redundant aperture size printouts
reported in PR kern/24859 by Nicolas Joly
 1.21 23-Dec-2003  tron Support i82845G/GL based motherboards without an Integrated Graphics
Device. Patch supplied by Nicolas Joly in PR kern/23860.
 1.20 07-Sep-2003  tron Compile in the i845/i865 fallback attachment code only if generic AGP Intel
support is enabled.
 1.19 07-Sep-2003  tron If we fail to find the Integrated Graphics Device of an Intel i840 or
i865 chipset try the generic Intel AGP code because it is probably
a motherboard without onboard graphics.
 1.18 26-Aug-2003  tron Add support for i865G integrated graphics support to agp(4). Patches
contributed by Michael D. Allen in PR port-i386/22600.
 1.17 20-Jul-2003  hannken Add support for i855 agp. From FreeBSD.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.16 24-Mar-2003  drochner branches: 1.16.2;
Remove an aprint_normal() so that the output looks reasonable
at least in the non-error case.
(The aprint_* stuff makes it hard to keep track of newlines and
device name tags, and it suffers from lack of rules.)
 1.15 31-Jan-2003  thorpej Use aprint_*().
 1.14 13-Dec-2002  scw Add support for i830/i845 agp. From Shingo WATANABE (on tech-x11) and
FreeBSD, with cleanup/KNF by me.

Note: These chipsets are not well supported by the i810 driver in
NetBSD's in-tree xsrc (based on XFree86 4.2.1 at this time). However,
the driver works perfectly using bleeding-edge XFree86-current on my
Omnibook's i830MG with these agp changes.
 1.13 11-Aug-2002  drochner update the is_bound flag for local memory too
 1.12 22-Jan-2002  augustss branches: 1.12.8; 1.12.10;
Don't pretend we can handle i830; it needs a somewhat different AGP driver.
(I added i830 to quickly.)
 1.11 14-Jan-2002  augustss Add i830M to agp chip tables.
 1.10 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.9 13-Nov-2001  lukem add RCSID
 1.8 20-Sep-2001  fvdl branches: 1.8.2; 1.8.4;
Add message to explain failure if the internal i810 config registers
weren't found.
 1.7 15-Sep-2001  drochner normalize error message if agp_map_aperture() fails
 1.6 15-Sep-2001  thorpej Clean up the AGP match/attach code somewhat.
 1.5 14-Sep-2001  drochner make the hardware cursor work
 1.4 13-Sep-2001  drochner -allocate DMA maps as large as necessary in the worst case
-Add a really bad hack: The X server (4.1.0 afaict) appearently overwrites
the PGTBL_CTL which contains the base address of the pseudo-GATT.
Restore the original value if we notice this happened.
The X server works now, but only with soft cursor.
 1.3 11-Sep-2001  fvdl branches: 1.3.2;
Fix i810/other intel chipsets attach mishap.
 1.2 10-Sep-2001  fvdl Fix reversed if condition in agp_i810_vgamatch.
 1.1 10-Sep-2001  fvdl AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.3.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.3.2.1 11-Sep-2001  thorpej file agp_i810.c was added on branch kqueue on 2001-09-13 01:15:50 +0000
 1.8.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.8.4.1 20-Sep-2001  fvdl file agp_i810.c was added on branch thorpej-devvp on 2001-10-01 12:45:51 +0000
 1.8.2.6 19-Dec-2002  thorpej Sync with HEAD.
 1.8.2.5 13-Aug-2002  nathanw Catch up to -current.
 1.8.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.8.2.1 20-Sep-2001  nathanw file agp_i810.c was added on branch nathanw_sa on 2001-09-21 22:35:53 +0000
 1.12.10.1 26-Jan-2003  jmc Pullup revisions 1.12-1.13 (requested by manu in ticket #1073)
update the is_bound flag for local memory too
 1.12.8.1 29-Aug-2002  gehenna catch up with -current.
 1.16.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.16.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.16.2.4 14-Nov-2004  skrll Sync with HEAD.
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.1 12-Nov-2004  jmc Pullup rev 1.23 (requested by xtraeme in ticket #938)

Add another case to match "PCI_PRODUCT_INTEL_82815_FULL_HUB"
(Intel 82815 Hub) in agp_i810_attach(). PR#27863
 1.23.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.6.1 12-Feb-2005  yamt sync with head.
 1.23.4.1 29-Apr-2005  kent sync with -current
 1.25.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.26.2.9 17-Mar-2008  yamt sync with head.
 1.26.2.8 27-Feb-2008  yamt sync with head.
 1.26.2.7 21-Jan-2008  yamt sync with head
 1.26.2.6 07-Dec-2007  yamt sync with head
 1.26.2.5 15-Nov-2007  yamt sync with head.
 1.26.2.4 27-Oct-2007  yamt sync with head.
 1.26.2.3 03-Sep-2007  yamt sync with head.
 1.26.2.2 30-Dec-2006  yamt sync with head.
 1.26.2.1 21-Jun-2006  yamt sync with head.
 1.27.2.1 01-Feb-2006  yamt sync with head.
 1.28.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.28.8.1 19-Apr-2006  elad sync with head.
 1.28.6.2 11-Aug-2006  yamt sync with head
 1.28.6.1 24-May-2006  yamt sync with head.
 1.28.4.1 22-Apr-2006  simonb Sync with head.
 1.28.2.1 09-Sep-2006  rpaulo sync with head
 1.30.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.32.6.2 10-Dec-2006  yamt sync with head.
 1.32.6.1 22-Oct-2006  yamt sync with head
 1.32.4.1 18-Nov-2006  ad Sync with head.
 1.35.4.3 15-Apr-2007  yamt sync with head.
 1.35.4.2 24-Mar-2007  yamt sync with head.
 1.35.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.6.1 29-Mar-2007  reinoud Pullup to -current
 1.36.4.1 11-Jul-2007  mjf Sync with head.
 1.36.2.4 23-Oct-2007  ad Sync with head.
 1.36.2.3 20-Aug-2007  ad Sync with HEAD.
 1.36.2.2 15-Jul-2007  ad Sync with head.
 1.36.2.1 10-Apr-2007  ad Sync with head.
 1.41.6.13 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.41.6.12 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.41.6.11 14-Nov-2007  joerg Sync with HEAD.
 1.41.6.10 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.41.6.9 31-Oct-2007  joerg Sync with HEAD.
 1.41.6.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.41.6.7 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.41.6.6 06-Sep-2007  jmcneill Add Intel G33 AGP support, resolves PR36902, PR36903, PR36904, PR36906,
PR36907, PR36908, PR36909, PR36910, PR36911, PR36912, PR36913, and PR36925.
 1.41.6.5 27-Aug-2007  jmcneill Add 965PM support.
 1.41.6.4 16-Aug-2007  jmcneill Sync with HEAD.
 1.41.6.3 07-Aug-2007  jmcneill Add i810 power handler.
 1.41.6.2 06-Aug-2007  jmcneill Move agp_i810_power to agp, since it does nothing specific to the i810
hardware. Allow agp front-ends to override the default power handler if
specific configuration needs to take place, and expose agp_power via
agpvar.h so the front-ends can call back to it to do generic initialization.
 1.41.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.41.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.42.6.2 13-Nov-2007  bouyer Sync with HEAD
 1.42.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.42.2.3 23-Mar-2008  matt sync with HEAD
 1.42.2.2 09-Jan-2008  matt sync with HEAD
 1.42.2.1 06-Nov-2007  matt sync with HEAD
 1.44.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.44.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.44.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.44.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.46.4.1 11-Dec-2007  yamt sync with head.
 1.46.2.1 26-Dec-2007  ad Sync with head.
 1.47.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.48.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.48.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.48.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.48.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.48.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.48.2.1 24-Mar-2008  keiichi sync with head.
 1.52.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.52.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.4.5 11-Aug-2010  yamt sync with head.
 1.52.4.4 11-Mar-2010  yamt sync with head
 1.52.4.3 16-May-2009  yamt sync with head
 1.52.4.2 04-May-2009  yamt sync with head.
 1.52.4.1 16-May-2008  yamt sync with head.
 1.52.2.2 17-Jun-2008  yamt sync with head.
 1.52.2.1 18-May-2008  yamt sync with head.
 1.54.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.54.4.1 19-Oct-2008  haad Sync with HEAD.
 1.56.8.1 21-Apr-2010  matt sync to netbsd-5
 1.56.4.2 20-Nov-2010  riz Pull up following revision(s) (requested by jakllsch in ticket #1362):
sys/dev/pci/pcidevs: revision 1.1026
sys/dev/pci/agp_intel.c: revision 1.35
sys/dev/pci/agp_i810.c: revision 1.67
Add Intel 82855GM Host-AGP Bridge.
regen
Add (non-IGP) AGP port support for Intel 82855GM.
agp_intel tested with radeondrm(4). agp_i810 tested with i915drm(4).
 1.56.4.1 05-May-2009  bouyer Pull up following revision(s) (requested by snj in ticket #737):
sys/arch/x86/pci/pchb.c: revisions 1.15 - 1.17
sys/dev/pci/agp.c: revisions 1.63 - 1.65
sys/dev/pci/agp_i810.c: revisions 1.57 - 1.64
sys/dev/pci/pcidevs: revisions 1.965, 1.967 via patch
sys/dev/pci/agpreg.h: revision 1.20
Add AGP support for Intel G35, G45, and Q45.
 1.56.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.56.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.62.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.65.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.65.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.66.2.4 21-Apr-2011  rmind sync with head
 1.66.2.3 05-Mar-2011  rmind sync with head
 1.66.2.2 03-Jul-2010  rmind sync with head
 1.66.2.1 30-May-2010  rmind sync with head
 1.69.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.69.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.69.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.73.26.2 05-Mar-2014  riastradh Expose agp_i810_write_gtt_entry for drm2.

Also add an agp_i810_post_gtt_entry to do a posting read for that GTT
entry.
 1.73.26.1 05-Mar-2014  riastradh Expose the agp_i810 softc.

This is an Intel-specific kludge so that i915drmkms can get at the
GTT, graphics translation table, for pre-Sandy Bridge Intel graphics
devices.
 1.73.24.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1105):
src/sys/dev/pci/agp_i810.c 1.108-1.110 via patch.
Bind i810 dcache pages at the requested offset, not at VA start.
From John D Baker in PR xsrc/48344.
 1.73.18.1 18-May-2014  rmind sync with head
 1.73.16.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1105):
src/sys/dev/pci/agp_i810.c 1.108-1.110 via patch.
Bind i810 dcache pages at the requested offset, not at VA start.
From John D Baker in PR xsrc/48344.
 1.73.14.2 03-Dec-2017  jdolecek update from HEAD
 1.73.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.73.10.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1105):
src/sys/dev/pci/agp_i810.c 1.108-1.110 via patch.
Bind i810 dcache pages at the requested offset, not at VA start.
From John D Baker in PR xsrc/48344.
 1.73.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.74.2.1 10-Aug-2014  tls Rebase.
 1.112.2.5 27-Jan-2016  snj Pull up following revision(s) (requested by riastradh in ticket #1078):
sys/dev/pci/agp_i810.c: revision 1.120
sys/dev/pci/agp_i810.c: revision 1.121
CID 1328433: Anding with 0 and comparing != 0 will not work very will.
Fix typo
 1.112.2.4 06-Nov-2015  riz Pull up following revision(s) (requested by riastradh in ticket #1000):
sys/dev/pci/agp_i810.c: revision 1.119
Fix mapping Intel graphics device registers.
- Accept either 32-bit or 64-bit mappings for all devices.
- Let the device always dictate size of the mapping.
- Explain why we don't have a statically fixed mapping size.
Fixes the main part of PR kern/50060. Still a display mode issue
from one submitter, but it is almost certainly an unrelated issue.
 1.112.2.3 23-Apr-2015  snj Pull up following revision(s) (requested by mrg in ticket #718):
sys/arch/x86/include/pmap.h: revision 1.56
sys/arch/x86/x86/pmap.c: revision 1.188
sys/dev/pci/agp_amd64.c: revision 1.8
sys/dev/pci/agp_i810.c: revision 1.118
sys/external/bsd/drm2/dist/drm/i915/i915_dma.c: revision 1.16
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.29
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c: revision 1.4
sys/external/bsd/drm2/dist/drm/radeon/atombios_crtc.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_agp.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_display.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_crtc.c: revision 1.2
sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c: revisions 1.7-1.10
sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c: revision 1.5
sys/external/bsd/drm2/i915drm/intelfb.c: revision 1.13
sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h: revisions 1.12, 1.13
sys/external/bsd/drm2/include/linux/mm.h: revision 1.5
sys/external/bsd/drm2/include/linux/pci.h: revisions 1.16, 1.17
sys/external/bsd/drm2/nouveau/nouveaufb.c: revision 1.2
sys/external/bsd/drm2/radeon/radeon_pci.c: revisions 1.8, 1.9
sys/uvm/uvm_init.c: revision 1.46
Hack against the blank console problem:
Leave the CLUT alone on ancient cards. At least this leaves us with a
semi working console (red and blue are flipped). Leave an example of what
seems to be happening but disable it because colors are better than 444 bit
greyscale.
--
Initialize P->V tracking for unmanaged device pages in uvm_init.

Conditional on __HAVE_PMAP_PV_TRACK until we add it to all pmaps.

MI part of pmap_pv(9) change proposed on tech-kern:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html
--
Implement pmap_pv(9) for x86 for P->V tracking of unmanaged pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html
--
Use pmap_pv(9) to remove mappings of Intel graphics aperture pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html

Further background at:

https://mail-index.netbsd.org/tech-kern/2014/07/23/msg017392.html
--
Use pmap_pv(9) to remove mappings of device pages in TTM.

Adapt nouveau and radeon to do pmap_pv_track for their device pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html

Further background at:

https://mail-index.netbsd.org/tech-kern/2014/07/23/msg017392.html
--
Fix error branches in agp_amd64.c.

- agp_generic_detach always.
- Free asc if it was allocated. (Found by Brainy, noted by maxv@.)
- Free the GATT if it was allocated.
--
pmf_device_register returns false on failure, not true
--
In DRM_SPIN_WAIT_ON, don't stop after waiting only one tick.

Continue the loop to recheck the condition and count the whole
duration.
--
Don't use the video BIOS memory as an i915 flush page!
--
Don't let anyone else allocate the video BIOS either.
--
Missed a zero: it's 0x100000, not 0x10000.
--
Don't reserve if atomic -- caller must have pre-pinned the buffer.
--
Don't reserve if atomic -- caller must have pre-pinned the buffer.
--
almost add radeondrmkms suspend/resume support. it unfortunately doesn't work.
--
Need the page's uvm object lock to do pmap_page_protect.
--
Use KASSERTMSG to show bad base/offset.
--
KASSERT about page-alignment on initialization too.
--
Don't break when hardclock_ticks wraps around.

Since we now only count time spent in wait, rather than determining
the end time and checking whether we've passed it, timeouts might be
marginally longer in effect. Unlikely to be an issue.
--
Remove broken drm2 vm_mmap stub. Can't possibly have ever worked.
--
apply some of the additional changes from Arto Huusko in PR#49645:
- call pmf_device_deregister on detach.

i've kept the "resume = true" for radeon_resume_kms() call as it
seems to work for me (indeed, code inspection shows it is unused
on netbsd :-)

my old nforce4 box that can resume old drm (or could, last i tried
several years ago) while X and GL apps were running, can at least
survive a resume if X hasn't started. my one attempt so far with
X exited, but having run, did not work.
--
First attempt to make ttm_buffer_object_transfer less bogus.
--
Make sure mem.bus.is_iomem is initialized. PR 49833
 1.112.2.2 17-Mar-2015  riz Pull up following revision(s) (requested by snj in ticket #590):
sys/external/bsd/drm2/i915drm/intel_gtt.c: revision 1.5
sys/external/bsd/drm2/drm/drm_drv.c: revision 1.15
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.28
sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/clock/nouveau_subdev_clock_nv50.c: revision 1.3
sys/dev/pci/agp_i810.c: revision 1.115
sys/dev/pci/agp_i810.c: revision 1.116
sys/external/bsd/drm2/include/drm/intel-gtt.h: revision 1.5
sys/dev/pci/agp_i810.c: revision 1.117
sys/external/bsd/drm2/drm/drm_gem_vm.c: revision 1.6
sys/dev/pci/agp_i810var.h: revision 1.6
Issue a write barrier after updating the GTT.
Linux never used to do this...until a month:
<a rel="nofollow" href="https://bugs.freedesktop.org/show_bug.cgi?id=88191">https://bugs.freedesktop.org/show_bug.cgi?id=88191</a>
commit 983d308cb8f602d1920a8c40196eb2ab6cc07bd2
Author: Chris Wilson &lt;chris%chris-wilson.co.uk@localhost&gt;
Date: Mon Jan 26 10:47:10 2015 +0000
agp/intel: Serialise after GTT updates
Include &lt;sys/atomic.h&gt; for membar_producer.
(Why didn't this fail in my build?)
Pass cache-related flags through to the GTT on pre-SNB devices.
I had assumed for ages this would increase the amount of caching and
thereby increase the chance of stale caches leading to rendering
glitches. But apparently I was wrong, and failing to pass these
through was causing all sorts of problems!
Dedup the NetBSD portion of the code (ok Riastradh), no functional change.
Don't return events that are too large and leave them in the list.
Apply access control to gem mmap.
fix gcc is stupid.
 1.112.2.1 18-Sep-2014  martin Pull up following revision(s) (requested by riastradh in ticket #94):
sys/dev/pci/agp_i810.c: revision 1.113
sys/dev/pci/agp_i810.c: revision 1.114
Revert to mapping the whole GTTMMADR region all at once for now and
use the right BAR for MMIO register sizing on i810.
 1.114.2.3 29-May-2016  skrll Sync with HEAD
 1.114.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.114.2.1 06-Apr-2015  skrll Sync with HEAD
 1.122.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.122.18.1 10-Jun-2019  christos Sync with HEAD
 1.122.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.122.10.1 31-Aug-2018  martin Pull up following revision(s) (requested by riastradh in ticket #998):

sys/dev/pci/agp_i810var.h: revision 1.7
sys/external/bsd/drm2/i915drm/intel_gtt.c: revision 1.7
sys/dev/pci/agp_i810.c: revision 1.123

Restore gtt page table control register on resume.

Additional subroutine agp_i810_reset is used by i915drmkms to make
sure it happens early enough, since i915drmkms resumes before agp.

XXX pullup-7
XXX pullup-8
 1.125.4.1 03-Feb-2024  martin Pull up following revision(s) (requested by riastradh in ticket #574):

sys/dev/pci/agp_i810.c: revision 1.126

agp_i810(4): Use ipi(9) for chipset flush on all CPUs, not xcall(9).

i915 now calls into this with a spin lock held, so we have to use
ipi(9), which spin-waits for the other CPUs to complete, rather than
xcall(9), which may sleep-wait.

Fortunately, this is just to execute WBINVD on x86 (and if this code
ever runs on other architectures, which it probably doesn't, it'll be
a similar barrier instruction), so spinning to wait for that on all
CPUs isn't too costly.

PR kern/57878
 1.7 27-Aug-2018  riastradh Restore gtt page table control register on resume.

Additional subroutine agp_i810_reset is used by i915drmkms to make
sure it happens early enough, since i915drmkms resumes before agp.

XXX pullup-7
XXX pullup-8
 1.6 06-Mar-2015  riastradh branches: 1.6.10; 1.6.16; 1.6.18;
Pass cache-related flags through to the GTT on pre-SNB devices.

I had assumed for ages this would increase the amount of caching and
thereby increase the chance of stale caches leading to rendering
glitches. But apparently I was wrong, and failing to pass these
through was causing all sorts of problems!
 1.5 10-Jun-2014  riastradh branches: 1.5.2; 1.5.4; 1.5.6;
Another round of weed-whacking for agp_i810.

- Make struct agp_i810_softc::gatt specific to i810 chipsets; use other
members of struct agp_i810_softc for non-i810 chipsets.

- agp_i810_init detects and sets isc->gtt_size.

- Map GTT based on the GTT size detected by agp_i810_init.

- Sprinkle some comments particularly about questionable calculations.
 1.4 27-May-2014  riastradh Rework agp_i810 attachment code a little.

- Fix up error branches in agp_i810_attach.

- Use a separate bus space handle for the GTT, whether it is in a
separate BAR or a subregion of the MMIO device registers, so that

(a) agp_i810_write_gtt_entry and agp_i810_post_gtt_entry are easier to
follow, and

(b) we can map the GTT prefetchable eventually.
 1.3 23-May-2014  riastradh Implement Intel AGP chipset flush.

While here, fix the use of the I915 PCI MSAC register: it lies on the
bridge device (bus 0 dev 0 func 0), not the graphics device (bus 0
dev 2 func 0). I'm not sure we ever need to consult this register,
really -- the PCI BARs should be sized. But I'll leave a rototill of
this mess for another day.
 1.2 18-Mar-2014  riastradh branches: 1.2.2; 1.2.4; 1.2.6;
Merge riastradh-drm2 to HEAD.
 1.1 05-Mar-2014  riastradh branches: 1.1.2;
file agp_i810var.h was initially added on branch riastradh-drm2.
 1.1.2.2 05-Mar-2014  riastradh Expose agp_i810_write_gtt_entry for drm2.

Also add an agp_i810_post_gtt_entry to do a posting read for that GTT
entry.
 1.1.2.1 05-Mar-2014  riastradh Expose the agp_i810 softc.

This is an Intel-specific kludge so that i915drmkms can get at the
GTT, graphics translation table, for pre-Sandy Bridge Intel graphics
devices.
 1.2.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.6.1 18-Mar-2014  yamt file agp_i810var.h was added on branch yamt-pagecache on 2014-05-22 11:40:24 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 18-Mar-2014  rmind file agp_i810var.h was added on branch rmind-smpnet on 2014-05-18 17:45:39 +0000
 1.2.2.1 10-Aug-2014  tls Rebase.
 1.5.6.1 06-Apr-2015  skrll Sync with HEAD
 1.5.4.3 03-Dec-2017  jdolecek update from HEAD
 1.5.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.4.1 10-Jun-2014  tls file agp_i810var.h was added on branch tls-maxphys on 2014-08-20 00:03:41 +0000
 1.5.2.1 17-Mar-2015  riz Pull up following revision(s) (requested by snj in ticket #590):
sys/external/bsd/drm2/i915drm/intel_gtt.c: revision 1.5
sys/external/bsd/drm2/drm/drm_drv.c: revision 1.15
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.28
sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/clock/nouveau_subdev_clock_nv50.c: revision 1.3
sys/dev/pci/agp_i810.c: revision 1.115
sys/dev/pci/agp_i810.c: revision 1.116
sys/external/bsd/drm2/include/drm/intel-gtt.h: revision 1.5
sys/dev/pci/agp_i810.c: revision 1.117
sys/external/bsd/drm2/drm/drm_gem_vm.c: revision 1.6
sys/dev/pci/agp_i810var.h: revision 1.6
Issue a write barrier after updating the GTT.
Linux never used to do this...until a month:
<a rel="nofollow" href="https://bugs.freedesktop.org/show_bug.cgi?id=88191">https://bugs.freedesktop.org/show_bug.cgi?id=88191</a>
commit 983d308cb8f602d1920a8c40196eb2ab6cc07bd2
Author: Chris Wilson &lt;chris%chris-wilson.co.uk@localhost&gt;
Date: Mon Jan 26 10:47:10 2015 +0000
agp/intel: Serialise after GTT updates
Include &lt;sys/atomic.h&gt; for membar_producer.
(Why didn't this fail in my build?)
Pass cache-related flags through to the GTT on pre-SNB devices.
I had assumed for ages this would increase the amount of caching and
thereby increase the chance of stale caches leading to rendering
glitches. But apparently I was wrong, and failing to pass these
through was causing all sorts of problems!
Dedup the NetBSD portion of the code (ok Riastradh), no functional change.
Don't return events that are too large and leave them in the list.
Apply access control to gem mmap.
fix gcc is stupid.
 1.6.18.1 10-Jun-2019  christos Sync with HEAD
 1.6.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.10.1 31-Aug-2018  martin Pull up following revision(s) (requested by riastradh in ticket #998):

sys/dev/pci/agp_i810var.h: revision 1.7
sys/external/bsd/drm2/i915drm/intel_gtt.c: revision 1.7
sys/dev/pci/agp_i810.c: revision 1.123

Restore gtt page table control register on resume.

Additional subroutine agp_i810_reset is used by i915drmkms to make
sure it happens early enough, since i915drmkms resumes before agp.

XXX pullup-7
XXX pullup-8
 1.39 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.38 05-Feb-2019  mrg fix a >15 year old code rework bug, and add a missing break;.

the code in rev 1.7 looks like it does in this change, but rev 1.8 would
write the I443 AGP_INTEL_AGPCTRL value, and then the other value.
 1.37 04-Apr-2011  dyoung branches: 1.37.48; 1.37.56;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.36 13-Nov-2010  uebayasi branches: 1.36.2;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.35 04-Apr-2010  jakllsch Add (non-IGP) AGP port support for Intel 82855GM.
agp_intel tested with radeondrm(4). agp_i810 tested with i915drm(4).
 1.34 24-Feb-2010  dyoung branches: 1.34.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.33 08-Jan-2010  dyoung branches: 1.33.2;
Expand PMF_FN_* macros.
 1.32 09-Jun-2008  freza branches: 1.32.8;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.31 10-Apr-2008  cegger branches: 1.31.2; 1.31.4; 1.31.6;
use aprint_*_dev and device_xname
 1.30 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.29 21-Feb-2008  drochner clean up the error bit clear code:
-use an aligned pci config space address as everyone else -- I'm sorry
about that because I like gson's way a lot -- it keeps the address
offset due to alignment visually close to the data shift --, but since
aligned addresses are used everywhere else in definitions, this
causes confusion
-the mask applied to the data didn't make much sense, a look at the
FreeBSD code where this code originates from suggests that there
was just a mistake -- one trailing zero missing --
anyway, the datasheet tells that the error bits are all write-one-
to-clear, so just write back the value and we are done
 1.28 15-Feb-2008  gson branches: 1.28.2; 1.28.6;
Fix unaligned write to PCI configuration space. Should fix PR kern/37824.
 1.27 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.26 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.25 09-Dec-2007  jmcneill branches: 1.25.2;
Merge jmcneill-pm branch.
 1.24 12-Nov-2007  joerg branches: 1.24.2; 1.24.4;
Merge bunch of AGP changes from jmcneill-pm.
 1.23 19-Oct-2007  ad branches: 1.23.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.22 26-Mar-2007  hubertf branches: 1.22.8; 1.22.10; 1.22.14;
Remove duplicate include of <sys/agpio.h>
From: Slava Semushin <php-coder@altlinux.ru>
 1.21 16-Nov-2006  christos branches: 1.21.4; 1.21.8; 1.21.10; 1.21.12;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.18 11-Mar-2006  jmcneill branches: 1.18.10; 1.18.12;
Add Intel AGP powerhook. Tested on an 82855PM.
 1.17 16-Jan-2006  christos branches: 1.17.2; 1.17.4; 1.17.6; 1.17.8;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.16 11-Dec-2005  christos branches: 1.16.2;
merge ktrace-lwp.
 1.15 28-Jun-2005  thorpej branches: 1.15.2;
Use ANSI function decls and static.
 1.14 26-Aug-2003  tron branches: 1.14.14;
Rework support for i845, i865 and i875P. agp(4) now doesn't "kill" the
i82547EI on my i865PE motherboard any longer.
 1.13 26-Aug-2003  tron Replaces space with tabs.
 1.12 22-Jul-2003  simonb Clean up autoconfiguration output a little.
 1.11 06-Jul-2003  tron Handle i865 and i875P chipsets like the i845. This works good enough to
make XFree86 work with agp(4) enabled on an i865PE motherboard.
 1.10 25-Jun-2003  ichiro branches: 1.10.2;
The problem which stops in the middle of booting was solved.

(kern/21843 Brian Stark <bpstark@pacbell.net>)
 1.9 14-Jun-2003  ichiro make compile
 1.8 14-Jun-2003  ichiro fix some bugs
 1.7 09-Jun-2003  ichiro fix bug report - xsrc/17810, kern/16898

add AGP configuration registers for i840/855PM, i840/i850E, 82443LX/BX/GX
Although there chips are well alike, but initialization and so on procedures differ.
 1.6 31-Jan-2003  thorpej Use aprint_*().
 1.5 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.4 13-Nov-2001  lukem add RCSID
 1.3 15-Sep-2001  thorpej branches: 1.3.2; 1.3.4;
Clean up the AGP match/attach code somewhat.
 1.2 11-Sep-2001  fvdl branches: 1.2.2;
Don't forget to install the pointer to the chip-specific chipc.
 1.1 10-Sep-2001  fvdl AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.2.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.2.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.2.1 11-Sep-2001  thorpej file agp_intel.c was added on branch kqueue on 2001-09-13 01:15:51 +0000
 1.3.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.3.4.1 15-Sep-2001  fvdl file agp_intel.c was added on branch thorpej-devvp on 2001-10-01 12:45:51 +0000
 1.3.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.3.2.1 15-Sep-2001  nathanw file agp_intel.c was added on branch nathanw_sa on 2001-09-21 22:35:53 +0000
 1.10.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.14.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.15.2.8 17-Mar-2008  yamt sync with head.
 1.15.2.7 27-Feb-2008  yamt sync with head.
 1.15.2.6 21-Jan-2008  yamt sync with head
 1.15.2.5 15-Nov-2007  yamt sync with head.
 1.15.2.4 27-Oct-2007  yamt sync with head.
 1.15.2.3 03-Sep-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.2.1 01-Feb-2006  yamt sync with head.
 1.17.8.1 19-Apr-2006  elad sync with head.
 1.17.6.1 13-Mar-2006  yamt sync with head.
 1.17.4.1 22-Apr-2006  simonb Sync with head.
 1.17.2.1 09-Sep-2006  rpaulo sync with head
 1.18.12.2 10-Dec-2006  yamt sync with head.
 1.18.12.1 22-Oct-2006  yamt sync with head
 1.18.10.1 18-Nov-2006  ad Sync with head.
 1.21.12.1 29-Mar-2007  reinoud Pullup to -current
 1.21.10.1 11-Jul-2007  mjf Sync with head.
 1.21.8.2 23-Oct-2007  ad Sync with head.
 1.21.8.1 10-Apr-2007  ad Sync with head.
 1.21.4.1 15-Apr-2007  yamt sync with head.
 1.22.14.2 13-Nov-2007  bouyer Sync with HEAD
 1.22.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.10.3 23-Mar-2008  matt sync with HEAD
 1.22.10.2 09-Jan-2008  matt sync with HEAD
 1.22.10.1 06-Nov-2007  matt sync with HEAD
 1.22.8.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.22.8.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.22.8.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.8.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.22.8.1 08-Aug-2007  jmcneill Add Intel (older version) AGP power management support.
 1.23.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.23.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.23.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.24.4.1 11-Dec-2007  yamt sync with head.
 1.24.2.1 26-Dec-2007  ad Sync with head.
 1.25.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.25.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.28.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.28.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.28.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.28.2.1 24-Mar-2008  keiichi sync with head.
 1.31.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.31.4.3 11-Aug-2010  yamt sync with head.
 1.31.4.2 11-Mar-2010  yamt sync with head
 1.31.4.1 04-May-2009  yamt sync with head.
 1.31.2.1 17-Jun-2008  yamt sync with head.
 1.32.8.1 20-Nov-2010  riz Pull up following revision(s) (requested by jakllsch in ticket #1362):
sys/dev/pci/pcidevs: revision 1.1026
sys/dev/pci/agp_intel.c: revision 1.35
sys/dev/pci/agp_i810.c: revision 1.67
Add Intel 82855GM Host-AGP Bridge.
regen
Add (non-IGP) AGP port support for Intel 82855GM.
agp_intel tested with radeondrm(4). agp_i810 tested with i915drm(4).
 1.33.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.2.3 21-Apr-2011  rmind sync with head
 1.34.2.2 05-Mar-2011  rmind sync with head
 1.34.2.1 30-May-2010  rmind sync with head
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.56.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.56.1 10-Jun-2019  christos Sync with HEAD
 1.37.48.1 01-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1311):

sys/dev/pci/agp_intel.c: revision 1.38

fix a >15 year old code rework bug, and add a missing break;.

the code in rev 1.7 looks like it does in this change, but rev 1.8 would
write the I443 AGP_INTEL_AGPCTRL value, and then the other value.
 1.15 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.14 13-Nov-2010  uebayasi branches: 1.14.60;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.13 09-Jun-2008  freza branches: 1.13.20;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.12 04-Jan-2008  ad branches: 1.12.6; 1.12.8; 1.12.10; 1.12.12;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.11 19-Oct-2007  ad branches: 1.11.2; 1.11.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.10 16-Nov-2006  christos branches: 1.10.8; 1.10.22; 1.10.24; 1.10.28;
__unused removal on arguments; approved by core.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 16-Jan-2006  christos branches: 1.8.18; 1.8.20;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.7 11-Dec-2005  christos branches: 1.7.2;
merge ktrace-lwp.
 1.6 28-Jun-2005  thorpej branches: 1.6.2;
Use ANSI function decls and static.
 1.5 27-Feb-2005  perry branches: 1.5.2;
nuke trailing whitespace
 1.4 31-Jan-2003  thorpej branches: 1.4.2; 1.4.10; 1.4.12;
Use aprint_*().
 1.3 13-Nov-2001  lukem add RCSID
 1.2 15-Sep-2001  thorpej branches: 1.2.2; 1.2.4;
Clean up the AGP match/attach code somewhat.
 1.1 10-Sep-2001  fvdl branches: 1.1.2;
AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.1.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.2.1 10-Sep-2001  thorpej file agp_sis.c was added on branch kqueue on 2001-09-13 01:15:51 +0000
 1.2.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.1 15-Sep-2001  fvdl file agp_sis.c was added on branch thorpej-devvp on 2001-10-01 12:45:51 +0000
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 15-Sep-2001  nathanw file agp_sis.c was added on branch nathanw_sa on 2001-09-21 22:35:53 +0000
 1.4.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.10.1 29-Apr-2005  kent sync with -current
 1.4.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.6.2.3 21-Jan-2008  yamt sync with head
 1.6.2.2 27-Oct-2007  yamt sync with head.
 1.6.2.1 21-Jun-2006  yamt sync with head.
 1.7.2.1 01-Feb-2006  yamt sync with head.
 1.8.20.2 10-Dec-2006  yamt sync with head.
 1.8.20.1 22-Oct-2006  yamt sync with head
 1.8.18.1 18-Nov-2006  ad Sync with head.
 1.10.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.24.2 09-Jan-2008  matt sync with HEAD
 1.10.24.1 06-Nov-2007  matt sync with HEAD
 1.10.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.10.8.1 23-Oct-2007  ad Sync with head.
 1.11.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.11.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.12.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.10.1 04-May-2009  yamt sync with head.
 1.12.8.1 17-Jun-2008  yamt sync with head.
 1.12.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.13.20.1 05-Mar-2011  rmind sync with head
 1.14.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.21 19-Feb-2011  jmcneill branches: 1.21.56;
more AGP v3 fixes from FreeBSD:
- fix a typo when enabling the aperture (read wrong register)
- get_aperture/set_aperture: handle AGP v3 APSIZE register layout
 1.20 15-Feb-2011  jmcneill print AGP mode (v3/v2compat/v2) with aprint_debug instead of aprint_normal
 1.19 13-Nov-2010  uebayasi branches: 1.19.2; 1.19.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.18 31-Jan-2010  hubertf branches: 1.18.4;
Replace more printfs with aprint_normal / aprint_verbose
Makes "boot -z" go mostly silent for me.
 1.17 09-Jun-2008  freza branches: 1.17.8; 1.17.16;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.16 11-Mar-2008  joerg branches: 1.16.2; 1.16.4; 1.16.6;
Avoid unaligned pci_conf_read.
 1.15 04-Jan-2008  ad branches: 1.15.2; 1.15.6;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.14 19-Oct-2007  ad branches: 1.14.2; 1.14.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 27-Mar-2007  jmcneill branches: 1.13.8; 1.13.10; 1.13.14;
Instead of having a lookup table of devices that support AGP V3, use the
capabilities register to determine the chipset's supported AGP mode. We
still fallback to V2 compatibility mode when necessary.
 1.12 27-Mar-2007  jmcneill Add AGPv3 support to VIA AGP driver from FreeBSD.
I can now use DRI w/ AGP enabled on my r300.
 1.11 16-Nov-2006  christos branches: 1.11.4; 1.11.8; 1.11.10; 1.11.12;
__unused removal on arguments; approved by core.
 1.10 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9 16-Jan-2006  christos branches: 1.9.18; 1.9.20;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.8 11-Dec-2005  christos branches: 1.8.2;
merge ktrace-lwp.
 1.7 28-Jun-2005  thorpej branches: 1.7.2;
Use ANSI function decls and static.
 1.6 27-Feb-2005  perry branches: 1.6.2;
nuke trailing whitespace
 1.5 31-Jan-2003  thorpej branches: 1.5.2; 1.5.10; 1.5.12;
Use aprint_*().
 1.4 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.3 13-Nov-2001  lukem add RCSID
 1.2 15-Sep-2001  thorpej branches: 1.2.2; 1.2.4;
Clean up the AGP match/attach code somewhat.
 1.1 10-Sep-2001  fvdl branches: 1.1.2;
AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.1.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.2.1 10-Sep-2001  thorpej file agp_via.c was added on branch kqueue on 2001-09-13 01:15:51 +0000
 1.2.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.1 15-Sep-2001  fvdl file agp_via.c was added on branch thorpej-devvp on 2001-10-01 12:45:52 +0000
 1.2.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 15-Sep-2001  nathanw file agp_via.c was added on branch nathanw_sa on 2001-09-21 22:35:53 +0000
 1.5.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.7.2.5 17-Mar-2008  yamt sync with head.
 1.7.2.4 21-Jan-2008  yamt sync with head
 1.7.2.3 27-Oct-2007  yamt sync with head.
 1.7.2.2 03-Sep-2007  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.8.2.1 01-Feb-2006  yamt sync with head.
 1.9.20.2 10-Dec-2006  yamt sync with head.
 1.9.20.1 22-Oct-2006  yamt sync with head
 1.9.18.1 18-Nov-2006  ad Sync with head.
 1.11.12.1 29-Mar-2007  reinoud Pullup to -current
 1.11.10.1 11-Jul-2007  mjf Sync with head.
 1.11.8.2 23-Oct-2007  ad Sync with head.
 1.11.8.1 10-Apr-2007  ad Sync with head.
 1.11.4.1 15-Apr-2007  yamt sync with head.
 1.13.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.10.3 23-Mar-2008  matt sync with HEAD
 1.13.10.2 09-Jan-2008  matt sync with HEAD
 1.13.10.1 06-Nov-2007  matt sync with HEAD
 1.13.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.14.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.15.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.15.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.2.1 24-Mar-2008  keiichi sync with head.
 1.16.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.16.4.2 11-Mar-2010  yamt sync with head
 1.16.4.1 04-May-2009  yamt sync with head.
 1.16.2.1 17-Jun-2008  yamt sync with head.
 1.17.16.1 21-Apr-2010  matt sync to netbsd-5
 1.17.8.2 19-May-2011  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1560):
sys/sys/agpio.h: revision 1.10
sys/dev/pci/agp_via.c: revision 1.21
sys/dev/pci/agp.c: revision 1.77
add AGP v3 support to agp_generic_enable from FreeBSD
 1.17.8.1 14-Feb-2010  bouyer Pull up following revision(s) (requested by hubertf in ticket #1290):
sys/kern/kern_ksyms.c: revision 1.53
sys/dev/pci/agp_via.c: revision 1.18
sys/netipsec/key.c: revision 1.63
sys/arch/x86/x86/x86_autoconf.c: revision 1.49
sys/kern/init_main.c: revision 1.415
sys/kern/cnmagic.c: revision 1.11
sys/netipsec/ipsec.c: revision 1.47
sys/arch/x86/x86/pmap.c: revision 1.100
sys/netkey/key.c: revision 1.176
Replace more printfs with aprint_normal / aprint_verbose
Makes "boot -z" go mostly silent for me.
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.19.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.19.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.19.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.56.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 11-Dec-2005  christos branches: 1.3.20; 1.3.22;
merge ktrace-lwp.
 1.2 24-May-2005  lukem branches: 1.2.2;
add __KERNEL_RCSID
 1.1 30-Aug-2004  drochner branches: 1.1.2;
add centralized {eisa,isa,pci,agp,mca}busprint() functions which do
what tens of the bus' parents foo{...}bridge_print()s scattered around do
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Sep-2004  skrll Sync with HEAD
 1.1.2.1 30-Aug-2004  skrll file agpbusprint.c was added on branch ktrace-lwp on 2004-09-03 12:45:27 +0000
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.22.2 10-Dec-2006  yamt sync with head.
 1.3.22.1 22-Oct-2006  yamt sync with head
 1.3.20.1 18-Nov-2006  ad Sync with head.
 1.24 27-Feb-2017  msaitoh Decode AGP capability.
 1.23 01-May-2016  nonaka branches: 1.23.2; 1.23.4;
kern/50453: Separate Pineview chipset from i915-family chipset support.

Should use AGP_I965_IFPADDR instead AGP_I915_IFPADDR in Pineview, becuase
AGP_I915_IFPADDR is used as PCIEXBAR.
 1.22 12-Jun-2014  riastradh branches: 1.22.4;
Get GTT size from PGTBL_CTL on G4X chipsets.
 1.21 23-May-2014  riastradh Implement Intel AGP chipset flush.

While here, fix the use of the I915 PCI MSAC register: it lies on the
bridge device (bus 0 dev 0 func 0), not the graphics device (bus 0
dev 2 func 0). I'm not sure we ever need to consult this register,
really -- the PCI BARs should be sized. But I'll leave a rototill of
this mess for another day.
 1.20 29-Nov-2008  christos branches: 1.20.26; 1.20.40;
Add support for the Intel G45 AGP. From Arnaud Lacombe
 1.19 11-Mar-2008  joerg branches: 1.19.4; 1.19.10; 1.19.12; 1.19.14; 1.19.18;
Avoid unaligned pci_conf_read.
 1.18 21-Feb-2008  drochner clean up the error bit clear code:
-use an aligned pci config space address as everyone else -- I'm sorry
about that because I like gson's way a lot -- it keeps the address
offset due to alignment visually close to the data shift --, but since
aligned addresses are used everywhere else in definitions, this
causes confusion
-the mask applied to the data didn't make much sense, a look at the
FreeBSD code where this code originates from suggests that there
was just a mistake -- one trailing zero missing --
anyway, the datasheet tells that the error bits are all write-one-
to-clear, so just write back the value and we are done
 1.17 15-Jan-2008  drochner branches: 1.17.2; 1.17.6;
fix some PCI config space offsets to be 32-bit aligned, the code
did already do the right bit shifting
 1.16 24-Nov-2007  markd branches: 1.16.6;
Add agp support for Intel Q35/G33/Q33.
 1.15 12-Nov-2007  joerg Merge bunch of AGP changes from jmcneill-pm.
 1.14 15-Aug-2007  markd branches: 1.14.2; 1.14.6; 1.14.8;
Add agp support for i965Q.

Based on a patch for FreeBSD by Eric Anholt.
OKed on tech-kern some months ago.
 1.13 04-Aug-2007  kiyohara branches: 1.13.2;
Add support agp_amd64. Imported from FreeBSD.
 1.12 20-Jun-2007  sborrill branches: 1.12.2; 1.12.6;
Support more i915 stolen memory configurations (previous limit was 8MB,
some configurations steal up to 64MB). OK christos@
 1.11 27-Mar-2007  jmcneill Add AGPv3 support to VIA AGP driver from FreeBSD.
I can now use DRI w/ AGP enabled on my r300.
 1.10 16-Jan-2006  christos branches: 1.10.24; 1.10.28; 1.10.30; 1.10.32;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.9 11-Dec-2005  christos branches: 1.9.2;
merge ktrace-lwp.
 1.8 27-Feb-2005  perry branches: 1.8.2; 1.8.4;
nuke trailing whitespace
 1.7 04-Feb-2004  soren branches: 1.7.8; 1.7.10;
Use the right bits for the AGP version.
 1.6 20-Jul-2003  hannken Add support for i855 agp. From FreeBSD.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.5 25-Jun-2003  ichiro branches: 1.5.2;
The problem which stops in the middle of booting was solved.

(kern/21843 Brian Stark <bpstark@pacbell.net>)
 1.4 14-Jun-2003  ichiro fix some bugs
 1.3 09-Jun-2003  ichiro fix bug report - xsrc/17810, kern/16898

add AGP configuration registers for i840/855PM, i840/i850E, 82443LX/BX/GX
Although there chips are well alike, but initialization and so on procedures differ.
 1.2 13-Dec-2002  scw Add support for i830/i845 agp. From Shingo WATANABE (on tech-x11) and
FreeBSD, with cleanup/KNF by me.

Note: These chipsets are not well supported by the i810 driver in
NetBSD's in-tree xsrc (based on XFree86 4.2.1 at this time). However,
the driver works perfectly using bleeding-edge XFree86-current on my
Omnibook's i830MG with these agp changes.
 1.1 10-Sep-2001  fvdl branches: 1.1.2; 1.1.4; 1.1.6;
AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.1.6.2 01-Oct-2001  fvdl Catch up with -current.
 1.1.6.1 10-Sep-2001  fvdl file agpreg.h was added on branch thorpej-devvp on 2001-10-01 12:45:52 +0000
 1.1.4.3 19-Dec-2002  thorpej Sync with HEAD.
 1.1.4.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.4.1 10-Sep-2001  nathanw file agpreg.h was added on branch nathanw_sa on 2001-09-21 22:35:53 +0000
 1.1.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.2.1 10-Sep-2001  thorpej file agpreg.h was added on branch kqueue on 2001-09-13 01:15:51 +0000
 1.5.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.8.4.7 17-Mar-2008  yamt sync with head.
 1.8.4.6 27-Feb-2008  yamt sync with head.
 1.8.4.5 21-Jan-2008  yamt sync with head
 1.8.4.4 07-Dec-2007  yamt sync with head
 1.8.4.3 15-Nov-2007  yamt sync with head.
 1.8.4.2 03-Sep-2007  yamt sync with head.
 1.8.4.1 21-Jun-2006  yamt sync with head.
 1.8.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.9.2.1 01-Feb-2006  yamt sync with head.
 1.10.32.1 29-Mar-2007  reinoud Pullup to -current
 1.10.30.1 11-Jul-2007  mjf Sync with head.
 1.10.28.3 20-Aug-2007  ad Sync with HEAD.
 1.10.28.2 15-Jul-2007  ad Sync with head.
 1.10.28.1 10-Apr-2007  ad Sync with head.
 1.10.24.1 15-Apr-2007  yamt sync with head.
 1.12.6.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.12.6.3 06-Sep-2007  jmcneill Add Intel G33 AGP support, resolves PR36902, PR36903, PR36904, PR36906,
PR36907, PR36908, PR36909, PR36910, PR36911, PR36912, PR36913, and PR36925.
 1.12.6.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.12.6.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.12.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.13.2.2 04-Aug-2007  kiyohara Add support agp_amd64. Imported from FreeBSD.
 1.13.2.1 04-Aug-2007  kiyohara file agpreg.h was added on branch matt-mips64 on 2007-08-04 09:33:06 +0000
 1.14.8.3 18-Feb-2008  mjf Sync with HEAD.
 1.14.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.14.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.14.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.14.2.2 23-Mar-2008  matt sync with HEAD
 1.14.2.1 09-Jan-2008  matt sync with HEAD
 1.16.6.1 19-Jan-2008  bouyer Sync with HEAD
 1.17.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.17.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.2.1 24-Mar-2008  keiichi sync with head.
 1.19.18.1 21-Apr-2010  matt sync to netbsd-5
 1.19.14.1 05-May-2009  bouyer Pull up following revision(s) (requested by snj in ticket #737):
sys/arch/x86/pci/pchb.c: revisions 1.15 - 1.17
sys/dev/pci/agp.c: revisions 1.63 - 1.65
sys/dev/pci/agp_i810.c: revisions 1.57 - 1.64
sys/dev/pci/pcidevs: revisions 1.965, 1.967 via patch
sys/dev/pci/agpreg.h: revision 1.20
Add AGP support for Intel G35, G45, and Q45.
 1.19.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.19.4.1 04-May-2009  yamt sync with head.
 1.20.40.1 10-Aug-2014  tls Rebase.
 1.20.26.2 03-Dec-2017  jdolecek update from HEAD
 1.20.26.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.4.2 28-Aug-2017  skrll Sync with HEAD
 1.22.4.1 29-May-2016  skrll Sync with HEAD
 1.23.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.23.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.22 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.21 02-Nov-2014  christos make the apple code compile again.
 1.20 12-Jun-2014  riastradh Extend agp_generic_bind_memory with bounds to check.

New routine agp_generic_bind_memory_bounded.

Use it in agp_i810 to replace the pile of code I wrote as a
replacement which is apparently broken.
 1.19 12-Jun-2014  riastradh Check bounds in agp_i810_borrow.

Out of paranoia, do a bus_space_subregion in case the old drm code
tries sizes that the agp_i810 code doesn't agree with.
 1.18 06-May-2009  cegger branches: 1.18.22; 1.18.36;
struct device * -> device_t, no functional changes intended.
 1.17 09-Jun-2008  freza branches: 1.17.12;
o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
 1.16 22-Feb-2008  drochner branches: 1.16.2; 1.16.4; 1.16.6;
Add a horrible hack to allow the DRM driver to get at the bus_space_handle
allocated by the AGP driver in the case of Intel chipset graphics.
This is different from the patch by Yorick Hardy circulated a while ago
in that it doesn't change the semantics of reference counting within
the (3rd-party) DRM code -- it just bypasses it.
Needless to say that it is uglier, but it eases future updates to
the DRM code because the change there is just 2 LOC.

Imo, a cleaner solution for all that would be to attach "agp" to "vga"
in the intel chipset graphics case, which better reflects how the hardware
is structured. This would still need a hack to the DRM code, but
it would be confined to childs of the "vga" device, without need for
global variables.
Since there is a variety of intel chipsets with AGP and/or builtin
graphics options, this would need a considerable testing effort.
 1.15 04-Aug-2007  kiyohara branches: 1.15.2; 1.15.18; 1.15.22; 1.15.24;
Add support agp_amd64. Imported from FreeBSD.
 1.14 06-Mar-2007  xtraeme branches: 1.14.2; 1.14.10; 1.14.14;
Use a mutex rather than lockmgr. Approved by Andrew Doran.
 1.13 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 17-Aug-2006  christos branches: 1.12.8;
Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.11 16-Jan-2006  christos branches: 1.11.2; 1.11.6;
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.10 11-Dec-2005  christos branches: 1.10.2;
merge ktrace-lwp.
 1.9 27-Feb-2005  perry branches: 1.9.2; 1.9.4;
nuke trailing whitespace
 1.8 30-Aug-2004  drochner branches: 1.8.4; 1.8.6;
Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.7 30-Aug-2004  drochner add centralized {eisa,isa,pci,agp,mca}busprint() functions which do
what tens of the bus' parents foo{...}bridge_print()s scattered around do
 1.6 08-Jul-2003  itojun function prototype must not have variable name
 1.5 01-Feb-2003  thorpej branches: 1.5.2;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.4 01-Oct-2001  fvdl Don't map the aperture into KVA, it isn't needed.
 1.3 15-Sep-2001  thorpej branches: 1.3.2; 1.3.4;
Clean up the AGP match/attach code somewhat.
 1.2 11-Sep-2001  fvdl branches: 1.2.2;
Fix i810/other intel chipsets attach mishap.
 1.1 10-Sep-2001  fvdl AGP GART support code. Originally written by Doug Rabson for FreeBSD,
modifications to fit it into the NetBSD device/config structure and
to use bus_dma by me.
 1.2.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.2.1 11-Sep-2001  thorpej file agpvar.h was added on branch kqueue on 2001-09-13 01:15:52 +0000
 1.3.4.3 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.3.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.3.4.1 15-Sep-2001  fvdl file agpvar.h was added on branch thorpej-devvp on 2001-10-01 12:45:52 +0000
 1.3.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.3.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.3.2.1 15-Sep-2001  nathanw file agpvar.h was added on branch nathanw_sa on 2001-09-21 22:35:53 +0000
 1.5.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Sep-2004  skrll Sync with HEAD
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.9.4.4 27-Feb-2008  yamt sync with head.
 1.9.4.3 03-Sep-2007  yamt sync with head.
 1.9.4.2 30-Dec-2006  yamt sync with head.
 1.9.4.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.10.2.1 01-Feb-2006  yamt sync with head.
 1.11.6.1 03-Sep-2006  yamt sync with head.
 1.11.2.1 09-Sep-2006  rpaulo sync with head
 1.12.8.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.14.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.14.14.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.14.14.2 06-Aug-2007  jmcneill Move agp_i810_power to agp, since it does nothing specific to the i810
hardware. Allow agp front-ends to override the default power handler if
specific configuration needs to take place, and expose agp_power via
agpvar.h so the front-ends can call back to it to do generic initialization.
 1.14.14.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.14.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.14.2.1 20-Aug-2007  ad Sync with HEAD.
 1.15.24.2 04-Aug-2007  kiyohara Add support agp_amd64. Imported from FreeBSD.
 1.15.24.1 04-Aug-2007  kiyohara file agpvar.h was added on branch matt-mips64 on 2007-08-04 09:33:06 +0000
 1.15.22.2 29-Jun-2008  mjf Sync with HEAD.
 1.15.22.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.18.1 24-Mar-2008  keiichi sync with head.
 1.15.2.1 23-Mar-2008  matt sync with HEAD
 1.16.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.16.4.2 16-May-2009  yamt sync with head
 1.16.4.1 04-May-2009  yamt sync with head.
 1.16.2.1 17-Jun-2008  yamt sync with head.
 1.17.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.36.1 10-Aug-2014  tls Rebase.
 1.18.22.2 03-Dec-2017  jdolecek update from HEAD
 1.18.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.77 03-Oct-2025  thorpej Use device_{get,set}prop_bool() for "aic7xxx-use-target-defaults" and
"aic7xxx-override-ultra".
 1.76 27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.75 09-Feb-2024  andvar branches: 1.75.2;
fix spelling mistakes, mainly in comments and log messages.
 1.74 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.73 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.72 03-Jun-2018  maxv branches: 1.72.2;
Constify ahc_pci_ident_table[] so that it lands in .rodata (1488 bytes).
 1.71 14-Jul-2016  msaitoh branches: 1.71.16;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.70 29-Mar-2014  christos branches: 1.70.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.69 18-Feb-2014  macallan if MMIO is allowed and available, prefer it over PIO
now my ADPT,2930CU works again
 1.68 26-Nov-2009  njoly branches: 1.68.12; 1.68.22; 1.68.26;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.67 02-Sep-2009  tsutsui Call pmf_device_register(9) in ahc_attahc() rather than ahc_pci_attach()
since pmf_device_deregister(9) is called from ahc_detach() so that
cardbus backend also gets proper pmf(9) calls.
PCI backend is tested on on O2, but cardbus is untested.
 1.66 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.65 05-May-2009  cegger device_t/softc split
 1.64 03-Jan-2009  yamt branches: 1.64.2;
remove extra semicolons.
 1.63 22-Feb-2008  dyoung branches: 1.63.4; 1.63.12;
Use device_t and accessors. Use aprint_*_dev(). Use PMF_FN_*.
 1.62 28-Jan-2008  macallan branches: 1.62.2; 1.62.6;
get rid of the shutdown hook, add suspend and resume handlers instead
XXX: ahc_suspend panics here so suspend calls ahc_shutdown and resume does
nothing.
This fixes a hangup and subsequent panic which occured when the shutdown hooks
were called and /afterwards/ the sd suspend handler tried to flush caches
through an already shut down ahc.
 1.61 15-Dec-2007  tsutsui Rename a device property name: "override_ultra" -> "aic7xxx-override-ultra"
 1.60 19-Oct-2007  ad branches: 1.60.2; 1.60.4; 1.60.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.59 26-Sep-2007  macallan branches: 1.59.2;
allow to override the check for an external precision resistor via device
property so we can have 40MB/s on SGI O2
 1.58 16-Nov-2006  christos branches: 1.58.8; 1.58.22; 1.58.24; 1.58.26;
__unused removal on arguments; approved by core.
 1.57 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.56 10-Jul-2006  thorpej branches: 1.56.4; 1.56.6;
Put appropriate prefixes on property names to reduce chances of name
collisions.
 1.55 05-May-2006  thorpej branches: 1.55.4;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.54 15-Apr-2006  tsutsui Add AHC_USETARGETDEFAULTS to ahc_flag, which enables to
use default target (but not for host) device settings on
ahc(4) interface without its SEEPROM (mostly on-board one).

This flag could be useful if host's BIOS (firmware) initializes
ahc(4) chip with some conservative (async, no tagged queuing etc.)
target settings for minimum support to load its primary loader etc.,
and it will be enabled in each attachment according to MD device
properties(9). Currently this property is set only on sgimips for
O2 on-board aic7880 adapters.

No objection on tech-kern (and netbsd-bugs), and closes PR kern/23276.
 1.53 24-Dec-2005  perry branches: 1.53.4; 1.53.6; 1.53.8; 1.53.10; 1.53.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.52 11-Dec-2005  christos merge ktrace-lwp.
 1.51 28-Jun-2005  thorpej branches: 1.51.2;
Use ANSI function decls and static.
 1.50 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.49 27-Feb-2005  perry nuke trailing whitespace
 1.48 04-Feb-2005  perry de-__P
 1.47 17-Oct-2004  christos branches: 1.47.4; 1.47.6;
Bring back ALLOW_MEMIO change that was lost between 1.38 and 1.39. This
change reportedly makes the driver work on macppc. There must be a better
way of doing this (based on the chip revision?).
 1.46 16-Oct-2004  christos Make a commented out print statement compile and avoid wrapped lines.
No functional change.
 1.45 16-Mar-2004  simonb branches: 1.45.2;
Fix an assigned-to-but-not-used variable in the non AHC_ALLOW_MEMIO case.
 1.44 13-Jan-2004  augustss Print the device description in the attach routine like all other drivers do.
 1.43 18-Aug-2003  taca make ahc(4) to recognize Adaptec 2915LP Ultra160 SCSI adapter.
 1.42 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.41 04-Jun-2003  pk branches: 1.41.2;
ahc_pci_probe: avoid placeholder entries in the `identities' table.
 1.40 25-Apr-2003  fvdl On the first read of the DEVCONFIG PCI config register, sparc64 systems
seem to return all 1s. The second read is ok, though. So, as a workaround,
read it twice. From Manuel Bouyer.
 1.39 19-Apr-2003  fvdl Newer ahc driver, port from Justin Gibbs' driver in FreeBSD. Ported by
Pascal Renauld at Network Storage Solutions, Inc, with some changes
by me.
 1.38 31-Jan-2003  thorpej Use aprint_*().
 1.37 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.36 20-Jan-2003  simonb Remove variable that is only assigned too but not referenced.
 1.35 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.34 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.33 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.32 21-Nov-2001  wiz branches: 1.32.10;
Presence looks better with a 'c' instead of an 's'.
 1.31 13-Nov-2001  lukem add RCSID
 1.30 24-Mar-2001  christos branches: 1.30.2;
There was a stray debugging message "OptionMode = %x\n". Prefix it with
the device name, and enable it only in debugging mode.
 1.29 18-Jan-2001  jdolecek branches: 1.29.2;
constify
 1.28 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.27 24-Sep-2000  jdolecek use new generic bootverbose instead of local definition
 1.26 04-Sep-2000  soren Fix 'RAID unsupported' printf.
 1.25 04-Sep-2000  soren Add support for the AAA-131 RAID controller by treating it as a 7890.
Taken from rev 1.32 of the FreeBSD ahc_pci.c.
 1.24 10-May-2000  thorpej branches: 1.24.4;
Support Adaptec U2W cards with a 64-bit PCI memory range (such cards
are available with Power Macintosh G3 and G4 systems).
 1.23 16-Mar-2000  fvdl Set bus_intr to ahc_pci_intr.
 1.22 15-Mar-2000  fvdl PCI frontend for new ahc driver.
 1.21 26-Jan-2000  thorpej Remove the FreeBSD support from this file. It hasn't worked in FreeBSD
for some time, and only made the code harder to read.
 1.20 26-Jan-2000  thorpej Split the code that reads the SEEPROM into its own file.
 1.19 12-Oct-1999  hannken branches: 1.19.2;
Add support for `Adaptec AHA 2940UW Pro'.
Behaves like the `Adaptec AHA 2940UW'.

Device info: product id = 0x8778, Chip = AIC7880P.
 1.18 08-Jun-1998  thorpej branches: 1.18.14;
Nuke __BROKEN_INDIRECT_CONFIG.
 1.17 16-Mar-1998  leo Use bus-dma functions.
 1.16 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.15 08-May-1997  thorpej branches: 1.15.2; 1.15.4;
Garbage-collect and uneeded #ifdef.
 1.14 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.13 13-Apr-1997  cgd use pci_map_register(). map both mem and I/O spaces, preferring mem
space if it's usable, but falling back to I/O space if mem isn't usable.
 1.12 10-Apr-1997  cgd clean these up (mostly rename bus_space_{tag,handle}_t variables) so that
this code makes equal sense for memory and I/O space, prefer to map
the PCI front end via memory space (conditionalized on a patchable kernel
variable), and do a bit of other random NetBSD-specific cleanup. (These
changes were sent to Justin Gibbs on March 28.)
 1.11 13-Mar-1997  cgd clean up the __BROKEN_INDIRECT_CONFIG chunks of the last change
 1.10 13-Mar-1997  cgd fixes from Matt Jacob so that these can compile and run on the Alpha.
(aic7xxx has been tested and works on the Alpha, bha has not yet been
tested on thne Alpha.)
 1.9 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.8 13-Oct-1996  christos backout kprintf changes
 1.7 10-Oct-1996  christos - move a variable declaration that is unused under NetBSD into the ifdef
for FreeBSD
- printf -> kprintf, sprintf -> ksprintf
 1.6 08-Oct-1996  gibbs dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.

Regen microcode header file.

dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.

Fix a problem with handing the QUEUE FULL condition.

Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.

Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.

dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.

dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.

Regen data file.

scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.

Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
 1.5 28-Aug-1996  thorpej Quiet the ahc driver down a bit by only enabling some of less useful
messages #if defined(DEBUG) in the NetBSD case.
 1.4 14-Jul-1996  cgd #ifdefs are not allowed in macro invocations.
 1.3 10-Jul-1996  explorer Updates to aic7xxx driver ; from pr port-i386/2600
 1.2 20-May-1996  thorpej branches: 1.2.4;
RCS Id police.
 1.1 16-May-1996  mycroft New version, with changes from Justin Gibbs and Noriyuki Soda.
 1.2.4.2 04-Mar-1997  mycroft Pull up latest ahc driver. Fixes several bugs.
 1.2.4.1 18-Jul-1996  jtc Pulled up from rev 1.4, ahc fixes
 1.15.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.15.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.18.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.19.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.19.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.19.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.24.4.2 06-Feb-2002  he Pull up revision 1.30 (requested by jlam):
Move stray debugging message to only occur in debug mode.
 1.24.4.1 05-Sep-2000  soren Pull up revs 1.25-1.26:
> Add support for the AAA-131 RAID controller by treating it as a 7890.
> Taken from rev 1.32 of the FreeBSD ahc_pci.c.
> Fix 'RAID unsupported' printf.
 1.29.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.29.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.29.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.29.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.30.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.30.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.32.10.1 23-Aug-2003  tron Pull up revision 1.43 via patch (requested by taca in ticket #1430):
make ahc(4) to recognize Adaptec 2915LP Ultra160 SCSI adapter.
 1.41.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.41.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.41.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.41.2.4 19-Oct-2004  skrll Sync with HEAD
 1.41.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.41.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.41.2.1 03-Aug-2004  skrll Sync with HEAD
 1.45.2.1 12-Nov-2004  jmc Pullup rev 1.46-1.47 (requested by christos in ticket #930)

Bring back ALLOW_MEMIO change that was lost between 1.38 and 1.39.
 1.47.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.47.6.1 12-Feb-2005  yamt sync with head.
 1.47.4.1 29-Apr-2005  kent sync with -current
 1.51.2.6 27-Feb-2008  yamt sync with head.
 1.51.2.5 04-Feb-2008  yamt sync with head.
 1.51.2.4 21-Jan-2008  yamt sync with head
 1.51.2.3 27-Oct-2007  yamt sync with head.
 1.51.2.2 30-Dec-2006  yamt sync with head.
 1.51.2.1 21-Jun-2006  yamt sync with head.
 1.53.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.53.10.2 11-May-2006  elad sync with head
 1.53.10.1 19-Apr-2006  elad sync with head.
 1.53.8.2 11-Aug-2006  yamt sync with head
 1.53.8.1 24-May-2006  yamt sync with head.
 1.53.6.2 01-Jun-2006  kardel Sync with head.
 1.53.6.1 22-Apr-2006  simonb Sync with head.
 1.53.4.1 09-Sep-2006  rpaulo sync with head
 1.55.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.56.6.2 10-Dec-2006  yamt sync with head.
 1.56.6.1 22-Oct-2006  yamt sync with head
 1.56.4.1 18-Nov-2006  ad Sync with head.
 1.58.26.1 06-Oct-2007  yamt sync with head.
 1.58.24.3 23-Mar-2008  matt sync with HEAD
 1.58.24.2 09-Jan-2008  matt sync with HEAD
 1.58.24.1 06-Nov-2007  matt sync with HEAD
 1.58.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.58.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.58.8.2 23-Oct-2007  ad Sync with head.
 1.58.8.1 09-Oct-2007  ad Sync with head.
 1.59.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.60.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.60.4.1 26-Dec-2007  ad Sync with head.
 1.60.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.62.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.62.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.62.2.1 24-Mar-2008  keiichi sync with head.
 1.63.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.63.4.4 11-Mar-2010  yamt sync with head
 1.63.4.3 16-Sep-2009  yamt sync with head
 1.63.4.2 16-May-2009  yamt sync with head
 1.63.4.1 04-May-2009  yamt sync with head.
 1.64.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.68.26.1 18-May-2014  rmind sync with head
 1.68.22.2 03-Dec-2017  jdolecek update from HEAD
 1.68.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.68.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.70.6.1 05-Oct-2016  skrll Sync with HEAD
 1.71.16.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.71.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.72.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.72.2.1 10-Jun-2019  christos Sync with HEAD
 1.75.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 12-May-2007  bouyer Split the ahcisata driver in pci front-end and bus-independant back-end.
 1.4 04-Mar-2007  christos branches: 1.4.2; 1.4.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 03-Jan-2007  bouyer branches: 1.3.2; 1.3.4;
Fix cut'n'paste, don't print version 1.0 when we have a version 1.1 controller.
Pointed out by Craig Metz.
 1.2 02-Dec-2006  bouyer branches: 1.2.2; 1.2.4;
Don't call the done callback twice if a special action is waiting on the queue.
Don't forget to free the xfer in the normal bio path.
 1.1 30-Nov-2006  bouyer branches: 1.1.2;
Add ahcisata(4), a driver for AHCI 1.0 and 1.1 controllers. Tested on the sata
ports of a Intel 63xxESB chipset. Does not support NCQ yet.
 1.1.2.3 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.1.2.2 04-Jan-2007  tron branches: 1.1.2.2.2;
Pull up following revision(s) (requested by bouyer in ticket #329):
sys/dev/pci/ahcisata.c: revision 1.3
Fix cut'n'paste, don't print version 1.0 when we have a version 1.1 controller.
Pointed out by Craig Metz.
 1.1.2.1 03-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #242):
sys/dev/pci/ahcisata.c: revision 1.2
Don't call the done callback twice if a special action is waiting on the queue.
Don't forget to free the xfer in the normal bio path.
 1.1.2.2.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.2.4.4 03-Sep-2007  yamt sync with head.
 1.2.4.3 26-Feb-2007  yamt sync with head.
 1.2.4.2 30-Dec-2006  yamt sync with head.
 1.2.4.1 02-Dec-2006  yamt file ahcisata.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:41 +0000
 1.2.2.2 10-Dec-2006  yamt sync with head.
 1.2.2.1 02-Dec-2006  yamt file ahcisata.c was added on branch yamt-splraiseipl on 2006-12-10 07:17:41 +0000
 1.3.4.2 17-May-2007  yamt sync with head.
 1.3.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.2.2 12-Jan-2007  ad Sync with head.
 1.3.2.1 03-Jan-2007  ad file ahcisata.c was added on branch newlock2 on 2007-01-12 00:57:40 +0000
 1.4.4.1 11-Jul-2007  mjf Sync with head.
 1.4.2.2 27-May-2007  ad Sync with head.
 1.4.2.1 05-Apr-2007  ad Compile fixes.
 1.72 20-Apr-2025  andvar viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.

Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).

Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.

Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.

For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html

Should fix and close PR kern/37517.

Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.

Reviewed by bad.
 1.71 10-Oct-2023  abs branches: 1.71.6;
Add support for ASMEDIA 0x0624

... an AHCI SATA adaptor which identifies itself as an IDE storage device
 1.70 10-Sep-2023  abs Rework AHCISATA_EXTRA_DELAY for kern/56737

- Remove AHCI_QUIRK_EXTRA_DELAY as issue appears to be drive and
not controller related
- Replace AHCISATA_EXTRA_DELAY with AHCISATA_REMOVE_EXTRA_DELAY,
so defaulting to enabling the extra delay, as the downside of
slower probing on systems which do not need it is less than having
other systems intermittently fail to probe and attach drives
- Also allow disabling extra delay with AHCISATA_EXTRA_DELAY_MS = 0

We should return to this code to work out which of the extra delays
are needed, and how long they need to be. It may be that faster
systems are more likely to trigger the issue (I've only seen it on
a 13th gen i7-13700, though only tested on a limited set)

XXX pullup -10
 1.69 31-Jul-2023  tnn ahcisata: ASM106x needs EXTRA_DELAY quirk
 1.68 12-Oct-2022  macallan branches: 1.68.2;
set AHCI_QUIRK_EXTRA_DELAY for ASMedia ASM1061 - now it reliably attaches old
1.5GBit/s only disks
 1.67 02-Oct-2022  martin Add extra delay quirk for AMD FCH SATA Controller D.
 1.66 02-Oct-2022  martin regen (AMD FCH SATA D added)
 1.65 31-May-2022  andvar fix various typos in comments, documentation and messages.
 1.64 29-May-2022  rin Apply extra delay quirk for

- Intel 7 Series (mobile) SATA Controller (AHCI):
rev. 0x04 sometimes fails to probe Seagate ST500LT012.

Reported by RVP. Thanks!
 1.63 29-May-2022  rin Apply extra delay quirk for followings:

- Intel Braswell AHCI: rev. 0x35 fails for Seagate ST2000LX001.

- Intel 8 Series (desktop) SATA Controller (AHCI): rev. 0x04 fails for
Seagate ST1000LX015 and WD WD10JPVX, whereas it works without the
quirk for some SSD models...

Reported by Matthias Petermann. Thanks!
 1.62 14-May-2022  rin Apply extra-delay quirk to "Intel 9 Series SATA Controller (AHCI)";
without the quirk, the controller fails to probe some HDD models,
at least "Seagate ST2000DM008".

Info and patch provided by Tiago Seco, thanks!
 1.61 19-Nov-2021  rin ahcisata(4): Introduce AHCI_QUIRK_EXTRA_DELAY quirk for devices that
need extra delays as done by AHCISATA_EXTRA_DELAY option.

Enable this quirk for "C600/X79 AHCI". Also add commented out quirk
entries for "Bay Trail SATA (AHCI)" and "Mobile AHCI SATA Controller",
for which non-reproducible failures worked around by extra delays have
been reported.

500 ms of delays inserted by these option/quirk may be too much. Add
AHCISATA_EXTRA_DELAY_MS option to adjust number of delays in ms, like:

----
options AHCISATA_EXTRA_DELAY_MS=200
----

Thanks prlw1@ and jun@ for testing!
 1.60 12-Nov-2021  skrll Fix the conditional for failed interrupt establishment
 1.59 08-Nov-2021  rin Group quirks by vendors. No functional changes.
 1.58 28-Dec-2020  jmcneill Remove duplicate opt_ahcisata_pci.h include
 1.57 18-Jan-2020  simonb branches: 1.57.6;
Add new AHCI_QUIRK_BADNCQ quick for controllers that have issues with
NCQ on (some) drives. Enable this quirk for ATI (AMD) SB600/SB700
controllers. Alternate fix for kern/54790 and kern/54855.

ok jdolecek@, tested on my SB700 chipset and tsutsui's SB600 chipset.
 1.56 18-Oct-2019  tnn branches: 1.56.2;
ahcisata: make sure bus mastering and memory space are actually enabled

This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.
 1.55 27-Jan-2019  pgoyette branches: 1.55.4;
Merge the [pgoyette-compat] branch
 1.54 22-Jan-2019  jdolecek fix pasto; still PR kern/53307
 1.53 22-Jan-2019  jdolecek add BADPMP quirk also for AMD Hudson AHCI SATA Controller, seems in some
configurations/BIOS versions the PMP reset works, in others not; it's better
to have the common configuration working

related to PR kern/53307
 1.52 22-Jan-2019  jdolecek add BADPMP quirk for Intel 82801JI SATA Controller (AHCI mode), which
apparently has problem with the PMP reset

part of PR kern/53307 - Christos machine
 1.51 14-Jan-2019  jdolecek nothing handles AHCI_QUIRK_BADPMPRESET quirk, remove and change all entries
using it (ATI SB600/SB700) to instead use AHCI_QUIRK_BADPMP
 1.50 08-Dec-2018  jdolecek support multi-vector MSI-X

tested and confirmed working by Masanobu SAITOH on C3000
 1.49 04-Dec-2018  jdolecek disable MSI-X for time being since it's not working; allow only MSI
and INTx which both are confirmed working
 1.48 30-Nov-2018  jdolecek simplify intr establish code - rely on pci_intr_alloc() to allow
also MSI-X, and to return interrupt types which are possible for
pci_intr_establish(); remove fallbacks to retry with MSI/MSI-X
explicitly disabled

discussed on tech-kern@

https://mail-index.netbsd.org/tech-kern/2018/11/27/msg024240.html
 1.47 26-Nov-2018  jdolecek add AHCI_PCI_QUIRK_FORCE for apu2 to be recognized; patch by Mike Pumford
on current-users@
 1.46 24-Nov-2018  skrll Handle Cavium AHCI/RAID controller BAR weirdness.

Support 64bit BARs as well.
 1.45 20-Nov-2018  prlw1 Trivial build fix
 1.44 20-Nov-2018  skrll Add support for MSI/MSI-X to ahcisata at pci.

The options AHCISATA_DISABLE_MSI and AHCISATA_DISABLE_MSIX are available
if required.
 1.43 18-Nov-2018  skrll Trailing whitespace
 1.42 25-Oct-2018  jdolecek release intr if pci_intr_establish_xname() fails
 1.41 24-Oct-2018  jdolecek detach the controller itself on shutdown; adjust to not detach already
detached atabus/channel
 1.40 22-Oct-2018  jdolecek first disestablish interrupt, then release
 1.39 22-Oct-2018  jdolecek enable MSI support where available
 1.38 13-Oct-2016  jdolecek branches: 1.38.8; 1.38.14; 1.38.16;
provide intr xname
 1.37 23-Aug-2016  msaitoh Sync with pcidevs rev. 1.1263. No functional change.
 1.36 29-Mar-2014  christos branches: 1.36.6; 1.36.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.35 21-Jan-2014  msaitoh Rename 88SE91XX.
 1.34 10-Jan-2014  msaitoh Sync with pcidev's change. Rename PCI_PRODUCT_MARVELL2_88SE9128 to
PCI_PRODUCT_MARVELL2_88SE912Z. No functional change.
 1.33 09-Jan-2014  christos revert unintended changes
 1.32 09-Jan-2014  htodd Fix build. Only compile tested.
 1.31 21-Oct-2012  matt branches: 1.31.2;
Add FORCE quirks for ASMEDIA ASM1061
 1.30 20-Aug-2012  bouyer branches: 1.30.2;
Fix typo, pointed out by Markus W Kilbinger
 1.29 10-Aug-2012  bouyer Remove leftover comment.
 1.28 10-Aug-2012  bouyer Work around some SATA PMP issues in some AHCI controllers by either
disabling PMP entirely, or special handling in the reset function.
Controller list from linux and FreeBSD.
 1.27 30-Jan-2012  drochner branches: 1.27.2; 1.27.4;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.26 06-Aug-2011  jakllsch branches: 1.26.2; 1.26.6;
Marvell 88SE9128 needs AHCI_PCI_QUIRK_FORCE.
 1.25 27-May-2011  matt Add quirk for ALI M5228
 1.24 03-Apr-2011  dyoung Deregister in ahci_pci_detach() the PMF hooks registered in
ahci_pci_attach().
 1.23 13-Nov-2010  uebayasi branches: 1.23.2;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.22 07-Aug-2010  jmcneill Add NVIDIA MCP77 to the quirk table, so ahcisata will attach when the
BIOS is set to 'RAID' mode.
 1.21 27-Jul-2010  jakllsch Use use 64-bit DMA tag (where available and supported) for ahcisata.
Avoid the possible ATI SB600 64-bit DMA problem.
 1.20 27-Jul-2010  jakllsch Support detachment of ahcisata(4).
Use use 64-bit DMA tag (where available) for ahcisata(4) at jmide(4).
Beginnings of detach/resume support for jmide(4).
Sprinkle static. Misc. little changes.
 1.19 24-Feb-2010  dyoung branches: 1.19.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.18 08-Jan-2010  dyoung branches: 1.18.2;
Expand PMF_FN_* macros.
 1.17 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.16 19-Aug-2009  pgoyette Use __arraycount() for readability
 1.15 11-Jun-2009  cegger Attach Marvel 88SE6121 SATA II controller on ahci.
W/o this, it attaches on pciide.
 1.14 27-Mar-2009  dholland Add the other three PCI ids for the nvidia MCP65 SATA controller to
the quirk table. This way they attach as ahcisata and work, instead of
attaching as viaide and failing miserably.

Fixes PR kern/37826.

XXX: There are a bunch of additional MCP67 and MCP73 PCI ids that
XXX: should probably be added also, but I don't want to do that without
XXX: further investigation and testing.
 1.13 08-Dec-2008  tron branches: 1.13.2;
Force the nVidia nForce 630i MCP73 to attach to ahcisata(4) as well.
It would otherwise attach to pciide(4) and use PIO mode.

Patch submitted by Bernhard Moellemann in PR kern/40134.
 1.12 01-Aug-2008  dillo branches: 1.12.2; 1.12.4;
Force ahcisata to attach to NVIDIA MCP65 and MCP67, as they don't
work with viaide.

Reviewed by bouyer.
 1.11 20-Mar-2008  cube branches: 1.11.4; 1.11.6; 1.11.10;
Fix previous. *Sigh*
 1.10 20-Mar-2008  cube Don't forget to se the device_t back pointer in the softc.
 1.9 18-Mar-2008  cube Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.8 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.7 23-Feb-2008  mlelstv make this less verbose
 1.6 23-Feb-2008  mlelstv Always attach AHCI_SATA devices, even when not configured for AHCI mode.
Fixes PR kern/38081.
 1.5 19-Feb-2008  jnemeth branches: 1.5.2; 1.5.6;
KNF
 1.4 19-Feb-2008  jnemeth PR/38056 - Simon Burge -- In ahci_pci_match, return the correct
value so that we only match SATA RAID controllers in AHCI mode.

Tested by: simonb@
Approved by: bouyer@
 1.3 11-Feb-2008  xtraeme Attach ahcisata(4) to any RAID controller that supports AHCI, and make it
pass the ATAC_CAP_RAID capability for them. ok'ed by bouyer@.
 1.2 09-Dec-2007  jmcneill Merge jmcneill-pm branch.
 1.1 12-May-2007  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12; 1.1.14; 1.1.16; 1.1.18; 1.1.20; 1.1.26; 1.1.28; 1.1.30;
Split the ahcisata driver in pci front-end and bus-independant back-end.
 1.1.30.1 11-Dec-2007  yamt sync with head.
 1.1.28.1 26-Dec-2007  ad Sync with head.
 1.1.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.20.7 24-Mar-2008  yamt sync with head.
 1.1.20.6 17-Mar-2008  yamt sync with head.
 1.1.20.5 27-Feb-2008  yamt sync with head.
 1.1.20.4 11-Feb-2008  yamt sync with head.
 1.1.20.3 21-Jan-2008  yamt sync with head
 1.1.20.2 03-Sep-2007  yamt sync with head.
 1.1.20.1 12-May-2007  yamt file ahcisata_pci.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:20 +0000
 1.1.18.2 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.18.1 12-May-2007  wrstuden file ahcisata_pci.c was added on branch wrstuden-fixsa on 2007-09-03 07:04:27 +0000
 1.1.16.2 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.1.16.1 12-May-2007  pavel file ahcisata_pci.c was added on branch netbsd-4 on 2007-08-31 20:09:25 +0000
 1.1.14.2 23-Mar-2008  matt sync with HEAD
 1.1.14.1 09-Jan-2008  matt sync with HEAD
 1.1.12.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.1.12.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.1.12.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.1.12.1 04-Aug-2007  he Factor out the hardware initialization code in ahcisata_core.c,
and provide them to the pci frontend, which has now grown its own
softc and a power management handler.

There may be one too many re-initializations done on resume (witness
the multiple kernel messages from ahcisata), but at least this is
sufficient to get the Lenovo T60 to come out of resume with a
working disk controller and disk.
 1.1.6.2 11-Jul-2007  mjf Sync with head.
 1.1.6.1 12-May-2007  mjf file ahcisata_pci.c was added on branch mjf-ufs-trans on 2007-07-11 20:06:58 +0000
 1.1.4.2 09-Jun-2007  ad Sync with head.
 1.1.4.1 12-May-2007  ad file ahcisata_pci.c was added on branch vmlocking on 2007-06-09 21:37:23 +0000
 1.1.2.2 17-May-2007  yamt sync with head.
 1.1.2.1 12-May-2007  yamt file ahcisata_pci.c was added on branch yamt-idlelwp on 2007-05-17 13:41:29 +0000
 1.5.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.5.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.5.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.2.1 24-Mar-2008  keiichi sync with head.
 1.11.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.10.1 19-Oct-2008  haad Sync with HEAD.
 1.11.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.4.5 11-Aug-2010  yamt sync with head.
 1.11.4.4 11-Mar-2010  yamt sync with head
 1.11.4.3 16-Sep-2009  yamt sync with head
 1.11.4.2 20-Jun-2009  yamt sync with head
 1.11.4.1 04-May-2009  yamt sync with head.
 1.12.4.3 21-Nov-2010  riz branches: 1.12.4.3.2;
Pull up following revision(s) (requested by jmcneill in ticket #1437):
sys/dev/pci/ahcisata_pci.c: revision 1.22
Add NVIDIA MCP77 to the quirk table, so ahcisata will attach when the
BIOS is set to 'RAID' mode.
 1.12.4.2 30-Mar-2009  snj branches: 1.12.4.2.4;
Pull up following revision(s) (requested by dholland in ticket #616):
sys/dev/pci/ahcisata_pci.c: revision 1.14
Add the other three PCI ids for the nvidia MCP65 SATA controller to
the quirk table. This way they attach as ahcisata and work, instead of
attaching as viaide and failing miserably.
Fixes PR kern/37826.
XXX: There are a bunch of additional MCP67 and MCP73 PCI ids that
XXX: should probably be added also, but I don't want to do that without
XXX: further investigation and testing.
 1.12.4.1 10-Dec-2008  snj Pull up following revision(s) (requested by tron in ticket #170):
sys/dev/pci/ahcisata_pci.c: revision 1.13
Force the nVidia nForce 630i MCP73 to attach to ahcisata(4) as well.
It would otherwise attach to pciide(4) and use PIO mode.
Patch submitted by Bernhard Moellemann in PR kern/40134.
 1.12.4.3.2.1 14-Oct-2011  matt revision 1.25
date: 2011/05/27 15:11:59; author: matt; state: Exp; lines: +4 -2
Add quirk for ALI M5228
 1.12.4.2.4.2 26-Mar-2014  matt Use ahci_resume
 1.12.4.2.4.1 05-Nov-2013  matt Support a 64-bit BAR for AHCI
 1.12.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.12.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.2.2 23-Jul-2009  jym Sync with HEAD.
 1.13.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.18.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.2.3 31-May-2011  rmind sync with head
 1.19.2.2 21-Apr-2011  rmind sync with head
 1.19.2.1 05-Mar-2011  rmind sync with head
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.6.1 18-Feb-2012  mrg merge to -current.
 1.26.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.2.2 30-Oct-2012  yamt sync with head
 1.26.2.1 17-Apr-2012  yamt sync with head
 1.27.4.1 18-Nov-2012  matt Merge tickets 658 and 659.
 1.27.2.1 18-Nov-2012  msaitoh Pull up following revision(s) (requested by matt in ticket #659):
sys/dev/pci/ahcisata_pci.c: revision 1.31
Add FORCE quirks for ASMEDIA ASM1061
 1.30.2.4 03-Dec-2017  jdolecek update from HEAD
 1.30.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.30.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.31.2.1 18-May-2014  rmind sync with head
 1.36.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.36.6.2 05-Dec-2016  skrll Sync with HEAD
 1.36.6.1 05-Oct-2016  skrll Sync with HEAD
 1.38.16.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.38.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.38.16.1 10-Jun-2019  christos Sync with HEAD
 1.38.14.4 26-Jan-2019  pgoyette Sync with HEAD
 1.38.14.3 18-Jan-2019  pgoyette Synch with HEAD
 1.38.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.38.14.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.38.8.2 13-Oct-2023  martin Pull up following revision(s) (requested by abs in ticket #1911):

sys/dev/pci/ahcisata_pci.c: revision 1.71

Add support for ASMEDIA 0x0624
... an AHCI SATA adaptor which identifies itself as an IDE storage device
 1.38.8.1 18-Dec-2018  martin Pull up following revision(s) (requested by is in ticket #1139):

sys/dev/pci/ahcisata_pci.c: revision 1.47

add AHCI_PCI_QUIRK_FORCE for apu2 to be recognized; patch by Mike Pumford
on current-users@
 1.55.4.4 09-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1944):

sys/dev/pci/viaide.c: revision 1.90
sys/dev/pci/ahcisata_pci.c: revision 1.72
sys/dev/pci/pciide_apollo_reg.h: revision 1.21
sys/dev/pci/viaide.c: revision 1.91
sys/dev/pci/viaide.c: revision 1.92
sys/dev/pci/viaide.c: revision 1.93
sys/dev/pci/viaide.c: revision 1.94
sys/dev/pci/viaide.c: revision 1.96
sys/dev/pci/viaide.c: revision 1.97
sys/dev/pci/viaide.c: revision 1.98
share/man/man4/viaide.4: revision 1.11
share/man/man4/viaide.4: revision 1.12

Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
Add VIA VT8261 southbridge SATA controller IDs and PCIB.
viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.
Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.
via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.
Fixes PR kern/59010.
Reviewed and approved by jakllsch@.

Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.
These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.
This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.
The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

viaide(4): add IDE controller identification by the VT8237S ISA bridge.
The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.
Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaurs demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.


viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.
The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.
Tested on ECS VX900-I.
Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.
Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).
Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.
Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.
For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html
Should fix and close PR kern/37517.
Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.
Reviewed by bad.
viaide(4): check if chip enable register returns 0 before emulating enable
bits.
At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
viaide(4): update the list of supported VIA controllers.
viaide(4): remove notes section about VT6421, it is not currently required to
setup RAID/JBOD sets to access drives.
 1.55.4.3 13-Oct-2023  martin Pull up following revision(s) (requested by abs in ticket #1748):

sys/dev/pci/ahcisata_pci.c: revision 1.71

Add support for ASMEDIA 0x0624
... an AHCI SATA adaptor which identifies itself as an IDE storage device
 1.55.4.2 21-Jan-2020  martin Pull up following revision(s) (requested by simonb in ticket #630):

sys/dev/ic/ahcisatavar.h: revision 1.24
sys/dev/pci/ahcisata_pci.c: revision 1.57
sys/dev/ic/ahcisata_core.c: revision 1.81

Add new AHCI_QUIRK_BADNCQ quick for controllers that have issues with
NCQ on (some) drives. Enable this quirk for ATI (AMD) SB600/SB700
controllers. Alternate fix for kern/54790 and kern/54855.
ok jdolecek@, tested on my SB700 chipset and tsutsui's SB600 chipset.
 1.55.4.1 23-Oct-2019  martin Pull up following revision(s) (requested by tnn in ticket #358):

sys/dev/pci/ahcisata_pci.c: revision 1.56

ahcisata: make sure bus mastering and memory space are actually enabled
This makes the "ROCKPro64 PCI-e to Dual SATA-II Interface Card" work.
 1.56.2.1 25-Jan-2020  ad Sync with head.
 1.57.6.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.68.2.4 09-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1101):

sys/dev/pci/viaide.c: revision 1.90
sys/dev/pci/ahcisata_pci.c: revision 1.72
sys/dev/pci/pciide_apollo_reg.h: revision 1.21
sys/dev/pci/viaide.c: revision 1.91
sys/dev/pci/viaide.c: revision 1.92
sys/dev/pci/viaide.c: revision 1.93
sys/dev/pci/viaide.c: revision 1.94
sys/dev/pci/viaide.c: revision 1.96
sys/dev/pci/viaide.c: revision 1.97
sys/dev/pci/viaide.c: revision 1.98
share/man/man4/viaide.4: revision 1.11
share/man/man4/viaide.4: revision 1.12

Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
Add VIA VT8261 southbridge SATA controller IDs and PCIB.
viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.
Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.
via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.
Fixes PR kern/59010.
Reviewed and approved by jakllsch@.

Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.
These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.
This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.
The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

viaide(4): add IDE controller identification by the VT8237S ISA bridge.
The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.
Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaurs demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.


viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.
The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.
Tested on ECS VX900-I.
Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.
Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).
Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.
Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.
For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html
Should fix and close PR kern/37517.
Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.
Reviewed by bad.
viaide(4): check if chip enable register returns 0 before emulating enable
bits.
At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
viaide(4): update the list of supported VIA controllers.
viaide(4): remove notes section about VT6421, it is not currently required to
setup RAID/JBOD sets to access drives.
 1.68.2.3 13-Oct-2023  martin Pull up following revision(s) (requested by abs in ticket #403):

sys/dev/pci/ahcisata_pci.c: revision 1.71

Add support for ASMEDIA 0x0624
... an AHCI SATA adaptor which identifies itself as an IDE storage device
 1.68.2.2 11-Sep-2023  martin Pull up following revision(s) (requested by abs in ticket #366):

sys/dev/pci/ahcisata_pci.c: revision 1.70
sys/dev/ic/ahcisata_core.c: revision 1.108
sys/dev/ic/ahcisatavar.h: revision 1.28
sys/conf/files: revision 1.1309

Rework AHCISATA_EXTRA_DELAY for kern/56737
- Remove AHCI_QUIRK_EXTRA_DELAY as issue appears to be drive and
not controller related
- Replace AHCISATA_EXTRA_DELAY with AHCISATA_REMOVE_EXTRA_DELAY,
so defaulting to enabling the extra delay, as the downside of
slower probing on systems which do not need it is less than having
other systems intermittently fail to probe and attach drives
- Also allow disabling extra delay with AHCISATA_EXTRA_DELAY_MS = 0

We should return to this code to work out which of the extra delays
are needed, and how long they need to be. It may be that faster
systems are more likely to trigger the issue (I've only seen it on
a 13th gen i7-13700, though only tested on a limited set)
 1.68.2.1 22-Aug-2023  martin Pull up following revision(s) (requested by tnn in ticket #334):

sys/dev/pci/ahcisata_pci.c: revision 1.69

ahcisata: ASM106x needs EXTRA_DELAY quirk
 1.71.6.1 02-Aug-2025  perseant Sync with HEAD
 1.2 12-May-2007  bouyer Split the ahcisata driver in pci front-end and bus-independant back-end.
 1.1 30-Nov-2006  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.14; 1.1.16; 1.1.22;
Add ahcisata(4), a driver for AHCI 1.0 and 1.1 controllers. Tested on the sata
ports of a Intel 63xxESB chipset. Does not support NCQ yet.
 1.1.22.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.16.1 11-Jul-2007  mjf Sync with head.
 1.1.14.2 09-Jun-2007  ad Sync with head.
 1.1.14.1 27-May-2007  ad Sync with head.
 1.1.10.1 17-May-2007  yamt sync with head.
 1.1.8.2 12-Jan-2007  ad Sync with head.
 1.1.8.1 30-Nov-2006  ad file ahcisatareg.h was added on branch newlock2 on 2007-01-12 00:57:40 +0000
 1.1.6.3 03-Sep-2007  yamt sync with head.
 1.1.6.2 30-Dec-2006  yamt sync with head.
 1.1.6.1 30-Nov-2006  yamt file ahcisatareg.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:41 +0000
 1.1.4.2 10-Dec-2006  yamt sync with head.
 1.1.4.1 30-Nov-2006  yamt file ahcisatareg.h was added on branch yamt-splraiseipl on 2006-12-10 07:17:41 +0000
 1.1.2.1 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.40 28-May-2022  andvar fix various typos, mainly in comments.
 1.39 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.38 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.37 23-Jun-2018  maxv branches: 1.37.2;
constify
 1.36 15-Jan-2018  maya branches: 1.36.2;
malloc+memset zero to malloc(, |M_ZERO);

ok rkujawa
 1.35 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.34 21-Apr-2013  msaitoh branches: 1.34.4;
Delete "PCI_" from PCIX and PICE capability registers.
 1.33 30-Dec-2011  christos branches: 1.33.6;
PR/45760: Henning Petersen: Add Adaptec29329LPE to ahd_pci.c
 1.32 21-Apr-2010  dyoung branches: 1.32.8; 1.32.12;
Don't printf bus_space_tag_t's in a MI driver.
 1.31 26-Sep-2009  tsutsui branches: 1.31.2; 1.31.4;
Split device_t/softc. Tested on aic7901A.
 1.30 05-Sep-2009  tsutsui Use device_t self arg to get a device name rather than through &ahd->sc_dev
which needs to be changed on future device_t/softc split.
 1.29 05-Sep-2009  tsutsui Wrap long lines.
 1.28 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.27 21-Mar-2008  dyoung branches: 1.27.4; 1.27.18;
Use aprint_*_dev(), and device_xname(). Constify a bit.
 1.26 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.25 16-Nov-2006  christos branches: 1.25.24; 1.25.44; 1.25.48;
__unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 17-Jun-2006  christos branches: 1.23.4; 1.23.6;
re-factor the pci powestate api. reviewed by gimpy
 1.22 08-Mar-2006  lukem branches: 1.22.4; 1.22.6;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.21 24-Dec-2005  perry branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.20 11-Dec-2005  christos merge ktrace-lwp.
 1.19 28-Jun-2005  thorpej branches: 1.19.2;
Use ANSI function decls and static.
 1.18 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.17 25-Apr-2005  bad Recognise the Dell OEM version of the ASR-29320B as found in recent
e.g. Dell SC1420 boxen. This adapter can't be put out of HostRaid mode,
so recognise it in that mode regardless.
 1.16 25-Apr-2005  bad Bring in some changes from rev. 1.17 of FreeBSD aic79xx_pci.c:
Fix the *_IROC_* masks so that the correct bits get masked out for the HostRaid
features.
The 29320 and 29320B really are 7902 based, not 7901A based. Use the approriate
chip setup routine.
Recognise generic 7901 based boards by matching against ID_9005_GENERIC_MASK.
 1.15 27-Feb-2005  perry branches: 1.15.2;
nuke trailing whitespace
 1.14 04-Feb-2005  perry de-__P
 1.13 24-Feb-2004  wiz branches: 1.13.6; 1.13.8; 1.13.10;
parameter with two es. From Peter Postma.
 1.12 18-Nov-2003  briggs Use aprint_* instead of printf.
 1.11 10-Oct-2003  fvdl Add a missing chip reset in attach. Makes things work for an on-board
7902B on a SuperMicro board.
 1.10 10-Oct-2003  fvdl Set some termination defaults correctly. Test register access like
in the original FreeBSD driver.
 1.9 10-Oct-2003  thorpej Fix some errors in device mapping and errata work-arounds, and generally
clean up mapping code.
 1.8 09-Oct-2003  fvdl Don't treat a 66-100Mhz PCI-X bus as plain PCI. From yamt (the code was
already like this in the FreeBSD driver).
 1.7 02-Sep-2003  fvdl Make this less chatty on probe/attach, to match the output of other controllers.
 1.6 29-Aug-2003  thorpej Apply the following change from 06/28/2003 04:39:49 by gibbs to the
FreeBSD ahd driver:

aic79xx.h:
Add a 7901A specific feature definition.

aic79xx_pci.c:
Split out the general aic790X setup into it's own
setup handler that works on single and dual controllers.
Adjust all other PCI setup handlers to initialize the
chips basic features and type before calling the generic
handler.

Turn off a few Rev B workarounds that are not required
on the 7901B.
 1.5 29-Aug-2003  thorpej Apply the following change from 5/26/2003 21:15:52 made by gibbs to the
FreeBSD ahd driver:

Add 7901B support.

Sort IDs based on chip type.

Remove IROC IDs. We'll switch to using the IROC masks
if/when we want to start attaching to IROC controllers.

Approved by: RE
 1.4 29-Aug-2003  thorpej Apply the following change checked in 2003/05/04 00:20:07 by gibbs
to the FreeBSD ahd driver:

Correct spelling errors.

Switch to handling bad SCSI status as a sequencer interrupt
instead of having the kernel proccess these failures via
the completion queue. This is done because:

o The old scheme required us to pause the sequencer and clear
critical sections for each SCB. It seems that these pause
actions, if coincident with a sequencer FIFO interrupt, would
result in a FIFO interrupt getting lost or directing to the
wrong FIFO. This caused hangs when the driver was stressed
under high "queue full" loads.
o The completion code assumed that it was always called with
the sequencer running. This may not be the case in timeout
processing where completions occur manually via
ahd_pause_and_flushwork().
o With this scheme, the extra expense of clearing critical
sections is avoided since the sequencer will only self pause
once all pending selections have cleared and it is not in
a critical section.

aic79xx.c
Add code to handle the new BAD_SCB_STATUS sequencer
interrupt code. This just redirects the SCB through
the already existing ahd_complete_scb() code path.
Remove code in ahd_handle_scsi_status() that paused
the sequencer, made sure that no selections where
pending, and cleared critical sections. Bad
status SCBs are now only processed when all of these
conditions are true.

aic79xx.reg:
Add the BAD_SCB_STATUS sequencer interrupt code.

aic79xx.seq:
When completing an SCB upload to the host, if
we are doing this because the SCB contains non-zero
SCSI status, defer completing the SCB until there
are no pending selection events. When completing
these SCBs, use the new BAD_SCB_STATUS sequencer
interrupt. For all other uploaded SCBs (currently
only for underruns), the SCB is completed via the
normal done queue. Additionally, keep the SCB that
is currently being uploaded on the COMPLETE_DMA_SCB
list until the dma is completed, not just until the
DMA is started. This ensures that the DMA is restarted
properly should the host disable the DMA transfer for
some reason.

In our RevA workaround for Maxtor drives, guard against
the host pausing us while trying to pause I/O until the
first data-valid REQ by clearing the current snapshot
so that we can tell if the transfer has completed prior
to us noticing the REQINIT status.

In cfg4data_intr, shave off an instruction before getting
the data path running by adding an entrypoint to the
overrun handler to also increment the FIFO use count.

In the overrun handler, be sure to clear our LONGJMP
address in both exit paths.

Perform a few sequencer optimizations.

aic79xx.c:
Print the full path from the SCB when a packetized
status overrun occurs.

Remove references to LONGJMP_SCB which is being
removed from firmware usage.

Print the new SCB_FIFO_USE_COUNT field in the
per-SCB section of ahd_dump_card_state(). The
SCB_TAG field is now re-used by the sequencer,
so it no longer makes sense to reference this
field in the kernel driver.

aic79xx.h:
Re-arrange fields in the hardware SCB from largest
size type to smallest. This makes it easier to
move fields without changing field alignment.

The hardware scb tag field is now down near the
"spare" portion of the SCB to facilitate reuse
by the sequencer.

aic79xx.reg:
Remove LONGJMP_ADDR.

Rearrange SCB fields to match aic79xx.h.
Add SCB_FIFO_USE_COUNT as the first byte
of the SCB_TAG field.

aic79xx.seq:
Add a per-SCB "Fifos in use count" field and use
it to determine when it is safe (all data posted)
to deliver status back to the host. The old method
involved polling one or both FIFOs to verify that
the current task did not have pending data. This
makes running down the GSFIFO very cheap, so we
will empty the GSFIFO in one idle loop pass in
all cases.

Use this simplification of the completion process
to prune down the data FIFO teardown sequencer for
packetized transfers. Much more code is now shared
between the data residual and transfer complete cases.

Correct some issues in the packetized status handler.
It used to be possible to CLRCHN our FIFO before status
had fully transferred to the host. We also failed to
handle NONPACKREQ phases that could occur should a CRC
error occur during transmission of the status data packet.

Correct a few big endian issues:

aic79xx.c:
aic79xx_inline.h:
aic79xx_pci.c:
aic79xx_osm.c:
o Always get the SCB's tag via the SCB_GET_TAG acccessor
o Add missing use of byte swapping macros when touching
hscb fields.
o Don't double swap SEEPROM data when it is printed.
Correct a big-endian bug. We cannot assign a
o When assigning a 32bit LE variable to a 64bit LE
variable, we must be explict about how the words
of the 64bit LE variable are initialized. Cast to
(uint32_t*) to do this.

aic79xx.c:
In ahd_clear_critical_section(), hit CRLSCSIINT
after restoring the interrupt masks to avoid what
appears to be a glitch on SCSIINT. Any real SCSIINT
status will be persistent and will immidiately
reset SCSIINT. This clear should only get rid of
spurious SCSIINTs.

This glitch was the cause of the "Unexpected PKT busfree"
status that occurred under high queue full loads

Call ahd_fini_scbdata() after shutdown so that
any ahd_chip_init() routine that might access
SCB data will not access free'd memory.

Reset the bus on an IOERR since the chip doesn't
seem to reset to the new voltage level without
this.
Change offset calculation for scatter gather maps
so that the calculation is correct if an integral
multiple of sg lists does not fit in the allocation
size.

Adjust bus dma tag for data buffers based on 39BIT
addressing flag in our softc.

Use the QFREEZE count to simplify ahd_pause_and_flushworkd().
We can thus rely on the sequencer eventually clearing ENSELO.

In ahd_abort_scbs(), fix a bug that could potentially
corrupt sequencer state. The saved SCB was being
restored in the SCSI mode instead of the saved mode.
It turns out that the SCB did not need to be saved at all
as the scbptr is already restored by all subroutines
called during this function that modify that register.

aic79xx.c:
aic79xx.h:
aic79xx_pci.c:
Add support for parsing the seeprom vital product
data. The VPD data are currently unused.

aic79xx.h:
aic79xx.seq:
aic79xx_pci.c:
Add a firmware workaround to make the LED blink
brighter during packetized operations on the H2A.

aic79xx_inline.h:
The host does not use timer interrupts, so don't
gate our decision on whether or not to unpause
the sequencer on whether or not a timer interrupt
is pending.
 1.3 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.2 14-May-2003  wiz branches: 1.2.2;
Correct spelling of coalesce. (Will forward to Justin Gibbs.)
 1.1 21-Apr-2003  fvdl ahd, driver for Adaptec 790x U320 controllers. Originally by Justin Gibbs
for FreeBSD, ported to NetBSD by Pascal Renauld, Network Storage Solutions,
Inc, plus a bunch of changes by me.

This driver is as yet untested in this final form, it will be added
to config files when it has been tested.
 1.2.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.10.1 12-Feb-2005  yamt sync with head.
 1.13.8.1 29-Apr-2005  kent sync with -current
 1.13.6.1 13-May-2005  riz Pull up revisions 1.16, 1.17 (requested by bad in ticket #1480):
Bring in some changes from rev. 1.17 of FreeBSD aic79xx_pci.c:
Fix the *_IROC_* masks so that the correct bits get masked out for the HostRaid
features.
The 29320 and 29320B really are 7902 based, not 7901A based. Use the approriate
chip setup routine.
Recognise generic 7901 based boards by matching against ID_9005_GENERIC_MASK.

Recognise the Dell OEM version of the ASR-29320B as found in recent
e.g. Dell SC1420 boxen. This adapter can't be put out of HostRaid mode,
so recognise it in that mode regardless.
 1.15.2.2 28-Apr-2005  tron Pull up revision 1.17 (requested by bad in ticket #204):
Recognise the Dell OEM version of the ASR-29320B as found in recent
e.g. Dell SC1420 boxen. This adapter can't be put out of HostRaid mode,
so recognise it in that mode regardless.
 1.15.2.1 28-Apr-2005  tron Pull up revision 1.16 (requested by bad in ticket #204):
Bring in some changes from rev. 1.17 of FreeBSD aic79xx_pci.c:
Fix the *_IROC_* masks so that the correct bits get masked out for the HostRaid
features.
The 29320 and 29320B really are 7902 based, not 7901A based. Use the approriate
chip setup routine.
Recognise generic 7901 based boards by matching against ID_9005_GENERIC_MASK.
 1.19.2.3 24-Mar-2008  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.21.10.1 19-Apr-2006  elad sync with head.
 1.21.8.2 26-Jun-2006  yamt sync with head.
 1.21.8.1 13-Mar-2006  yamt sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.22.6.1 13-Jul-2006  gdamore Merge from HEAD.
 1.22.4.1 19-Jun-2006  chap Sync with head.
 1.23.6.2 10-Dec-2006  yamt sync with head.
 1.23.6.1 22-Oct-2006  yamt sync with head
 1.23.4.1 18-Nov-2006  ad Sync with head.
 1.25.48.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.44.1 24-Mar-2008  keiichi sync with head.
 1.25.24.1 23-Mar-2008  matt sync with HEAD
 1.27.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.4.4 11-Aug-2010  yamt sync with head.
 1.27.4.3 11-Mar-2010  yamt sync with head
 1.27.4.2 16-Sep-2009  yamt sync with head
 1.27.4.1 16-May-2009  yamt sync with head
 1.31.4.1 30-May-2010  rmind sync with head
 1.31.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.12.1 18-Feb-2012  mrg merge to -current.
 1.32.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.8.1 17-Apr-2012  yamt sync with head
 1.33.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.6.1 23-Jun-2013  tls resync from head
 1.34.4.1 18-May-2014  rmind sync with head
 1.36.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.36.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.37.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.2.1 10-Jun-2019  christos Sync with HEAD
 1.10 16-May-1996  mycroft New version, with changes from Justin Gibbs and Noriyuki Soda.
 1.9 13-May-1996  mycroft Use intr.h.
 1.8 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.7 04-Mar-1996  cgd reorganize mapping register definitions
 1.6 31-Jan-1996  cgd update for new version of 'pcidevs'
 1.5 28-Dec-1995  thorpej Squish a couple of rogue old-style RCS ids.
 1.4 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.3 12-Nov-1995  christos Don't use the softc at probe time on pci devices because it has not been
allocated yet. Thanks Charles...
 1.2 10-Nov-1995  christos - pcidevs: add 3c590 and adaptec ultra
- aic7xxx.c: fix the probe routines to use pcidevs.h
 1.1 09-Oct-1995  mycroft Add an Adaptec 2940 driver, by John Aycock and Justin Gibbs, ported to NetBSD by Stefan
Grefen, with several bug fixes by me.
 1.14 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.13 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.12 24-Apr-2021  thorpej branches: 1.12.2; 1.12.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.11 22-Dec-2019  thorpej branches: 1.11.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.10 18-Mar-2012  martin branches: 1.10.40;
Split device_t
 1.9 11-Mar-2012  pgoyette Since there are no RW_READERs for the device's rw_lock, convert it to a
mutex and reduce the overhead.

Also, even if we're polling, we need to use the lock to control access to
the bus, otherwise we get anomolous results.

(These same changes were made several weeks ago to other drivers; I
missed this one.)
 1.8 10-Feb-2011  hannken branches: 1.8.4; 1.8.8;
Make the SMbus Send/Receive functions work.

If cmdlen = 0 and len = 1 use the XXX_HC_CMD_BYTE protocol, send
data through XXX_SMB_HCMD or receive data from XXX_SMB_HD0.

Ok: Paul Goyette
 1.7 11-Mar-2010  mrg branches: 1.7.2; 1.7.4; 1.7.6;
various aprint_* fixes.
 1.6 12-May-2009  cegger branches: 1.6.2;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.5 11-May-2009  cegger use device_xname()
 1.4 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.3 18-Mar-2009  cegger branches: 1.3.2;
bzero -> memset
 1.2 03-Feb-2009  pgoyette branches: 1.2.2;
Update the i2c_exec() functions to handle quick_read/quick_write protocol.

Although interface routines i2c_smbus_*() exist, nothing in NetBSD actually
uses them yet.
 1.1 29-Oct-2008  jkunz branches: 1.1.6; 1.1.8; 1.1.10;
Ported alipm(4) and admtemp(4) from OpenBSD.
 1.1.10.4 28-Apr-2009  skrll Sync with HEAD.
 1.1.10.3 03-Mar-2009  skrll Sync with HEAD.
 1.1.10.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.10.1 29-Oct-2008  skrll file alipm.c was added on branch nick-hppapmap on 2009-01-19 13:18:24 +0000
 1.1.8.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.8.1 29-Oct-2008  mjf file alipm.c was added on branch mjf-devfs2 on 2009-01-17 13:28:59 +0000
 1.1.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.6.1 29-Oct-2008  haad file alipm.c was added on branch haad-dm on 2008-12-13 01:14:34 +0000
 1.2.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.2.4 11-Aug-2010  yamt sync with head.
 1.3.2.3 16-May-2009  yamt sync with head
 1.3.2.2 04-May-2009  yamt sync with head.
 1.3.2.1 18-Mar-2009  yamt file alipm.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:54 +0000
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.6.1 17-Feb-2011  bouyer Sync with HEAD
 1.7.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.2.1 05-Mar-2011  rmind sync with head
 1.8.8.1 05-Apr-2012  mrg sync to latest -current.
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.10.40.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.10.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.12.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.12.2.1 14-May-2021  thorpej Pass along our devhandle to the iic bus instance.
 1.4 18-Dec-2022  reinoud Add amdsmn(4) and amdccp(4) power management stubs.
 1.3 26-Oct-2022  msaitoh branches: 1.3.2;
Add AMD F17/1x and F17/9x CCP(PSP) support to amdccp(4).
 1.2 25-Jun-2020  thorpej Include all necessary letters in the word "Cryptographic".
 1.1 24-Jun-2020  thorpej Add a PCI front-end for the "amdccp" (AMD Cryptographic Coprocessor)
driver.
 1.3.2.1 19-Dec-2022  martin Pull up following revision(s) (requested by reinoud in ticket #3):

sys/dev/pci/amdccp_pci.c: revision 1.4
sys/arch/x86/pci/amdsmn.c: revision 1.15
sys/dev/acpi/amdccp_acpi.c: revision 1.6
sys/dev/fdt/amdccp_fdt.c: revision 1.7

Add amdsmn(4) and amdccp(4) power management stubs.
 1.43 19-Mar-2022  riastradh rnd(9): Adjust IPL of locks used by rndsource callbacks.

These no longer ever run from hard interrupt context or with a spin
lock held, so there is no longer any need to have them at IPL_VM to
block hard interrupts. Instead, lower them to IPL_SOFTSERIAL.
 1.42 30-May-2020  jdolecek remove #if 0'ed pci_conf_print() call
 1.41 30-Apr-2020  riastradh rnd_attach_source calls the callback itself now.

No need for every driver to explicitly call it to prime the pool.

Eliminate now-unused <sys/rndpool.h>.
 1.40 30-Apr-2020  riastradh Don't attach rndsource until it's actually ready to run.
 1.39 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.38 10-Aug-2014  tls branches: 1.38.4;
Merge tls-earlyentropy branch into HEAD.
 1.37 13-Jun-2013  tls branches: 1.37.6;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.36 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.35 30-Jan-2012  drochner branches: 1.35.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.34 07-Feb-2010  pgoyette branches: 1.34.12; 1.34.16;
Recognize the i2c bus on the AMD768 PCI-ISA/LPC Bridge

Resolves PR/42759 - thanks Michael Stapelberg
 1.33 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.32 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.31 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.30 28-Apr-2008  martin branches: 1.30.14;
Remove clause 3 and 4 from TNF licenses
 1.29 10-Apr-2008  cegger branches: 1.29.2; 1.29.4;
use aprint_*_dev and device_xname
 1.28 19-Oct-2007  ad branches: 1.28.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.27 26-Aug-2007  xtraeme branches: 1.27.2; 1.27.6;
There's no need to add timecounter code inside of __HAVE_TIMECOUNTER
ifdefs.
 1.26 09-Jul-2007  ad branches: 1.26.2; 1.26.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.25 05-Feb-2007  jmcneill branches: 1.25.6; 1.25.8;
Disgusting Xbox hack;

The "pci0 dev 1 function 2" aka "System Management" on the nForce chipset
isn't detected on the Xbox. If XBOX is defined and arch_i386_is_xbox is
true, force intrline to 12 and map the system management IO space at
0x8000. We can now call iic_smbus_intr when a system management interrupt
takes place.

While we're here, make amdpm_smbus honour the I2C_F_POLL flag.

The Xbox no longer resets when you press the eject button.
 1.24 06-Jan-2007  jmcneill Make sure that we don't use the amdpm timecounter on Xbox.
 1.23 06-Jan-2007  jmcneill nForce uses a slightly different register offset for the smbus controls;
compensate for this.
 1.22 06-Jan-2007  jmcneill Add nVidia nForce support, tested on Xbox.
 1.21 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 27-Aug-2006  christos branches: 1.19.2; 1.19.4;
restructure ifdefs
 1.18 11-Jul-2006  drochner include machine/bus.h explicitely, fixes build problem
 1.17 11-Jul-2006  drochner use timecounter code in dev/ic/acpipmtimer.*,
kill interface attribute in device declaration
 1.16 10-Jul-2006  xtraeme Attach amdpm timer on AMD8111 too, as was suggested by Nicolas Joly.
 1.15 10-Jul-2006  christos PR/33968: Nicolas Joly: amdpm(4) timer, fix and AMD8111 support
Refactor the code to use different variable names to hold each conf register
and avoid reading/witing the conf space multiple times.
 1.14 21-Jun-2006  explorer formatting nit, newline, print device name
 1.13 21-Jun-2006  explorer Actually set amdpm_timecounter.tc_priv before using it later.
 1.12 17-Jun-2006  xtraeme Support for the 24/32bit timer in the AMD 768 Power Management
Controller, to try it use `sysctl -w kern.timecounter.hardware=amdpm`.

From OpenBSD.
 1.11 19-Feb-2006  tls branches: 1.11.2; 1.11.8; 1.11.10;
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).

From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.10 28-Jan-2006  kleink branches: 1.10.2; 1.10.4;
Add support for the AMD8111 RNG; from Nicolas Joly in PR kern/32284.
 1.9 04-Dec-2005  christos branches: 1.9.2;
PR/32220: Murray Armfield: Enable AMD768 random no generator.
 1.8 28-Jun-2005  thorpej branches: 1.8.2;
Use ANSI function decls and static.
 1.7 01-Sep-2003  tls branches: 1.7.14;
Revert previous change, which was wrong. As Enami points out, we really do
want the NO_ESTIMATE flag here, because if the source doesn't have it,
rnd_add_data will *use the time the data was added directly as entropy*,
which is not a good idea either for a hardware RNG that works like this
one (periodically polled by the driver) or, really, like any other that I've
seen, because even for "interrupt when ready" RNGs the data rate (and thus
interrupt time) will vary only slightly for a given RNG configuration over
time, if at all.

The data we add _is_ counted into the pool estimage because we directly
pass in an entropy estimate.

The overloading of the NO_ESTIMATE flag with this meaning seems, to me, like
a design bug (albeit easily fixed) in the rng interface; but until that's
changed, we need to use it here.
 1.6 12-Aug-2003  tls Remove RND_FLAG_NO_ESTIMATE and comment claiming we can't estimate (which
means "count", in this context) the entropy we're adding because we poll the
device periodically. Sure, we poll it periodically, but it's a hardware
RNG -- the data returned should be random no matter when we read the
register!
 1.5 31-Jan-2003  thorpej branches: 1.5.2;
Use aprint_*().
 1.4 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.3 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 02-Jun-2002  enami branches: 1.1.2; 1.1.4; 1.1.6;
Collect random number from AMD 768MPX power management controller.
 1.1.6.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.6.1 02-Jun-2002  jdolecek file amdpm.c was added on branch kqueue on 2002-06-23 17:47:32 +0000
 1.1.4.2 20-Jun-2002  gehenna catch up with -current.
 1.1.4.1 02-Jun-2002  gehenna file amdpm.c was added on branch gehenna-devsw on 2002-06-20 16:33:29 +0000
 1.1.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 02-Jun-2002  nathanw file amdpm.c was added on branch nathanw_sa on 2002-06-20 03:45:19 +0000
 1.5.2.5 11-Dec-2005  christos Sync with head.
 1.5.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.14.3 20-Feb-2006  tron Pull up following revision(s) (requested by tls in ticket #1179):
sys/dev/pci/amdpm.c: revision 1.11
sys/dev/i2c/files.i2c: revision 1.7
sys/dev/i2c/adt7463.c: revision 1.1
sys/dev/pci/files.pci: revision 1.242 via patch
sys/dev/pci/amdpmvar.h: revision 1.1
sys/dev/i2c/adt7463reg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.192 via patch
sys/dev/pci/amdpm_smbus.c: revision 1.1
sys/dev/pci/amdpm_smbusreg.h: revision 1.1
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).
From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.7.14.2 05-Feb-2006  riz Pull up following revision(s) (requested by tls in ticket #1159):
sys/dev/pci/amdpm.c: revision 1.10
share/man/man4/amdpm.4: revision 1.4
Add support for the AMD8111 RNG; from Nicolas Joly in PR kern/32284.
 1.7.14.1 05-Feb-2006  riz Pull up following revision(s) (requested by tls in ticket #1158):
sys/dev/pci/amdpm.c: revision 1.9
PR/32220: Murray Armfield: Enable AMD768 random no generator.
 1.8.2.5 27-Oct-2007  yamt sync with head.
 1.8.2.4 03-Sep-2007  yamt sync with head.
 1.8.2.3 26-Feb-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.9.2.2 01-Mar-2006  yamt sync with head.
 1.9.2.1 01-Feb-2006  yamt sync with head.
 1.10.4.1 22-Apr-2006  simonb Sync with head.
 1.10.2.1 09-Sep-2006  rpaulo sync with head
 1.11.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.11.8.1 19-Jun-2006  chap Sync with head.
 1.11.2.3 03-Sep-2006  yamt sync with head.
 1.11.2.2 11-Aug-2006  yamt sync with head
 1.11.2.1 26-Jun-2006  yamt sync with head.
 1.19.4.2 10-Dec-2006  yamt sync with head.
 1.19.4.1 22-Oct-2006  yamt sync with head
 1.19.2.3 09-Feb-2007  ad Sync with HEAD.
 1.19.2.2 12-Jan-2007  ad Sync with head.
 1.19.2.1 18-Nov-2006  ad Sync with head.
 1.25.8.1 11-Jul-2007  mjf Sync with head.
 1.25.6.3 23-Oct-2007  ad Sync with head.
 1.25.6.2 09-Oct-2007  ad Sync with head.
 1.25.6.1 01-Jul-2007  ad Adapt to callout API change.
 1.26.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.26.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.26.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.27.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.27.2.1 06-Nov-2007  matt sync with HEAD
 1.28.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.4.3 11-Mar-2010  yamt sync with head
 1.29.4.2 16-May-2009  yamt sync with head
 1.29.4.1 16-May-2008  yamt sync with head.
 1.29.2.1 18-May-2008  yamt sync with head.
 1.30.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.16.1 18-Feb-2012  mrg merge to -current.
 1.34.12.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.34.12.2 30-Oct-2012  yamt sync with head
 1.34.12.1 17-Apr-2012  yamt sync with head
 1.35.6.4 03-Dec-2017  jdolecek update from HEAD
 1.35.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.6.2 23-Jun-2013  tls resync from head
 1.35.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.6.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.38.4.1 06-Jun-2015  skrll Sync with HEAD
 1.26 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.25 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.24 24-Apr-2021  thorpej branches: 1.24.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.23 22-Dec-2019  thorpej branches: 1.23.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.22 14-Feb-2016  chs branches: 1.22.18;
zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.21 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.20 13-Jun-2013  tls branches: 1.20.10;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.19 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.18 14-Feb-2012  pgoyette branches: 1.18.6;
Replace the xxx_acquire()/xxx_release() rwlocks with mutexes. There are
only RW_WRITERs for these, and no RW_READERs, so no need to incur the
extra overhead of allowing for both. As discussed on tech-kern.

For piixpm and ichsmb, the acquire/release protocol needs to be used,
even if the request is I2C_F_POLL'd (or if the device supports only
polled mode). Otherwise multiple requests can be running at the same
time, and they stomp on each other and create anomolous results.

Part 2 addresses my PR kern/45889

3 ACKs from releng
 1.17 19-Nov-2011  christos branches: 1.17.4;
bye xbox
 1.16 03-Feb-2009  pgoyette branches: 1.16.14;
Update the i2c_exec() functions to handle quick_read/quick_write protocol.

Although interface routines i2c_smbus_*() exist, nothing in NetBSD actually
uses them yet.
 1.15 10-Apr-2008  cegger branches: 1.15.4; 1.15.12;
use aprint_*_dev and device_xname
 1.14 27-Aug-2007  xtraeme branches: 1.14.22;
Use rwlock(9) rather than lockmgr(9).
 1.13 27-Aug-2007  xtraeme Apply some KNF.
 1.12 06-Feb-2007  jmcneill branches: 1.12.6; 1.12.14; 1.12.18;
Fix build failure for !XBOX, pointed out by Paul Goyette on current-users
 1.11 06-Feb-2007  jmcneill Another Xbox hack;

If we're handling system management interrupts ourselves, the system locks
solid when the ACPI timer SCI fires. Disable this interrupt so we can have
an uptime of more than ~10 minutes.
 1.10 05-Feb-2007  jmcneill Disgusting Xbox hack;

The "pci0 dev 1 function 2" aka "System Management" on the nForce chipset
isn't detected on the Xbox. If XBOX is defined and arch_i386_is_xbox is
true, force intrline to 12 and map the system management IO space at
0x8000. We can now call iic_smbus_intr when a system management interrupt
takes place.

While we're here, make amdpm_smbus honour the I2C_F_POLL flag.

The Xbox no longer resets when you press the eject button.
 1.9 06-Jan-2007  jmcneill There is absolutely no way that this code could have worked for reading
values from the smbus before. amdpm_smbus_exec was using the values read
from the registers and using them as return values instead of filling in
the caller's buffer.
 1.8 06-Jan-2007  jmcneill nForce uses a slightly different register offset for the smbus controls;
compensate for this.
 1.7 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 24-Sep-2006  jmcneill Use /* ... */ for comment instead of // ...
 1.4 26-Jun-2006  drochner branches: 1.4.4; 1.4.6; 1.4.8;
use the "i2cbus" interface attribute rather than putting a string name
into the i2cbus attach args
 1.3 30-Apr-2006  xtraeme branches: 1.3.4; 1.3.6;
PR kern/32913: amdpm(4) smbus/i2cbus needs locking. Apply patch
from Nicolas Joly.
 1.2 19-Feb-2006  xtraeme branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12;
Add __KERNEL_RCSID.
 1.1 19-Feb-2006  tls Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).

From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.2.12.3 01-Jun-2006  kardel Sync with head.
 1.2.12.2 22-Apr-2006  simonb Sync with head.
 1.2.12.1 19-Feb-2006  simonb file amdpm_smbus.c was added on branch simonb-timecounters on 2006-04-22 11:39:13 +0000
 1.2.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.8.1 11-May-2006  elad sync with head
 1.2.6.2 11-Aug-2006  yamt sync with head
 1.2.6.1 24-May-2006  yamt sync with head.
 1.2.4.2 01-Mar-2006  yamt sync with head.
 1.2.4.1 19-Feb-2006  yamt file amdpm_smbus.c was added on branch yamt-uio_vmspace on 2006-03-01 09:28:21 +0000
 1.2.2.2 20-Feb-2006  tron Pull up following revision(s) (requested by tls in ticket #1179):
sys/dev/pci/amdpm.c: revision 1.11
sys/dev/i2c/files.i2c: revision 1.7
sys/dev/i2c/adt7463.c: revision 1.1
sys/dev/pci/files.pci: revision 1.242 via patch
sys/dev/pci/amdpmvar.h: revision 1.1
sys/dev/i2c/adt7463reg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.192 via patch
sys/dev/pci/amdpm_smbus.c: revision 1.1
sys/dev/pci/amdpm_smbusreg.h: revision 1.1
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).
From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.2.2.1 19-Feb-2006  tron file amdpm_smbus.c was added on branch netbsd-3 on 2006-02-20 23:00:27 +0000
 1.3.6.5 03-Sep-2007  yamt sync with head.
 1.3.6.4 26-Feb-2007  yamt sync with head.
 1.3.6.3 30-Dec-2006  yamt sync with head.
 1.3.6.2 21-Jun-2006  yamt sync with head.
 1.3.6.1 30-Apr-2006  yamt file amdpm_smbus.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:03 +0000
 1.3.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.4.8.2 10-Dec-2006  yamt sync with head.
 1.4.8.1 22-Oct-2006  yamt sync with head
 1.4.6.2 09-Sep-2006  rpaulo sync with head
 1.4.6.1 26-Jun-2006  rpaulo file amdpm_smbus.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:16 +0000
 1.4.4.3 09-Feb-2007  ad Sync with HEAD.
 1.4.4.2 12-Jan-2007  ad Sync with head.
 1.4.4.1 18-Nov-2006  ad Sync with head.
 1.12.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.12.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.12.6.1 09-Oct-2007  ad Sync with head.
 1.14.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.12.1 03-Mar-2009  skrll Sync with HEAD.
 1.15.4.1 04-May-2009  yamt sync with head.
 1.16.14.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.14.2 30-Oct-2012  yamt sync with head
 1.16.14.1 17-Apr-2012  yamt sync with head
 1.17.4.1 18-Feb-2012  mrg merge to -current.
 1.18.6.3 03-Dec-2017  jdolecek update from HEAD
 1.18.6.2 23-Jun-2013  tls resync from head
 1.18.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.20.10.2 19-Mar-2016  skrll Sync with HEAD
 1.20.10.1 06-Jun-2015  skrll Sync with HEAD
 1.22.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.23.10.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.24.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 16-Sep-2021  andvar fix typos in word "successfully", mainly s/succesfully/successfully/.
 1.2 03-Feb-2009  pgoyette Update the i2c_exec() functions to handle quick_read/quick_write protocol.

Although interface routines i2c_smbus_*() exist, nothing in NetBSD actually
uses them yet.
 1.1 19-Feb-2006  tls branches: 1.1.2; 1.1.4; 1.1.12; 1.1.18; 1.1.24; 1.1.78; 1.1.88;
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).

From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.1.88.1 03-Mar-2009  skrll Sync with HEAD.
 1.1.78.1 04-May-2009  yamt sync with head.
 1.1.24.2 09-Sep-2006  rpaulo sync with head
 1.1.24.1 19-Feb-2006  rpaulo file amdpm_smbusreg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:16 +0000
 1.1.18.2 21-Jun-2006  yamt sync with head.
 1.1.18.1 19-Feb-2006  yamt file amdpm_smbusreg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:03 +0000
 1.1.12.2 22-Apr-2006  simonb Sync with head.
 1.1.12.1 19-Feb-2006  simonb file amdpm_smbusreg.h was added on branch simonb-timecounters on 2006-04-22 11:39:13 +0000
 1.1.4.2 01-Mar-2006  yamt sync with head.
 1.1.4.1 19-Feb-2006  yamt file amdpm_smbusreg.h was added on branch yamt-uio_vmspace on 2006-03-01 09:28:21 +0000
 1.1.2.2 20-Feb-2006  tron Pull up following revision(s) (requested by tls in ticket #1179):
sys/dev/pci/amdpm.c: revision 1.11
sys/dev/i2c/files.i2c: revision 1.7
sys/dev/i2c/adt7463.c: revision 1.1
sys/dev/pci/files.pci: revision 1.242 via patch
sys/dev/pci/amdpmvar.h: revision 1.1
sys/dev/i2c/adt7463reg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.192 via patch
sys/dev/pci/amdpm_smbus.c: revision 1.1
sys/dev/pci/amdpm_smbusreg.h: revision 1.1
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).
From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.1.2.1 19-Feb-2006  tron file amdpm_smbusreg.h was added on branch netbsd-3 on 2006-02-20 23:00:27 +0000
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 06-Jan-2007  jmcneill branches: 1.3.40; 1.3.42; 1.3.44;
Add nVidia nForce support, tested on Xbox.
 1.2 17-Jun-2006  xtraeme branches: 1.2.4;
Support for the 24/32bit timer in the AMD 768 Power Management
Controller, to try it use `sysctl -w kern.timecounter.hardware=amdpm`.

From OpenBSD.
 1.1 02-Jun-2002  enami branches: 1.1.2; 1.1.4; 1.1.6; 1.1.28; 1.1.42; 1.1.46; 1.1.52; 1.1.54;
Collect random number from AMD 768MPX power management controller.
 1.1.54.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.52.1 19-Jun-2006  chap Sync with head.
 1.1.46.1 26-Jun-2006  yamt sync with head.
 1.1.42.1 09-Sep-2006  rpaulo sync with head
 1.1.28.2 26-Feb-2007  yamt sync with head.
 1.1.28.1 21-Jun-2006  yamt sync with head.
 1.1.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.6.1 02-Jun-2002  jdolecek file amdpmreg.h was added on branch kqueue on 2002-06-23 17:47:32 +0000
 1.1.4.2 20-Jun-2002  gehenna catch up with -current.
 1.1.4.1 02-Jun-2002  gehenna file amdpmreg.h was added on branch gehenna-devsw on 2002-06-20 16:33:29 +0000
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 02-Jun-2002  nathanw file amdpmreg.h was added on branch nathanw_sa on 2002-06-20 03:45:19 +0000
 1.2.4.1 12-Jan-2007  ad Sync with head.
 1.3.44.1 16-May-2008  yamt sync with head.
 1.3.42.1 18-May-2008  yamt sync with head.
 1.3.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.12 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.11 13-Apr-2015  riastradh branches: 1.11.18;
Convert sys/dev to use <sys/rndsource.h>.
 1.10 13-Jun-2013  tls branches: 1.10.10;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.9 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.8 14-Feb-2012  pgoyette branches: 1.8.6;
Replace the xxx_acquire()/xxx_release() rwlocks with mutexes. There are
only RW_WRITERs for these, and no RW_READERs, so no need to incur the
extra overhead of allowing for both. As discussed on tech-kern.

For piixpm and ichsmb, the acquire/release protocol needs to be used,
even if the request is I2C_F_POLL'd (or if the device supports only
polled mode). Otherwise multiple requests can be running at the same
time, and they stomp on each other and create anomolous results.

Part 2 addresses my PR kern/45889

3 ACKs from releng
 1.7 19-Nov-2011  tls branches: 1.7.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.6 28-Apr-2008  martin branches: 1.6.34;
Remove clause 3 and 4 from TNF licenses
 1.5 27-Aug-2007  xtraeme branches: 1.5.22; 1.5.24; 1.5.26;
Use rwlock(9) rather than lockmgr(9).
 1.4 05-Feb-2007  jmcneill branches: 1.4.6; 1.4.14; 1.4.18;
Disgusting Xbox hack;

The "pci0 dev 1 function 2" aka "System Management" on the nForce chipset
isn't detected on the Xbox. If XBOX is defined and arch_i386_is_xbox is
true, force intrline to 12 and map the system management IO space at
0x8000. We can now call iic_smbus_intr when a system management interrupt
takes place.

While we're here, make amdpm_smbus honour the I2C_F_POLL flag.

The Xbox no longer resets when you press the eject button.
 1.3 06-Jan-2007  jmcneill Add nVidia nForce support, tested on Xbox.
 1.2 30-Apr-2006  xtraeme branches: 1.2.6; 1.2.10; 1.2.12;
PR kern/32913: amdpm(4) smbus/i2cbus needs locking. Apply patch
from Nicolas Joly.
 1.1 19-Feb-2006  tls branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).

From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.1.12.3 01-Jun-2006  kardel Sync with head.
 1.1.12.2 22-Apr-2006  simonb Sync with head.
 1.1.12.1 19-Feb-2006  simonb file amdpmvar.h was added on branch simonb-timecounters on 2006-04-22 11:39:13 +0000
 1.1.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.8.1 11-May-2006  elad sync with head
 1.1.6.1 24-May-2006  yamt sync with head.
 1.1.4.2 01-Mar-2006  yamt sync with head.
 1.1.4.1 19-Feb-2006  yamt file amdpmvar.h was added on branch yamt-uio_vmspace on 2006-03-01 09:28:21 +0000
 1.1.2.2 20-Feb-2006  tron Pull up following revision(s) (requested by tls in ticket #1179):
sys/dev/pci/amdpm.c: revision 1.11
sys/dev/i2c/files.i2c: revision 1.7
sys/dev/i2c/adt7463.c: revision 1.1
sys/dev/pci/files.pci: revision 1.242 via patch
sys/dev/pci/amdpmvar.h: revision 1.1
sys/dev/i2c/adt7463reg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.192 via patch
sys/dev/pci/amdpm_smbus.c: revision 1.1
sys/dev/pci/amdpm_smbusreg.h: revision 1.1
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).
From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.1.2.1 19-Feb-2006  tron file amdpmvar.h was added on branch netbsd-3 on 2006-02-20 23:00:27 +0000
 1.2.12.2 09-Sep-2006  rpaulo sync with head
 1.2.12.1 30-Apr-2006  rpaulo file amdpmvar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:16 +0000
 1.2.10.2 09-Feb-2007  ad Sync with HEAD.
 1.2.10.1 12-Jan-2007  ad Sync with head.
 1.2.6.4 03-Sep-2007  yamt sync with head.
 1.2.6.3 26-Feb-2007  yamt sync with head.
 1.2.6.2 21-Jun-2006  yamt sync with head.
 1.2.6.1 30-Apr-2006  yamt file amdpmvar.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:03 +0000
 1.4.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.4.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.4.6.1 09-Oct-2007  ad Sync with head.
 1.5.26.1 16-May-2008  yamt sync with head.
 1.5.24.1 18-May-2008  yamt sync with head.
 1.5.22.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.34.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.34.2 30-Oct-2012  yamt sync with head
 1.6.34.1 17-Apr-2012  yamt sync with head
 1.7.2.1 18-Feb-2012  mrg merge to -current.
 1.8.6.3 03-Dec-2017  jdolecek update from HEAD
 1.8.6.2 23-Jun-2013  tls resync from head
 1.8.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.10.10.1 06-Jun-2015  skrll Sync with HEAD
 1.11.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.68 02-Feb-2024  andvar fix various typos in comments.
 1.67 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.66 24-Apr-2021  thorpej branches: 1.66.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.65 10-Nov-2019  chs branches: 1.65.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.64 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.63 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.62 27-Sep-2016  pgoyette branches: 1.62.14; 1.62.16;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.61 14-Jul-2016  msaitoh branches: 1.61.2;
KNF. No functional change.
 1.60 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.59 02-Mar-2015  christos From Tom Ivar Helbekkmo:

- Use mutexes and condvars instead of spl() calls.
- Add a couple of bugfixes from FreeBSD (the easily observed ones).
- Add a simple watchdog thread for the newer versions of the hardware,
that tickles the controller at task submission time if it seems not ready
(from FreeBSD).
- Add a buffer allocation size hack to the ioctl handler, to work around
a firmware bug in some versions of the controller (also from FreeBSD).
- Rearrange the bus_dmamap_sync() calls to make the use match the
documentation.
 1.58 25-Jul-2014  dholland branches: 1.58.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.57 29-Mar-2014  christos branches: 1.57.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.56 16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.55 27-Jul-2012  jakllsch branches: 1.55.2; 1.55.4;
Convert amr(4) to device_t (CFATTACH_DECL_NEW).
 1.54 13-Nov-2010  uebayasi branches: 1.54.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.53 26-Nov-2009  njoly branches: 1.53.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.52 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.51 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.50 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.49 08-Jun-2008  tsutsui branches: 1.49.12;
Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
 1.48 28-Apr-2008  martin branches: 1.48.2;
Remove clause 3 and 4 from TNF licenses
 1.47 10-Apr-2008  cegger branches: 1.47.2; 1.47.4;
use aprint_*_dev and device_xname
 1.46 19-Oct-2007  ad branches: 1.46.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.45 09-Jul-2007  ad branches: 1.45.6; 1.45.8; 1.45.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.44 04-Mar-2007  christos branches: 1.44.2; 1.44.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.43 02-Dec-2006  elad branches: 1.43.2;
Change kauth(9) KPI for kauth_authorize_device_passthru() to add another
argument, u_long, serving as a bit-mask of generic requests for the
passthru request.

Discussed on tech-security@ and tech-kern@. Okay tls@.
 1.42 25-Nov-2006  christos branches: 1.42.2;
spell precede; from Zafer
 1.41 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.40 08-Nov-2006  elad Replace securelevel checks with kauth(9) calls.
 1.39 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.38 27-Aug-2006  christos branches: 1.38.2; 1.38.4;
- static needs to be first
- complete the cdevsw
 1.37 23-Aug-2006  christos Acting as Elad's keyboard:

Place the securelevel checks in their logical locations.
This will be clearer in the future when code changes to use kauth(9) calls.

input and okay ad@
 1.36 23-Jul-2006  bouyer Add a /dev/amr* control file for amr(4) devices, which allows sending raw
commands to the controller.
Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and individual
drives).
From FreeBSD, with some adjustements by Andrew Doran and me.
 1.35 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.34 17-Apr-2006  elad branches: 1.34.2;
Fix typos.
 1.33 15-Apr-2006  he The type returned by __arraycount() is a size_t, not an int, so print it
with %zd and not %d.
 1.32 14-Apr-2006  christos Coverity CID 1535: Avoid reading past the end of arrays because we don't
pay proper attention to the number of logical drives each controller can
support.
 1.31 11-Dec-2005  jonathan branches: 1.31.4; 1.31.6; 1.31.8; 1.31.10; 1.31.12;
Add pcidevs entries and support to amr(4) for newer LSI MegaRAID devices,
including the LSI MegaRAID SCSI 320-0x, 320-2x, 320-4x, 320-1E, 320-2E,
the LSI MegaRAID SATA 300-6x and 300-8x.

Tested on an LSI MegaRAID SATA 300-8x, which confirms private advice
that after PCI-IDs to our amr(4) driver, the newer LSI MegaRAID cards
will Just Work

The Linux megaraid2 driver accepts various Intel cards with the same
pci-device IDs as the LSI MegaRAID cards, treating them exaclty as the
above-listed LSI cards. Rework our amr(4) driver to also match and
attach those device-ID if seen with an Intel vendor-ID. Add the
Intel-vendor PCI decice-ids to pcidevs, so that PCI_VERBOSE will
correctly identify the Intel cards.

Update src/share/man/man4/amr.4 to list the newly-supported cards.

(NB: I don't have the LSI SCSI or any Intel cards to test, just the
LSI SATA, which works fine for me.)
 1.30 11-Dec-2005  christos merge ktrace-lwp.
 1.29 26-Aug-2005  drochner kill some more simple submatch() functions, use config_stdsubmatch()
 1.28 25-Aug-2005  drochner replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
 1.27 28-Jun-2005  thorpej branches: 1.27.2;
Use ANSI function decls and static.
 1.26 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.25 27-Feb-2005  perry branches: 1.25.2;
nuke trailing whitespace
 1.24 28-Oct-2004  martti branches: 1.24.4; 1.24.6;
Added Dell PERC 4/SC
 1.23 20-Oct-2004  martti Added support for DELL PERC 4e/Si RAID controller
 1.22 13-Sep-2004  drochner a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.21 02-Sep-2004  he Make this driver recognize LSI Logic MegaRAID 320-2 RAID controllers.
Fixes PR#26834, patch from that PR.
 1.20 22-Apr-2004  itojun sprintf -> snprintf
 1.19 05-Nov-2003  fvdl branches: 1.19.2;
Apparently, Dell PERC 4/Di controllers can have two memory BARs, with the
second one empty. The previous revision made it pick the empty one.
Reinstate the BAR size check.
 1.18 29-Oct-2003  mycroft Rework to remove bogus initializers. Also fixes a potential problem with
amr_teardown() unmapping too much.
 1.17 25-Oct-2003  christos Fix completely bogus printf that used uninitialized variables.
 1.16 25-Oct-2003  christos Fix uninitialized variable warnings
 1.15 21-Oct-2003  fvdl Don't pass NULL as an integer value.
 1.14 14-Oct-2003  martti Added another Dell PERC 4/Di
 1.13 13-Oct-2003  ad Make this work with the newer 'Quartz' controllers.
 1.12 26-Sep-2003  matt Add DELL Perc 4/di (from Freebsd).
 1.11 15-May-2003  fvdl branches: 1.11.2;
Fix reversed arguments to bus_space_unmap.
 1.10 14-May-2003  ad Fix thinko.
 1.9 04-May-2003  ad - Fix the mailbox protocol. Not tested with newer 'Quartz' controllers.
- Handle failure during initalisation more gracefully.
- Create a watchdog thread to poke the board and check for status changes.
- Make ready for > 64kB transfers.
 1.8 31-Jan-2003  thorpej Use aprint_*().
 1.7 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.2 01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.1 30-Jan-2002  ad branches: 1.1.2; 1.1.4; 1.1.12;
Bare-bones driver for AMI RAID. Parts taken from FreeBSD. This was tried a
good while ago and it had problems under load. Changes were made to address
that, but I don't have the ability to test them. So, I'm committing it
before it rots.
 1.1.12.1 20-Jun-2002  gehenna catch up with -current.
 1.1.4.5 03-Jan-2003  thorpej Sync with HEAD.
 1.1.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 30-Jan-2002  nathanw file amr.c was added on branch nathanw_sa on 2002-02-28 04:13:57 +0000
 1.1.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 30-Jan-2002  jdolecek file amr.c was added on branch kqueue on 2002-02-11 20:09:55 +0000
 1.11.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.11.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.2 03-Sep-2004  skrll Sync with HEAD
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.3 12-Nov-2004  jmc Pullup rev 1.24 (requested by martti in ticket #953)

Added Dell PERC 4/SC
 1.19.2.2 12-Nov-2004  jmc Pullup rev 1.23 (requested by martti in ticket #947)

Added support for DELL PERC 4e/Si RAID controller
 1.19.2.1 11-Sep-2004  tron Pull up revision 1.21 (requested by he in ticket #826):
Make this driver recognize LSI Logic MegaRAID 320-2 RAID controllers.
Fixes PR#26834, patch from that PR.
 1.24.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.24.4.1 29-Apr-2005  kent sync with -current
 1.25.2.2 30-Jul-2006  tron Apply patch (requested by bouyer in ticket #1431):
- Add a /dev/amr* control file for amr(4) devices, which allows sending
raw commands to the controller.
- Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and
individual drives).
 1.25.2.1 15-Dec-2005  tron Pull up following revision(s) (requested by jonathan in ticket #1047):
share/man/man4/amr.4: revision 1.11
sys/dev/pci/amr.c: revision 1.31
sys/dev/pci/pcidevs: revision 1.746 via patch
Add pcidevs entries and support to amr(4) for newer LSI MegaRAID devices,
including the LSI MegaRAID SCSI 320-0x, 320-2x, 320-4x, 320-1E, 320-2E,
the LSI MegaRAID SATA 300-6x and 300-8x.
Tested on an LSI MegaRAID SATA 300-8x, which confirms private advice
that after PCI-IDs to our amr(4) driver, the newer LSI MegaRAID cards
will Just Work
The Linux megaraid2 driver accepts various Intel cards with the same
pci-device IDs as the LSI MegaRAID cards, treating them exaclty as the
above-listed LSI cards. Rework our amr(4) driver to also match and
attach those device-ID if seen with an Intel vendor-ID. Add the
Intel-vendor PCI decice-ids to pcidevs, so that PCI_VERBOSE will
correctly identify the Intel cards.
Update src/share/man/man4/amr.4 to list the newly-supported cards.
(NB: I don't have the LSI SCSI or any Intel cards to test, just the
LSI SATA, which works fine for me.)
 1.27.2.4 27-Oct-2007  yamt sync with head.
 1.27.2.3 03-Sep-2007  yamt sync with head.
 1.27.2.2 30-Dec-2006  yamt sync with head.
 1.27.2.1 21-Jun-2006  yamt sync with head.
 1.31.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.31.10.1 19-Apr-2006  elad sync with head.
 1.31.8.4 03-Sep-2006  yamt sync with head.
 1.31.8.3 11-Aug-2006  yamt sync with head
 1.31.8.2 26-Jun-2006  yamt sync with head.
 1.31.8.1 24-May-2006  yamt sync with head.
 1.31.6.2 22-Apr-2006  simonb Sync with head.
 1.31.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.31.4.1 09-Sep-2006  rpaulo sync with head
 1.34.2.1 19-Jun-2006  chap Sync with head.
 1.38.4.2 10-Dec-2006  yamt sync with head.
 1.38.4.1 22-Oct-2006  yamt sync with head
 1.38.2.2 12-Jan-2007  ad Sync with head.
 1.38.2.1 18-Nov-2006  ad Sync with head.
 1.42.2.1 04-Dec-2006  tron Pull up following revision(s) (requested by elad in ticket #247):
sys/dev/ic/dpt.c: revision 1.55
sys/dev/pci/amr.c: revision 1.43
sys/secmodel/bsd44/secmodel_bsd44_securelevel.c: revision 1.19
sys/dev/pci/mly.c: revision 1.33
share/man/man9/kauth.9: revision 1.37
sys/dev/ic/mlx.c: revision 1.49
sys/dev/ic/icp_ioctl.c: revision 1.14
sys/dev/i2o/iop.c: revision 1.62
sys/dev/pci/twe.c: revision 1.82
sys/sys/kauth.h: revision 1.25
sys/dev/i2o/dpti.c: revision 1.31
sys/kern/kern_auth.c: revision 1.33
sys/dev/tc/stic.c: revision 1.37
Change kauth(9) KPI for kauth_authorize_device_passthru() to add another
argument, u_long, serving as a bit-mask of generic requests for the
passthru request.
Discussed on tech-security@ and tech-kern@. Okay tls@.
 1.43.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.44.4.1 11-Jul-2007  mjf Sync with head.
 1.44.2.4 23-Oct-2007  ad Sync with head.
 1.44.2.3 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.44.2.2 10-Apr-2007  ad Nuke the deferred kthread creation stuff, as it's no longer needed.
Pointed out by thorpej@.
 1.44.2.1 09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.45.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.45.8.1 06-Nov-2007  matt sync with HEAD
 1.45.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.16.3 29-Jun-2008  mjf Sync with HEAD.
 1.46.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.46.16.1 05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.47.4.4 11-Mar-2010  yamt sync with head
 1.47.4.3 16-May-2009  yamt sync with head
 1.47.4.2 04-May-2009  yamt sync with head.
 1.47.4.1 16-May-2008  yamt sync with head.
 1.47.2.2 17-Jun-2008  yamt sync with head.
 1.47.2.1 18-May-2008  yamt sync with head.
 1.48.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.49.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.4.1 05-Mar-2011  rmind sync with head
 1.54.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.54.8.1 30-Oct-2012  yamt sync with head
 1.55.4.1 18-May-2014  rmind sync with head
 1.55.2.3 03-Dec-2017  jdolecek update from HEAD
 1.55.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.2.1 12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.57.2.1 10-Aug-2014  tls Rebase.
 1.58.4.3 05-Oct-2016  skrll Sync with HEAD
 1.58.4.2 09-Jul-2016  skrll Sync with HEAD
 1.58.4.1 06-Apr-2015  skrll Sync with HEAD
 1.61.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.62.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.62.16.1 10-Jun-2019  christos Sync with HEAD
 1.62.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.62.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.65.10.3 28-Mar-2021  thorpej Correct the names of the arguments passed to the rescan function.
 1.65.10.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.65.10.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.66.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 23-Jul-2006  bouyer branches: 1.1.2; 1.1.6; 1.1.10; 1.1.16;
Add a /dev/amr* control file for amr(4) devices, which allows sending raw
commands to the controller.
Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and individual
drives).
From FreeBSD, with some adjustements by Andrew Doran and me.
 1.1.16.2 30-Dec-2006  yamt sync with head.
 1.1.16.1 23-Jul-2006  yamt file amrio.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:41 +0000
 1.1.10.2 09-Sep-2006  rpaulo sync with head
 1.1.10.1 23-Jul-2006  rpaulo file amrio.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:16 +0000
 1.1.6.2 11-Aug-2006  yamt sync with head
 1.1.6.1 23-Jul-2006  yamt file amrio.h was added on branch yamt-pdpolicy on 2006-08-11 15:44:25 +0000
 1.1.2.2 30-Jul-2006  tron Apply patch (requested by bouyer in ticket #1431):
- Add a /dev/amr* control file for amr(4) devices, which allows sending
raw commands to the controller.
- Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and
individual drives).
 1.1.2.1 23-Jul-2006  tron file amrio.h was added on branch netbsd-3 on 2006-07-30 16:38:59 +0000
 1.6 15-Aug-2023  mrg amr(4): fix the size of the the drive format array.

now this is actually 1024 bytes long, like it wants to be.

found by GCC 12.
 1.5 08-Sep-2008  gmcgarry Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.4 28-Apr-2008  martin branches: 1.4.2; 1.4.6;
Remove clause 3 and 4 from TNF licenses
 1.3 23-Jul-2006  bouyer branches: 1.3.54; 1.3.56; 1.3.58;
Add a /dev/amr* control file for amr(4) devices, which allows sending raw
commands to the controller.
Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and individual
drives).
From FreeBSD, with some adjustements by Andrew Doran and me.
 1.2 04-May-2003  ad branches: 1.2.16; 1.2.18; 1.2.32; 1.2.36;
- Fix the mailbox protocol. Not tested with newer 'Quartz' controllers.
- Handle failure during initalisation more gracefully.
- Create a watchdog thread to poke the board and check for status changes.
- Make ready for > 64kB transfers.
 1.1 30-Jan-2002  ad branches: 1.1.2; 1.1.4;
Bare-bones driver for AMI RAID. Parts taken from FreeBSD. This was tried a
good while ago and it had problems under load. Changes were made to address
that, but I don't have the ability to test them. So, I'm committing it
before it rots.
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 30-Jan-2002  nathanw file amrreg.h was added on branch nathanw_sa on 2002-02-28 04:13:57 +0000
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 30-Jan-2002  jdolecek file amrreg.h was added on branch kqueue on 2002-02-11 20:09:55 +0000
 1.2.36.1 11-Aug-2006  yamt sync with head
 1.2.32.1 09-Sep-2006  rpaulo sync with head
 1.2.18.1 30-Dec-2006  yamt sync with head.
 1.2.16.1 30-Jul-2006  tron Apply patch (requested by bouyer in ticket #1431):
- Add a /dev/amr* control file for amr(4) devices, which allows sending
raw commands to the controller.
- Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and
individual drives).
 1.3.58.2 04-May-2009  yamt sync with head.
 1.3.58.1 16-May-2008  yamt sync with head.
 1.3.56.1 18-May-2008  yamt sync with head.
 1.3.54.2 28-Sep-2008  mjf Sync with HEAD.
 1.3.54.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.6.1 19-Oct-2008  haad Sync with HEAD.
 1.4.2.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.10 02-Mar-2015  christos From Tom Ivar Helbekkmo:

- Use mutexes and condvars instead of spl() calls.
- Add a couple of bugfixes from FreeBSD (the easily observed ones).
- Add a simple watchdog thread for the newer versions of the hardware,
that tickles the controller at task submission time if it seems not ready
(from FreeBSD).
- Add a buffer allocation size hack to the ioctl handler, to work around
a firmware bug in some versions of the controller (also from FreeBSD).
- Rearrange the bus_dmamap_sync() calls to make the use match the
documentation.
 1.9 27-Jul-2012  jakllsch branches: 1.9.2; 1.9.16;
Convert amr(4) to device_t (CFATTACH_DECL_NEW).
 1.8 28-Apr-2008  martin branches: 1.8.34;
Remove clause 3 and 4 from TNF licenses
 1.7 09-Jul-2007  ad branches: 1.7.28; 1.7.30; 1.7.32;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6 23-Jul-2006  bouyer branches: 1.6.14; 1.6.16;
Add a /dev/amr* control file for amr(4) devices, which allows sending raw
commands to the controller.
Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and individual
drives).
From FreeBSD, with some adjustements by Andrew Doran and me.
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.8;
merge ktrace-lwp.
 1.4 13-Sep-2004  drochner branches: 1.4.10; 1.4.12;
a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.3 14-May-2003  ad branches: 1.3.2;
Fix thinko.
 1.2 04-May-2003  ad - Fix the mailbox protocol. Not tested with newer 'Quartz' controllers.
- Handle failure during initalisation more gracefully.
- Create a watchdog thread to poke the board and check for status changes.
- Make ready for > 64kB transfers.
 1.1 30-Jan-2002  ad branches: 1.1.2; 1.1.4;
Bare-bones driver for AMI RAID. Parts taken from FreeBSD. This was tried a
good while ago and it had problems under load. Changes were made to address
that, but I don't have the ability to test them. So, I'm committing it
before it rots.
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 30-Jan-2002  nathanw file amrvar.h was added on branch nathanw_sa on 2002-02-28 04:13:57 +0000
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 30-Jan-2002  jdolecek file amrvar.h was added on branch kqueue on 2002-02-11 20:09:55 +0000
 1.3.2.2 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.1 18-Sep-2004  skrll Sync with HEAD.
 1.4.12.2 03-Sep-2007  yamt sync with head.
 1.4.12.1 30-Dec-2006  yamt sync with head.
 1.4.10.1 30-Jul-2006  tron Apply patch (requested by bouyer in ticket #1431):
- Add a /dev/amr* control file for amr(4) devices, which allows sending
raw commands to the controller.
- Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and
individual drives).
 1.5.8.1 11-Aug-2006  yamt sync with head
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.16.1 11-Jul-2007  mjf Sync with head.
 1.6.14.1 09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.7.32.1 16-May-2008  yamt sync with head.
 1.7.30.1 18-May-2008  yamt sync with head.
 1.7.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.34.1 30-Oct-2012  yamt sync with head
 1.9.16.1 06-Apr-2015  skrll Sync with HEAD
 1.9.2.1 03-Dec-2017  jdolecek update from HEAD
 1.3 05-Dec-2007  xtraeme branches: 1.3.8;
Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.2 04-Dec-2007  xtraeme Use a rwlock(4) for arc_lock/unlock. arc_msgbuf() is too fragile and
we want to be sure that only one consumer is using it at a time.
 1.1 04-Dec-2007  xtraeme Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.

arc0 at pci2 dev 14 function 0: interrupting at ioapic0 pin 18 (irq 5)
arc0: Areca ARC-1210 Host Adapter RAID controller
arc0: 4 ports, 256MB SDRAM, firmware <V1.43 2007-4-17>
scsibus0 at arc0: 16 targets, 8 luns per target
[...]
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <Areca, ARC-1210-VOL#00, R001> disk fixed
sd0: 465 GB, 56514 cyl, 36 head, 480 sec, 512 bytes/sect x 976562176 sectors
sd1 at scsibus0 target 0 lun 1: <Areca, ARC-1210-VOL#01, R001> disk fixed
sd1: 465 GB, 56514 cyl, 36 head, 480 sec, 512 bytes/sect x 976562176 sectors

bioctl(4) output with two RAID0 volumes:

Volume Status Size Device
arc0 0 Online 466G ARC-1210-VOL#00 RAID0
0 Online 234G 0:0.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:1.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
arc0 1 Online 466G ARC-1210-VOL#01 RAID0
0 Online 234G 0:2.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:3.0 noencl <WDC WD2500YS-01SHB1 20.06C06>

The driver still needs changes related to locking and talking to the
firmware, which sometimes is unable to answer...

Raid card donated by Areca Technology Corporation via Trent George.
Disks used for testing were contributed by TNF.

Thank you very much.
 1.3.8.2 05-Dec-2007  xtraeme Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.3.8.1 05-Dec-2007  xtraeme file arc.c was added on branch mjf-devfs on 2007-12-05 00:18:08 +0000
 1.45 09-Feb-2024  andvar s/firwmare/firmware/ in comments.
 1.44 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.43 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.42 13-Jun-2021  mlelstv branches: 1.42.2;
Fix race when freeing sensors.
 1.41 24-Apr-2021  thorpej branches: 1.41.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.40 01-Oct-2019  chs branches: 1.40.10;
in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.39 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.38 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.37 12-Aug-2017  mlelstv branches: 1.37.2; 1.37.4;
tag arcmsr scsipi adapter and pci interrupt as MPSAFE. I/O is now done
without taking kernel lock.
 1.36 19-Jun-2016  dholland more NBIO > 0
(not sure why test-compiling yesterday didn't expose these, probably
improper cflags)
 1.35 19-Jun-2016  dholland Broaden the #if NBIO > 0 block. Should fix broken evbppc build.
 1.34 12-Jun-2016  christos Make internal functions static to avoid conflicts with arc_* from zfs.
 1.33 02-May-2016  christos move scsipi_strvis -> libkern:strnvisx()
change the prototype to match userland
fix sizes of strings passed to it
 1.32 12-Mar-2015  christos Dedup the conversion of bioc_disk and bioc_vol to envsys_data_t
 1.31 29-Mar-2014  christos branches: 1.31.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.30 20-Jun-2011  pgoyette branches: 1.30.2; 1.30.12; 1.30.16;
Initialize current value for ENVSYS_DRIVE sensors
 1.29 20-Jun-2011  pgoyette Initialize sensors states before registering.
 1.28 20-Jun-2011  pgoyette Maintain our own storage for volume and disk ID info rather than
(ab)using envstat's storage.

XXX Compile-tested only.
 1.27 04-Jun-2011  pgoyette Update to use the new name for the sensor's private data.

XXX This driver still uses the sensor's value_min for an unrelated
XXX purpose, but changing that will have to wait for another day.
 1.26 13-Nov-2010  uebayasi branches: 1.26.2; 1.26.6;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.25 03-Apr-2010  jruoho Only unregister the sensors if these were successfully installed;
sysmon_envsys_unregister() does not check for NULL pointers gracefully.
 1.24 03-Apr-2010  pgoyette If we're detaching the device, make sure we unregister the sensors.
 1.23 14-Mar-2010  pgoyette branches: 1.23.2;
Remove setting of edata->monitor since that member no longer exists.
 1.22 23-Sep-2008  christos branches: 1.22.14;
PR/39583: Brad du Plessis: acrmsr(4) driver doesn't report number of volumes correctly
to bioctl(8)
PR/39584: Juan RP: arcmsr(4) driver disk state values are incorrect (for ARC-1220)
 1.21 24-Jun-2008  gmcgarry branches: 1.21.2;
Replace gcc variadic macros with c99 variadic macros.
 1.20 03-Apr-2008  xtraeme branches: 1.20.4; 1.20.6; 1.20.8; 1.20.10;
Add ARC_FW_DISK_INITIALIZED flag for device_state and do not treat
it as unknown; in this state the disk is correctly working so set it
as online.

Also remove some bogus htole32() for diskinfo->device_state.

This should fix PR kern/38299 by Hiroyuki Bessho.
 1.19 05-Mar-2008  xtraeme Split device_t/softc, and other related cosmetic changes.
 1.18 03-Mar-2008  xtraeme Detect and initialize correctly RAID 1+0 levels.
 1.17 01-Mar-2008  xtraeme RAID 1/1+0 volumes may only be created with foreground initialization,
use the quick_init member in the ARC_FW_CREATE_VOLUME command code.

You can now create RAID 1/1+0 volumes through bioctl(8), but only one
volume will be initialized; the other ones that need initialization will
wait until the first is done.
 1.16 01-Mar-2008  xtraeme arc_create_sensors: if there are no valid volumes (all passthru volumes),
just exit from the kthread.
 1.15 29-Feb-2008  xtraeme arc_bio_inq: ask the firmware only once for the ARC_FW_SYSINFO
command code and use the softc values on the next bio requests.
 1.14 29-Feb-2008  xtraeme If a disk has been disconnected in a volume set, mark it as offline
and put it on another bus and print "disk missing"... the OpenBSD driver
does that but I forgot to re-add it.

Also save some values provided by the firmware in the softc and use them
in the bio(4) ioctls, this speeds up considerably bioctl(8) and avoids
so many firmware commands every time we want the current status.
 1.13 29-Feb-2008  xtraeme arc_refresh_sensors: show rebuilding status.
 1.12 29-Feb-2008  xtraeme arc_bio_disk_novol: don't forget to free diskinfo if arc_msgbuf
returns an error.
 1.11 28-Feb-2008  xtraeme If pmf_device_register1() fails for some reason, make it panic(9)
rather than printing an error. The shutdown handler is mandatory on
this driver to flush controller's cache or stopping background
rebuilds.
 1.10 28-Feb-2008  xtraeme Register a sensor per disk connected to a valid volume, so that we
can get more details if state on a disk or volume has changed,
previously only state about the volume was available.

You'll see something like this with envstat(8) now:

$ envstat -darcmsr0
RAID 5 volume0 (sd0): building
disk0 volume0 (sd0): online
disk1 volume0 (sd0): online
disk2 volume0 (sd0): online
disk3 volume0 (sd0): online
$

Convert the driver to use pmf(9) and register a shutdown power handler
via pmf_device_register1() that was added recently.

Misc cosmetics tweaks while I'm here.
 1.9 02-Jan-2008  xtraeme branches: 1.9.2; 1.9.4; 1.9.6; 1.9.10;
New functionality for arcmsr(4) native management via bioctl(8):

Added support to create/remove hot-spare, pass-through disks.
Added support to create/remove volume sets.
Added support to show information about physical disks, even if they
are marked unused, hot-spares or pass-through.

sd(4) devices are attached/detached automagically when a pass-through
disk or volume set is created/removed... thanks scsipi(9) and cube@
for hints.
 1.8 07-Dec-2007  xtraeme branches: 1.8.2; 1.8.4; 1.8.6; 1.8.10; 1.8.12;
Add BIOC_SVMIGRATING to bio(4) and bioctl(8) to report if a volume
is migrating currently showing the percentage.

Update arcmsr(4) to report this, like:

$ sudo ./bioctl -h arcmsr0
Volume Status Size Device
arcmsr0 0 Migrating 698G ARC-1210-VOL#00 RAID 5 7% done
0 Online 234G 0:0.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:1.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
2 Online 234G 0:2.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
3 Online 234G 0:3.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
$
 1.7 07-Dec-2007  xtraeme - Improve the locking based in comments from ad@.
- malloc(9) -> kmem(9) now that most of the bio code doesn't need to run
on interrupt context.
- Reduce code that runs in interrupt context to a small part in
arc_msgbuf() and is protected by arc_lock()/arc_unlock().

Reviewed and help by ad@.
 1.6 05-Dec-2007  gmcgarry Fix locking botch.
 1.5 05-Dec-2007  xtraeme Boh! I spoke too soon before, without the rwlock(9) sometimes
arc_wait() waits forever, so put it back until I figure any other way
to remove the rwlock(9).
 1.4 05-Dec-2007  xtraeme Use SCSIPI_CHAN_NOSETTLE... the driver doesn't have to wait.
 1.3 05-Dec-2007  xtraeme Make it use mutex(9) and condvar(9), bye bye spl(9) and tsleep(9).

Fully stable with all debugging options turned on, unless someday any
problem appears :-)
 1.2 05-Dec-2007  xtraeme - arc_msgbuf: free wbuf and rbuf with the correct type (M_TEMP vs M_DEVBUF)
this fixes a panic with debugging options.
- Do not use a callout to refresh sensor data, and make it available
every time someone requests it.
- Enable ENVSYS_FMONSTCHANGED for notifications in the volumes.
 1.1 05-Dec-2007  xtraeme Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.8.12.1 08-Jan-2008  bouyer Sync with HEAD
 1.8.10.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.10.1 07-Dec-2007  jmcneill file arcmsr.c was added on branch jmcneill-pm on 2007-12-09 19:37:52 +0000
 1.8.6.3 18-Feb-2008  mjf Sync with HEAD.
 1.8.6.2 08-Dec-2007  mjf Sync with HEAD.
 1.8.6.1 07-Dec-2007  mjf file arcmsr.c was added on branch mjf-devfs on 2007-12-08 18:19:41 +0000
 1.8.4.2 08-Dec-2007  ad Sync with head.
 1.8.4.1 07-Dec-2007  ad file arcmsr.c was added on branch vmlocking2 on 2007-12-08 17:57:25 +0000
 1.8.2.4 17-Mar-2008  yamt sync with head.
 1.8.2.3 21-Jan-2008  yamt sync with head
 1.8.2.2 07-Dec-2007  yamt sync with head
 1.8.2.1 07-Dec-2007  yamt file arcmsr.c was added on branch yamt-lazymbuf on 2007-12-07 17:30:22 +0000
 1.9.10.4 28-Sep-2008  mjf Sync with HEAD.
 1.9.10.3 29-Jun-2008  mjf Sync with HEAD.
 1.9.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.6.1 24-Mar-2008  keiichi sync with head.
 1.9.4.4 24-Sep-2008  bouyer Pull up following revision(s) (requested by christos in ticket #1205):
sys/dev/pci/arcmsrvar.h: revision 1.13
sys/dev/pci/arcmsr.c: revision 1.22
PR/39583: Brad du Plessis: acrmsr(4) driver doesn't report number of
volumes correctly
to bioctl(8)
PR/39584: Juan RP: arcmsr(4) driver disk state values are incorrect (for
ARC-1220)
 1.9.4.3 29-Aug-2008  bouyer Apply patch, requested by christos in tickets #1175:
sys/dev/bio.c patch
sys/dev/biovar.h patch
sys/dev/pci/arcmsr.c patch
sys/dev/pci/arcmsrvar.h patch
sbin/bioctl/Makefile patch
sbin/bioctl/bioctl.8 patch
sbin/bioctl/bioctl.c patch
sbin/bioctl/dehumanize_number.c patch
sbin/bioctl/strtonum.c patch
sbin/bioctl/strtonum.h patch

Port bioctl(8) and arcmsr(4) from current:
bioctl(8): Rewritten to handle new features like creating/removing
hot-spare, pass-through disks and RAID volumes, start/stop
consistency checks in volumes and others.
arcmsr(4): Added support to create/remove hot-spare, pass-through
disks and RAID volumes, start/stop consistency checks
in volumes as well as showing information about physical
disks (even if they are marked as hot-spare, pass-through
or unused).
 1.9.4.2 11-Jan-2008  xtraeme Pull up following revision(s) (requested by christos in ticket #1037):
sys/dev/pci/arcmsr.c: patch
sys/dev/pci/arcmsrvar.h: patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/files.pci: patch
sys/arch/i386/conf/GENERIC: patch
sys/arch/i386/conf/XEN2_DOM0: patch
sys/arch/i386/conf/INSTALL_LARGE: patch
sys/arch/amd64/conf/GENERIC: patch
sys/arch/amd64/conf/INSTALL: patch
share/man/man4/Makefile: patch
share/man/man4/arcmsr.4: patch
distrib/sets/lists/man/mi: patch

Add the Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.
 1.9.4.1 02-Jan-2008  xtraeme file arcmsr.c was added on branch netbsd-4 on 2008-01-11 17:03:16 +0000
 1.9.2.3 23-Mar-2008  matt sync with HEAD
 1.9.2.2 09-Jan-2008  matt sync with HEAD
 1.9.2.1 02-Jan-2008  matt file arcmsr.c was added on branch matt-armv6 on 2008-01-09 01:53:32 +0000
 1.20.10.1 27-Jun-2008  simonb Sync with head.
 1.20.8.3 04-Sep-2008  skrll Sync with netbsd-4.
 1.20.8.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.20.8.1 03-Apr-2008  skrll file arcmsr.c was added on branch wrstuden-fixsa on 2008-06-03 20:47:23 +0000
 1.20.6.2 10-Oct-2008  skrll Sync with HEAD.
 1.20.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.20.4.2 11-Aug-2010  yamt sync with head.
 1.20.4.1 04-May-2009  yamt sync with head.
 1.21.2.1 19-Oct-2008  haad Sync with HEAD.
 1.22.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.23.2.3 12-Jun-2011  rmind sync with head
 1.23.2.2 05-Mar-2011  rmind sync with head
 1.23.2.1 30-May-2010  rmind sync with head
 1.26.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.16.1 18-May-2014  rmind sync with head
 1.30.12.3 03-Dec-2017  jdolecek update from HEAD
 1.30.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.12.1 02-Dec-2012  tls Areca controller maximum-transfer size limits -- looked up in FreeBSD
driver.

Actually exporting the per-volume transfer size for this driver will
be quite hard; the controller firmware shows the host the configured
volumes when the host probes the controller's "scsibus", and we can't
really associate them with particular RAID volumes until later. I think
we will have to intercept the SCSI inquiry commands -- yuck.
 1.30.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31.6.4 28-Aug-2017  skrll Sync with HEAD
 1.31.6.3 09-Jul-2016  skrll Sync with HEAD
 1.31.6.2 29-May-2016  skrll Sync with HEAD
 1.31.6.1 06-Apr-2015  skrll Sync with HEAD
 1.37.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.4.1 10-Jun-2019  christos Sync with HEAD
 1.37.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.37.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.40.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.41.2.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.42.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.16 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.15 12-Jun-2016  christos Make internal functions static to avoid conflicts with arc_* from zfs.
 1.14 20-Jun-2011  pgoyette branches: 1.14.12; 1.14.30;
Maintain our own storage for volume and disk ID info rather than
(ab)using envstat's storage.

XXX Compile-tested only.
 1.13 23-Sep-2008  christos branches: 1.13.26;
PR/39583: Brad du Plessis: acrmsr(4) driver doesn't report number of volumes correctly
to bioctl(8)
PR/39584: Juan RP: arcmsr(4) driver disk state values are incorrect (for ARC-1220)
 1.12 03-Apr-2008  xtraeme branches: 1.12.4; 1.12.6; 1.12.8; 1.12.12;
Add ARC_FW_DISK_INITIALIZED flag for device_state and do not treat
it as unknown; in this state the disk is correctly working so set it
as online.

Also remove some bogus htole32() for diskinfo->device_state.

This should fix PR kern/38299 by Hiroyuki Bessho.
 1.11 05-Mar-2008  xtraeme Split device_t/softc, and other related cosmetic changes.
 1.10 29-Feb-2008  xtraeme If a disk has been disconnected in a volume set, mark it as offline
and put it on another bus and print "disk missing"... the OpenBSD driver
does that but I forgot to re-add it.

Also save some values provided by the firmware in the softc and use them
in the bio(4) ioctls, this speeds up considerably bioctl(8) and avoids
so many firmware commands every time we want the current status.
 1.9 28-Feb-2008  xtraeme Register a sensor per disk connected to a valid volume, so that we
can get more details if state on a disk or volume has changed,
previously only state about the volume was available.

You'll see something like this with envstat(8) now:

$ envstat -darcmsr0
RAID 5 volume0 (sd0): building
disk0 volume0 (sd0): online
disk1 volume0 (sd0): online
disk2 volume0 (sd0): online
disk3 volume0 (sd0): online
$

Convert the driver to use pmf(9) and register a shutdown power handler
via pmf_device_register1() that was added recently.

Misc cosmetics tweaks while I'm here.
 1.8 03-Jan-2008  xtraeme branches: 1.8.2; 1.8.4; 1.8.6; 1.8.10;
Fix indentation.
 1.7 02-Jan-2008  xtraeme New functionality for arcmsr(4) native management via bioctl(8):

Added support to create/remove hot-spare, pass-through disks.
Added support to create/remove volume sets.
Added support to show information about physical disks, even if they
are marked unused, hot-spares or pass-through.

sd(4) devices are attached/detached automagically when a pass-through
disk or volume set is created/removed... thanks scsipi(9) and cube@
for hints.
 1.6 09-Dec-2007  xtraeme branches: 1.6.4; 1.6.6;
Erm fix some defines in previous...
 1.5 08-Dec-2007  xtraeme branches: 1.5.2; 1.5.4;
Add some more firmware command/status codes from the freebsd driver.
 1.4 05-Dec-2007  xtraeme branches: 1.4.2;
Boh! I spoke too soon before, without the rwlock(9) sometimes
arc_wait() waits forever, so put it back until I figure any other way
to remove the rwlock(9).
 1.3 05-Dec-2007  xtraeme Make it use mutex(9) and condvar(9), bye bye spl(9) and tsleep(9).

Fully stable with all debugging options turned on, unless someday any
problem appears :-)
 1.2 05-Dec-2007  xtraeme - arc_msgbuf: free wbuf and rbuf with the correct type (M_TEMP vs M_DEVBUF)
this fixes a panic with debugging options.
- Do not use a callout to refresh sensor data, and make it available
every time someone requests it.
- Enable ENVSYS_FMONSTCHANGED for notifications in the volumes.
 1.1 05-Dec-2007  xtraeme Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.4.2.4 17-Mar-2008  yamt sync with head.
 1.4.2.3 21-Jan-2008  yamt sync with head
 1.4.2.2 07-Dec-2007  yamt sync with head
 1.4.2.1 05-Dec-2007  yamt file arcmsrvar.h was added on branch yamt-lazymbuf on 2007-12-07 17:30:23 +0000
 1.5.4.4 18-Feb-2008  mjf Sync with HEAD.
 1.5.4.3 27-Dec-2007  mjf Sync with HEAD.
 1.5.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.5.4.1 08-Dec-2007  mjf file arcmsrvar.h was added on branch mjf-devfs on 2007-12-08 18:19:41 +0000
 1.5.2.3 26-Dec-2007  ad Sync with head.
 1.5.2.2 08-Dec-2007  ad Sync with head.
 1.5.2.1 08-Dec-2007  ad file arcmsrvar.h was added on branch vmlocking2 on 2007-12-08 17:57:26 +0000
 1.6.6.1 08-Jan-2008  bouyer Sync with HEAD
 1.6.4.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.6.4.1 09-Dec-2007  jmcneill file arcmsrvar.h was added on branch jmcneill-pm on 2007-12-09 19:37:53 +0000
 1.8.10.3 28-Sep-2008  mjf Sync with HEAD.
 1.8.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.6.1 24-Mar-2008  keiichi sync with head.
 1.8.4.4 24-Sep-2008  bouyer Pull up following revision(s) (requested by christos in ticket #1205):
sys/dev/pci/arcmsrvar.h: revision 1.13
sys/dev/pci/arcmsr.c: revision 1.22
PR/39583: Brad du Plessis: acrmsr(4) driver doesn't report number of
volumes correctly
to bioctl(8)
PR/39584: Juan RP: arcmsr(4) driver disk state values are incorrect (for
ARC-1220)
 1.8.4.3 29-Aug-2008  bouyer Apply patch, requested by christos in tickets #1175:
sys/dev/bio.c patch
sys/dev/biovar.h patch
sys/dev/pci/arcmsr.c patch
sys/dev/pci/arcmsrvar.h patch
sbin/bioctl/Makefile patch
sbin/bioctl/bioctl.8 patch
sbin/bioctl/bioctl.c patch
sbin/bioctl/dehumanize_number.c patch
sbin/bioctl/strtonum.c patch
sbin/bioctl/strtonum.h patch

Port bioctl(8) and arcmsr(4) from current:
bioctl(8): Rewritten to handle new features like creating/removing
hot-spare, pass-through disks and RAID volumes, start/stop
consistency checks in volumes and others.
arcmsr(4): Added support to create/remove hot-spare, pass-through
disks and RAID volumes, start/stop consistency checks
in volumes as well as showing information about physical
disks (even if they are marked as hot-spare, pass-through
or unused).
 1.8.4.2 11-Jan-2008  xtraeme Pull up following revision(s) (requested by christos in ticket #1037):
sys/dev/pci/arcmsr.c: patch
sys/dev/pci/arcmsrvar.h: patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/files.pci: patch
sys/arch/i386/conf/GENERIC: patch
sys/arch/i386/conf/XEN2_DOM0: patch
sys/arch/i386/conf/INSTALL_LARGE: patch
sys/arch/amd64/conf/GENERIC: patch
sys/arch/amd64/conf/INSTALL: patch
share/man/man4/Makefile: patch
share/man/man4/arcmsr.4: patch
distrib/sets/lists/man/mi: patch

Add the Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.
 1.8.4.1 03-Jan-2008  xtraeme file arcmsrvar.h was added on branch netbsd-4 on 2008-01-11 17:03:17 +0000
 1.8.2.3 23-Mar-2008  matt sync with HEAD
 1.8.2.2 09-Jan-2008  matt sync with HEAD
 1.8.2.1 03-Jan-2008  matt file arcmsrvar.h was added on branch matt-armv6 on 2008-01-09 01:53:33 +0000
 1.12.12.1 19-Oct-2008  haad Sync with HEAD.
 1.12.8.3 04-Sep-2008  skrll Sync with netbsd-4.
 1.12.8.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.12.8.1 03-Apr-2008  skrll file arcmsrvar.h was added on branch wrstuden-fixsa on 2008-06-03 20:47:24 +0000
 1.12.6.1 10-Oct-2008  skrll Sync with HEAD.
 1.12.4.1 04-May-2009  yamt sync with head.
 1.13.26.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.30.1 09-Jul-2016  skrll Sync with HEAD
 1.14.12.2 03-Dec-2017  jdolecek update from HEAD
 1.14.12.1 02-Dec-2012  tls Areca controller maximum-transfer size limits -- looked up in FreeBSD
driver.

Actually exporting the per-volume transfer size for this driver will
be quite hard; the controller firmware shows the host the configured
volumes when the host probes the controller's "scsibus", and we can't
really associate them with particular RAID volumes until later. I think
we will have to intercept the SCSI inquiry commands -- yuck.
 1.3 05-Dec-2007  xtraeme branches: 1.3.8;
Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.2 04-Dec-2007  xtraeme Use a rwlock(4) for arc_lock/unlock. arc_msgbuf() is too fragile and
we want to be sure that only one consumer is using it at a time.
 1.1 04-Dec-2007  xtraeme Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.

arc0 at pci2 dev 14 function 0: interrupting at ioapic0 pin 18 (irq 5)
arc0: Areca ARC-1210 Host Adapter RAID controller
arc0: 4 ports, 256MB SDRAM, firmware <V1.43 2007-4-17>
scsibus0 at arc0: 16 targets, 8 luns per target
[...]
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <Areca, ARC-1210-VOL#00, R001> disk fixed
sd0: 465 GB, 56514 cyl, 36 head, 480 sec, 512 bytes/sect x 976562176 sectors
sd1 at scsibus0 target 0 lun 1: <Areca, ARC-1210-VOL#01, R001> disk fixed
sd1: 465 GB, 56514 cyl, 36 head, 480 sec, 512 bytes/sect x 976562176 sectors

bioctl(4) output with two RAID0 volumes:

Volume Status Size Device
arc0 0 Online 466G ARC-1210-VOL#00 RAID0
0 Online 234G 0:0.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:1.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
arc0 1 Online 466G ARC-1210-VOL#01 RAID0
0 Online 234G 0:2.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:3.0 noencl <WDC WD2500YS-01SHB1 20.06C06>

The driver still needs changes related to locking and talking to the
firmware, which sometimes is unable to answer...

Raid card donated by Areca Technology Corporation via Trent George.
Disks used for testing were contributed by TNF.

Thank you very much.
 1.3.8.2 05-Dec-2007  xtraeme Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.3.8.1 05-Dec-2007  xtraeme file arcvar.h was added on branch mjf-devfs on 2007-12-05 00:18:08 +0000
 1.30 23-Jan-2023  andvar s/cyliner/cylinder/ and s/specturm/spectrum/ in messages.
 1.29 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.28 20-Oct-2017  jdolecek branches: 1.28.2; 1.28.4;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.27 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.26 29-Mar-2014  christos branches: 1.26.18;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.25 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.24 31-Jul-2012  bouyer branches: 1.24.2; 1.24.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.23 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.22 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.21 04-Apr-2011  dyoung branches: 1.21.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.20 05-Nov-2010  jakllsch branches: 1.20.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.19 26-Nov-2009  njoly branches: 1.19.2; 1.19.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.18 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.17 18-Mar-2008  cube branches: 1.17.2; 1.17.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.16 19-Jul-2007  dsl branches: 1.16.6; 1.16.22; 1.16.26; 1.16.28;
include cdefs.h before any opt_xxx.h
 1.15 09-Feb-2007  ad branches: 1.15.6; 1.15.14;
Merge newlock2 to head.
 1.14 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.13 25-Oct-2006  bouyer Use common wdc_sataprobe() where possible; explain why we can't in satalink.c
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 26-Jun-2006  xtraeme branches: 1.11.4; 1.11.6;
Add missing __KERNEL_RCSID()
 1.10 29-Mar-2006  thorpej branches: 1.10.4;
Use device_cfdata().
 1.9 16-Jan-2006  bouyer branches: 1.9.2; 1.9.4; 1.9.6; 1.9.8; 1.9.10;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.8 11-Dec-2005  christos branches: 1.8.2;
merge ktrace-lwp.
 1.7 27-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 12-Feb-2005  rearnsha Change PCIIDE_I31244_ENABLEDMA to PCIIDE_I31244_DISABLEDMA as
suggested by briggs. Put the flag in opt_pciide.h.
 1.5 11-Feb-2005  rearnsha Add support for the Artisea device operating in DPA mode.

Approved by briggs.
 1.4 20-Aug-2004  thorpej branches: 1.4.4; 1.4.6;
Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.3 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.2 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.1 14-Dec-2003  thorpej branches: 1.1.4;
Split the Intel i31244 SATA controller ("Artisea") driver out of piixide
into its own driver (artsata).
 1.1.4.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.6 15-Feb-2005  skrll Sync with HEAD.
 1.1.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 14-Dec-2003  skrll file artsata.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.4.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.6.1 12-Feb-2005  yamt sync with head.
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.7.4.5 24-Mar-2008  yamt sync with head.
 1.7.4.4 03-Sep-2007  yamt sync with head.
 1.7.4.3 26-Feb-2007  yamt sync with head.
 1.7.4.2 30-Dec-2006  yamt sync with head.
 1.7.4.1 21-Jun-2006  yamt sync with head.
 1.8.2.1 01-Feb-2006  yamt sync with head.
 1.9.10.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.9.8.1 19-Apr-2006  elad sync with head.
 1.9.6.2 11-Aug-2006  yamt sync with head
 1.9.6.1 01-Apr-2006  yamt sync with head.
 1.9.4.1 22-Apr-2006  simonb Sync with head.
 1.9.2.1 09-Sep-2006  rpaulo sync with head
 1.10.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.11.6.2 10-Dec-2006  yamt sync with head.
 1.11.6.1 22-Oct-2006  yamt sync with head
 1.11.4.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.11.4.1 18-Nov-2006  ad Sync with head.
 1.15.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.15.6.1 12-Oct-2007  ad Fix merge errors.
 1.16.28.2 19-Jul-2007  dsl include cdefs.h before any opt_xxx.h
 1.16.28.1 19-Jul-2007  dsl file artsata.c was added on branch matt-mips64 on 2007-07-19 21:53:16 +0000
 1.16.26.2 02-Jun-2008  mjf Sync with HEAD.
 1.16.26.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.22.1 24-Mar-2008  keiichi sync with head.
 1.16.6.1 23-Mar-2008  matt sync with HEAD
 1.17.4.2 11-Mar-2010  yamt sync with head
 1.17.4.1 16-May-2008  yamt sync with head.
 1.17.2.1 18-May-2008  yamt sync with head.
 1.19.4.2 21-Apr-2011  rmind sync with head
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.19.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.20.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.21.4.1 30-Oct-2012  yamt sync with head
 1.24.4.1 18-May-2014  rmind sync with head
 1.24.2.3 03-Dec-2017  jdolecek update from HEAD
 1.24.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.26.18.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.28.4.1 10-Jun-2019  christos Sync with HEAD
 1.28.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.16 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.15 30-Nov-2018  jmcneill Add support for polling com devices when no interrupt is available.
 1.14 29-Mar-2014  christos branches: 1.14.28; 1.14.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.13 27-Oct-2012  chs branches: 1.13.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.12 13-Nov-2010  uebayasi branches: 1.12.8; 1.12.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.11 26-Nov-2009  njoly branches: 1.11.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 16-Apr-2008  cegger branches: 1.9.2; 1.9.4;
device_t / softc split. From Hans Rosenfeld.
 1.8 15-Apr-2008  cegger device_t / softc split. From Hans Rosenfeld
 1.7 10-Apr-2008  cegger use aprint_*_dev and device_xname
 1.6 19-Oct-2007  ad branches: 1.6.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 04-Mar-2007  christos branches: 1.5.2; 1.5.14; 1.5.16; 1.5.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 11-Dec-2005  christos branches: 1.4.26;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 10-Feb-2004  jdolecek branches: 1.2.4; 1.2.10; 1.2.12;
checkpoint DMA support; still disabled, not tested yet
 1.1 25-Jan-2004  jdolecek add puc(4) atppc(4) attachment; probes correctly, but needs further
work to support DMA, and some actual transfer testing
 1.2.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.10.1 29-Apr-2005  kent sync with -current
 1.2.4.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 10-Feb-2004  skrll file atppc_puc.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.3.4.2 27-Oct-2007  yamt sync with head.
 1.3.4.1 03-Sep-2007  yamt sync with head.
 1.4.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.16.1 06-Nov-2007  matt sync with HEAD
 1.5.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.2.1 23-Oct-2007  ad Sync with head.
 1.6.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.4.2 11-Mar-2010  yamt sync with head
 1.9.4.1 16-May-2008  yamt sync with head.
 1.9.2.1 18-May-2008  yamt sync with head.
 1.11.4.1 05-Mar-2011  rmind sync with head
 1.12.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.12.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.8.1 30-Oct-2012  yamt sync with head
 1.13.2.1 18-May-2014  rmind sync with head
 1.14.30.1 10-Jun-2019  christos Sync with HEAD
 1.14.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.39 29-Feb-2020  isaki round_blocksize must return a multiple of the framesize
even if 6 channels mode.
I believe that keeping "good alignment" is just a wish, not constraint.
 1.38 08-Jun-2019  isaki branches: 1.38.2; 1.38.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.37 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.36 16-Mar-2019  isaki branches: 1.36.2;
Use C99 style struct initializer to audio_hw_if.
 1.35 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.34 23-Jun-2018  maxv branches: 1.34.2;
constify
 1.33 01-Jun-2017  chs branches: 1.33.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.32 29-Mar-2014  christos branches: 1.32.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.31 27-Oct-2012  chs branches: 1.31.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.30 24-Nov-2011  mrg branches: 1.30.8;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.29 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.28 13-Nov-2010  uebayasi branches: 1.28.8; 1.28.10;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.27 24-Feb-2010  dyoung branches: 1.27.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.26 08-Jan-2010  dyoung branches: 1.26.2;
Expand PMF_FN_* macros.
 1.25 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.24 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.23 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.22 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.21 28-Apr-2008  martin branches: 1.21.12; 1.21.14;
Remove clause 3 and 4 from TNF licenses
 1.20 10-Apr-2008  cegger branches: 1.20.2; 1.20.4;
use aprint_*_dev and device_xname
 1.19 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.18 09-Dec-2007  jmcneill branches: 1.18.6; 1.18.10;
Merge jmcneill-pm branch.
 1.17 19-Oct-2007  ad branches: 1.17.4; 1.17.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 04-Mar-2007  christos branches: 1.16.2; 1.16.14; 1.16.16; 1.16.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.15 16-Nov-2006  christos branches: 1.15.4; 1.15.6;
__unused removal on arguments; approved by core.
 1.14 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.13 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.12 27-Aug-2006  christos branches: 1.12.2; 1.12.4;
add missing initializer
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.8;
merge ktrace-lwp.
 1.10 28-Jun-2005  thorpej branches: 1.10.2;
Use ANSI function decls and static.
 1.9 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.8 17-Jan-2005  augustss Make it compile with debug.
 1.7 15-Jan-2005  kent branches: 1.7.2;
ansify and KNF
 1.6 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.5 16-Nov-2004  augustss branches: 1.5.2;
Add RECORD to the conversion table, otherwise we panic on boot.
The fact that we cannot record (yet) is found out later anyway.
 1.4 13-Nov-2004  kent adopt auconv_set_converter()
 1.3 10-Nov-2004  kent move IS_FIXED_RATE(), SUPPORTS_4CH(), and SUPPORTS_6CH to ac97var.h
 1.2 09-Nov-2004  kent remove unnecessary ac97-related code
 1.1 10-Oct-2004  augustss branches: 1.1.2;
Add a driver for the Acer Labs M5455 audio controller.
This controller is integrated in some ALi Southbridges.

XXX This driver is incomplete and slightly buggy, but it
works enough to enable me to listen to music on my Sharp MM20.
 1.1.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.6 24-Jan-2005  skrll Sync with HEAD.
 1.1.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.1.2.4 29-Nov-2004  skrll Sync with HEAD.
 1.1.2.3 14-Nov-2004  skrll Sync with HEAD.
 1.1.2.2 19-Oct-2004  skrll Sync with HEAD
 1.1.2.1 10-Oct-2004  skrll file auacer.c was added on branch ktrace-lwp on 2004-10-19 15:56:57 +0000
 1.5.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.5.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.7.2.1 29-Apr-2005  kent sync with -current
 1.10.2.5 17-Mar-2008  yamt sync with head.
 1.10.2.4 21-Jan-2008  yamt sync with head
 1.10.2.3 27-Oct-2007  yamt sync with head.
 1.10.2.2 03-Sep-2007  yamt sync with head.
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.8.1 03-Sep-2006  yamt sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.4.2 10-Dec-2006  yamt sync with head.
 1.12.4.1 22-Oct-2006  yamt sync with head
 1.12.2.1 18-Nov-2006  ad Sync with head.
 1.15.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.15.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.16.3 23-Mar-2008  matt sync with HEAD
 1.16.16.2 09-Jan-2008  matt sync with HEAD
 1.16.16.1 06-Nov-2007  matt sync with HEAD
 1.16.14.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.16.14.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.16.14.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.14.1 04-Oct-2007  joerg Convert to generic PCI power handler.
 1.16.2.1 23-Oct-2007  ad Sync with head.
 1.17.6.1 11-Dec-2007  yamt sync with head.
 1.17.4.1 26-Dec-2007  ad Sync with head.
 1.18.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.18.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.18.6.1 24-Mar-2008  keiichi sync with head.
 1.20.4.3 11-Mar-2010  yamt sync with head
 1.20.4.2 16-May-2009  yamt sync with head
 1.20.4.1 16-May-2008  yamt sync with head.
 1.20.2.1 18-May-2008  yamt sync with head.
 1.21.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.12.3 13-Dec-2008  ad Fix locking for ac97.
 1.21.12.2 12-Dec-2008  ad Checkpoint work in progress.
 1.21.12.1 08-Dec-2008  ad Convert some more drivers.
 1.26.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.27.2.1 05-Mar-2011  rmind sync with head
 1.28.10.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.28.10.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.28.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.8.2 30-Oct-2012  yamt sync with head
 1.28.8.1 17-Apr-2012  yamt sync with head
 1.30.8.3 03-Dec-2017  jdolecek update from HEAD
 1.30.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.31.2.1 18-May-2014  rmind sync with head
 1.32.6.1 28-Aug-2017  skrll Sync with HEAD
 1.33.8.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.33.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.34.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.34.2.1 10-Jun-2019  christos Sync with HEAD
 1.36.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.36.2.2 27-Apr-2019  isaki Adapt to audio2.
 1.36.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.38.4.1 29-Feb-2020  ad Sync with head.
 1.38.2.1 21-Mar-2020  martin Pull up following revision(s) (requested by isaki in ticket #792):

sys/arch/amiga/dev/aucc.c: revision 1.48
sys/dev/pci/auixp.c: revision 1.49
sys/dev/pci/gcscaudio.c: revision 1.19
sys/dev/pci/auich.c: revision 1.159
sys/dev/sbus/dbri.c: revision 1.42
sys/dev/pci/auvia.c: revision 1.85
sys/dev/pci/auacer.c: revision 1.39

Drop 512 bytes limit on auvia_round_blocksize().

This fixes attach on 6 channels device.
PR kern/55017.

round_blocksize must return a multiple of the framesize.
aucc(4) supports 3 channels mode.

round_blocksize must return a multiple of the framesize
even if passed blocksize is greater than the upper limit.

round_blocksize must return a multiple of the framesize.

It's not divisible when blk=GCSCAUDI_PRD_SIZE_MAX and channels=4.
round_blocksize must return a multiple of the framesize
even if 6 channels mode.

I believe that keeping "good alignment" is just a wish, not constraint.
 1.5 08-Feb-2018  dholland Typos.
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.70; 1.3.72; 1.3.74;
merge ktrace-lwp.
 1.2 15-Jan-2005  kent ansify and KNF
 1.1 10-Oct-2004  augustss branches: 1.1.2;
Add a driver for the Acer Labs M5455 audio controller.
This controller is integrated in some ALi Southbridges.

XXX This driver is incomplete and slightly buggy, but it
works enough to enable me to listen to music on my Sharp MM20.
 1.1.2.3 17-Jan-2005  skrll Sync with HEAD.
 1.1.2.2 19-Oct-2004  skrll Sync with HEAD
 1.1.2.1 10-Oct-2004  skrll file auacerreg.h was added on branch ktrace-lwp on 2004-10-19 15:56:57 +0000
 1.3.74.1 16-May-2008  yamt sync with head.
 1.3.72.1 18-May-2008  yamt sync with head.
 1.3.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.161 10-May-2023  riastradh auich(4): Use config_detach_children.
 1.160 06-Feb-2021  isaki Hold sc_intr_lock in open()/close().
vtbl->{lock,unlock} (in fact ac97_{lock,unlock}) don't seem to need
releasing an interrupt lock.
Confirmed on auich.
 1.159 29-Feb-2020  isaki branches: 1.159.6;
round_blocksize must return a multiple of the framesize
even if 6 channels mode.
I believe that keeping "good alignment" is just a wish, not constraint.
 1.158 06-Dec-2019  maxv branches: 1.158.2;
Minor changes, reported by the LGTM bot.
 1.157 08-Jun-2019  isaki branches: 1.157.2;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.156 11-May-2019  christos Don't return the raw audio formats; return the ones after we disabled some
of them because the device does not support them. Fixes panic in virtualbox.
 1.155 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.154 18-Apr-2019  isaki branches: 1.154.2;
White space and indent fix.
 1.153 16-Mar-2019  isaki Use C99 style struct initializer to audio_hw_if.
 1.152 24-Mar-2018  jdolecek branches: 1.152.2;
use pci_intr_establish_xname()
 1.151 01-Jun-2017  chs branches: 1.151.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.150 25-Jan-2017  martin auich_round_blocksize: never return 0 as blocksize
 1.149 07-Jul-2016  msaitoh branches: 1.149.2; 1.149.4;
KNF. Remove extra spaces. No functional change.
 1.148 24-May-2015  christos PR/49926: Robert Millan: Avoid deadlock condition in auich_read_codec()
and auich_write_codec() when running in userspase.
 1.147 24-May-2015  christos PR/49927: Robert Millan: Avoid zerodivide on emulated hardware.
 1.146 24-May-2015  christos use aprint consistently; note that we use aprint_normal_dev in debugging
statements instead of aprint_debug_dev because those are controlled by
the driver debugging, not the centralized one.
 1.145 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.144 10-Aug-2014  tls branches: 1.144.4;
Merge tls-earlyentropy branch into HEAD.
 1.143 29-Mar-2014  christos branches: 1.143.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.142 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.141 02-Jun-2012  dsl branches: 1.141.2; 1.141.4;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.140 24-Nov-2011  mrg put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.139 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.138 13-Nov-2010  uebayasi branches: 1.138.8; 1.138.10;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.137 24-Feb-2010  dyoung branches: 1.137.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.136 01-Feb-2010  njoly branches: 1.136.2;
Do not print ac97 link rate message unless verbose boot is requested.
 1.135 13-Jan-2010  jakllsch Revert code I added in 1.133 that touches the PCI_COMMAND_IO_ENABLE and
PCI_COMMAND_MEM_ENABLE bits in PCI_COMMAND_STATUS_REG. This causes
problems where the BAR is 0. 'options PCI_ADDR_FIXUP' is more
appropriate when these bits are not set correctly by the BIOS.
 1.134 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.133 30-Dec-2009  jakllsch Ensure that the memory or i/o space we need is accessible at attach
and resume.

Rework register mapping code path, using 'goto', so duplicate code
is reduced.

I've tested this on nvidia and sis auich(4)-compatible controllers.
In addition this change is reported to fix PR/39652.
 1.132 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.131 12-Nov-2009  dyoung Remove superfluous activation hook.
 1.130 03-Sep-2009  sborrill SiS 7012 uses different multichannel control bits compared to other codecs
(data from linux via OpenBSD).
 1.129 17-Mar-2009  dyoung Handle child-detachment by NULL'ing the child pointer so that
auich_detach() does not subsequently dereference a dangling pointer.
 1.128 08-Nov-2008  dyoung branches: 1.128.2; 1.128.4;
To finish the device_t/softc split, convert some casts to struct
auich_softc * to device_private() calls.
 1.127 04-May-2008  xtraeme branches: 1.127.6; 1.127.8; 1.127.10; 1.127.14;
device_t/softc split and other related cosmetic changes.
 1.126 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.125 10-Apr-2008  cegger branches: 1.125.2; 1.125.4;
use aprint_*_dev and device_xname
 1.124 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.123 06-Jan-2008  kent branches: 1.123.2; 1.123.6;
fix a bug of S/PDIF audio format selection

PR/36493 by Arcady Antipin
 1.122 13-Dec-2007  jmcneill Make this compile again.
 1.121 13-Dec-2007  jmcneill Restore the native mode PCI conf register on select chipsets on resume,
in case it was lost when power was removed.
 1.120 09-Dec-2007  jmcneill branches: 1.120.2;
Merge jmcneill-pm branch.
 1.119 19-Oct-2007  ad branches: 1.119.2; 1.119.4; 1.119.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.118 02-Sep-2007  xtraeme branches: 1.118.4;
Attach to the ICH6 AC-97 Modem function.
 1.117 04-Mar-2007  christos branches: 1.117.2; 1.117.10; 1.117.14; 1.117.16;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.116 21-Feb-2007  thorpej branches: 1.116.2;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.115 16-Nov-2006  christos branches: 1.115.4;
__unused removal on arguments; approved by core.
 1.114 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.113 25-Sep-2006  jmcneill No need to call pci_set_powerstate from our powerhook, the bus handles this
for us now.
 1.112 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.111 03-Aug-2006  bsh branches: 1.111.4; 1.111.6;
Device 10de:026c is not AC-97 controller but nForce430 HD Audio controller.

Pointed out by Brad. Thanks.
 1.110 01-Aug-2006  bsh Support nForce430's audio.

(I have tested this only with nFroce410, not with nFroce430)
 1.109 28-Jul-2006  kent add support for S/PDIF.
 1.108 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.107 27-Apr-2006  jmcneill branches: 1.107.2; 1.107.4;
Disable my aggressive power saving changes; they're causing too many
problems.
 1.106 16-Apr-2006  jmcneill Use AC97_HOST_INVERTED_EAMP on the Sony VAIO VGN-B1XP. From PR#33272 by
Dieter Roelants.
 1.105 16-Apr-2006  christos Deal with machines that have inverted eamp power. Data from the FreeBSD
driver. Finally sound works on my vaio vgn-t250p.
 1.104 14-Apr-2006  rpaulo s/#ifdef DEBUG/#ifdef AUICH_DEBUG/
 1.103 07-Mar-2006  jmcneill branches: 1.103.2;
Don't try to suspend while already suspended.
 1.102 07-Mar-2006  jmcneill branches: 1.102.2;
Put the device in D3 state when it's not in use to save power.
 1.101 04-Dec-2005  xtraeme branches: 1.101.4; 1.101.6; 1.101.8;
Add support for Intel 6300ESB.
 1.100 02-Dec-2005  xtraeme Add support for ICH7. Tested by gendalia@.
 1.99 22-Aug-2005  rpaulo Use #ifdef AUICH_DEBUG instead of #if 0/#if 1. Suggested by perry@.
 1.98 21-Aug-2005  rpaulo PR#31030: debug printf in auich_halt_pipe. From lmneto@gmail.com.
It was under #if 1, so I just replaced the if by 0.
 1.97 28-Jun-2005  thorpej branches: 1.97.2;
Use ANSI function decls and static.
 1.96 20-Jun-2005  atatat Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.95 12-Apr-2005  jmcneill Some broken codecs don't release the CAS on reads to AC97_REG_GPIO_STATUS.
In auich_read_codec, do a dummy read to the RESET register if we're
reading GPIO_STATUS to be safe.
 1.94 11-Apr-2005  jmcneill i82801CA is an ICH3, not ICH2. Fix typo in auich_modem_devices. Pointed out
by Nicolas Joly.
 1.93 08-Apr-2005  jmcneill Add identifiers for Intel ICH3 AC'97 modems and CXT33 modem codecs, from
Nicolas Joly <njoly _at_ pasteur _dot_ fr>.
 1.92 07-Apr-2005  jmcneill More modem fixes:
* Ignore ICH_PCM246_MASK for modem devices
* Set LINE1 rate and level in set_params
* Enable mmap for modem devices. This was previously disallowed due to
the ext_id field not advertising that the device supported variable
rates. Since modems don't use ext_id (they use ext_mid instead), enable
mmap. Multiple rates are supported on AC'97 modems.
 1.91 04-Apr-2005  jmcneill Work-in-progress of AC'97 modem support. Currently disabled by default
(can be enabled by options AUICH_ATTACH_MODEM), and untested. Shouldn't
have any impact on auich audio capabilities.
 1.90 11-Mar-2005  mycroft branches: 1.90.2;
Three changes:
1) After setting an input or output channel to pause, watch for DCH (DMA
halted) to be set before resetting the registers. The manual says this is
required. This *may* fix random auich lockups.
2) Add auich_{trigger,intr,halt}_pipe(), which can operate on any of the
input and output channels. This reduces code duplication quite a bit.
While I'm at it, fill in the mic interrupt handling.
3) The mic in interrupt is MINT, not MIINT. (The latter is modem input.)
 1.89 27-Feb-2005  perry nuke trailing whitespace
 1.88 27-Jan-2005  jdolecek match nForce2 Ultra 400 audio
 1.87 27-Jan-2005  kent support nForce 4
 1.86 26-Jan-2005  jmcneill Add pci_conf_{capture,restore} to auich(4) powerhook
 1.85 15-Jan-2005  kent branches: 1.85.2; 1.85.4;
ansify and KNF
 1.84 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.83 11-Dec-2004  cube Some SiS 7012 chips come muted by default, so un-mute all SiS 7012 chips at
attach time the way Linux does it. Reported and tested by Jonathan
Schleifer, I checked it didn't break my own 7012 device which doesn't need
that manipulation.
 1.82 17-Nov-2004  kent branches: 1.82.2;
implement auich_activate() and auich_detach()
 1.81 17-Nov-2004  kent make functions static as possible
 1.80 13-Nov-2004  kent adopt auconv_set_converter()
 1.79 11-Nov-2004  kent device matching by pcireg_t, not a pair of vendor ID and product ID.
This change reduces 170 Byte of i386 kernel size.
 1.78 10-Nov-2004  cube Add support for the ICH6 AC97 controller.
 1.77 10-Nov-2004  cube Return an error when a read operation fails, instead of pretending it
succeeded and transmitting a bogus value.
 1.76 10-Nov-2004  cube In auich_calibrate, set sc_ac97_clock to a default value of 48000 first.
That way, if the calibration fails or times out, sc_ac97_clock won't be 0
and there won't be a division by zero later in ac97_set_rate.
 1.75 10-Nov-2004  kent move IS_FIXED_RATE(), SUPPORTS_4CH(), and SUPPORTS_6CH to ac97var.h
 1.74 06-Nov-2004  xtraeme Add support for "nForce3 250 MCP-T AC-97 Audio", from Kouichirou Hiratsuka
in PR 27843.

Ok'ed christos@
 1.73 01-Nov-2004  mycroft Some miscellaneous cleanup:
* Encapsulate all the ring-specific variables into a substructure. (This will
help with some potential code sharing.)
* Don't bother with "last buffer complete" interrupts -- we should be taking an
interrupt anyway because we set IOC on every buffer.
* Likewise, ignore CELV; it's meaningless to us.
* Get rid of the FIFO error counters, since this doesn't actually happen any
more.
 1.72 31-Oct-2004  mycroft Copyright maintenance.
 1.71 31-Oct-2004  mycroft More code reduction.
Also, allow any sample rate between 8000 and 48000Hz. (This range should
probably be larger, but this is what's known to work.)

Another 180 bytes shaved.
 1.70 31-Oct-2004  mycroft Shave another 112 bytes by reducing some divisions to shifts.
 1.69 31-Oct-2004  mycroft Fix a regression -- my previous changes made the kernel slightly larger.
 1.68 31-Oct-2004  mycroft In the trigger routines, start *all* the blocks, not just the first one. This
was causing some "fifo under/overrun" errors during the initial trigger.

Also fixes a ring synchronization problem introduced in the earlier changes.

This should completely fix the FIFO errors with auich.
 1.67 31-Oct-2004  mycroft Reorder some register writes just to be safe.
 1.66 31-Oct-2004  mycroft Attempt to mitigate "fifo underrun" errors in two ways:
1) Update the queue pointers any time we get a block completion interrupt,
not just when we hit the last block.
2) Set the "back-to-back enable" bit.
In addition:
3) Make sure we ack every block we transfer; there was a bug that could cause
the audio layer to get out of sync.
 1.65 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.64 27-Oct-2004  kent add "hw.auichN.ac97rate" sysctl MIB to specify AC'97 link rate.
It is needed because automatic calibration by auich_calibrate() is not
so precise.

- Why not ioctl?
It is not good idea to add a new ioctl operation to MI audio for
a specific audio device.
- Why not mixerctl item?
AC'97 linke rate is not related to audio mixing.
 1.63 17-Oct-2004  kent no need to restore AC97_REG_EXT_AUDIO_CTRL value on resuming
because ac97_codec_if_vtbl::restore_ports() does it.
 1.62 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.61 07-Aug-2004  soren - Don't attempt to clear the CELV bit by setting it high like the
FIFOE/BCIS/LVBCI bits; it's is cleared automatically by the hardware.
- Separate AUICH_DEBUG out from AUDIO_DEBUG and make it possible to debug
interrupt handling separately.
- A little KNF.
 1.60 09-Jul-2004  mycroft Clean up. Attempt to make these safer against stray interrupts.
 1.59 09-Jul-2004  mycroft There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.58 13-Jan-2004  kent branches: 1.58.2;
remove/modify confusing error messsges.
 1.57 03-Jan-2004  soren Only report codec readiness if DEBUG to avoid printing it on every resume.
 1.56 28-Dec-2003  kent ICH4/ICH5:
When native i/o mapping fails, try compatible i/o mapping.
 1.55 22-Nov-2003  kent For ICH4/ICH5, use native BARs instead of compatible BARs.
The patch was provided by Lars Heidieker.
 1.54 06-Nov-2003  mycroft Force the codec into a known state before trying to determine its speed.
 1.53 31-Oct-2003  kent auich_calibrate():
- make the buffer longer to improve the precision of measurement
- round off the result to the nearest multiple of 1000.
 1.52 30-Oct-2003  kent For ICH4/ICH5, set IOSE flag to make them compatible to old ICHs.
 1.51 28-Oct-2003  mycroft Eliminate bogus initializer (the code was technically wrong).
 1.50 25-Oct-2003  christos Fix uninitialized variable warnings
 1.49 24-Oct-2003  kent auich_reset_codec:
wait for readiness of one of all codecs.
 1.48 23-Oct-2003  kent Change the short names of nForce:
nForce-MCP -> nForce
nForce-MCP-T -> nForce2
nForce-MCP-T -> nForce3

Use snprintf() and strlcpy() instead of sprintf() and strcpy().
 1.47 23-Oct-2003  kent - remove unused code
- print diagnostic messages if the primary codec does not get ready in
auich_reset_codec().
 1.46 23-Oct-2003  kent No need to check the codec ready flag in read_codec() and write_codec().
According to the ICH datasheets, the flag is unchanged unless resetting
the codec.

The flag is useless after enabling bus mastering. This behavior is common
to all ICH chips. The quirk handling code is removed.
 1.45 22-Oct-2003  manu Patch from http://mail-index.netbsd.org/current-users/2003/09/04/0018.html
to fix problems with a sound card
 1.44 22-Oct-2003  fvdl Match the nForce3 AC-97 chip.
 1.43 21-Oct-2003  fvdl Add missing field initializer.
 1.42 02-Oct-2003  mycroft Cleanup:
* auich_calibrate() assumes that the AC97 part is in its reset state. To
ensure this, call audio_attach_mi() after auich_calibrate().
* Explicitly support 12000Hz and 24000Hz. (Why is there a discrete list at
all?)
* Fix an obvious recording bug -- we were acking the wrong interrupt.
* Ensure that we don't get an interrupt during the AC97 speed probe by clearing
the "interrupt on completion" bit in the DMA setup.
 1.41 28-Sep-2003  kent Support for 4ch/6ch audio playback.
 1.40 19-Aug-2003  erh Add entry for Intel 82801EB AC-97 audio. Audio sounds fine with this,
although the mixer settings are a bit odd: outputs.master doesn't do anything,
but outputs.surround does.
 1.39 13-Jun-2003  kent branches: 1.39.2;
Fix a regression of the last commit.
ICH4 needs IGNORE_CODEC_READY_MAYBE.
 1.38 13-Jun-2003  kent Not only ICH4 but also ICH0 and ICH2 might set no ICH_PCR.
The patch was provided by lha.

PR: kern/21031
 1.37 03-May-2003  wiz DMA, not dma nor Dma.
 1.36 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.35 31-Jan-2003  thorpej Use aprint_*().
 1.34 28-Jan-2003  kent Apply BUS_DMA_NOCACHE for the buffers in the case of 440MX. The
code was provided by DHOYASHIKI Shinichi in kern/19919, and
address kern/19435.
 1.33 21-Jan-2003  kent Add DIAGNOSTIC code provided in PR kern/19919 by DHOYASHIKI Shinichi.
 1.32 16-Jan-2003  gendalia add support for nForce2 MCP-T
 1.31 15-Jan-2003  kent Fixed a problem that /dev/sound can not be opened in some cases.

auich_set_rate() modified audio_params::sample_rate to actual
sample rate though auich_set_params() rejected sample rates
other than some specific rates. For example, setting 8000Hz
with auich_set_params() modified sample_rate to 7998Hz in the
case of overclocked AC97 codec, and calling auich_set_params()
again returned with EINVAL because sample_rate was 7998Hz and
auich_set_params() rejected 7998Hz.

For now, auich_set_params() never modify audio_params::sample_rate.
 1.30 12-Oct-2002  wiz Fix typo in comment.
 1.29 11-Oct-2002  kent Kick auich_calibrate() by config_interrupts().

auichi_calibrate(): If the measured rate is less than 48k, use
48k.
 1.28 08-Oct-2002  kent auich_set_params(): Don't return in the for loop.
 1.27 08-Oct-2002  kent auich_softc:
Remove sc_fixed_rate and sc_ac97rate. ac97_softc has such
information.

auich_attach():
Remove VRA/VRM enabling code. ac97_attach() does it.

auich_set_rate():
Use ac97_codec_if::set_rate().

auich_get_props():
Return no AUDIO_PROP_MMAP if the codec is fixed-rate.

auichreg.h:
Remove unnecessary ICH_PM_*.
 1.26 06-Oct-2002  kent Add some constant symbols for AC97 registers and values based on OpenBSD.
Rename some symbols to sync with OpenBSD:
AC97_REG_EXTENDED_ID
-> AC97_REG_EXT_AUDIO_ID
AC97_REG_EXTENDED_STATUS
-> AC97_REG_EXT_AUDIO_CTRL
AC97_CODEC_DOES_VRA/AC97_ENAB_VRA
-> AC97_EXT_AUDIO_VRA
AC97_CODEC_DOES_MICVRA/AC97_ENAB_MICVRA
-> AC97_EXT_AUDIO_VRM

ac97feature: "mic channel" -> "dedicated mic channel"
ac97_attach(): print extended capabilities; VRA, DRA, SPDIF, VRM, CDAC,
SDAC, LDAC.
 1.25 04-Oct-2002  kent Improve nForce MCP support.

Submitted by: FUKAUMI Naoki <naoki at fukaumi dot org>
PR: kern/18524
 1.24 02-Oct-2002  kent Remove a line added accidentally(?) at revision 1.21.
 1.23 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.22 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.21 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20 28-Aug-2002  dsainty Fix playback at 48kHz sample rate (integer overflow bug introduced in 1.18)
 1.19 16-Aug-2002  kent Fix division-by-zero when auich_set_params() is called before auich_calibrate().
 1.18 07-Aug-2002  kent - Port clock calibration code (auich_calibrate) from ich.c of FreeBSD to solve
kern/16373.
- SiS 7012 support from kern/17716 submitted by Quentin Garnier.
- ICH4 support
- Experimental support for nForce MCP, AMD768 and AMD8111.
- Rename the short name for ICH3: "i830M" -> "ICH3"
 1.17 11-Apr-2002  augustss branches: 1.17.2; 1.17.4;
When the DAC claims to support variable rate it doesn't seem to
always do this, so do some extra chechs and fall back on fixed rate.
 1.16 23-Mar-2002  kent whitespace and folding fix.
 1.15 21-Mar-2002  kent Apply a patch by Mark Davies.
http://mail-index.netbsd.org/port-i386/2002/03/18/0000.html

Check codec status in auich_read/write_codec().
 1.14 15-Mar-2002  tacha Use appropriate emulation functions and set ADC rate(not DAC date!) for recording.
Now /dev/audio with auich becomes usable.
 1.13 10-Mar-2002  kent auich_set_params() sets 2 to hw_channels whenever monaural format is requested.
 1.12 07-Mar-2002  kent Sampling rate and mono-stereo conversion described in
http://mail-index.netbsd.org/tech-kern/2002/03/04/0005.html

auconv.c: Add conversion functions

audio.c: Sample alignment, calling conversion functions, etc.

audio_if.h: Add four hw_* members to "struct audio_params"

audiovar.h: Add conversion buffers, etc.

auich and uaudio: Add conversion request code to *_set_params().
 1.11 14-Feb-2002  augustss Oops, I messed up the last commit, try again.
 1.10 14-Feb-2002  augustss Make fixed rate codecs work. From Tsuyoshi Iguchi in kern/15606.
 1.9 02-Feb-2002  augustss Make auich support variable rate codec, and suspend/resume.
From URA Hiroshi in PR kern/15431 (partly from OpenBSD).
 1.8 14-Jan-2002  augustss Add i830M to the chip list.
 1.7 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.6 12-Jan-2002  enami Skip not yet emulated 8bit ulinear encoding correctly.
 1.5 13-Nov-2001  lukem add RCSID
 1.4 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.3 28-Dec-2000  sommerfeld branches: 1.3.2; 1.3.4; 1.3.6;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.2 28-Nov-2000  thorpej branches: 1.2.2;
Use AC97_REG_* constants rather than defining them ourselves.
 1.1 28-Nov-2000  thorpej Device driver for the built-in audio on Intel ICH, ICH0, ICH2,
and i440MX chipsets. Based on a driver by Michael Shalayeff,
modified somewhat by me to use bus_dma properly, and fix some
audio encoding emulation bugs.

Thanks to Manuel Bouyer for testing and feedback.
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1 28-Nov-2000  bouyer file auich.c was added on branch thorpej_scsipi on 2000-12-08 09:12:30 +0000
 1.3.6.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.3.4.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.11 17-Jan-2003  thorpej Sync with HEAD.
 1.3.2.10 15-Jan-2003  thorpej Sync with HEAD.
 1.3.2.9 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.8 17-Sep-2002  nathanw Catch up to -current.
 1.3.2.7 27-Aug-2002  nathanw Catch up to -current.
 1.3.2.6 13-Aug-2002  nathanw Catch up to -current.
 1.3.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.3.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.17.4.1 15-Mar-2004  jmc Pullup patch (requested by kent in ticket #1612)

Add support for ICH3, ICH4, ICH5, SiS 7012, nForce MCP, nForce2 MCP-T, and
nForce3 MCP-T to auich driver
 1.17.2.1 29-Aug-2002  gehenna catch up with -current.
 1.39.2.16 11-Dec-2005  christos Sync with head.
 1.39.2.15 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.39.2.14 01-Apr-2005  skrll Sync with HEAD.
 1.39.2.13 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.39.2.12 04-Feb-2005  skrll Sync with HEAD.
 1.39.2.11 17-Jan-2005  skrll Sync with HEAD.
 1.39.2.10 18-Dec-2004  skrll Sync with HEAD.
 1.39.2.9 29-Nov-2004  skrll Sync with HEAD.
 1.39.2.8 14-Nov-2004  skrll Sync with HEAD.
 1.39.2.7 02-Nov-2004  skrll Sync with HEAD.
 1.39.2.6 19-Oct-2004  skrll Sync with HEAD
 1.39.2.5 24-Sep-2004  skrll Sync with HEAD.
 1.39.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.39.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.39.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.39.2.1 03-Aug-2004  skrll Sync with HEAD
 1.58.2.1 22-Sep-2004  jmc branches: 1.58.2.1.2;
Pullup rev 1.62 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.58.2.1.2.2 19-May-2005  tron Pull up revision 1.78 (requested by riz in ticket #1533):
Add support for the ICH6 AC97 controller.
 1.58.2.1.2.1 07-Apr-2005  tron Pull up revision 1.74 (requested by hira in ticket #1103):
Add support for "nForce3 250 MCP-T AC-97 Audio", from Kouichirou Hiratsuka
in PR 27843.
Ok'ed christos@
 1.82.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.82.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.85.4.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.85.4.1 12-Feb-2005  yamt sync with head.
 1.85.2.1 29-Apr-2005  kent sync with -current
 1.90.2.2 06-Dec-2005  riz Apply patch (requested by xtraeme in ticket #1027):
sys/dev/pci/auich.c: patch
sys/dev/pci/auichreg.h: patch
Add support for Intel ICH7 and 6300ESB.
 1.90.2.1 30-Oct-2005  jmc Pullup revs 1.98-1.99 (requested by rpaulo in ticket #920)
Fix debug printf in auich_halt_pipe. PR#31030
 1.97.2.7 17-Mar-2008  yamt sync with head.
 1.97.2.6 21-Jan-2008  yamt sync with head
 1.97.2.5 27-Oct-2007  yamt sync with head.
 1.97.2.4 03-Sep-2007  yamt sync with head.
 1.97.2.3 26-Feb-2007  yamt sync with head.
 1.97.2.2 30-Dec-2006  yamt sync with head.
 1.97.2.1 21-Jun-2006  yamt sync with head.
 1.101.8.4 11-Aug-2006  yamt sync with head
 1.101.8.3 26-Jun-2006  yamt sync with head.
 1.101.8.2 24-May-2006  yamt sync with head.
 1.101.8.1 13-Mar-2006  yamt sync with head.
 1.101.6.2 01-Jun-2006  kardel Sync with head.
 1.101.6.1 22-Apr-2006  simonb Sync with head.
 1.101.4.1 09-Sep-2006  rpaulo sync with head
 1.102.2.3 11-May-2006  elad sync with head
 1.102.2.2 19-Apr-2006  elad sync with head.
 1.102.2.1 07-Mar-2006  elad file auich.c was added on branch elad-kernelauth on 2006-04-19 03:25:33 +0000
 1.103.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.107.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.107.2.1 19-Jun-2006  chap Sync with head.
 1.111.6.2 10-Dec-2006  yamt sync with head.
 1.111.6.1 22-Oct-2006  yamt sync with head
 1.111.4.1 18-Nov-2006  ad Sync with head.
 1.115.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.115.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.116.2.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.117.16.3 23-Mar-2008  matt sync with HEAD
 1.117.16.2 09-Jan-2008  matt sync with HEAD
 1.117.16.1 06-Nov-2007  matt sync with HEAD
 1.117.14.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.117.14.6 11-Nov-2007  joerg In auich_intr, check if device is currently powered down.
 1.117.14.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.117.14.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.117.14.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.117.14.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.117.14.1 05-Aug-2007  jmcneill Convert auich powerhook to pnp power handler (untested).
 1.117.10.1 03-Sep-2007  skrll Sync with HEAD.
 1.117.2.2 23-Oct-2007  ad Sync with head.
 1.117.2.1 09-Oct-2007  ad Sync with head.
 1.118.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.119.6.1 11-Dec-2007  yamt sync with head.
 1.119.4.1 26-Dec-2007  ad Sync with head.
 1.119.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.120.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.120.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.123.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.123.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.123.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.123.2.1 24-Mar-2008  keiichi sync with head.
 1.125.4.4 11-Mar-2010  yamt sync with head
 1.125.4.3 16-Sep-2009  yamt sync with head
 1.125.4.2 04-May-2009  yamt sync with head.
 1.125.4.1 16-May-2008  yamt sync with head.
 1.125.2.1 18-May-2008  yamt sync with head.
 1.127.14.1 21-Apr-2010  matt sync to netbsd-5
 1.127.10.2 15-Jan-2010  snj Revert ticket 1218.
 1.127.10.1 09-Jan-2010  snj Pull up following revision(s) (requested by jakllsch in ticket #1218):
sys/dev/pci/auich.c: revision 1.133
Ensure that the memory or i/o space we need is accessible at attach
and resume.
Rework register mapping code path, using 'goto', so duplicate code
is reduced.
I've tested this on nvidia and sis auich(4)-compatible controllers.
In addition this change is reported to fix PR/39652.
 1.127.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.127.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.127.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.128.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.128.2.3 13-Dec-2008  ad Fix locking for ac97.
 1.128.2.2 12-Dec-2008  ad Checkpoint work in progress.
 1.128.2.1 08-Dec-2008  ad Convert some more drivers.
 1.136.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.137.2.1 05-Mar-2011  rmind sync with head
 1.138.10.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.138.10.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.138.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.138.8.2 30-Oct-2012  yamt sync with head
 1.138.8.1 17-Apr-2012  yamt sync with head
 1.141.4.1 18-May-2014  rmind sync with head
 1.141.2.2 03-Dec-2017  jdolecek update from HEAD
 1.141.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.143.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.144.4.4 28-Aug-2017  skrll Sync with HEAD
 1.144.4.3 05-Feb-2017  skrll Sync with HEAD
 1.144.4.2 09-Jul-2016  skrll Sync with HEAD
 1.144.4.1 06-Jun-2015  skrll Sync with HEAD
 1.149.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.149.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.151.8.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.152.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.152.2.1 10-Jun-2019  christos Sync with HEAD
 1.154.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.154.2.2 27-Apr-2019  isaki Adapt to audio2.
- Correct frequency_type in modem_audio_format.
- {spdif,modem}_audio_format in my previous commit (in this branch)
was also wrong. :(
 1.154.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.157.2.1 21-Mar-2020  martin Pull up following revision(s) (requested by isaki in ticket #792):

sys/arch/amiga/dev/aucc.c: revision 1.48
sys/dev/pci/auixp.c: revision 1.49
sys/dev/pci/gcscaudio.c: revision 1.19
sys/dev/pci/auich.c: revision 1.159
sys/dev/sbus/dbri.c: revision 1.42
sys/dev/pci/auvia.c: revision 1.85
sys/dev/pci/auacer.c: revision 1.39

Drop 512 bytes limit on auvia_round_blocksize().

This fixes attach on 6 channels device.
PR kern/55017.

round_blocksize must return a multiple of the framesize.
aucc(4) supports 3 channels mode.

round_blocksize must return a multiple of the framesize
even if passed blocksize is greater than the upper limit.

round_blocksize must return a multiple of the framesize.

It's not divisible when blk=GCSCAUDI_PRD_SIZE_MAX and channels=4.
round_blocksize must return a multiple of the framesize
even if 6 channels mode.

I believe that keeping "good alignment" is just a wish, not constraint.
 1.158.2.1 29-Feb-2020  ad Sync with head.
 1.159.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.13 08-Feb-2018  dholland Typos.
 1.12 03-Sep-2009  sborrill SiS 7012 uses different multichannel control bits compared to other codecs
(data from linux via OpenBSD).
 1.11 14-Jan-2008  martin branches: 1.11.10;
Make sure pci config space access only happens on 32bit aligned addresses.
 1.10 02-Dec-2005  xtraeme branches: 1.10.46; 1.10.52; 1.10.60;
Add support for ICH7. Tested by gendalia@.
 1.9 11-Apr-2005  jmcneill branches: 1.9.2;
Add ICH_CODEC_OFFSET definition
 1.8 11-Dec-2004  cube branches: 1.8.2; 1.8.8;
Some SiS 7012 chips come muted by default, so un-mute all SiS 7012 chips at
attach time the way Linux does it. Reported and tested by Jonathan
Schleifer, I checked it didn't break my own 7012 device which doesn't need
that manipulation.
 1.7 22-Nov-2003  kent For ICH4/ICH5, use native BARs instead of compatible BARs.
The patch was provided by Lars Heidieker.
 1.6 30-Oct-2003  kent For ICH4/ICH5, set IOSE flag to make them compatible to old ICHs.
 1.5 03-May-2003  wiz branches: 1.5.2;
DMA, not dma nor Dma.
 1.4 08-Oct-2002  kent auich_softc:
Remove sc_fixed_rate and sc_ac97rate. ac97_softc has such
information.

auich_attach():
Remove VRA/VRM enabling code. ac97_attach() does it.

auich_set_rate():
Use ac97_codec_if::set_rate().

auich_get_props():
Return no AUDIO_PROP_MMAP if the codec is fixed-rate.

auichreg.h:
Remove unnecessary ICH_PM_*.
 1.3 07-Aug-2002  kent - Port clock calibration code (auich_calibrate) from ich.c of FreeBSD to solve
kern/16373.
- SiS 7012 support from kern/17716 submitted by Quentin Garnier.
- ICH4 support
- Experimental support for nForce MCP, AMD768 and AMD8111.
- Rename the short name for ICH3: "i830M" -> "ICH3"
 1.2 28-Nov-2000  thorpej branches: 1.2.2; 1.2.4; 1.2.6; 1.2.18; 1.2.20;
Use AC97_REG_* constants rather than defining them ourselves.
 1.1 28-Nov-2000  thorpej Device driver for the built-in audio on Intel ICH, ICH0, ICH2,
and i440MX chipsets. Based on a driver by Michael Shalayeff,
modified somewhat by me to use bus_dma properly, and fix some
audio encoding emulation bugs.

Thanks to Manuel Bouyer for testing and feedback.
 1.2.20.1 15-Mar-2004  jmc Pullup patch (requested by kent in ticket #1612)

Add support for ICH3, ICH4, ICH5, SiS 7012, nForce MCP, nForce2 MCP-T, and
nForce3 MCP-T to auich driver
 1.2.18.1 29-Aug-2002  gehenna catch up with -current.
 1.2.6.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.4.1 13-Aug-2002  nathanw Catch up to -current.
 1.2.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1 28-Nov-2000  bouyer file auichreg.h was added on branch thorpej_scsipi on 2000-12-08 09:12:30 +0000
 1.5.2.6 11-Dec-2005  christos Sync with head.
 1.5.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.8.1 06-Dec-2005  riz Apply patch (requested by xtraeme in ticket #1027):
sys/dev/pci/auich.c: patch
sys/dev/pci/auichreg.h: patch
Add support for Intel ICH7 and 6300ESB.
 1.8.2.1 29-Apr-2005  kent sync with -current
 1.9.2.2 21-Jan-2008  yamt sync with head
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.60.1 19-Jan-2008  bouyer Sync with HEAD
 1.10.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.46.1 23-Mar-2008  matt sync with HEAD
 1.11.10.1 16-Sep-2009  yamt sync with head
 1.55 08-Feb-2024  andvar s/inlucde/include/, s/implemetation/implementation/ in comments and error msg.
 1.54 27-Aug-2022  skrll Correct the abbreviation of approximately to 'approx.'
 1.53 25-Jan-2022  andvar fix various typos in comments.
 1.52 21-Aug-2021  andvar s/helt/held+s/eroneously/erroneously/+s/splitted/split/+s/recommented/recommended/
 1.51 20-Aug-2021  andvar fix various typos in comments and log messages.
 1.50 03-Jul-2020  isaki Fix an argument passes to auixp_intr().
This is rest of rev 1.39 (split device_t/softc) in 2012.
Problem reported and tested by Riccardo Mottola.
 1.49 29-Feb-2020  isaki round_blocksize must return a multiple of the framesize
even if 6 channels mode.
I believe that keeping "good alignment" is just a wish, not constraint.
 1.48 16-Oct-2019  maya branches: 1.48.2;
Switch files copyright Reinoud Zandijk from BSD 4 clause to BSD 2 clause.

OK'd by reinoud in email (from 4 Feb 2019).
 1.47 08-Jun-2019  isaki branches: 1.47.2;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.46 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.45 16-Mar-2019  isaki branches: 1.45.2;
Use C99 style struct initializer to audio_hw_if.
 1.44 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.43 01-Jun-2017  chs branches: 1.43.8; 1.43.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.42 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.41 18-Oct-2014  snj branches: 1.41.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.40 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.39 27-Oct-2012  chs branches: 1.39.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.38 30-Jan-2012  drochner branches: 1.38.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.37 02-Dec-2011  jmcneill branches: 1.37.2;
audio cookie is a struct auixp_codec, not auixp_softc
 1.36 24-Nov-2011  mrg put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.35 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.34 24-Feb-2010  dyoung branches: 1.34.10; 1.34.12;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.33 08-Jan-2010  dyoung branches: 1.33.2;
Expand PMF_FN_* macros.
 1.32 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.31 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.30 18-Mar-2009  cegger bzero -> memset
 1.29 05-Mar-2009  msaitoh Fix typo(s/interupt/interrupt/)
 1.28 10-Apr-2008  cegger branches: 1.28.4; 1.28.12; 1.28.16; 1.28.18;
use aprint_*_dev and device_xname
 1.27 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.26 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.25 09-Dec-2007  jmcneill branches: 1.25.6; 1.25.10;
Merge jmcneill-pm branch.
 1.24 19-Oct-2007  ad branches: 1.24.4; 1.24.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.23 29-Apr-2007  msaitoh branches: 1.23.6; 1.23.8; 1.23.12;
fix typos
 1.22 04-Mar-2007  christos branches: 1.22.2; 1.22.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.21 16-Nov-2006  christos branches: 1.21.4; 1.21.6;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.18 24-Sep-2006  jmcneill Don't use // for comments.
 1.17 18-Sep-2006  reinoud Since SPDIF support fo the auixp driver is still half done disable it for
now since some chipset revisions will freak out on the aparent
half-initialisation. Even on my machine i can't seem to get the SPDIF led
to light up so something is wrong.

Also delay the setting of the DMA bits until after the codec detection but
before the enabling of interrupts. Note that the dma has to be explicitly
started when the device is opened.
 1.16 27-Aug-2006  christos branches: 1.16.2; 1.16.4;
Add missing initializers.
 1.15 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.14 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.13 14-May-2006  elad branches: 1.13.2; 1.13.4;
integrate kauth.
 1.12 11-Apr-2006  rpaulo Coverity ID 2311: in auixp_allocate_dma_chain() free dma variable if
we are unable to allocate hardware dma descriptors.
 1.11 24-Jan-2006  reinoud branches: 1.11.2; 1.11.4; 1.11.6; 1.11.8; 1.11.10;
Duh! If askes to halt the input dont halt the output instead. This also
fixes the timeout on draining when closing.
 1.10 11-Dec-2005  christos branches: 1.10.2;
merge ktrace-lwp.
 1.9 27-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static. Fix a memory leak uncovered by
doing so (auixp_freemem() was never called).
 1.8 15-Jun-2005  reinoud Cosmetic change giving better feedback on what's going on. It would allways
tell the hardware reset timed out when it didn't. Also cleaned up code
comments.
 1.7 12-Jun-2005  reinoud Implement auixp AC-link reset
 1.6 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.5 26-Jan-2005  fvdl branches: 1.5.4;
Don't print a message when there's no interrupt to be handled, since this
can happen when one is shared. Also, don't claim it in that case.

Make some printfs more consistent.
 1.4 13-Jan-2005  simonb branches: 1.4.2; 1.4.4; 1.4.6;
More KNF nits.
 1.3 12-Jan-2005  kent remove empty auixp_open() and auixp_close(). They are optional.

style fixes
* Don't associate a name with the types
* The function type must be declared on a line by itself
preceding the function.
* DO NOT initialize variables in the declarations.
* No parentheses are needed around the return value.
 1.2 12-Jan-2005  reinoud Update copyright messages
 1.1 12-Jan-2005  reinoud Initial commit of auixp(4) driver. It's a driver for the audio part of ATI
IXP-200 and family motherboard chips. Its functional for both recording and
playback.

Note that quadraphonic and Dolby 5.1 audio are not tested by me but ought
to work fine. I can set the number of channels etc. OK but i can't listen
to the result. Any feedback on this performance would be greatly
apreciated.
 1.4.6.1 12-Feb-2005  yamt sync with head.
 1.4.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.3 04-Feb-2005  skrll Sync with HEAD.
 1.4.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.4.4.1 13-Jan-2005  skrll file auixp.c was added on branch ktrace-lwp on 2005-01-17 19:31:23 +0000
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.5.4.1 28-Jan-2006  tron Pull up following revision(s) (requested by reinoud in ticket #1138):
sys/dev/pci/auixp.c: revision 1.11
Duh! If askes to halt the input dont halt the output instead. This also
fixes the timeout on draining when closing.
 1.9.2.7 24-Mar-2008  yamt sync with head.
 1.9.2.6 17-Mar-2008  yamt sync with head.
 1.9.2.5 21-Jan-2008  yamt sync with head
 1.9.2.4 27-Oct-2007  yamt sync with head.
 1.9.2.3 03-Sep-2007  yamt sync with head.
 1.9.2.2 30-Dec-2006  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 01-Feb-2006  yamt sync with head.
 1.11.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.11.8.1 19-Apr-2006  elad sync with head.
 1.11.6.3 03-Sep-2006  yamt sync with head.
 1.11.6.2 26-Jun-2006  yamt sync with head.
 1.11.6.1 24-May-2006  yamt sync with head.
 1.11.4.1 22-Apr-2006  simonb Sync with head.
 1.11.2.1 09-Sep-2006  rpaulo sync with head
 1.13.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.13.2.1 19-Jun-2006  chap Sync with head.
 1.16.4.2 10-Dec-2006  yamt sync with head.
 1.16.4.1 22-Oct-2006  yamt sync with head
 1.16.2.1 18-Nov-2006  ad Sync with head.
 1.21.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.21.4.2 07-May-2007  yamt sync with head.
 1.21.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.4.1 11-Jul-2007  mjf Sync with head.
 1.22.2.2 23-Oct-2007  ad Sync with head.
 1.22.2.1 27-May-2007  ad Sync with head.
 1.23.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.8.3 23-Mar-2008  matt sync with HEAD
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.23.6.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.23.6.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.23.6.2 04-Oct-2007  joerg Also deregister PNP handler at detach time.
 1.23.6.1 04-Oct-2007  joerg Add blindly codec power management support.
 1.24.6.1 11-Dec-2007  yamt sync with head.
 1.24.4.1 26-Dec-2007  ad Sync with head.
 1.25.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.25.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.6.1 24-Mar-2008  keiichi sync with head.
 1.28.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.16.3 13-Dec-2008  ad Fix locking for ac97.
 1.28.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.28.16.1 08-Dec-2008  ad Convert some more drivers.
 1.28.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.28.4.3 11-Mar-2010  yamt sync with head
 1.28.4.2 16-May-2009  yamt sync with head
 1.28.4.1 04-May-2009  yamt sync with head.
 1.33.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.12.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.34.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.34.10.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.34.10.2 30-Oct-2012  yamt sync with head
 1.34.10.1 17-Apr-2012  yamt sync with head
 1.37.2.1 18-Feb-2012  mrg merge to -current.
 1.38.6.3 03-Dec-2017  jdolecek update from HEAD
 1.38.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.39.2.1 18-May-2014  rmind sync with head
 1.41.2.2 28-Aug-2017  skrll Sync with HEAD
 1.41.2.1 09-Jul-2016  skrll Sync with HEAD
 1.43.10.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.43.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.43.10.1 10-Jun-2019  christos Sync with HEAD
 1.43.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.45.2.2 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.45.2.1 27-Apr-2019  isaki Adapt to audio2.
- Move auixp_formats' definition from header to source.
- Make compilable even with DEBUG_AUIXP.
 1.47.2.2 07-Jul-2020  martin Pull up following revision(s) (requested by isaki in ticket #983):

sys/dev/pci/auixp.c: revision 1.50

Fix an argument passes to auixp_intr().

This is rest of rev 1.39 (split device_t/softc) in 2012.
Problem reported and tested by Riccardo Mottola.
 1.47.2.1 21-Mar-2020  martin Pull up following revision(s) (requested by isaki in ticket #792):

sys/arch/amiga/dev/aucc.c: revision 1.48
sys/dev/pci/auixp.c: revision 1.49
sys/dev/pci/gcscaudio.c: revision 1.19
sys/dev/pci/auich.c: revision 1.159
sys/dev/sbus/dbri.c: revision 1.42
sys/dev/pci/auvia.c: revision 1.85
sys/dev/pci/auacer.c: revision 1.39

Drop 512 bytes limit on auvia_round_blocksize().

This fixes attach on 6 channels device.
PR kern/55017.

round_blocksize must return a multiple of the framesize.
aucc(4) supports 3 channels mode.

round_blocksize must return a multiple of the framesize
even if passed blocksize is greater than the upper limit.

round_blocksize must return a multiple of the framesize.

It's not divisible when blk=GCSCAUDI_PRD_SIZE_MAX and channels=4.
round_blocksize must return a multiple of the framesize
even if 6 channels mode.

I believe that keeping "good alignment" is just a wish, not constraint.
 1.48.2.1 29-Feb-2020  ad Sync with head.
 1.4 16-Oct-2019  maya Switch files copyright Reinoud Zandijk from BSD 4 clause to BSD 2 clause.

OK'd by reinoud in email (from 4 Feb 2019).
 1.3 11-Dec-2005  christos branches: 1.3.164;
merge ktrace-lwp.
 1.2 12-Jan-2005  reinoud branches: 1.2.4;
Update copyright messages
 1.1 12-Jan-2005  reinoud Initial commit of auixp(4) driver. It's a driver for the audio part of ATI
IXP-200 and family motherboard chips. Its functional for both recording and
playback.

Note that quadraphonic and Dolby 5.1 audio are not tested by me but ought
to work fine. I can set the number of channels etc. OK but i can't listen
to the result. Any feedback on this performance would be greatly
apreciated.
 1.2.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.2.4.1 12-Jan-2005  skrll file auixpreg.h was added on branch ktrace-lwp on 2005-01-17 19:31:23 +0000
 1.3.164.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11 20-Aug-2021  andvar fix various typos in comments and log messages.
 1.10 16-Oct-2019  maya Switch files copyright Reinoud Zandijk from BSD 4 clause to BSD 2 clause.

OK'd by reinoud in email (from 4 Feb 2019).
 1.9 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.8 27-Oct-2012  chs branches: 1.8.38; 1.8.42;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.7 23-Nov-2011  jmcneill branches: 1.7.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.6 09-Dec-2007  jmcneill branches: 1.6.26; 1.6.48; 1.6.50;
Merge jmcneill-pm branch.
 1.5 04-Mar-2007  christos branches: 1.5.14; 1.5.16; 1.5.24; 1.5.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 11-Dec-2005  christos branches: 1.4.26; 1.4.28;
merge ktrace-lwp.
 1.3 12-Jan-2005  kent branches: 1.3.4; 1.3.12;
remove empty auixp_open() and auixp_close(). They are optional.

style fixes
* Don't associate a name with the types
* The function type must be declared on a line by itself
preceding the function.
* DO NOT initialize variables in the declarations.
* No parentheses are needed around the return value.
 1.2 12-Jan-2005  reinoud Update copyright messages
 1.1 12-Jan-2005  reinoud Initial commit of auixp(4) driver. It's a driver for the audio part of ATI
IXP-200 and family motherboard chips. Its functional for both recording and
playback.

Note that quadraphonic and Dolby 5.1 audio are not tested by me but ought
to work fine. I can set the number of channels etc. OK but i can't listen
to the result. Any feedback on this performance would be greatly
apreciated.
 1.3.12.2 21-Jan-2008  yamt sync with head
 1.3.12.1 03-Sep-2007  yamt sync with head.
 1.3.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.3.4.1 12-Jan-2005  skrll file auixpvar.h was added on branch ktrace-lwp on 2005-01-17 19:31:23 +0000
 1.4.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.4.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.26.1 11-Dec-2007  yamt sync with head.
 1.5.24.1 26-Dec-2007  ad Sync with head.
 1.5.16.1 09-Jan-2008  matt sync with HEAD
 1.5.14.1 04-Oct-2007  joerg Add blindly codec power management support.
 1.6.50.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.6.48.2 30-Oct-2012  yamt sync with head
 1.6.48.1 17-Apr-2012  yamt sync with head
 1.6.26.1 08-Dec-2008  ad Convert some more drivers.
 1.7.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.42.3 05-May-2019  isaki Remove sc_encodings. (I forgot it)
 1.8.42.2 27-Apr-2019  isaki Adapt to audio2.
- Move auixp_formats' definition from header to source.
- Make compilable even with DEBUG_AUIXP.
 1.8.42.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.8.38.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.38.1 10-Jun-2019  christos Sync with HEAD
 1.60 25-Jan-2022  andvar fix various typos in comments.
 1.59 29-Feb-2020  isaki Remove rounding by 4 bytes on round_blocksize().
For drivers which supports only 16bit * 2channels sampling,
rounding by 4 bytes no longer meaningful.
 1.58 08-Jun-2019  isaki branches: 1.58.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.57 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.56 16-Mar-2019  isaki branches: 1.56.2;
Use C99 style struct initializer to audio_hw_if.
 1.55 01-Jun-2017  chs branches: 1.55.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.54 10-May-2017  msaitoh - Use pci_intr_establish_xname().
- Style change.
 1.53 07-Jul-2016  msaitoh branches: 1.53.8;
KNF. Remove extra spaces. No functional change.
 1.52 01-Aug-2014  joerg branches: 1.52.4;
Byte access is only used in the midi code.
 1.51 29-Mar-2014  christos branches: 1.51.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.50 17-Mar-2012  martin branches: 1.50.2; 1.50.4;
Split device_t
 1.49 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.48 24-Nov-2011  mrg branches: 1.48.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.47 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.46 24-Feb-2010  dyoung branches: 1.46.10; 1.46.12;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.45 08-Jan-2010  dyoung branches: 1.45.2;
Expand PMF_FN_* macros.
 1.44 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.43 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.42 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.41 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.40 03-Jul-2008  gson branches: 1.40.8; 1.40.10;
Revert the change of revision 1.37 - a driver must not blindly set the
mem/io enable bits of a PCI device as the BARs may not be correctly
configured. Fixes PR kern/38857.
 1.39 10-Apr-2008  cegger branches: 1.39.4; 1.39.6; 1.39.8;
use aprint_*_dev and device_xname
 1.38 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.37 27-Jan-2008  jmcneill branches: 1.37.2; 1.37.6;
Fixup PCI_COMMAND_STATUS_REG on attach.
 1.36 09-Dec-2007  jmcneill Merge jmcneill-pm branch.
 1.35 19-Oct-2007  ad branches: 1.35.2; 1.35.4; 1.35.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.34 16-Nov-2006  christos branches: 1.34.6; 1.34.8; 1.34.22; 1.34.24; 1.34.28;
__unused removal on arguments; approved by core.
 1.33 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.31 28-Aug-2006  christos branches: 1.31.2; 1.31.4;
add missing initializer
 1.30 08-Mar-2006  lukem Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.29 22-Feb-2006  garbled branches: 1.29.2; 1.29.4;
IBM makes a pcn card that shows up as:
Trident Microsystems 4DWAVE DX (ethernet network, revision 0x25)
Unfortunately, this is an autri sound card. Special case the match routines
for both drivers so if_pcn properly picks it up, and autri doesn't.
 1.28 24-Dec-2005  perry branches: 1.28.2; 1.28.4; 1.28.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.27 11-Dec-2005  christos merge ktrace-lwp.
 1.26 28-Jun-2005  thorpej branches: 1.26.2;
Use ANSI function decls and static.
 1.25 02-Feb-2005  gson Generate an interrupt only after processing all the samples in a block
rather than at the time of the last sample, to eliminate a click at the
end of each block when recording. Fixes kern/18066.
 1.24 15-Jan-2005  kent branches: 1.24.2; 1.24.4;
ansify and KNF
 1.23 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.22 09-Nov-2004  kent branches: 1.22.2;
remove mixer setting code in *_attach() because ac97_attach() does it.
 1.21 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.20 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.19 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.18 29-Oct-2003  mycroft branches: 1.18.2;
Bogus initializers suck.
 1.17 25-Oct-2003  christos Fix uninitialized variable warnings
 1.16 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.15 04-Apr-2003  perry branches: 1.15.2;
fix from OpenBSD, contributed by Gabriel Gonzalez in PR kern/20999
 1.14 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.13 31-Jan-2003  thorpej Use aprint_*().
 1.12 06-Jan-2003  wiz interrupt with two rs.
 1.11 07-Nov-2002  someya Fix recording problem on SiS7018.
 1.10 20-Oct-2002  someya Bit shifts for interrupt channel exceeded u_int32_t width.
 1.9 12-Oct-2002  someya add autri_flags_codec() from OpenBSD, reported by grendel@zeitbombe.org
 1.8 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.7 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 30-May-2002  someya Fix playback problem on SiS7018.
- mute the volume for interrupt channel
- add some improvements for device initialization

but recording does not work properly.

Reported and tested by Jan Wagner <waja@cyconet.org>. Thanks.
 1.4 05-Feb-2002  eeh branches: 1.4.8;
Fix a blatant inconsistency in PCI_PRODUCT handling.
 1.3 18-Nov-2001  augustss branches: 1.3.2; 1.3.4;
ANSIfy driver.
 1.2 18-Nov-2001  augustss Don't use a static variable in the power hook. It doesn't work with more
than one device.
 1.1 18-Nov-2001  someya add Trident 4DWAVE based (4DWAVE DX/NX,SiS 7018,ALi M5451) PCI audio driver
 1.3.4.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.4.1 18-Nov-2001  thorpej file autri.c was added on branch kqueue on 2002-01-10 19:56:26 +0000
 1.3.2.7 07-Jan-2003  thorpej Sync with HEAD.
 1.3.2.6 11-Nov-2002  nathanw Catch up to -current
 1.3.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.3.2.1 18-Nov-2001  nathanw file autri.c was added on branch nathanw_sa on 2002-01-08 00:30:58 +0000
 1.4.8.1 20-Jun-2002  gehenna catch up with -current.
 1.15.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.8 04-Feb-2005  skrll Sync with HEAD.
 1.15.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.15.2.6 14-Nov-2004  skrll Sync with HEAD.
 1.15.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.15.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.15.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.2.1 22-Sep-2004  jmc Pullup rev 1.20 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.22.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.22.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.24.4.1 12-Feb-2005  yamt sync with head.
 1.24.2.1 29-Apr-2005  kent sync with -current
 1.26.2.6 17-Mar-2008  yamt sync with head.
 1.26.2.5 04-Feb-2008  yamt sync with head.
 1.26.2.4 21-Jan-2008  yamt sync with head
 1.26.2.3 27-Oct-2007  yamt sync with head.
 1.26.2.2 30-Dec-2006  yamt sync with head.
 1.26.2.1 21-Jun-2006  yamt sync with head.
 1.28.6.1 22-Apr-2006  simonb Sync with head.
 1.28.4.1 09-Sep-2006  rpaulo sync with head
 1.28.2.1 01-Mar-2006  yamt sync with head.
 1.29.4.1 19-Apr-2006  elad sync with head.
 1.29.2.2 03-Sep-2006  yamt sync with head.
 1.29.2.1 13-Mar-2006  yamt sync with head.
 1.31.4.2 10-Dec-2006  yamt sync with head.
 1.31.4.1 22-Oct-2006  yamt sync with head
 1.31.2.1 18-Nov-2006  ad Sync with head.
 1.34.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.34.24.3 23-Mar-2008  matt sync with HEAD
 1.34.24.2 09-Jan-2008  matt sync with HEAD
 1.34.24.1 06-Nov-2007  matt sync with HEAD
 1.34.22.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.34.22.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.34.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.34.22.1 04-Oct-2007  joerg Convert autri(4) to PNP power handling.
 1.34.8.1 23-Oct-2007  ad Sync with head.
 1.34.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.35.6.1 11-Dec-2007  yamt sync with head.
 1.35.4.1 26-Dec-2007  ad Sync with head.
 1.35.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.37.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.37.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.37.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.37.2.1 24-Mar-2008  keiichi sync with head.
 1.39.8.1 03-Jul-2008  simonb Sync with head.
 1.39.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.39.4.3 11-Mar-2010  yamt sync with head
 1.39.4.2 16-May-2009  yamt sync with head
 1.39.4.1 04-May-2009  yamt sync with head.
 1.40.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.40.8.2 12-Dec-2008  ad Checkpoint work in progress.
 1.40.8.1 08-Dec-2008  ad Convert some more drivers.
 1.45.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.46.12.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.46.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.46.10.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.10.1 17-Apr-2012  yamt sync with head
 1.48.2.2 05-Apr-2012  mrg sync to latest -current.
 1.48.2.1 18-Feb-2012  mrg merge to -current.
 1.50.4.1 18-May-2014  rmind sync with head
 1.50.2.2 03-Dec-2017  jdolecek update from HEAD
 1.50.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.51.2.1 10-Aug-2014  tls Rebase.
 1.52.4.2 28-Aug-2017  skrll Sync with HEAD
 1.52.4.1 09-Jul-2016  skrll Sync with HEAD
 1.53.8.1 11-May-2017  pgoyette Sync with HEAD
 1.55.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.55.10.1 10-Jun-2019  christos Sync with HEAD
 1.56.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.56.2.3 27-Apr-2019  isaki More adapt to audio2.
- Shrink autri_formats[]. HW actually supports frequencies other
than 48kHz but they may include (ignorable) rounding error in
thier calculation. So accept only 48kHz. It's enough.
- Remove obsoleted and empty methods.
 1.56.2.2 27-Apr-2019  isaki Adapt to audio2.
Tested on sparc64 by macallan@. Thank you.
 1.56.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.58.4.1 29-Feb-2020  ad Sync with head.
 1.3 07-Nov-2002  someya Fix recording problem on SiS7018.
 1.2 30-May-2002  someya Fix playback problem on SiS7018.
- mute the volume for interrupt channel
- add some improvements for device initialization

but recording does not work properly.

Reported and tested by Jan Wagner <waja@cyconet.org>. Thanks.
 1.1 18-Nov-2001  someya branches: 1.1.2; 1.1.4; 1.1.12;
add Trident 4DWAVE based (4DWAVE DX/NX,SiS 7018,ALi M5451) PCI audio driver
 1.1.12.1 20-Jun-2002  gehenna catch up with -current.
 1.1.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 18-Nov-2001  thorpej file autrireg.h was added on branch kqueue on 2002-01-10 19:56:26 +0000
 1.1.2.4 11-Nov-2002  nathanw Catch up to -current
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 18-Nov-2001  nathanw file autrireg.h was added on branch nathanw_sa on 2002-01-08 00:30:59 +0000
 1.6 17-Mar-2012  martin Split device_t
 1.5 23-Nov-2011  jmcneill branches: 1.5.2;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.4 09-Dec-2007  jmcneill branches: 1.4.26; 1.4.48; 1.4.50;
Merge jmcneill-pm branch.
 1.3 04-Mar-2007  christos branches: 1.3.14; 1.3.16; 1.3.24; 1.3.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 18-Nov-2001  augustss branches: 1.2.2; 1.2.4; 1.2.36; 1.2.74; 1.2.76;
ANSIfy driver.
 1.1 18-Nov-2001  someya add Trident 4DWAVE based (4DWAVE DX/NX,SiS 7018,ALi M5451) PCI audio driver
 1.2.76.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.2.74.1 12-Mar-2007  rmind Sync with HEAD.
 1.2.36.2 21-Jan-2008  yamt sync with head
 1.2.36.1 03-Sep-2007  yamt sync with head.
 1.2.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.1 18-Nov-2001  thorpej file autrivar.h was added on branch kqueue on 2002-01-10 19:56:27 +0000
 1.2.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.2.2.1 18-Nov-2001  nathanw file autrivar.h was added on branch nathanw_sa on 2002-01-08 00:30:59 +0000
 1.3.26.1 11-Dec-2007  yamt sync with head.
 1.3.24.1 26-Dec-2007  ad Sync with head.
 1.3.16.1 09-Jan-2008  matt sync with HEAD
 1.3.14.1 04-Oct-2007  joerg Convert autri(4) to PNP power handling.
 1.4.50.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.4.48.1 17-Apr-2012  yamt sync with head
 1.4.26.1 08-Dec-2008  ad Convert some more drivers.
 1.5.2.1 05-Apr-2012  mrg sync to latest -current.
 1.87 06-Feb-2021  isaki Hold sc_intr_lock in open()/close().
vtbl->{lock,unlock} (in fact ac97_{lock,unlock}) don't seem to need
releasing an interrupt lock.
Confirmed on auich.
 1.86 19-Apr-2020  isaki branches: 1.86.2;
Fix round_blocksize not to return 0.
 1.85 28-Feb-2020  isaki branches: 1.85.4;
Drop 512 bytes limit on auvia_round_blocksize().
This fixes attach on 6 channels device.
PR kern/55017.
 1.84 08-Jun-2019  isaki branches: 1.84.2; 1.84.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.83 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.82 16-Mar-2019  isaki branches: 1.82.2;
Use C99 style struct initializer to audio_hw_if.
 1.81 16-Mar-2019  isaki Fix (probably) typo. SLINEAR_LE -> ULINEAR_LE.
 1.80 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.79 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.78 01-Jun-2017  chs branches: 1.78.8; 1.78.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.77 29-Mar-2014  christos branches: 1.77.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.76 16-Oct-2013  christos remove unused variables.
 1.75 24-Nov-2011  mrg branches: 1.75.8; 1.75.12;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.74 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.73 13-Nov-2010  uebayasi branches: 1.73.8; 1.73.10;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.72 24-Feb-2010  dyoung branches: 1.72.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.71 08-Jan-2010  dyoung branches: 1.71.2;
Expand PMF_FN_* macros.
 1.70 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.69 06-May-2009  cegger device_t/softc split
tested by jakllsch@
 1.68 05-May-2009  cegger struct cfdata * -> cfdata_t
 1.67 11-Oct-2008  dholland branches: 1.67.6; 1.67.8;
Print a message on two previously silent error paths in auvia_attach.
 1.66 01-Jul-2008  jmcneill branches: 1.66.2;
VT8233+ uses a different register base for capturing, tested by sborrill
 1.65 28-Apr-2008  martin branches: 1.65.2; 1.65.4;
Remove clause 3 and 4 from TNF licenses
 1.64 10-Apr-2008  cegger branches: 1.64.2; 1.64.4;
use aprint_*_dev and device_xname
 1.63 23-Feb-2008  dyoung Detach self and children. Use device_t and accessors. Use PMF_FN_*.
 1.62 14-Jan-2008  tsutsui branches: 1.62.2; 1.62.6;
Use htole32() to write parameters to DMA descriptors for big endian machines.
Tested on Pegasos by mrg@ on port-ofppc.
 1.61 09-Dec-2007  jmcneill branches: 1.61.2;
Merge jmcneill-pm branch.
 1.60 04-Mar-2007  christos branches: 1.60.14; 1.60.16; 1.60.22; 1.60.24; 1.60.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.59 21-Feb-2007  thorpej branches: 1.59.2;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.58 16-Nov-2006  christos branches: 1.58.2; 1.58.4; 1.58.6;
__unused removal on arguments; approved by core.
 1.57 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.56 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.55 28-Aug-2006  christos branches: 1.55.2; 1.55.4;
add missing initializer
 1.54 27-Jul-2006  kent add support for AC'97 S/PDIF
 1.53 28-Nov-2005  rpaulo branches: 1.53.4; 1.53.8;
PR 32178: Nicolas Joly: VT8233 AC'97 Audio revision 0x10 small display
fix. I just changed the comment a bit.
 1.52 28-Jun-2005  thorpej branches: 1.52.2; 1.52.8;
Use ANSI function decls and static.
 1.51 15-Jan-2005  kent ansify and KNF
 1.50 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.49 16-Nov-2004  xtraeme branches: 1.49.2;
Fix typo.
 1.48 13-Nov-2004  kent adopt auconv_set_converter()
 1.47 10-Nov-2004  kent remove unused variable
 1.46 10-Nov-2004  kent move IS_FIXED_RATE(), SUPPORTS_4CH(), and SUPPORTS_6CH to ac97var.h
 1.45 08-Nov-2004  kent print dmesg correctly for VT8237
 1.44 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.43 17-Oct-2004  kent add support for suspending/resuming.
patch provided by Rhialto in PR#26432
 1.42 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.41 09-Jul-2004  mycroft Clean up. Attempt to make these safer against stray interrupts.
 1.40 09-Jul-2004  mycroft There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.39 22-Apr-2004  itojun sprintf -> snprintf
 1.38 12-Apr-2004  jmmv Be consistent with other messages: output "VIA Technologies" instead of
only "VIA". Also add a missing "Audio" word to a message.
Closes PR kern/25152 by Nicolas Joly.
 1.37 31-Mar-2004  jmcneill Don't allow block sizes < 288 bytes on VT823x chips (patch from kent@).
Fixes kern/22788.
 1.36 25-Mar-2004  xtraeme branches: 1.36.2;
err fix previous (return -> break) in case statement.
 1.35 25-Mar-2004  xtraeme There are two revisions of the VT8235 audio chipset (0x50 and 0x60), so
print any of them as VT8235, approved by martin@.
 1.34 25-Mar-2004  martin Better identify some revisions of via 823* audio chips.
From PR kern/24906.
 1.33 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.32 14-Sep-2003  jmmv Enable auvia_reset_codec's code and wait until the card is available.
Fixes 'invalid codec' problems (at least with AD1980). Ok'ed by tsarna@.
 1.31 03-May-2003  wiz branches: 1.31.2;
DMA, not dma nor Dma.
 1.30 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.29 31-Jan-2003  thorpej Use aprint_*().
 1.28 04-Nov-2002  kent auvia_set_params:
For a fixed-rate codec, when AUMODE_RECORD and AUDIO_ENCODING_MULAW or
AUDIO_ENCODING_ALAW, use AUDIO_ENCODING_SLINEAR_LE/16bit for native encoding
instead of AUDIO_ENCODING_ULINEAR/8bit because aurateconv does not support
sampling rate conversion for 8 bit PCM.
This change fixes PR kern/18834.
 1.27 16-Oct-2002  kent Support for 4ch/6ch audio playback with VT8233/VT8235.
 1.26 08-Oct-2002  kent - Enable in-kernel sampling rate conversion for fixed-rate codec
- Remove VRA/VRM enabling in auvia_attach()
- Use ac97_codec_if::set_rate()
- Return no AUDIO_PROPS_MMAP for fixed-rate codec
- Remove unused variables in auvia_softc
 1.25 07-Oct-2002  kent Revive VIA8233_RP_DXS_[LR]VOL in auvia_trigger_*().
 1.24 06-Oct-2002  kent - auvia_trigger_output(): correct register;
AUVIA_RP_CONTROL -> AUVIA_RP_MODE
- auvia_trigger_output(), auvia_trigger_input(): Remove DXS_[LR]VOL setting.
- whitespace
 1.23 06-Oct-2002  kent Add some constant symbols for AC97 registers and values based on OpenBSD.
Rename some symbols to sync with OpenBSD:
AC97_REG_EXTENDED_ID
-> AC97_REG_EXT_AUDIO_ID
AC97_REG_EXTENDED_STATUS
-> AC97_REG_EXT_AUDIO_CTRL
AC97_CODEC_DOES_VRA/AC97_ENAB_VRA
-> AC97_EXT_AUDIO_VRA
AC97_CODEC_DOES_MICVRA/AC97_ENAB_MICVRA
-> AC97_EXT_AUDIO_VRM

ac97feature: "mic channel" -> "dedicated mic channel"
ac97_attach(): print extended capabilities; VRA, DRA, SPDIF, VRM, CDAC,
SDAC, LDAC.
 1.22 05-Oct-2002  kent Add support for VIA VT8233/VT8235. The patch was provided by Ola Eriksson
<ola at mreriksson dot net> in PR kern/18375. It is based on auvia of
OpenBSD.
 1.21 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.20 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.19 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.18 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.17 02-Apr-2002  fvdl Return 0 when no interrupt was handled.
 1.16 16-Mar-2002  jmcneill Backout addition of the VIA VT8233.
 1.15 16-Mar-2002  jmcneill Add support for the VT8233 AC'97.
 1.14 13-Nov-2001  lukem add RCSID
 1.13 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.12 04-Aug-2001  jdolecek branches: 1.12.2;
It seems the fixed rate versions are actually fixed at 48 kHz, not 44.1 kHz.
 1.11 19-Feb-2001  fvdl branches: 1.11.2; 1.11.4;
Switch line in mute off by default.
 1.10 05-Jan-2001  augustss Don't make local defines for stuff that's already in ac97reg.h.
 1.9 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.8 10-Dec-2000  jdolecek do not try to get/set sample rate on codecs which don't support variable
rate audio - always report/use fixed rate of 44100 for them, so that the
other audio code DTRT
 1.7 15-Nov-2000  jdolecek branches: 1.7.2;
if AC97_CODEC_DOES_VRA is not supported, only print warning than
hw Variable Rate Audio is not supported and continue attaching the driver.
This is I believe more correct than what was done in rev 1.5
 1.6 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.5 01-Sep-2000  jdolecek even through the integrated audio on my MSI 694D Pro
does not set AC97_CODEC_DOES_VRA in AC97_REG_EXT_AUDIO_ID request, it
works okay; only require the bit set for revision < 'H'
 1.4 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3 15-May-2000  thorpej branches: 1.3.4;
ac97.h -> ac97var.h
 1.2 08-Apr-2000  tsarna Fix auvia_free, clean up more on close, and be more careful in interrupt
handler.
 1.1 31-Mar-2000  tsarna Add auvia, a driver for the integrated AC'97 audio on the VIA VT82C686A
southbridge.

Tested on a ASUS K7M (w/ AD1881 codec). Please report any problems.
 1.3.4.2 01-Sep-2000  jdolecek pullup rev. 1.5 (approved by thorpej):
rev. H apparently doesn't set AC97_CODEC_DOES_VRA bit but works ok with
this driver, so only require the bit set for revisions < H
 1.3.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.7.2.6 12-Mar-2001  bouyer Sync with HEAD.
 1.7.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.4 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.7.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.7.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 15-Nov-2000  bouyer file auvia.c was added on branch thorpej_scsipi on 2000-11-20 11:42:14 +0000
 1.11.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.11.2.7 11-Nov-2002  nathanw Catch up to -current
 1.11.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.11.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.11.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.11.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.11.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.12.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.31.2.11 11-Dec-2005  christos Sync with head.
 1.31.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.31.2.9 17-Jan-2005  skrll Sync with HEAD.
 1.31.2.8 29-Nov-2004  skrll Sync with HEAD.
 1.31.2.7 14-Nov-2004  skrll Sync with HEAD.
 1.31.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.31.2.5 19-Oct-2004  skrll Sync with HEAD
 1.31.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.31.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.31.2.1 03-Aug-2004  skrll Sync with HEAD
 1.36.2.2 22-Sep-2004  jmc branches: 1.36.2.2.2;
Pullup rev 1.42 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.36.2.1 01-Apr-2004  jmc Pullup rev 1.37 (requested by jmcneill in ticket #36)

Don't allow block sizes < 288 bytes on VT823x chips. PR#22788
 1.36.2.2.2.1 30-Jan-2005  he Pull up revision 1.43 (requested by kent in ticket #949):
Add support for suspending/resuming. Fixes PR#26432.
 1.49.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.49.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.52.8.1 29-Nov-2005  yamt sync with head.
 1.52.2.6 27-Feb-2008  yamt sync with head.
 1.52.2.5 21-Jan-2008  yamt sync with head
 1.52.2.4 03-Sep-2007  yamt sync with head.
 1.52.2.3 26-Feb-2007  yamt sync with head.
 1.52.2.2 30-Dec-2006  yamt sync with head.
 1.52.2.1 21-Jun-2006  yamt sync with head.
 1.53.8.2 03-Sep-2006  yamt sync with head.
 1.53.8.1 11-Aug-2006  yamt sync with head
 1.53.4.1 09-Sep-2006  rpaulo sync with head
 1.55.4.2 10-Dec-2006  yamt sync with head.
 1.55.4.1 22-Oct-2006  yamt sync with head
 1.55.2.1 18-Nov-2006  ad Sync with head.
 1.58.6.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.58.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.58.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.58.2.1 06-Jul-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1161):
sys/dev/pci/auvia.c: revision 1.66
VT8233+ uses a different register base for capturing, tested by sborrill
 1.59.2.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.60.26.1 11-Dec-2007  yamt sync with head.
 1.60.24.1 26-Dec-2007  ad Sync with head.
 1.60.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.60.16.2 23-Mar-2008  matt sync with HEAD
 1.60.16.1 09-Jan-2008  matt sync with HEAD
 1.60.14.3 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.60.14.2 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.60.14.1 04-Oct-2007  joerg Convert auvia(4) to PNP power management.
 1.61.2.1 19-Jan-2008  bouyer Sync with HEAD
 1.62.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.62.6.3 02-Jul-2008  mjf Sync with HEAD.
 1.62.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.62.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.62.2.1 24-Mar-2008  keiichi sync with head.
 1.64.4.4 11-Mar-2010  yamt sync with head
 1.64.4.3 16-May-2009  yamt sync with head
 1.64.4.2 04-May-2009  yamt sync with head.
 1.64.4.1 16-May-2008  yamt sync with head.
 1.64.2.1 18-May-2008  yamt sync with head.
 1.65.4.1 03-Jul-2008  simonb Sync with head.
 1.65.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.66.2.1 19-Oct-2008  haad Sync with HEAD.
 1.67.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.67.6.3 13-Dec-2008  ad Fix locking for ac97.
 1.67.6.2 11-Dec-2008  ad Checkpoint work in progress.
 1.67.6.1 08-Dec-2008  ad Convert some more drivers.
 1.71.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.72.2.1 05-Mar-2011  rmind sync with head
 1.73.10.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.73.10.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.73.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.73.8.1 17-Apr-2012  yamt sync with head
 1.75.12.1 18-May-2014  rmind sync with head
 1.75.8.2 03-Dec-2017  jdolecek update from HEAD
 1.75.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.77.6.1 28-Aug-2017  skrll Sync with HEAD
 1.78.10.3 21-Apr-2020  martin Sync with HEAD
 1.78.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.78.10.1 10-Jun-2019  christos Sync with HEAD
 1.78.8.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.78.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.82.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.82.2.3 03-May-2019  isaki Remove unnecessary header file.
 1.82.2.2 27-Apr-2019  isaki Adapt to audio2.
- auvia_set_params_sub is also renamed because caller auvia_set_params
is renamed to auvia_set_format.
 1.82.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.84.4.1 29-Feb-2020  ad Sync with head.
 1.84.2.1 21-Mar-2020  martin Pull up following revision(s) (requested by isaki in ticket #792):

sys/arch/amiga/dev/aucc.c: revision 1.48
sys/dev/pci/auixp.c: revision 1.49
sys/dev/pci/gcscaudio.c: revision 1.19
sys/dev/pci/auich.c: revision 1.159
sys/dev/sbus/dbri.c: revision 1.42
sys/dev/pci/auvia.c: revision 1.85
sys/dev/pci/auacer.c: revision 1.39

Drop 512 bytes limit on auvia_round_blocksize().

This fixes attach on 6 channels device.
PR kern/55017.

round_blocksize must return a multiple of the framesize.
aucc(4) supports 3 channels mode.

round_blocksize must return a multiple of the framesize
even if passed blocksize is greater than the upper limit.

round_blocksize must return a multiple of the framesize.

It's not divisible when blk=GCSCAUDI_PRD_SIZE_MAX and channels=4.
round_blocksize must return a multiple of the framesize
even if 6 channels mode.

I believe that keeping "good alignment" is just a wish, not constraint.
 1.85.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.86.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.17 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.16 23-Nov-2011  jmcneill branches: 1.16.50; 1.16.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.15 06-May-2009  cegger branches: 1.15.12; 1.15.14;
device_t/softc split
tested by jakllsch@
 1.14 28-Apr-2008  martin branches: 1.14.12; 1.14.14;
Remove clause 3 and 4 from TNF licenses
 1.13 23-Feb-2008  dyoung branches: 1.13.2; 1.13.4;
Detach self and children. Use device_t and accessors. Use PMF_FN_*.
 1.12 09-Dec-2007  jmcneill branches: 1.12.6; 1.12.10;
Merge jmcneill-pm branch.
 1.11 21-Feb-2007  thorpej branches: 1.11.2; 1.11.16; 1.11.18; 1.11.26; 1.11.28;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.10 27-Jul-2006  kent branches: 1.10.10;
add support for AC'97 S/PDIF
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.8;
merge ktrace-lwp.
 1.8 13-Nov-2004  kent branches: 1.8.12;
adopt auconv_set_converter()
 1.7 10-Nov-2004  kent move IS_FIXED_RATE(), SUPPORTS_4CH(), and SUPPORTS_6CH to ac97var.h
 1.6 17-Oct-2004  kent add support for suspending/resuming.
patch provided by Rhialto in PR#26432
 1.5 16-Oct-2002  kent branches: 1.5.6; 1.5.10;
Support for 4ch/6ch audio playback with VT8233/VT8235.
 1.4 08-Oct-2002  kent - Enable in-kernel sampling rate conversion for fixed-rate codec
- Remove VRA/VRM enabling in auvia_attach()
- Use ac97_codec_if::set_rate()
- Return no AUDIO_PROPS_MMAP for fixed-rate codec
- Remove unused variables in auvia_softc
 1.3 05-Oct-2002  kent Add support for VIA VT8233/VT8235. The patch was provided by Ola Eriksson
<ola at mreriksson dot net> in PR kern/18375. It is based on auvia of
OpenBSD.
 1.2 10-Dec-2000  jdolecek branches: 1.2.2;
do not try to get/set sample rate on codecs which don't support variable
rate audio - always report/use fixed rate of 44100 for them, so that the
other audio code DTRT
 1.1 31-Mar-2000  tsarna branches: 1.1.6;
Add auvia, a driver for the integrated AC'97 audio on the VIA VT82C686A
southbridge.

Tested on a ASUS K7M (w/ AD1881 codec). Please report any problems.
 1.1.6.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 31-Mar-2000  bouyer file auviavar.h was added on branch thorpej_scsipi on 2000-11-20 11:42:14 +0000
 1.2.2.1 18-Oct-2002  nathanw Catch up to -current.
 1.5.10.1 30-Jan-2005  he Pull up revision 1.6 (requested by kent in ticket #949):
Add support for suspending/resuming. Fixes PR#26432.
 1.5.6.3 29-Nov-2004  skrll Sync with HEAD.
 1.5.6.2 14-Nov-2004  skrll Sync with HEAD.
 1.5.6.1 19-Oct-2004  skrll Sync with HEAD
 1.8.12.4 27-Feb-2008  yamt sync with head.
 1.8.12.3 21-Jan-2008  yamt sync with head
 1.8.12.2 26-Feb-2007  yamt sync with head.
 1.8.12.1 30-Dec-2006  yamt sync with head.
 1.9.8.1 11-Aug-2006  yamt sync with head
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.11.28.1 11-Dec-2007  yamt sync with head.
 1.11.26.1 26-Dec-2007  ad Sync with head.
 1.11.18.2 23-Mar-2008  matt sync with HEAD
 1.11.18.1 09-Jan-2008  matt sync with HEAD
 1.11.16.1 04-Oct-2007  joerg Convert auvia(4) to PNP power management.
 1.11.2.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.12.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.6.1 24-Mar-2008  keiichi sync with head.
 1.13.4.2 16-May-2009  yamt sync with head
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.12.2 11-Dec-2008  ad Checkpoint work in progress.
 1.14.12.1 08-Dec-2008  ad Convert some more drivers.
 1.15.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.15.12.1 17-Apr-2012  yamt sync with head
 1.16.54.1 27-Apr-2019  isaki Adapt to audio2.
- auvia_set_params_sub is also renamed because caller auvia_set_params
is renamed to auvia_set_format.
 1.16.50.1 10-Jun-2019  christos Sync with HEAD
 1.89 09-Feb-2020  jmcneill Retire azalia(4).
 1.88 08-Jun-2019  isaki branches: 1.88.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.87 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.86 16-Mar-2019  isaki branches: 1.86.2;
Use C99 style struct initializer to audio_hw_if.
 1.85 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.84 01-Jun-2017  chs branches: 1.84.8; 1.84.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.83 09-Nov-2014  nonaka branches: 1.83.2;
Wait for the RIRB DMA engine to come ready. Needed on the audio device
integrated in the Vortex86EX SoC. From OpenBSD.
 1.82 21-Sep-2014  christos Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.81 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.80 20-Oct-2013  christos move debugging code inside ifdef debug
 1.79 24-Nov-2011  mrg branches: 1.79.8; 1.79.12;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.78 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.77 29-Aug-2011  jmcneill branches: 1.77.2; 1.77.4;
have pci register itself as a module, and make PCI driver modules depend on it
 1.76 28-Aug-2011  jmcneill set default WARNS for modules to 3 -- the only one that needs < 3 now is pf
 1.75 25-May-2010  pgoyette Revert earlier changes to callers of pci_find{vendor,product} since
the original routine entrypoint name has been restored.

Requested by dyoung@ and mrg@
 1.74 24-May-2010  pgoyette Update all callers of the pci_find{vendor,product} routines to now call
these routines through their global pointers.
 1.73 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.72 20-Jan-2010  tonnerre branches: 1.72.2;
Signedness bug/crash in azalia and hdaudio. Fixes PR 42604.
By Pierre Pronchery.
 1.71 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.70 12-Nov-2009  dyoung Remove superfluous activation hook.
 1.69 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.68 02-Apr-2009  dyoung Cosmetic changes, only, to clarify and to save a couple of lines: return
a constant, 0, instead of returning ret when it is always 0. Wait to
initialize ret until we really need to.
 1.67 25-Feb-2009  jmcneill PR# port-i386/40143: Viewing an mpeg transport stream with mplayer causes crash

Not directly related to the PR but this bug was discovered while testing.

In azalia_stream_halt, invalidate the intr ptr to prevent a race condition
where azalia_stream_intr can jump off into lala land during stream shutdown.
 1.66 17-Dec-2008  cegger branches: 1.66.2;
make this build with AZALIA_DEBUG
 1.65 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.64 26-Jun-2008  kent branches: 1.64.4; 1.64.6; 1.64.8;
* azalia_rirb_intr()
fix a problem that normal responses are skipped unintentionally.

* azalia_stream_start()
access HDA_INTCTL with AZ_READ_4()/AZ_WRITE_4().
access HDA_SD_CTL with STR_READ_1()/AZ_WRITE_1().

* azalia_modcmd()
enclose config_cfdata_attach() with splaudio().
 1.63 08-Jun-2008  cegger branches: 1.63.2;
make this build with AZALIA_DEBUG
get rid of XNAME macro
 1.62 07-Jun-2008  freza Split device_t/softc. Remove unused macros.
 1.61 02-Jun-2008  jmcneill Backout previous; causes a panic on attach/detach/reattach for some
unknown reason.
 1.60 02-Jun-2008  jmcneill Halt streams before deleting them on detach.
 1.59 02-Jun-2008  jmcneill Fix MODULE_CMD_FINI case, azalia can be unloaded now.
 1.58 02-Jun-2008  jmcneill Allow azalia to be built as a module.
 1.57 13-May-2008  mjf Do not dereference this->intr if it's NULL.
 1.56 10-May-2008  jmcneill Cleanup aprint messages, remove unnecessary usage of aprint_error.
 1.55 28-Apr-2008  martin branches: 1.55.2;
Remove clause 3 and 4 from TNF licenses
 1.54 10-Apr-2008  cegger branches: 1.54.2; 1.54.4;
use aprint_*_dev and device_xname
 1.53 23-Feb-2008  dyoung Add a method to detach children. Use device_t and accessors. Use
PMF_FN_*.
 1.52 09-Dec-2007  jmcneill branches: 1.52.6; 1.52.10;
Merge jmcneill-pm branch.
 1.51 14-Aug-2007  kent branches: 1.51.2; 1.51.10; 1.51.12;
support for playback-only devices such as Radeon HD 2x00
 1.50 13-May-2007  kent branches: 1.50.2; 1.50.6;
Add PCI_SUBCLASS_MULTIMEDIA_HDAUDIO to pcireg.h
and azalia(4) uses it
 1.49 08-May-2007  kent * azalia_code_connect_stream()
set stream#0 for unused converters in a group

PR#35658 by kikuma norimitsu
 1.48 08-May-2007  kent Some codecs need explicit initialization even for uni-directional pins.

Pointed out by Deanna Phillips
 1.47 11-Mar-2007  kent branches: 1.47.2;
don't start dmesg lines with \t to do grep easily
 1.46 10-Mar-2007  kent branches: 1.46.2;
add diagnostic code in azalia_codec_construct_format()
 1.45 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.44 21-Feb-2007  thorpej branches: 1.44.2;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.43 05-Feb-2007  kent branches: 1.43.2;
If both of AZALIA_DEBUG and AZALIA_DEBUG_DOT are defined,
a DOT file for Graphviz representing the widget structure
is printed.
 1.42 16-Nov-2006  christos branches: 1.42.2; 1.42.4;
__unused removal on arguments; approved by core.
 1.41 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.40 24-Sep-2006  jmcneill Don't use // for comments.
 1.39 28-Aug-2006  christos branches: 1.39.2; 1.39.4;
add missing initializer.
 1.38 21-Jul-2006  kent * azalia_init_corb()
No need to confirm CORBRPRST is set even with ICH6/ICH7
 1.37 13-Jul-2006  kent For MCP55, don't check CORBRPRST flag

a part of PR#33741
 1.36 27-Jun-2006  kent * azalia_pci_attach()
print the vendor name of the device
* azalia_pci_detach()
add some debug messages
* azalia_codec_delete()
fix a possible NULL dereference
 1.35 25-Jun-2006  kent * disconnect a stream and audio converters on a halt of the stream
* enable S/PDIF for a digital audio converter when connecting
a stream
* rename "inputs.usingdac" to "playback.mode", and
"record.usingadc" to "record.mode"
* add S/PDIF output configuration to ALC882
 1.34 25-Jun-2006  kent ALC260 & Fujitsu LOOX:
mute the internal speaker when the headphone is inserted, and
unmute the internal speaker when the headphone is pulled out.
 1.33 25-Jun-2006  kent printf() -> DPRINTF(())
 1.32 25-Jun-2006  kent avoid infinite recursive call of azalia_rirb_kick_unsol_events()
 1.31 25-Jun-2006  kent handle unsolicited responses.
A codec can receive unsolicited responses by codec_t::unsol_event()
 1.30 24-Jun-2006  kent If the encoding of an audio converter is 0, refers
the audio function node. CMI9880 0.2 has such ADCs.

PR#33787
 1.29 16-Jun-2006  kent check return values of azalia_init_corb() and azalia_init_rirb()

a part of PR#33741
 1.28 15-Jun-2006  kent support for a converter group of which members have
non-identical bits_rates.
 1.27 13-Jun-2006  kent branches: 1.27.2;
- always prints the codec index in dmesg
- add missing \n
 1.26 11-Jun-2006  kent fix audio_format allocation for recording
 1.25 11-Jun-2006  kent support for multi-channel (>=3) recording with ALC880, ALC882, or STAC9221
 1.24 11-Jun-2006  kent If the codec supports for modem, print that we support for no modem
explicitly.
 1.23 09-Jun-2006  kent - print audio format only when the format is changed
- print the name of STAC9220 codec
 1.22 09-Jun-2006  kent shorten audio format message
 1.21 07-Jun-2006  kent * move mixer functions from azalia.c to azalia_codec.c, and
rename them like azalia_mixer_foo() to generic_mixer_foo()

* enable codec-specific code to hook any mixer operations such
as creating mixer items, or special handling for a specific
item.

* provide a custom mixer table specific to ALC260
* provide a custom mixer table specific to Fujitsu LOOX
 1.20 07-May-2006  kent branches: 1.20.2;
Don't assume the device always has PCI_MAPREG_MEM_TYPE_64BIT.
This change might help nForce 410/430 support.
 1.19 16-Jan-2006  kent branches: 1.19.2; 1.19.4; 1.19.6; 1.19.8; 1.19.10;
Don't crash when a connection list has invalid NIDs.

PR#32485 by Samuel Tran
 1.18 08-Jan-2006  kent add some trace messages in azalia_mixer_init().
 1.17 03-Jan-2006  kent - make this compile with AZALIA_DEBUG
Thanks to Tomokatsu HAYAKAWA.
- introduce WIDGET_CHANNELS macro
 1.16 11-Dec-2005  christos branches: 1.16.2;
merge ktrace-lwp.
 1.15 29-Sep-2005  kent branches: 1.15.6;
* shorten *_init_dacgroup() functions
* add a hook point for widget initialization and implement for ALC882
 1.14 28-Sep-2005  kent add codec-specific code for ALC260, ALC880, ALC882,
and STAC9221 to detect DAC/ADC cominations.
 1.13 28-Sep-2005  kent split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.12 26-Sep-2005  kent * azalia_attach_intr()
ignore errors of codec initializations if at least one
codec is initialized successfully

* azalia_alloc_dmamem()
fail if the HDA controller does not support 64 bit addressing
and buf_dmamap_* allocate a 64 bit address.

Pointed out by Brett Lymn
 1.11 02-Aug-2005  kent * azalia_mixer_init()
set AUDIO_MAX_GAIN/2 to all of volume items.
 1.10 02-Aug-2005  kent - handle widgets without `format override' or `amp param override'
- support for volume knob
 1.9 31-Jul-2005  kent - make sure the power state of a node is D0
- ignore unsoliticited responses
 1.8 29-Jul-2005  kent make this compile with AZALIA_DEBUG.
thanks to cube@
 1.7 25-Jun-2005  kent branches: 1.7.2; 1.7.4;
- free all of allocated resources when an error occurs
- code cleanup
 1.6 21-Jun-2005  kent support for recording
 1.5 20-Jun-2005  kent - print the controller name if possible
- make the max values of mixers AUDIO_MAX_GAIN
- reset the stream in trigger_output()
 1.4 19-Jun-2005  kent - add capabilities to specify a DAC group or an ADC.
- support for 4,6,8 channels playback
 1.3 19-Jun-2005  kent - add support for headphone-boost mixer controls
- fix a bug of creation of output mute
- unmute all controls by azalia_set_mixer()
- if a bidirectional pin is green, orange, gray, or black, set
it as "output" direction by default.
 1.2 19-Jun-2005  kent partial support for mixer.
Still we have no ways to specify DACs or ADCs.
 1.1 18-Jun-2005  kent A driver for High Definition Audio.

The driver is highly experimental at this moment:
- limited support for playback
- no support for mixer controls
- no support for recording
 1.7.4.6 27-Feb-2008  yamt sync with head.
 1.7.4.5 21-Jan-2008  yamt sync with head
 1.7.4.4 03-Sep-2007  yamt sync with head.
 1.7.4.3 26-Feb-2007  yamt sync with head.
 1.7.4.2 30-Dec-2006  yamt sync with head.
 1.7.4.1 21-Jun-2006  yamt sync with head.
 1.7.2.39 27-May-2007  bouyer Pull up following revision(s) (requested by kent in ticket #1780):
sys/dev/pci/azalia_codec.c: revisions 1.25, 1.28, 1.30 - 1.42
sys/dev/pci/azalia.c: revisions 1.43, 1.46 - 1.49
sys/dev/pci/azalia.h: revisions 1.15 - 1.16
Bug fixes, and add support for some more codecs.
PR#34880, PR#35658, PR#36302
 1.7.2.38 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.38
* azalia_init_corb()
No need to confirm CORBRPRST is set even with ICH6/ICH7
 1.7.2.37 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.37
For MCP55, don't check CORBRPRST flag
a part of PR#33741
 1.7.2.36 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.36
* azalia_pci_attach()
print the vendor name of the device
* azalia_pci_detach()
add some debug messages
* azalia_codec_delete()
fix a possible NULL dereference
 1.7.2.35 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.20
sys/dev/pci/azalia.h: revision 1.13
sys/dev/pci/azalia.c: revision 1.35
* disconnect a stream and audio converters on a halt of the stream
* enable S/PDIF for a digital audio converter when connecting
a stream
* rename "inputs.usingdac" to "playback.mode", and
"record.usingadc" to "record.mode"
* add S/PDIF output configuration to ALC882
 1.7.2.34 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.12
sys/dev/pci/azalia_codec.c: revision 1.19
sys/dev/pci/azalia.c: revision 1.34
ALC260 & Fujitsu LOOX:
mute the internal speaker when the headphone is inserted, and
unmute the internal speaker when the headphone is pulled out.
 1.7.2.33 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.33
printf() -> DPRINTF(())
 1.7.2.32 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.32
avoid infinite recursive call of azalia_rirb_kick_unsol_events()
 1.7.2.31 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.11
sys/dev/pci/azalia.c: revision 1.31
handle unsolicited responses.
A codec can receive unsolicited responses by codec_t::unsol_event()
 1.7.2.30 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.30
If the encoding of an audio converter is 0, refers
the audio function node. CMI9880 0.2 has such ADCs.
PR#33787
 1.7.2.29 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.29
check return values of azalia_init_corb() and azalia_init_rirb()
a part of PR#33741
 1.7.2.28 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.28
support for a converter group of which members have
non-identical bits_rates.
 1.7.2.27 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.27
- always prints the codec index in dmesg
- add missing n
 1.7.2.26 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.26
fix audio_format allocation for recording
 1.7.2.25 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.25
sys/dev/pci/azalia.h: revision 1.9
sys/dev/pci/azalia_codec.c: revision 1.12
support for multi-channel (>=3) recording with ALC880, ALC882, or STAC9221
 1.7.2.24 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.24
If the codec supports for modem, print that we support for no modem
explicitly.
 1.7.2.23 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.23
sys/dev/pci/azalia.h: revision 1.8
sys/dev/pci/azalia_codec.c: revision 1.10
- print audio format only when the format is changed
- print the name of STAC9220 codec
 1.7.2.22 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.22
shorten audio format message
 1.7.2.21 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.7
sys/dev/pci/azalia_codec.c: revision 1.9
sys/dev/pci/azalia.c: revision 1.21
* move mixer functions from azalia.c to azalia_codec.c, and
rename them like azalia_mixer_foo() to generic_mixer_foo()
* enable codec-specific code to hook any mixer operations such
as creating mixer items, or special handling for a specific
item.
* provide a custom mixer table specific to ALC260
* provide a custom mixer table specific to Fujitsu LOOX
 1.7.2.20 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.20
Don't assume the device always has PCI_MAPREG_MEM_TYPE_64BIT.
This change might help nForce 410/430 support.
 1.7.2.19 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia.h: revision 1.6
sys/dev/pci/azalia.c: revision 1.19
Don't crash when a connection list has invalid NIDs.
PR#32485 by Samuel Tran
 1.7.2.18 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia.c: revision 1.18
add some trace messages in azalia_mixer_init().
 1.7.2.17 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia.h: revision 1.5
sys/dev/pci/azalia.c: revision 1.17
- make this compile with AZALIA_DEBUG
Thanks to Tomokatsu HAYAKAWA.
- introduce WIDGET_CHANNELS macro
 1.7.2.16 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.3
sys/dev/pci/azalia_codec.c: revision 1.3
sys/dev/pci/azalia.c: revision 1.15
* shorten *_init_dacgroup() functions
* add a hook point for widget initialization and implement for ALC882
 1.7.2.15 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.2
sys/dev/pci/azalia_codec.c: revision 1.2
sys/dev/pci/azalia.c: revision 1.14
add codec-specific code for ALC260, ALC880, ALC882,
and STAC9221 to detect DAC/ADC cominations.
 1.7.2.14 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.1
sys/dev/pci/azalia_codec.c: revision 1.1
sys/dev/pci/azalia.c: revision 1.13
sys/dev/pci/files.pci: revision 1.239
split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.7.2.13 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.c: revision 1.12
* azalia_attach_intr()
ignore errors of codec initializations if at least one
codec is initialized successfully
* azalia_alloc_dmamem()
fail if the HDA controller does not support 64 bit addressing
and buf_dmamap_* allocate a 64 bit address.
Pointed out by Brett Lymn
 1.7.2.12 14-Aug-2005  riz branches: 1.7.2.12.2;
Pull up revision 1.11 (requested by kent in ticket #647):
* azalia_mixer_init()
set AUDIO_MAX_GAIN/2 to all of volume items.
 1.7.2.11 14-Aug-2005  riz Pull up revision 1.10 (requested by kent in ticket #647):
- handle widgets without `format override' or `amp param override'
- support for volume knob
 1.7.2.10 14-Aug-2005  riz Pull up revision 1.9 (requested by kent in ticket #647):
- make sure the power state of a node is D0
- ignore unsoliticited responses
 1.7.2.9 14-Aug-2005  riz Pull up revision 1.8 (requested by kent in ticket #647):
make this compile with AZALIA_DEBUG.
thanks to cube@
 1.7.2.8 02-Jul-2005  tron Pull up revision 1.7 (requested by kent in ticket #494):
- free all of allocated resources when an error occurs
- code cleanup
 1.7.2.7 02-Jul-2005  tron Pull up revision 1.6 (requested by kent in ticket #494):
support for recording
 1.7.2.6 02-Jul-2005  tron Pull up revision 1.5 (requested by kent in ticket #494):
- print the controller name if possible
- make the max values of mixers AUDIO_MAX_GAIN
- reset the stream in trigger_output()
 1.7.2.5 02-Jul-2005  tron Pull up revision 1.4 (requested by kent in ticket #494):
- add capabilities to specify a DAC group or an ADC.
- support for 4,6,8 channels playback
 1.7.2.4 02-Jul-2005  tron Pull up revision 1.3 (requested by kent in ticket #494):
- add support for headphone-boost mixer controls
- fix a bug of creation of output mute
- unmute all controls by azalia_set_mixer()
- if a bidirectional pin is green, orange, gray, or black, set
it as "output" direction by default.
 1.7.2.3 02-Jul-2005  tron Pull up revision 1.2 (requested by kent in ticket #494):
partial support for mixer.
Still we have no ways to specify DACs or ADCs.
 1.7.2.2 02-Jul-2005  tron Pull up revision 1.1 (requested by kent in ticket #494):
An audio driver for High Definition Audio.
The driver is highly experimental at this moment:
- limieted support for playback
- support for no mixer controls
- support for no recording
 1.7.2.1 25-Jun-2005  tron file azalia.c was added on branch netbsd-3 on 2005-07-02 16:39:31 +0000
 1.7.2.12.2.1 02-Feb-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia.c: revision 1.19 via patch
Don't crash when a connection list has invalid NIDs.
PR#32485 by Samuel Tran
 1.15.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.6.1 29-Sep-2005  skrll file azalia.c was added on branch ktrace-lwp on 2005-11-10 14:06:00 +0000
 1.16.2.2 01-Feb-2006  yamt sync with head.
 1.16.2.1 15-Jan-2006  yamt sync with head.
 1.19.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.19.8.1 11-May-2006  elad sync with head
 1.19.6.4 03-Sep-2006  yamt sync with head.
 1.19.6.3 11-Aug-2006  yamt sync with head
 1.19.6.2 26-Jun-2006  yamt sync with head.
 1.19.6.1 24-May-2006  yamt sync with head.
 1.19.4.2 07-Jun-2006  kardel Sync with head.
 1.19.4.1 01-Jun-2006  kardel Sync with head.
 1.19.2.1 09-Sep-2006  rpaulo sync with head
 1.20.2.1 19-Jun-2006  chap Sync with head.
 1.27.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.39.4.2 10-Dec-2006  yamt sync with head.
 1.39.4.1 22-Oct-2006  yamt sync with head
 1.39.2.2 09-Feb-2007  ad Sync with HEAD.
 1.39.2.1 18-Nov-2006  ad Sync with head.
 1.42.4.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.42.2.2 21-Jan-2010  snj Apply patch (requested by tonnerre in ticket #1375):
Signedness bug/crash in azalia. Fixes PR 42604.
 1.42.2.1 20-May-2007  jdc branches: 1.42.2.1.4;
Pull up revisions 1.43, 1.46-1.49 (requested by kent in ticket #649).

If both of AZALIA_DEBUG and AZALIA_DEBUG_DOT are defined,
a DOT file for Graphviz representing the widget structure
is printed.

add diagnostic code in azalia_codec_construct_format()

don't start dmesg lines with \t to do grep easily

Some codecs need explicit initialization even for uni-directional pins.

Pointed out by Deanna Phillips

* azalia_code_connect_stream()
set stream#0 for unused converters in a group

PR#35658 by kikuma norimitsu
 1.42.2.1.4.1 21-Jan-2010  snj Apply patch (requested by tonnerre in ticket #1375):
Signedness bug/crash in azalia. Fixes PR 42604.
 1.43.2.3 17-May-2007  yamt sync with head.
 1.43.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.43.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.44.2.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.46.2.3 20-Aug-2007  ad Sync with HEAD.
 1.46.2.2 27-May-2007  ad Sync with head.
 1.46.2.1 13-Mar-2007  ad Sync with head.
 1.47.2.1 11-Jul-2007  mjf Sync with head.
 1.50.6.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.50.6.5 07-Nov-2007  joerg Introduce device_has_power to fix a race between resuming a device and
the device enabling interrupts as seen by jmcneill@ with uhci. Change
ehci, ohci, uhci and azalia to use this function to protect the
interrupt handler.
 1.50.6.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.50.6.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.50.6.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.50.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.50.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.51.12.1 11-Dec-2007  yamt sync with head.
 1.51.10.1 26-Dec-2007  ad Sync with head.
 1.51.2.2 23-Mar-2008  matt sync with HEAD
 1.51.2.1 09-Jan-2008  matt sync with HEAD
 1.52.10.5 17-Jan-2009  mjf Sync with HEAD.
 1.52.10.4 29-Jun-2008  mjf Sync with HEAD.
 1.52.10.3 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.52.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.52.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.52.6.1 24-Mar-2008  keiichi sync with head.
 1.54.4.4 11-Mar-2010  yamt sync with head
 1.54.4.3 16-May-2009  yamt sync with head
 1.54.4.2 04-May-2009  yamt sync with head.
 1.54.4.1 16-May-2008  yamt sync with head.
 1.54.2.3 17-Jun-2008  yamt sync with head.
 1.54.2.2 04-Jun-2008  yamt sync with head
 1.54.2.1 18-May-2008  yamt sync with head.
 1.55.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.55.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.63.2.1 27-Jun-2008  simonb Sync with head.
 1.64.8.2 12-Dec-2008  ad Checkpoint work in progress.
 1.64.8.1 11-Dec-2008  ad Checkpoint work in progress.
 1.64.6.2 21-Jan-2010  snj Pull up following revision(s) (requested by tonnerre in ticket #1258):
sys/dev/pci/azalia.c: revision 1.72
sys/dev/pci/hdaudio/hdaudio_afg.c: revision 1.19
Signedness bug/crash in azalia and hdaudio. Fixes PR 42604.
By Pierre Pronchery.
 1.64.6.1 02-Mar-2009  snj branches: 1.64.6.1.2; 1.64.6.1.4;
Pull up following revision(s) (requested by jmcneill in ticket #521):
sys/dev/pci/azalia.c: revision 1.67
PR# port-i386/40143: Viewing an mpeg transport stream with mplayer causes crash
Not directly related to the PR but this bug was discovered while testing.
In azalia_stream_halt, invalidate the intr ptr to prevent a race condition
where azalia_stream_intr can jump off into lala land during stream shutdown.
 1.64.6.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.64.6.1.2.1 21-Jan-2010  snj Pull up following revision(s) (requested by tonnerre in ticket #1258):
sys/dev/pci/azalia.c: revision 1.72
Signedness bug/crash in azalia. Fixes PR 42604.
By Pierre Pronchery.
 1.64.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.64.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.64.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.66.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.72.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.77.4.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.77.4.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.77.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.77.2.1 17-Apr-2012  yamt sync with head
 1.79.12.1 18-May-2014  rmind sync with head
 1.79.8.2 03-Dec-2017  jdolecek update from HEAD
 1.79.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.83.2.1 28-Aug-2017  skrll Sync with HEAD
 1.84.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.84.10.1 10-Jun-2019  christos Sync with HEAD
 1.84.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.86.2.2 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.86.2.1 28-Apr-2019  isaki Adapt to audio2.
 1.88.4.1 29-Feb-2020  ad Sync with head.
 1.23 09-Feb-2020  jmcneill Retire azalia(4).
 1.22 08-May-2019  isaki branches: 1.22.4;
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.21 23-Nov-2011  jmcneill branches: 1.21.50; 1.21.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.20 14-Aug-2008  jmcneill branches: 1.20.6; 1.20.28; 1.20.30;
PR#38860: azalia record does not work on Realtek ALC662-GR

o Don't add unconnected pins to generated mixer list, should help
make auto-generated mixer lists slightly easier to work with.
o Move COP_AWTYPE_AUDIO_MIXER type knobs to mix.* rather than polluting
the inputs.* namespace and giving a few more characters for the
auto-generated names.
o Introduce an alternate to generic_mixer_init, generic_mixer_autoinit.
generic_mixer_autoinit uses COP_AWTYPE_PIN_COMPLEX "default
configuration" capability flags to determine proper pin widget control
and eapd configuration, as well as creating virtual outputs.master,
inputs.dac, and record.volume mixer controls that mirror the default
dac and adc controls.
o Introduce generic_mixer_init_widget which uses COP_AWTYPE_PIN_COMPLEX
"default configuration" device type, gross location, and geometric
locations to guess friendlier mixer control names.
o On ALC662-GR, the primary ADC NID is 0x09, not 0x08, so correct the
convgroupset in alc662_init_dacgroup.

Audio capture now works on ALC662-GR (as found in the ASUS EeePC 701).
Note that only ALC662-GR uses generic_mixer_autoinit and
generic_mixer_init_widget; other codecs will need to be tested and
converted to address PR#38578: azalia_codec.o is too large.
 1.19 07-Jun-2008  freza branches: 1.19.4;
Split device_t/softc. Remove unused macros.
 1.18 28-Apr-2008  martin branches: 1.18.2;
Remove clause 3 and 4 from TNF licenses
 1.17 13-May-2007  kent branches: 1.17.28; 1.17.30; 1.17.32;
Add PCI_SUBCLASS_MULTIMEDIA_HDAUDIO to pcireg.h
and azalia(4) uses it
 1.16 08-May-2007  kent fix a typo: PRESENSE -> PRESENCE

From deanna@OpenBSD
 1.15 05-Feb-2007  kent branches: 1.15.2; 1.15.4; 1.15.6; 1.15.8;
If both of AZALIA_DEBUG and AZALIA_DEBUG_DOT are defined,
a DOT file for Graphviz representing the widget structure
is printed.
 1.14 21-Jul-2006  kent branches: 1.14.4; 1.14.8; 1.14.10;
support for EAPD, Balanced I/O, and LR-Swap
 1.13 25-Jun-2006  kent * disconnect a stream and audio converters on a halt of the stream
* enable S/PDIF for a digital audio converter when connecting
a stream
* rename "inputs.usingdac" to "playback.mode", and
"record.usingadc" to "record.mode"
* add S/PDIF output configuration to ALC882
 1.12 25-Jun-2006  kent ALC260 & Fujitsu LOOX:
mute the internal speaker when the headphone is inserted, and
unmute the internal speaker when the headphone is pulled out.
 1.11 25-Jun-2006  kent handle unsolicited responses.
A codec can receive unsolicited responses by codec_t::unsol_event()
 1.10 23-Jun-2006  kent add some constant macros for unsolicited response and jack sense
 1.9 11-Jun-2006  kent branches: 1.9.2; 1.9.4;
support for multi-channel (>=3) recording with ALC880, ALC882, or STAC9221
 1.8 09-Jun-2006  kent - print audio format only when the format is changed
- print the name of STAC9220 codec
 1.7 07-Jun-2006  kent * move mixer functions from azalia.c to azalia_codec.c, and
rename them like azalia_mixer_foo() to generic_mixer_foo()

* enable codec-specific code to hook any mixer operations such
as creating mixer items, or special handling for a specific
item.

* provide a custom mixer table specific to ALC260
* provide a custom mixer table specific to Fujitsu LOOX
 1.6 16-Jan-2006  kent branches: 1.6.2; 1.6.4; 1.6.6; 1.6.12;
Don't crash when a connection list has invalid NIDs.

PR#32485 by Samuel Tran
 1.5 03-Jan-2006  kent - make this compile with AZALIA_DEBUG
Thanks to Tomokatsu HAYAKAWA.
- introduce WIDGET_CHANNELS macro
 1.4 11-Dec-2005  christos branches: 1.4.2; 1.4.4;
merge ktrace-lwp.
 1.3 29-Sep-2005  kent branches: 1.3.6;
* shorten *_init_dacgroup() functions
* add a hook point for widget initialization and implement for ALC882
 1.2 28-Sep-2005  kent add codec-specific code for ALC260, ALC880, ALC882,
and STAC9221 to detect DAC/ADC cominations.
 1.1 28-Sep-2005  kent split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 29-Sep-2005  skrll file azalia.h was added on branch ktrace-lwp on 2005-11-10 14:06:00 +0000
 1.4.4.2 01-Feb-2006  yamt sync with head.
 1.4.4.1 15-Jan-2006  yamt sync with head.
 1.4.2.15 27-May-2007  bouyer Pull up following revision(s) (requested by kent in ticket #1780):
sys/dev/pci/azalia_codec.c: revisions 1.25, 1.28, 1.30 - 1.42
sys/dev/pci/azalia.c: revisions 1.43, 1.46 - 1.49
sys/dev/pci/azalia.h: revisions 1.15 - 1.16
Bug fixes, and add support for some more codecs.
PR#34880, PR#35658, PR#36302
 1.4.2.14 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.23
sys/dev/pci/azalia.h: revision 1.14
support for EAPD, Balanced I/O, and LR-Swap
 1.4.2.13 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.20
sys/dev/pci/azalia.h: revision 1.13
sys/dev/pci/azalia.c: revision 1.35
* disconnect a stream and audio converters on a halt of the stream
* enable S/PDIF for a digital audio converter when connecting
a stream
* rename "inputs.usingdac" to "playback.mode", and
"record.usingadc" to "record.mode"
* add S/PDIF output configuration to ALC882
 1.4.2.12 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.12
sys/dev/pci/azalia_codec.c: revision 1.19
sys/dev/pci/azalia.c: revision 1.34
ALC260 & Fujitsu LOOX:
mute the internal speaker when the headphone is inserted, and
unmute the internal speaker when the headphone is pulled out.
 1.4.2.11 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.11
sys/dev/pci/azalia.c: revision 1.31
handle unsolicited responses.
A codec can receive unsolicited responses by codec_t::unsol_event()
 1.4.2.10 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.10
add some constant macros for unsolicited response and jack sense
 1.4.2.9 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.25
sys/dev/pci/azalia.h: revision 1.9
sys/dev/pci/azalia_codec.c: revision 1.12
support for multi-channel (>=3) recording with ALC880, ALC882, or STAC9221
 1.4.2.8 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.23
sys/dev/pci/azalia.h: revision 1.8
sys/dev/pci/azalia_codec.c: revision 1.10
- print audio format only when the format is changed
- print the name of STAC9220 codec
 1.4.2.7 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.7
sys/dev/pci/azalia_codec.c: revision 1.9
sys/dev/pci/azalia.c: revision 1.21
* move mixer functions from azalia.c to azalia_codec.c, and
rename them like azalia_mixer_foo() to generic_mixer_foo()
* enable codec-specific code to hook any mixer operations such
as creating mixer items, or special handling for a specific
item.
* provide a custom mixer table specific to ALC260
* provide a custom mixer table specific to Fujitsu LOOX
 1.4.2.6 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia.h: revision 1.6
sys/dev/pci/azalia.c: revision 1.19
Don't crash when a connection list has invalid NIDs.
PR#32485 by Samuel Tran
 1.4.2.5 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia.h: revision 1.5
sys/dev/pci/azalia.c: revision 1.17
- make this compile with AZALIA_DEBUG
Thanks to Tomokatsu HAYAKAWA.
- introduce WIDGET_CHANNELS macro
 1.4.2.4 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.3
sys/dev/pci/azalia_codec.c: revision 1.3
sys/dev/pci/azalia.c: revision 1.15
* shorten *_init_dacgroup() functions
* add a hook point for widget initialization and implement for ALC882
 1.4.2.3 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.2
sys/dev/pci/azalia_codec.c: revision 1.2
sys/dev/pci/azalia.c: revision 1.14
add codec-specific code for ALC260, ALC880, ALC882,
and STAC9221 to detect DAC/ADC cominations.
 1.4.2.2 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.1
sys/dev/pci/azalia_codec.c: revision 1.1
sys/dev/pci/azalia.c: revision 1.13
sys/dev/pci/files.pci: revision 1.239
split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.4.2.1 11-Dec-2005  riz file azalia.h was added on branch netbsd-3 on 2005-12-29 19:33:40 +0000
 1.6.12.1 19-Jun-2006  chap Sync with head.
 1.6.6.2 11-Aug-2006  yamt sync with head
 1.6.6.1 26-Jun-2006  yamt sync with head.
 1.6.4.1 07-Jun-2006  kardel Sync with head.
 1.6.2.1 09-Sep-2006  rpaulo sync with head
 1.9.4.5 03-Sep-2007  yamt sync with head.
 1.9.4.4 26-Feb-2007  yamt sync with head.
 1.9.4.3 30-Dec-2006  yamt sync with head.
 1.9.4.2 21-Jun-2006  yamt sync with head.
 1.9.4.1 11-Jun-2006  yamt file azalia.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:03 +0000
 1.9.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.14.10.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.14.8.1 20-May-2007  jdc Pull up revision 1.15-1.16 (requested by kent in ticket #649).

If both of AZALIA_DEBUG and AZALIA_DEBUG_DOT are defined,
a DOT file for Graphviz representing the widget structure
is printed.

fix a typo: PRESENSE -> PRESENCE

>From deanna@OpenBSD
 1.14.4.1 09-Feb-2007  ad Sync with HEAD.
 1.15.8.1 11-Jul-2007  mjf Sync with head.
 1.15.6.1 27-May-2007  ad Sync with head.
 1.15.4.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.15.2.1 17-May-2007  yamt sync with head.
 1.17.32.2 04-May-2009  yamt sync with head.
 1.17.32.1 16-May-2008  yamt sync with head.
 1.17.30.2 17-Jun-2008  yamt sync with head.
 1.17.30.1 18-May-2008  yamt sync with head.
 1.17.28.3 28-Sep-2008  mjf Sync with HEAD.
 1.17.28.2 29-Jun-2008  mjf Sync with HEAD.
 1.17.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.18.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.19.4.1 19-Oct-2008  haad Sync with HEAD.
 1.20.30.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.20.28.1 17-Apr-2012  yamt sync with head
 1.20.6.2 12-Dec-2008  ad Checkpoint work in progress.
 1.20.6.1 11-Dec-2008  ad Checkpoint work in progress.
 1.21.54.1 28-Apr-2019  isaki Adapt to audio2.
 1.21.50.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.50.1 10-Jun-2019  christos Sync with HEAD
 1.22.4.1 29-Feb-2020  ad Sync with head.
 1.82 09-Feb-2020  jmcneill Retire azalia(4).
 1.81 28-Jul-2017  nat branches: 1.81.4; 1.81.12;
Mixer device bounds checking.

Analysis by Ilja van Sprundel.
 1.80 01-Jun-2017  chs branches: 1.80.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.79 23-Nov-2011  jmcneill branches: 1.79.8; 1.79.24; 1.79.26; 1.79.28; 1.79.36;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.78 03-May-2010  dholland branches: 1.78.8; 1.78.10;
Fix a crash during alc888 initialization caused by holding a pointer
across realloc. Patch from Bj?rn Barkenfelt in PR kern/41957, rearranged
somewhat by myself.
 1.77 07-Apr-2009  stacktic branches: 1.77.2; 1.77.4;
Add Realtek ALC663 and treat like ALC662 (ok pooka@)
 1.76 28-Feb-2009  jmcneill Add proper Realtek ALC268 support. While we're here, fix a comment in
the ALC262 quirk section. Tested by Sean Davis on an Acer Aspire One.
 1.75 23-Feb-2009  jmcneill * Realtek ALC885: Use generic_mixer_autoinit/init_widget
* generic_mixer_create_virtual: if the front l/r DAC doesn't have a volume
capability, enumerate all peer widgets and search for a volume mixer
there.
 1.74 27-Jan-2009  markd branches: 1.74.2;
Add Analog Devices AD1984A and treat like AD1984.
 1.73 18-Jan-2009  cegger Use aprint_error_dev. Eliminates XNAME macro.
 1.72 12-Nov-2008  jmcneill branches: 1.72.2;
Add support for Realtek ALC269 as found in Eee PC 1000HA.
 1.71 24-Aug-2008  kent branches: 1.71.2; 1.71.4;
* generic_mixer_create_virtual()
Don't track items by pointers because the buffer can be moved by realloc().

PR kern/39382, reported and patch provided by Takahiro Hayashi
 1.70 15-Aug-2008  jmcneill AD1984: Take advantage of pin auto-config and auto-naming.
 1.69 15-Aug-2008  jmcneill Skip unconnected pins when creating a selector connlist.
 1.68 14-Aug-2008  jmcneill PR#38860: azalia record does not work on Realtek ALC662-GR

o Don't add unconnected pins to generated mixer list, should help
make auto-generated mixer lists slightly easier to work with.
o Move COP_AWTYPE_AUDIO_MIXER type knobs to mix.* rather than polluting
the inputs.* namespace and giving a few more characters for the
auto-generated names.
o Introduce an alternate to generic_mixer_init, generic_mixer_autoinit.
generic_mixer_autoinit uses COP_AWTYPE_PIN_COMPLEX "default
configuration" capability flags to determine proper pin widget control
and eapd configuration, as well as creating virtual outputs.master,
inputs.dac, and record.volume mixer controls that mirror the default
dac and adc controls.
o Introduce generic_mixer_init_widget which uses COP_AWTYPE_PIN_COMPLEX
"default configuration" device type, gross location, and geometric
locations to guess friendlier mixer control names.
o On ALC662-GR, the primary ADC NID is 0x09, not 0x08, so correct the
convgroupset in alc662_init_dacgroup.

Audio capture now works on ALC662-GR (as found in the ASUS EeePC 701).
Note that only ALC662-GR uses generic_mixer_autoinit and
generic_mixer_init_widget; other codecs will need to be tested and
converted to address PR#38578: azalia_codec.o is too large.
 1.67 06-Jul-2008  abs branches: 1.67.2;
Commit patch from jmcneill@ to fix "No sound on Thinkpad azalia"
Definitely fixes a T60p, and hopefully will fix PR#37141 for an R61 also
 1.66 24-Jun-2008  gmcgarry pcc doesn't like empty structures for initialisation. Fill with zeros.
 1.65 07-Jun-2008  freza branches: 1.65.2;
Split device_t/softc. Remove unused macros.
 1.64 28-Apr-2008  martin branches: 1.64.2;
Remove clause 3 and 4 from TNF licenses
 1.63 10-Apr-2008  cegger branches: 1.63.2; 1.63.4;
use aprint_*_dev and device_xname
 1.62 31-Mar-2008  jmcneill Add outputs.master.mute and inputs.dac.mute knobs for ALC662. XXX these
currently only control speaker mute, not headphone. Needs to be revisited.
 1.61 31-Mar-2008  jmcneill Initial support for the Realtek ALC662-GR as found in the ASUS Eee PC.
 1.60 22-Feb-2008  oster Make outputs.master and inputs.dac show up in mixerctl output for the ALC888. Patch from, and much thanks to, jmcneill @.
 1.59 31-Jan-2008  markd branches: 1.59.2; 1.59.6;
s/AD1983_EVENT/AD198X_EVENT/
 1.58 31-Jan-2008  markd Use more meaningful names for AD1984 widgets.
Select dac as default input for internal mono speaker.
Handle jack pin detect for headphones and lineout on Dell Optiplex 755.
 1.57 30-Jan-2008  jmcneill AD1984: Create a dummy outputs.master mixer knob that mirrors inputs.dac,
since AD1984 doesn't have a traditional master volume control.
 1.56 30-Jan-2008  jmcneill AD1984: Use the same DAC for speaker and headphones, so the headphone jack
works as expected on Thinkpad T61 (and probably others).
 1.55 06-Jan-2008  kent recognized the names of Sigmatel STAC9227-9230
 1.54 04-Jan-2008  kent shorten mixer-input names by mixer-name automatic generation

PR/37273
 1.53 04-Jan-2008  kent simplify conversion rule between device volume values and userland
volume values. Some mixer values never be 255 by this change.

PR#37274
 1.52 03-Jan-2008  kent code cleanup
- use __arraycount
- remove unnecessary M_ZERO flags
 1.51 03-Jan-2008  kent - add initialization for ATI HDMI audio
- add custom mixer table for AD1986A by scw@
PR: kern/36140
 1.50 09-Dec-2007  jmcneill branches: 1.50.2;
Merge jmcneill-pm branch.
 1.49 26-Nov-2007  christos branches: 1.49.2; 1.49.4;
Add dell latitude 420 in the list of machines that need special treatment
to silence speakers when headphones are plugged in. From Marcin Michal Jessa
 1.48 07-Nov-2007  joerg When converting mixer values to hardware values, round up. This makes
stepping and restore actually work.
 1.47 03-Nov-2007  markd branches: 1.47.2;
Add support for Analog Devices AD1983 codec as found in Dell Optiplex 745.
 1.46 30-Oct-2007  joerg Add another Dell machine where the head phone event needs to be handled.
 1.45 22-Sep-2007  xtraeme branches: 1.45.4;
alc883_mixer_init: fix this->nmixers, __arraycount() wasn't correct.
 1.44 22-Sep-2007  xtraeme Apply revision 1.22 from OpenBSD, quoting deanna's commit:

"Add support for Realtek ALC883. This is the "value" edition of the
ALC882, and differs only by lacking an ADC and a mixer, so have it use
ALC882's get_port(), set_port() and a slightly modified version of its
mixer init."
 1.43 13-Sep-2007  jmcneill Add basic support for the Analog Devices AD1984 codec as found in the
ThinkPad T61.
 1.42 13-May-2007  kent branches: 1.42.6; 1.42.8;
* stac9221_gpio_unmute()
The target node should be the audio function group, not 0.
Pointed out by Deanna Phillips

* stac9221_mixer_init()
Enable GPIO unmute for Intel Macintosh
 1.41 10-May-2007  sketch Match recent addition as a STAC9200.
 1.40 10-May-2007  sketch Update previous to match what the author probably meant to do.
 1.39 10-May-2007  kent Support for headphone-sensing for DELL Inspiron 6400.

PR#36302 by Aleksej Saushev
 1.38 08-May-2007  kent fix a typo: PRESENSE -> PRESENCE

From deanna@OpenBSD
 1.37 08-May-2007  kent - fix incorrect codec name of STAC9200
- support for headphone-sensing in some DELL machines with STAC9200

From azalia_codec.c rev.1.19 by deanna@OpenBSD
 1.36 19-Mar-2007  kent readable mixer item names for AD1981HD
 1.35 18-Mar-2007  kent don't make a mixer item for a power widget
 1.34 18-Mar-2007  kent correct the DAC group definition for AD1988.
reported by wiz
 1.33 11-Mar-2007  kent branches: 1.33.2; 1.33.4;
* codec names for Realtek ALC262, ALC268, ALC861, ALC861-VD-GR,
ALC883, ALC885, and ALC888
* DAC/ADC group definitions for Realtek ALC861, ALC861-VD-GR,
ALC883, ALC885, and ALC888
 1.32 11-Mar-2007  kent remove DPRINTF() in generic_mixer_init() because they are useless
in many cases.
 1.31 11-Mar-2007  kent - Add jack-sense code for STAC9220 in some DELL models (currently disabled)
- Add DAC/ADC grouping for AD1988
 1.30 11-Mar-2007  kent reviced Intel Mac support code (currently disabled)

PR#34880
 1.29 21-Feb-2007  thorpej branches: 1.29.4;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.28 06-Jan-2007  kent branches: 1.28.2;
* generic_mixer_default()
make the default values of bidirectional pins `output' because
they were often the main reason of no sound problems.

* add stac9221_mixer_init()
It has a code for Intel Mac but it is disabled for now.
 1.27 16-Nov-2006  christos branches: 1.27.2; 1.27.4;
__unused removal on arguments; approved by core.
 1.26 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.25 03-Sep-2006  christos branches: 1.25.2; 1.25.4;
fix initializers
 1.24 23-Jul-2006  kent For ThinkPad T60, make the default value of outputs.linein.dir "output"
 1.23 21-Jul-2006  kent support for EAPD, Balanced I/O, and LR-Swap
 1.22 19-Jul-2006  kent fix crash by reading a mixer value with AD1981HD codec, which
has invalid connection lists.
 1.21 26-Jun-2006  kent * custom mixer table for ALC880
* remove useless mixers of ALC882
 1.20 25-Jun-2006  kent * disconnect a stream and audio converters on a halt of the stream
* enable S/PDIF for a digital audio converter when connecting
a stream
* rename "inputs.usingdac" to "playback.mode", and
"record.usingadc" to "record.mode"
* add S/PDIF output configuration to ALC882
 1.19 25-Jun-2006  kent ALC260 & Fujitsu LOOX:
mute the internal speaker when the headphone is inserted, and
unmute the internal speaker when the headphone is pulled out.
 1.18 24-Jun-2006  kent custom mixer table for CMI9880

PR#33787
 1.17 24-Jun-2006  kent DAC&ADC group for CMI9880

PR#33787
 1.16 15-Jun-2006  kent branches: 1.16.2;
Fix a bug that AUDIO_MIXER_READ returns an incorrect
mixer_ctrl_t::un.value.num_channels in the case of the
combination of a mono pin and a stereo mixer.
 1.15 13-Jun-2006  kent branches: 1.15.2;
* generic_mixer_default()
set the default pin direction depending on the pin's device, not color
 1.14 13-Jun-2006  kent ALC882:
- add usingdac and usingadc
- remove alc882_init_widget() because it has no effect any more
 1.13 11-Jun-2006  kent codec-specific mixer initialization for Realtek ALC882
 1.12 11-Jun-2006  kent support for multi-channel (>=3) recording with ALC880, ALC882, or STAC9221
 1.11 11-Jun-2006  kent * azalia_codec_init_vtbl()
recognize the name of AD1983
* generic_codec_find_dac()
check validity of a node in a connection list
* introduce MIXER_DELTA, and simplify the code with it
* codec-specific mixer initialization for STAC9220
 1.10 09-Jun-2006  kent - print audio format only when the format is changed
- print the name of STAC9220 codec
 1.9 07-Jun-2006  kent * move mixer functions from azalia.c to azalia_codec.c, and
rename them like azalia_mixer_foo() to generic_mixer_foo()

* enable codec-specific code to hook any mixer operations such
as creating mixer items, or special handling for a specific
item.

* provide a custom mixer table specific to ALC260
* provide a custom mixer table specific to Fujitsu LOOX
 1.8 10-May-2006  kent branches: 1.8.2;
fix incorrect ADC list for ALC880.

PR kern/33326 by Uwe Klaus
 1.7 16-Jan-2006  kent branches: 1.7.2; 1.7.4; 1.7.6; 1.7.8; 1.7.10;
readable names for AD1981HD codec
 1.6 03-Jan-2006  kent support for 8ch playback with STAC9221D codec.
Thanks to Tomokatsu HAYAKAWA.
 1.5 03-Jan-2006  kent ALC260: improve readability of mixer item names.
 1.4 11-Dec-2005  christos branches: 1.4.2; 1.4.4;
merge ktrace-lwp.
 1.3 29-Sep-2005  kent branches: 1.3.6;
* shorten *_init_dacgroup() functions
* add a hook point for widget initialization and implement for ALC882
 1.2 28-Sep-2005  kent add codec-specific code for ALC260, ALC880, ALC882,
and STAC9221 to detect DAC/ADC cominations.
 1.1 28-Sep-2005  kent split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 29-Sep-2005  skrll file azalia_codec.c was added on branch ktrace-lwp on 2005-11-10 14:06:00 +0000
 1.4.4.2 01-Feb-2006  yamt sync with head.
 1.4.4.1 15-Jan-2006  yamt sync with head.
 1.4.2.26 27-May-2007  bouyer Pull up following revision(s) (requested by kent in ticket #1780):
sys/dev/pci/azalia_codec.c: revisions 1.25, 1.28, 1.30 - 1.42
sys/dev/pci/azalia.c: revisions 1.43, 1.46 - 1.49
sys/dev/pci/azalia.h: revisions 1.15 - 1.16
Bug fixes, and add support for some more codecs.
PR#34880, PR#35658, PR#36302
 1.4.2.25 31-Jul-2006  tron Apply patch (requested by kent in ticket #1432):
Fix build problem.
 1.4.2.24 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.24
For ThinkPad T60, make the default value of outputs.linein.dir "output"
 1.4.2.23 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.23
sys/dev/pci/azalia.h: revision 1.14
support for EAPD, Balanced I/O, and LR-Swap
 1.4.2.22 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.22
fix crash by reading a mixer value with AD1981HD codec, which
has invalid connection lists.
 1.4.2.21 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.21
* custom mixer table for ALC880
* remove useless mixers of ALC882
 1.4.2.20 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.20
sys/dev/pci/azalia.h: revision 1.13
sys/dev/pci/azalia.c: revision 1.35
* disconnect a stream and audio converters on a halt of the stream
* enable S/PDIF for a digital audio converter when connecting
a stream
* rename "inputs.usingdac" to "playback.mode", and
"record.usingadc" to "record.mode"
* add S/PDIF output configuration to ALC882
 1.4.2.19 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.12
sys/dev/pci/azalia_codec.c: revision 1.19
sys/dev/pci/azalia.c: revision 1.34
ALC260 & Fujitsu LOOX:
mute the internal speaker when the headphone is inserted, and
unmute the internal speaker when the headphone is pulled out.
 1.4.2.18 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.18
custom mixer table for CMI9880
PR#33787
 1.4.2.17 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.17
DAC&ADC group for CMI9880
PR#33787
 1.4.2.16 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.16
Fix a bug that AUDIO_MIXER_READ returns an incorrect
mixer_ctrl_t::un.value.num_channels in the case of the
combination of a mono pin and a stereo mixer.
 1.4.2.15 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.15
* generic_mixer_default()
set the default pin direction depending on the pin's device, not color
 1.4.2.14 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.14
ALC882:
- add usingdac and usingadc
- remove alc882_init_widget() because it has no effect any more
 1.4.2.13 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.13
codec-specific mixer initialization for Realtek ALC882
 1.4.2.12 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.25
sys/dev/pci/azalia.h: revision 1.9
sys/dev/pci/azalia_codec.c: revision 1.12
support for multi-channel (>=3) recording with ALC880, ALC882, or STAC9221
 1.4.2.11 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia_codec.c: revision 1.11
* azalia_codec_init_vtbl()
recognize the name of AD1983
* generic_codec_find_dac()
check validity of a node in a connection list
* introduce MIXER_DELTA, and simplify the code with it
* codec-specific mixer initialization for STAC9220
 1.4.2.10 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.c: revision 1.23
sys/dev/pci/azalia.h: revision 1.8
sys/dev/pci/azalia_codec.c: revision 1.10
- print audio format only when the format is changed
- print the name of STAC9220 codec
 1.4.2.9 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/azalia.h: revision 1.7
sys/dev/pci/azalia_codec.c: revision 1.9
sys/dev/pci/azalia.c: revision 1.21
* move mixer functions from azalia.c to azalia_codec.c, and
rename them like azalia_mixer_foo() to generic_mixer_foo()
* enable codec-specific code to hook any mixer operations such
as creating mixer items, or special handling for a specific
item.
* provide a custom mixer table specific to ALC260
* provide a custom mixer table specific to Fujitsu LOOX
 1.4.2.8 13-May-2006  tron Pull up following revision(s) (requested by kent in ticket #1318):
sys/dev/pci/azalia_codec.c: revision 1.8
fix incorrect ADC list for ALC880.
PR kern/33326 by Uwe Klaus
 1.4.2.7 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia_codec.c: revision 1.7
readable names for AD1981HD codec
 1.4.2.6 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia_codec.c: revision 1.6
support for 8ch playback with STAC9221D codec.
Thanks to Tomokatsu HAYAKAWA.
 1.4.2.5 27-Jan-2006  tron Pull up following revision(s) (requested by kent in ticket #1124):
sys/dev/pci/azalia_codec.c: revision 1.5
ALC260: improve readability of mixer item names.
 1.4.2.4 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.3
sys/dev/pci/azalia_codec.c: revision 1.3
sys/dev/pci/azalia.c: revision 1.15
* shorten *_init_dacgroup() functions
* add a hook point for widget initialization and implement for ALC882
 1.4.2.3 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.2
sys/dev/pci/azalia_codec.c: revision 1.2
sys/dev/pci/azalia.c: revision 1.14
add codec-specific code for ALC260, ALC880, ALC882,
and STAC9221 to detect DAC/ADC cominations.
 1.4.2.2 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.1
sys/dev/pci/azalia_codec.c: revision 1.1
sys/dev/pci/azalia.c: revision 1.13
sys/dev/pci/files.pci: revision 1.239
split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.4.2.1 11-Dec-2005  riz file azalia_codec.c was added on branch netbsd-3 on 2005-12-29 19:33:40 +0000
 1.7.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.8.1 11-May-2006  elad sync with head
 1.7.6.4 14-Sep-2006  yamt sync with head.
 1.7.6.3 11-Aug-2006  yamt sync with head
 1.7.6.2 26-Jun-2006  yamt sync with head.
 1.7.6.1 24-May-2006  yamt sync with head.
 1.7.4.2 07-Jun-2006  kardel Sync with head.
 1.7.4.1 01-Jun-2006  kardel Sync with head.
 1.7.2.1 09-Sep-2006  rpaulo sync with head
 1.8.2.1 19-Jun-2006  chap Sync with head.
 1.15.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.16.2.11 27-Feb-2008  yamt sync with head.
 1.16.2.10 04-Feb-2008  yamt sync with head.
 1.16.2.9 21-Jan-2008  yamt sync with head
 1.16.2.8 07-Dec-2007  yamt sync with head
 1.16.2.7 15-Nov-2007  yamt sync with head.
 1.16.2.6 27-Oct-2007  yamt sync with head.
 1.16.2.5 03-Sep-2007  yamt sync with head.
 1.16.2.4 26-Feb-2007  yamt sync with head.
 1.16.2.3 30-Dec-2006  yamt sync with head.
 1.16.2.2 21-Jun-2006  yamt sync with head.
 1.16.2.1 15-Jun-2006  yamt file azalia_codec.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:03 +0000
 1.25.4.2 10-Dec-2006  yamt sync with head.
 1.25.4.1 22-Oct-2006  yamt sync with head
 1.25.2.2 12-Jan-2007  ad Sync with head.
 1.25.2.1 18-Nov-2006  ad Sync with head.
 1.27.4.3 04-Sep-2008  skrll Sync with netbsd-4.
 1.27.4.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.27.4.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.27.2.3 06-Jul-2008  bouyer Pull up following revision(s) (requested by abs in ticket #1162):
sys/dev/pci/azalia_codec.c: revision 1.67
Commit patch from jmcneill@ to fix "No sound on Thinkpad azalia"
Definitely fixes a T60p, and hopefully will fix PR#37141 for an R61 also
 1.27.2.2 01-Feb-2008  riz Pull up following revision(s) (requested by joerg in ticket #982):
sys/dev/pci/azalia_codec.c: revision 1.48
When converting mixer values to hardware values, round up. This makes
stepping and restore actually work.
 1.27.2.1 20-May-2007  jdc Pull up revisions 1.28, 1.30-1.42 (requested by kent in ticket #649).

* generic_mixer_default()
make the default values of bidirectional pins `output' because
they were often the main reason of no sound problems.

* add stac9221_mixer_init()
It has a code for Intel Mac but it is disabled for now.

reviced Intel Mac support code (currently disabled)

PR#34880

- Add jack-sense code for STAC9220 in some DELL models (currently disabled)
- Add DAC/ADC grouping for AD1988

remove DPRINTF() in generic_mixer_init() because they are useless
in many cases.

* codec names for Realtek ALC262, ALC268, ALC861, ALC861-VD-GR,
ALC883, ALC885, and ALC888
* DAC/ADC group definitions for Realtek ALC861, ALC861-VD-GR,
ALC883, ALC885, and ALC888

correct the DAC group definition for AD1988.
reported by wiz

don't make a mixer item for a power widget

readable mixer item names for AD1981HD

- fix incorrect codec name of STAC9200
- support for headphone-sensing in some DELL machines with STAC9200

>From azalia_codec.c rev.1.19 by deanna@OpenBSD

fix a typo: PRESENSE -> PRESENCE

>From deanna@OpenBSD

Support for headphone-sensing for DELL Inspiron 6400.

PR#36302 by Aleksej Saushev

Update previous to match what the author probably meant to do.

Match recent addition as a STAC9200.

* stac9221_gpio_unmute()
The target node should be the audio function group, not 0.
Pointed out by Deanna Phillips

* stac9221_mixer_init()
Enable GPIO unmute for Intel Macintosh
 1.28.2.4 17-May-2007  yamt sync with head.
 1.28.2.3 24-Mar-2007  yamt sync with head.
 1.28.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.28.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.29.4.4 09-Oct-2007  ad Sync with head.
 1.29.4.3 27-May-2007  ad Sync with head.
 1.29.4.2 10-Apr-2007  ad Sync with head.
 1.29.4.1 13-Mar-2007  ad Sync with head.
 1.33.4.1 29-Mar-2007  reinoud Pullup to -current
 1.33.2.1 11-Jul-2007  mjf Sync with head.
 1.42.8.4 23-Mar-2008  matt sync with HEAD
 1.42.8.3 09-Jan-2008  matt sync with HEAD
 1.42.8.2 08-Nov-2007  matt sync with -HEAD
 1.42.8.1 06-Nov-2007  matt sync with HEAD
 1.42.6.7 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.42.6.6 11-Nov-2007  joerg Sync with HEAD.
 1.42.6.5 04-Nov-2007  jmcneill Sync with HEAD.
 1.42.6.4 31-Oct-2007  joerg Sync with HEAD.
 1.42.6.3 03-Oct-2007  jmcneill Enable pnp messaging for the ALC262 codec
 1.42.6.2 02-Oct-2007  joerg Sync with HEAD.
 1.42.6.1 13-Sep-2007  jmcneill Sync with HEAD.
 1.45.4.1 13-Nov-2007  bouyer Sync with HEAD
 1.47.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.47.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.47.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.47.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.49.4.1 11-Dec-2007  yamt sync with head.
 1.49.2.1 26-Dec-2007  ad Sync with head.
 1.50.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.59.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.59.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.59.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.59.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.59.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.59.2.1 24-Mar-2008  keiichi sync with head.
 1.63.4.3 11-Aug-2010  yamt sync with head.
 1.63.4.2 04-May-2009  yamt sync with head.
 1.63.4.1 16-May-2008  yamt sync with head.
 1.63.2.2 17-Jun-2008  yamt sync with head.
 1.63.2.1 18-May-2008  yamt sync with head.
 1.64.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.64.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.65.2.2 18-Jul-2008  simonb Sync with head.
 1.65.2.1 27-Jun-2008  simonb Sync with head.
 1.67.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.67.2.1 19-Oct-2008  haad Sync with HEAD.
 1.71.4.3 02-Mar-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #533):
sys/dev/pci/azalia_codec.c: revision 1.76
Add proper Realtek ALC268 support. While we're here, fix a comment in
the ALC262 quirk section. Tested by Sean Davis on an Acer Aspire One.
 1.71.4.2 24-Feb-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #491):
sys/dev/pci/azalia_codec.c: revision 1.75
* Realtek ALC885: Use generic_mixer_autoinit/init_widget
* generic_mixer_create_virtual: if the front l/r DAC doesn't have a volume
capability, enumerate all peer widgets and search for a volume mixer
there.
 1.71.4.1 14-Nov-2008  snj Pull up following revision(s) (requested by jmcneill in ticket #54):
sys/dev/pci/azalia_codec.c: revision 1.72
Add support for Realtek ALC269 as found in Eee PC 1000HA.
 1.71.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.71.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.71.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.72.2.2 13-Dec-2008  ad Make it compile.
 1.72.2.1 12-Dec-2008  ad Checkpoint work in progress.
 1.74.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.77.4.1 30-May-2010  rmind sync with head
 1.77.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.78.10.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.78.8.1 17-Apr-2012  yamt sync with head
 1.79.36.1 09-Aug-2017  snj Pull up following revision(s) (requested by nat in ticket #1460):
sys/dev/auconv.c: revision 1.30 via patch
sys/dev/ic/ac97.c: revision 1.97 via patch
sys/dev/pci/azalia_codec.c: revision 1.81 via patch
Mixer device bounds checking.
Analysis by Ilja van Sprundel.
 1.79.28.1 09-Aug-2017  snj Pull up following revision(s) (requested by nat in ticket #1460):
sys/dev/auconv.c: revision 1.30 via patch
sys/dev/ic/ac97.c: revision 1.97 via patch
sys/dev/pci/azalia_codec.c: revision 1.81 via patch
Mixer device bounds checking.
Analysis by Ilja van Sprundel.
 1.79.26.1 28-Aug-2017  skrll Sync with HEAD
 1.79.24.1 09-Aug-2017  snj Pull up following revision(s) (requested by nat in ticket #1460):
sys/dev/auconv.c: revision 1.30 via patch
sys/dev/ic/ac97.c: revision 1.97 via patch
sys/dev/pci/azalia_codec.c: revision 1.81 via patch
Mixer device bounds checking.
Analysis by Ilja van Sprundel.
 1.79.8.1 03-Dec-2017  jdolecek update from HEAD
 1.80.2.1 01-Aug-2017  snj Pull up following revision(s) (requested by nat in ticket #166):
sys/dev/auconv.c: revision 1.30
sys/dev/audio.c: revision 1.372
sys/dev/ic/ac97.c: revision 1.97
sys/dev/pci/azalia_codec.c: revision 1.81
Mixer device bounds checking.
Analysis by Ilja van Sprundel.
 1.81.12.1 29-Feb-2020  ad Sync with head.
 1.81.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.41 13-Oct-2016  jdolecek provide intr xname
 1.40 18-Oct-2014  snj branches: 1.40.2; 1.40.4;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.39 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.38 27-Oct-2012  chs branches: 1.38.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.37 26-Nov-2009  njoly branches: 1.37.12; 1.37.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.36 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.35 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.34 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.33 28-Apr-2008  martin branches: 1.33.14;
Remove clause 3 and 4 from TNF licenses
 1.32 10-Apr-2008  cegger branches: 1.32.2; 1.32.4;
use aprint_*_dev and device_xname
 1.31 19-Oct-2007  ad branches: 1.31.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.30 16-Nov-2006  christos branches: 1.30.8; 1.30.22; 1.30.24; 1.30.28;
__unused removal on arguments; approved by core.
 1.29 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.28 11-Dec-2005  christos branches: 1.28.20; 1.28.22;
merge ktrace-lwp.
 1.27 28-Jun-2005  thorpej branches: 1.27.2;
Use ANSI function decls and static.
 1.26 04-Feb-2005  perry de-__P
 1.25 31-Jan-2003  thorpej branches: 1.25.2; 1.25.10; 1.25.12;
Use aprint_*().
 1.24 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.23 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.22 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.21 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.20 13-Nov-2001  lukem add RCSID
 1.19 03-May-2001  ross branches: 1.19.2;
Split pci and eisa/isa attachment calls, plus misc cleanup.
 1.18 25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.17 28-Dec-2000  sommerfeld branches: 1.17.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.16 15-Aug-1998  mycroft branches: 1.16.12;
Assign my copyrights to TNF.
 1.15 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.14 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.13 07-Jun-1997  thorpej branches: 1.13.2; 1.13.4;
Pull the thorpej-bus-dma branch into the mainline.
 1.12 13-Apr-1997  cgd branches: 1.12.2;
rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.11 13-Apr-1997  cgd use pci_map_register().
 1.10 28-Mar-1997  mycroft Use a temporary data structure for holding probe information, rather than a
full softc.
 1.9 13-Mar-1997  cgd clean up the __BROKEN_INDIRECT_CONFIG chunks of the last change
 1.8 13-Mar-1997  cgd fixes from Matt Jacob so that these can compile and run on the Alpha.
(aic7xxx has been tested and works on the Alpha, bha has not yet been
tested on thne Alpha.)
 1.7 17-Feb-1997  jonathan Change bha_pci product names to match latest pcidevs:
PCI_PRODUCT_BUSLOGIC_OLD946C -> PCI_PRODUCT_BUSLOGIC_MULTIMASTER_NC
PCI_PRODUCT_BUSLOGIC_946C -> PCI_PRODUCT_BUSLOGIC_MULTIMASTER
 1.6 05-Nov-1996  jonathan branches: 1.6.4;
* Add command struct and modifier definitions for controlling the
ISA-compatible port space of PCI buslogic cards.

* Add call to bha_pci.c to disable the ISA-compatible ports of a PCI
device. The ISA-compatible ports are enabled by default, which
causes the card to be autoconfigured a second time as an ISA device,
which appears to deadlock the card.

* Change bha_cmd() to return the number of bytes it actually received
in response to a command, or -1 on error.

* Use heuristics (checking for bha-only registers, and checking the size
of the response to BHA_INQURE_EXTENDED) to bha_find, to make sure the
bha driver never matches an aha (Adaptec 1542 or compatible) device.

A single kernel should now boot on either Adaptec or BusLogic controllers,
provided we always probe for BusLogic devices before Adaptec devices,
but this has not yet been verified.
 1.5 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.4 13-Oct-1996  christos backout kprintf changes
 1.3 10-Oct-1996  christos - printf -> kprintf, sprintf -> ksprintf
- include systm.h
 1.2 01-Sep-1996  mycroft Minor changes.
 1.1 31-Aug-1996  mycroft Split the BusLogic driver apart, and rename it to `bha (like BSDi).
 1.6.4.1 12-Mar-1997  is Merge in changes from The Trunk
 1.12.2.1 13-May-1997  thorpej Stash the bus dma tag and bus-specific DMA flags in the softc.
 1.13.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.13.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.16.12.2 27-Mar-2001  bouyer Convert these drivers to thorpej_scsipi (untested).
 1.16.12.1 05-Jan-2001  bouyer Sync with HEAD
 1.17.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.17.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.17.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.17.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.19.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.19.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.25.12.1 12-Feb-2005  yamt sync with head.
 1.25.10.1 29-Apr-2005  kent sync with -current
 1.25.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.27.2.2 27-Oct-2007  yamt sync with head.
 1.27.2.1 30-Dec-2006  yamt sync with head.
 1.28.22.2 10-Dec-2006  yamt sync with head.
 1.28.22.1 22-Oct-2006  yamt sync with head
 1.28.20.1 18-Nov-2006  ad Sync with head.
 1.30.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.30.24.1 06-Nov-2007  matt sync with HEAD
 1.30.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.30.8.1 23-Oct-2007  ad Sync with head.
 1.31.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.4.3 11-Mar-2010  yamt sync with head
 1.32.4.2 16-May-2009  yamt sync with head
 1.32.4.1 16-May-2008  yamt sync with head.
 1.32.2.1 18-May-2008  yamt sync with head.
 1.33.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.37.22.3 03-Dec-2017  jdolecek update from HEAD
 1.37.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.37.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.12.1 30-Oct-2012  yamt sync with head
 1.38.2.1 18-May-2014  rmind sync with head
 1.40.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.40.2.1 05-Dec-2016  skrll Sync with HEAD
 1.37 05-Dec-2023  thorpej b3_617_map_vme(): use VM_NOSLEEP. EX_NOWAIT is 0, to lack of EX_WAITOK
is the same as EX_NOWAIT.
 1.36 05-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage VME<->PCI address
translations.

While here, malloc(9) -> kmem(9), and fix a couple of things that
the newer compiler gripes about.
 1.35 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.34 24-Apr-2021  thorpej branches: 1.34.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.33 24-Aug-2020  msaitoh branches: 1.33.4;
s/ressource/resource/. No functional change.
 1.32 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.31 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.30 29-Mar-2014  christos branches: 1.30.28; 1.30.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.29 27-Oct-2012  chs branches: 1.29.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.28 30-Jan-2012  drochner branches: 1.28.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.27 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.26 26-Nov-2009  njoly branches: 1.26.12; 1.26.16;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.25 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.24 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.23 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.22 16-Mar-2009  dsl ANSIfy functions with function-pointer arguments
 1.21 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.20 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.19 16-Dec-2008  christos branches: 1.19.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.18 10-Apr-2008  cegger branches: 1.18.4; 1.18.12;
use aprint_*_dev and device_xname
 1.17 19-Oct-2007  ad branches: 1.17.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 10-Jan-2007  cube branches: 1.16.6; 1.16.18; 1.16.20; 1.16.24;
Make it compile.
 1.15 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.14 11-Dec-2005  christos branches: 1.14.20; 1.14.22;
merge ktrace-lwp.
 1.13 04-Feb-2005  perry branches: 1.13.6;
de-__P
 1.12 31-Jan-2003  thorpej branches: 1.12.2; 1.12.10; 1.12.12;
Use aprint_*().
 1.11 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.10 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.9 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.8 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.7 04-Mar-2002  simonb Don't "extern int cold;" - this is in <sys/kernel.h>.
 1.6 13-Nov-2001  lukem add RCSID
 1.5 12-Jun-2001  wiz branches: 1.5.2;
receive, not recieve
 1.4 28-Dec-2000  sommerfeld branches: 1.4.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.3 08-Aug-2000  tv sizeof(fmtstring) + 8 wasn't enough for the string; that won't cope with the
printed version. Make a little more room for the bitmask_snprintf() call.
 1.2 08-Aug-2000  tv %b -> bitmask_snprintf()
 1.1 30-Jun-1999  drochner branches: 1.1.2; 1.1.4;
add driver for the Bit3 PCI-VME adapter, without the DMA parts for now
 1.1.4.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.2.1 30-Jun-1999  thorpej file btvmei.c was added on branch chs-ubc2 on 1999-07-01 23:34:02 +0000
 1.4.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.4.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.12.1 12-Feb-2005  yamt sync with head.
 1.12.10.1 29-Apr-2005  kent sync with -current
 1.12.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.13.6.3 27-Oct-2007  yamt sync with head.
 1.13.6.2 26-Feb-2007  yamt sync with head.
 1.13.6.1 30-Dec-2006  yamt sync with head.
 1.14.22.1 10-Dec-2006  yamt sync with head.
 1.14.20.1 12-Jan-2007  ad Sync with head.
 1.16.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.20.1 06-Nov-2007  matt sync with HEAD
 1.16.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.6.1 23-Oct-2007  ad Sync with head.
 1.17.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.17.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.18.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.18.4.3 11-Mar-2010  yamt sync with head
 1.18.4.2 16-May-2009  yamt sync with head
 1.18.4.1 04-May-2009  yamt sync with head.
 1.19.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.16.1 18-Feb-2012  mrg merge to -current.
 1.26.12.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.12.2 30-Oct-2012  yamt sync with head
 1.26.12.1 17-Apr-2012  yamt sync with head
 1.28.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.2.1 18-May-2014  rmind sync with head
 1.30.30.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.30.30.1 10-Jun-2019  christos Sync with HEAD
 1.30.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.33.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.34.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.28 24-Apr-2024  thorpej b3_2706_map_vme(): Use VM_BESTFIT.
 1.27 05-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage VME<->PCI address
translations.

While here, malloc(9) -> kmem(9), and fix a couple of things that
the newer compiler gripes about.
 1.26 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.25 24-Apr-2021  thorpej branches: 1.25.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.24 10-Nov-2019  chs branches: 1.24.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.23 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.22 27-Oct-2012  chs branches: 1.22.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.21 30-Jun-2011  wiz branches: 1.21.2; 1.21.12;
dependant -> dependent
 1.20 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.19 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.18 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.17 16-Mar-2009  dsl ANSIfy functions with function-pointer arguments
 1.16 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.15 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.14 10-Apr-2008  cegger branches: 1.14.4; 1.14.12; 1.14.18;
use aprint_*_dev and device_xname
 1.13 19-Oct-2007  ad branches: 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 24-Nov-2006  wiz branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
s/independant/independent/, from Zafer.
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 04-Feb-2005  perry branches: 1.10.6;
de-__P
 1.9 31-Jan-2003  thorpej branches: 1.9.2; 1.9.10; 1.9.12;
Use aprint_*().
 1.8 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.7 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 04-Mar-2002  simonb Don't "extern int cold;" - this is in <sys/kernel.h>.
 1.4 13-Nov-2001  lukem add RCSID
 1.3 07-Jul-2001  thorpej branches: 1.3.2;
bcopy -> memcpy
 1.2 12-Mar-2000  drochner branches: 1.2.6; 1.2.8;
support bus probes a la "badaddr" and VME interrupts, fix error handling
after mapping problems
 1.1 25-Feb-2000  drochner add (minimal, PIO only) support for the popular "Tundra Universe"
PCI-VME interface chip and a frontend for the "Bit3 Mod. 2706"
PCI-VME adapter
 1.2.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.8.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.8.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.8.1 24-Aug-2001  nathanw Catch up with -current.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 12-Mar-2000  bouyer file btvmeii.c was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.3.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.12.1 12-Feb-2005  yamt sync with head.
 1.9.10.1 29-Apr-2005  kent sync with -current
 1.9.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.10.6.2 27-Oct-2007  yamt sync with head.
 1.10.6.1 30-Dec-2006  yamt sync with head.
 1.11.22.1 10-Dec-2006  yamt sync with head.
 1.11.20.1 12-Jan-2007  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.14.4.2 16-May-2009  yamt sync with head
 1.14.4.1 04-May-2009  yamt sync with head.
 1.21.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.2.1 30-Oct-2012  yamt sync with head
 1.22.38.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22.38.1 10-Jun-2019  christos Sync with HEAD
 1.24.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.25.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 11-Dec-2005  christos merge ktrace-lwp.
 1.4 24-Feb-2004  wiz Spell interrupt with two rs. From Peter Postma.
 1.3 16-Sep-2001  wiz branches: 1.3.18;
Spell 'occurred' with two 'r's.
 1.2 12-Jun-2001  wiz branches: 1.2.2; 1.2.4;
receive, not recieve
 1.1 30-Jun-1999  drochner branches: 1.1.2; 1.1.16;
add driver for the Bit3 PCI-VME adapter, without the DMA parts for now
 1.1.16.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.16.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.2.1 30-Jun-1999  thorpej file btvmeireg.h was added on branch chs-ubc2 on 1999-07-01 23:34:02 +0000
 1.2.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.18.1 03-Aug-2004  skrll Sync with HEAD
 1.6 05-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage VME<->PCI address
translations.

While here, malloc(9) -> kmem(9), and fix a couple of things that
the newer compiler gripes about.
 1.5 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.4 11-Dec-2005  christos branches: 1.4.110; 1.4.120;
merge ktrace-lwp.
 1.3 04-Feb-2005  perry de-__P
 1.2 24-Mar-2004  drochner branches: 1.2.8; 1.2.10;
remove license clauses 3 and 4 from my cpoyright notices
 1.1 30-Jun-1999  drochner branches: 1.1.2; 1.1.38;
add driver for the Bit3 PCI-VME adapter, without the DMA parts for now
 1.1.38.4 04-Feb-2005  skrll Sync with HEAD.
 1.1.38.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.38.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.38.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.2.1 30-Jun-1999  thorpej file btvmeivar.h was added on branch chs-ubc2 on 1999-07-01 23:34:03 +0000
 1.2.10.1 12-Feb-2005  yamt sync with head.
 1.2.8.1 29-Apr-2005  kent sync with -current
 1.4.120.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.110.1 30-Oct-2012  yamt sync with head
 1.36 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.35 27-Sep-2016  pgoyette branches: 1.35.14; 1.35.16;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.34 29-Mar-2014  christos branches: 1.34.6; 1.34.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.33 27-Oct-2012  chs branches: 1.33.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.32 26-Nov-2009  njoly branches: 1.32.12; 1.32.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.31 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.30 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.29 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.28 28-Apr-2008  martin branches: 1.28.14;
Remove clause 3 and 4 from TNF licenses
 1.27 10-Apr-2008  cegger branches: 1.27.2; 1.27.4;
use aprint_*_dev and device_xname
 1.26 19-Oct-2007  ad branches: 1.26.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.25 04-Mar-2007  christos branches: 1.25.2; 1.25.14; 1.25.16; 1.25.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.24 28-Nov-2006  ad branches: 1.24.4;
Improve error handling. Related to PR/21900.
 1.23 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.22 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21 28-Aug-2006  christos branches: 1.21.2; 1.21.4;
static goes first.
 1.20 11-Dec-2005  christos branches: 1.20.4; 1.20.8;
merge ktrace-lwp.
 1.19 28-Jun-2005  thorpej branches: 1.19.2;
Use ANSI function decls and static.
 1.18 27-Feb-2005  perry nuke trailing whitespace
 1.17 31-Jan-2003  thorpej branches: 1.17.2; 1.17.10; 1.17.12;
Use aprint_*().
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 15-May-2002  augustss Adapt to new bridge name.
 1.12 25-Jan-2002  ad - Always validate the return value read from the outbound FIFO.
- Copy access method info into the softc so we don't double dereference.
- Remove static on functions.
 1.11 13-Nov-2001  lukem add RCSID
 1.10 10-Jan-2001  ad branches: 1.10.2; 1.10.4;
Make this work with the SA 431 and 42xx series controllers.
 1.9 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.8 09-Nov-2000  ad branches: 1.8.2;
Match controllers hiding behind a Symbios 53c1510; thanks to Jonathan Lemon
<jlemon@flugsvamp.com> for providing clarification.
 1.7 19-Oct-2000  ad Nuke unused includes, sort decls.
 1.6 26-Sep-2000  ad Pasto; shouldn't have bitten anyone.
 1.5 01-Sep-2000  ad - Interface cleanup. static, const in places.
- cac_pci_l0 has been moved to cac.c, since it's useful for EISA boards.
- Model-specific linkage now is responsible for DMA synchronization.
- If we don't recognise the board, print the subsystem ID.
- Add support for RAID LC2 and Smart Array 431.
- Start firmware background tasks on controllers that need it.
 1.4 13-Jun-2000  ad branches: 1.4.2;
Use my proper name.
 1.3 23-Mar-2000  ad branches: 1.3.2;
Identify individual models correctly.
 1.2 21-Mar-2000  ad Try to use memory mapped I/O on everything but the SMART-2/E.
 1.1 16-Mar-2000  ad Driver for Compaq array controllers and disks (cac(4)/ca(4)).
 1.3.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.4.2.2 29-Jan-2002  he Pull up revision 1.12 (requested by ad):
Some fixes:
o Always validate return value read from outbound FIFO
o Copy access method into to softc to avoid double dereference
o Remove static on functions
Fixes PR#14453.
 1.4.2.1 25-Oct-2001  he Pull up revisions 1.5-1.10 (via patch, requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.8.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.8.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.8.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.8.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.2.1 09-Nov-2000  bouyer file cac_pci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.10.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.10.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.10.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.10.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.10.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.17.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.10.1 29-Apr-2005  kent sync with -current
 1.17.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.3 27-Oct-2007  yamt sync with head.
 1.19.2.2 03-Sep-2007  yamt sync with head.
 1.19.2.1 30-Dec-2006  yamt sync with head.
 1.20.8.1 03-Sep-2006  yamt sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.21.4.2 10-Dec-2006  yamt sync with head.
 1.21.4.1 22-Oct-2006  yamt sync with head
 1.21.2.2 12-Jan-2007  ad Sync with head.
 1.21.2.1 18-Nov-2006  ad Sync with head.
 1.24.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.25.16.1 06-Nov-2007  matt sync with HEAD
 1.25.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.25.2.1 23-Oct-2007  ad Sync with head.
 1.26.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.4.3 11-Mar-2010  yamt sync with head
 1.27.4.2 16-May-2009  yamt sync with head
 1.27.4.1 16-May-2008  yamt sync with head.
 1.27.2.1 18-May-2008  yamt sync with head.
 1.28.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.22.3 03-Dec-2017  jdolecek update from HEAD
 1.32.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.32.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.12.1 30-Oct-2012  yamt sync with head
 1.33.2.1 18-May-2014  rmind sync with head
 1.34.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.34.6.1 05-Oct-2016  skrll Sync with HEAD
 1.35.16.1 10-Jun-2019  christos Sync with HEAD
 1.35.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.31 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.30 22-Jul-2011  njoly branches: 1.30.2; 1.30.6;
Fix CHIPSFB_DEBUG build
 1.29 11-May-2011  dyoung Constify pci_attach_args.
 1.28 05-Apr-2011  dyoung Bitwise-OR PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE into
the PCI Command Register instead of PCI_FLAGS_IO_ENABLED |
PCI_FLAGS_MEM_ENABLED. The latter amounts to the same value, but the
names are in the pa_flags namespace instead of the PCI Command Register
bits namespace.
 1.27 23-Mar-2011  macallan complete the driver/bus frontend split and make sure the driver can deal with
both PCI and VLB variants of the chip
 1.26 09-Feb-2011  macallan use the bus independent stuff from ic/ct65550* and leave only the PCI specific
bits in pci/chipsfb.c
 1.25 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.24 23-Dec-2010  cegger branches: 1.24.2; 1.24.4;
build fix: add missing initializers
 1.23 16-Dec-2010  cegger ioctl: KNF switch-case
 1.22 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.21 04-May-2010  macallan use alternate font if available ( for autogenerated box drawing characters )
 1.20 20-Aug-2009  macallan branches: 1.20.2; 1.20.4;
use vcons_replay_msgbuf() when appropriate
 1.19 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.18 06-May-2009  elad Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.17 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.16 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.15 08-May-2008  macallan branches: 1.15.12;
nuke clause 3
 1.14 10-Apr-2008  cegger branches: 1.14.2; 1.14.4; 1.14.6;
use aprint_*_dev and device_xname
 1.13 27-Feb-2008  macallan get rid of the last #ifdef macppc and use PCI_MAGIC_IO_RANGE to select
at which offset we mmap PCI IO space
 1.12 19-Aug-2007  he branches: 1.12.2; 1.12.18; 1.12.22;
Use bool with prop_dictionary_get_bool.
 1.11 02-Aug-2007  macallan branches: 1.11.2; 1.11.4;
don't bus_space_map more IO space than we really need
 1.10 28-Jul-2007  mjf Implement bounds checking in some places in display driver code to avoid
the possibility of a local user panic.
 1.9 04-Mar-2007  christos branches: 1.9.2; 1.9.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.8 22-Jan-2007  macallan branches: 1.8.2;
get rid of OpenFirmware dependencies, use device properties instead
 1.7 20-Jan-2007  he Unify the declaration of OF_interpret() between sparc{,64} and macppc
by adding the "nargs" argument to the macppc version, and fix the macppc
ports uses of OF_interpret() accordingly.

Also move the declaration of OF_interpt() from macppc's autoconf.h to
ofw/openfirm.h. This fixes the build of the macppc port.

Approved by macallan@.
 1.6 10-Nov-2006  macallan branches: 1.6.2; 1.6.6;
remove some leftover #includes
 1.5 27-Oct-2006  macallan fix a typo in chipsfb_bitblt()
 1.4 16-Oct-2006  macallan branches: 1.4.2;
detect video RAM size
 1.3 27-Sep-2006  macallan the chip wants all data we send with 64bit padding, no matter what padding
individual scanlines have so we send an extra 0 when we have to.
 1.2 27-Sep-2006  macallan cleanup, implement putchar() using the blitter
 1.1 23-Sep-2006  macallan a half done wsdisplay driver for Chips & Technologies 65550 graphics chips
So far it only uses the blitter for scrolling and rectangle filling,
characters are still drawn in software and there's no support for video
mode switching. Virtual consoles are supported via vcons.
Works fine on a PowerBook 3400c.
 1.4.2.3 10-Dec-2006  yamt sync with head.
 1.4.2.2 22-Oct-2006  yamt sync with head
 1.4.2.1 16-Oct-2006  yamt file chipsfb.c was added on branch yamt-splraiseipl on 2006-10-22 06:06:16 +0000
 1.6.6.5 17-Mar-2008  yamt sync with head.
 1.6.6.4 03-Sep-2007  yamt sync with head.
 1.6.6.3 26-Feb-2007  yamt sync with head.
 1.6.6.2 30-Dec-2006  yamt sync with head.
 1.6.6.1 10-Nov-2006  yamt file chipsfb.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:43 +0000
 1.6.2.3 01-Feb-2007  ad Sync with head.
 1.6.2.2 18-Nov-2006  ad Sync with head.
 1.6.2.1 10-Nov-2006  ad file chipsfb.c was added on branch newlock2 on 2006-11-18 21:34:29 +0000
 1.8.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.9.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.9.2.1 20-Aug-2007  ad Sync with HEAD.
 1.11.4.2 02-Aug-2007  macallan don't bus_space_map more IO space than we really need
 1.11.4.1 02-Aug-2007  macallan file chipsfb.c was added on branch matt-mips64 on 2007-08-02 06:56:44 +0000
 1.11.2.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.12.22.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.22.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.18.1 24-Mar-2008  keiichi sync with head.
 1.12.2.1 23-Mar-2008  matt sync with HEAD
 1.14.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.4.4 11-Aug-2010  yamt sync with head.
 1.14.4.3 16-Sep-2009  yamt sync with head
 1.14.4.2 16-May-2009  yamt sync with head
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.4.4 31-May-2011  rmind sync with head
 1.20.4.3 21-Apr-2011  rmind sync with head
 1.20.4.2 05-Mar-2011  rmind sync with head
 1.20.4.1 30-May-2010  rmind sync with head
 1.20.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.24.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.24.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.24.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.6.1 18-Feb-2012  mrg merge to -current.
 1.30.2.1 17-Apr-2012  yamt sync with head
 1.4 09-Feb-2011  macallan this is no longer needed, register definitions for chipsfb now live in
dev/ic/ct65550reg.h
 1.3 08-May-2008  macallan branches: 1.3.20; 1.3.26; 1.3.28;
nuke clause 3
 1.2 27-Sep-2006  macallan branches: 1.2.2; 1.2.4; 1.2.8; 1.2.54; 1.2.56; 1.2.58; 1.2.60;
cleanup, implement putchar() using the blitter
 1.1 23-Sep-2006  macallan a half done wsdisplay driver for Chips & Technologies 65550 graphics chips
So far it only uses the blitter for scrolling and rectangle filling,
characters are still drawn in software and there's no support for video
mode switching. Virtual consoles are supported via vcons.
Works fine on a PowerBook 3400c.
 1.2.60.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.2.58.1 16-May-2008  yamt sync with head.
 1.2.56.1 18-May-2008  yamt sync with head.
 1.2.54.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2 30-Dec-2006  yamt sync with head.
 1.2.8.1 27-Sep-2006  yamt file chipsfbreg.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:43 +0000
 1.2.4.2 18-Nov-2006  ad Sync with head.
 1.2.4.1 27-Sep-2006  ad file chipsfbreg.h was added on branch newlock2 on 2006-11-18 21:34:29 +0000
 1.2.2.2 22-Oct-2006  yamt sync with head
 1.2.2.1 27-Sep-2006  yamt file chipsfbreg.h was added on branch yamt-splraiseipl on 2006-10-22 06:06:16 +0000
 1.3.28.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.20.1 05-Mar-2011  rmind sync with head
 1.23 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.22 14-Jul-2020  jdolecek match newer HP Smart Array controllers, list from FreeBSD
 1.21 14-Jul-2020  jdolecek fix __arraycount() parameter
 1.20 14-Jul-2020  jdolecek make ciss_pci_devices[] more compact
 1.19 14-Jul-2020  jdolecek remove CISS_NO_INTERRUPT_HACK, discussed with joerg@ and spz@
 1.18 14-Jul-2020  jdolecek add support for PERFORMANT mode, and allow MSI/MSI-X (only) for adapters which
support it

code adapted from FreeBSD, but with fix for setting the performant bit
and pull count on command submittion as seen in hpsa Linux driver

tested with INTx and MSI-X on HP Smart Array 11

thanks to Andreas Gustafsson for initial testing, and providing
access to test machine
 1.17 05-Jul-2020  jdolecek there is more to MSI/MSI-X support in ciss(4) than just allocating the
right interrupt, it needs some explicit support; disable for now
until the full support is there

PR kern/55461
 1.16 04-Jul-2020  jdolecek switch to pci_intr_alloc() so this uses MSI/MSI-X if device supports it
 1.15 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.14 12-Feb-2018  joerg branches: 1.14.2; 1.14.4;
Add a new option CISS_NO_INTERRUPT_HACK for driving ciss(4) by callouts.
This is intended as workaround for certain Xen issues with dom0 kernels
and will likely want to have a high HZ value as well for decent
performance.
 1.13 14-Jul-2016  msaitoh branches: 1.13.10;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.12 17-Jun-2016  christos catch up with new names.
 1.11 29-Mar-2014  christos branches: 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.10 27-Oct-2012  chs branches: 1.10.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.9 26-Nov-2009  njoly branches: 1.9.12; 1.9.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.8 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.7 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.6 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.5 10-Apr-2008  cegger branches: 1.5.4; 1.5.18;
use aprint_*_dev and device_xname
 1.4 19-Oct-2007  ad branches: 1.4.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.3 16-Nov-2006  christos branches: 1.3.8; 1.3.22; 1.3.24; 1.3.28;
__unused removal on arguments; approved by core.
 1.2 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.1 21-Mar-2006  he branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12; 1.1.18; 1.1.22; 1.1.24; 1.1.26;
Add a driver, ciss(4), for the HP/Compaq drivers using the newer
"Command Interface to SCSI-3 Support" command interface. Driver
ported from OpenBSD by Tonnerre Lombard -- thanks!
 1.1.26.2 10-Dec-2006  yamt sync with head.
 1.1.26.1 22-Oct-2006  yamt sync with head
 1.1.24.2 09-Sep-2006  rpaulo sync with head
 1.1.24.1 21-Mar-2006  rpaulo file ciss_pci.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:16 +0000
 1.1.22.1 18-Nov-2006  ad Sync with head.
 1.1.18.4 27-Oct-2007  yamt sync with head.
 1.1.18.3 30-Dec-2006  yamt sync with head.
 1.1.18.2 21-Jun-2006  yamt sync with head.
 1.1.18.1 21-Mar-2006  yamt file ciss_pci.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:03 +0000
 1.1.12.2 22-Apr-2006  simonb Sync with head.
 1.1.12.1 21-Mar-2006  simonb file ciss_pci.c was added on branch simonb-timecounters on 2006-04-22 11:39:13 +0000
 1.1.10.2 19-Apr-2006  elad sync with head.
 1.1.10.1 21-Mar-2006  elad file ciss_pci.c was added on branch elad-kernelauth on 2006-04-19 03:25:33 +0000
 1.1.8.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.8.1 21-Mar-2006  yamt file ciss_pci.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.6.2 11-Apr-2006  riz Pull up following revision(s) (requested by he in ticket #10409):
sys/dev/ic/cissreg.h: revision 1.1
sys/dev/pci/ciss_pci.c: revision 1.1
sys/dev/ic/cissvar.h: revision 1.1
sys/dev/pci/files.pci: revision 1.245
sys/dev/ic/ciss.c: revision 1.1 via patch
Add a driver, ciss(4), for the HP/Compaq drivers using the newer
"Command Interface to SCSI-3 Support" command interface. Driver
ported from OpenBSD by Tonnerre Lombard -- thanks!
 1.1.6.1 21-Mar-2006  riz file ciss_pci.c was added on branch netbsd-2 on 2006-04-11 01:15:22 +0000
 1.1.4.2 08-Apr-2006  tron Pull up following revision(s) (requested by he in ticket #1247):
sys/dev/ic/cissreg.h: revision 1.1
sys/dev/pci/ciss_pci.c: revision 1.1
sys/dev/ic/cissvar.h: revision 1.1
sys/dev/pci/files.pci: revision 1.245
sys/dev/ic/ciss.c: revision 1.1
Add a driver, ciss(4), for the HP/Compaq drivers using the newer
"Command Interface to SCSI-3 Support" command interface. Driver
ported from OpenBSD by Tonnerre Lombard -- thanks!
 1.1.4.1 21-Mar-2006  tron file ciss_pci.c was added on branch netbsd-3 on 2006-04-08 23:31:38 +0000
 1.1.2.2 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 21-Mar-2006  tron file ciss_pci.c was added on branch peter-altq on 2006-03-28 09:42:13 +0000
 1.3.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.24.1 06-Nov-2007  matt sync with HEAD
 1.3.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.8.1 23-Oct-2007  ad Sync with head.
 1.4.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.4.2 11-Mar-2010  yamt sync with head
 1.5.4.1 16-May-2009  yamt sync with head
 1.9.22.3 03-Dec-2017  jdolecek update from HEAD
 1.9.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.12.1 30-Oct-2012  yamt sync with head
 1.10.2.1 18-May-2014  rmind sync with head
 1.11.6.2 05-Oct-2016  skrll Sync with HEAD
 1.11.6.1 09-Jul-2016  skrll Sync with HEAD
 1.13.10.1 09-Apr-2018  bouyer Pull up following revision(s) (requested by spz in ticket #708):
sys/conf/files: revision 1.1194
sys/dev/ic/cissvar.h: revision 1.7
sys/dev/ic/ciss.c: revision 1.38
sys/dev/pci/ciss_pci.c: revision 1.14
sys/arch/amd64/conf/ALL: revision 1.81
Add a new option CISS_NO_INTERRUPT_HACK for driving ciss(4) by callouts.
This is intended as workaround for certain Xen issues with dom0 kernels
and will likely want to have a high HZ value as well for decent
performance.
 1.14.4.1 10-Jun-2019  christos Sync with HEAD
 1.14.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.47 26-Dec-2021  andvar fix various typos, mainly in comments.
 1.46 17-Jul-2020  jdolecek remove explicit irqack() call for unexpected interrupt; this happens
normally during boot when running identify for the drive as polled
command, and fixes hard hang caused by the irqack() on a sun machine

the unexpected interrupt happens because cmdide doesn't respect
WDCTL_IDS bit and triggers interrupt also for polled commands

also reclassify the "bogus intr" as aprint_verbose() to avoid noise
on boot

discussed and tested by Martin Husemann
 1.45 01-Jul-2020  jdolecek revert, not working
 1.44 01-Jul-2020  jdolecek ignore interrupt when not expecting one, particularly don't invoke
the irqack in this case

seems cmdide doesn't honour WDCTL_IDS when executing polled commands,
and there is a race where the irqack call interferes with polled
command and causes a lockup

reported by Martin Husemann
 1.43 22-Oct-2017  jdolecek branches: 1.43.10;
do not share queue between the non-indepedant channels; instead make
sure only one of the channels is ever active on the same controller

fixes PR kern/52606 by Martin Husemann, thanks for report and testing
 1.42 20-Oct-2017  jdolecek actually 0680 uses different chip map func, which doesn't call the function
handing non-independant channels, so don't set IDE_SHARED_CHANNELS for it
 1.41 20-Oct-2017  jdolecek move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.40 19-Oct-2017  jdolecek replace the chek for the shared channel of cmdide(4) a flag of the
product array, rather than switch inside attach routine

XXX judging from product name, Silicon Image 0680 might be newer than 0649
XXX and hence have actually independant channels, but I don't have the hw
XXX so keeping as-is

no functional change, just to improve visibility in course of fixing
PR kern/52606
 1.39 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.38 03-Sep-2012  kiyohara branches: 1.38.2; 1.38.28;
Fix no wd on cmd680.
Also move setting wdc_maxdrives into cmd*_chip_map().
 1.37 31-Jul-2012  bouyer Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.36 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.35 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.34 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.33 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.32 04-Apr-2011  dyoung branches: 1.32.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.31 06-Nov-2010  jakllsch branches: 1.31.2;
Enable detachment.

Tested on SiI 0680 (native mapped).
 1.30 05-Nov-2010  jakllsch Pave the way for detachment of pciide(4)-family ATA controllers.
 1.29 19-Oct-2009  bouyer branches: 1.29.2; 1.29.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.28 18-Mar-2008  cube branches: 1.28.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.27 09-Feb-2007  ad branches: 1.27.20; 1.27.36; 1.27.40;
Merge newlock2 to head.
 1.26 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.25 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 07-Feb-2006  bouyer branches: 1.23.14; 1.23.16;
Add another missing ch_ndrive initialization.
 1.22 17-Jan-2006  bouyer branches: 1.22.2; 1.22.4;
Add missing ch_ndrive initialisations. Pointed out by Juan RP.
 1.21 11-Dec-2005  christos branches: 1.21.2;
merge ktrace-lwp.
 1.20 21-Sep-2005  christos PR/31364: Douglas Fraser: cmd680 IDE controller not configured properly.
 1.19 24-May-2005  lukem branches: 1.19.2;
add __KERNEL_RCSID
 1.18 27-Feb-2005  perry nuke trailing whitespace
 1.17 21-Aug-2004  thorpej branches: 1.17.4; 1.17.6;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.16 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.15 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.14 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.13 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.12 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.11 02-Aug-2004  bouyer branches: 1.11.2;
If acknowledge "bogus" interrupts (that is, interrupts that have happened
according to the controller-dependant registers while wdc was not waiting for
an interrupt). A reset can generate spurious interrupts (or even a flow of
spurious interrupts on the promise) that needs to be properly acknowledged.
 1.10 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.9 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.8 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.7 13-Dec-2003  thorpej Split out the Silicon Image SATALink support into its own driver,
"satalink".
 1.6 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.5 10-Nov-2003  wiz Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.4 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.3 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.11.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.11.2.2 03-Aug-2004  skrll Sync with HEAD
 1.11.2.1 02-Aug-2004  skrll file cmdide.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.17.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.4.1 29-Apr-2005  kent sync with -current
 1.19.2.4 24-Mar-2008  yamt sync with head.
 1.19.2.3 26-Feb-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.21.2.2 18-Feb-2006  yamt sync with head.
 1.21.2.1 01-Feb-2006  yamt sync with head.
 1.22.4.1 22-Apr-2006  simonb Sync with head.
 1.22.2.1 09-Sep-2006  rpaulo sync with head
 1.23.16.2 10-Dec-2006  yamt sync with head.
 1.23.16.1 22-Oct-2006  yamt sync with head
 1.23.14.3 06-Feb-2007  ad Quiten noisy boot messages.
 1.23.14.2 12-Jan-2007  ad Sync with head.
 1.23.14.1 18-Nov-2006  ad Sync with head.
 1.27.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.27.36.1 24-Mar-2008  keiichi sync with head.
 1.27.20.1 23-Mar-2008  matt sync with HEAD
 1.28.4.1 11-Mar-2010  yamt sync with head
 1.29.4.2 21-Apr-2011  rmind sync with head
 1.29.4.1 05-Mar-2011  rmind sync with head
 1.29.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.31.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.4.1 30-Oct-2012  yamt sync with head
 1.38.28.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.38.2.2 03-Dec-2017  jdolecek update from HEAD
 1.38.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.43.10.1 17-Aug-2020  martin Pull up following revision(s) (requested by jdolecek in ticket #1054):

sys/dev/pci/cmdide.c: revision 1.46

remove explicit irqack() call for unexpected interrupt; this happens
normally during boot when running identify for the drive as polled
command, and fixes hard hang caused by the irqack() on a sun machine
the unexpected interrupt happens because cmdide doesn't respect
WDCTL_IDS bit and triggers interrupt also for polled commands

also reclassify the "bogus intr" as aprint_verbose() to avoid noise
on boot

discussed and tested by Martin Husemann
 1.2 28-Dec-2001  itohy Move this figure to more suitable place:
http://www.netbsd.org/Documentation/Hardware/Chips/C-Media/cmi8738-mixer.fig
 1.1 27-Dec-2001  itohy Analyzed structure of CMI8738/PCI-6ch-* mixer
for the benefit of those who edit the driver.

This is a Fig file. Use Xfig to edit/view, use Transfig
package to convert to other graphic formats.
 1.61 08-Jan-2024  chs mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.60 31-May-2022  andvar branches: 1.60.4;
fix various typos in comments, documentation and messages.
 1.59 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.58 24-Apr-2021  thorpej branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.57 29-Feb-2020  isaki branches: 1.57.8;
Remove rounding by 4 bytes on round_blocksize().
For drivers which supports only 16bit * 2channels sampling,
rounding by 4 bytes no longer meaningful.
 1.56 08-Jun-2019  isaki branches: 1.56.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.55 12-May-2019  maya Remove unused function following isaki-audio2 merge.

Shows up when doing clang builds. From a.rin.
 1.54 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.53 16-Mar-2019  isaki branches: 1.53.2;
White space.
 1.52 16-Mar-2019  isaki Use C99 style struct initializer to audio_hw_if.
 1.51 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.50 01-Jun-2017  chs branches: 1.50.8; 1.50.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.49 15-Aug-2016  maxv Use the exact same argument for kmem_alloc and kmem_free; from brainy
 1.48 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.47 29-Mar-2014  christos branches: 1.47.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.46 27-Oct-2012  chs branches: 1.46.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.45 30-Jan-2012  drochner branches: 1.45.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.44 24-Nov-2011  mrg branches: 1.44.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.43 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.42 26-Nov-2009  njoly branches: 1.42.12; 1.42.14;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.41 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.40 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.39 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.38 10-Apr-2008  cegger branches: 1.38.4; 1.38.16; 1.38.18;
use aprint_*_dev and device_xname
 1.37 01-Apr-2008  xtraeme Fix fallout from device_t/softc split to mpu(4):
always pass the mpu_softc to mpu_intr(). Found by Takeshi Nakayama.
 1.36 19-Oct-2007  ad branches: 1.36.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.35 04-Mar-2007  christos branches: 1.35.2; 1.35.14; 1.35.16; 1.35.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.34 16-Nov-2006  christos branches: 1.34.4; 1.34.6;
__unused removal on arguments; approved by core.
 1.33 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32 29-Aug-2006  christos branches: 1.32.2; 1.32.4;
fix incomplete initializer.
 1.31 11-May-2006  mrg quell GCC 4.1 uninitialised variable warnings.
 1.30 24-Dec-2005  perry branches: 1.30.4; 1.30.6; 1.30.8; 1.30.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.29 11-Dec-2005  christos merge ktrace-lwp.
 1.28 15-Jan-2005  kent branches: 1.28.10;
ansify and KNF
 1.27 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.26 29-Oct-2004  yamt branches: 1.26.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.25 26-Oct-2004  xtraeme Fix typo in a comment: alalog -> analog.
 1.24 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.23 06-Dec-2003  itohy Back out the following commit and apply the real fix.
A variable was actually used in a wrong way.

> revision 1.20
> date: 2003/10/25 21:31:43; author: christos; state: Exp; lines: +3 -3
> Fix uninitialized variable warnings.
 1.22 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.21 22-Nov-2003  itohy - Correctly handle bit 24 of miscellaneous control register, which has
different meanings for read and write.
This fixes 48kHz playback to SPDIF.
- Fix the problem where the SPDIF output voltage setting (0.5V, 5V)
was swapped. The default value is changed from 0.5V to 5V, which
correctly selects 5V (so the default physical behavior is unchanged).

Should fix PRs kern/16047 and kern/16817
(but not tested since I don't have other SPDIF hardware to test with).
Approved by tshiozak.
 1.20 25-Oct-2003  christos Fix uninitialized variable warnings.
 1.19 25-Oct-2003  christos Fix uninitialized variable warnings
 1.18 01-Feb-2003  thorpej branches: 1.18.2;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.17 31-Jan-2003  thorpej Use aprint_*().
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 02-Feb-2002  augustss Fix typo so that 48kHz can be set. From Stephen Ma in kern/15456.
 1.12 27-Dec-2001  itohy Fix comment.
 1.11 13-Nov-2001  lukem add RCSID
 1.10 04-Nov-2001  itohy Re-implement the mixer
o Implement SPDIF selection/monitoring function.
Now, say, playback to both analog output and SPDIF is possible.

o Implement support of AUX input, MIC preamp and MIC recording gain.

o L-R selection of record source doesn't seem to work on cmpci.
Therefore, the *.swap mixer functions are and deleted.

o Following SB mixer registers don't exist on cmpci, and they are removed.
input gain, output gain, AGC, equalization (bass, treble)

o Other mixer changes, including
inputs.XXX.mute -> (deleted)
outputs.XXX.mute -> inputs.XXX.mute
inputs.pc_speaker -> inputs.speaker
spdif.* -> reorganized to spdif.input.*, spdif.output.*

o Current status:
I have tested these and confirmed to work fine.
- Output and recording from Line-in, AUX, CD and MIC analog inputs,
- Output and recording from FM synthesizer,
- Output from PC speaker input,
- Output wave playback.
- SPDIF (44.1kHz) input selection (#1, #2 (6ch version only),
wave to spdin), phase selection, monitoring and recording,
- SPDIF (44.1kHz) playback, through (SPDIF in to SPDIF out)
and monitoring.

I haven't tested these but may work.
- SPDIF 48kHz input and output,
- Full-duplex operation,
- Recording wave output.

I don't think these are working.
- Legacy (wave + FM synthesizer) to SPDIF output (and the monitoring),
- Exchanging front and rear outputs,
- Surround.

These are not implemented.
- 4ch / 6ch support,
- Joystick port support.
 1.9 03-Oct-2001  augustss branches: 1.9.2;
Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.8 04-Sep-2001  itohy branches: 1.8.2;
- Add opl at cmpci attachment.
- Add mpu at cmpci attachment.
- Fix panic during attach on alpha.
- Change register of SPDIF input phase (but undocumented, either).
- Change code for mixer initialization.
- Return 1, not 0, when an interrupt is processed.

More changes to the mixer are pending....
 1.7 12-Feb-2001  tshiozak branches: 1.7.2; 1.7.4;
some improvement for cmpci; SPDIF supports, etc.
 1.6 18-Jan-2001  jdolecek constify
 1.5 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.4 26-Jun-2000  simonb branches: 1.4.2;
Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3 08-Jun-2000  gmcgarry branches: 1.3.2;
Make attach messages consistent with PCI drivers. Make function pointer
usage consistent with other drivers.
 1.2 30-Apr-2000  augustss branches: 1.2.2;
Remove unneeded #include "mpu.h"
 1.1 30-Apr-2000  augustss Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.4.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.4.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.4.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 26-Jun-2000  bouyer file cmpci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.7.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.4.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.7.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.7.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.7.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.7.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.7.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.8.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.9.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.18.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.18.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.26.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.26.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.28.10.4 27-Oct-2007  yamt sync with head.
 1.28.10.3 03-Sep-2007  yamt sync with head.
 1.28.10.2 30-Dec-2006  yamt sync with head.
 1.28.10.1 21-Jun-2006  yamt sync with head.
 1.30.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.8.2 03-Sep-2006  yamt sync with head.
 1.30.8.1 24-May-2006  yamt sync with head.
 1.30.6.1 01-Jun-2006  kardel Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.32.4.2 10-Dec-2006  yamt sync with head.
 1.32.4.1 22-Oct-2006  yamt sync with head
 1.32.2.1 18-Nov-2006  ad Sync with head.
 1.34.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.34.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.35.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.35.16.1 06-Nov-2007  matt sync with HEAD
 1.35.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.35.2.1 23-Oct-2007  ad Sync with head.
 1.36.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.36.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.38.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.38.16.1 11-Dec-2008  ad Checkpoint work in progress.
 1.38.4.2 11-Mar-2010  yamt sync with head
 1.38.4.1 16-May-2009  yamt sync with head
 1.42.14.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.42.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.42.12.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.12.2 30-Oct-2012  yamt sync with head
 1.42.12.1 17-Apr-2012  yamt sync with head
 1.44.2.1 18-Feb-2012  mrg merge to -current.
 1.45.6.3 03-Dec-2017  jdolecek update from HEAD
 1.45.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.45.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.46.2.1 18-May-2014  rmind sync with head
 1.47.6.3 28-Aug-2017  skrll Sync with HEAD
 1.47.6.2 05-Oct-2016  skrll Sync with HEAD
 1.47.6.1 09-Jul-2016  skrll Sync with HEAD
 1.50.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.50.10.1 10-Jun-2019  christos Sync with HEAD
 1.50.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.53.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.53.2.2 28-Apr-2019  isaki Adapt to audio2.
 1.53.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.56.4.1 29-Feb-2020  ad Sync with head.
 1.57.8.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.58.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.60.4.1 14-Jan-2024  martin Pull up following revision(s) (requested by chs in ticket #542):

sys/dev/pci/yds.c: revision 1.69
sys/dev/pci/cmpci.c: revision 1.61
sys/dev/pci/sv.c: revision 1.62
sys/dev/pci/fms.c: revision 1.50

mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 22-Nov-2003  itohy - Correctly handle bit 24 of miscellaneous control register, which has
different meanings for read and write.
This fixes 48kHz playback to SPDIF.
- Fix the problem where the SPDIF output voltage setting (0.5V, 5V)
was swapped. The default value is changed from 0.5V to 5V, which
correctly selects 5V (so the default physical behavior is unchanged).

Should fix PRs kern/16047 and kern/16817
(but not tested since I don't have other SPDIF hardware to test with).
Approved by tshiozak.
 1.4 04-Nov-2001  itohy branches: 1.4.16;
Re-implement the mixer
o Implement SPDIF selection/monitoring function.
Now, say, playback to both analog output and SPDIF is possible.

o Implement support of AUX input, MIC preamp and MIC recording gain.

o L-R selection of record source doesn't seem to work on cmpci.
Therefore, the *.swap mixer functions are and deleted.

o Following SB mixer registers don't exist on cmpci, and they are removed.
input gain, output gain, AGC, equalization (bass, treble)

o Other mixer changes, including
inputs.XXX.mute -> (deleted)
outputs.XXX.mute -> inputs.XXX.mute
inputs.pc_speaker -> inputs.speaker
spdif.* -> reorganized to spdif.input.*, spdif.output.*

o Current status:
I have tested these and confirmed to work fine.
- Output and recording from Line-in, AUX, CD and MIC analog inputs,
- Output and recording from FM synthesizer,
- Output from PC speaker input,
- Output wave playback.
- SPDIF (44.1kHz) input selection (#1, #2 (6ch version only),
wave to spdin), phase selection, monitoring and recording,
- SPDIF (44.1kHz) playback, through (SPDIF in to SPDIF out)
and monitoring.

I haven't tested these but may work.
- SPDIF 48kHz input and output,
- Full-duplex operation,
- Recording wave output.

I don't think these are working.
- Legacy (wave + FM synthesizer) to SPDIF output (and the monitoring),
- Exchanging front and rear outputs,
- Surround.

These are not implemented.
- 4ch / 6ch support,
- Joystick port support.
 1.3 04-Sep-2001  itohy branches: 1.3.4;
- Add opl at cmpci attachment.
- Add mpu at cmpci attachment.
- Fix panic during attach on alpha.
- Change register of SPDIF input phase (but undocumented, either).
- Change code for mixer initialization.
- Return 1, not 0, when an interrupt is processed.

More changes to the mixer are pending....
 1.2 12-Feb-2001  tshiozak branches: 1.2.2; 1.2.4;
some improvement for cmpci; SPDIF supports, etc.
 1.1 30-Apr-2000  augustss branches: 1.1.6;
Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.1.6.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 30-Apr-2000  bouyer file cmpcireg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.2.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.3.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.4.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.16.1 03-Aug-2004  skrll Sync with HEAD
 1.12 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.11 23-Nov-2011  jmcneill branches: 1.11.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.10 04-Mar-2007  christos branches: 1.10.54; 1.10.76; 1.10.78;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 11-Dec-2005  christos branches: 1.9.26; 1.9.28;
merge ktrace-lwp.
 1.8 15-Jan-2005  kent branches: 1.8.10;
ansify and KNF
 1.7 10-Nov-2004  wiz Fix typo in comment; from Sergey Svishchev.
 1.6 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 22-Nov-2003  itohy - Correctly handle bit 24 of miscellaneous control register, which has
different meanings for read and write.
This fixes 48kHz playback to SPDIF.
- Fix the problem where the SPDIF output voltage setting (0.5V, 5V)
was swapped. The default value is changed from 0.5V to 5V, which
correctly selects 5V (so the default physical behavior is unchanged).

Should fix PRs kern/16047 and kern/16817
(but not tested since I don't have other SPDIF hardware to test with).
Approved by tshiozak.
 1.4 04-Nov-2001  itohy branches: 1.4.16;
Re-implement the mixer
o Implement SPDIF selection/monitoring function.
Now, say, playback to both analog output and SPDIF is possible.

o Implement support of AUX input, MIC preamp and MIC recording gain.

o L-R selection of record source doesn't seem to work on cmpci.
Therefore, the *.swap mixer functions are and deleted.

o Following SB mixer registers don't exist on cmpci, and they are removed.
input gain, output gain, AGC, equalization (bass, treble)

o Other mixer changes, including
inputs.XXX.mute -> (deleted)
outputs.XXX.mute -> inputs.XXX.mute
inputs.pc_speaker -> inputs.speaker
spdif.* -> reorganized to spdif.input.*, spdif.output.*

o Current status:
I have tested these and confirmed to work fine.
- Output and recording from Line-in, AUX, CD and MIC analog inputs,
- Output and recording from FM synthesizer,
- Output from PC speaker input,
- Output wave playback.
- SPDIF (44.1kHz) input selection (#1, #2 (6ch version only),
wave to spdin), phase selection, monitoring and recording,
- SPDIF (44.1kHz) playback, through (SPDIF in to SPDIF out)
and monitoring.

I haven't tested these but may work.
- SPDIF 48kHz input and output,
- Full-duplex operation,
- Recording wave output.

I don't think these are working.
- Legacy (wave + FM synthesizer) to SPDIF output (and the monitoring),
- Exchanging front and rear outputs,
- Surround.

These are not implemented.
- 4ch / 6ch support,
- Joystick port support.
 1.3 04-Sep-2001  itohy branches: 1.3.4;
- Add opl at cmpci attachment.
- Add mpu at cmpci attachment.
- Fix panic during attach on alpha.
- Change register of SPDIF input phase (but undocumented, either).
- Change code for mixer initialization.
- Return 1, not 0, when an interrupt is processed.

More changes to the mixer are pending....
 1.2 12-Feb-2001  tshiozak branches: 1.2.2; 1.2.4;
some improvement for cmpci; SPDIF supports, etc.
 1.1 30-Apr-2000  augustss branches: 1.1.6;
Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.1.6.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 30-Apr-2000  bouyer file cmpcivar.h was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.2.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.2.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.3.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.4.16.5 17-Jan-2005  skrll Sync with HEAD.
 1.4.16.4 14-Nov-2004  skrll Sync with HEAD.
 1.4.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.16.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.1 03-Sep-2007  yamt sync with head.
 1.9.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.78.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.10.76.2 30-Oct-2012  yamt sync with head
 1.10.76.1 17-Apr-2012  yamt sync with head
 1.10.54.1 11-Dec-2008  ad Checkpoint work in progress.
 1.11.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.27 25-Mar-2021  rin Introduce sc_poll_ticks and obsolete COM_HW_POLL bit in sc_hwflags.
Polling is scheduled at every sc_poll_ticks ticks.

This is useful to work around H/W bug, by which interrupts are lost
*sometimes*; interrupt-based I/O mostly works and no need for polling
every counter ticks.
 1.26 08-Dec-2018  thorpej branches: 1.26.12; 1.26.14;
Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.25 30-Nov-2018  jmcneill Add support for polling com devices when no interrupt is available.
 1.24 27-Apr-2017  msaitoh branches: 1.24.8; 1.24.10;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.23 23-May-2014  msaitoh branches: 1.23.4; 1.23.18;
Print the type of serial port from the interface field in the PCI class
register.
 1.22 29-Mar-2014  christos branches: 1.22.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.21 31-Jul-2013  soren On x86, print the I/O address of lpt_puc as for com_puc so that hacks
using iopl/ioperm can be told where to find the parallel port.

Closes PR kern/43683.
 1.20 22-Jul-2013  soren Since puc(4) serial ports are typically not identified in the
BIOS COM[1234] table, the I/O address must be manually set using
installboot(8) in order to enable a serial console.
Print the address here so the user doesn't have to dig through
PCI configuration space to find it.

Enable suspend/resume hooks.
 1.19 26-Nov-2009  njoly branches: 1.19.12; 1.19.22; 1.19.26; 1.19.34;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.18 14-Mar-2008  cube branches: 1.18.4;
Split device_t and softc for all com(4) devices (well, everything that
uses a com_softc backend). Use proper types and ansify where appropriate.
 1.17 19-Oct-2007  ad branches: 1.17.12; 1.17.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 16-Nov-2006  christos branches: 1.16.8; 1.16.22; 1.16.24; 1.16.28;
__unused removal on arguments; approved by core.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 13-Jul-2006  gdamore branches: 1.14.4; 1.14.6;
Add an option COM_REGMAP to allow com(4) to use an array of register indices.
This allows us to convert aucom to just another com attachment, and cleanup
some code in the com_arbus.c.

Additionally, we use a common com_cleanup routine rather than having a
zillion copies of it in the attachment points.

This has been tested on a number architectures, and it has been shown to get
close to comparable performance when COM_REGMAP is defined, and comparable
when it is not defined.

Approved by core@. Fixes PR port-evbmips/32362.
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.8; 1.13.16;
merge ktrace-lwp.
 1.12 28-Jun-2005  thorpej branches: 1.12.2;
Use ANSI function decls and static.
 1.11 04-Feb-2005  perry de-__P
 1.10 03-Feb-2004  fredb branches: 1.10.8; 1.10.10;
Fix a warning about possibly uninitialized variable.
 1.9 03-Feb-2004  fredb Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.8 31-Jan-2003  thorpej branches: 1.8.2;
Use aprint_*().
 1.7 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.6 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.3 13-Nov-2001  lukem add RCSID
 1.2 16-Mar-2001  bouyer branches: 1.2.2;
Ops, forgot to commit this file along with the "variable com freq" support.
Thanks to Bill Sommerfeld for pointing this out.
 1.1 26-Jun-1998  cgd branches: 1.1.14; 1.1.24; 1.1.26;
add a driver for "PCI 'universal' communications" cards, that is, PCI cards
which contain 'standard' com- and lpt-type ports. Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not. (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.) Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
 1.1.26.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.26.3 08-Jan-2002  nathanw Catch up to -current.
 1.1.26.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.26.1 09-Apr-2001  nathanw Catch up with -current.
 1.1.24.1 22-Mar-2001  he Pull up revision 1.2 (requested by bouyer):
Allow attaching ``com'' devices at frequency other than the
standard COM_FREQ.
 1.1.14.1 27-Mar-2001  bouyer Sync with HEAD.
 1.2.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.10.1 12-Feb-2005  yamt sync with head.
 1.10.8.1 29-Apr-2005  kent sync with -current
 1.12.2.3 17-Mar-2008  yamt sync with head.
 1.12.2.2 27-Oct-2007  yamt sync with head.
 1.12.2.1 30-Dec-2006  yamt sync with head.
 1.13.16.3 17-Jun-2006  gdamore Undo the undo. Restore COM_INIT_REGS.
 1.13.16.2 17-Jun-2006  gdamore Revert COM_INIT_REGS.
 1.13.16.1 15-Jun-2006  gdamore Adapt to new com framework.
 1.13.8.1 11-Aug-2006  yamt sync with head
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.6.2 10-Dec-2006  yamt sync with head.
 1.14.6.1 22-Oct-2006  yamt sync with head
 1.14.4.1 18-Nov-2006  ad Sync with head.
 1.16.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.24.2 23-Mar-2008  matt sync with HEAD
 1.16.24.1 06-Nov-2007  matt sync with HEAD
 1.16.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.8.1 23-Oct-2007  ad Sync with head.
 1.17.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.12.1 24-Mar-2008  keiichi sync with head.
 1.18.4.1 11-Mar-2010  yamt sync with head
 1.19.34.1 23-Jul-2013  riastradh sync with HEAD
 1.19.26.2 18-May-2014  rmind sync with head
 1.19.26.1 28-Aug-2013  rmind sync with head
 1.19.22.2 03-Dec-2017  jdolecek update from HEAD
 1.19.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.22.2.1 10-Aug-2014  tls Rebase.
 1.23.18.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.23.4.1 28-Aug-2017  skrll Sync with HEAD
 1.24.10.1 10-Jun-2019  christos Sync with HEAD
 1.24.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.26.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.26.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.21 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.20 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.19 24-Apr-2021  thorpej branches: 1.19.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.18 23-Dec-2019  thorpej branches: 1.18.10;
No need to use I2C_F_POLL here.
 1.17 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.16 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.15 06-Jun-2018  maya branches: 1.15.2;
Remove duplicate ;
 1.14 01-Jun-2017  chs branches: 1.14.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.13 29-Mar-2014  christos branches: 1.13.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.12 16-Oct-2013  christos remove unused variables.
 1.11 29-Oct-2012  chs branches: 1.11.2;
remove an unnecessary cast.
use the standard name for the third arg to attach.
adjust some whitespace.
 1.10 30-Jan-2012  drochner branches: 1.10.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.9 29-Aug-2011  jmcneill branches: 1.9.2; 1.9.6;
have pci register itself as a module, and make PCI driver modules depend on it
 1.8 09-Aug-2011  jmcneill modify the dtv device api so hardware drivers can be loaded independently
of the dtv module
 1.7 06-Aug-2011  jmcneill build fix: forgot to add sc_board to softc
 1.6 06-Aug-2011  jmcneill print devname not subdevname on attach, and report the board name to dtv
subsystem instead of generic CX23885
 1.5 06-Aug-2011  jmcneill don't attach iic@coram unless CORAM_ATTACH_I2C is defined
 1.4 05-Aug-2011  jmcneill hide debug messages under CORAM_DEBUG
 1.3 05-Aug-2011  jmcneill return status from demod instead of 0, and don't ignore errors when setting
demod parameters
 1.2 04-Aug-2011  jmcneill modularize coram and add detach + childdet methods
 1.1 04-Aug-2011  jakllsch Add coram(4).

A driver for CX23885-based TV cards, such as the
Hauppauge WinTV HVR-1250 "Coram" board.

Currently only supports ATSC 8VSB reception.
 1.9.6.1 18-Feb-2012  mrg merge to -current.
 1.9.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.2.2 30-Oct-2012  yamt sync with head
 1.9.2.1 17-Apr-2012  yamt sync with head
 1.10.6.3 03-Dec-2017  jdolecek update from HEAD
 1.10.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.2.1 18-May-2014  rmind sync with head
 1.13.6.1 28-Aug-2017  skrll Sync with HEAD
 1.14.8.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.14.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.15.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.2.1 10-Jun-2019  christos Sync with HEAD
 1.18.10.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.19.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 09-Aug-2011  jmcneill modify the dtv device api so hardware drivers can be loaded independently
of the dtv module
 1.3 06-Aug-2011  jmcneill build fix: forgot to add sc_board to softc
 1.2 04-Aug-2011  jmcneill modularize coram and add detach + childdet methods
 1.1 04-Aug-2011  jakllsch Add coram(4).

A driver for CX23885-based TV cards, such as the
Hauppauge WinTV HVR-1250 "Coram" board.

Currently only supports ATSC 8VSB reception.
 1.77 08-Feb-2024  andvar fix misplaced or missing "e" in words with "ment" ending (argument, implement,
increment, decrement, alignment), in comments, documentation, log messages.
 1.76 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.75 24-Dec-2022  andvar s/reqest/request/, s/requst/request/ and s/reuqest/request/ in comments.
 1.74 09-Aug-2021  andvar s/fist/first/
 1.73 03-Feb-2021  isaki Remove code no longer used.
The code that used sc->{halt_input,halt_output} function pointer
was removed in 2004. (see cs428x.c rev 1.7)
 1.72 08-May-2019  isaki branches: 1.72.10;
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.71 16-Mar-2019  isaki branches: 1.71.2;
Use C99 style struct initializer to audio_hw_if.
 1.70 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.69 07-Jul-2016  msaitoh branches: 1.69.16; 1.69.18;
KNF. Remove extra spaces. No functional change.
 1.68 21-Sep-2014  christos branches: 1.68.2;
remove more old pci_findvendor code
 1.67 21-Sep-2014  christos Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.66 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.65 27-Oct-2012  chs branches: 1.65.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.64 30-Jan-2012  drochner branches: 1.64.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.63 24-Nov-2011  mrg branches: 1.63.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.62 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.61 04-Apr-2011  dyoung branches: 1.61.4; 1.61.6;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.60 25-May-2010  pgoyette branches: 1.60.2;
Revert earlier changes to callers of pci_find{vendor,product} since
the original routine entrypoint name has been restored.

Requested by dyoung@ and mrg@
 1.59 24-May-2010  pgoyette Update all callers of the pci_find{vendor,product} routines to now call
these routines through their global pointers.
 1.58 22-May-2010  pgoyette When PCIVERBOSE is not included, pci_findvendor() and pci_findproduct()
can return NULL. Defend against this and print the values in hex if we
can't decode them properly.
 1.57 24-Feb-2010  dyoung branches: 1.57.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.56 08-Jan-2010  dyoung branches: 1.56.2;
Expand PMF_FN_* macros.
 1.55 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.54 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.53 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.52 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.51 21-Mar-2008  dyoung branches: 1.51.4; 1.51.16; 1.51.18;
Use aprint_*_dev() instead of accessing struct device member dv_xname
directly.
 1.50 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.49 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.48 09-Dec-2007  jmcneill branches: 1.48.6; 1.48.10;
Merge jmcneill-pm branch.
 1.47 19-Oct-2007  ad branches: 1.47.4; 1.47.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.46 15-Jun-2007  joerg branches: 1.46.6; 1.46.8; 1.46.12;
Fix ACPI suspend/resume support of clcs and clct. Based on auich and
hints from jmcneill@.
 1.45 16-Nov-2006  christos branches: 1.45.2; 1.45.6; 1.45.8; 1.45.10; 1.45.16;
__unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.42 29-Aug-2006  christos branches: 1.42.2; 1.42.4;
fix incomplete initializer
 1.41 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.40 06-Aug-2006  jmcneill PR/12843: Workaround for CS4280 on IBM ThinkPads. From Stephane Witzmann.

Note: This workaround conflicts with piixpm(4); you will need to disable
the piixpm driver if you need this fix.
 1.39 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.38 15-Apr-2006  jmcneill branches: 1.38.2; 1.38.4;
Add support for the Turtle Beach Santa Cruz. Special thanks to Stephane
Witzmann for spending so much time debugging this.

Fixes: kern/18880, kern/24488, port-i386/14260, kern/12603, kern/12723,
kern/24957, kern/23584

Tested on i386 (Stephane Witzmann), alpha (me).
 1.37 29-Jan-2006  dsl branches: 1.37.2; 1.37.4; 1.37.6; 1.37.8; 1.37.10;
Make almost everything #include <sys/bswap.h> instead of <machine/bswap.h>
The bswap.h and endian.h files are all rather incestuous, but I want to
get the constant folding stuff into one place - sys/bswap.h
 1.36 11-Dec-2005  christos branches: 1.36.2;
merge ktrace-lwp.
 1.35 28-Jun-2005  thorpej branches: 1.35.2;
Use ANSI function decls and static.
 1.34 15-Jan-2005  kent ansify and KNF
 1.33 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.32 09-Nov-2004  kent branches: 1.32.2;
remove mixer setting code in *_attach() because ac97_attach() does it.
 1.31 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.30 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.29 05-Aug-2004  drochner simplify some pointer arithmetics which uses typecasts on the LHS
so that gcc-3.4 doesn't complain
 1.28 09-Jul-2004  mycroft Attempt to make these safer against stray interrupts.
 1.27 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.26 03-May-2003  wiz branches: 1.26.2; 1.26.4;
DMA, not dma nor Dma.
 1.25 31-Jan-2003  thorpej Use aprint_*().
 1.24 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.23 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.22 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.21 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20 31-May-2002  augustss Some casts in printf().
 1.19 15-Nov-2001  lukem branches: 1.19.8;
don't need <sys/types.h> when including <sys/param.h>
 1.18 13-Nov-2001  lukem add RCSID
 1.17 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.16 18-Apr-2001  tacha branches: 1.16.2; 1.16.4;
rewrite suspend/resume routine. If you suspend while playing audio,
clcs and clct continue playing when resume.
 1.15 13-Feb-2001  tacha branches: 1.15.2;
Check and set PCI power management register. clcs now works when
warm boot from Windows.
 1.14 07-Feb-2001  tacha Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.13 27-Jan-2001  augustss Sleep a little when closing the midi device to allow the UART to drain.
 1.12 18-Jan-2001  jdolecek constify
 1.11 15-Jan-2001  perry powerhook fixes, from thorpej, tested by me. Thinkpad T20 sound now perfect.
 1.10 15-Jan-2001  perry Fixes from OpenBSD via chopps. Audio now works on my Thinkpad T20
provided I don't suspend the thing...
 1.9 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.8 26-Nov-2000  takemura Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().
 1.7 20-Sep-2000  augustss branches: 1.7.2;
Apply a patch from the driver author (originally from OpenBSD).
 1.6 19-Jul-2000  augustss Add MIDI support. From Tatoku Ogaito.
 1.5 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.4 15-May-2000  thorpej branches: 1.4.4;
Use <dev/ic/ac97reg.h>
 1.3 15-May-2000  thorpej ac97.h -> ac97var.h
 1.2 14-Jan-2000  augustss Apply patches from Tatoku Ogaito (the author of the code).
 1.1 13-Dec-1999  augustss branches: 1.1.2;
Add a device driver for the Cirrus Logic CS4280 sound chip.
The code has been contributed by Tatoku Ogaito.
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.4.8 06-May-2001  he Pull up revisions 1.7-1.8, 1.10-1.14, 1.16 (via patch, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.4.4.7 13-Mar-2001  he Apply patch (requested by tacha):
Correct checking of AC97 Input Slot Valid register bits.
 1.4.4.6 26-Feb-2001  he Pull up revision 1.15 (requested by tacha):
Fix problem when warm booting from Windows.
 1.4.4.5 26-Feb-2001  he Back out previous two pullups, they have "issues".
I must be getting rusty...
 1.4.4.4 26-Feb-2001  he Apply patch (requested by he):
Typo correction.
 1.4.4.3 26-Feb-2001  he Pull up revisions 1.7,1.10-1.11 (via patch, requested by perry):
Fixes so that this audio driver should work (hardware as in e.g.
IBM ThinkPad T20).
 1.4.4.2 19-Jul-2000  augustss Pull up 1.5-1.6 change: Add MIDI support.
Approved by thorpej.
 1.4.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.7.2.8 21-Apr-2001  bouyer Sync with HEAD
 1.7.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.7.2.6 11-Feb-2001  bouyer Sync with HEAD.
 1.7.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.7.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.7.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 20-Sep-2000  bouyer file cs4280.c was added on branch thorpej_scsipi on 2000-11-20 11:42:15 +0000
 1.15.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.15.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.15.2.5 20-Jun-2002  nathanw Catch up to -current.
 1.15.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.15.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.16.4.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.16.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.16.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.16.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.8.1 20-Jun-2002  gehenna catch up with -current.
 1.26.4.1 22-Sep-2004  jmc Pullup rev 1.30 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.26.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.8 17-Jan-2005  skrll Sync with HEAD.
 1.26.2.7 14-Nov-2004  skrll Sync with HEAD.
 1.26.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.26.2.5 24-Sep-2004  skrll Sync with HEAD.
 1.26.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.26.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.26.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.2.3 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.32.2.2 03-Jan-2005  kent * remove stream_filter_list_append and stream_filter_list_prepend
* add stream_filter_list_t::{append(), prepend(), set()}
 1.32.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.35.2.7 24-Mar-2008  yamt sync with head.
 1.35.2.6 17-Mar-2008  yamt sync with head.
 1.35.2.5 21-Jan-2008  yamt sync with head
 1.35.2.4 27-Oct-2007  yamt sync with head.
 1.35.2.3 03-Sep-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.36.2.1 01-Feb-2006  yamt sync with head.
 1.37.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.8.1 19-Apr-2006  elad sync with head.
 1.37.6.4 03-Sep-2006  yamt sync with head.
 1.37.6.3 11-Aug-2006  yamt sync with head
 1.37.6.2 26-Jun-2006  yamt sync with head.
 1.37.6.1 24-May-2006  yamt sync with head.
 1.37.4.1 22-Apr-2006  simonb Sync with head.
 1.37.2.1 09-Sep-2006  rpaulo sync with head
 1.38.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.38.2.1 19-Jun-2006  chap Sync with head.
 1.42.4.2 10-Dec-2006  yamt sync with head.
 1.42.4.1 22-Oct-2006  yamt sync with head
 1.42.2.1 18-Nov-2006  ad Sync with head.
 1.45.16.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.45.10.1 11-Jul-2007  mjf Sync with head.
 1.45.8.2 23-Oct-2007  ad Sync with head.
 1.45.8.1 15-Jul-2007  ad Sync with head.
 1.45.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.45.2.1 18-Jun-2007  liamjfoy Pull up following revision(s) (requested by joerg in ticket #733):
sys/dev/pci/cs4280.c: revision 1.46
sys/dev/pci/cs4281.c: revision 1.34
sys/dev/pci/cs428x.h: revision 1.13
Fix ACPI suspend/resume support of clcs and clct. Based on auich and
hints from jmcneill@.
 1.46.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.46.8.3 23-Mar-2008  matt sync with HEAD
 1.46.8.2 09-Jan-2008  matt sync with HEAD
 1.46.8.1 06-Nov-2007  matt sync with HEAD
 1.46.6.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.46.6.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.46.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.6.1 04-Oct-2007  joerg Convert clcs(4) and clct(4) to PNP power management. This should also
allow more then one instance of each to resume correctly.
 1.47.6.1 11-Dec-2007  yamt sync with head.
 1.47.4.1 26-Dec-2007  ad Sync with head.
 1.48.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.48.6.1 24-Mar-2008  keiichi sync with head.
 1.51.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.51.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.51.16.1 11-Dec-2008  ad Checkpoint work in progress.
 1.51.4.3 11-Aug-2010  yamt sync with head.
 1.51.4.2 11-Mar-2010  yamt sync with head
 1.51.4.1 16-May-2009  yamt sync with head
 1.56.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.56.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.57.2.2 21-Apr-2011  rmind sync with head
 1.57.2.1 30-May-2010  rmind sync with head
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.61.6.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.61.6.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.61.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.61.4.2 30-Oct-2012  yamt sync with head
 1.61.4.1 17-Apr-2012  yamt sync with head
 1.63.2.1 18-Feb-2012  mrg merge to -current.
 1.64.6.3 03-Dec-2017  jdolecek update from HEAD
 1.64.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.64.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.65.2.1 18-May-2014  rmind sync with head
 1.68.2.1 09-Jul-2016  skrll Sync with HEAD
 1.69.18.1 10-Jun-2019  christos Sync with HEAD
 1.69.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.71.2.3 05-May-2019  isaki Remove encoding conversions on recording.
These are handled in the upper layer now.
 1.71.2.2 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.71.2.1 21-Apr-2019  isaki Adapt cs428x families to audio2.
- recording on cs4280 seems to have its own conversion.
I will see it later but first make it compilable.
 1.72.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 28-Jun-2005  thorpej Use ANSI function decls and static.
 1.2 18-Jan-2001  jdolecek branches: 1.2.24;
constify
 1.1 13-Dec-1999  augustss branches: 1.1.2; 1.1.8;
Add a device driver for the Cirrus Logic CS4280 sound chip.
The code has been contributed by Tatoku Ogaito.
 1.1.8.3 11-Feb-2001  bouyer Sync with HEAD.
 1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.8.1 13-Dec-1999  bouyer file cs4280_image.h was added on branch thorpej_scsipi on 2000-11-20 11:42:16 +0000
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.24.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9 08-Feb-2024  andvar fix misplaced or missing "e" in words with "ment" ending (argument, implement,
increment, decrement, alignment), in comments, documentation, log messages.
 1.8 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.7 15-Apr-2006  jmcneill branches: 1.7.152; 1.7.156;
Add support for the Turtle Beach Santa Cruz. Special thanks to Stephane
Witzmann for spending so much time debugging this.

Fixes: kern/18880, kern/24488, port-i386/14260, kern/12603, kern/12723,
kern/24957, kern/23584

Tested on i386 (Stephane Witzmann), alpha (me).
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8; 1.6.10; 1.6.12;
merge ktrace-lwp.
 1.5 15-Jan-2005  kent branches: 1.5.10;
ansify and KNF
 1.4 07-Feb-2001  tacha branches: 1.4.24;
Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.3 15-May-2000  thorpej branches: 1.3.6;
Use <dev/ic/ac97reg.h>
 1.2 14-Jan-2000  augustss Apply patches from Tatoku Ogaito (the author of the code).
 1.1 13-Dec-1999  augustss branches: 1.1.2;
Add a device driver for the Cirrus Logic CS4280 sound chip.
The code has been contributed by Tatoku Ogaito.
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.6.3 11-Feb-2001  bouyer Sync with HEAD.
 1.3.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 15-May-2000  bouyer file cs4280reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:16 +0000
 1.4.24.1 17-Jan-2005  skrll Sync with HEAD.
 1.5.10.1 21-Jun-2006  yamt sync with head.
 1.6.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.10.1 19-Apr-2006  elad sync with head.
 1.6.8.1 24-May-2006  yamt sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.156.1 05-May-2019  isaki Remove encoding conversions on recording.
These are handled in the upper layer now.
 1.7.152.1 10-Jun-2019  christos Sync with HEAD
 1.61 07-Jan-2025  andvar Fix typos in the word 'Control' in comments.
 1.60 14-Sep-2024  andvar s/intterupt/interrupt/ in comments.
 1.59 20-Dec-2023  thorpej branches: 1.59.2;
Remove unnecessary <sys/malloc.h>.
 1.58 29-Mar-2022  riastradh cs4281(4): Fix lock ordering in suspend.

No idea if this code works -- obviously this path has never been
tested in the >decade it's been here!
 1.57 03-Feb-2021  isaki Remove code no longer used.
The code that used sc->{halt_input,halt_output} function pointer
was removed in 2004. (see cs428x.c rev 1.7)
 1.56 08-May-2020  simonb branches: 1.56.2;
Whitespace nit.
 1.55 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.54 16-Mar-2019  isaki branches: 1.54.2;
Use C99 style struct initializer to audio_hw_if.
 1.53 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.52 07-Jul-2016  msaitoh branches: 1.52.16; 1.52.18;
KNF. Remove extra spaces. No functional change.
 1.51 29-Mar-2014  christos branches: 1.51.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.50 16-Oct-2013  christos use __USE()
 1.49 16-Oct-2013  christos use variables that are only used in debugging.
 1.48 27-Oct-2012  chs branches: 1.48.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.47 30-Jan-2012  drochner branches: 1.47.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.46 24-Nov-2011  mrg branches: 1.46.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.45 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.44 24-Feb-2010  dyoung branches: 1.44.10; 1.44.12;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.43 08-Jan-2010  dyoung branches: 1.43.2;
Expand PMF_FN_* macros.
 1.42 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.41 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.40 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.39 21-Mar-2008  dyoung branches: 1.39.4; 1.39.16; 1.39.18;
Use aprint_*_dev() instead of accessing struct device member dv_xname
directly.
 1.38 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.37 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.36 09-Dec-2007  jmcneill branches: 1.36.6; 1.36.10;
Merge jmcneill-pm branch.
 1.35 19-Oct-2007  ad branches: 1.35.4; 1.35.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.34 15-Jun-2007  joerg branches: 1.34.6; 1.34.8; 1.34.12;
Fix ACPI suspend/resume support of clcs and clct. Based on auich and
hints from jmcneill@.
 1.33 16-Nov-2006  christos branches: 1.33.2; 1.33.6; 1.33.8; 1.33.10; 1.33.16;
__unused removal on arguments; approved by core.
 1.32 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.31 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.30 29-Aug-2006  christos branches: 1.30.2; 1.30.4;
fix incomplete initializer
 1.29 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.28 15-Apr-2006  jmcneill branches: 1.28.2; 1.28.4;
Add support for the Turtle Beach Santa Cruz. Special thanks to Stephane
Witzmann for spending so much time debugging this.

Fixes: kern/18880, kern/24488, port-i386/14260, kern/12603, kern/12723,
kern/24957, kern/23584

Tested on i386 (Stephane Witzmann), alpha (me).
 1.27 11-Dec-2005  christos branches: 1.27.4; 1.27.6; 1.27.8; 1.27.10; 1.27.12;
merge ktrace-lwp.
 1.26 28-Jun-2005  thorpej branches: 1.26.2;
Use ANSI function decls and static.
 1.25 06-Jun-2005  yamt cs4281_set_params: fix printf format.
 1.24 27-Feb-2005  perry nuke trailing whitespace
 1.23 15-Jan-2005  kent branches: 1.23.2; 1.23.4;
ansify and KNF
 1.22 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.21 02-Nov-2004  yamt branches: 1.21.2;
make recording of clct(4) work. namely,
- cs4281_intr: advance a pointer after copying data.
- cs4281_trigger_input: fix an inverted condition about dma mode.
 1.20 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.19 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.18 09-Jul-2004  mycroft Attempt to make these safer against stray interrupts.
 1.17 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.16 03-May-2003  wiz branches: 1.16.2; 1.16.4;
DMA, not dma nor Dma.
 1.15 31-Jan-2003  thorpej Use aprint_*().
 1.14 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 15-May-2002  simonb Print some error messages when the codec fails to initialise (some errors
were already reported, others weren't).
Sprinkle some KNF around.
 1.9 13-Dec-2001  tacha remove bogus printf.
 1.8 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.7 13-Nov-2001  lukem add RCSID
 1.6 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.5 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.4 18-Apr-2001  tacha branches: 1.4.2; 1.4.4; 1.4.6;
rewrite suspend/resume routine. If you suspend while playing audio,
clcs and clct continue playing when resume.
 1.3 07-Feb-2001  tacha branches: 1.3.2; 1.3.4;
Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.2 22-Jan-2001  augustss Clean up a little.
 1.1 22-Jan-2001  augustss Add clct driver for Cirrus Logic CrystalClear PCI Audio CS4281.
Driver written by Tatoku Ogaito.
 1.3.4.8 29-Dec-2002  thorpej Sync with HEAD.
 1.3.4.7 18-Oct-2002  nathanw Catch up to -current.
 1.3.4.6 20-Jun-2002  nathanw Catch up to -current.
 1.3.4.5 08-Jan-2002  nathanw Catch up to -current.
 1.3.4.4 14-Nov-2001  nathanw Catch up to -current.
 1.3.4.3 08-Oct-2001  nathanw Catch up to -current.
 1.3.4.2 21-Sep-2001  nathanw Catch up to -current.
 1.3.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.1 07-Feb-2001  bouyer file cs4281.c was added on branch thorpej_scsipi on 2001-02-11 19:15:50 +0000
 1.4.6.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.4.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.4 27-Dec-2001  he Pull up revision 1.9 (requested by tacha):
Remove spurious warning which is no longer valid.
 1.4.2.3 29-Jul-2001  he Apply patch (requested by minoura):
Correct argument to pci_intr_map(). Fixes PR#13508.
 1.4.2.2 06-May-2001  he Pull up revisions 1.1-1.4 (new, via patch, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.4.2.1 18-Apr-2001  he file cs4281.c was added on branch netbsd-1-5 on 2001-05-06 15:12:08 +0000
 1.16.4.1 22-Sep-2004  jmc branches: 1.16.4.1.2;
Pullup rev 1.19 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.16.4.1.2.1 30-Jan-2005  he Pull up revision 1.21 (requested by yamt in ticket #967):
Make recording of clct(4) work, namely:
o cs_4281_intr: advance a pointer after copying data
o cs_4281_trigger_input: fix an inverted condition about
dma mode
 1.16.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.16.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.16.2.6 14-Nov-2004  skrll Sync with HEAD.
 1.16.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.16.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.2.3 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.21.2.2 03-Jan-2005  kent * remove stream_filter_list_append and stream_filter_list_prepend
* add stream_filter_list_t::{append(), prepend(), set()}
 1.21.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.23.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.2.1 29-Apr-2005  kent sync with -current
 1.26.2.7 24-Mar-2008  yamt sync with head.
 1.26.2.6 17-Mar-2008  yamt sync with head.
 1.26.2.5 21-Jan-2008  yamt sync with head
 1.26.2.4 27-Oct-2007  yamt sync with head.
 1.26.2.3 03-Sep-2007  yamt sync with head.
 1.26.2.2 30-Dec-2006  yamt sync with head.
 1.26.2.1 21-Jun-2006  yamt sync with head.
 1.27.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.27.10.1 19-Apr-2006  elad sync with head.
 1.27.8.3 03-Sep-2006  yamt sync with head.
 1.27.8.2 26-Jun-2006  yamt sync with head.
 1.27.8.1 24-May-2006  yamt sync with head.
 1.27.6.1 22-Apr-2006  simonb Sync with head.
 1.27.4.1 09-Sep-2006  rpaulo sync with head
 1.28.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.28.2.1 19-Jun-2006  chap Sync with head.
 1.30.4.2 10-Dec-2006  yamt sync with head.
 1.30.4.1 22-Oct-2006  yamt sync with head
 1.30.2.1 18-Nov-2006  ad Sync with head.
 1.33.16.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.33.10.1 11-Jul-2007  mjf Sync with head.
 1.33.8.2 23-Oct-2007  ad Sync with head.
 1.33.8.1 15-Jul-2007  ad Sync with head.
 1.33.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.33.2.1 18-Jun-2007  liamjfoy Pull up following revision(s) (requested by joerg in ticket #733):
sys/dev/pci/cs4280.c: revision 1.46
sys/dev/pci/cs4281.c: revision 1.34
sys/dev/pci/cs428x.h: revision 1.13
Fix ACPI suspend/resume support of clcs and clct. Based on auich and
hints from jmcneill@.
 1.34.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.34.8.3 23-Mar-2008  matt sync with HEAD
 1.34.8.2 09-Jan-2008  matt sync with HEAD
 1.34.8.1 06-Nov-2007  matt sync with HEAD
 1.34.6.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.34.6.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.34.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.34.6.1 04-Oct-2007  joerg Convert clcs(4) and clct(4) to PNP power management. This should also
allow more then one instance of each to resume correctly.
 1.35.6.1 11-Dec-2007  yamt sync with head.
 1.35.4.1 26-Dec-2007  ad Sync with head.
 1.36.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.36.6.1 24-Mar-2008  keiichi sync with head.
 1.39.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.16.1 12-Dec-2008  ad Checkpoint work in progress.
 1.39.4.2 11-Mar-2010  yamt sync with head
 1.39.4.1 16-May-2009  yamt sync with head
 1.43.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.44.12.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.44.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.44.10.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.44.10.2 30-Oct-2012  yamt sync with head
 1.44.10.1 17-Apr-2012  yamt sync with head
 1.46.2.1 18-Feb-2012  mrg merge to -current.
 1.47.6.3 03-Dec-2017  jdolecek update from HEAD
 1.47.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.47.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.48.2.1 18-May-2014  rmind sync with head
 1.51.6.1 09-Jul-2016  skrll Sync with HEAD
 1.52.18.1 10-Jun-2019  christos Sync with HEAD
 1.52.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.54.2.2 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.54.2.1 21-Apr-2019  isaki Adapt cs428x families to audio2.
- recording on cs4280 seems to have its own conversion.
I will see it later but first make it compilable.
 1.56.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.59.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 15-Jan-2005  kent branches: 1.4.2; 1.4.4;
ansify and KNF
 1.3 07-Feb-2001  tacha branches: 1.3.2; 1.3.6; 1.3.28;
Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.2 22-Jan-2001  augustss Clean up a little.
 1.1 22-Jan-2001  augustss Add clct driver for Cirrus Logic CrystalClear PCI Audio CS4281.
Driver written by Tatoku Ogaito.
 1.3.28.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.28.1 17-Jan-2005  skrll Sync with HEAD.
 1.3.6.2 06-May-2001  he Pull up revisions 1.1-1.3 (new, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.3.6.1 07-Feb-2001  he file cs4281reg.h was added on branch netbsd-1-5 on 2001-05-06 15:12:25 +0000
 1.3.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.1 07-Feb-2001  bouyer file cs4281reg.h was added on branch thorpej_scsipi on 2001-02-11 19:15:50 +0000
 1.4.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.20 08-Jun-2019  isaki Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.19 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.18 01-Jun-2017  chs branches: 1.18.10; 1.18.14;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.17 27-Oct-2012  chs branches: 1.17.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.16 23-Nov-2011  jmcneill branches: 1.16.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.15 10-Apr-2008  cegger branches: 1.15.16; 1.15.38; 1.15.40;
use aprint_*_dev and device_xname
 1.14 19-Oct-2007  ad branches: 1.14.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 16-Nov-2006  christos branches: 1.13.6; 1.13.8; 1.13.22; 1.13.24; 1.13.28;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 15-Apr-2006  jmcneill branches: 1.11.8; 1.11.10;
Add support for the Turtle Beach Santa Cruz. Special thanks to Stephane
Witzmann for spending so much time debugging this.

Fixes: kern/18880, kern/24488, port-i386/14260, kern/12603, kern/12723,
kern/24957, kern/23584

Tested on i386 (Stephane Witzmann), alpha (me).
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.6; 1.10.8; 1.10.10; 1.10.12;
merge ktrace-lwp.
 1.9 15-Jan-2005  kent branches: 1.9.10;
ansify and KNF
 1.8 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.7 09-Jul-2004  mycroft branches: 1.7.2;
There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.6 03-May-2003  wiz branches: 1.6.2;
DMA, not dma nor Dma.
 1.5 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.4 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.3 13-Nov-2001  lukem add RCSID
 1.2 18-Apr-2001  tacha branches: 1.2.2; 1.2.4;
rewrite suspend/resume routine. If you suspend while playing audio,
clcs and clct continue playing when resume.
 1.1 07-Feb-2001  tacha branches: 1.1.2; 1.1.4;
Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.1.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 07-Feb-2001  bouyer file cs428x.c was added on branch thorpej_scsipi on 2001-02-11 19:15:52 +0000
 1.2.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.2 06-May-2001  he Pull up revisions 1.1-1.2 (new, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.2.2.1 18-Apr-2001  he file cs428x.c was added on branch netbsd-1-5 on 2001-05-06 15:11:14 +0000
 1.6.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.9.10.3 27-Oct-2007  yamt sync with head.
 1.9.10.2 30-Dec-2006  yamt sync with head.
 1.9.10.1 21-Jun-2006  yamt sync with head.
 1.10.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.10.10.1 19-Apr-2006  elad sync with head.
 1.10.8.1 24-May-2006  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.10.2 10-Dec-2006  yamt sync with head.
 1.11.10.1 22-Oct-2006  yamt sync with head
 1.11.8.1 18-Nov-2006  ad Sync with head.
 1.13.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.24.1 06-Nov-2007  matt sync with HEAD
 1.13.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.13.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.14.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.40.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.15.38.2 30-Oct-2012  yamt sync with head
 1.15.38.1 17-Apr-2012  yamt sync with head
 1.15.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.15.16.1 11-Dec-2008  ad Checkpoint work in progress.
 1.16.8.2 03-Dec-2017  jdolecek update from HEAD
 1.16.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.14.1 28-Aug-2017  skrll Sync with HEAD
 1.18.14.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.18.14.2 03-May-2019  isaki Remove dev/auconv.[ch].
Now it is handled in dev/audio/audio.c and dev/audio/linear.c.
Remove dev/mulaw.h.
It already have been just a link to dev/audio/mulaw.h in this
branch.
 1.18.14.1 21-Apr-2019  isaki Adapt cs428x families to audio2.
- recording on cs4280 seems to have its own conversion.
I will see it later but first make it compilable.
 1.18.10.1 10-Jun-2019  christos Sync with HEAD
 1.18 03-Feb-2021  isaki Remove code no longer used.
The code that used sc->{halt_input,halt_output} function pointer
was removed in 2004. (see cs428x.c rev 1.7)
 1.17 08-May-2019  isaki branches: 1.17.10;
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.16 27-Oct-2012  chs branches: 1.16.38; 1.16.42;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.15 23-Nov-2011  jmcneill branches: 1.15.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.14 09-Dec-2007  jmcneill branches: 1.14.26; 1.14.48; 1.14.50;
Merge jmcneill-pm branch.
 1.13 15-Jun-2007  joerg branches: 1.13.6; 1.13.8; 1.13.16; 1.13.18;
Fix ACPI suspend/resume support of clcs and clct. Based on auich and
hints from jmcneill@.
 1.12 04-Mar-2007  christos branches: 1.12.2; 1.12.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 06-Aug-2006  jmcneill branches: 1.11.8; 1.11.10; 1.11.12; 1.11.14;
PR/12843: Workaround for CS4280 on IBM ThinkPads. From Stephane Witzmann.

Note: This workaround conflicts with piixpm(4); you will need to disable
the piixpm driver if you need this fix.
 1.10 15-Apr-2006  jmcneill Add support for the Turtle Beach Santa Cruz. Special thanks to Stephane
Witzmann for spending so much time debugging this.

Fixes: kern/18880, kern/24488, port-i386/14260, kern/12603, kern/12723,
kern/24957, kern/23584

Tested on i386 (Stephane Witzmann), alpha (me).
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10; 1.9.12;
merge ktrace-lwp.
 1.8 15-Jan-2005  kent branches: 1.8.10;
ansify and KNF
 1.7 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.6 03-May-2003  wiz branches: 1.6.2; 1.6.6;
DMA, not dma nor Dma.
 1.5 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.4 18-Apr-2001  tacha branches: 1.4.2;
rewrite suspend/resume routine. If you suspend while playing audio,
clcs and clct continue playing when resume.
 1.3 07-Feb-2001  tacha branches: 1.3.2; 1.3.4;
Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.2 22-Jan-2001  augustss Clean up a little.
 1.1 22-Jan-2001  augustss Add clct driver for Cirrus Logic CrystalClear PCI Audio CS4281.
Driver written by Tatoku Ogaito.
 1.3.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.1 07-Feb-2001  bouyer file cs428x.h was added on branch thorpej_scsipi on 2001-02-11 19:15:52 +0000
 1.4.2.2 06-May-2001  he Pull up revisions 1.1-1.4 (new, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.4.2.1 18-Apr-2001  he file cs428x.h was added on branch netbsd-1-5 on 2001-05-06 15:12:48 +0000
 1.6.6.1 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.6.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.8.10.4 21-Jan-2008  yamt sync with head
 1.8.10.3 03-Sep-2007  yamt sync with head.
 1.8.10.2 30-Dec-2006  yamt sync with head.
 1.8.10.1 21-Jun-2006  yamt sync with head.
 1.9.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.10.1 19-Apr-2006  elad sync with head.
 1.9.8.2 11-Aug-2006  yamt sync with head
 1.9.8.1 24-May-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.11.14.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.11.12.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.11.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.11.8.1 18-Jun-2007  liamjfoy Pull up following revision(s) (requested by joerg in ticket #733):
sys/dev/pci/cs4280.c: revision 1.46
sys/dev/pci/cs4281.c: revision 1.34
sys/dev/pci/cs428x.h: revision 1.13
Fix ACPI suspend/resume support of clcs and clct. Based on auich and
hints from jmcneill@.
 1.12.4.1 11-Jul-2007  mjf Sync with head.
 1.12.2.1 15-Jul-2007  ad Sync with head.
 1.13.18.1 11-Dec-2007  yamt sync with head.
 1.13.16.1 26-Dec-2007  ad Sync with head.
 1.13.8.1 09-Jan-2008  matt sync with HEAD
 1.13.6.1 04-Oct-2007  joerg Convert clcs(4) and clct(4) to PNP power management. This should also
allow more then one instance of each to resume correctly.
 1.14.50.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.14.48.2 30-Oct-2012  yamt sync with head
 1.14.48.1 17-Apr-2012  yamt sync with head
 1.14.26.2 12-Dec-2008  ad Checkpoint work in progress.
 1.14.26.1 11-Dec-2008  ad Checkpoint work in progress.
 1.15.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.16.42.2 05-May-2019  isaki Remove encoding conversions on recording.
These are handled in the upper layer now.
 1.16.42.1 21-Apr-2019  isaki Adapt cs428x families to audio2.
- recording on cs4280 seems to have its own conversion.
I will see it later but first make it compilable.
 1.16.38.1 10-Jun-2019  christos Sync with HEAD
 1.17.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 15-Jan-2005  kent ansify and KNF
 1.2 22-Jan-2001  augustss branches: 1.2.2; 1.2.6; 1.2.28;
Clean up a little.
 1.1 22-Jan-2001  augustss Add clct driver for Cirrus Logic CrystalClear PCI Audio CS4281.
Driver written by Tatoku Ogaito.
 1.2.28.1 17-Jan-2005  skrll Sync with HEAD.
 1.2.6.2 06-May-2001  he Pull up revisions 1.1-1.2 (new, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.2.6.1 22-Jan-2001  he file cs428xreg.h was added on branch netbsd-1-5 on 2001-05-06 15:13:08 +0000
 1.2.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.1 22-Jan-2001  bouyer file cs428xreg.h was added on branch thorpej_scsipi on 2001-02-11 19:15:52 +0000
 1.2 09-Aug-2011  jmcneill add CLK_DELAY
 1.1 04-Aug-2011  jakllsch Add coram(4).

A driver for CX23885-based TV cards, such as the
Hauppauge WinTV HVR-1250 "Coram" board.

Currently only supports ATSC 8VSB reception.
 1.23 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.22 09-Feb-2024  andvar s/discriptor/descriptor/ in comments.
 1.21 10-May-2023  riastradh cxdtv(4): Use config_detach_children.
 1.20 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.19 24-Apr-2021  thorpej branches: 1.19.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.18 23-Dec-2019  thorpej branches: 1.18.10;
No need to use I2C_F_POLL here.
 1.17 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.16 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.15 01-Jun-2017  chs branches: 1.15.8; 1.15.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.14 29-Mar-2014  christos branches: 1.14.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.13 16-Oct-2013  christos remove unused variables.
 1.12 27-Oct-2012  chs branches: 1.12.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.11 30-Jan-2012  drochner branches: 1.11.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.10 16-Jan-2012  jmcneill Only match supported boards.
 1.9 26-Sep-2011  jakllsch branches: 1.9.2; 1.9.6;
Define and use symbolic bits in registers.
 1.8 29-Aug-2011  jmcneill have pci register itself as a module, and make PCI driver modules depend on it
 1.7 09-Aug-2011  jmcneill modify the dtv device api so hardware drivers can be loaded independently
of the dtv module
 1.6 25-Jul-2011  jakllsch Remove unconditional debugging code. Also, a few other cleanups.
 1.5 15-Jul-2011  jmcneill use lg3303_get_snr, lg3303_get_signal_strength
 1.4 15-Jul-2011  jmcneill add pcHDTV HD-5500 support:

cxdtv0 at pci0 dev 14 function 2: pcHDTV HD-5500 HDTV Video Capture (rev. 0x05)
cxdtv0: interrupting at irq 10
cxdtv0: lg3303: found @ 0x59
cxdtv0: tvpll: LG TDVS-H06xF
dtv0 at cxdtv0: CX23880 [ATSC]
 1.3 15-Jul-2011  jmcneill add detach support
 1.2 14-Jul-2011  jmcneill hook in lg3303 demod support and modularize
 1.1 11-Jul-2011  jakllsch Add cxdtv(4), a dtv(4) driver for Conexant CX23880-series DTV interface chips.

Initially supports digital reception on ATI HDTV Wonder card.
 1.9.6.1 18-Feb-2012  mrg merge to -current.
 1.9.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.2.2 30-Oct-2012  yamt sync with head
 1.9.2.1 17-Apr-2012  yamt sync with head
 1.11.6.3 03-Dec-2017  jdolecek update from HEAD
 1.11.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.12.2.1 18-May-2014  rmind sync with head
 1.14.6.1 28-Aug-2017  skrll Sync with HEAD
 1.15.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.10.1 10-Jun-2019  christos Sync with HEAD
 1.15.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.18.10.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.19.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 14-Jul-2011  jmcneill hook in lg3303 demod support and modularize
 1.1 11-Jul-2011  jakllsch Add cxdtv(4), a dtv(4) driver for Conexant CX23880-series DTV interface chips.

Initially supports digital reception on ATI HDTV Wonder card.
 1.1 11-Jul-2011  jakllsch Add cxdtv(4), a dtv(4) driver for Conexant CX23880-series DTV interface chips.

Initially supports digital reception on ATI HDTV Wonder card.
 1.3 11-Jul-2015  kamil Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.2 26-Sep-2011  jakllsch branches: 1.2.12; 1.2.30;
Define and use symbolic bits in registers.
 1.1 11-Jul-2011  jakllsch Add cxdtv(4), a dtv(4) driver for Conexant CX23880-series DTV interface chips.

Initially supports digital reception on ATI HDTV Wonder card.
 1.2.30.1 22-Sep-2015  skrll Sync with HEAD
 1.2.12.1 03-Dec-2017  jdolecek update from HEAD
 1.4 09-Aug-2011  jmcneill modify the dtv device api so hardware drivers can be loaded independently
of the dtv module
 1.3 25-Jul-2011  jakllsch Remove unconditional debugging code. Also, a few other cleanups.
 1.2 15-Jul-2011  jmcneill add detach support
 1.1 11-Jul-2011  jakllsch Add cxdtv(4), a dtv(4) driver for Conexant CX23880-series DTV interface chips.

Initially supports digital reception on ATI HDTV Wonder card.
 1.8 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.7 17-Jan-2008  jklos branches: 1.7.10; 1.7.30; 1.7.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.6 19-Oct-2007  ad branches: 1.6.2; 1.6.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 10-Jul-2007  jklos branches: 1.5.2; 1.5.4; 1.5.10; 1.5.12; 1.5.14; 1.5.18;
More updates to the cxgb stuff. Now it actually starts configuring and
talking to the hardware.
 1.4 09-Jul-2007  jklos More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.3 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.2 05-Jul-2007  jklos Updates of working copies (there will be many).
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.5.18.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.14.4 21-Jan-2008  yamt sync with head
 1.5.14.3 27-Oct-2007  yamt sync with head.
 1.5.14.2 03-Sep-2007  yamt sync with head.
 1.5.14.1 10-Jul-2007  yamt file cxgb_adapter.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:28 +0000
 1.5.12.2 23-Mar-2008  matt sync with HEAD
 1.5.12.1 06-Nov-2007  matt sync with HEAD
 1.5.10.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.4.3 23-Oct-2007  ad Sync with head.
 1.5.4.2 15-Jul-2007  ad Sync with head.
 1.5.4.1 10-Jul-2007  ad file cxgb_adapter.h was added on branch vmlocking on 2007-07-15 13:21:22 +0000
 1.5.2.2 11-Jul-2007  mjf Sync with head.
 1.5.2.1 10-Jul-2007  mjf file cxgb_adapter.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:05 +0000
 1.6.8.1 19-Jan-2008  bouyer Sync with HEAD
 1.6.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.32.1 30-May-2010  rmind sync with head
 1.7.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.2 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.22; 1.1.24; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.24.1 11-Dec-2007  yamt sync with head.
 1.1.22.1 26-Dec-2007  ad Sync with head.
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_ael1002.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:29 +0000
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_ael1002.c was added on branch vmlocking on 2007-07-15 13:21:22 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_ael1002.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:05 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.2 07-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.12; 1.2.14; 1.2.20; 1.2.26;
Updating Chelsio files. Not quite compiling yet.
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.2.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.14.3 21-Jan-2008  yamt sync with head
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 07-Jul-2007  yamt file cxgb_common.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:29 +0000
 1.2.12.1 23-Mar-2008  matt sync with HEAD
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 07-Jul-2007  ad file cxgb_common.h was added on branch vmlocking on 2007-07-15 13:21:22 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 07-Jul-2007  mjf file cxgb_common.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:06 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_config.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:30 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_config.h was added on branch vmlocking on 2007-07-15 13:21:23 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_config.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:07 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_ctl_defs.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:30 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_ctl_defs.h was added on branch vmlocking on 2007-07-15 13:21:23 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_ctl_defs.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:07 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_firmware_exports.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:30 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_firmware_exports.h was added on branch vmlocking on 2007-07-15 13:21:23 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_firmware_exports.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:08 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.7 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.6 17-Jan-2008  jklos branches: 1.6.10; 1.6.30; 1.6.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.5 09-Jul-2007  jklos branches: 1.5.2; 1.5.4; 1.5.12; 1.5.14; 1.5.20; 1.5.26;
More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.4 08-Jul-2007  jklos Updating more Chelsio files.
 1.3 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.2 05-Jul-2007  jklos Updates of working copies (there will be many).
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.5.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.5.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.14.3 21-Jan-2008  yamt sync with head
 1.5.14.2 03-Sep-2007  yamt sync with head.
 1.5.14.1 09-Jul-2007  yamt file cxgb_include.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:31 +0000
 1.5.12.1 23-Mar-2008  matt sync with HEAD
 1.5.4.2 15-Jul-2007  ad Sync with head.
 1.5.4.1 09-Jul-2007  ad file cxgb_include.h was added on branch vmlocking on 2007-07-15 13:21:24 +0000
 1.5.2.2 11-Jul-2007  mjf Sync with head.
 1.5.2.1 09-Jul-2007  mjf file cxgb_include.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:08 +0000
 1.6.32.1 30-May-2010  rmind sync with head
 1.6.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.10.1 11-Aug-2010  yamt sync with head.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_ioctl.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:31 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_ioctl.h was added on branch vmlocking on 2007-07-15 13:21:24 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_ioctl.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:09 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 05-Jul-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 05-Jul-2007  yamt file cxgb_jhash.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:32 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 05-Jul-2007  ad file cxgb_jhash.h was added on branch vmlocking on 2007-07-15 13:21:24 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 05-Jul-2007  mjf file cxgb_jhash.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:10 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.8 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.7 17-Jan-2008  jklos branches: 1.7.10; 1.7.30; 1.7.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.6 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.5 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.4 26-Aug-2007  dyoung branches: 1.4.2; 1.4.4; 1.4.10; 1.4.12; 1.4.14; 1.4.16;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.3 09-Jul-2007  jklos branches: 1.3.2; 1.3.4; 1.3.6; 1.3.10;
More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.2 08-Jul-2007  jklos Updating more Chelsio files.
 1.1 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.3.10.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.3.6.1 03-Sep-2007  skrll Sync with HEAD.
 1.3.4.3 09-Oct-2007  ad Sync with head.
 1.3.4.2 15-Jul-2007  ad Sync with head.
 1.3.4.1 09-Jul-2007  ad file cxgb_l2t.c was added on branch vmlocking on 2007-07-15 13:21:25 +0000
 1.3.2.2 11-Jul-2007  mjf Sync with head.
 1.3.2.1 09-Jul-2007  mjf file cxgb_l2t.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:10 +0000
 1.4.16.3 19-Jan-2008  bouyer Sync with HEAD
 1.4.16.2 08-Jan-2008  bouyer Sync with HEAD
 1.4.16.1 13-Dec-2007  bouyer Sync with HEAD
 1.4.14.1 11-Dec-2007  yamt sync with head.
 1.4.12.1 26-Dec-2007  ad Sync with head.
 1.4.10.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.4.3 21-Jan-2008  yamt sync with head
 1.4.4.2 03-Sep-2007  yamt sync with head.
 1.4.4.1 26-Aug-2007  yamt file cxgb_l2t.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:32 +0000
 1.4.2.2 23-Mar-2008  matt sync with HEAD
 1.4.2.1 09-Jan-2008  matt sync with HEAD
 1.7.32.1 30-May-2010  rmind sync with head
 1.7.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.2 07-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.12; 1.2.14; 1.2.20; 1.2.26;
Updating Chelsio files. Not quite compiling yet.
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.2.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.14.3 21-Jan-2008  yamt sync with head
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 07-Jul-2007  yamt file cxgb_l2t.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:33 +0000
 1.2.12.1 23-Mar-2008  matt sync with HEAD
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 07-Jul-2007  ad file cxgb_l2t.h was added on branch vmlocking on 2007-07-15 13:21:25 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 07-Jul-2007  mjf file cxgb_l2t.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:11 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.7 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.6 17-Jan-2008  jklos branches: 1.6.10; 1.6.30; 1.6.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.5 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.4 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.3 19-Oct-2007  ad branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.2 08-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12; 1.2.14; 1.2.18;
Updating more Chelsio files.
 1.1 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.2.18.1 25-Oct-2007  bouyer Sync with HEAD.
 1.2.14.4 21-Jan-2008  yamt sync with head
 1.2.14.3 27-Oct-2007  yamt sync with head.
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 08-Jul-2007  yamt file cxgb_lro.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:33 +0000
 1.2.12.3 23-Mar-2008  matt sync with HEAD
 1.2.12.2 09-Jan-2008  matt sync with HEAD
 1.2.12.1 06-Nov-2007  matt sync with HEAD
 1.2.10.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.2.4.3 23-Oct-2007  ad Sync with head.
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 08-Jul-2007  ad file cxgb_lro.c was added on branch vmlocking on 2007-07-15 13:21:25 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 08-Jul-2007  mjf file cxgb_lro.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:12 +0000
 1.3.8.3 19-Jan-2008  bouyer Sync with HEAD
 1.3.8.2 02-Jan-2008  bouyer Sync with HEAD
 1.3.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.3.6.1 11-Dec-2007  yamt sync with head.
 1.3.4.1 26-Dec-2007  ad Sync with head.
 1.3.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.32.1 30-May-2010  rmind sync with head
 1.6.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.10.1 11-Aug-2010  yamt sync with head.
 1.17 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.16 12-May-2009  cegger branches: 1.16.2; 1.16.4;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.15 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.14 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.13 18-Mar-2009  cegger bcopy -> memcpy
 1.12 07-Nov-2008  dyoung branches: 1.12.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.11 07-Feb-2008  dyoung branches: 1.11.6; 1.11.10; 1.11.16; 1.11.18;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.10 17-Jan-2008  jklos 10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.9 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.8 19-Oct-2007  ad branches: 1.8.2; 1.8.4; 1.8.6; 1.8.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.7 12-Jul-2007  he branches: 1.7.2; 1.7.8; 1.7.10; 1.7.12; 1.7.16;
Adapt two more uses to the new signature of callout_init().
 1.6 10-Jul-2007  jklos branches: 1.6.2;
More updates to the cxgb stuff. Now it actually starts configuring and
talking to the hardware.
 1.5 09-Jul-2007  jklos More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.4 08-Jul-2007  jklos Updating more Chelsio files.
 1.3 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.2 05-Jul-2007  jklos Updates of working copies (there will be many).
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.6.2.2 11-Jul-2007  mjf Sync with head.
 1.6.2.1 10-Jul-2007  mjf file cxgb_main.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:13 +0000
 1.7.16.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.12.5 11-Feb-2008  yamt sync with head.
 1.7.12.4 21-Jan-2008  yamt sync with head
 1.7.12.3 27-Oct-2007  yamt sync with head.
 1.7.12.2 03-Sep-2007  yamt sync with head.
 1.7.12.1 12-Jul-2007  yamt file cxgb_main.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:34 +0000
 1.7.10.3 23-Mar-2008  matt sync with HEAD
 1.7.10.2 09-Jan-2008  matt sync with HEAD
 1.7.10.1 06-Nov-2007  matt sync with HEAD
 1.7.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.2.3 23-Oct-2007  ad Sync with head.
 1.7.2.2 15-Jul-2007  ad Sync with head.
 1.7.2.1 12-Jul-2007  ad file cxgb_main.c was added on branch vmlocking on 2007-07-15 13:21:26 +0000
 1.8.8.2 19-Jan-2008  bouyer Sync with HEAD
 1.8.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.8.6.1 11-Dec-2007  yamt sync with head.
 1.8.4.1 26-Dec-2007  ad Sync with head.
 1.8.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.11.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.11.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.10.3 11-Aug-2010  yamt sync with head.
 1.11.10.2 16-May-2009  yamt sync with head
 1.11.10.1 04-May-2009  yamt sync with head.
 1.11.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.12.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.4.1 30-May-2010  rmind sync with head
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 09-Jul-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 09-Jul-2007  yamt file cxgb_mbuf.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:35 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 09-Jul-2007  ad file cxgb_mbuf.h was added on branch vmlocking on 2007-07-15 13:21:26 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 09-Jul-2007  mjf file cxgb_mbuf.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:13 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.2 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.22; 1.1.24; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.24.1 11-Dec-2007  yamt sync with head.
 1.1.22.1 26-Dec-2007  ad Sync with head.
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_mc5.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:35 +0000
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_mc5.c was added on branch vmlocking on 2007-07-15 13:21:27 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_mc5.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:14 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.2 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.22; 1.1.24; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.24.1 11-Dec-2007  yamt sync with head.
 1.1.22.1 26-Dec-2007  ad Sync with head.
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_mv88e1xxx.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:36 +0000
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_mv88e1xxx.c was added on branch vmlocking on 2007-07-15 13:21:27 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_mv88e1xxx.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:15 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.2 09-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.12; 1.2.14; 1.2.20; 1.2.26;
More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.1 08-Jul-2007  jklos Updating more Chelsio files.
 1.2.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.14.3 21-Jan-2008  yamt sync with head
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 09-Jul-2007  yamt file cxgb_mvec.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:36 +0000
 1.2.12.1 23-Mar-2008  matt sync with HEAD
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 09-Jul-2007  ad file cxgb_mvec.h was added on branch vmlocking on 2007-07-15 13:21:28 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 09-Jul-2007  mjf file cxgb_mvec.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:15 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.7 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.6 17-Jan-2008  jklos branches: 1.6.10; 1.6.30; 1.6.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.5 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.4 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.3 19-Oct-2007  ad branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.2 09-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.12; 1.2.14; 1.2.18;
More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.1 07-Jul-2007  jklos Adding another file for Chesio 10 gig card support.
 1.2.18.1 25-Oct-2007  bouyer Sync with HEAD.
 1.2.14.4 21-Jan-2008  yamt sync with head
 1.2.14.3 27-Oct-2007  yamt sync with head.
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 09-Jul-2007  yamt file cxgb_offload.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:37 +0000
 1.2.12.3 23-Mar-2008  matt sync with HEAD
 1.2.12.2 09-Jan-2008  matt sync with HEAD
 1.2.12.1 06-Nov-2007  matt sync with HEAD
 1.2.10.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.2.4.3 23-Oct-2007  ad Sync with head.
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 09-Jul-2007  ad file cxgb_offload.c was added on branch vmlocking on 2007-07-15 13:21:28 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 09-Jul-2007  mjf file cxgb_offload.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:16 +0000
 1.3.8.3 19-Jan-2008  bouyer Sync with HEAD
 1.3.8.2 02-Jan-2008  bouyer Sync with HEAD
 1.3.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.3.6.1 11-Dec-2007  yamt sync with head.
 1.3.4.1 26-Dec-2007  ad Sync with head.
 1.3.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.32.1 30-May-2010  rmind sync with head
 1.6.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.2 07-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.12; 1.2.14; 1.2.20; 1.2.26;
Updating Chelsio files. Not quite compiling yet.
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.2.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.14.3 21-Jan-2008  yamt sync with head
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 07-Jul-2007  yamt file cxgb_offload.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:38 +0000
 1.2.12.1 23-Mar-2008  matt sync with HEAD
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 07-Jul-2007  ad file cxgb_offload.h was added on branch vmlocking on 2007-07-15 13:21:29 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 07-Jul-2007  mjf file cxgb_offload.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:17 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.2 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.1 17-Jan-2008  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14; 1.1.18; 1.1.38; 1.1.40;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.1.40.1 30-May-2010  rmind sync with head
 1.1.38.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.18.1 11-Aug-2010  yamt sync with head.
 1.1.14.2 23-Mar-2008  matt sync with HEAD
 1.1.14.1 17-Jan-2008  matt file cxgb_osdep.c was added on branch matt-armv6 on 2008-03-23 02:04:45 +0000
 1.1.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.6.1 17-Jan-2008  mjf file cxgb_osdep.c was added on branch mjf-devfs on 2008-02-18 21:05:56 +0000
 1.1.4.2 21-Jan-2008  yamt sync with head
 1.1.4.1 17-Jan-2008  yamt file cxgb_osdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:43:45 +0000
 1.1.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 17-Jan-2008  bouyer file cxgb_osdep.c was added on branch bouyer-xeni386 on 2008-01-19 12:15:08 +0000
 1.11 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.10 08-Sep-2008  gmcgarry branches: 1.10.14; 1.10.16;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.9 17-Jan-2008  jklos branches: 1.9.6; 1.9.10; 1.9.12; 1.9.16;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.8 07-Jan-2008  ad Remove vestiges of simplelock debugging.
 1.7 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.6 14-Dec-2007  dogcow remove typedef for caddr_t
 1.5 19-Oct-2007  ad branches: 1.5.2; 1.5.4; 1.5.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.4 10-Jul-2007  jklos branches: 1.4.2; 1.4.4; 1.4.10; 1.4.12; 1.4.14; 1.4.18;
More updates to the cxgb stuff. Now it actually starts configuring and
talking to the hardware.
 1.3 09-Jul-2007  jklos More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.2 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.4.18.1 25-Oct-2007  bouyer Sync with HEAD.
 1.4.14.4 21-Jan-2008  yamt sync with head
 1.4.14.3 27-Oct-2007  yamt sync with head.
 1.4.14.2 03-Sep-2007  yamt sync with head.
 1.4.14.1 10-Jul-2007  yamt file cxgb_osdep.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:38 +0000
 1.4.12.3 23-Mar-2008  matt sync with HEAD
 1.4.12.2 09-Jan-2008  matt sync with HEAD
 1.4.12.1 06-Nov-2007  matt sync with HEAD
 1.4.10.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.4.4.3 23-Oct-2007  ad Sync with head.
 1.4.4.2 15-Jul-2007  ad Sync with head.
 1.4.4.1 10-Jul-2007  ad file cxgb_osdep.h was added on branch vmlocking on 2007-07-15 13:21:29 +0000
 1.4.2.2 11-Jul-2007  mjf Sync with head.
 1.4.2.1 10-Jul-2007  mjf file cxgb_osdep.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:17 +0000
 1.5.8.3 19-Jan-2008  bouyer Sync with HEAD
 1.5.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.5.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.4.1 26-Dec-2007  ad Sync with head.
 1.5.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.16.1 19-Oct-2008  haad Sync with HEAD.
 1.9.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.9.10.2 11-Aug-2010  yamt sync with head.
 1.9.10.1 04-May-2009  yamt sync with head.
 1.9.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.10.16.1 30-May-2010  rmind sync with head
 1.10.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.14; 1.1.38; 1.1.60; 1.1.62;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.62.1 30-May-2010  rmind sync with head
 1.1.60.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.38.1 11-Aug-2010  yamt sync with head.
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_regs.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:39 +0000
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_regs.h was added on branch vmlocking on 2007-07-15 13:21:29 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_regs.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:18 +0000
 1.13 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.12 18-Mar-2009  cegger branches: 1.12.2; 1.12.4;
bzero -> memset
 1.11 03-Jan-2009  yamt branches: 1.11.2;
remove extra semicolons.
 1.10 19-Dec-2008  cegger use M_ZERO on malloc() and remove subsequent bzero().
 1.9 17-Jan-2008  jklos branches: 1.9.6; 1.9.10; 1.9.18;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.8 14-Dec-2007  dogcow caddr_t -> void *
 1.7 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.6 19-Oct-2007  ad branches: 1.6.2; 1.6.4; 1.6.6; 1.6.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 12-Jul-2007  he branches: 1.5.2; 1.5.8; 1.5.10; 1.5.12; 1.5.16;
Adapt two more uses to the new signature of callout_init().
 1.4 10-Jul-2007  jklos branches: 1.4.2;
More updates to the cxgb stuff. Now it actually starts configuring and
talking to the hardware.
 1.3 09-Jul-2007  jklos More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.2 07-Jul-2007  jklos Updating Chelsio files. Not quite compiling yet.
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.4.2.2 11-Jul-2007  mjf Sync with head.
 1.4.2.1 10-Jul-2007  mjf file cxgb_sge.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:20 +0000
 1.5.16.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.12.4 21-Jan-2008  yamt sync with head
 1.5.12.3 27-Oct-2007  yamt sync with head.
 1.5.12.2 03-Sep-2007  yamt sync with head.
 1.5.12.1 12-Jul-2007  yamt file cxgb_sge.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:40 +0000
 1.5.10.3 23-Mar-2008  matt sync with HEAD
 1.5.10.2 09-Jan-2008  matt sync with HEAD
 1.5.10.1 06-Nov-2007  matt sync with HEAD
 1.5.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.2.3 23-Oct-2007  ad Sync with head.
 1.5.2.2 15-Jul-2007  ad Sync with head.
 1.5.2.1 12-Jul-2007  ad file cxgb_sge.c was added on branch vmlocking on 2007-07-15 13:21:30 +0000
 1.6.8.3 19-Jan-2008  bouyer Sync with HEAD
 1.6.8.2 02-Jan-2008  bouyer Sync with HEAD
 1.6.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.6.6.1 11-Dec-2007  yamt sync with head.
 1.6.4.1 26-Dec-2007  ad Sync with head.
 1.6.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.9.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.9.10.2 11-Aug-2010  yamt sync with head.
 1.9.10.1 04-May-2009  yamt sync with head.
 1.9.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.11.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.4.1 30-May-2010  rmind sync with head
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_sge_defs.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:41 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_sge_defs.h was added on branch vmlocking on 2007-07-15 13:21:31 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_sge_defs.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:20 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.3 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.2 17-Jan-2008  jklos branches: 1.2.10; 1.2.30; 1.2.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_t3_cpl.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:41 +0000
 1.1.12.1 23-Mar-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_t3_cpl.h was added on branch vmlocking on 2007-07-15 13:21:31 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_t3_cpl.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:21 +0000
 1.2.32.1 30-May-2010  rmind sync with head
 1.2.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.10.1 11-Aug-2010  yamt sync with head.
 1.6 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.5 17-Jan-2008  jklos branches: 1.5.10; 1.5.30; 1.5.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.4 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.3 10-Jul-2007  jklos branches: 1.3.2; 1.3.4; 1.3.12; 1.3.14; 1.3.20; 1.3.22; 1.3.24; 1.3.26;
More updates to the cxgb stuff. Now it actually starts configuring and
talking to the hardware.
 1.2 09-Jul-2007  jklos More updates to Chelsio support files. It compiles, but almost certainly
doesn't work yet.
 1.1 22-Jun-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.3.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.3.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.3.24.1 11-Dec-2007  yamt sync with head.
 1.3.22.1 26-Dec-2007  ad Sync with head.
 1.3.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.14.3 21-Jan-2008  yamt sync with head
 1.3.14.2 03-Sep-2007  yamt sync with head.
 1.3.14.1 10-Jul-2007  yamt file cxgb_t3_hw.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:42 +0000
 1.3.12.2 23-Mar-2008  matt sync with HEAD
 1.3.12.1 09-Jan-2008  matt sync with HEAD
 1.3.4.2 15-Jul-2007  ad Sync with head.
 1.3.4.1 10-Jul-2007  ad file cxgb_t3_hw.c was added on branch vmlocking on 2007-07-15 13:21:31 +0000
 1.3.2.2 11-Jul-2007  mjf Sync with head.
 1.3.2.1 10-Jul-2007  mjf file cxgb_t3_hw.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:22 +0000
 1.5.32.1 30-May-2010  rmind sync with head
 1.5.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.10.1 11-Aug-2010  yamt sync with head.
 1.2 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.14; 1.1.38; 1.1.60; 1.1.62;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.62.1 30-May-2010  rmind sync with head
 1.1.60.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.38.1 11-Aug-2010  yamt sync with head.
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_tcb.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:43 +0000
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_tcb.h was added on branch vmlocking on 2007-07-15 13:21:32 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_tcb.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:23 +0000
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
More Chelsio 10 gigabit driver files to complete the ones checked in
yesterday.
 1.2 07-Jul-2007  jklos branches: 1.2.2; 1.2.4; 1.2.12; 1.2.14; 1.2.20; 1.2.26;
Updating Chelsio files. Not quite compiling yet.
 1.1 05-Jul-2007  jklos These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.2.26.1 19-Jan-2008  bouyer Sync with HEAD
 1.2.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.14.3 21-Jan-2008  yamt sync with head
 1.2.14.2 03-Sep-2007  yamt sync with head.
 1.2.14.1 07-Jul-2007  yamt file cxgb_toedev.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:43 +0000
 1.2.12.1 23-Mar-2008  matt sync with HEAD
 1.2.4.2 15-Jul-2007  ad Sync with head.
 1.2.4.1 07-Jul-2007  ad file cxgb_toedev.h was added on branch vmlocking on 2007-07-15 13:21:32 +0000
 1.2.2.2 11-Jul-2007  mjf Sync with head.
 1.2.2.1 07-Jul-2007  mjf file cxgb_toedev.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:24 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.2 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.14; 1.1.38; 1.1.60; 1.1.62;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.62.1 30-May-2010  rmind sync with head
 1.1.60.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.38.1 11-Aug-2010  yamt sync with head.
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_version.h was added on branch yamt-lazymbuf on 2007-09-03 14:36:44 +0000
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_version.h was added on branch vmlocking on 2007-07-15 13:21:33 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_version.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:24 +0000
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.2 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.22; 1.1.24; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.24.1 11-Dec-2007  yamt sync with head.
 1.1.22.1 26-Dec-2007  ad Sync with head.
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_vsc7323.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:44 +0000
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_vsc7323.c was added on branch vmlocking on 2007-07-15 13:21:33 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_vsc7323.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:25 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.2 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.22; 1.1.24; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.24.1 11-Dec-2007  yamt sync with head.
 1.1.22.1 26-Dec-2007  ad Sync with head.
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_vsc8211.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:45 +0000
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_vsc8211.c was added on branch vmlocking on 2007-07-15 13:21:33 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_vsc8211.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:26 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.4 21-Mar-2010  jklos Reorganizing Chelsio 10 gig files into separate directory.
 1.3 17-Jan-2008  jklos branches: 1.3.10; 1.3.30; 1.3.32;
10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.2 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.1 22-Jun-2007  jklos branches: 1.1.2; 1.1.4; 1.1.12; 1.1.14; 1.1.20; 1.1.22; 1.1.24; 1.1.26;
These files (cxgb*) are for the Chelsio T3 10 gigabit ethernet card from
the FreeBSD driver by Kip Macy (kmacy@FreeBSD.org).
 1.1.26.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.26.1 13-Dec-2007  bouyer Sync with HEAD
 1.1.24.1 11-Dec-2007  yamt sync with head.
 1.1.22.1 26-Dec-2007  ad Sync with head.
 1.1.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.14.3 21-Jan-2008  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 22-Jun-2007  yamt file cxgb_xgmac.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:45 +0000
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 22-Jun-2007  ad file cxgb_xgmac.c was added on branch vmlocking on 2007-07-15 13:21:34 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 22-Jun-2007  mjf file cxgb_xgmac.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:26 +0000
 1.3.32.1 30-May-2010  rmind sync with head
 1.3.30.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.10.1 11-Aug-2010  yamt sync with head.
 1.11 17-Aug-2024  thorpej Make the cyhc lock a regular mutex rather than a spin mutex. Simplify
some interaction with the lock by converting some open-coded test/panic
blocks to KASSERT()s that can be safely tested outside the lock perimeter.

PR port-alpha/58602
 1.10 06-Jun-2018  maya branches: 1.10.34; 1.10.40;
Remove duplicate ;
 1.9 20-Mar-2014  skrll branches: 1.9.28;
Mechanically replace simplelock with kmutex_t.
 1.8 19-Apr-2010  dyoung branches: 1.8.8; 1.8.18; 1.8.22;
Add default implementations for bus_space_is_equal(9),
bus_space_tag_create(9), and bus_space_tag_destroy(9). Use
bus_space_is_equal(9) throughout the kernel to compare
bus_space_tag_t's. Tested on i386 and on sparc64.
 1.7 22-Mar-2010  dyoung #if 0 some diagnostic code that compares two bus_space_tag_t's.

MI code should not compare an opaque type such as bus_space_tag_t!
 1.6 28-Apr-2008  martin branches: 1.6.20; 1.6.22;
Remove clause 3 and 4 from TNF licenses
 1.5 04-Jan-2008  ad branches: 1.5.6; 1.5.8; 1.5.10;
Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.4 19-Oct-2007  ad branches: 1.4.2; 1.4.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.3 13-Nov-2001  lukem branches: 1.3.32; 1.3.74; 1.3.88; 1.3.90; 1.3.94;
cleanup RCSID
 1.2 24-Nov-2000  chs branches: 1.2.2; 1.2.4;
adjust the spinlock macros in the non-MULTIPROCESSOR, non-LOCKDEBUG case
so that gcc will think that static spinlock are used.
this allows us to remove the ugly conditionalization of
static spinlock declarations.
 1.1 06-Jun-2000  thorpej branches: 1.1.4; 1.1.6;
Common routines for read/writing Cypress 82c693 control registers. Needed
by `pciide' and the Alpha `sio' (PCI-ISA bridge) driver.
 1.1.6.3 08-Dec-2000  bouyer Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 06-Jun-2000  bouyer file cy82c693.c was added on branch thorpej_scsipi on 2000-11-20 11:42:16 +0000
 1.1.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.4.1 06-Jun-2000  minoura file cy82c693.c was added on branch minoura-xpg4dl on 2000-06-22 17:07:17 +0000
 1.2.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.3.94.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.90.2 09-Jan-2008  matt sync with HEAD
 1.3.90.1 06-Nov-2007  matt sync with HEAD
 1.3.88.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.74.1 23-Oct-2007  ad Sync with head.
 1.3.32.2 21-Jan-2008  yamt sync with head
 1.3.32.1 27-Oct-2007  yamt sync with head.
 1.4.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.4.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.10.2 11-Aug-2010  yamt sync with head.
 1.5.10.1 16-May-2008  yamt sync with head.
 1.5.8.1 18-May-2008  yamt sync with head.
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.22.1 30-May-2010  rmind sync with head
 1.6.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.22.1 18-May-2014  rmind sync with head
 1.8.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.28.1 25-Jun-2018  pgoyette Sync with HEAD
 1.10.40.1 02-Aug-2025  perseant Sync with HEAD
 1.10.34.1 24-Aug-2024  martin Pull up following revision(s) (requested by thorpej in ticket #809):

sys/dev/pci/cy82c693.c: revision 1.11

Make the cyhc lock a regular mutex rather than a spin mutex. Simplify
some interaction with the lock by converting some open-coded test/panic
blocks to KASSERT()s that can be safely tested outside the lock perimeter.

PR port-alpha/58602
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 06-Jun-2000  thorpej branches: 1.1.4; 1.1.6; 1.1.128; 1.1.130; 1.1.132;
Common routines for read/writing Cypress 82c693 control registers. Needed
by `pciide' and the Alpha `sio' (PCI-ISA bridge) driver.
 1.1.132.1 16-May-2008  yamt sync with head.
 1.1.130.1 18-May-2008  yamt sync with head.
 1.1.128.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 06-Jun-2000  bouyer file cy82c693reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:17 +0000
 1.1.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.4.1 06-Jun-2000  minoura file cy82c693reg.h was added on branch minoura-xpg4dl on 2000-06-22 17:07:18 +0000
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 06-Jun-2000  thorpej branches: 1.1.4; 1.1.6; 1.1.128; 1.1.130; 1.1.132;
Common routines for read/writing Cypress 82c693 control registers. Needed
by `pciide' and the Alpha `sio' (PCI-ISA bridge) driver.
 1.1.132.1 16-May-2008  yamt sync with head.
 1.1.130.1 18-May-2008  yamt sync with head.
 1.1.128.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 06-Jun-2000  bouyer file cy82c693var.h was added on branch thorpej_scsipi on 2000-11-20 11:42:17 +0000
 1.1.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.4.1 06-Jun-2000  minoura file cy82c693var.h was added on branch minoura-xpg4dl on 2000-06-22 17:07:18 +0000
 1.26 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.25 07-Jul-2016  msaitoh branches: 1.25.16; 1.25.18;
KNF. Remove extra spaces. No functional change.
 1.24 29-Mar-2014  christos branches: 1.24.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.23 26-Mar-2008  matt branches: 1.23.38; 1.23.48; 1.23.54;
split device_t/softc. Use aprint_*_dev and device_xname.
switch to device_lookup_private.
 1.22 19-Oct-2007  ad branches: 1.22.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.21 16-Nov-2006  christos branches: 1.21.8; 1.21.22; 1.21.24; 1.21.28;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 11-Dec-2005  christos branches: 1.19.20; 1.19.22;
merge ktrace-lwp.
 1.18 28-Jun-2005  thorpej branches: 1.18.2;
Use ANSI function decls and static.
 1.17 31-Jan-2003  thorpej branches: 1.17.2;
Use aprint_*().
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 13-Nov-2001  lukem add RCSID
 1.12 20-Jan-2001  thorpej branches: 1.12.2; 1.12.4;
Only need to pass a cy_softc * to cy_attach().
 1.11 20-Jan-2001  thorpej Clean up the PCI attachment a bit, and adjust the other pieces
to suit.
 1.10 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.9 29-May-2000  tsubai * Support (not so) new cards. (only Cyclom-8YsP+ is tested)
* Make compilable with CY_DEBUG.
 1.8 08-Jun-1998  thorpej branches: 1.8.8; 1.8.14; 1.8.22;
Nuke __BROKEN_INDIRECT_CONFIG.
 1.7 17-Jun-1997  cgd Change expected mapping register type argument for the pci_mapreg_map()
call for the board's memory space to be PCI_MAPREG_MEM_TYPE_32BIT_1M or
PCI_MAPREG_MEM_TYPE_32BIT depending on the board ID. Also, remove a
bogus extra argument to an interrupt-establishment-error printf. Problems
pointed out by Jarkko Torppa <torppa@cute.fi> in PR 3753, but fixed slightly
differently than he suggested.
 1.6 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.5 13-Apr-1997  cgd use pci_map_register(). Also, almost a complete rewrite/cleanup of this
code. (It still needs more!)
 1.4 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.3 13-Oct-1996  christos backout kprintf changes
 1.2 10-Oct-1996  christos - printf -> kprintf, sprintf -> ksprintf
- remove unused variables.
- fix cleanup code in case of probe failure.
 1.1 24-Sep-1996  christos New cyclades driver from Timo Rossi.
 1.8.22.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.14.3 11-Feb-2001  bouyer Sync with HEAD.
 1.8.14.2 05-Jan-2001  bouyer Sync with HEAD
 1.8.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.8.1 03-Jun-2000  he Pull up revision 1.9 (requested by tsubai):
Add support for PCI variants of Cyclom-4Y and -8Y cards.
Also fixes PR#7175 (new serial controller).
 1.12.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.17.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.2 27-Oct-2007  yamt sync with head.
 1.18.2.1 30-Dec-2006  yamt sync with head.
 1.19.22.2 10-Dec-2006  yamt sync with head.
 1.19.22.1 22-Oct-2006  yamt sync with head
 1.19.20.1 18-Nov-2006  ad Sync with head.
 1.21.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.21.24.1 06-Nov-2007  matt sync with HEAD
 1.21.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.21.8.1 23-Oct-2007  ad Sync with head.
 1.22.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.23.54.1 18-May-2014  rmind sync with head
 1.23.48.2 03-Dec-2017  jdolecek update from HEAD
 1.23.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.38.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.6.1 09-Jul-2016  skrll Sync with HEAD
 1.25.18.1 10-Jun-2019  christos Sync with HEAD
 1.25.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 19-Oct-2007  ad branches: 1.4.16; 1.4.18; 1.4.20;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.3 11-Dec-2005  christos branches: 1.3.30; 1.3.44; 1.3.46; 1.3.50;
merge ktrace-lwp.
 1.2 04-Feb-2004  fredb branches: 1.2.4; 1.2.18;
The variables to hold the registers don't need to be declared volatile.
Pointed out by Simon Burge on tech-kern.
 1.1 03-Feb-2004  fredb Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.2.18.1 27-Oct-2007  yamt sync with head.
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 04-Feb-2004  skrll file cyber.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.3.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.46.1 06-Nov-2007  matt sync with HEAD
 1.3.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.30.1 23-Oct-2007  ad Sync with head.
 1.4.20.1 16-May-2008  yamt sync with head.
 1.4.18.1 18-May-2008  yamt sync with head.
 1.4.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 11-Dec-2005  christos branches: 1.2.70; 1.2.72; 1.2.74;
merge ktrace-lwp.
 1.1 03-Feb-2004  fredb branches: 1.1.4;
Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 03-Feb-2004  skrll file cyberreg.h was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.2.74.1 16-May-2008  yamt sync with head.
 1.2.72.1 18-May-2008  yamt sync with head.
 1.2.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 11-Dec-2005  christos branches: 1.2.70; 1.2.72; 1.2.74;
merge ktrace-lwp.
 1.1 03-Feb-2004  fredb branches: 1.1.4;
Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 03-Feb-2004  skrll file cybervar.h was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.2.74.1 16-May-2008  yamt sync with head.
 1.2.72.1 18-May-2008  yamt sync with head.
 1.2.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.32 20-Oct-2017  jdolecek move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.31 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.30 07-Oct-2013  jakllsch branches: 1.30.18;
Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.29 31-Jul-2012  bouyer branches: 1.29.2; 1.29.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.28 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.27 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.26 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.25 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.24 04-Apr-2011  dyoung branches: 1.24.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.23 05-Nov-2010  jakllsch branches: 1.23.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.22 19-Oct-2009  bouyer branches: 1.22.2; 1.22.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.21 18-Mar-2008  cube branches: 1.21.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.20 09-Feb-2007  ad branches: 1.20.20; 1.20.36; 1.20.40;
Merge newlock2 to head.
 1.19 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 16-Jan-2006  bouyer branches: 1.17.18; 1.17.20;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.16 11-Dec-2005  christos branches: 1.16.2;
merge ktrace-lwp.
 1.15 24-May-2005  lukem branches: 1.15.2;
add __KERNEL_RCSID
 1.14 27-Feb-2005  perry nuke trailing whitespace
 1.13 20-Aug-2004  thorpej branches: 1.13.4; 1.13.6;
Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.12 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.11 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.10 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.9 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.8 02-Aug-2004  bouyer branches: 1.8.2;
Don't map the interrupt in pciide_mapregs_compat().
In default_chip_map() we'll do further checks to see if the channel should
really be enabled, and in case it's not we would keep the interrupt mapped.
Fix kern/26502 from Christian Biere.
 1.7 03-Jan-2004  thorpej branches: 1.7.2;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.6 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.5 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.4 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.3 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.7.2.1 11-Aug-2004  jmc Pullup rev 1.8 (requested by bouyer in ticket #734)

Don't map the interrupt in pciide_mapregs_compat().
In default_chip_map() we'll do further checks to see if the channel should
really be enabled, and in case it's not we would keep the interrupt mapped.
PR#26502
 1.8.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.8.2.2 03-Aug-2004  skrll Sync with HEAD
 1.8.2.1 02-Aug-2004  skrll file cypide.c was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.13.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.4.1 29-Apr-2005  kent sync with -current
 1.15.2.4 24-Mar-2008  yamt sync with head.
 1.15.2.3 26-Feb-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.2.1 01-Feb-2006  yamt sync with head.
 1.17.20.2 10-Dec-2006  yamt sync with head.
 1.17.20.1 22-Oct-2006  yamt sync with head
 1.17.18.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.17.18.1 18-Nov-2006  ad Sync with head.
 1.20.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.20.36.1 24-Mar-2008  keiichi sync with head.
 1.20.20.1 23-Mar-2008  matt sync with HEAD
 1.21.4.1 11-Mar-2010  yamt sync with head
 1.22.4.2 21-Apr-2011  rmind sync with head
 1.22.4.1 05-Mar-2011  rmind sync with head
 1.22.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.4.1 30-Oct-2012  yamt sync with head
 1.29.4.1 18-May-2014  rmind sync with head
 1.29.2.3 03-Dec-2017  jdolecek update from HEAD
 1.29.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.30.18.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.66 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.65 26-Oct-2022  riastradh cz(4): Convert to ttylock/ttyunlock.
 1.64 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.63 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.62 07-Jul-2016  msaitoh branches: 1.62.16; 1.62.18;
KNF. Remove extra spaces. No functional change.
 1.61 15-Nov-2014  christos branches: 1.61.2;
centralize the dialout/call unit macros.
 1.60 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.59 29-Mar-2014  christos branches: 1.59.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.58 16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.57 12-Sep-2013  martin Eliminate an unused variable - someone with docs and test hardware please
check the XXX introduced.
 1.56 27-Oct-2012  chs branches: 1.56.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.55 24-Apr-2011  rmind branches: 1.55.4; 1.55.14;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.54 26-Jul-2010  jym branches: 1.54.2;
Add PAE to ALL kernel, so that most paddr_t format string errors get caught
during compilation.

While here, fix the compilation for ALL.
 1.53 26-Nov-2009  njoly branches: 1.53.2; 1.53.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.52 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.51 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.50 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.49 08-Jun-2008  tsutsui branches: 1.49.12;
Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
 1.48 10-Apr-2008  cegger branches: 1.48.2; 1.48.4; 1.48.6;
use aprint_*_dev and device_xname
 1.47 19-Nov-2007  ad branches: 1.47.14;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.46 12-Nov-2007  ad Call ttwakeup() with tty_lock held.
 1.45 09-Jul-2007  ad branches: 1.45.6; 1.45.8; 1.45.12; 1.45.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.44 08-May-2007  garbled Add a missing brace in cztty_receive inside a ifdef HOSTRAMCODE. This
would randomly cause internal compiler errors while compiling pmppc.
 1.43 04-Mar-2007  christos branches: 1.43.2; 1.43.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.42 16-Nov-2006  christos branches: 1.42.4;
__unused removal on arguments; approved by core.
 1.41 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.40 01-Oct-2006  elad More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.39 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN, batch #2 from Matt Fleming, thanks!

Also, add forgotten splx() calls in some places.
 1.38 21-Jul-2006  ad branches: 1.38.4; 1.38.6;
- Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.37 14-May-2006  elad integrate kauth.
 1.36 28-Mar-2006  thorpej Use device_unit().
 1.35 05-Mar-2006  christos branches: 1.35.2; 1.35.4;
cleanup more SET/CLR/ISSET lossage
 1.34 11-Dec-2005  christos branches: 1.34.4; 1.34.6; 1.34.8;
merge ktrace-lwp.
 1.33 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.32 28-Jun-2005  thorpej branches: 1.32.2;
Use ANSI function decls and static.
 1.31 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.30 27-Feb-2005  perry nuke trailing whitespace
 1.29 27-Oct-2003  chs branches: 1.29.8; 1.29.10;
uninitialized variables
 1.28 29-Jun-2003  fvdl branches: 1.28.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.27 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.26 05-Feb-2003  perry "Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.25 31-Jan-2003  thorpej Use aprint_*().
 1.24 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.23 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.22 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.21 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.19 17-Mar-2002  atatat branches: 1.19.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.18 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.17 13-Nov-2001  lukem add RCSID
 1.16 02-May-2001  scw branches: 1.16.2; 1.16.4;
Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.15 20-Jan-2001  thorpej branches: 1.15.2;
Use device_lookup() in cztty_getttysoftc().
 1.14 20-Jan-2001  thorpej Garbage-collect some unused macros.
 1.13 20-Jan-2001  thorpej Don't deref NULL when searching for the correct board.
 1.12 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.11 02-Nov-2000  eeh branches: 1.11.2;
Adapt to the new line discipline scheme.
 1.10 28-Jul-2000  thorpej Handle booting without a serial expander box connected.
 1.9 14-Jun-2000  thorpej Make sure we use firmware->host communication channel in cz_intr(), from
Bill Studenmund.
 1.8 09-Jun-2000  wrstuden Adapt to going back to decemal device numbering.
 1.7 09-Jun-2000  wrstuden Rather than assinging 64 tty's per pci card, assign tty's as found.
Cyclades says driver should work with up to 128 tty's per pci card
even though they only support 64 now. Also matches FreeBSD behavior.

Print located tty's using new tty naming scheme - ttyCZ?? where ?? are
two hex letters.

Make firmware load on macppc - one le32toh() was missing.
 1.6 24-May-2000  thorpej branches: 1.6.2;
Update from Bill Studenmund <wrstuden@zembu.com>:
- Note that the FreeBSD driver distributed by Cyclades served as
documentation on how the board works.
- Use the wait-until-pending-I/O-completes-before-loading-parameters
command in czttyparam().
- Pass BREAKs up to the tty later properly.
- Garbage-collect some debugging code.
 1.5 23-May-2000  thorpej Typo in previous.
 1.4 23-May-2000  thorpej Update from Bill Studenmund <wrstuden@zembu.com>:

Correctly send and receive BREAKs -- still needs to do something
intelligent with them. Some additional debugging goo.
 1.3 19-May-2000  thorpej In tiocm_to_cztty(), use SET() instead of CLR() in the
TIOCMBIS case. "Oops!"
 1.2 18-May-2000  thorpej Fix an inverted test.
 1.1 17-May-2000  thorpej Add a device driver for the Cyclades-Z series of intelligent multi-port
serial boards. Written by Jason R. Thorpe and Bill Studenmund.
 1.6.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.11.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.11.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.11.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.2.1 02-Nov-2000  bouyer file cz.c was added on branch thorpej_scsipi on 2000-11-20 11:42:17 +0000
 1.15.2.7 11-Nov-2002  nathanw Catch up to -current
 1.15.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.15.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.15.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.15.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.15.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.16.4.3 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.16.4.2 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.16.4.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.16.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.16.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.16.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.16.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.4.1 16-May-2002  gehenna Add the character device switch.
Replace the local major search function with devsw API.
 1.28.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.28.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.28.2.2 03-Aug-2004  skrll Sync with HEAD
 1.28.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.29.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.29.8.1 29-Apr-2005  kent sync with -current
 1.32.2.5 07-Dec-2007  yamt sync with head
 1.32.2.4 15-Nov-2007  yamt sync with head.
 1.32.2.3 03-Sep-2007  yamt sync with head.
 1.32.2.2 30-Dec-2006  yamt sync with head.
 1.32.2.1 21-Jun-2006  yamt sync with head.
 1.34.8.4 11-Aug-2006  yamt sync with head
 1.34.8.3 24-May-2006  yamt sync with head.
 1.34.8.2 01-Apr-2006  yamt sync with head.
 1.34.8.1 13-Mar-2006  yamt sync with head.
 1.34.6.2 01-Jun-2006  kardel Sync with head.
 1.34.6.1 22-Apr-2006  simonb Sync with head.
 1.34.4.1 09-Sep-2006  rpaulo sync with head
 1.35.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.35.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.35.2.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.35.2.3 19-Apr-2006  elad sync with head.
 1.35.2.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.35.2.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.38.6.2 10-Dec-2006  yamt sync with head.
 1.38.6.1 22-Oct-2006  yamt sync with head
 1.38.4.1 18-Nov-2006  ad Sync with head.
 1.42.4.2 17-May-2007  yamt sync with head.
 1.42.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.43.4.1 11-Jul-2007  mjf Sync with head.
 1.43.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.43.2.1 27-May-2007  ad Sync with head.
 1.45.14.2 08-Dec-2007  mjf Sync with HEAD.
 1.45.14.1 19-Nov-2007  mjf Sync with HEAD.
 1.45.12.2 21-Nov-2007  bouyer Sync with HEAD
 1.45.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.45.8.1 09-Jan-2008  matt sync with HEAD
 1.45.6.2 21-Nov-2007  joerg Sync with HEAD.
 1.45.6.1 14-Nov-2007  joerg Sync with HEAD.
 1.47.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.47.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.48.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.4.4 11-Aug-2010  yamt sync with head.
 1.48.4.3 11-Mar-2010  yamt sync with head
 1.48.4.2 16-May-2009  yamt sync with head
 1.48.4.1 04-May-2009  yamt sync with head.
 1.48.2.1 17-Jun-2008  yamt sync with head.
 1.49.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.4.2 31-May-2011  rmind sync with head
 1.53.4.1 05-Mar-2011  rmind sync with head
 1.53.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.54.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.55.14.3 03-Dec-2017  jdolecek update from HEAD
 1.55.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.55.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.55.4.1 30-Oct-2012  yamt sync with head
 1.56.2.1 18-May-2014  rmind sync with head
 1.59.2.1 10-Aug-2014  tls Rebase.
 1.61.2.1 09-Jul-2016  skrll Sync with HEAD
 1.62.18.1 10-Jun-2019  christos Sync with HEAD
 1.62.16.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.62.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.3 11-Jul-2015  kamil Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.2 25-Dec-2007  perry branches: 1.2.54; 1.2.74;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.1 17-May-2000  thorpej branches: 1.1.6; 1.1.46; 1.1.104; 1.1.110; 1.1.114; 1.1.118;
Add a device driver for the Cyclades-Z series of intelligent multi-port
serial boards. Written by Jason R. Thorpe and Bill Studenmund.
 1.1.118.1 02-Jan-2008  bouyer Sync with HEAD
 1.1.114.1 26-Dec-2007  ad Sync with head.
 1.1.110.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.104.1 09-Jan-2008  matt sync with HEAD
 1.1.46.1 21-Jan-2008  yamt sync with head
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 17-May-2000  bouyer file czreg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:18 +0000
 1.2.74.1 22-Sep-2015  skrll Sync with HEAD
 1.2.54.1 03-Dec-2017  jdolecek update from HEAD
 1.14 21-Sep-2014  christos Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.13 17-Nov-2008  matt branches: 1.13.26;
Store pcidevs in a more compact manner. Instead of many string with duplicate
words, store each word individual in a long string and then store offsets
in the string to that word. This reduces the space needed by half.
 1.12 11-Dec-2005  christos branches: 1.12.70; 1.12.74; 1.12.80; 1.12.84;
merge ktrace-lwp.
 1.11 28-Jun-2005  thorpej static'ify pci_vendors[] and pci_products[]
 1.10 27-Feb-2005  perry don't leave whitespace at the end of $ stripped RCS Ids
don't put unneeded tabs at the end of a line
 1.9 02-Aug-2004  mycroft branches: 1.9.4; 1.9.6;
For the PCIVERBOSE case, separate vendors and products into separate tables.
Eliminating redundant pointers in the tables saves nearly 20K (20% of the table
size). In the process, add a pci_findproduct() and make that and
pci_findvendor() return a "const char *".
 1.8 15-Dec-2003  jmc Fixes from PR#23177. Various lint/logic fixes:
Fix some non-initialized variables
close the output files when done
Redo the printing for RCS strings so they don't expand in the awk script too
Do proper tests for variables existance before accessing

Verified output from all scripts is identical to original versions
 1.7 05-Dec-2003  grant remove some extraneous \'s to shut up warning from gawk.
 1.6 18-Jan-2001  jdolecek branches: 1.6.24;
make pci_knowndevs[] const
 1.5 09-Jan-1998  thorpej branches: 1.5.14;
Put RCS IDs into generated files, in the correct place.
 1.4 08-Jan-1998  thorpej Back out RCD ID related changes.
 1.3 05-Jan-1998  perry make script insert RCS ids into generated files
 1.2 22-Jan-1996  cgd update PCIVERBOSE code in various ways:
(1) remove the 'UNSUPP' keyword from the device list,
because it can't be reasonably used (becuase different
devices may be supported on different machines, for
good reason).
(2) enhance pci_devinfo so that class/subclass information
is optional (so pci_devinfo can be used by drivers that
match classes of devices, and want to look up the
devices' names easily).
(3) more known vendors and devices.
 1.1 18-Jun-1995  cgd learn about some PCI vendor and product numbers. not yet used
 1.5.14.1 11-Feb-2001  bouyer Sync with HEAD.
 1.6.24.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.24.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.4.1 29-Apr-2005  kent sync with -current
 1.12.84.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.80.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.12.74.1 04-May-2009  yamt sync with head.
 1.12.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.13.26.1 03-Dec-2017  jdolecek update from HEAD
 1.28 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.27 29-Mar-2014  christos branches: 1.27.28; 1.27.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.26 27-Oct-2012  chs branches: 1.26.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.25 26-Nov-2009  njoly branches: 1.25.12; 1.25.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.24 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.23 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.22 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.21 10-Apr-2008  cegger branches: 1.21.4; 1.21.18;
use aprint_*_dev and device_xname
 1.20 19-Oct-2007  ad branches: 1.20.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.19 16-Nov-2006  christos branches: 1.19.8; 1.19.22; 1.19.24; 1.19.28;
__unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 11-Dec-2005  christos branches: 1.17.20; 1.17.22;
merge ktrace-lwp.
 1.16 27-Feb-2005  perry branches: 1.16.4;
nuke trailing whitespace
 1.15 04-Dec-2003  keihan branches: 1.15.8; 1.15.10;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.14 31-Jan-2003  thorpej branches: 1.14.2;
Use aprint_*().
 1.13 07-Dec-2002  ad Implement the DPT EATA ioctl() interface.
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 13-Nov-2001  lukem branches: 1.9.10;
add RCSID
 1.8 25-Apr-2001  bouyer branches: 1.8.2;
Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.7 28-Dec-2000  sommerfeld branches: 1.7.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.6 13-Jun-2000  ad Use my proper name.
 1.5 25-Feb-2000  ad branches: 1.5.2;
Cosmetic change.
 1.4 18-Jan-2000  ad Fix register offset problem. This should make EISA boards work correctly,
and is also needed for the ISA frontend (some time this week).
 1.3 05-Jan-2000  ad branches: 1.3.2;
Spelling.
 1.2 29-Sep-1999  ad branches: 1.2.2;
- Move initial reset code into dpt_readcfg()
- Bus specific front-end is now responsible for reading EATA configuration
- EATA configuration data is now saved in the softc
- Make synchronous writes work properly
- Don't ignore HBA timeouts in dpt_cmd()
- Prefix eata_cfg's members with `ec_', not `dc_'
 1.1 27-Sep-1999  ad A driver for DPT EATA SCSI adapters. dpt.c contains a brief TODO list.
 1.2.2.3 01-Apr-2001  ad - Make this work.
- Restructure a bit.
- KNF, const.
 1.2.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.3 18-Jan-2000  he Pull up revision 1.4 (requested by ad):
Fix register offset problem to make EISA boards work correctly.
 1.3.2.2 17-Jan-2000  he Pull up revisions 1.1-1.3 (requested by ad):
Add driver for DPT SmartCache and SmartRAID III or IV SCSI
adapters.
 1.3.2.1 05-Jan-2000  he file dpt_pci.c was added on branch netbsd-1-4 on 2000-01-17 18:35:41 +0000
 1.5.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.7.2.4 11-Dec-2002  thorpej Sync with HEAD.
 1.7.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.10.1 12-Dec-2002  he Pull up revision 1.13 (requested by ad in ticket #1031):
Implement DPT EATA ioctl interface.
 1.14.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.16.4.2 27-Oct-2007  yamt sync with head.
 1.16.4.1 30-Dec-2006  yamt sync with head.
 1.17.22.2 10-Dec-2006  yamt sync with head.
 1.17.22.1 22-Oct-2006  yamt sync with head
 1.17.20.1 18-Nov-2006  ad Sync with head.
 1.19.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.19.24.1 06-Nov-2007  matt sync with HEAD
 1.19.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.19.8.1 23-Oct-2007  ad Sync with head.
 1.20.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.21.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.4.2 11-Mar-2010  yamt sync with head
 1.21.4.1 16-May-2009  yamt sync with head
 1.25.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.25.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.12.1 30-Oct-2012  yamt sync with head
 1.26.2.1 18-May-2014  rmind sync with head
 1.27.30.1 10-Jun-2019  christos Sync with HEAD
 1.27.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.103 17-May-2024  nia eap(4): Restore the full set of supported hardware encodings from netbsd-7

Tested in QEMU.
 1.102 25-Jul-2019  msaitoh branches: 1.102.2; 1.102.28;
Make register address unsigned to avoid undefined behavior. Found by KUBSan.
 1.101 08-Jun-2019  isaki Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.100 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.99 16-Mar-2019  isaki branches: 1.99.2;
Use C99 style struct initializer to audio_hw_if.
 1.98 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.97 01-Jun-2017  chs branches: 1.97.8; 1.97.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.96 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.95 29-Mar-2014  christos branches: 1.95.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.94 24-Nov-2011  mrg branches: 1.94.8; 1.94.12;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.93 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.92 28-Apr-2008  martin branches: 1.92.12; 1.92.34; 1.92.36;
Remove clause 3 and 4 from TNF licenses
 1.91 04-Mar-2008  cube branches: 1.91.2; 1.91.4;
Split device_t/softc, and other related cosmetic changes.
 1.90 19-Oct-2007  ad branches: 1.90.12; 1.90.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.89 04-Mar-2007  christos branches: 1.89.2; 1.89.14; 1.89.16; 1.89.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.88 16-Nov-2006  christos branches: 1.88.4; 1.88.6;
__unused removal on arguments; approved by core.
 1.87 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.86 30-Aug-2006  christos branches: 1.86.2; 1.86.4;
fix incomplete initializers
 1.85 01-Jul-2006  chap Correct build failures when MIDI is not enabled (the idea!).

Specifically eap but no midi, which makes sense if you want sound,
and umidi but no midi, which makes little sense but shouldn't fail the
build.

Suggest changing the evbarm conf files containing umidi but #midi
to comment out umidi as well (even though this fix should let them build).
 1.84 30-Jun-2006  chap Ankh-Morpork, we have a MIDI driver....

Merge from chap-midi branch, after
~month for review
Comments by thorpej@ drochner@ and Alexandre Ratchov

Incorporated: points by thorpej@ drochner@; preliminary support for
a stats-collecting ioctl suggested by martin@ from comments by A.R.

PR kern/32441 kern/32442 kern/32567 kern/32588 kern/32694 kern/33590
kern/33614 and one instance of kern/32651

ok martin@
 1.83 13-Jun-2006  rpaulo branches: 1.83.2;
Initialize the mixer delta value to 8 for the 1370 version. No
objections in tech-kern.
 1.82 10-Jun-2006  rpaulo KNF.
 1.81 24-Dec-2005  perry branches: 1.81.4; 1.81.8; 1.81.14;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.80 11-Dec-2005  christos merge ktrace-lwp.
 1.79 28-Jun-2005  thorpej branches: 1.79.2;
Use ANSI function decls and static.
 1.78 27-Feb-2005  perry nuke trailing whitespace
 1.77 13-Feb-2005  fredb "output.source" on the Ensoniq 1371 really should be "input.source". Making
it so lets the audio(4) interface -- play.port and play.gain -- attach
properly. Analysis and patch provided by Joachim Kuebart in PR kern/29178.
 1.76 15-Jan-2005  kent branches: 1.76.2; 1.76.4;
ansify and KNF
 1.75 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.74 09-Nov-2004  kent branches: 1.74.2;
remove mixer setting code in *_attach() because ac97_attach() does it.
 1.73 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.72 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.71 03-Aug-2004  drochner Check return values of config_detach() for child devices and abort
our own detach() on errors.
 1.70 09-Jul-2004  mycroft Clean up. Attempt to make these safer against stray interrupts.
 1.69 08-Jul-2004  drochner support the game port on eap1371
This is only usable with some caution because these soundcards only
allow to map IO port 0x20x for this, thus bypassing PCI address
management. Very likely this will only work on primary PCI buses, and there
is some potential for conflicts with ISA devices as well.
(XXX cannot be detached because the "joy" driver doesn't support it yet)
 1.68 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.67 04-Dec-2003  keihan branches: 1.67.2;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.66 03-May-2003  wiz branches: 1.66.2;
DMA, not dma nor Dma.
 1.65 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.64 31-Jan-2003  thorpej Use aprint_*().
 1.63 14-Jan-2003  mrg add detach support
 1.62 26-Dec-2002  pooka For the ES1370 do "best effort" rate selection for the FM DAC. The
card contains only one clock, which is already used by the other
DAC. The FM DAC can handle a few fixed-frequency choices.

thanks to Matthew Green for testing
 1.61 14-Dec-2002  pooka Silly me for assuming that the CT5880 cards could be identified by looking
at which ones had the Product ID CT5880. Try to get the checks right now.

Also add ES1373_8 to the list.
 1.60 05-Dec-2002  pooka Recognize a few more CT5880 chips. Only cosmetic, does not
affect functionality.
 1.59 30-Nov-2002  pooka Don't use tsleep() in attach, use delay()

This change makes the driver work properly for the following card,
which used to function a bit weird:

eap0 at pci0 dev 10 function 0: Ensoniq CT5880 CT5880C (rev. 0x02)
eap0: interrupting at irq 9
eap0: TriTech TR28602 codec; no 3D stereo
 1.58 24-Nov-2002  scw Fix uninitialised variable warnings.
 1.57 14-Nov-2002  gson eap.c 1.54 changed ES1371 specific code but failed to make the
corresponding cases to the ES1370 case, causing a panic when
attaching an ES1370.
 1.56 11-Nov-2002  pooka rename EAP_EN() to the more descriptive EAP_DAC_EN(), and
use it everywhere.
 1.55 07-Nov-2002  thorpej Don't use newlines in string literals.
 1.54 04-Nov-2002  pooka add support for the second DAC found on the chip. to attach the second
audio device, define EAP_USE_BOTH_DACS
 1.53 10-Oct-2002  pooka make a few debug printf's match reality
 1.52 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.51 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.50 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.49 04-Jul-2002  gson Mask MCCB interrupts since they are not currently handled
and it is not clear how they should be handled. Fixes
kern/17071.
 1.48 13-Nov-2001  lukem branches: 1.48.8; 1.48.10;
add RCSID
 1.47 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.46 03-Sep-2001  reinoud branches: 1.46.2;
Fixed compiling error when AUDIO_DEBUG was switched on ...
 1.45 24-Apr-2001  mycroft branches: 1.45.2;
It appears there's a race condition when disabling a channel that causes us to
need to explicitly relatch the interrupt when firing it up again. So, in the
trigger routines, explicitly disable and reenable the interrupt to relatch it,
like we do in the interrupt routine.

Also clean up some broken loop overrun checks.

My ES1371 seems to be more reliable now, but I'm not going to pretend to fully
understand this chip.
 1.44 27-Jan-2001  augustss branches: 1.44.2;
ANSIfy.
 1.43 27-Jan-2001  augustss Sleep a little when closing the midi device to allow the UART to drain.
 1.42 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.41 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.40 01-Jun-2000  augustss branches: 1.40.2;
Update URLs.
 1.39 15-May-2000  thorpej branches: 1.39.2;
ac97.h -> ac97var.h
 1.38 01-May-2000  augustss Change the way the codec is access to mimic how Linux&FreeBSD does it.
 1.37 30-Apr-2000  augustss Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.36 24-Apr-2000  augustss Move a test if the MIDI is open outside a loop in the interrupt routine.
Some stylistic changes.
 1.35 19-Mar-2000  soren Make it a bit more clear which functions are specific to which models.
Split off register definitions into eapreg.h.
Remove duplicate codec reset.
 1.34 11-Mar-2000  soren The shortened 1371 reset delay in revision 1.32 doesn't seem to be
quite enough for my 1373, so increase it some.
 1.33 06-Mar-2000  perry Make Creative Soundblaster PCI 128's work -- from Masahiro Ishiyama
Note that on device close, there's a sharp pop that probably should be fixed.

Note also that the device is hanging the machine at times for brief
periods inside audio.c::audiogetinfo(), but I haven't yet figured out
why.
 1.32 02-Nov-1999  augustss Shorten some delay()s. From WITEK Wnuk <witek@atari.org>
 1.31 02-Nov-1999  soren Fix crash when both 1370 and 1371/1373 devices are configured.
Update documentation links.
XXX The initial volume of the 1371 mixers is set to 255. Should be ~200.
 1.30 01-Nov-1999  augustss Make little endian and big endian version of all functions
that deal with 16 bit samples. Let the drivers decide which ones
to use.
 1.29 29-Oct-1999  augustss Add MIDI support.
Closes PR 8578.
 1.28 27-Oct-1999  augustss Add support for ES1371. From OpenBSD and Ezra Story <ezy@panix.com>.
 1.27 01-Sep-1999  kleink branches: 1.27.2; 1.27.4; 1.27.6;
Don't make a human-readable device description being printed at attach time
depend on PCIVERBOSE.
 1.26 10-Jul-1999  kleink Fix a buglet in the driver's DMA buffer list ipmlementation, causing the next-
in-list (wrong) descriptor structure of the buffer in question to be freed.
 1.25 18-Feb-1999  mycroft branches: 1.25.4;
Pass the correct address (PCI bus address, not PA) to the card.
Works on an Alpha now.
 1.24 18-Feb-1999  mycroft Minor code munging.
 1.23 17-Feb-1999  mycroft Fix a silly type.
 1.22 17-Feb-1999  mycroft Update comments.
 1.21 17-Feb-1999  mycroft Pass the direction to the allocm and round_buffersize methods.
Some drivers need this to properly allocate DMAable memory.
 1.20 08-Jan-1999  augustss Fix more `void *' arithmetic.
 1.19 25-Nov-1998  augustss Make the copyright header conform to the NetBSD template.
 1.18 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


XXX XXX XXX
the d_mmap cdev routine should be changed to have a prototype like:
paddr_t (*d_mmap) __P((dev_t, off_t, int));

by someone!
 1.17 25-Aug-1998  thorpej Add some braces to make egcs happy.
 1.16 17-Aug-1998  augustss * Redo the way the way the MIDI driver attaches to audio devices.
* Improve the midisyn layer a little.
* Add a driver for the Yamaha OPL[23] FM synths.
The opl driver is not finished yet; it sounds pretty awful.

For some strange reason I cannot get any FM sound from my SB64 cards,
but a regular SB16 works fine.
 1.15 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.14 12-Aug-1998  mycroft Associate the preamp with the mic volume in the input class.
 1.13 12-Aug-1998  mycroft Oops; fix typos.
 1.12 12-Aug-1998  mycroft Add a knob to enable/disable the mic preamp.
 1.11 10-Aug-1998  mycroft For consistency, only do the rate coupling in full-duplex mode.
 1.10 09-Aug-1998  mycroft Minor cleanup to debugging cruft.
 1.9 09-Aug-1998  mycroft Several things:
* Use the new trigger_{in,out}put interface.
* Allow the play and record channels to have different encodings (but the
same sample rate).
* Play u-law and a-law as 16-bit data. (This may not work yet...)
 1.8 06-Jul-1998  augustss Add mixer output selection.
From gson@araneus.fi (Andreas Gustafsson)
 1.7 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.6 26-May-1998  augustss Fix a recording problem that occurs when the EAP chip sends its
interrupt just BEFORE the dma has finished rather than after.
 1.5 06-May-1998  augustss Remove some lint.
 1.4 02-May-1998  mycroft Adjust PCLKDIV by 2 to correct the output sample rate. (Unfortunately, this
isn't documented.)
Fix typo in mappage routine.
 1.3 02-May-1998  mycroft Oops; fix typo.
 1.2 02-May-1998  mycroft Fix reading of the master volume, and a hack that seems to make stereo output
work correctly. (Will check the documentation as soon as I can read it.)
 1.1 01-May-1998  augustss Add a driver for the Ensoniq AudioPCI sound card. The driver still
needs some testing, but it seems to produce sound. The driver was written
by me, but since I don't have the hardware the debugging and testing was
done by Andreas Gustafsson <gson@araneus.fi>, Chuck Cranor
<chuck@maria.wustl.edu>, and Phil Nelson <phil@cs.wwu.edu>. Thanks.
 1.25.4.1 02-Aug-1999  thorpej Update from trunk.
 1.27.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.27.4.1 15-Nov-1999  fvdl Sync with -current
 1.27.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.27.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.27.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.39.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.40.2.2 01-May-2001  he Pull up revision 1.45 (requested by hubertf):
Work around race condition by relatching the interrupt. Makes
the eap driver not hang on certain occasions.
 1.40.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.44.2.11 15-Jan-2003  thorpej Sync with HEAD.
 1.44.2.10 29-Dec-2002  thorpej Sync with HEAD.
 1.44.2.9 19-Dec-2002  thorpej Sync with HEAD.
 1.44.2.8 11-Dec-2002  thorpej Sync with HEAD.
 1.44.2.7 11-Nov-2002  nathanw Catch up to -current
 1.44.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.44.2.5 01-Aug-2002  nathanw Catch up to -current.
 1.44.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.44.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.44.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.44.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.45.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.45.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.45.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.45.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.46.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.48.10.1 15-Dec-2002  he Pull up revision 1.59 (requested by pooka in ticket #1035):
Don't use tsleep() in attach, use delay(). Makes the driver
work properly with ``Ensoniq CT5880''-based audio card.
 1.48.8.1 15-Jul-2002  gehenna catch up with -current.
 1.66.2.11 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.66.2.10 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.66.2.9 15-Feb-2005  skrll Sync with HEAD.
 1.66.2.8 17-Jan-2005  skrll Sync with HEAD.
 1.66.2.7 14-Nov-2004  skrll Sync with HEAD.
 1.66.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.66.2.5 24-Sep-2004  skrll Sync with HEAD.
 1.66.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.66.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.66.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.66.2.1 03-Aug-2004  skrll Sync with HEAD
 1.67.2.1 22-Sep-2004  jmc Pullup rev 1.72 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.74.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.74.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.76.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.76.2.1 29-Apr-2005  kent sync with -current
 1.79.2.5 17-Mar-2008  yamt sync with head.
 1.79.2.4 27-Oct-2007  yamt sync with head.
 1.79.2.3 03-Sep-2007  yamt sync with head.
 1.79.2.2 30-Dec-2006  yamt sync with head.
 1.79.2.1 21-Jun-2006  yamt sync with head.
 1.81.14.2 19-Jun-2006  chap Sync with head.
 1.81.14.1 18-Jun-2006  chap Updates PR kern/32651

The eap driver now makes use of the MIDI UART tx interrupt available on
the Ensoniq chips. A test with nominally 20 seconds of continuous transmit
data went from 26 s real / 25 s system to 22 s real / 0.16 s system.
Implementation is quite simple, and anyone who knows any of the other
MIDI UART chips well enough to get a tx interrupt out of it would do a
world of good by updating their drivers similarly.

Anyway, scratch one off the kern/32651 todo list.

Also added a documentation reference to the ES1373 datasheet, and added
more 1371- and 1373-specific #defines in eapreg.h. Enough there now that
anyone who wanted to play with the S/PDIF capability on the 1373 could
begin to do that.
 1.81.8.3 03-Sep-2006  yamt sync with head.
 1.81.8.2 11-Aug-2006  yamt sync with head
 1.81.8.1 26-Jun-2006  yamt sync with head.
 1.81.4.1 09-Sep-2006  rpaulo sync with head
 1.83.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.86.4.2 10-Dec-2006  yamt sync with head.
 1.86.4.1 22-Oct-2006  yamt sync with head
 1.86.2.1 18-Nov-2006  ad Sync with head.
 1.88.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.88.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.89.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.89.16.2 23-Mar-2008  matt sync with HEAD
 1.89.16.1 06-Nov-2007  matt sync with HEAD
 1.89.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.89.2.1 23-Oct-2007  ad Sync with head.
 1.90.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.90.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.90.12.1 24-Mar-2008  keiichi sync with head.
 1.91.4.1 16-May-2008  yamt sync with head.
 1.91.2.1 18-May-2008  yamt sync with head.
 1.92.36.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.92.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.92.34.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.92.34.1 17-Apr-2012  yamt sync with head
 1.92.12.5 12-Dec-2008  ad Checkpoint work in progress.
 1.92.12.4 11-Dec-2008  ad Checkpoint work in progress.
 1.92.12.3 09-Dec-2008  ad Checkpoint work on MIDI.
 1.92.12.2 08-Dec-2008  ad Death to NOWAIT.
 1.92.12.1 07-Dec-2008  ad Ressurect the ad-audiomp branch at request of matt@.

With this commit:

- core audio subsystem made MPSAFE
- eap, btsco drivers made MPSAFE

TODO:

- midi
- convert remaining drivers
 1.94.12.1 18-May-2014  rmind sync with head
 1.94.8.2 03-Dec-2017  jdolecek update from HEAD
 1.94.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.95.6.2 28-Aug-2017  skrll Sync with HEAD
 1.95.6.1 09-Jul-2016  skrll Sync with HEAD
 1.97.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.97.10.1 10-Jun-2019  christos Sync with HEAD
 1.97.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.99.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.99.2.3 30-Apr-2019  isaki More adapt to audio2.
- Use set_format.
- Remove an empty method.
- XXX DAC1 and secondary audio device support should be removed.
Now mixing two (or more) sources is done by audio layer.
 1.99.2.2 21-Apr-2019  isaki Adapt to audio2.
- Drop INDEPENDENT property from es1370 which has only one clock.
 1.99.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.102.28.1 17-Jun-2024  martin Pull up following revision(s) (requested by nia in ticket #697):

sys/dev/pci/eap.c: revision 1.103

eap(4): Restore the full set of supported hardware encodings from netbsd-7

Tested in QEMU.
 1.102.2.1 17-Jun-2024  martin Pull up following revision(s) (requested by nia in ticket #1843):

sys/dev/pci/eap.c: revision 1.103

eap(4): Restore the full set of supported hardware encodings from netbsd-7

Tested in QEMU.
 1.14 21-May-2024  nia eap(4): re-organize mixer controls to put classes first

some software (understandably) doesn't like it if you declare a
mixer node's child before the parent, notably ossxmix in pkgsrc
 1.13 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.12 30-Jun-2006  chap branches: 1.12.54; 1.12.56; 1.12.58;
Ankh-Morpork, we have a MIDI driver....

Merge from chap-midi branch, after
~month for review
Comments by thorpej@ drochner@ and Alexandre Ratchov

Incorporated: points by thorpej@ drochner@; preliminary support for
a stats-collecting ioctl suggested by martin@ from comments by A.R.

PR kern/32441 kern/32442 kern/32567 kern/32588 kern/32694 kern/33590
kern/33614 and one instance of kern/32651

ok martin@
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.8; 1.11.14; 1.11.16;
merge ktrace-lwp.
 1.10 13-Feb-2005  fredb branches: 1.10.6;
"output.source" on the Ensoniq 1371 really should be "input.source". Making
it so lets the audio(4) interface -- play.port and play.gain -- attach
properly. Analysis and patch provided by Joachim Kuebart in PR kern/29178.
 1.9 15-Jan-2005  kent branches: 1.9.2; 1.9.4;
ansify and KNF
 1.8 08-Jul-2004  drochner support the game port on eap1371
This is only usable with some caution because these soundcards only
allow to map IO port 0x20x for this, thus bypassing PCI address
management. Very likely this will only work on primary PCI buses, and there
is some potential for conflicts with ISA devices as well.
(XXX cannot be detached because the "joy" driver doesn't support it yet)
 1.7 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.6 14-Dec-2002  pooka branches: 1.6.6;
Silly me for assuming that the CT5880 cards could be identified by looking
at which ones had the Product ID CT5880. Try to get the checks right now.

Also add ES1373_8 to the list.
 1.5 05-Dec-2002  pooka Recognize a few more CT5880 chips. Only cosmetic, does not
affect functionality.
 1.4 11-Nov-2002  pooka rename EAP_EN() to the more descriptive EAP_DAC_EN(), and
use it everywhere.
 1.3 04-Nov-2002  pooka add support for the second DAC found on the chip. to attach the second
audio device, define EAP_USE_BOTH_DACS
 1.2 30-Apr-2000  augustss branches: 1.2.6; 1.2.8;
Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.1 19-Mar-2000  soren Make it a bit more clear which functions are specific to which models.
Split off register definitions into eapreg.h.
Remove duplicate codec reset.
 1.2.8.3 19-Dec-2002  thorpej Sync with HEAD.
 1.2.8.2 11-Dec-2002  thorpej Sync with HEAD.
 1.2.8.1 11-Nov-2002  nathanw Catch up to -current
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 30-Apr-2000  bouyer file eapreg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:19 +0000
 1.6.6.5 15-Feb-2005  skrll Sync with HEAD.
 1.6.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.9.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.2.1 29-Apr-2005  kent sync with -current
 1.10.6.1 30-Dec-2006  yamt sync with head.
 1.11.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.11.14.1 18-Jun-2006  chap Updates PR kern/32651

The eap driver now makes use of the MIDI UART tx interrupt available on
the Ensoniq chips. A test with nominally 20 seconds of continuous transmit
data went from 26 s real / 25 s system to 22 s real / 0.16 s system.
Implementation is quite simple, and anyone who knows any of the other
MIDI UART chips well enough to get a tx interrupt out of it would do a
world of good by updating their drivers similarly.

Anyway, scratch one off the kern/32651 todo list.

Also added a documentation reference to the ES1373 datasheet, and added
more 1371- and 1373-specific #defines in eapreg.h. Enough there now that
anyone who wanted to play with the S/PDIF capability on the 1373 could
begin to do that.
 1.11.8.1 11-Aug-2006  yamt sync with head
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.58.1 16-May-2008  yamt sync with head.
 1.12.56.1 18-May-2008  yamt sync with head.
 1.12.54.1 02-Jun-2008  mjf Sync with HEAD.
 1.6 05-Mar-2020  riastradh Revert "Include opt_diagnostic.h for DIAGNOSTIC."

This did not do what I thought it did. opt_diagnostic.h is only for
the unused _DIAGNOSTIC, which seems like an abortive attempt to
incrementally convert DIAGNOSTIC to an opt_*.h option rather than a
command-line option.
 1.5 05-Mar-2020  riastradh Include opt_diagnostic.h for DIAGNOSTIC.

...at least, in header files, which may not have already included
libkern.h.
 1.4 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.3 06-May-2009  cegger branches: 1.3.12; 1.3.14;
struct device * -> device_t, no functional changes intended.
 1.2 11-Dec-2005  christos branches: 1.2.74; 1.2.88; 1.2.90;
merge ktrace-lwp.
 1.1 08-Jul-2004  drochner branches: 1.1.2;
support the game port on eap1371
This is only usable with some caution because these soundcards only
allow to map IO port 0x20x for this, thus bypassing PCI address
management. Very likely this will only work on primary PCI buses, and there
is some potential for conflicts with ISA devices as well.
(XXX cannot be detached because the "joy" driver doesn't support it yet)
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 08-Jul-2004  skrll file eapvar.h was added on branch ktrace-lwp on 2004-08-03 10:49:06 +0000
 1.2.90.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.88.1 12-Dec-2008  ad Checkpoint work in progress.
 1.2.74.1 16-May-2009  yamt sync with head
 1.3.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.3.12.1 17-Apr-2012  yamt sync with head
 1.78 31-Mar-2025  riastradh ehci(4): Sprinkle KERNEL_LOCKED_P and KNF on usb_*_add/rem.

Mark with XXXSMP comments to be fixed later without the kernel lock.

No functional change intended: callers generally do this from
autoconf *_attach/detach routines, which run kernel-locked anyway
(for the moment).

Cleanup in preparation for:

PR port-amd64/59180: System reboots instead of shutting down
 1.77 24-Mar-2024  mrg branches: 1.77.2;
ehci(4): properly handle failed attach

thinkpad a475 fails to attach an ehci instance:

ehci0: pre-2.0 USB rev, device ignored

which ends up stopping suspend/resume working as the device has no
pmf handlers installed. put most of the teardown code into a new
common function that is called from failed attach and detach. if
attach fails, register NULL pmf handlers. don't check the return
value of pmf_device_register*().

re-order several parts of detach to match the reverse attach order.

tested on rockpro64, thinkpad a475, and xps 1645, the a475 can now
suspend/resume almost fully successfully.
 1.76 24-Jan-2023  mlelstv Consistently use cached chipset tag value.
 1.75 28-Oct-2022  riastradh branches: 1.75.2;
ehci(4): Mark PCI interrupt handler MP-safe.

ehci_intr has its own intr lock to coordinate with the MP-safe
softint it defers all its work to, other than reading and writing a
few registers to get and acknowledge the interrupt status.
 1.74 13-Mar-2022  riastradh ehci(4): Serialize access to portsc registers.

Both ehci_roothub_ctrl and ehci_suspend/resume do r/m/w on them, so
use a mutex to serialize access to avoid stomping on each other.
 1.73 22-Dec-2021  skrll Three fixes

- pass the 64bit DMA tag if the HCCPARAMS says ehci supports it and the
64bit DMA tag is available/valid. This should help with the
"cannot create xfer" error on 64bit systems.

- restrict the control structure memory allocation to the low 4GB
(CTRLDSSEGMENT was always set to zero anyway)

- if ehci_init fails then tidyup before returning the error.
 1.72 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.71 24-Apr-2021  thorpej branches: 1.71.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.70 13-Jun-2019  maxv branches: 1.70.12;
Fix the error handling in ehci_pci_attach(): if we got a USB<2 device we
won't call ehci_init(), so don't call ehci_detach() in ehci_pci_detach().

Fixes a panic seen on a recent Lenovo machine, which has an USB 1.1
controller; ehci_detach() was getting called while 'sc' had not been
completely initialized.
 1.69 13-Jun-2019  maxv Random style in ehci, also KM_SLEEP does not fail.
 1.68 25-Oct-2018  jdolecek enable MSI support where available
 1.67 10-May-2018  msaitoh branches: 1.67.2;
KNF. No binary change.
 1.66 09-Apr-2018  jakllsch Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.
 1.65 12-Jun-2017  sborrill branches: 1.65.4;
Deal with broken BIOSes that leave PCI interrupts disabled.

Thanks to nick@
 1.64 13-Oct-2016  jdolecek branches: 1.64.8;
provide intr xname
 1.63 23-Apr-2016  skrll branches: 1.63.2;
Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
 1.62 31-Aug-2015  skrll Improve error handling in attach code. From t-hash.
 1.61 19-Aug-2015  skrll Interrupt handlers aren't MP-safe yet so use IPL_USB which is IPL_VM
which takes the kernel lock.
 1.60 15-Jul-2015  msaitoh Initialize some members little earlier. It's not a bug.
 1.59 21-Sep-2014  christos branches: 1.59.2;
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.58 29-Mar-2014  christos branches: 1.58.4; 1.58.8;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.57 22-Sep-2012  tsutsui branches: 1.57.2;
Fix PR kern/46828 (6.0_BETA2 and 6.0_RC1 won't start on DL320/G5p):
In ehci_get_ownership(), don't explicitly clear EHCI_LEG_HC_BIOS_OWNED
semaphore bit in the driver before asking BIOS to give up ownership.
The EHCI spec implies that the semaphore should not be changed by
the other agent and actually the previous one (introduced in rev 1.53
after 5.x) caused hangup during probe on at least two HP machines
as mentioned in the PR. Analyzed and patch provided by Ryo ONODERA.

Should be pulled up to netbsd-6 (fatal hangup during boot).
 1.56 20-Jul-2012  uwe branches: 1.56.2;
EHCI_USBINTR is 4 bytes wide, use proper access ops.
 1.55 10-Jun-2012  mrg merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.
 1.54 30-Jan-2012  drochner branches: 1.54.2; 1.54.4;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.53 30-Jul-2011  jmcneill branches: 1.53.2; 1.53.6;
ehci_get_ownership: clear BIOS semaphore when setting OS semaphore, slow
down poll rate, and make sure to clear all SMI bits when we're done
 1.52 04-Apr-2011  dyoung Deregister PMF handlers during detachment. Complete the host controller
shutdown.
 1.51 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.50 11-Dec-2010  matt branches: 1.50.2;
Make ehci deal with pci devices that have multiple companion functions and
ehci functions. We can't assume that there will only be one ehci per device.
The existing code could not deal with:

Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured
 1.49 25-May-2010  pgoyette Revert earlier changes to callers of pci_find{vendor,product} since
the original routine entrypoint name has been restored.

Requested by dyoung@ and mrg@
 1.48 24-May-2010  pgoyette Update all callers of the pci_find{vendor,product} routines to now call
these routines through their global pointers.
 1.47 24-Feb-2010  dyoung branches: 1.47.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.46 08-Jan-2010  dyoung branches: 1.46.2;
Expand PMF_FN_* macros.
 1.45 15-Jun-2009  cegger Apply hw workaround required for all SB600 revisions and SB700 revisions
A12 and A13 to avoid USB subsystem hang symptom. The USB subsystem hang
symptom is observed when the system has multiple USB devices connected to it
or one USB device is often re-connected. In some cases a USB hub may be
required to observe this symptom.

This patch works around the problem by correcting the internal register setting
that will help by changing the behavior of the internal logic to avoid the
USB subsystem hang issue. The change in the behavior of the logic does not
impact the normal operation of the USB subsystem.

This fix has been discussed, developped, reviewed, polished up
and tested on current-users by several people. Thread starts at:
http://mail-index.netbsd.org/current-users/2009/05/17/msg009460.html
 1.44 26-Apr-2009  cegger u_intNN_t -> uintNN_t
 1.43 26-Apr-2009  cegger - Fix error handling in attachment
- use aprint_*_dev
 1.42 17-Apr-2009  christos appease gcc
 1.41 17-Apr-2009  dyoung Use device_t instead of 'struct device *' or device_ptr_t. Use cfdata_t
instead of 'struct cfdata *'. Delete some gratuitous parentheses.
 1.40 17-Apr-2009  dyoung Disable interrupts on the h/w before detaching the interrupt
handler. Protects against the problem described in
<http://mail-index.netbsd.org/port-i386/2009/04/10/msg001317.html>,
Xintr_ioapic_levelN jumps to 0 during shutdown.
 1.39 07-Apr-2009  dyoung Detach ehci(4) and uhci(4) at shutdown.
 1.38 28-Apr-2008  martin branches: 1.38.8; 1.38.10; 1.38.14; 1.38.16;
Remove clause 3 and 4 from TNF licenses
 1.37 28-Mar-2008  drochner branches: 1.37.2; 1.37.4;
split device/softc for USB host controllers and the usb (control)
device,
this is hairy stuff, and I've only tested with uhci/ehci at pci,
please test the rest and report problems
 1.36 07-Mar-2008  dyoung Use device_t and accessors. Setup power management in the PCI
front-end (XXX needs to look more alike the Cardbus front-end).
Establish the shutdown hook using PMF.
 1.35 22-Feb-2008  dyoung Add a method to detach child.

Cosmetic: use device_t and accessors. Use aprint_*_dev(). Use
PMF_FN_{ARGS,CALL,PROTO}.
 1.34 28-Jan-2008  jmcneill branches: 1.34.2; 1.34.6;
Release ownership of EHCI to the BIOS when we suspend or detach the
device driver.
 1.33 27-Jan-2008  jmcneill Don't attempt to claim ownership from the BIOS if the OS already holds
the HC OS Owned semaphore. Unconditionally clear SMIs as long as the
USB legacy capability is present.
 1.32 09-Dec-2007  jmcneill Merge jmcneill-pm branch.
 1.31 19-Oct-2007  ad branches: 1.31.2; 1.31.4; 1.31.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.30 04-Aug-2007  tsutsui branches: 1.30.2; 1.30.6; 1.30.8;
ATI's ehci also requires EHCIF_DROPPED_INTR_WORKAROUND. From FreeBSD.
 1.29 01-Aug-2007  christos branches: 1.29.2;
Establish powerhooks in the proper order. From Anon Ymous
 1.28 08-Jul-2007  jmcneill branches: 1.28.2;
If the USB legacy capability flag is not set, we mistakenly attempt to
clear it anyway by writing to PCI configuration register 0x00. Instead,
if this flag is not set, simply bail out from ehci_get_ownership.
 1.27 09-Feb-2007  ad branches: 1.27.6; 1.27.8; 1.27.14;
Merge newlock2 to head.
 1.26 16-Nov-2006  christos branches: 1.26.2; 1.26.4;
__unused removal on arguments; approved by core.
 1.25 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.24 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.23 10-Mar-2006  jmcneill branches: 1.23.10; 1.23.12;
On suspend, capture PCI configuration registers. On resume, restore them
as well as explicitly reclaiming ownership of the UHCI/EHCI from the BIOS.
 1.22 17-Jan-2006  xtraeme branches: 1.22.2; 1.22.4; 1.22.6; 1.22.8;
From OpenBSD:

--
Add a workaround for VIA EHCI controllers which, under load, signal qTD
completion before they have performed writeback from the overlay qTD.

This condition would exhibit itself as a umass stall that never recovers.
--

This fixes the problem reported by Thomas Klausner on current-users@:
http://mail-index.netbsd.org/current-users/2006/01/17/0000.html
 1.21 20-Nov-2005  augustss branches: 1.21.2;
Print an error message if we cannot located the legacy capability.
 1.20 20-Nov-2005  augustss Make debug printout a little nicer.
 1.19 20-Nov-2005  augustss Go through the prescribed process to get ownership of the controller from
BIOS before we start using it.
This seems to fix the problems some people have been experiencing with
keyboards not working.
 1.18 28-Jun-2005  thorpej branches: 1.18.2; 1.18.8;
Use ANSI function decls and static.
 1.17 27-Feb-2005  perry branches: 1.17.2;
nuke trailing whitespace
 1.16 02-Aug-2004  mycroft branches: 1.16.4; 1.16.6;
For the PCIVERBOSE case, separate vendors and products into separate tables.
Eliminating redundant pointers in the tables saves nearly 20K (20% of the table
size). In the process, add a pci_findproduct() and make that and
pci_findvendor() return a "const char *".
 1.15 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.14 22-Apr-2004  itojun sprintf -> snprintf
 1.13 31-Jan-2003  thorpej branches: 1.13.2;
Use aprint_*().
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 22-Aug-2002  augustss Fix an error message.
 1.8 14-Feb-2002  augustss branches: 1.8.8;
Use the correct years for copyright.
 1.7 09-Jan-2002  augustss Split out some code so you can have cardbus ehci without pci.
 1.6 13-Nov-2001  lukem add RCSID
 1.5 10-Nov-2001  augustss Fill the companion controller array.
 1.4 06-Nov-2001  augustss Add some data structures to keep enable finding companion controllers
for EHCI.
 1.3 28-Dec-2000  sommerfeld branches: 1.3.2; 1.3.4; 1.3.6; 1.3.10;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.2 24-Dec-2000  augustss Even stubs need improvements.
 1.1 24-Dec-2000  augustss Add some placeholders for the EHCI (USB 2) driver.

Don't get your hopes up. I've not even finished reading the
(100+) page spec, and I have no hardware.
 1.3.10.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.3.6.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.6.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.3.4.4 27-Aug-2002  nathanw Catch up to -current.
 1.3.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.2 11-Jan-2002  nathanw More catchup.
 1.3.4.1 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.3.2.1 28-Dec-2000  bouyer file ehci_pci.c was added on branch thorpej_scsipi on 2001-01-05 17:36:03 +0000
 1.8.8.1 29-Aug-2002  gehenna catch up with -current.
 1.13.2.6 11-Dec-2005  christos Sync with head.
 1.13.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.16.4.1 29-Apr-2005  kent sync with -current
 1.17.2.2 22-Jan-2006  tron Pull up following revision(s) (requested by xtraeme in ticket #1123):
sys/dev/usb/ehcivar.h: revision 1.23
sys/dev/pci/ehci_pci.c: revision 1.22
sys/dev/usb/ehci.c: revision 1.108
From OpenBSD:

--
Add a workaround for VIA EHCI controllers which, under load, signal qTD
completion before they have performed writeback from the overlay qTD.
This condition would exhibit itself as a umass stall that never
recovers.
--

This fixes the problem reported by Thomas Klausner on current-users@:
http://mail-index.netbsd.org/current-users/2006/01/17/0000.html
 1.17.2.1 07-Dec-2005  riz Pull up following revision(s) (requested by gendalia in ticket #1034):
sys/dev/pci/ehci_pci.c: revisions 1.18-1.21
sys/dev/usb/ehcireg.h: revisions 1.22-1.23
Go through the prescribed process to get ownership of the controller from
BIOS before we start using it.
This seems to fix the problems some people have been experiencing with
keyboards not working.

Pull up additional code formatting, debugging, and a few #defines.
Fixes PR#32249.
 1.18.8.1 22-Nov-2005  yamt sync with head.
 1.18.2.9 17-Mar-2008  yamt sync with head.
 1.18.2.8 27-Feb-2008  yamt sync with head.
 1.18.2.7 04-Feb-2008  yamt sync with head.
 1.18.2.6 21-Jan-2008  yamt sync with head
 1.18.2.5 27-Oct-2007  yamt sync with head.
 1.18.2.4 03-Sep-2007  yamt sync with head.
 1.18.2.3 26-Feb-2007  yamt sync with head.
 1.18.2.2 30-Dec-2006  yamt sync with head.
 1.18.2.1 21-Jun-2006  yamt sync with head.
 1.21.2.1 01-Feb-2006  yamt sync with head.
 1.22.8.1 19-Apr-2006  elad sync with head.
 1.22.6.1 13-Mar-2006  yamt sync with head.
 1.22.4.1 22-Apr-2006  simonb Sync with head.
 1.22.2.1 09-Sep-2006  rpaulo sync with head
 1.23.12.2 10-Dec-2006  yamt sync with head.
 1.23.12.1 22-Oct-2006  yamt sync with head
 1.23.10.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.23.10.1 18-Nov-2006  ad Sync with head.
 1.26.4.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.26.2.1 09-Jul-2007  liamjfoy Pull up following revision(s) (requested by jmcneill in ticket #760):
sys/dev/pci/ehci_pci.c: revision 1.28
If the USB legacy capability flag is not set, we mistakenly attempt to
clear it anyway by writing to PCI configuration register 0x00.
Instead, if this flag is not set, simply bail out from ehci_get_ownership.
 1.27.14.1 22-May-2007  itohy Overhaul of USB stack, mostly DMA related

This applies to NetBSD 4.99.13 (March 1, 2007)

usbdi(9) interface is based on FreeBSD version, excluding
- removal of portability code

Patch most NetBSD changes, excluding
- DMA memory "reserve", since we don't need contiguous buffers any longer
- volatiles in DMA structure, since it should not be needed
with proper bus_dmamap_sync(9)s

DMA/non-DMA memory management overhaul
- Move all DMA related code to usb_mem.[ch]
(add usb_alloc_buffer_dma(), usb_free_buffer_dma(), etc.).
XXX Should usb_mem.[ch] be renamed as usb_mem_dma.[ch] ?
- Add corresponding non-DMA code to usb_mem_nodma.[ch] .
Currently just use malloc(9).
- Above files are conditionally used by config framework (added
attributes to conf/files and dev/usb/files.usb).
- Add diagnostic panics when resource allocation is requested
on interrupt context.
- Change memory allocations (that require context) from NOWAIT to WAITOK.

Allocate DMA/non-DMA buffer per host interface, not globally.
advantage: Buffers can be freed on detaching host interface.
Activity of a host interface does not affect others.
disadvantages: It possibly consumes more memory.

API changes
- usbd_alloc_xfer() is changed:
old: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev);
new: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev,
usbd_pipe_handle pipe);
- pipe argument of usbd_setup_*xfer() are now unused
XXX the pipe argument should be removed?
- add mapping APIs
- async request will be processed as a task (kernel thread context),
and delayed to some extent
- usbdivar.h: struct usbd_xfer: renamed a member "allocbuf" to "hcbuffer"
(mapped/allocated/refered buffer for HCI driver)
- usb_port.h: change usb_proc_ptr from struct ptoc * to struct lwp *
- usb_port.h: add usb_sigproc_ptr for psignal(9) (struct proc *)
- usb.h: add UE_MAXPKTSZ(ep) and UE_MAXPKTSZ_MASK macros for USB 2.0

changes to USB device drivers
- atu, aue, axe, cdce, cue, kue, rum, udav, upl, ural, url,
uaudio, ubt, ucom, ugen, uhidev, uirda, ulpt, umidi, urio,
uscanner, ustir, utoppy:
* catch up API change of usbd_alloc_xfer()
- umass, usscanner:
* catch up API change of usbd_alloc_xfer()
* eliminate memory copy for large transfer

ohci
- free resources on detach
- add lots of bus_dmamap_sync() operations
- simplify the code of loading std chain
- rewrite code of looking up TD/ITD from DMA addr by using allocation chunk
- add workaround for CMD Tech 670 and 673 chipsets
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

slhci
- allocate xfer and slhci_xfer at once, and simplify relevant code
- add slhci_detach()
- remove second arg of slhci_attach() since it is the same as the first arg.
- add support for "mapping" (no, it doesn't map since it doesn't do DMA)
buffer and mbuf
- add pcmcia frontend
- NOT TESTED, missing hardware

ehci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf
- done only simple test

uhci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

To do
- review, test, debug
- rewrite network drivers to utilize usbd_map_buffer_mbuf()
- rewrite uaudio(4) to eliminate memcpy
- "pipe" argument of usbd_setup_*xfer() should eventually be removed
 1.27.8.1 11-Jul-2007  mjf Sync with head.
 1.27.6.3 23-Oct-2007  ad Sync with head.
 1.27.6.2 20-Aug-2007  ad Sync with HEAD.
 1.27.6.1 15-Jul-2007  ad Sync with head.
 1.28.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.29.2.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.29.2.6 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.29.2.5 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.29.2.4 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.29.2.3 21-Aug-2007  joerg Disable interrupts etc before saving the config space and reenable them
afterwards. This fixes resume on my Thinkpad R52.
 1.29.2.2 04-Aug-2007  jmcneill Sync with HEAD.
 1.29.2.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.30.8.2 04-Aug-2007  tsutsui ATI's ehci also requires EHCIF_DROPPED_INTR_WORKAROUND. From FreeBSD.
 1.30.8.1 04-Aug-2007  tsutsui file ehci_pci.c was added on branch matt-mips64 on 2007-08-04 10:36:07 +0000
 1.30.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.30.2.3 23-Mar-2008  matt sync with HEAD
 1.30.2.2 09-Jan-2008  matt sync with HEAD
 1.30.2.1 06-Nov-2007  matt sync with HEAD
 1.31.6.1 11-Dec-2007  yamt sync with head.
 1.31.4.1 26-Dec-2007  ad Sync with head.
 1.31.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.34.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.34.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.34.2.1 24-Mar-2008  keiichi sync with head.
 1.37.4.4 11-Mar-2010  yamt sync with head
 1.37.4.3 20-Jun-2009  yamt sync with head
 1.37.4.2 04-May-2009  yamt sync with head.
 1.37.4.1 16-May-2008  yamt sync with head.
 1.37.2.1 18-May-2008  yamt sync with head.
 1.38.16.1 17-Jun-2009  bouyer branches: 1.38.16.1.2;
Pull up following revision(s) (requested by cegger in ticket #814):
sys/dev/pci/ehci_pci.c: revision 1.45
Apply hw workaround required for all SB600 revisions and SB700 revisions
A12 and A13 to avoid USB subsystem hang symptom. The USB subsystem hang
symptom is observed when the system has multiple USB devices connected to it
or one USB device is often re-connected. In some cases a USB hub may be
required to observe this symptom.
This patch works around the problem by correcting the internal register setting
that will help by changing the behavior of the internal logic to avoid the
USB subsystem hang issue. The change in the behavior of the logic does not
impact the normal operation of the USB subsystem.
This fix has been discussed, developped, reviewed, polished up
and tested on current-users by several people. Thread starts at:
http://mail-index.netbsd.org/current-users/2009/05/17/msg009460.html
 1.38.16.1.2.3 04-Jan-2012  matt Take changes from matt-nb5-pq3 which fixes how multiple ehci functions
on a pci device claim companion ohci controllers.
 1.38.16.1.2.2 03-Jan-2012  matt Only do the pci_conf_write if PCI_COMMAND_MASTER_ENABLE isn't already set.
 1.38.16.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.38.14.2 23-Jul-2009  jym Sync with HEAD.
 1.38.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.38.10.1 17-Jun-2009  bouyer branches: 1.38.10.1.4;
Pull up following revision(s) (requested by cegger in ticket #814):
sys/dev/pci/ehci_pci.c: revision 1.45
Apply hw workaround required for all SB600 revisions and SB700 revisions
A12 and A13 to avoid USB subsystem hang symptom. The USB subsystem hang
symptom is observed when the system has multiple USB devices connected to it
or one USB device is often re-connected. In some cases a USB hub may be
required to observe this symptom.
This patch works around the problem by correcting the internal register setting
that will help by changing the behavior of the internal logic to avoid the
USB subsystem hang issue. The change in the behavior of the logic does not
impact the normal operation of the USB subsystem.
This fix has been discussed, developped, reviewed, polished up
and tested on current-users by several people. Thread starts at:
http://mail-index.netbsd.org/current-users/2009/05/17/msg009460.html
 1.38.10.1.4.1 07-Jan-2011  matt Deal with multifunction pci devices better in choosing companion devices.
 1.38.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.46.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.47.2.2 21-Apr-2011  rmind sync with head
 1.47.2.1 05-Mar-2011  rmind sync with head
 1.50.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.53.6.4 12-Mar-2012  mrg fix detach bugs:
- need to disestablish the ehci softint's.
- need to destroy needs_explore_cv
- note that ehci.c inits locks, but ehci_pci.c destroys them due to the
way that the (pci) front end does softint handling, and can only be
trusted to destroy them. XXX need to fix this, by looking at the many
ehci frontends as well and checking ohci/uhci.
 1.53.6.3 18-Feb-2012  mrg merge to -current.
 1.53.6.2 09-Dec-2011  mrg - make pipe->close method take the thread lock

- convert usb_taskq to use mutex/cv

- convert needs_explore usage into a cv on the thread lock

- remove KERNEL_*LOCK from uaudio and umidi, since we're supposedly
MPSAFE here now

- use IPL_SCHED instead of IPL_USB (aka biglocked) interrupts

- drop the audio thread lock when calling into usb when it may sleep,
avoiding a deadlock between audiowrite and audioioctl. this fixes
mixerctl -a vs. playing hanging the system
XXX probably need to check this in a bunch more places.
 1.53.6.1 04-Dec-2011  jmcneill Make ehci mpsafe.
 1.53.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.53.2.2 30-Oct-2012  yamt sync with head
 1.53.2.1 17-Apr-2012  yamt sync with head
 1.54.4.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.54.2.1 01-Oct-2012  riz Pull up following revision(s) (requested by tstsui in ticket #569):
sys/dev/pci/ehci_pci.c: revision 1.57
Fix PR kern/46828 (6.0_BETA2 and 6.0_RC1 won't start on DL320/G5p):
In ehci_get_ownership(), don't explicitly clear EHCI_LEG_HC_BIOS_OWNED
semaphore bit in the driver before asking BIOS to give up ownership.
The EHCI spec implies that the semaphore should not be changed by
the other agent and actually the previous one (introduced in rev 1.53
after 5.x) caused hangup during probe on at least two HP machines
as mentioned in the PR. Analyzed and patch provided by Ryo ONODERA.
Should be pulled up to netbsd-6 (fatal hangup during boot).
 1.56.2.3 03-Dec-2017  jdolecek update from HEAD
 1.56.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.57.2.1 18-May-2014  rmind sync with head
 1.58.8.2 14-Sep-2016  skrll Use IPL_USB for interrupt handler
 1.58.8.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.58.4.2 08-Jul-2017  snj Pull up following revision(s) (requested by sborrill in ticket #1431):
sys/dev/pci/ehci_pci.c: revision 1.65
Deal with broken BIOSes that leave PCI interrupts disabled.
Thanks to nick@
 1.58.4.1 05-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1395):
share/man/man4/axe.4: netbsd-7-nhusb
share/man/man4/axen.4: netbsd-7-nhusb
share/man/man4/cdce.4: netbsd-7-nhusb
share/man/man4/uaudio.4: netbsd-7-nhusb
share/man/man4/ucom.4: netbsd-7-nhusb
share/man/man4/uep.4: netbsd-7-nhusb
share/man/man4/urtw.4: netbsd-7-nhusb
share/man/man4/usb.4: netbsd-7-nhusb
share/man/man4/uyap.4: netbsd-7-nhusb
share/man/man4/xhci.4: netbsd-7-nhusb
share/man/man9/usbdi.9: netbsd-7-nhusb
sys/arch/amd64/conf/ALL: netbsd-7-nhusb
sys/arch/amd64/conf/GENERIC: netbsd-7-nhusb
sys/arch/amiga/dev/slhci_zbus.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_otg.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_usb.c: netbsd-7-nhusb
sys/arch/arm/amlogic/amlogic_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/at91/at91ohci.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm2835_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm53xx_usb.c: netbsd-7-nhusb
sys/arch/arm/ep93xx/epohci.c: netbsd-7-nhusb
sys/arch/arm/gemini/obio_ehci.c: netbsd-7-nhusb
sys/arch/arm/imx/files.imx23: netbsd-7-nhusb
sys/arch/arm/imx/imxusb.c: netbsd-7-nhusb
sys/arch/arm/imx/imxusbreg.h: netbsd-7-nhusb
sys/arch/arm/omap/obio_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/omap3_ehci.c: netbsd-7-nhusb
sys/arch/arm/omap/omapl1x_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/tiotg.c: netbsd-7-nhusb
sys/arch/arm/s3c2xx0/ohci_s3c24x0.c: netbsd-7-nhusb
sys/arch/arm/samsung/exynos_usb.c: netbsd-7-nhusb
sys/arch/arm/xscale/pxa2x0_ohci.c: netbsd-7-nhusb
sys/arch/arm/zynq/zynq_usb.c: netbsd-7-nhusb
sys/arch/hpcarm/dev/nbp_slhci.c: netbsd-7-nhusb
sys/arch/hpcmips/dev/plumohci.c: netbsd-7-nhusb
sys/arch/i386/conf/ALL: netbsd-7-nhusb
sys/arch/i386/conf/GENERIC: netbsd-7-nhusb
sys/arch/i386/pci/gcscehci.c: netbsd-7-nhusb
sys/arch/luna68k/conf/GENERIC: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahci.c: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahcivar.h: netbsd-7-nhusb
sys/arch/mips/alchemy/dev/ohci_aubus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ehci_arbus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ohci_arbus.c: netbsd-7-nhusb
sys/arch/mips/conf/files.adm5120: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ehci.c: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ohci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ehci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ohci.c: netbsd-7-nhusb
sys/arch/playstation2/dev/ohci_sbus.c: netbsd-7-nhusb
sys/arch/powerpc/booke/dev/pq3ehci.c: netbsd-7-nhusb
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c: netbsd-7-nhusb
sys/arch/x68k/dev/slhci_intio.c: netbsd-7-nhusb
sys/conf/files: netbsd-7-nhusb
sys/dev/cardbus/ehci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/ohci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/uhci_cardbus.c: netbsd-7-nhusb
sys/dev/ic/sl811hs.c: netbsd-7-nhusb
sys/dev/ic/sl811hsvar.h: netbsd-7-nhusb
sys/dev/isa/slhci_isa.c: netbsd-7-nhusb
sys/dev/marvell/ehci_mv.c: netbsd-7-nhusb
sys/dev/pci/ehci_pci.c: netbsd-7-nhusb
sys/dev/pci/ohci_pci.c: netbsd-7-nhusb
sys/dev/pci/uhci_pci.c: netbsd-7-nhusb
sys/dev/pci/xhci_pci.c: netbsd-7-nhusb
sys/dev/pcmcia/slhci_pcmcia.c: netbsd-7-nhusb
sys/dev/usb/Makefile.usbdevs: netbsd-7-nhusb
sys/dev/usb/TODO: netbsd-7-nhusb
sys/dev/usb/TODO.usbmp: netbsd-7-nhusb
sys/dev/usb/aubtfwl.c: netbsd-7-nhusb
sys/dev/usb/auvitek.c: netbsd-7-nhusb
sys/dev/usb/auvitek_audio.c: netbsd-7-nhusb
sys/dev/usb/auvitek_dtv.c: netbsd-7-nhusb
sys/dev/usb/auvitek_i2c.c: netbsd-7-nhusb
sys/dev/usb/auvitek_video.c: netbsd-7-nhusb
sys/dev/usb/auvitekvar.h: netbsd-7-nhusb
sys/dev/usb/ehci.c: netbsd-7-nhusb
sys/dev/usb/ehcireg.h: netbsd-7-nhusb
sys/dev/usb/ehcivar.h: netbsd-7-nhusb
sys/dev/usb/emdtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_dtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_ir.c: netbsd-7-nhusb
sys/dev/usb/emdtvvar.h: netbsd-7-nhusb
sys/dev/usb/ezload.c: netbsd-7-nhusb
sys/dev/usb/ezload.h: netbsd-7-nhusb
sys/dev/usb/files.usb: netbsd-7-nhusb
sys/dev/usb/hid.c: netbsd-7-nhusb
sys/dev/usb/hid.h: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.c: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.h: netbsd-7-nhusb
sys/dev/usb/if_atu.c: netbsd-7-nhusb
sys/dev/usb/if_atureg.h: netbsd-7-nhusb
sys/dev/usb/if_aue.c: netbsd-7-nhusb
sys/dev/usb/if_auereg.h: netbsd-7-nhusb
sys/dev/usb/if_axe.c: netbsd-7-nhusb
sys/dev/usb/if_axen.c: netbsd-7-nhusb
sys/dev/usb/if_axenreg.h: netbsd-7-nhusb
sys/dev/usb/if_axereg.h: netbsd-7-nhusb
sys/dev/usb/if_cdce.c: netbsd-7-nhusb
sys/dev/usb/if_cdcereg.h: netbsd-7-nhusb
sys/dev/usb/if_cue.c: netbsd-7-nhusb
sys/dev/usb/if_cuereg.h: netbsd-7-nhusb
sys/dev/usb/if_kue.c: netbsd-7-nhusb
sys/dev/usb/if_kuereg.h: netbsd-7-nhusb
sys/dev/usb/if_otus.c: netbsd-7-nhusb
sys/dev/usb/if_otusvar.h: netbsd-7-nhusb
sys/dev/usb/if_rum.c: netbsd-7-nhusb
sys/dev/usb/if_rumreg.h: netbsd-7-nhusb
sys/dev/usb/if_rumvar.h: netbsd-7-nhusb
sys/dev/usb/if_run.c: netbsd-7-nhusb
sys/dev/usb/if_runvar.h: netbsd-7-nhusb
sys/dev/usb/if_smsc.c: netbsd-7-nhusb
sys/dev/usb/if_smscreg.h: netbsd-7-nhusb
sys/dev/usb/if_smscvar.h: netbsd-7-nhusb
sys/dev/usb/if_udav.c: netbsd-7-nhusb
sys/dev/usb/if_udavreg.h: netbsd-7-nhusb
sys/dev/usb/if_upgt.c: netbsd-7-nhusb
sys/dev/usb/if_upgtvar.h: netbsd-7-nhusb
sys/dev/usb/if_upl.c: netbsd-7-nhusb
sys/dev/usb/if_ural.c: netbsd-7-nhusb
sys/dev/usb/if_uralreg.h: netbsd-7-nhusb
sys/dev/usb/if_uralvar.h: netbsd-7-nhusb
sys/dev/usb/if_url.c: netbsd-7-nhusb
sys/dev/usb/if_urlreg.h: netbsd-7-nhusb
sys/dev/usb/if_urndis.c: netbsd-7-nhusb
sys/dev/usb/if_urndisreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtw.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn_data.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnvar.h: netbsd-7-nhusb
sys/dev/usb/if_urtwreg.h: netbsd-7-nhusb
sys/dev/usb/if_zyd.c: netbsd-7-nhusb
sys/dev/usb/if_zydreg.h: netbsd-7-nhusb
sys/dev/usb/irmce.c: netbsd-7-nhusb
sys/dev/usb/moscom.c: netbsd-7-nhusb
sys/dev/usb/motg.c: netbsd-7-nhusb
sys/dev/usb/motgvar.h: netbsd-7-nhusb
sys/dev/usb/ohci.c: netbsd-7-nhusb
sys/dev/usb/ohcireg.h: netbsd-7-nhusb
sys/dev/usb/ohcivar.h: netbsd-7-nhusb
sys/dev/usb/pseye.c: netbsd-7-nhusb
sys/dev/usb/slurm.c: netbsd-7-nhusb
sys/dev/usb/stuirda.c: netbsd-7-nhusb
sys/dev/usb/u3g.c: netbsd-7-nhusb
sys/dev/usb/uark.c: netbsd-7-nhusb
sys/dev/usb/uatp.c: netbsd-7-nhusb
sys/dev/usb/uaudio.c: netbsd-7-nhusb
sys/dev/usb/uberry.c: netbsd-7-nhusb
sys/dev/usb/ubsa.c: netbsd-7-nhusb
sys/dev/usb/ubsa_common.c: netbsd-7-nhusb
sys/dev/usb/ubsavar.h: netbsd-7-nhusb
sys/dev/usb/ubt.c: netbsd-7-nhusb
sys/dev/usb/uchcom.c: netbsd-7-nhusb
sys/dev/usb/ucom.c: netbsd-7-nhusb
sys/dev/usb/ucomvar.h: netbsd-7-nhusb
sys/dev/usb/ucycom.c: netbsd-7-nhusb
sys/dev/usb/udl.c: netbsd-7-nhusb
sys/dev/usb/udl.h: netbsd-7-nhusb
sys/dev/usb/udsbr.c: netbsd-7-nhusb
sys/dev/usb/udsir.c: netbsd-7-nhusb
sys/dev/usb/uep.c: netbsd-7-nhusb
sys/dev/usb/uftdi.c: netbsd-7-nhusb
sys/dev/usb/uftdireg.h: netbsd-7-nhusb
sys/dev/usb/ugen.c: netbsd-7-nhusb
sys/dev/usb/ugensa.c: netbsd-7-nhusb
sys/dev/usb/uhci.c: netbsd-7-nhusb
sys/dev/usb/uhcireg.h: netbsd-7-nhusb
sys/dev/usb/uhcivar.h: netbsd-7-nhusb
sys/dev/usb/uhid.c: netbsd-7-nhusb
sys/dev/usb/uhidev.c: netbsd-7-nhusb
sys/dev/usb/uhidev.h: netbsd-7-nhusb
sys/dev/usb/uhmodem.c: netbsd-7-nhusb
sys/dev/usb/uhso.c: netbsd-7-nhusb
sys/dev/usb/uhub.c: netbsd-7-nhusb
sys/dev/usb/uipad.c: netbsd-7-nhusb
sys/dev/usb/uipaq.c: netbsd-7-nhusb
sys/dev/usb/uirda.c: netbsd-7-nhusb
sys/dev/usb/uirdavar.h: netbsd-7-nhusb
sys/dev/usb/ukbd.c: netbsd-7-nhusb
sys/dev/usb/ukbdmap.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.h: netbsd-7-nhusb
sys/dev/usb/ulpt.c: netbsd-7-nhusb
sys/dev/usb/umass.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.h: netbsd-7-nhusb
sys/dev/usb/umass_quirks.c: netbsd-7-nhusb
sys/dev/usb/umass_quirks.h: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.c: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.h: netbsd-7-nhusb
sys/dev/usb/umassvar.h: netbsd-7-nhusb
sys/dev/usb/umcs.c: netbsd-7-nhusb
sys/dev/usb/umct.c: netbsd-7-nhusb
sys/dev/usb/umidi.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.h: netbsd-7-nhusb
sys/dev/usb/umodem.c: netbsd-7-nhusb
sys/dev/usb/umodem_common.c: netbsd-7-nhusb
sys/dev/usb/umodemvar.h: netbsd-7-nhusb
sys/dev/usb/ums.c: netbsd-7-nhusb
sys/dev/usb/uplcom.c: netbsd-7-nhusb
sys/dev/usb/urio.c: netbsd-7-nhusb
sys/dev/usb/urio.h: netbsd-7-nhusb
sys/dev/usb/usb.c: netbsd-7-nhusb
sys/dev/usb/usb.h: netbsd-7-nhusb
sys/dev/usb/usb_mem.c: netbsd-7-nhusb
sys/dev/usb/usb_mem.h: netbsd-7-nhusb
sys/dev/usb/usb_quirks.c: netbsd-7-nhusb
sys/dev/usb/usb_quirks.h: netbsd-7-nhusb
sys/dev/usb/usb_subr.c: netbsd-7-nhusb
sys/dev/usb/usbdevices.config: netbsd-7-nhusb
sys/dev/usb/usbdevs: netbsd-7-nhusb
sys/dev/usb/usbdevs.h: netbsd-7-nhusb
sys/dev/usb/usbdevs_data.h: netbsd-7-nhusb
sys/dev/usb/usbdi.c: netbsd-7-nhusb
sys/dev/usb/usbdi.h: netbsd-7-nhusb
sys/dev/usb/usbdi_util.c: netbsd-7-nhusb
sys/dev/usb/usbdi_util.h: netbsd-7-nhusb
sys/dev/usb/usbdivar.h: netbsd-7-nhusb
sys/dev/usb/usbhid.h: netbsd-7-nhusb
sys/dev/usb/usbhist.h: netbsd-7-nhusb
sys/dev/usb/usbroothub.c: netbsd-7-nhusb
sys/dev/usb/usbroothub.h: netbsd-7-nhusb
sys/dev/usb/usbroothub_subr.c: delete
sys/dev/usb/usbroothub_subr.h: delete
sys/dev/usb/uscanner.c: netbsd-7-nhusb
sys/dev/usb/uslsa.c: netbsd-7-nhusb
sys/dev/usb/usscanner.c: netbsd-7-nhusb
sys/dev/usb/ustir.c: netbsd-7-nhusb
sys/dev/usb/uthum.c: netbsd-7-nhusb
sys/dev/usb/utoppy.c: netbsd-7-nhusb
sys/dev/usb/uts.c: netbsd-7-nhusb
sys/dev/usb/uvideo.c: netbsd-7-nhusb
sys/dev/usb/uvisor.c: netbsd-7-nhusb
sys/dev/usb/uvscom.c: netbsd-7-nhusb
sys/dev/usb/uyap.c: netbsd-7-nhusb
sys/dev/usb/uyap_firmware.h: netbsd-7-nhusb
sys/dev/usb/uyurex.c: netbsd-7-nhusb
sys/dev/usb/x1input_rdesc.h: netbsd-7-nhusb
sys/dev/usb/xhci.c: netbsd-7-nhusb
sys/dev/usb/xhcireg.h: netbsd-7-nhusb
sys/dev/usb/xhcivar.h: netbsd-7-nhusb
sys/dev/usb/xinput_rdesc.h: netbsd-7-nhusb
sys/external/bsd/common/conf/files.linux: netbsd-7-nhusb
sys/external/bsd/common/include/linux/err.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/kernel.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/workqueue.h: netbsd-7-nhusb
sys/external/bsd/common/linux/linux_work.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/atombios_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/drm/files.drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/i915drm/files.i915drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/include/linux/err.h: delete
sys/external/bsd/drm2/include/linux/workqueue.h: delete
sys/external/bsd/drm2/linux/files.drmkms_linux: netbsd-7-nhusb
sys/external/bsd/drm2/linux/linux_work.c: delete
sys/external/bsd/dwc2/dwc2.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2var.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwctwo2netbsd: netbsd-7-nhusb
sys/external/bsd/dwc2/conf/files.dwc2: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_coreintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdddma.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hw.h: netbsd-7-nhusb
sys/modules/drmkms_linux/Makefile: netbsd-7-nhusb
sys/modules/i915drmkms/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libugenhc/ugenhc.c: netbsd-7-nhusb
sys/rump/dev/lib/libusb/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libusb/USB.ioconf: netbsd-7-nhusb
sys/rump/dev/lib/libusb/usb_at_ugenhc.c: delete
sys/rump/dev/lib/libusb/opt/opt_usb.h: delete
sys/rump/dev/lib/libusb/opt/opt_usbverbose.h: delete
sys/sys/mbuf.h: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.8: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.c: netbsd-7-nhusb
Merge netbsd-7-nhusb:
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
- Change the SOFTINT level from NET to SERIAL for the USB softint handler.
This gives the callback a chance of running when another softint handler
at SOFTINT_NET has blocked holding a lock, e.g. softnet_lock and most of
the network stack.
- kern/49065 - ifconfig tun0 ... sequence locks up system / lockup:
softnet_lock held across usb xfr
- kern/50491 - unkillable wait in usbd_transfer while using usmsc0
on raspberry pi 2
- kern/51395 - USB Ethernet makes xhci hang
- Various improvements to slhci(4)
- Various improvements to dwc2(4)
 1.59.2.6 28-Aug-2017  skrll Sync with HEAD
 1.59.2.5 05-Dec-2016  skrll Sync with HEAD
 1.59.2.4 22-Sep-2015  skrll Sync with HEAD
 1.59.2.3 05-Dec-2014  skrll Use int for return type for [eou]chi_init and motg_init.
 1.59.2.2 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.59.2.1 03-Dec-2014  skrll Trailing whitespace.
 1.63.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.64.8.1 15-Jun-2017  snj Pull up following revision(s) (requested by sborrill in ticket #33):
sys/dev/pci/ehci_pci.c: revision 1.65
Deal with broken BIOSes that leave PCI interrupts disabled.
Thanks to nick@
 1.65.4.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.65.4.2 21-May-2018  pgoyette Sync with HEAD
 1.65.4.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.67.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.67.2.1 10-Jun-2019  christos Sync with HEAD
 1.70.12.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.71.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.75.2.2 11-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #823):

sys/dev/pci/ehci_pci.c: revision 1.77

ehci(4): properly handle failed attach

thinkpad a475 fails to attach an ehci instance:

ehci0: pre-2.0 USB rev, device ignored

which ends up stopping suspend/resume working as the device has no
pmf handlers installed. put most of the teardown code into a new
common function that is called from failed attach and detach. if
attach fails, register NULL pmf handlers. don't check the return
value of pmf_device_register*().

re-order several parts of detach to match the reverse attach order.
tested on rockpro64, thinkpad a475, and xps 1645, the a475 can now
suspend/resume almost fully successfully.
 1.75.2.1 11-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #631):

sys/dev/pci/ehci_pci.c: revision 1.76

Consistently use cached chipset tag value.
 1.77.2.1 02-Aug-2025  perseant Sync with HEAD
 1.79 08-Jun-2024  andvar s/amound/amount/ in comment.
 1.78 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.77 10-May-2023  riastradh emuxki(4): Use config_detach_children.
 1.76 07-Sep-2022  khorben emuxki(4): import a list of board definitions

This is inspired by the cxdtv(4) driver.

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI)
and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe).

Additional sound cards sponsored by the NetBSD Foundation; thanks!
 1.75 07-Sep-2022  khorben emuxki(4): place struct emuxki_softc into its own file

NFCI
 1.74 07-Sep-2022  khorben emuxki(4): restrict DMA memory within the first 2GB

As implemented in the driver, the EMU10K1 chip can only address memory
up to 31-bit addresses.

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI)
and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe).

Additional sound cards sponsored by the NetBSD Foundation; thanks!
 1.73 07-Sep-2022  khorben emuxki(4): allow building as a module

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870)

Note that this required setting outputs.master to the maximum value
allowed (255) to get sound out, and then cranking the volume pretty
high.

Additional sound cards sponsored by the NetBSD Foundation; thanks!
 1.72 29-Aug-2022  khorben emuxki(4): add support for the Sound Blaster Audigy Rx

This is as per kern/56980. Confirmed working on one out of two different
computers, albeit with a strong hissing noise (same card, different
mainboard). The mixer settings seem to be irrelevant or not supported
though.

Original support inspired by the Linux driver, and confirmed with the
OpenBSD driver, itself originally from NetBSD.

Tested on NetBSD/amd64.
 1.71 06-Feb-2021  isaki Remove debug messages which are no longer necessary.
 1.70 08-Jun-2019  isaki branches: 1.70.10;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.69 29-May-2019  isaki Fix build error on i386. These were only needed during development.
Reported by msaitoh@.
 1.68 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.67 16-Mar-2019  isaki branches: 1.67.2;
Use C99 style struct initializer to audio_hw_if.
 1.66 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.65 01-Jun-2017  chs branches: 1.65.8; 1.65.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.64 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.63 29-Mar-2014  christos branches: 1.63.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.62 30-Jan-2012  drochner branches: 1.62.6; 1.62.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.61 24-Nov-2011  mrg branches: 1.61.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.60 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.59 26-Nov-2009  njoly branches: 1.59.12; 1.59.14;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.58 09-Jun-2009  tsutsui Split device_t/softc.

Tested on:
emuxki0 at pci2 dev 7 function 0: Creative Labs SBLive! EMU 10000
(audio multimedia, revision 0x05)
 1.57 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.56 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.55 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.54 06-Sep-2008  gmcgarry branches: 1.54.6; 1.54.8;
Backout unintended change.
 1.53 06-Sep-2008  gmcgarry Use One exit point to avoid unreachable code.
 1.52 28-Apr-2008  martin branches: 1.52.2; 1.52.6;
Remove clause 3 and 4 from TNF licenses
 1.51 10-Apr-2008  cegger branches: 1.51.2; 1.51.4;
use aprint_*_dev and device_xname
 1.50 04-Mar-2007  christos branches: 1.50.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.49 16-Nov-2006  christos branches: 1.49.4; 1.49.6;
__unused removal on arguments; approved by core.
 1.48 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.47 23-Sep-2006  jmcneill Print "interrupt at irq <foo>" message immediately after we establish the
interrupt. Patch from PR# 33567.
 1.46 30-Aug-2006  christos branches: 1.46.2; 1.46.4;
- fix incomplete initializer
- remove unsigned comparison < 0
 1.45 14-Apr-2006  christos branches: 1.45.4;
Coverity CID 1537: Make it clear to coverity that there is no overflow.
 1.44 14-Apr-2006  christos Coverity CID 1538: Avoid array overrun.
 1.43 11-Dec-2005  christos branches: 1.43.4; 1.43.6; 1.43.8; 1.43.10; 1.43.12;
merge ktrace-lwp.
 1.42 11-Oct-2005  jdolecek put back joystick enabling code, lost in Audigy support merge
 1.41 27-Feb-2005  perry branches: 1.41.4;
nuke trailing whitespace
 1.40 15-Jan-2005  kent branches: 1.40.2; 1.40.4;
ansify and KNF
 1.39 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.38 29-Oct-2004  yamt branches: 1.38.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.37 07-Oct-2004  dsainty Corrected a scattering of typos in comments
 1.36 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.35 27-May-2004  christos PR/25731: Adam K kirchhoff: Audigy support with the emuxki driver.
 1.34 23-May-2004  tsutsui Add some byteswap ops around DMA descriptors for big endian machines.
Tested on macppc by matthew green.

XXX This driver completely lacks bus_dmamap_sync(9) ops.
 1.33 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.32 03-Apr-2004  martti Added another SB Live! 5.1 soundcard and joystick version
 1.31 10-Nov-2003  wiz branches: 1.31.2;
Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.30 30-Oct-2003  hannken Complete last commit: Remove assigned-to but otherwise unused variable.
 1.29 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.28 25-Oct-2003  christos Fix uninitialized variable warnings.
 1.27 25-Oct-2003  christos Fix uninitialized variable warnings
 1.26 03-May-2003  wiz branches: 1.26.2;
DMA, not dma nor Dma.
 1.25 26-Apr-2003  wiz Management, not managment. Mostly from jmc@openbsd.
 1.24 17-Mar-2003  toshii Fix a memory leak in emuxki_voice_new.
Pointed out by Izumi Tsutsui in the current-users mailing list.
 1.23 17-Mar-2003  toshii Make emuxki_voice_set_audioparms return EINVAL if invalid sample rate
is passed.
 1.22 16-Mar-2003  toshii Fix recording with formats other than 16 bit slinear_le, based on the
patch submitted as kern/20620.
 1.21 16-Mar-2003  toshii Remove a couple of false comments, as pointed out in kern/20620.
 1.20 03-Mar-2003  fvdl The intrmasks array is only used in if 0-ed code, so if 0 it as well.
 1.19 25-Feb-2003  toshii Add recording support for emuxki(4). The patch is basically the same
as I submitted in PR kern/18093. Some of the patch needs refinement.
Also, only the ADC recording source is supported, because the other
sources are probably much less useful and the implementation isn't
trivial.
 1.18 22-Feb-2003  tsutsui hz -> Hz
 1.17 18-Feb-2003  wiz s/intial/initial/, from jmc in .pl in PR 20414.
 1.16 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.15 31-Jan-2003  thorpej Use aprint_*().
 1.14 01-Jan-2003  tron Use bus_space_write_2() to write the 16 bit register "EMU_TIMER" which
should fix PR kern/15663. Patch supplied by Yorick Hardy via GNATS.
 1.13 24-Dec-2002  jdolecek emuxki_intr(): return 1 if interrupt was for us, 0 if not
this appear to fix occassional sample repeats on my dual CPU i386
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 02-Feb-2002  jdolecek branches: 1.9.10;
enable the joystick port on attach, too
 1.8 27-Jan-2002  jdolecek emuxki_set_params(): don't try to set parameters if the appropriate
'voice' is not initialized
This fixes kern/15394 by Onno van der Linden.

Code fragment to trigger the bug:

AUDIO_INITINFO(&info);
info.mode = AUMODE_PLAY;
info.play.channels = 2;
fd = open("/dev/audioctl0", O_RDWR);
(void)ioctl(fd, AUDIO_SETINFO, &info);

emuxki_voice_set_audioparms(): g/c check for voice == NULL, this is
never called with null voice
some minor style changes in emuxki_open()/emuxki_close()
 1.7 23-Dec-2001  jdolecek branches: 1.7.2; 1.7.4;
Merge in changes sent by Michael Shalayeff, from OpenBSD port of this driver:
- use better default for DAC level (previous produced distorted output)
- preserve DAC setting in between openings
 1.6 23-Dec-2001  jdolecek Add the AC97_HOST_SWAPPED_CHANNELS quirk for emuxki, and do some
whitespace cleanup. Streight from Yannick Montulet.
 1.5 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.4 13-Nov-2001  lukem add RCSID
 1.3 22-Oct-2001  jdolecek branches: 1.3.2;
De-__P()ify. Suggested by Lennart Augustsson.
 1.2 18-Oct-2001  jdolecek Fix obviously wrong printf() format in pci_intr_establish() failure case.
Pointed out by Chuck Silvers.
XXX This has compiled without a warning for me - what's up?

Add sc->sc_dev.dv_xname in another failure printf()
 1.1 17-Oct-2001  jdolecek Add driver for Creative Labs SBLive! EMU10000, possibly also PCI512.
Written by Yannick Montulet (thanks!), with only couple minor touches by me.
 1.3.2.8 03-Jan-2003  thorpej Sync with HEAD.
 1.3.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.3.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.3.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.3.2.1 22-Oct-2001  nathanw file emuxki.c was added on branch nathanw_sa on 2001-10-22 20:41:23 +0000
 1.7.4.3 09-Feb-2002  he Pull up revision 1.8 (requested by jdolecek):
Do not try to set parameters if the appropriate ``voice'' is not
initialized. Fixes PR#15394.
 1.7.4.2 19-Jan-2002  he Pull up revisions 1.1-1.7 (new, via patch, requested by he):
Add driver for Creative Labs SBLive! EMU10000 and (probably) PCI512.
Fixes PR#15260.
 1.7.4.1 23-Dec-2001  he file emuxki.c was added on branch netbsd-1-5 on 2002-01-19 21:55:09 +0000
 1.7.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.7.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.1 23-Dec-2001  thorpej file emuxki.c was added on branch kqueue on 2002-01-10 19:56:32 +0000
 1.9.10.1 05-Jan-2003  jmc Pull up revisions 1.13-1.14 (requested by tron in ticket #1056)
Use bus_space_write_2() to write the 16 bit register EMU_TIMER which
should fix PR kern/15663. Patch supplied by Yorick Hardy via GNATS.
 1.26.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.26.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.26.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.26.2.5 19-Oct-2004  skrll Sync with HEAD
 1.26.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.26.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.26.2.1 03-Aug-2004  skrll Sync with HEAD
 1.31.2.2 22-Sep-2004  jmc branches: 1.31.2.2.2;
Pullup rev 1.36 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.31.2.1 05-Apr-2004  tron Pull up revision 1.32 (requested by martti in ticket #54):
Added another SB Live! 5.1 soundcard and joystick version
 1.31.2.2.2.1 13-Apr-2005  tron Pull up revision 1.34 (requested by tsutsui in ticket #1071):
Add some byteswap ops around DMA descriptors for big endian machines.
Tested on macppc by matthew green.
XXX This driver completely lacks bus_dmamap_sync(9) ops.
 1.38.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.38.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.40.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.40.2.1 29-Apr-2005  kent sync with -current
 1.41.4.3 03-Sep-2007  yamt sync with head.
 1.41.4.2 30-Dec-2006  yamt sync with head.
 1.41.4.1 21-Jun-2006  yamt sync with head.
 1.43.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.43.10.1 19-Apr-2006  elad sync with head.
 1.43.8.2 03-Sep-2006  yamt sync with head.
 1.43.8.1 24-May-2006  yamt sync with head.
 1.43.6.1 22-Apr-2006  simonb Sync with head.
 1.43.4.1 09-Sep-2006  rpaulo sync with head
 1.45.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.46.4.2 10-Dec-2006  yamt sync with head.
 1.46.4.1 22-Oct-2006  yamt sync with head
 1.46.2.1 18-Nov-2006  ad Sync with head.
 1.49.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.49.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.50.36.2 28-Sep-2008  mjf Sync with HEAD.
 1.50.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.51.4.5 11-Mar-2010  yamt sync with head
 1.51.4.4 20-Jun-2009  yamt sync with head
 1.51.4.3 16-May-2009  yamt sync with head
 1.51.4.2 04-May-2009  yamt sync with head.
 1.51.4.1 16-May-2008  yamt sync with head.
 1.51.2.1 18-May-2008  yamt sync with head.
 1.52.6.1 19-Oct-2008  haad Sync with HEAD.
 1.52.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.54.8.2 23-Jul-2009  jym Sync with HEAD.
 1.54.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.54.6.3 13-Dec-2008  ad Fix locking for ac97.
 1.54.6.2 12-Dec-2008  ad Checkpoint work in progress.
 1.54.6.1 11-Dec-2008  ad Checkpoint work in progress.
 1.59.14.4 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.59.14.3 21-Nov-2011  jakllsch Make emuxki(4) work w/ audiomp changes.
 1.59.14.2 19-Nov-2011  jmcneill adapt to audiomp api changes
 1.59.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.59.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.59.12.1 17-Apr-2012  yamt sync with head
 1.61.2.1 18-Feb-2012  mrg merge to -current.
 1.62.10.1 18-May-2014  rmind sync with head
 1.62.6.2 03-Dec-2017  jdolecek update from HEAD
 1.62.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.63.6.2 28-Aug-2017  skrll Sync with HEAD
 1.63.6.1 09-Jul-2016  skrll Sync with HEAD
 1.65.10.1 10-Jun-2019  christos Sync with HEAD
 1.65.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.67.2.7 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.67.2.6 03-May-2019  isaki Remove unnecessary header file.
 1.67.2.5 01-May-2019  isaki Use __nothing macro.
 1.67.2.4 01-May-2019  isaki Reimplement emuxki driver.
- Use single voice per playback and per recording.
- Use fixed format, 2ch/48kHz, to simplify.
- Fix several problems in previous driver.
And now it works even on alpha!
The driver is written by Y.Sugahara. Thanks!
 1.67.2.3 01-May-2019  isaki Adapt to audio2.
- XXX New set_format is not implemented at this point.
This implementation can not adapt to audio2 (and it also has not
worked since netbsd-8).
The driver supports multiple hardware stream which is named 'voice'.
This voice was allocated at open() and was deallocated at close().
However, in order to support mixing, some interfaces such as
set_params() (or set_format in audio2) has to be called before open().
 1.67.2.2 21-Apr-2019  isaki Make it compilable (on this branch).
flags here is F(READ|WRITE), not AUOPEN_(READ|WRITE).
 1.67.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.70.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 07-Sep-2022  khorben emuxki(4): import a list of board definitions

This is inspired by the cxdtv(4) driver.

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI)
and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe).

Additional sound cards sponsored by the NetBSD Foundation; thanks!
 1.1 07-Sep-2022  khorben emuxki(4): import a list of board definitions

This is inspired by the cxdtv(4) driver.

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI)
and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe).

Additional sound cards sponsored by the NetBSD Foundation; thanks!
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 11-Dec-2005  christos branches: 1.7.70; 1.7.72; 1.7.74;
merge ktrace-lwp.
 1.6 15-Jan-2005  kent ansify and KNF
 1.5 27-May-2004  christos PR/25731: Adam K kirchhoff: Audigy support with the emuxki driver.
 1.4 24-Feb-2004  wiz occured -> occurred. From Peter Postma.
 1.3 28-Jan-2003  wiz branches: 1.3.2;
unknown, not unkown. Noted by mjl.
 1.2 23-Dec-2001  jdolecek branches: 1.2.2; 1.2.4;
Whitespace cleanup, streight from Yannick Montulet.
 1.1 17-Oct-2001  jdolecek branches: 1.1.2;
Add driver for Creative Labs SBLive! EMU10000, possibly also PCI512.
Written by Yannick Montulet (thanks!), with only couple minor touches by me.
 1.1.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.1.2.1 17-Oct-2001  nathanw file emuxkireg.h was added on branch nathanw_sa on 2001-10-22 20:41:23 +0000
 1.2.4.2 19-Jan-2002  he Pull up revision 1.1-1.2 (new, requested by he):
Add driver for Creative Labs SBLive! EMU10000 and (probably) PCI512.
Fixes PR#15260.
 1.2.4.1 23-Dec-2001  he file emuxkireg.h was added on branch netbsd-1-5 on 2002-01-19 21:54:30 +0000
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 23-Dec-2001  thorpej file emuxkireg.h was added on branch kqueue on 2002-01-10 19:56:32 +0000
 1.3.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.74.1 16-May-2008  yamt sync with head.
 1.7.72.1 18-May-2008  yamt sync with head.
 1.7.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.16 07-Sep-2022  khorben emuxki(4): import a list of board definitions

This is inspired by the cxdtv(4) driver.

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI)
and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe).

Additional sound cards sponsored by the NetBSD Foundation; thanks!
 1.15 07-Sep-2022  khorben emuxki(4): place struct emuxki_softc into its own file

NFCI
 1.14 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.13 23-Nov-2011  jmcneill branches: 1.13.50; 1.13.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.12 09-Jun-2009  tsutsui branches: 1.12.12; 1.12.14;
Split device_t/softc.

Tested on:
emuxki0 at pci2 dev 7 function 0: Creative Labs SBLive! EMU 10000
(audio multimedia, revision 0x05)
 1.11 28-Apr-2008  martin branches: 1.11.12; 1.11.14;
Remove clause 3 and 4 from TNF licenses
 1.10 04-Mar-2007  christos branches: 1.10.36; 1.10.38; 1.10.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 11-Dec-2005  christos branches: 1.9.26; 1.9.28;
merge ktrace-lwp.
 1.8 15-Jan-2005  kent branches: 1.8.10;
ansify and KNF
 1.7 27-May-2004  christos PR/25731: Adam K kirchhoff: Audigy support with the emuxki driver.
 1.6 03-May-2003  wiz branches: 1.6.2;
DMA, not dma nor Dma.
 1.5 26-Apr-2003  wiz Management, not managment. Mostly from jmc@openbsd.
 1.4 18-Feb-2003  wiz s/intial/initial/, from jmc in .pl in PR 20414.
 1.3 23-Dec-2001  jdolecek branches: 1.3.2; 1.3.4;
Merge in changes sent by Michael Shalayeff, from OpenBSD port of this driver:
- use better default for DAC level (previous produced distorted output)
- preserve DAC setting in between openings
 1.2 23-Dec-2001  jdolecek Whitespace cleanup, streight from Yannick Montulet.
 1.1 17-Oct-2001  jdolecek branches: 1.1.2;
Add driver for Creative Labs SBLive! EMU10000, possibly also PCI512.
Written by Yannick Montulet (thanks!), with only couple minor touches by me.
 1.1.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.1.2.1 17-Oct-2001  nathanw file emuxkivar.h was added on branch nathanw_sa on 2001-10-22 20:41:23 +0000
 1.3.4.2 19-Jan-2002  he Pull up revisions 1.1-1.3 (new, requested by he):
Add driver for Creative Labs SBLive! EMU10000 and (probably) PCI512.
Fixes PR#15260.
 1.3.4.1 23-Dec-2001  he file emuxkivar.h was added on branch netbsd-1-5 on 2002-01-19 21:54:48 +0000
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 23-Dec-2001  thorpej file emuxkivar.h was added on branch kqueue on 2002-01-10 19:56:32 +0000
 1.6.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.1 03-Sep-2007  yamt sync with head.
 1.9.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.40.2 20-Jun-2009  yamt sync with head
 1.10.40.1 16-May-2008  yamt sync with head.
 1.10.38.1 18-May-2008  yamt sync with head.
 1.10.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.14.1 23-Jul-2009  jym Sync with HEAD.
 1.11.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.12.14.2 21-Nov-2011  jakllsch Make emuxki(4) work w/ audiomp changes.
 1.12.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.12.12.1 17-Apr-2012  yamt sync with head
 1.13.54.1 01-May-2019  isaki Reimplement emuxki driver.
- Use single voice per playback and per recording.
- Use fixed format, 2ch/48kHz, to simplify.
- Fix several problems in previous driver.
And now it works even on alpha!
The driver is written by Y.Sugahara. Thanks!
 1.13.50.1 10-Jun-2019  christos Sync with HEAD
 1.66 10-May-2023  riastradh esa(4): Use config_detach_children.
 1.65 08-Jun-2019  isaki Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.64 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.63 16-Mar-2019  isaki branches: 1.63.2;
Use C99 style struct initializer to audio_hw_if.
 1.62 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.61 01-Jun-2017  chs branches: 1.61.8; 1.61.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.60 29-Mar-2014  christos branches: 1.60.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.59 16-Oct-2013  christos - use proper types (uint16_t instead of uint32_t)
- don't index past the end of arrays
- use __arraycount() consistently instead of manual cruft.
- remove useless cast
 1.58 30-Jan-2012  drochner branches: 1.58.6; 1.58.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.57 03-Dec-2011  ryo branches: 1.57.2;
the argument of esa_get_locks() is struct esa_voice *, not struct esa_softc *.

ok by mrg@ jmcneill@
 1.56 24-Nov-2011  mrg put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.55 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.54 24-Feb-2010  dyoung branches: 1.54.10; 1.54.12;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.53 08-Jan-2010  dyoung branches: 1.53.2;
Expand PMF_FN_* macros.
 1.52 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.51 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.50 10-Jun-2008  dyoung branches: 1.50.8; 1.50.10;
Fix a couple of mistakes in the device_t/softc split that cause
machines such as my HP Pavilion N3270 to freeze at boot. This
should fix PR kern/38815, too.
 1.49 13-May-2008  jmcneill branches: 1.49.2;
Hook hardware volume buttons into pmf.
 1.48 27-Mar-2008  jmcneill branches: 1.48.2; 1.48.4; 1.48.6;
Split device_t and softc
 1.47 21-Mar-2008  dyoung Use aprint_*_dev() instead of accessing struct device member dv_xname
directly.
 1.46 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.45 22-Feb-2008  dyoung Add methods for detaching self and for detaching children.

Use device_t and accessors. Use aprint_*_dev().
 1.44 27-Jan-2008  jmcneill branches: 1.44.2; 1.44.6;
On resume, ensure that esa is powered up, and ensure we power the
AC97 codec once the host controller is up and running.
 1.43 09-Dec-2007  jmcneill Merge jmcneill-pm branch.
 1.42 19-Oct-2007  ad branches: 1.42.2; 1.42.4; 1.42.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.41 04-Mar-2007  christos branches: 1.41.2; 1.41.14; 1.41.16; 1.41.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.40 16-Nov-2006  christos branches: 1.40.4; 1.40.6;
__unused removal on arguments; approved by core.
 1.39 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.38 25-Sep-2006  jmcneill No need to call pci_set_powerstate from our powerhook, the bus handles this
for us now.
 1.37 24-Sep-2006  jmcneill PR# 23620: channels are swapped
 1.36 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.35 24-Sep-2006  jmcneill Formatting fixups, remove commented out code that should not have been here,
and remove a few unnecessary XXX comments.
 1.34 30-Aug-2006  christos branches: 1.34.2; 1.34.4;
missing comma
 1.33 30-Aug-2006  christos fix incomplete initializers
 1.32 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.31 11-Dec-2005  christos branches: 1.31.4; 1.31.8; 1.31.14; 1.31.16;
merge ktrace-lwp.
 1.30 29-Oct-2005  jmcneill Wow, this is clearly wrong (found in esa_set_params):
if (p->channels < 1 && p->channels > 2)
return EINVAL;
Change the 'and' to an 'or' so the check actually does something.
 1.29 28-Jun-2005  thorpej branches: 1.29.2; 1.29.4;
Use ANSI function decls and static.
 1.28 15-Jan-2005  kent ansify and KNF
 1.27 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.26 29-Oct-2004  yamt branches: 1.26.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.25 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.24 21-Jul-2004  scw - Don't hardcode buffer size and block size in esa_round_buffersize() and
esa_round_blocksize().
- Fix esa_trigger_output() and esa_trigger_input() to initialise the
channel's buffer/block size using the supplied parameters.
- While here, simplify esa_intr().

This gets kphone working on my esa(4)-equipped laptop.
 1.23 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.22 25-Oct-2003  christos branches: 1.22.2;
Fix uninitialized variable warnings
 1.21 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.20 01-Feb-2003  thorpej branches: 1.20.2;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.19 31-Jan-2003  thorpej Use aprint_*().
 1.18 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.17 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.16 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.15 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.14 08-Aug-2002  itojun audit bitmask test mistake (s/&&/&/). from openbsd
 1.13 02-Jun-2002  jmcneill Fix the mixer controls to work a bit better.
 1.12 24-Mar-2002  jmcneill branches: 1.12.2;
Fix suspend/resume. Previously, suspending/resuming while playback was active
would either:

1. Cause the machine to stop responding, or
2. Cause the currently playing voices to stop output.

With this change, voices are stopped on suspend, and continue from where they
left off on resume.
 1.11 16-Mar-2002  jmcneill Add multiple voice support to the ESS Allegro-1 / Maestro-3 family of
audio accelerators.

Mixing is done in hardware by the ASSP, but is limited to 4 simultaneous
channels due to the restricted "minisrc" image that we are currently
working with.

Due to limitations in the audio subsystem, I'm currently attaching multiple
'audio' devices to 'esa', one for each voice. Because of this hack, the
default ESA_NUM_VOICES is 1.
 1.10 10-Mar-2002  jmcneill Correctly enable/disable the low-pass filter, depending on the sample rate.
This fixes timing issues when playing back at 48kHz (noticable using
pkgsrc/graphics/mplayer and DivX ;-) streams).
 1.9 26-Feb-2002  joda in esa_resume, call esa_codec_reset; makes it much more happy after a
suspend on my O500 (snatched from FreeBSD)
 1.8 23-Jan-2002  pooka branches: 1.8.2;
free memory allocated for suspend save area in detach
 1.7 14-Jan-2002  pooka Use standard PCI power management definitions from pcireg.h instead
of homegrown ones.

suggested by Soren
 1.6 13-Jan-2002  jmcneill Every card I've seen has had their channels swapped with respect
to the mixer. Ie:
$ mixerctl -w outputs.master=0,191
Would result in the _right_ speaker being turned off.

So, we will swap the left and right mixer channels to compensate
for this.
 1.5 13-Jan-2002  jmcneill Use malloc's M_ZERO flag instead of malloc/memset.
 1.4 13-Jan-2002  pooka Add support for the driver to work after suspend/resume. Does nothing
fancy, works for the basic output case, but does not support programs
which use playback while going into suspend.

Sketched after code found in FreeBSD and Linux drivers.
 1.3 07-Jan-2002  jmcneill branches: 1.3.2; 1.3.4;
Integrate recording support into the driver. Not very heavily tested yet.
 1.2 06-Jan-2002  augustss Note that Don Kim wrote the original Linux driver.
 1.1 06-Jan-2002  jmcneill Import driver for the ESS Allegro-1 / Maestro-3 based PCI Audio Accelerators.
 1.3.4.8 29-Dec-2002  thorpej Sync with HEAD.
 1.3.4.7 18-Oct-2002  nathanw Catch up to -current.
 1.3.4.6 13-Aug-2002  nathanw Catch up to -current.
 1.3.4.5 20-Jun-2002  nathanw Catch up to -current.
 1.3.4.4 12-Apr-2002  nathanw Missed some revisions in the merge.
 1.3.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.2 11-Jan-2002  nathanw More catchup.
 1.3.4.1 07-Jan-2002  nathanw file esa.c was added on branch nathanw_sa on 2002-01-11 23:39:17 +0000
 1.3.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 07-Jan-2002  thorpej file esa.c was added on branch kqueue on 2002-01-10 19:56:32 +0000
 1.8.2.3 09-Mar-2002  he Apply patch (requested by jmcneill):
Fix timing of playback at 48kHz.
 1.8.2.2 24-Jan-2002  he Pull up revisions 1.1-1.8 (new, via patch, requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.8.2.1 23-Jan-2002  he file esa.c was added on branch netbsd-1-5 on 2002-01-24 22:35:57 +0000
 1.12.2.2 29-Aug-2002  gehenna catch up with -current.
 1.12.2.1 20-Jun-2002  gehenna catch up with -current.
 1.20.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.20.2.3 02-Nov-2004  skrll Sync with HEAD.
 1.20.2.2 24-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.1 22-Sep-2004  jmc Pullup rev 1.25 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.26.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.26.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.29.4.1 02-Nov-2005  yamt sync with head.
 1.29.2.8 24-Mar-2008  yamt sync with head.
 1.29.2.7 27-Feb-2008  yamt sync with head.
 1.29.2.6 04-Feb-2008  yamt sync with head.
 1.29.2.5 21-Jan-2008  yamt sync with head
 1.29.2.4 27-Oct-2007  yamt sync with head.
 1.29.2.3 03-Sep-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.31.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.31.14.1 19-Jun-2006  chap Sync with head.
 1.31.8.2 03-Sep-2006  yamt sync with head.
 1.31.8.1 26-Jun-2006  yamt sync with head.
 1.31.4.1 09-Sep-2006  rpaulo sync with head
 1.34.4.2 10-Dec-2006  yamt sync with head.
 1.34.4.1 22-Oct-2006  yamt sync with head
 1.34.2.1 18-Nov-2006  ad Sync with head.
 1.40.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.40.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.41.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.41.16.3 23-Mar-2008  matt sync with HEAD
 1.41.16.2 09-Jan-2008  matt sync with HEAD
 1.41.16.1 06-Nov-2007  matt sync with HEAD
 1.41.14.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.41.14.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.41.14.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.41.14.1 05-Oct-2007  joerg Convert esa(4) to PNP power management.
 1.41.2.1 23-Oct-2007  ad Sync with head.
 1.42.6.1 11-Dec-2007  yamt sync with head.
 1.42.4.1 26-Dec-2007  ad Sync with head.
 1.42.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.44.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.44.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.44.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.44.2.1 24-Mar-2008  keiichi sync with head.
 1.48.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.4.4 11-Mar-2010  yamt sync with head
 1.48.4.3 16-May-2009  yamt sync with head
 1.48.4.2 04-May-2009  yamt sync with head.
 1.48.4.1 16-May-2008  yamt sync with head.
 1.48.2.2 17-Jun-2008  yamt sync with head.
 1.48.2.1 18-May-2008  yamt sync with head.
 1.49.2.1 18-Jun-2008  simonb Sync with head.
 1.50.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.8.2 12-Dec-2008  ad Checkpoint work in progress.
 1.50.8.1 08-Dec-2008  ad Convert some more drivers.
 1.53.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.54.12.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.54.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.54.10.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.54.10.1 17-Apr-2012  yamt sync with head
 1.57.2.1 18-Feb-2012  mrg merge to -current.
 1.58.10.1 18-May-2014  rmind sync with head
 1.58.6.2 03-Dec-2017  jdolecek update from HEAD
 1.58.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.60.6.1 28-Aug-2017  skrll Sync with HEAD
 1.61.10.1 10-Jun-2019  christos Sync with HEAD
 1.61.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.63.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.63.2.3 04-May-2019  isaki Remove obsoleted methods in audio_hw_if.
- drain: is handled in audio upper layer now.
- mappage: is handled in audio upper layer now.
- setfd: no one uses and it's meaningless now.
 1.63.2.2 28-Apr-2019  isaki Adapt to audio2.
- Fix wrong round_blocksize() calculation. ~0x20 -> -0x20.
 1.63.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.7 16-Oct-2013  christos - use proper types (uint16_t instead of uint32_t)
- don't index past the end of arrays
- use __arraycount() consistently instead of manual cruft.
- remove useless cast
 1.6 11-Dec-2005  christos branches: 1.6.110; 1.6.120; 1.6.126;
merge ktrace-lwp.
 1.5 15-Jan-2005  kent ansify and KNF
 1.4 07-Jan-2002  jmcneill branches: 1.4.2; 1.4.4; 1.4.6; 1.4.22;
Integrate recording support into the driver. Not very heavily tested yet.
 1.3 06-Jan-2002  augustss Note that Don Kim wrote the original Linux driver.
 1.2 06-Jan-2002  augustss Change copyright somewhat. (These are not TNF copyright templates so I
removed the advertising clause.)
 1.1 06-Jan-2002  augustss Part of the ESS Allegro-1 & Maestro3 driver.
 1.4.22.1 17-Jan-2005  skrll Sync with HEAD.
 1.4.6.2 24-Jan-2002  he Pull up revisions 1.1-1.4 (new, requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.4.6.1 07-Jan-2002  he file esadsp.h was added on branch netbsd-1-5 on 2002-01-24 22:36:48 +0000
 1.4.4.2 11-Jan-2002  nathanw More catchup.
 1.4.4.1 07-Jan-2002  nathanw file esadsp.h was added on branch nathanw_sa on 2002-01-11 23:39:17 +0000
 1.4.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 07-Jan-2002  thorpej file esadsp.h was added on branch kqueue on 2002-01-10 19:56:33 +0000
 1.6.126.1 18-May-2014  rmind sync with head
 1.6.120.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.110.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11 13-May-2023  andvar fix typo in unused definition s/ESA_KDATA_OUEUE_LEFT/ESA_KDATA_QUEUE_LEFT/.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 15-Jan-2005  kent ansify and KNF
 1.8 06-Mar-2002  jmcneill branches: 1.8.14;
Fix another typo that I missed last time (foo -> ESA_foo)
 1.7 06-Mar-2002  jmcneill Fix a few typos (foo -> ESA_foo).
 1.6 14-Jan-2002  pooka branches: 1.6.2;
Use standard PCI power management definitions from pcireg.h instead
of homegrown ones.

suggested by Soren
 1.5 13-Jan-2002  jmcneill Remove unnecessary (also unused) AC'97 definitions -- they already exist
in syssrc/sys/dev/ic/ac97reg.h.
 1.4 13-Jan-2002  pooka * add power definitions
* fix a few (hidden) typos in the definitions
 1.3 06-Jan-2002  augustss branches: 1.3.2; 1.3.4;
Note that Don Kim wrote the original Linux driver.
 1.2 06-Jan-2002  augustss Change copyright somewhat. (These are not TNF copyright templates so I
removed the advertising clause.)
 1.1 06-Jan-2002  augustss Part of the ESS Allegro-1 & Maestro3 driver.
 1.3.4.4 12-Apr-2002  nathanw Missed some revisions in the merge.
 1.3.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.2 11-Jan-2002  nathanw More catchup.
 1.3.4.1 06-Jan-2002  nathanw file esareg.h was added on branch nathanw_sa on 2002-01-11 23:39:18 +0000
 1.3.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 06-Jan-2002  thorpej file esareg.h was added on branch kqueue on 2002-01-10 19:56:33 +0000
 1.6.2.2 24-Jan-2002  he Pull up revisions 1.1-1.6 (new, requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.6.2.1 14-Jan-2002  he file esareg.h was added on branch netbsd-1-5 on 2002-01-24 22:36:33 +0000
 1.8.14.1 17-Jan-2005  skrll Sync with HEAD.
 1.12 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.11 23-Nov-2011  jmcneill branches: 1.11.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.10 27-Mar-2008  jmcneill branches: 1.10.16; 1.10.38; 1.10.40;
Missed in previous device_t/softc split commit for esa, pointed out by
xtraeme@
 1.9 09-Dec-2007  jmcneill branches: 1.9.10;
Merge jmcneill-pm branch.
 1.8 04-Mar-2007  christos branches: 1.8.14; 1.8.16; 1.8.24; 1.8.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 11-Dec-2005  christos branches: 1.7.26; 1.7.28;
merge ktrace-lwp.
 1.6 24-Mar-2005  jmcneill branches: 1.6.2;
Update my email address (the one listed hasn't been active in years).
 1.5 15-Jan-2005  kent branches: 1.5.2; 1.5.4;
ansify and KNF
 1.4 16-Mar-2002  jmcneill branches: 1.4.12;
Add multiple voice support to the ESS Allegro-1 / Maestro-3 family of
audio accelerators.

Mixing is done in hardware by the ASSP, but is limited to 4 simultaneous
channels due to the restricted "minisrc" image that we are currently
working with.

Due to limitations in the audio subsystem, I'm currently attaching multiple
'audio' devices to 'esa', one for each voice. Because of this hack, the
default ESA_NUM_VOICES is 1.
 1.3 13-Jan-2002  pooka branches: 1.3.2;
Add support for the driver to work after suspend/resume. Does nothing
fancy, works for the basic output case, but does not support programs
which use playback while going into suspend.

Sketched after code found in FreeBSD and Linux drivers.
 1.2 07-Jan-2002  jmcneill branches: 1.2.2; 1.2.4;
Integrate recording support into the driver. Not very heavily tested yet.
 1.1 06-Jan-2002  jmcneill Import driver for the ESS Allegro-1 / Maestro-3 based PCI Audio Accelerators.
 1.2.4.4 12-Apr-2002  nathanw Merge miss.
 1.2.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.2 11-Jan-2002  nathanw More catchup.
 1.2.4.1 07-Jan-2002  nathanw file esavar.h was added on branch nathanw_sa on 2002-01-11 23:39:18 +0000
 1.2.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 07-Jan-2002  thorpej file esavar.h was added on branch kqueue on 2002-01-10 19:56:33 +0000
 1.3.2.2 24-Jan-2002  he Pull up revisions 1.1-1.3 (new, requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.3.2.1 13-Jan-2002  he file esavar.h was added on branch netbsd-1-5 on 2002-01-24 22:36:13 +0000
 1.4.12.2 01-Apr-2005  skrll Sync with HEAD.
 1.4.12.1 17-Jan-2005  skrll Sync with HEAD.
 1.5.4.1 26-Mar-2005  yamt sync with head.
 1.5.2.1 29-Apr-2005  kent sync with -current
 1.6.2.2 21-Jan-2008  yamt sync with head
 1.6.2.1 03-Sep-2007  yamt sync with head.
 1.7.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.7.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.26.1 11-Dec-2007  yamt sync with head.
 1.8.24.1 26-Dec-2007  ad Sync with head.
 1.8.16.1 09-Jan-2008  matt sync with HEAD
 1.8.14.1 05-Oct-2007  joerg Nuke some unused prototypes and softc members after PNP conversion.
 1.9.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.40.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.10.38.2 30-Oct-2012  yamt sync with head
 1.10.38.1 17-Apr-2012  yamt sync with head
 1.10.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.10.16.1 08-Dec-2008  ad Convert some more drivers.
 1.11.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.17 19-Oct-2009  bouyer branches: 1.17.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.16 15-May-2009  tsutsui Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2
 1.15 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.14 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.13 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.12 16-Nov-2006  christos branches: 1.12.52; 1.12.68;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 27-Feb-2005  perry nuke trailing whitespace
 1.7 04-Feb-2005  perry de-__P
 1.6 09-Apr-2003  thorpej branches: 1.6.2; 1.6.10; 1.6.12;
Need <uvm/uvm_extern.h>.
 1.5 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 23-Apr-2002  bouyer branches: 1.2.6; 1.2.8;
More copyright fixes, pointed out by Thomas. Thanks !
 1.1 21-Apr-2002  bouyer First cut at a esiop driver (enhanced siop). Doesn't implement tagged queuing
yet.
If is restricted to SIOP which implement the load/store instruction, and
has 10 scratch registers (basically, 825 and newer, possibly 770).
It implements a different interface between host and script, using a real
ring for command starts, and improved support for reconnect which will allow
256 tag per device. It uses interrupt on the fly to signal complete command,
which allows several commands to be serviced per interrupt and doesn't require
the script to stop to signal command completion.
 1.2.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 23-Apr-2002  jdolecek file esiop_pci.c was added on branch kqueue on 2002-06-23 17:47:37 +0000
 1.2.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.2.6.1 23-Apr-2002  nathanw file esiop_pci.c was added on branch nathanw_sa on 2002-06-20 03:45:22 +0000
 1.6.12.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.12.1 12-Feb-2005  yamt sync with head.
 1.6.10.1 29-Apr-2005  kent sync with -current
 1.6.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.9.2.1 30-Dec-2006  yamt sync with head.
 1.10.22.2 10-Dec-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.12.68.2 23-Jul-2009  jym Sync with HEAD.
 1.12.68.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.52.2 11-Mar-2010  yamt sync with head
 1.12.52.1 16-May-2009  yamt sync with head
 1.17.4.1 05-Mar-2011  rmind sync with head
 1.67 01-Sep-2025  mlelstv With the device_t split, esm(4) got damaged since the wrong pointer
is passed around.

Fixes PR install/59621

Pullups -11, -10, -9.
 1.66 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.65 19-Apr-2020  isaki Fix round_blocksize not to return 0.
 1.64 05-Oct-2019  mrg branches: 1.64.6;
add missing break.
 1.63 08-Jun-2019  isaki branches: 1.63.2;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.62 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.61 16-Mar-2019  isaki branches: 1.61.2;
Use C99 style struct initializer to audio_hw_if.
 1.60 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.59 07-Jul-2016  msaitoh branches: 1.59.16; 1.59.18;
KNF. Remove extra spaces. No functional change.
 1.58 29-Mar-2014  christos branches: 1.58.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.57 14-Sep-2013  joerg GC wc_rdreg and wc_rdchctl
 1.56 30-Jan-2012  drochner branches: 1.56.6; 1.56.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.55 24-Nov-2011  mrg branches: 1.55.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.54 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.53 24-Feb-2010  dyoung branches: 1.53.10; 1.53.12;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.52 08-Jan-2010  dyoung branches: 1.52.2;
Expand PMF_FN_* macros.
 1.51 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.50 12-Jun-2009  cegger use __arraycount(). Same object code generated.
 1.49 07-May-2009  cegger device_t/softc split
patch presented on tech-kern@, no comments on it
 1.48 05-May-2009  cegger struct cfdata * -> cfdata_t
 1.47 10-Apr-2008  cegger branches: 1.47.4; 1.47.16; 1.47.18;
use aprint_*_dev and device_xname
 1.46 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.45 23-Feb-2008  dyoung Detach self and children. Make some functions static. Use device_t
and accessors. Use PMF_FN_*.
 1.44 09-Dec-2007  jmcneill branches: 1.44.6; 1.44.10;
Merge jmcneill-pm branch.
 1.43 19-Oct-2007  ad branches: 1.43.4; 1.43.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.42 04-Mar-2007  christos branches: 1.42.2; 1.42.14; 1.42.16; 1.42.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.41 16-Nov-2006  christos branches: 1.41.4; 1.41.6;
__unused removal on arguments; approved by core.
 1.40 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.39 25-Sep-2006  jmcneill No need to call pci_set_powerstate from our powerhook, the bus handles this
for us now.
 1.38 24-Sep-2006  jmcneill PR# 29372: notebook with Maestro 2E sound chip panics (w/ fix)
 1.37 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.36 30-Aug-2006  christos branches: 1.36.2; 1.36.4;
fix incomplete initializers
 1.35 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.34 14-Apr-2006  christos branches: 1.34.2; 1.34.4;
Coverity CID 1102: Make the code more coverity friendly.
 1.33 08-Mar-2006  lukem branches: 1.33.2;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.32 24-Dec-2005  perry branches: 1.32.4; 1.32.6; 1.32.8; 1.32.10;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.31 11-Dec-2005  christos merge ktrace-lwp.
 1.30 15-Jan-2005  kent branches: 1.30.10;
ansify and KNF
 1.29 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.28 29-Oct-2004  yamt branches: 1.28.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.27 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.26 08-Jul-2004  kleink Fix AUDIO_DEBUG printf formats.
 1.25 30-Apr-2004  simonb Set the WAVCACHE_CHCTL_U8 flag for both specific-endian unsigned
linear 8 bit encodings as well as for native.
Fixes problems with playing 8 bit .wav files on my Dell Inspiron 5000e.
 1.24 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.23 04-Dec-2003  keihan branches: 1.23.2;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.22 03-Feb-2003  kleink branches: 1.22.2;
Fix printf format warnings.
 1.21 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.20 31-Jan-2003  thorpej Use aprint_*().
 1.19 31-Dec-2002  fredette Removed esm_freemem(), which isn't used any more.
 1.18 30-Dec-2002  fredette First cut at recording support for the ESS Maestro-2 and 2e.
16-bit mono recording seems to work OK. 16-bit stereo recording
is missing the left channel for reasons unknown, fixes welcome.
8-bit recording still unsupported.
 1.17 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 14-Jan-2002  pooka Use standard PCI power management definitions from pcireg.h instead
of homegrown ones.

suggested by Soren
 1.12 13-Nov-2001  lukem add RCSID
 1.11 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.10 25-Apr-2001  simonb branches: 1.10.2; 1.10.4; 1.10.6;
Spell "portege" correctly - it's a computer, not a car.
 1.9 31-Mar-2001  rh Fix DPRINTF statements so this compiles with debug enabled.
 1.8 08-Mar-2001  ichiro Fix powerhook routine.
support resume/suspend.
 1.7 12-Feb-2001  ichiro branches: 1.7.2;
Power Management Hook
esm_powerhook();
 1.6 26-Jan-2001  rh Add left/right reversal quirk entry for Toshiba Protege 7020
 1.5 26-Jan-2001  rh Add quirk for Compaq Armada M700 to fix left/right channel reversal.
Quirk entry provided by Joachim Koenig-Baltes <koenig@cms.tecmath.com>
 1.4 18-Jan-2001  tv No-op commit to force update to a non-"-kk" revision.
 1.3 09-Jan-2001  rh branches: 1.3.2;
Add a quirk table for specific implementations.
Change the NEC-specific subvendor test for GPIO initialization into a more
generic quirk table flag.
Add a quirk flag for hardware that has left and right channels reversed
(currently the COMPAL 38W2 a.k.a. Dell Inspiron 5000e)
Clean up PCM channel initialization and add channel swapping option.
 1.2 09-Jan-2001  lukem *minor* knf
 1.1 08-Jan-2001  rh Initial import of the Maestro 2/2e 'esm' PCI audio driver. This driver
is based on the FreeBSD 'maestro' driver by Taku YAMAMOTO
<taku@cent.saitama-u.ac.jp>
 1.3.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.3.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.2.1 09-Jan-2001  bouyer file esm.c was added on branch thorpej_scsipi on 2001-01-18 09:23:25 +0000
 1.7.2.8 03-Jan-2003  thorpej Sync with HEAD.
 1.7.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.7.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.7.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.7.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.7.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.10.6.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.10.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.10.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.2.2 03-May-2001  he Pull up revisions 1.1-1.10 (new, via patch, requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.10.2.1 25-Apr-2001  he file esm.c was added on branch netbsd-1-5 on 2001-05-03 20:57:08 +0000
 1.22.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.22.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.22.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.2.1 22-Sep-2004  jmc Pullup rev 1.27 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.28.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.28.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.30.10.7 24-Mar-2008  yamt sync with head.
 1.30.10.6 27-Feb-2008  yamt sync with head.
 1.30.10.5 21-Jan-2008  yamt sync with head
 1.30.10.4 27-Oct-2007  yamt sync with head.
 1.30.10.3 03-Sep-2007  yamt sync with head.
 1.30.10.2 30-Dec-2006  yamt sync with head.
 1.30.10.1 21-Jun-2006  yamt sync with head.
 1.32.10.1 19-Apr-2006  elad sync with head.
 1.32.8.4 03-Sep-2006  yamt sync with head.
 1.32.8.3 26-Jun-2006  yamt sync with head.
 1.32.8.2 24-May-2006  yamt sync with head.
 1.32.8.1 13-Mar-2006  yamt sync with head.
 1.32.6.1 22-Apr-2006  simonb Sync with head.
 1.32.4.1 09-Sep-2006  rpaulo sync with head
 1.33.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.34.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.34.2.1 19-Jun-2006  chap Sync with head.
 1.36.4.2 10-Dec-2006  yamt sync with head.
 1.36.4.1 22-Oct-2006  yamt sync with head
 1.36.2.1 18-Nov-2006  ad Sync with head.
 1.41.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.41.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.42.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.42.16.3 23-Mar-2008  matt sync with HEAD
 1.42.16.2 09-Jan-2008  matt sync with HEAD
 1.42.16.1 06-Nov-2007  matt sync with HEAD
 1.42.14.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.42.14.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.42.14.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.42.14.1 05-Oct-2007  joerg Convert esm(4) to PNP power management.
 1.42.2.1 23-Oct-2007  ad Sync with head.
 1.43.6.1 11-Dec-2007  yamt sync with head.
 1.43.4.1 26-Dec-2007  ad Sync with head.
 1.44.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.44.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.44.6.1 24-Mar-2008  keiichi sync with head.
 1.47.18.2 23-Jul-2009  jym Sync with HEAD.
 1.47.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.47.16.3 13-Dec-2008  ad Fix locking for ac97.
 1.47.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.47.16.1 08-Dec-2008  ad Convert some more drivers.
 1.47.4.3 11-Mar-2010  yamt sync with head
 1.47.4.2 20-Jun-2009  yamt sync with head
 1.47.4.1 16-May-2009  yamt sync with head
 1.52.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.53.12.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.53.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.53.10.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.53.10.1 17-Apr-2012  yamt sync with head
 1.55.2.1 18-Feb-2012  mrg merge to -current.
 1.56.10.1 18-May-2014  rmind sync with head
 1.56.6.2 03-Dec-2017  jdolecek update from HEAD
 1.56.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.6.1 09-Jul-2016  skrll Sync with HEAD
 1.59.18.3 21-Apr-2020  martin Sync with HEAD
 1.59.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.59.18.1 10-Jun-2019  christos Sync with HEAD
 1.59.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.61.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.61.2.2 28-Apr-2019  isaki Adapt to audio2.
- Recording seems a bit tricky so I left it untouched.
(It should work on audio2 as well if it works on -current/-8.)
 1.61.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.63.2.1 27-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #493):

sys/dev/pci/esm.c: revision 1.64

add missing break.
 1.64.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.4 30-Dec-2002  fredette branches: 1.4.2;
First cut at recording support for the ESS Maestro-2 and 2e.
16-bit mono recording seems to work OK. 16-bit stereo recording
is missing the left channel for reasons unknown, fixes welcome.
8-bit recording still unsupported.
 1.3 14-Jan-2002  pooka Use standard PCI power management definitions from pcireg.h instead
of homegrown ones.

suggested by Soren
 1.2 18-Jan-2001  tv branches: 1.2.2; 1.2.4; 1.2.6;
No-op commit to force update to a non-"-kk" revision.
 1.1 08-Jan-2001  rh branches: 1.1.2;
Initial import of the Maestro 2/2e 'esm' PCI audio driver. This driver
is based on the FreeBSD 'maestro' driver by Taku YAMAMOTO
<taku@cent.saitama-u.ac.jp>
 1.1.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.1.2.1 08-Jan-2001  bouyer file esmreg.h was added on branch thorpej_scsipi on 2001-01-18 09:23:25 +0000
 1.2.6.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.2.4.2 03-May-2001  he Pull up revisions 1.1-1.2 (new, requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.2.4.1 18-Jan-2001  he file esmreg.h was added on branch netbsd-1-5 on 2001-05-03 20:57:28 +0000
 1.2.2.2 03-Jan-2003  thorpej Sync with HEAD.
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.19 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.18 23-Nov-2011  jmcneill branches: 1.18.50; 1.18.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.17 07-May-2009  cegger branches: 1.17.12; 1.17.14;
device_t/softc split
patch presented on tech-kern@, no comments on it
 1.16 23-Feb-2008  dyoung branches: 1.16.4; 1.16.16; 1.16.18;
Detach self and children. Make some functions static. Use device_t
and accessors. Use PMF_FN_*.
 1.15 09-Dec-2007  jmcneill branches: 1.15.6; 1.15.10;
Merge jmcneill-pm branch.
 1.14 04-Mar-2007  christos branches: 1.14.14; 1.14.16; 1.14.24; 1.14.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 11-Dec-2005  christos branches: 1.13.26; 1.13.28;
merge ktrace-lwp.
 1.12 15-Jan-2005  kent branches: 1.12.10;
ansify and KNF
 1.11 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.10 22-Sep-2004  kent branches: 1.10.2;
ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.9 04-Dec-2003  keihan branches: 1.9.2;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.8 01-Feb-2003  thorpej branches: 1.8.2;
Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.7 31-Dec-2002  fredette Removed esm_freemem(), which isn't used any more.
 1.6 30-Dec-2002  fredette First cut at recording support for the ESS Maestro-2 and 2e.
16-bit mono recording seems to work OK. 16-bit stereo recording
is missing the left channel for reasons unknown, fixes welcome.
8-bit recording still unsupported.
 1.5 31-Dec-2001  thorpej Avoid an "unmamed fields" warning (gcc 3.1).
 1.4 12-Feb-2001  ichiro branches: 1.4.2; 1.4.4; 1.4.6;
Power Management Hook
esm_powerhook();
 1.3 18-Jan-2001  tv No-op commit to force update to a non-"-kk" revision.
 1.2 09-Jan-2001  rh branches: 1.2.2;
Add a quirk table for specific implementations.
Change the NEC-specific subvendor test for GPIO initialization into a more
generic quirk table flag.
Add a quirk flag for hardware that has left and right channels reversed
(currently the COMPAL 38W2 a.k.a. Dell Inspiron 5000e)
Clean up PCM channel initialization and add channel swapping option.
 1.1 08-Jan-2001  rh Initial import of the Maestro 2/2e 'esm' PCI audio driver. This driver
is based on the FreeBSD 'maestro' driver by Taku YAMAMOTO
<taku@cent.saitama-u.ac.jp>
 1.2.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.2.2.1 09-Jan-2001  bouyer file esmvar.h was added on branch thorpej_scsipi on 2001-01-18 09:23:25 +0000
 1.4.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.4.2 03-May-2001  he Pull up revisions 1.1-1.4 (new, requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.4.4.1 12-Feb-2001  he file esmvar.h was added on branch netbsd-1-5 on 2001-05-03 20:57:46 +0000
 1.4.2.2 03-Jan-2003  thorpej Sync with HEAD.
 1.4.2.1 08-Jan-2002  nathanw Catch up to -current.
 1.8.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.8.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 22-Sep-2004  jmc Pullup rev 1.10 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.10.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.10.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.12.10.3 27-Feb-2008  yamt sync with head.
 1.12.10.2 21-Jan-2008  yamt sync with head
 1.12.10.1 03-Sep-2007  yamt sync with head.
 1.13.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.13.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.26.1 11-Dec-2007  yamt sync with head.
 1.14.24.1 26-Dec-2007  ad Sync with head.
 1.14.16.2 23-Mar-2008  matt sync with HEAD
 1.14.16.1 09-Jan-2008  matt sync with HEAD
 1.14.14.1 05-Oct-2007  joerg Nuke some unused prototypes and softc members after PNP conversion.
 1.15.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.6.1 24-Mar-2008  keiichi sync with head.
 1.16.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.16.16.1 08-Dec-2008  ad Convert some more drivers.
 1.16.4.1 16-May-2009  yamt sync with head
 1.17.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.17.12.1 17-Apr-2012  yamt sync with head
 1.18.54.1 28-Apr-2019  isaki Adapt to audio2.
- Recording seems a bit tricky so I left it untouched.
(It should work on audio2 as well if it works on -current/-8.)
 1.18.50.1 10-Jun-2019  christos Sync with HEAD
 1.75 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.74 26-Apr-2021  thorpej branches: 1.74.6;
- The "eso" device does not need to carry the "midibus" interface attribute.
It attaches "opl" and "mpu" instances, which themselves attach "midi".
- Be explicit about specifying the "eso" interface attribute when attaching
"opl", "mpu", and "joy" instances.
 1.73 24-Apr-2021  thorpej branches: 1.73.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.72 28-Oct-2019  joerg branches: 1.72.10;
Fix operand priority of bit op vs ternary operator.
 1.71 08-Jun-2019  isaki branches: 1.71.2;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.70 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.69 16-Mar-2019  isaki branches: 1.69.2;
Use C99 style struct initializer to audio_hw_if.
 1.68 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.67 01-Jun-2017  chs branches: 1.67.8; 1.67.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.66 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.65 29-Mar-2014  christos branches: 1.65.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.64 16-Oct-2013  christos remove unused variables.
 1.63 17-Jul-2013  soren A few "isa" files are so tightly integrated into the x86 platform code
as to not really be part of the optional isa bus autoconf machinery.

Allows configuring a kernel like so:

include "arch/amd64/conf/GENERIC"
no isa
 1.62 27-Oct-2012  chs branches: 1.62.2; 1.62.8;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.61 12-Aug-2012  gson branches: 1.61.2;
Add missing locking calls to eso_attach() to avoid panic on boot.
Partly based on a patch from mrg. Fixes PR kern/46791.
 1.60 15-May-2012  mrg don't kassert that the sc_intr_lock is held in eso_reset(). it's only
called from attach and doesn't need to have it held, and PR 46451 shows
that it currently asserts.
 1.59 24-Nov-2011  mrg branches: 1.59.2; 1.59.4;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.58 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.57 26-Nov-2009  njoly branches: 1.57.12; 1.57.14;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.56 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.55 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.54 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.53 10-Apr-2008  cegger branches: 1.53.4; 1.53.16; 1.53.18;
use aprint_*_dev and device_xname
 1.52 01-Apr-2008  xtraeme Fix fallout from device_t/softc split to mpu(4):
always pass the mpu_softc to mpu_intr(). Found by Takeshi Nakayama.
 1.51 19-Oct-2007  ad branches: 1.51.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.50 04-Mar-2007  christos branches: 1.50.2; 1.50.14; 1.50.16; 1.50.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.49 11-Jan-2007  kleink branches: 1.49.2; 1.49.4;
Replace home-grown list management for DMA buffers with SLISTs, and refactor.
 1.48 18-Dec-2006  kleink Redo rev. 1.42, fixing the original array subscript pasto the right way.
 1.47 14-Dec-2006  christos explicitly set clk to 1 or 0.
 1.46 14-Dec-2006  kleink Un-break clock selection after -Wsign-compare cleanup in rev. 1.43;
from Stephen Ma in PR kern/35220.
 1.45 16-Nov-2006  christos branches: 1.45.2;
__unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 30-Aug-2006  christos branches: 1.43.2; 1.43.4;
- fix missing initializer
- fix < 0 comparison with unsigned
 1.42 14-Apr-2006  christos Coverity CID 1539: Remove bogus test that caused array overrun.
 1.41 11-Dec-2005  christos branches: 1.41.4; 1.41.6; 1.41.8; 1.41.10; 1.41.12;
merge ktrace-lwp.
 1.40 26-Jan-2005  kleink branches: 1.40.6;
Clean up the array of audio_formats supported.
 1.39 15-Jan-2005  kent branches: 1.39.2; 1.39.4;
ansify and KNF
 1.38 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.37 29-Oct-2004  yamt branches: 1.37.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.36 09-Jul-2004  mycroft There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.35 08-Jul-2004  kleink In addition to alpha, grossly work around the 24-bit limitation of the
Audio 1 DMA engine by allocating through the ISA DMA tag on amd64
and i386.
 1.34 25-May-2004  kleink General mixer initialization improvements around the MONO_IN/MONO_OUT/
PreAmp register, including a new MONO_IN mixer stage bypass mixer control;
inspired by (and fixing) PR kern/18342 from Stephen Ma.
 1.33 17-Feb-2004  kleink branches: 1.33.2;
Fix a (non-dangerous) malloc size botch in eso_allocm();
from Stephen Ma in PR kern/18342.
 1.32 17-Feb-2004  kleink Audio 2's DMA current address register implements only the least
significant 20 bits, so make sure its memory allocation won't cross
a 1M boundary. From Stephen Ma in PR kern/18342.
 1.31 05-Feb-2003  kleink branches: 1.31.2;
unask -> unmask
 1.30 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.29 31-Jan-2003  thorpej Use aprint_*().
 1.28 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.27 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.26 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.25 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.24 25-Apr-2002  kleink branches: 1.24.4;
Add a joystick attachment to the ESS Solo-1 driver.
 1.23 13-Nov-2001  lukem add RCSID
 1.22 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.21 19-Jul-2001  kleink branches: 1.21.2;
Hint BUS_DMA_READ and BUS_DMA_WRITE.
 1.20 28-Dec-2000  sommerfeld branches: 1.20.2; 1.20.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.19 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.18 22-Mar-2000  kleink branches: 1.18.4;
Scale the drain timeout for allowing auto-initialize DMA to complete.
 1.17 18-Jan-2000  cjs Fix the size of the playback buffer. Patch from Dave Sainty <dave@dtsp.co.nz>.
 1.16 28-Dec-1999  kleink Off-by-one error in limiting the DMAC buffer size for Audio 2 to 64K (actually
64K - 1); from Dave Sainty in PR kern/9064.
 1.15 28-Dec-1999  kleink Fix a buffer KVA comparison botch in eso_mappage(); from Dave Sainty in
PR kern/9062.
 1.14 10-Dec-1999  kleink Add support code to have the Hardware Volume Control interact with the
software mixer Master Volume state in a defined way by lazily updating the
latter if input from the former was processed.
 1.13 03-Dec-1999  kleink A PCI Revision ID of 0x02 is what ESS happens to be calling ES1946 Revision E.
 1.12 02-Nov-1999  kleink Add a mixer control for the Master Volume Mute knob.
 1.11 01-Nov-1999  augustss Make little endian and big endian version of all functions
that deal with 16 bit samples. Let the drivers decide which ones
to use.
 1.10 28-Oct-1999  leo Remove htopci(). bus_space_write_4() takes care of necessary endian conversions.
 1.9 10-Oct-1999  cgd branches: 1.9.2; 1.9.4;
don't print using string pointer one off the end of the eso_rev2model
array. pointed out by Kouichi Hashikawa in PR#8601.
 1.8 28-Sep-1999  kleink branches: 1.8.2;
Since the Audio 1 DMA controller implements the 24 low address bits only,
add the gross hack originally implemented by Charles Hannum in the SonicVibes
driver to force allocation of DMA memory for that channel through the Scatter-
Gather Map to get an address range that fits in.

The eso driver now works on Alphas except for DWLPX-based systems, whose owners
are not likely to desire audio or likely can afford slightly less cheap audio
hardware. :-)
 1.7 23-Sep-1999  kleink Oops, we do have to check ourselves whether a given value is valid within an
enumeration.
 1.6 02-Sep-1999  kleink Use the approximated sampling rate to compute the filter rate.
 1.5 14-Aug-1999  kleink Add missing MPU interrupt glue.
 1.4 14-Aug-1999  kleink Forgot to initialize a pointer; from Simon Burge.
 1.3 02-Aug-1999  augustss branches: 1.3.2;
Move the mpu device declaration to conf/files.
Let the mpu device attach at the sb device, and then midi at the mpu.
Update the mpu at eso attachment.
 1.2 01-Aug-1999  augustss Move the MPU driver isa/ to ic/.
(I didn't move it in the repository because the revision history
is very short and uninteresting. :)
 1.1 12-Jul-1999  kleink Add a driver for the ESS Technology Solo-1 PCI AudioDrive line of chips.
 1.3.2.2 02-Aug-1999  thorpej Update from trunk.
 1.3.2.1 02-Aug-1999  thorpej file eso.c was added on branch chs-ubc2 on 1999-08-02 22:03:56 +0000
 1.8.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.4.1 15-Nov-1999  fvdl Sync with -current
 1.9.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.20.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.20.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.4.1 03-Aug-2001  lukem update to -current
 1.20.2.6 03-Jan-2003  thorpej Sync with HEAD.
 1.20.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.20.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.20.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.20.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.20.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.21.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.24.4.2 15-Mar-2004  jmc Pullup rev 1.33 (requested by kleink in ticket #1614)

Fix a (non-dangerous) malloc size botch in eso_allocm(). PR#18342
 1.24.4.1 15-Mar-2004  jmc Pullup rev 1.32 (requested by kleink in ticket #1613)

Audio 2's DMA current address register implements only the least
significant 20 bits, so make sure its memory allocation won't cross
a 1M boundary.
 1.31.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.31.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.31.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.31.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.31.2.1 03-Aug-2004  skrll Sync with HEAD
 1.33.2.2 10-Jul-2004  tron Pull up revision 1.35 (requested by kleink in ticket #633):
In addition to alpha, grossly work around the 24-bit limitation of the
Audio 1 DMA engine by allocating through the ISA DMA tag on amd64
and i386.
 1.33.2.1 29-May-2004  tron Pull up revision 1.34 (requested by kleink in ticket #400):
General mixer initialization improvements around the MONO_IN/MONO_OUT/
PreAmp register, including a new MONO_IN mixer stage bypass mixer control;
inspired by (and fixing) PR kern/18342 from Stephen Ma.
 1.37.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.37.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.39.4.1 12-Feb-2005  yamt sync with head.
 1.39.2.1 29-Apr-2005  kent sync with -current
 1.40.6.5 27-Oct-2007  yamt sync with head.
 1.40.6.4 03-Sep-2007  yamt sync with head.
 1.40.6.3 26-Feb-2007  yamt sync with head.
 1.40.6.2 30-Dec-2006  yamt sync with head.
 1.40.6.1 21-Jun-2006  yamt sync with head.
 1.41.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.41.10.1 19-Apr-2006  elad sync with head.
 1.41.8.2 03-Sep-2006  yamt sync with head.
 1.41.8.1 24-May-2006  yamt sync with head.
 1.41.6.1 22-Apr-2006  simonb Sync with head.
 1.41.4.1 09-Sep-2006  rpaulo sync with head
 1.43.4.4 21-Dec-2006  yamt sync with head.
 1.43.4.3 18-Dec-2006  yamt sync with head.
 1.43.4.2 10-Dec-2006  yamt sync with head.
 1.43.4.1 22-Oct-2006  yamt sync with head
 1.43.2.3 01-Feb-2007  ad Sync with head.
 1.43.2.2 12-Jan-2007  ad Sync with head.
 1.43.2.1 18-Nov-2006  ad Sync with head.
 1.45.2.1 17-Dec-2006  riz Pull up following revision(s) (requested by kleink in ticket #278):
sys/dev/pci/eso.c: revision 1.46
sys/dev/pci/eso.c: revision 1.47
Un-break clock selection after -Wsign-compare cleanup in rev. 1.43;
from Stephen Ma in PR kern/35220.
explicitly set clk to 1 or 0.
 1.49.4.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.49.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.50.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.50.16.1 06-Nov-2007  matt sync with HEAD
 1.50.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.50.2.1 23-Oct-2007  ad Sync with head.
 1.51.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.51.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.53.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.16.1 11-Dec-2008  ad Checkpoint work in progress.
 1.53.4.2 11-Mar-2010  yamt sync with head
 1.53.4.1 16-May-2009  yamt sync with head
 1.57.14.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.57.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.57.12.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.57.12.3 30-Oct-2012  yamt sync with head
 1.57.12.2 23-May-2012  yamt sync with head.
 1.57.12.1 17-Apr-2012  yamt sync with head
 1.59.4.2 13-Aug-2012  riz Pull up following revision(s) (requested by gson in ticket #494):
sys/dev/pci/eso.c: revision 1.61
Add missing locking calls to eso_attach() to avoid panic on boot.
Partly based on a patch from mrg. Fixes PR kern/46791.
 1.59.4.1 13-Jun-2012  riz Pull up following revision(s) (requested by mrg in ticket #332):
sys/dev/pci/eso.c: revision 1.60
don't kassert that the sc_intr_lock is held in eso_reset(). it's only
called from attach and doesn't need to have it held, and PR 46451 shows
that it currently asserts.
 1.59.2.1 02-Jun-2012  mrg sync to latest -current.
 1.61.2.3 03-Dec-2017  jdolecek update from HEAD
 1.61.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.61.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.62.8.1 23-Jul-2013  riastradh sync with HEAD
 1.62.2.2 18-May-2014  rmind sync with head
 1.62.2.1 28-Aug-2013  rmind sync with head
 1.65.6.2 28-Aug-2017  skrll Sync with HEAD
 1.65.6.1 09-Jul-2016  skrll Sync with HEAD
 1.67.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.67.10.1 10-Jun-2019  christos Sync with HEAD
 1.67.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.69.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.69.2.3 28-Apr-2019  isaki Don't release sc_lock on eso_halt_{input,output}.
halt_* is called with sc_lock && sc_intr_lock held. This lock order
is first sc_lock and then sc_intr_lock. So unlocking sc_lock with
sc_intr_lock held is wrong operation. And cv_wait(sc_intr_lock) will
work even with sc_lock held.
 1.69.2.2 28-Apr-2019  isaki Adapt to audio2.
- Select a few typical frequencies which doesn't have rounding error
instead of whole range.
 1.69.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.71.2.1 27-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #492):

sys/dev/pci/sv.c: revision 1.57
sys/dev/pci/eso.c: revision 1.72
sys/dev/ieee1394/fwohci.c: revision 1.144

Fix operand priority of bit op vs ternary operator.
 1.72.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.73.2.1 13-May-2021  thorpej Sync with HEAD.
 1.74.6.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.9 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.8 11-Dec-2005  christos branches: 1.8.164; 1.8.168;
merge ktrace-lwp.
 1.7 15-Jan-2005  kent ansify and KNF
 1.6 25-May-2004  kleink Fix a shift-by-one-bit glitch in the MONO_OUT mixer register's definition;
from Stephen Ma in PR kern/18342.
 1.5 10-Dec-1999  kleink branches: 1.5.28; 1.5.30;
Add support code to have the Hardware Volume Control interact with the
software mixer Master Volume state in a defined way by lazily updating the
latter if input from the former was processed.
 1.4 10-Dec-1999  kleink Add a symbolic name for the ES1946 rev. E in this place, too.
 1.3 23-Sep-1999  kleink branches: 1.3.2; 1.3.8;
Add Game Port definitions.
 1.2 14-Aug-1999  kleink Add missing MPU interrupt glue.
 1.1 12-Jul-1999  kleink branches: 1.1.2;
Add a driver for the ESS Technology Solo-1 PCI AudioDrive line of chips.
 1.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.1.2.1 12-Jul-1999  thorpej file esoreg.h was added on branch chs-ubc2 on 1999-08-02 22:03:56 +0000
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.30.1 29-May-2004  tron Pull up revision 1.6 (requested by kleink in ticket #400):
Fix a shift-by-one-bit glitch in the MONO_OUT mixer register's definition;
from Stephen Ma in PR kern/18342.
 1.5.28.4 17-Jan-2005  skrll Sync with HEAD.
 1.5.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.28.1 03-Aug-2004  skrll Sync with HEAD
 1.8.168.1 28-Apr-2019  isaki Adapt to audio2.
- Select a few typical frequencies which doesn't have rounding error
instead of whole range.
 1.8.164.1 10-Jun-2019  christos Sync with HEAD
 1.11 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.10 23-Nov-2011  jmcneill branches: 1.10.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.9 06-May-2009  cegger branches: 1.9.12; 1.9.14;
struct device * -> device_t, no functional changes intended.
 1.8 12-Jan-2007  kleink branches: 1.8.4; 1.8.44; 1.8.58; 1.8.60;
Replace home-grown list management for DMA buffers with SLISTs, and refactor.
 1.7 11-Dec-2005  christos branches: 1.7.20;
merge ktrace-lwp.
 1.6 15-Jan-2005  kent branches: 1.6.10;
ansify and KNF
 1.5 25-May-2004  kleink General mixer initialization improvements around the MONO_IN/MONO_OUT/
PreAmp register, including a new MONO_IN mixer stage bypass mixer control;
inspired by (and fixing) PR kern/18342 from Stephen Ma.
 1.4 22-Mar-2000  kleink branches: 1.4.28; 1.4.30;
Scale the drain timeout for allowing auto-initialize DMA to complete.
 1.3 02-Nov-1999  kleink Add a mixer control for the Master Volume Mute knob.
 1.2 02-Aug-1999  augustss branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Move the mpu device declaration to conf/files.
Let the mpu device attach at the sb device, and then midi at the mpu.
Update the mpu at eso attachment.
 1.1 12-Jul-1999  kleink Add a driver for the ESS Technology Solo-1 PCI AudioDrive line of chips.
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.6.1 15-Nov-1999  fvdl Sync with -current
 1.2.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.2 02-Aug-1999  thorpej Update from trunk.
 1.2.2.1 02-Aug-1999  thorpej file esovar.h was added on branch chs-ubc2 on 1999-08-02 22:03:57 +0000
 1.4.30.1 29-May-2004  tron Pull up revision 1.5 (requested by kleink in ticket #400):
General mixer initialization improvements around the MONO_IN/MONO_OUT/
PreAmp register, including a new MONO_IN mixer stage bypass mixer control;
inspired by (and fixing) PR kern/18342 from Stephen Ma.
 1.4.28.4 17-Jan-2005  skrll Sync with HEAD.
 1.4.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.28.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 26-Feb-2007  yamt sync with head.
 1.7.20.1 01-Feb-2007  ad Sync with head.
 1.8.60.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.58.1 11-Dec-2008  ad Checkpoint work in progress.
 1.8.44.1 16-May-2009  yamt sync with head
 1.8.4.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.9.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.9.12.2 30-Oct-2012  yamt sync with head
 1.9.12.1 17-Apr-2012  yamt sync with head
 1.10.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11 02-Nov-2014  christos revert changes, this needed to be done differently.
 1.10 02-Nov-2014  christos make the apple code compile again.
 1.9 01-Nov-2014  christos fix linking of DRMKMS kernel.
XXX: apple does not compile!
 1.8 29-Oct-2014  uebayasi Revert "normalization" for now.

XXX agp(4)'s config/attachment should be rewritten
 1.7 10-Oct-2014  uebayasi Normalize.
 1.6 04-Aug-2007  kiyohara branches: 1.6.34;
Add support agp_amd64. Imported from FreeBSD.
 1.5 25-Mar-2007  macallan branches: 1.5.4; 1.5.8;
add very experimental Apple UniNorth AGP driver
 1.4 11-Dec-2005  christos branches: 1.4.26; 1.4.30; 1.4.32; 1.4.34;
merge ktrace-lwp.
 1.3 30-Aug-2004  drochner branches: 1.3.12;
add centralized {eisa,isa,pci,agp,mca}busprint() functions which do
what tens of the bus' parents foo{...}bridge_print()s scattered around do
 1.2 15-Sep-2001  thorpej branches: 1.2.2; 1.2.4; 1.2.8; 1.2.24;
Give each AGP controller its own attribute, and let the "agpbus"
device (rather, the device that carries that attribute) also
carry one or more attributes indicating which type of controller
it might be.

This will allow systems that might have AGP, but would never have
e.g. an Intel PCI-Host bridge, to trim out code that won't be used.
 1.1 15-Sep-2001  thorpej Move the AGP device declaration stuff into files.agp.
 1.2.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.24.1 03-Sep-2004  skrll Sync with HEAD
 1.2.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.1 15-Sep-2001  thorpej file files.agp was added on branch kqueue on 2002-01-10 19:56:34 +0000
 1.2.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.1 15-Sep-2001  fvdl file files.agp was added on branch thorpej-devvp on 2001-10-01 12:45:53 +0000
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 15-Sep-2001  nathanw file files.agp was added on branch nathanw_sa on 2001-09-21 22:35:55 +0000
 1.3.12.1 03-Sep-2007  yamt sync with head.
 1.4.34.1 29-Mar-2007  reinoud Pullup to -current
 1.4.32.1 11-Jul-2007  mjf Sync with head.
 1.4.30.2 20-Aug-2007  ad Sync with HEAD.
 1.4.30.1 10-Apr-2007  ad Sync with head.
 1.4.26.1 15-Apr-2007  yamt sync with head.
 1.5.8.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.5.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.6.34.2 04-Aug-2007  kiyohara Add support agp_amd64. Imported from FreeBSD.
 1.6.34.1 04-Aug-2007  kiyohara file files.agp was added on branch matt-mips64 on 2007-08-04 09:34:44 +0000
 1.2 25-Jun-2005  dyoung Move the definitions in dev/pci/files.ath into dev/pci/files.pci.
Stop including dev/pci/files.ath in arch/i386/conf/files.i386,
since we get the same definitions by including dev/pci/files.pci,
now. Remove dev/pci/files.ath.

Add arch/macppc/conf/Makefile.macppc with directives for linking
the Atheros HAL for PowerPC.

In athhal-powerpc-be-eabi.opt_ah.h, #define AH_REGOPS_FUNC 1, since
otherwise the linker complains that the PowerPC HAL cannot link
with register-read/write subroutines.

Add ath(4) to the GENERIC macppc kernel configuration; comment it
out.
 1.1 13-Oct-2003  dyoung branches: 1.1.4;
Files belonging to the ath(4) PCI front-end.

We can only attach an ath(4) on architectures where we have a HAL
(which is only x86, for now) so I list the files belonging to the
PCI front-end separately from the other PCI files.
 1.1.4.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 13-Oct-2003  skrll file files.ath was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.451 04-Aug-2025  skrll Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.
 1.450 16-Jun-2025  macallan branches: 1.450.2;
defflag PM3FB_DEBUG
wipe glyphcache when re-entering terminal mode
 1.449 27-May-2025  macallan pm3fb needs glyphcache now
 1.448 20-Oct-2023  msaitoh branches: 1.448.6;
eqos(4): Add initial support for Intel Elkhart Lake internal Ethernet devices.

- Only tested on PSE SGMII 1G Ethernet MAC with MaxLinear GPY115.
- I don't know why dmat64 doesn't work. eqos_attach() have a special
code if EQOS_HW_FEATURE_ADDR64_32BIT(sc) is true, but it seems it doesn't
work.
- TODO:
Multiqueue support.
Detach support.
 1.447 04-Oct-2023  rin igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.446 12-Apr-2023  riastradh ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.445 14-Oct-2022  jmcneill branches: 1.445.2;
Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.444 16-Sep-2022  knakahara Add ALWAYS_TXDEFER option to ixl(4), too.
 1.443 16-Sep-2022  knakahara Add ALWAYS_TXDEFER option to vmx(4), too.
 1.442 16-Sep-2022  knakahara ixg(4) add an option for Tx to use deferred softint regardless of whether can get txq lock or not.

That imporve (7%) and stabilize throughput. But that can cause
latency degradation, so off by default.

ok'ed by msaitoh@n.o.
 1.441 07-Sep-2022  martin Fix the build, add new emuxki_boards.c
 1.440 17-Dec-2021  knakahara Add missing WM_TX_{,INTR_}PROCESS_LIMIT_DEFAULT options same as RX side.
 1.439 12-Nov-2021  skrll Trailing whitespace
 1.438 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.437 26-Apr-2021  thorpej - The "eso" device does not need to carry the "midibus" interface attribute.
It attaches "opl" and "mpu" instances, which themselves attach "midi".
- Be explicit about specifying the "eso" interface attribute when attaching
"opl", "mpu", and "joy" instances.
 1.436 09-Mar-2021  msaitoh branches: 1.436.4;
Modify some parameters to reduce packet dropping.

- Background: ixgbe doesn't use common MCLGET() interface and use the
driver specific cluster allocation mechanism (jcl). The cluster is
pre-allocated with a fixed number and the current number per queue
is num_rx_desc * 2 (2048*2=4096). It's too small. It also has a problem
that the max length of the pcq which is used in the TX path is big
(4096). Example:

100M <----- [ixg0 ixg1] <----- 1G
2048 TX descs <--- 4096 pcqs <---- 2048 RX descs

If a machine forwards a traffic from 1G interface to 100M interface,
It would require 2048+4096+2048=8192 descriptors, but the current number
is 2048*2=4096. It's too small. Even if the both interface's link speed
is the same and only small number of packet is queued in the pcq, 4096
jcl is small because 2048(RX)+TX(2048)=4096. If jcl is exhausted, not only
forwarding from ixg1 to ixg0 is dropped, but also another forwarding path
from ixg1 to another interface(e.g. wm0) is also dropped. Sockets also
queue packets, so if a lot of sockets are used and/or a socket buffer
size is changed to bigger one, it'll also become a problem. If the jcl
is exhausted, evcnt(9) counter "ixgX qY Rx no jumbo mbuf" is incremented.
Example:
vmstat -ev | grep ixg1 | grep "no jumbo"
ixg1 q0 Rx no jumbo mbuf 0 0 misc
ixg1 q1 Rx no jumbo mbuf 0 0 misc
ixg1 q2 Rx no jumbo mbuf 141326 0 misc
ixg1 q3 Rx no jumbo mbuf 0 0 misc


- To solve this problem:
- Add new config parameter IXGBE_JCLNUM_MULTI and set the default to 3
(2048 * 3). The minimum number is 2. The total number of jcl per queue
is available with hw.ixgN.num_jcl_per_queue sysctl.
- Reduce the max length of the pcq() which is used in the TX path from
4096 to 2048.

- Reviewed by knakahara@ and ozaki-r@.

- TODO: Use MCLGET().
 1.435 01-Mar-2021  jakllsch Update rge(4) from older OpenBSD, finish porting.

Should consider merging this all into re(4) and rgephy(4) someday.

Some cleanup tasks remain here.
 1.434 17-Feb-2021  knakahara In 64 bit architectures, WM_EVENT_COUNTER is enabled by default.

No objection from tech-kern@n.o and tech-net@n.o.

ok'ed by msaitoh@n.o.
 1.433 30-Jan-2021  jmcneill Sync with OpenBSD r1.98. Lots of improvements including checksum offload,
hardware vlan tagging, and support for multiple receive queues.
 1.432 14-Oct-2020  ryo branches: 1.432.2;
vmx(4) should be MI. moved to sys/dev/pci from sys/arch/x86/pci
 1.431 08-Sep-2020  yamaguchi Added iavf(4) that is based on OpenBSD's iavf(4) implementation

reviewed by msaitoh@n.o and knakahara@n.o
 1.430 26-Jul-2020  jdolecek Add driver for Intel XMM7360 LTE modem, based upon Linux driver available
at https://github.com/xmm7360/xmm7360-pci

This version works on Linux, OpenBSD, and NetBSD.

OpenBSD port written for genua GmbH

Modem requires python script from the master site to initialize the network,
it will be added to pkgsrc shortly
 1.429 24-Jun-2020  thorpej Add a PCI front-end for the "amdccp" (AMD Cryptographic Coprocessor)
driver.
 1.428 21-May-2020  macallan - remove i2cbus etc. on drivers that don't use iic
- for private iic buses pull in only what we need and skip the bus attachment
 1.427 20-May-2020  macallan radeonfb doesn't attach an iic*, so pull in iic, not i2cbus
 1.426 09-Feb-2020  jmcneill Retire azalia(4).
 1.425 25-Jan-2020  thorpej Retire the le@pci attachment. It has been superseded (and matched at a
higher priority) by the pcn(4) driver since NetBSD 1.6.
 1.424 20-Jan-2020  thorpej Remove FDDI support.
 1.423 19-Jan-2020  thorpej Remove the de(4) driver, which has long since been supplanted by the
tlp(4) driver, which supports more chips and more board variants.
 1.422 19-Jan-2020  thorpej Remove HIPPI support and the esh(4) driver that uses it. There have not
been any users of HIPPI for some time, and it is unlikely to be resurrected.
 1.421 17-Jan-2020  ryo support internal PHY temperature sensor
 1.420 16-Jan-2020  yamaguchi Use def{flag,param} for parameters in ixl(4)
 1.419 01-Jan-2020  ryo branches: 1.419.2;
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.
 1.418 10-Dec-2019  yamaguchi Ported driver for Intel Ethernet 700 series

reviewed by msaitoh and knakahara
 1.417 26-Nov-2019  nisimura - use mii(4) layer to control KSZ8841 builtin PHY.
- handle PAUSE flow control properly according to ifconfig(8) mediaopt
selection.
- some style knits; use aprint(9) and modernise callout(9).
 1.416 20-Nov-2019  hikaru Add opencrypto driver for Intel QuickAssist.
 1.415 22-Sep-2019  jmcneill Correct mcx comment, drop mii dependency
 1.414 22-Sep-2019  mrg add mcx attachment.
 1.413 08-May-2019  isaki branches: 1.413.2;
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.412 12-Dec-2018  maxv branches: 1.412.2;
Retire the LMC driver, and its associated lmcconfig tool. LMC has been
mentioned repeatedly as a non-MP-safe driver that is hard to maintain,
and no one is taking care of it.

LMC was removed from OpenBSD three years ago, and from FreeBSD a few
months ago.
 1.411 07-Dec-2018  msaitoh - defflag PPB_USEINTR
- Print "interrupting at "
 1.410 24-Nov-2018  bouyer Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.
Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.
Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.
 1.409 20-Nov-2018  skrll Add support for MSI/MSI-X to ahcisata at pci.

The options AHCISATA_DISABLE_MSI and AHCISATA_DISABLE_MSIX are available
if required.
 1.408 14-Nov-2018  skrll defflag XHCI_DISABLE_MSIX
 1.407 22-Sep-2018  maxv Remove isic(4). It is part of ISDN, which we are now retiring.
 1.406 22-Sep-2018  maxv Unreference iwic (now removed), forgot that.
 1.405 22-Sep-2018  maxv Remove the "ifritz" driver (no man page). It is part of ISDN, which we are
retiring.
 1.404 22-Sep-2018  maxv Remove ifpci(4). It is part of ISDN, which we are retiring.
 1.403 22-Sep-2018  nakayama ixg and ixv depend on mii and mii_phy.
 1.402 21-Sep-2018  maxv Remove iavc(4).
 1.401 06-Sep-2018  maxv Retire the 'midway' driver. Discussed on tech-net@ recently and also three
years ago, part of removing the network ATM code.
 1.400 25-Aug-2018  maxv branches: 1.400.2;
Retire NDIS. It appears that it has never worked, after 13 years it was
still marked as "experimental", and nowadays it may be one more obstacle
to MPification of the network stack.

Discussed on tech-net@.
 1.399 08-Aug-2018  maya Remove NetOctave NSP2000 support

This code has bitrotted - it hasn't been adjusted from the old module
framework.

Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2018/07/10/msg023638.html
 1.398 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.397 06-Jun-2018  jakllsch branches: 1.397.2;
shuffle mechanics of files.virtio config(5) include location,
without actually moving the contents thereof from dev/pci yet
 1.396 19-May-2018  jdolecek add config glue for ena(4)
 1.395 11-May-2018  maya add bwfm pci support, from openbsd

Tested on BCM43602.
 1.394 01-Mar-2018  pgoyette branches: 1.394.2;
Move the imc and imcsmb stuff out of general files.pci and into the
architecture-specific files.x86

Should unbreak the sgimips build.
 1.393 25-Feb-2018  pgoyette Import imcsmb driver from FreeBSD. This driver allows access to the
SMBus controllers which are part of the integrated memory controllers
on certain modern Intel CPUs. These SMBus are attached only to the
memory DIMMs, so we provide only a minimum amount of functionality.

Deliberately not included in GENERIC, as on some motherboards there
can be conflicting access between the driver and the motherboard. The
motherboards generally will provide a mechanism to synchronize access,
but the methods are likely proprietary; the driver provides a place
for inserting user-provided synchronization.
 1.392 03-Dec-2017  jdolecek port ips(4) driver from OpenBSD; needs a lot more work, right now just compilable
 1.391 05-Sep-2017  skrll Add an XHCI_DISABLE_MSI option
 1.390 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.389 02-Aug-2017  cherry Reorg the virtio(4) config(9) code to be explicitly pci specific.

We'll later use this for a non-pci virtio(4) usecase.

ok martin
 1.388 13-Apr-2017  knakahara branches: 1.388.4;
wm(4) can disable msi/msix by build option and ddb command.

suggested by nonaka@n.o.
reviewed by msaitoh@n.o and nonaka@n.o.
 1.387 22-Mar-2017  knakahara make kernel config flag WM_EVENT_COUNTERS.

suggested by msaitoh@n.o.
 1.386 03-Mar-2017  knakahara make kernel config option WM_RX_PROCESS_LIMIT_DEFAULT and WM_RX_INTR_PROCESS_LIMIT_DEFAULT

e.g. if
- WM_RX_PROCESS_LIMIT_DEFAULT is set 0
- WM_RX_INTR_PROCESS_LIMIT_DEFAULT is set -1 (means almost infinite)
that means wm(4) does not use polling mode.
 1.385 02-Dec-2016  msaitoh branches: 1.385.2;
Add ixgbe_osdep.c.
 1.384 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.383 28-Nov-2016  msaitoh FreeBSD r280182 made new file ix_txrx.c and moved ixgbe.c and ixv's common
code into it. Before sync with whole of them, just move ixgbe.c and ixv.c's
common code into ix_txrx.c from ixgbe.c. In this commit, only ixgbe.c is split
into the device dependent part and the common part. ixv.c isn't change to make
this commit no functional change. To use ixv.c with ix_txrx.c, it's required
to modify the common part's API and functions themselves.

This commit is done to make the next change easy to understand.
 1.382 21-Nov-2016  macallan missing bits for pm3fb, should have went with previous...
 1.381 01-May-2016  nonaka branches: 1.381.2;
Added nvme(4) for Non-Volatile Memory Host Controller Interface devices.
Ported from OpenBSD.
 1.380 05-Jan-2016  msaitoh Add ismt(4).
 1.379 29-Oct-2015  christos Add vioscsi, compile tested only (toxic)
 1.378 20-Oct-2015  tnn add ifnet attributes to vioif(4) so it can be config(8)ed as root device
 1.377 27-Aug-2015  nonaka Added rtwn(4) for Realtek RTL8188CE/RTL8192CE PCIe 802.11b/g/n wireless network
devices. Ported from OpenBSD.
 1.376 28-Mar-2015  jmcneill Split hdaudio and PCI attach glue. Even though the driver was written with
this separation in mind, all of the code lived in sys/dev/pci/hdaudio. Move
common parts to sys/dev/hdaudio and PCI attach glue to sys/dev/pci.
 1.375 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.374 10-Mar-2015  msaitoh Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
 1.373 07-Feb-2015  pooka Add a driver for Intel Centrino 7260 and similar wireless cards.
Supported devices should more or less match ones supported
by the Linux iwlwifi mvm driver. Sponsored by genua mbh for OpenBSD.

This is probably the world's first Canadian cross device driver: it was
created for OpenBSD by writing and porting a NetBSD driver which was
developed in a rump kernel in Linux userspace.

Note: I don't have access to the hardware anymore, so this version is
not tested and not enabled by default. While I tried to be careful in
adding the NetBSD bits back, it's probable that there's a snafu or two.
Feel free to send private email in case you have the hardware and there
are issues.
 1.372 26-Oct-2014  tls branches: 1.372.2;
Add viornd(4), a driver for the VirtIO entropy source available on
QEMU, KVM, and Google Compute Engine. From OpenBSD.
 1.371 19-Mar-2014  nonaka branches: 1.371.4;
Add a driver for Realtek RTS5209/RTS5229 Card Reader.
Ported from OpenBSD.
 1.370 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.369 26-Jan-2014  msaitoh PUCCN improvements:
- Fix a bug that the puc cn mechanism doesn't use the UART's frequency
in pucdata.c's table.

- Add a new option PUC_CNAUTO. If this option is set, consinit() in
x86/x86/consinit.c checks puc com device to use it as console.
Without this option, the behavior is the same as before.

- Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
If PUC_CNBUS is set, the specified number's bus will be scanned.

- Rename comcnprobe() to puc_cnprobe() to make it clear.

- Rename comcninit() to puc_cninit() to make it clear.

- Add code for a device that a device's com register is MMIO (#if0 ed).
 1.368 21-Jan-2014  mlelstv wscons driver for Intel Graphics Media Accelerator.
Initial commit that already works for a couple of Notebooks
based on G35, G45, Sandy Bridge and Ivy Bridge chips.

Despite the word 'Accelerator' there is nothing acclerated yet.
 1.367 18-Sep-2013  macallan a preliminary driver for nvidia geforce graphics chips
so far it only supports the GeForce 2MX, tested on macppc only
no acceleration yet, just some DAC setup
the main advantage over genfb is that this driver knows how to setup the
palette registers for the 2nd output
 1.366 21-Aug-2013  jakllsch We already have a config rule for the eventual core of xhci(4); may as
well have the PCI attachment rule as well.
 1.365 22-Jul-2013  soren PUCCN is now implicit.
 1.364 30-Mar-2013  christos branches: 1.364.4; 1.364.6;
patches for new wifi devices.
 1.363 30-Jan-2013  rkujawa Include rasops that are actually needed by this driver.
 1.362 01-Jan-2013  macallan add a compile option to override the fallback to software drawing of bitmap
fonts on R3xx ( options RADEONFB_ALWAYS_ACCEL_PUTCHAR ) since this works just
fine on my RV350.
Next step: don't map VRAM if we don't need it.
 1.361 17-Dec-2012  mbalmer Adding ibmcd(4), a device driver for the IBM 4810 BSP cash drawer port as
found e.g. in SurePOS 300 series point of sale terminals. The driver
provides a gpio(4) device with three pins: pin 0 to open drawer, pin 1
to read the status and pin 2 to read whether a cash drawer is connected or
not.
 1.360 02-Aug-2012  macallan branches: 1.360.2;
add support for anti-aliased fonts
 1.359 30-Jul-2012  degroote Add malo(4)@pci driver for Marvell Libertas wireless adaptor

Ported from OpenBSD
Known issues :
- contrary to OpenBSD one, only support pci at the moment, because I don't
have the necessary hardware to test PCMCIA / CARDUS Marvell Card
- not connected to pmf(9) (unable to test it)
 1.358 18-Jul-2012  rkujawa Add 3Dfx Voodoo2 driver. Still needs some cleanup and prettyfying, but hey
it works.
 1.357 19-Apr-2012  bouyer Add mpii(4), a driver for LSI Logic Fusion-MPT Message Passing Interface II
SAS controllers. Ported from OpenBSD.
 1.356 02-Mar-2012  nonaka Added Lemote Yeeloong Notebook support.
 1.355 16-Feb-2012  macallan cache glyphs in video memory when using anti-aliased fonts on r128fb and
radeonfb
 1.354 24-Jan-2012  rkujawa branches: 1.354.2;
Add missing i2c dependencies to voodoofb.
 1.353 21-Jan-2012  rkujawa Fix double i2cbus dependency for voyager
 1.352 21-Jan-2012  rkujawa Change dependency iic to i2cbus for fb drivers. OK macallan.
 1.351 03-Jan-2012  macallan support anti-aliased fonts in 32bit colour
enable with options RADEONFB_DEPTH_32
 1.350 30-Oct-2011  hannken branches: 1.350.2; 1.350.6;
Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.349 08-Oct-2011  kiyohara Fix panic when boot time. Require attribute drm to voodoofb.
 1.348 31-Aug-2011  macallan split up voyagerfb into the framebuffer portion and a pseudo bus that we can
attach all the other sub-devices to
while there attach an i2c bus
 1.347 27-Aug-2011  bouyer Add a basic driver for the SIS315 Pro frame buffer found on some loogson2-based
systems, from OpenBSD.
At this time it can only map the framebuffer and attaches wscons,
using whatever resolution was configured by the firmware.
It doens't support any accelaration or mode change.
 1.346 24-Aug-2011  dyoung Add to pci_bus_devorder() an argument that tells the number of slots
available in the devs array. Change the type of the devs array from
char to uint8_t. Treat the return value of pci_bus_devorder() as the
number of slots that it filled.

Don't use the __PCI_BUS_DEVORDER #definition to configure the kernel
but let the linker do it. Make pci_bus_devorder() available on all
architectures by adding a default implementation that will DTRT on
all architectures but hpcmips, the only architecture to #define
__PCI_BUS_DEVORDER. On hpcmips, adapt the implementation to the new
calling convention.

XXX I can compile an hpcmips GENERIC kernel, but I don't have a
XXX hpcmips box to test it on.
 1.345 12-Aug-2011  dyoung Attach ixg(4) to the kernel build (it's not in any kernel
configurations, yet).
 1.344 11-Aug-2011  mbalmer pwdog(4) is a device driver for QUANCOM Electronic PWDOG1 PCI
attached watchdog timers.
 1.343 04-Aug-2011  jakllsch Add coram(4).

A driver for CX23885-based TV cards, such as the
Hauppauge WinTV HVR-1250 "Coram" board.

Currently only supports ATSC 8VSB reception.
 1.342 14-Jul-2011  jmcneill hook in lg3303 demod support and modularize
 1.341 11-Jul-2011  jakllsch Add cxdtv(4), a dtv(4) driver for Conexant CX23880-series DTV interface chips.

Initially supports digital reception on ATI HDTV Wonder card.
 1.340 04-Apr-2011  bouyer Add rdcide(4), a driver for the IDE controller found in RDC's
vortex86/PMX-1000 system-on-chip.
 1.339 23-Feb-2011  jmcneill add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto
 1.338 09-Feb-2011  macallan use the bus independent stuff from ic/ct65550* and leave only the PCI specific
bits in pci/chipsfb.c
 1.337 26-Jan-2011  bouyer Add a driver for the RDC Semiconductor RDC R6040 10/100 Ethernet controller,
as found in the vortex86 SoCs (http://www.vortex86dx.com).
Ported from freebsd.
Not added to amd64's GENERIC because this CPU is 32bit only.

thanks to DM&P Electronics, Inc for providing documentation and sample
devices for this work.
 1.336 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.335 11-Dec-2010  matt branches: 1.335.2; 1.335.4;
arcmsr needs sysmon_envsys
 1.334 13-Nov-2010  jnemeth PR/39094 - Kaspar Brand -- Add et (Agere ET1310/ET1301) network driver

The et(4) driver supports PCI Express Ethernet adapters based on
the Agere/LSI ET1310/ET1301 integrated MAC/PHY.

The et(4) driver was written by Sepherosa Ziehau for DragonFlyBSD,
ported to OpenBSD by Jonathan Gray and subsequently ported to NetBSD
by Kaspar Brand.
 1.333 10-Nov-2010  skrll Add nside(4) - a driver for the National Semiconductor PC87415 IDE
controller as found in many HP PA-RISC machines.

From OpenBSD.

Reviewed by Manuel Bouyer.
 1.332 09-Nov-2010  skrll Update sti(4) from OpenBSD bringing across support for sti @ pci.

Thanks to Adam Hoka for testing.
 1.331 06-Nov-2010  jakllsch Add Intel SCH IDE controller driver.
From OpenBSD via Tomokazu HARADA in PR#42310.
 1.330 03-Nov-2010  macallan pull in rasops8 for radeonfb, while there defflag a bunch of options and
make them all use the same prefix
 1.329 24-May-2010  pgoyette Extract the vendor/product tables and related access routines into a
separate kernel module. Update pci bus attach routine to load the
module (if available) when we're about to start scanning the bus, and
unload the module after the scan is finished.

On architectures which support loading of modules by the boot loader,
the 'pciverbose' module can be loaded and executed without needing to
rebuild the kernel. On all architectures, using 'options PCIVERBOSE'
in the kernel configuration file will create a 'builtin' module which
is functionally equivalent to previous behavior.

XXX Although not nearly as large as the vendor and product tables,
XXX the PCI class and subclass tables might also be offloaded into
XXX the module at a future time.

XXX Cardbus (and possibly other) drivers should also be modified to
XXX load the module before scanning/attaching devices.
 1.328 01-Apr-2010  jakllsch Add support for Domex 536 PCI SCSI controller to nca(4).
This truly remarkable chip is found on the Domex DMX-3191D SCSI adapter.
 1.327 21-Mar-2010  jklos Reorganizing all Chelsio 10 gig files into separate directory.
 1.326 25-Feb-2010  macallan branches: 1.326.2;
a very preliminary driver for Wildcat 5110 / Sun XVR-500 graphics boards
Since we don't have any documentationthis driver is unaccelerated and thanks
to the insane state we get the hardware in it's also slow and scrolling
looks weird.
Some hardware info came from OpenBSD's ifb driver.
 1.325 22-Feb-2010  ahoka Restore splashscreen support with genfb.
genfb patch from Pierre Pronchery, other small changes to make it
compile by me.

Closes PR kern/42605.

XXX doesnt work in 8bit, probably a cmap issue
 1.324 07-Jan-2010  jdc branches: 1.324.2;
Add cas (Sun Cassini/Cassini+ (GigaSwift) Ethernet).
 1.323 28-Oct-2009  macallan A driver for the Permedia 2 graphics processor, so far it's been tested only
on sparc64 with a Sun PGX32 / TechSource Raptor GFX 8P
So far it accelerates block copies, rectangle fills and the cursor, it
supports the usual wsdisplay / vcons stuff.
TODO:
- character drawing by hardware so we don't need to map the framebuffer
- DDC2 support
- mode setting
This driver still relies on the firmware to set up graphics modes etc. so it
won't work on x86 ( or non-OpenFirmware for that matter ) unless you use the
VESA BIOS to set up graphics and pass the right properties ( width, height
etc. ) to the driver. For the same reason it will work only if it's the
OpenFirmware console.
 1.322 26-Sep-2009  snj "Intel High Definition Audio" -> "High Definition Audio"
 1.321 26-Sep-2009  jakllsch As, siisata attaches not just at pci, but for a while now, also at cardbus,
move siisata core driver config to the propper config file.
 1.320 20-Sep-2009  christos PR/42100: Dave J. Barnes: Support for old toshiba PICCOLO IDE controllers.
 1.319 06-Sep-2009  sborrill hdaudio(4) is a standards-compliant driver for Intel High Definition Audio.
It will replace azalia(4) after testing.

To use, comment out azalia in your kernel configuration and uncomment the
hdaudio and hdafg lines so it reads:

# Intel High Definition Audio
hdaudio* at pci? dev ? function ?
hdafg* at hdaudiobus?

You should also:
cd /dev
sh MAKEDEV audio
 1.318 12-Aug-2009  macallan add voyagerfb, a driver for the Gdium Liberty 1000's onboard graphics chip
 1.317 27-Jul-2009  kiyohara Support Marvell Hercules-I/II SATA Controllers.
 1.316 21-Jun-2009  mrg make external drm the default.
 1.315 17-Jun-2009  jakllsch A few changes for siisata(4):

- Support detachment. From KIYOHARA Takashi.
- Add PCI detachment functionality (albeit not very interesting when
the bus can not yet be rescanned).
- Rework interrupt handlers to reduce near-duplicate code.
Borrowed from ahcisata(4).
- Attempt to make polled I/O work. Untested.
- Fix formatting of some messages.
- For always-polled commands, disable interrupt
at slot level rather than port level.
- Instead of busy-waiting indefinitely for completion of some commands
move on after 31 seconds. Use cv_timedwait(9) instead of DELAY(9).
- Use abstracted SATA FIS code.
- Enable use of disks that don't respond with the standard signature.
 1.314 21-Apr-2009  nonaka Added SD/MMC support from OpenBSD.
tested on i386, amd64 at current-users ML by pgoyette@.
tested on zaurus by myself.
 1.313 20-Apr-2009  cegger Add ale(4), a driver for Attansic/Atheros L1E gigabit ethernet device.
Ported by me from OpenBSD, improvements from Kevin Lahey,
successfully tested by Kevin Lahey and Stephen Borrill.
 1.312 16-Jan-2009  cegger branches: 1.312.2;
age driver needs mii_phy
 1.311 16-Jan-2009  cegger Driver for Attansic L1 gigabit ethernet driver.

Written by Pyun YongHyeon for FreeBSD, ported to DragonFlyBSD
by Sepherosa Ziehau, ported to OpenBSD by Kevin Lo and then
ported to NetBSD by me.

XXX Driver needs testing.
 1.310 09-Jan-2009  macallan PCI attachment for the bwi driver
From Urban Boquist
 1.309 28-Dec-2008  jmcneill PR# port-i386/40284: add AMD Geode CS5536 audio driver; written by
SHIMIZU Ryo <ryo@nerv.org>
 1.308 30-Oct-2008  darran branches: 1.308.2; 1.308.8;
NetOctave NSP2000 driver, ported from FreeBSD and integrated with
opencrypto by CoyotePoint Systems. The FreeBSD driver source was recently
made available by NBMK Encryption Technologies.

The port includes some currently unused code which implements kernel and
user space interfaces for the driver in FreeBSD. These are left in at this
time to facilitate the port of these interface to NetBSD if they are of
interest.
 1.307 29-Oct-2008  jkunz Ported alipm(4) and admtemp(4) from OpenBSD.
 1.306 11-Oct-2008  bouyer branches: 1.306.2;
jme(4), a driver for JMicron Technologies JME250 Gigabit Ethernet and
JME260 Fast Ethernet PCI Express controllers.
Written with a lot of cut-n-paste from the FreeBSD jme(4) driver.
No support for jumbo ethernet frames yet (but should come soon).
Thanks to JMicron Technologies for providing me sample boards and
documentation for this work.
 1.305 21-Jul-2008  joerg Express explicitly that VGA_POST needs X86EMU.
 1.304 23-May-2008  jnemeth branches: 1.304.2; 1.304.4;
Import siisata(4) by Jonathan A. Kollasch.

The siisata driver supports the Silicon Image SteelVine family of SATA-II
controllers, interfacing the hardware with the ata(4) and atapi(4) sub-
systems.

The following controllers are supported by the siisata driver:

Silicon Image SiI3124 4-port PCI/PCI-X
Silicon Image SiI3132 2-port PCI-Express x1
Silicon Image SiI3531 1-port PCI-Express x1

SATA Native Command Queueing is not yet supported.
Device hot swapping is not yet supported.
Silicon Image's Software RAID is not yet supported by the
ataraid(4) driver.

Approved by: core (christos), releng (bouyer)
 1.303 29-Mar-2008  cube branches: 1.303.2; 1.303.4; 1.303.6;
Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.

The linux driver was used as documentation.

Many thanks to all the people who helped or at least supported me while I
was fighting that bug that made the EeePC freeze. At the top of that list,
Matt J. Fleming (mjf@) and David Gwynne (from the OpenBSD fame).
 1.302 09-Feb-2008  ober branches: 1.302.6;
Intel PRO/Wireless LAN 4965AGN Mini-PCI Adapter Driver ported from OpenBSD
by deroote@. OK nick@ moof@
 1.301 17-Jan-2008  jklos 10 gigabit Chelsio cards now compile and work, although not very well yet.
 1.300 25-Dec-2007  joerg Add initial version of calling VGA POST from vga_resume. This is the
equivalent to "vbetool post" using x86emu in the kernel.
 1.299 15-Dec-2007  dyoung Finish making the sip(4) and gsip(4) drivers share compiled code.
 1.298 05-Dec-2007  xtraeme branches: 1.298.4;
Rename the Areca RAID driver (known as arc(4) to arcmsr(4) to avoid
namespace conflict with NetBSD/arc.

Found by tsutsui@.
 1.297 04-Dec-2007  xtraeme Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.

arc0 at pci2 dev 14 function 0: interrupting at ioapic0 pin 18 (irq 5)
arc0: Areca ARC-1210 Host Adapter RAID controller
arc0: 4 ports, 256MB SDRAM, firmware <V1.43 2007-4-17>
scsibus0 at arc0: 16 targets, 8 luns per target
[...]
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <Areca, ARC-1210-VOL#00, R001> disk fixed
sd0: 465 GB, 56514 cyl, 36 head, 480 sec, 512 bytes/sect x 976562176 sectors
sd1 at scsibus0 target 0 lun 1: <Areca, ARC-1210-VOL#01, R001> disk fixed
sd1: 465 GB, 56514 cyl, 36 head, 480 sec, 512 bytes/sect x 976562176 sectors

bioctl(4) output with two RAID0 volumes:

Volume Status Size Device
arc0 0 Online 466G ARC-1210-VOL#00 RAID0
0 Online 234G 0:0.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:1.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
arc0 1 Online 466G ARC-1210-VOL#01 RAID0
0 Online 234G 0:2.0 noencl <WDC WD2500YS-01SHB1 20.06C06>
1 Online 234G 0:3.0 noencl <WDC WD2500YS-01SHB1 20.06C06>

The driver still needs changes related to locking and talking to the
firmware, which sometimes is unable to answer...

Raid card donated by Areca Technology Corporation via Trent George.
Disks used for testing were contributed by TNF.

Thank you very much.
 1.296 07-Nov-2007  macallan branches: 1.296.2;
add preliminary driver for ATI Rage 128 graphics controllers
So far it supports some acceleration ( copies and rectangle fills ) but
no video mode programming at all.
Known problems:
- tested only on macppc
- matches only one r128 chip out of ca. 30
- character drawing is unaccelerated
- no attempt is made to restore the console when X exits
 1.295 28-Jul-2007  kiyohara branches: 1.295.4; 1.295.6; 1.295.10; 1.295.12; 1.295.14;
Add support for Intel ICH SMBus controller.
 1.294 11-Jul-2007  kiyohara branches: 1.294.2;
Add support for NVIDIA nForce 2/3/4 SMBus controller and SMBus driver.
 1.293 10-Jul-2007  jklos More updates to the cxgb stuff. Now it actually starts configuring and
talking to the hardware.
 1.292 09-Jul-2007  jklos Boo boo - .h files don't go in here...
 1.291 09-Jul-2007  jklos Added one last file for Chelsio support.
 1.290 07-Jul-2007  jklos Added two files for Chelsio 10 gig cards.
 1.289 21-Jun-2007  jklos Added cxgb entry for Chelsio T3 10 gigabit card.
 1.288 15-May-2007  bouyer add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).

Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.
 1.287 12-May-2007  bouyer Split the ahcisata driver in pci front-end and bus-independant back-end.
 1.286 26-Apr-2007  garbled Remove the PCIIDE_SLIDE_SETIRQA hack. Recent revalations have uncovered
the fact that it's useless.
 1.285 11-Apr-2007  macallan fix a typo
 1.284 10-Apr-2007  macallan move genfb's PCI frontend to dev/pci
 1.283 24-Mar-2007  jmcneill Include dev/pci/drm/files.pcidrm
 1.282 23-Mar-2007  jmcneill Allow viadrm to attach to unichromefb
 1.281 23-Mar-2007  jmcneill Add viadrm
 1.280 21-Mar-2007  macallan defflag RADEONFB_DEBUG and MACHFB_DEBUG, pull in drm for both, pull in edid
for machfb
 1.279 20-Mar-2007  drochner Import DRM drivers, brought into shape by Yorick Hardy, posted to tech-x11.
Minor modifications by me:
-use an mi device major number
-(coarsly) divided into pci card specific and less specific parts, moved
the latter to dev/drm
-renamed autoconf attributes to reflect this
Todo:
-adapt all card frontends but i915 to drm include file location
-review the mtrr change
-make the change to agp_i810.c coexist with the fix for buggy VESA
BIOSes which is commented out temporarily
-RCS IDs etc style stuff
-LKM support (rescan support for vga)
-test
 1.278 20-Mar-2007  garbled Put a small hack in slide.c disabled by default. PCIIDE_SLIDE_SETIRQA. This
sets IDE_IRQA in the IDE Control/Status Register. This is needed on prep
machines with Motorola RAVEN host bridges, as they wire up the ide device
oddly.
 1.277 25-Jan-2007  macallan branches: 1.277.2; 1.277.6; 1.277.8; 1.277.10;
add some flags for chipsfb
 1.276 20-Jan-2007  xtraeme Updated viaenv(4) driver:

* Support for the VIA VT8231 Hardware monitor.
* Power Management Timer available for timecounters in both
VT86C686A and VT8231 (code simplified thanks to dev/ic/acpipmtimer).
* Remove viapm(4) code and manpage (which was a link to viaenv.4 anyway).

From OpenBSD, tested by some users.
 1.275 17-Dec-2006  bouyer Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.274 17-Dec-2006  bouyer Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
 1.273 30-Nov-2006  bouyer branches: 1.273.2;
Add ahcisata(4), a driver for AHCI 1.0 and 1.1 controllers. Tested on the sata
ports of a Intel 63xxESB chipset. Does not support NCQ yet.
 1.272 31-Oct-2006  thorpej In the pcn driver:
- Remove the PCN_NO_PROM option. Instead, query the am79c970-no-eeprom
property, and read the MAC address from the CSRs if that property is TRUE.

In the ibmnws port:
- Implement device_register().
- In device_register(), set the am79c970-no-eeprom property for the
built-in Ethernet.
 1.271 27-Oct-2006  bouyer Add SATA native registers support for VIA SATA controllers, so that
drives are probed using the SATA way (from FreeBSD). While here add the
VT8237A SATA Controller to the tables, should fix PR kern/34927.

Thanks to the C�sar Catri�n Carre�o and paul (at) whooppee.com for
tests.
 1.270 25-Oct-2006  bouyer Map the SATA registers for SATA channels, and probe drives using them instead
of using the old PATA way. Tested with a PDC20375 (2xSATA + 1xPATA).
While there add the PDC20618-621 products (Ultra/133 controllers);
untested. Yes, it's strange to support PATA-only devices in a driver
called pdcsata, but that's how it is ...
 1.269 23-Sep-2006  macallan a half done wsdisplay driver for Chips & Technologies 65550 graphics chips
So far it only uses the blitter for scrolling and rectangle filling,
characters are still drawn in software and there's no support for video
mode switching. Virtual consoles are supported via vcons.
Works fine on a PowerBook 3400c.
 1.268 09-Sep-2006  riz branches: 1.268.2;
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:

- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.

Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.267 07-Sep-2006  itohy branches: 1.267.2;
Add PIOBM (busmastering transfer using ATA PIO mode) support.
The PIOBM is used by only one driver (will be added later,
stay tuned) and intruduce an attribute "ata_piobm" so that
it will be conditionally compiled in.
The "ata_dma" (busmastering transfer using ATA DMA mode) and
"ata_udma" (busmastering transfer using ATA Ultra DMA mode)
attributes are also added for consistency, but unused for now.
 1.266 16-Aug-2006  gdamore Initial import of radeonfb. Works to some degree on at least some hardware.
Most of the testing was done on MIPS hardware -- it probably needs work before
it will be useful with x86 hardware, and it is probably incompatible with
the X11 server.

"ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
does not endorse, this software. ATI will not be responsible or liable
for any actual or alleged damage or loss caused by or in connection with
the use of or reliance on this software."

Enjoy!
 1.265 13-Aug-2006  jmcneill Add rasops16 attribute to unichromefb.
 1.264 13-Aug-2006  simonb Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.
 1.263 10-Aug-2006  cube iwi now needs firmload [hi nick!]
 1.262 02-Aug-2006  jmcneill branches: 1.262.2;
Forgot to commit this last night -- add the unichromefb(4) driver.
 1.261 11-Jul-2006  drochner use timecounter code in dev/ic/acpipmtimer.*,
kill interface attribute in device declaration
 1.260 30-Jun-2006  nisimura Add kse(4) driver for Micrel KSZ8842/8841 Ethernet controller.
 1.259 26-Jun-2006  drochner -make sure it is a PIIX4 before accessing counter stuff
(there might be usable registers on 440mx and that ATI thing too,
but that needs to be checked/tested)
-make sure the I/O access to the power management stuff was enabled
by the BIOS before trying to map/access stuff
-most PIIX4s have a bug in the timer latch which causes jitter or worse
if it is read naively - check the revision
-use common code in dev/ic/acpipmtimer.c
 1.258 07-Jun-2006  dogcow branches: 1.258.2;
revert my earlier commit - the /ic/ stuff should go in src/sys/conf/files,
not here.
 1.257 07-Jun-2006  dogcow ral_pci was missing the /ic/ files.
 1.256 06-Jun-2006  rpaulo Attachment framework for the rt2561.c and rt2661.c drivers.

From OpenBSD.
 1.255 28-May-2006  martin Move definition of the 'fb' attribute to global scope and make machfb@pci
require it. On most archs this does not change anything, but on sparc{,64}
it allows linking of kernels that have machfb as the only framebuffer.
Solution suggested by Quentin.
 1.254 24-May-2006  wrstuden 3ware 9000 driver, contributed by Wasabi Systems and written
by Jordan Rhody (based on the FreeBSD driver).

Contributed in NetBSD PR 33364.
 1.253 07-May-2006  jmcneill branches: 1.253.2;
Add support for the Intel PIIX4 power management controller, from OpenBSD.
 1.252 30-Apr-2006  xtraeme Add missing 'arp' keyword for the nfe driver, reported by Murray
Armfield in PR kern/33384.
 1.251 26-Apr-2006  rpaulo Comment out glxt.
 1.250 18-Apr-2006  rittera A number of minor changes for NDIS. (OK'd by phil)

1. Removed the makeoptions line from arch/i386/conf/GENERIC. Now
ndis_driver_data.h is simply copied into the kernel build directory instead
of editing the config file to specify its location.

2. Uncommented lines in files.i386 and files.pci related to NDIS. NDIS will
not be compiled into the kernel unless the two lines are uncommented from
GENERIC (I checked using nm), so there is no reason for this to be commented
out.

3. Added ndiscvt to usr.sbin/Makefile.
 1.249 17-Apr-2006  rpaulo Pull firmload on ipw.
 1.248 12-Apr-2006  macallan convert to vcons
while there, attach an fb device when running on sparc
 1.247 11-Apr-2006  macallan A driver for 3Dfx Voodoo3 graphics boards, may or may not work with Voodoo4,
Voodoo5 or Banshee boards.

So far it supports:
- full acceleration in 8bit graphics mode
- video mode switching
- virtual consoles via vcons

So far it hasn't been tested on anything else than macppc and even there it
needs a hack to overload ofb.

TODO:
- test on i386
- don't hardcode video mode
 1.246 31-Mar-2006  rittera Updated to the latest NDIS code. I added commented out lines in the files
arch/i386/conf/GENERIC, arch/i386/conf/files.i386 and dev/pci/files.pci which
can simply be uncommented to compile NDIS into the kernel. I'll write some
documentation on this soon.

Note that NDIS is still somewhat experimental. It is currently tested and
functions relatively well on on two cards:
1. Dell (Broadcom) TrueMobile 1400 Dual Band WLAN Mini-PCI
2. Intel EtherExpress Pro/100
 1.245 21-Mar-2006  he Add a driver, ciss(4), for the HP/Compaq drivers using the newer
"Command Interface to SCSI-3 Support" command interface. Driver
ported from OpenBSD by Tonnerre Lombard -- thanks!
 1.244 12-Mar-2006  chs branches: 1.244.2;
add nfe.
 1.243 06-Mar-2006  bouyer branches: 1.243.2;
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.242 19-Feb-2006  tls branches: 1.242.2;
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).

From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.241 06-Dec-2005  christos branches: 1.241.2; 1.241.4; 1.241.6;
New lmc driver from David Boggs
 1.240 18-Oct-2005  joerg Both iwi and ipw need arp.
 1.239 28-Sep-2005  kent split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.238 09-Sep-2005  ragge Device driver for the Neterion (S2io) Xframe-I 10Gbit ethernet card.
Still missing: VLAN + IPv6 checksum support.
 1.237 29-Aug-2005  drochner remove the interface attribute (defining the "channel" locator) from
all the XXXide mutants -- this is handled by the "ata" attribute already
 1.236 11-Jul-2005  kiyohara ieee1394 import from FreeBSD.
 1.235 01-Jul-2005  drochner branches: 1.235.2;
add autoconf glue for the ralink wireless drivers, basically from
PR kern/30449, but changed so that pci/cardbus and usb devices
are all called "ral" to the user, so that code can be shared eventually
 1.234 25-Jun-2005  dyoung Move the definitions in dev/pci/files.ath into dev/pci/files.pci.
Stop including dev/pci/files.ath in arch/i386/conf/files.i386,
since we get the same definitions by including dev/pci/files.pci,
now. Remove dev/pci/files.ath.

Add arch/macppc/conf/Makefile.macppc with directives for linking
the Atheros HAL for PowerPC.

In athhal-powerpc-be-eabi.opt_ah.h, #define AH_REGOPS_FUNC 1, since
otherwise the linker complains that the PowerPC HAL cannot link
with register-read/write subroutines.

Add ath(4) to the GENERIC macppc kernel configuration; comment it
out.
 1.233 18-Jun-2005  kent An audio driver for High Definition Audio.

The driver is highly experimental at this moment:
- limieted support for playback
- support for no mixer controls
- support for no recording
 1.232 27-Feb-2005  perry branches: 1.232.2;
nuke trailing whitespace
 1.231 20-Feb-2005  jdolecek Add device driver support for the VIA Networking Technologies VT6122
gigabit ethernet chip and integrated 10/100/1000 copper PHY.

Obtained from: FreeBSD
 1.230 12-Feb-2005  rearnsha Change PCIIDE_I31244_ENABLEDMA to PCIIDE_I31244_DISABLEDMA as
suggested by briggs. Put the flag in opt_pciide.h.
 1.229 21-Jan-2005  yamt branches: 1.229.2;
- switch to dev/rtl8169.c from pci/if_re.c.
- enable re@cardbus.
both of re@pci and re@cardbus seem to work for me.
 1.228 12-Jan-2005  reinoud branches: 1.228.2;
Initial commit of auixp(4) driver. It's a driver for the audio part of ATI
IXP-200 and family motherboard chips. Its functional for both recording and
playback.

Note that quadraphonic and Dolby 5.1 audio are not tested by me but ought
to work fine. I can set the number of channels etc. OK but i can't listen
to the result. Any feedback on this performance would be greatly
apreciated.
 1.227 11-Jan-2005  skrll Add iwi(4).
 1.226 06-Dec-2004  cube Add config wires for ixpide(4).
 1.225 01-Dec-2004  grant add iteide(4) driver for ITE8212-based IDE controllers. from
OpenBSD, ported to NetBSD by me.

ok'd by bouyer@, thorpej@.
 1.224 24-Nov-2004  bouyer pdcsata(4), a driver for the Promise SATA150 (aka PDC203xx) serie of
controllers. Tested with a PDC20375 (2 SATA, one PATA) controller on sparc64.
Added to all kernel config file which had pdcide(4).
 1.223 13-Nov-2004  kent auacer uses aurateconv
 1.222 22-Oct-2004  scw Make artsata depend on sata.
 1.221 10-Oct-2004  augustss Add a driver for the Acer Labs M5455 audio controller.
This controller is integrated in some ALi Southbridges.

XXX This driver is incomplete and slightly buggy, but it
works enough to enable me to listen to music on my Sharp MM20.
 1.220 26-Sep-2004  dyoung Add rtw(4).
 1.219 30-Aug-2004  drochner add centralized {eisa,isa,pci,agp,mca}busprint() functions which do
what tens of the bus' parents foo{...}bridge_print()s scattered around do
 1.218 30-Aug-2004  drochner there is (appearently) no reason for the "bktr" driver to carry a
"pcibus" attribute, so remove it
 1.217 26-Aug-2004  itohy Workbit NinjaSCSI-32 PCI/CardBus SCSI driver (njs)
 1.216 23-Aug-2004  lukem Add ipw(4)
 1.215 12-Aug-2004  thorpej Don't assume wdc-specific ATA / ATAPI code should be brought in if atabus
or atapibus are configured; use a separate wdc_common attribute to indicate
that the shared wdc code is also present.
 1.214 09-Jul-2004  bouyer Add geodeide(4), a driver for the AMD Geode CS5530A IDE controller.
Tested by Ian Zagorskih (ianzag at megasignal.com).
 1.213 08-Jul-2004  drochner support the game port on eap1371
This is only usable with some caution because these soundcards only
allow to map IO port 0x20x for this, thus bypassing PCI address
management. Very likely this will only work on primary PCI buses, and there
is some potential for conflicts with ISA devices as well.
(XXX cannot be detached because the "joy" driver doesn't support it yet)
 1.212 28-May-2004  thorpej satalink now needs the "sata" attribute.
 1.211 28-May-2004  toshii Add re(4) RealTek 8139C+/8169/8169S/8110S PCI ethernet adapter driver,
from FreeBSD.
I haven't tested this code very well, but it seems to work fairly well
for me.
 1.210 12-Mar-2004  ragge branches: 1.210.2;
Add driver for Intel PRO/10GbE ethernet adapter. Now NetBSD has no
problem with intercontinental TCP connections of over 4Gbit/s, which is
where my test hardware runs out of bus bandwidth.

Stuff that is on the TODO list:
* HW VLAN support.
* Large jumbo buffers (16k).
* TCP Segmentation Offload
* RAIDC (receive interrupt delay adaptation)
* Understand how to use memory above 4GB.
 1.209 14-Feb-2004  junyoung device<tab>
attach<tab>
 1.208 03-Feb-2004  fredb Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.207 25-Jan-2004  jdolecek add puc(4) atppc(4) attachment; probes correctly, but needs further
work to support DMA, and some actual transfer testing
 1.206 20-Jan-2004  jdolecek cleanup old lpt(4) attachment, and glue ppbus in so that they can coexist:
* lpt device is defined in MI place (dev/ppbus/files.ppbus), dev/ic/lpt.c
is included there too; dev/ic/lpt.c is not included if ppbus is
configured or if there is alternative platform lpt (like for pc532)
* g/c MD lpt definitions and custom puc/upc attachments,
glue moved to conf/files and dev/pci/files.pci respectively; remove
device lpt definition from dev/isa/files.isa
* add ppbus parport attribute, atppc device attachments, adjust plip and lpt
glue
 1.205 31-Dec-2003  jonathan Split opencrypto configuration into an attribute, usable by inkernel
clients, and a pseudo-device for userspace access.

The attribute is named `opencrypto'. The pseudo-device is renamed to
"crypto", which has a dependency on "opencrypto". The sys/conf/majors
entry and pseudo-device attach entrypoint are updated to match the
new pseudo-device name.

Fast IPsec (sys/netipsec/files.ipsec) now lists a dependency on the
"opencrypto" attribute. Drivers for crypto accelerators (ubsec,
hifn775x) also pull in opencrypto, as providers of opencrypto transforms.
 1.204 14-Dec-2003  thorpej Split the Intel i31244 SATA controller ("Artisea") driver out of piixide
into its own driver (artsata).
 1.203 13-Dec-2003  thorpej Split out the Silicon Image SATALink support into its own driver,
"satalink".
 1.202 05-Dec-2003  cube Remove bitbang code that was taken from FreeBSD to support recent SiS
chipsets and use mii_bitbang interface instead. Reflect sip dependency in
the config file.

Support for SiS96x needs broader testing.
 1.201 04-Nov-2003  mycroft Re-add ServerWorks IDE support, as "rccide". Note: this is untested, as I no
longer have a ServerWorks-based motherboard.
 1.200 31-Oct-2003  nisimura Added stpcide(4) driver for STMicroelectronics STPC IDE controllers.
 1.199 19-Oct-2003  matt Add PCN_NO_PROM flag. (read the macaddr from the chip assuming the "BIOS"
has properly written it). From John Gordon.
 1.198 08-Oct-2003  bouyer Following Matt Thomas's request, rename ata attribute to ata_hl, and
wdc_base to ata. We can now have
atabus* at ata?
in kernel config files.
 1.197 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.196 08-Oct-2003  bouyer Make the ATA mid-layer appears as atabus, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0006.html
This adds a device (atabus) between IDE controllers and wd or atapibus, to
have each ATA channel show up in the device tree. Later there will be atabus
devices in /dev, so that we can do IOCTL on them.
Each atabus has its own kernel thread, to handle operations that needs polling,
e.g. reset and others.

Device probing on each bus it defered to the atabus thread creation.
This allows to do the reset and basic device probes in parallel, which reduce
boot time on systems with several pciide controllers.
 1.195 30-Sep-2003  thorpej New generic I2C framework. Supports bit-bang and "intelligent" I2C
interface controllers (of varying intelligence levels).

Contributed by Wasabi Systems, Inc. Primarily written by Steve Woodford,
with some modification by me.
 1.194 27-Sep-2003  mrg add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by
yours truly.

XXX: missing mcast filter support.

thanks cliff!
 1.193 25-Sep-2003  pooka autoconf goop for iavc
 1.192 08-Sep-2003  thorpej Remove unused "skge" defns.
 1.191 26-Aug-2003  jdolecek Add driver for SysKonnect SK-9821 and 3COM 3C940 gigabit ethernet boards
From FreeBSD via OpenBSD, port to NetBSD done by Stephen Degler

Changes relative to submitted version:
* yukonreg.h and xmaciireg.h merged into if_skreg.h
* bhack[] constified + other small editing changes
* use 'Ethernet address' rather than 'address' in attach message

XXX completely untested by me, needs further cleanup

Driver provided in PR kern/22511 by Stephen Degler
 1.190 08-Aug-2003  jonathan Config hooks for ubsec (Bluesteelnet, Broadcom 582x) driver.
 1.189 06-Jul-2003  dyoung Add driver atw for PCI/Mini-PCI/Cardbus 802.11b NICs based on the
ADMtek ADM8211. Read the man page for bugs and other outstanding
issues.
 1.188 04-Jul-2003  wiz 1.179 had the commit message "Use CFATTACH_DECL()." but actually
added a paragraph for the non-existent (or just not in-tree)
als driver -- remove that paragraph again to avoid confusion.
 1.187 01-Jul-2003  drochner branches: 1.187.2;
VERY quick and VERY dirty port of the OpenBSD "txp" driver for
3Com 3C(R)990 cards. No TCP/UDP nor IPSEC offloading for now.
The ifmedia part needs some work, but I only have a 100-FX card;
hopefully someone will clean this up.
 1.186 19-Apr-2003  fvdl Add ahd at pci (to be added later).
 1.185 16-Apr-2003  thorpej Device driver for the LSI Logic Fusion-MPT based SCSI and Fibre Channel
adapters. Currently supports:

* LSI 53c1030 Ultra320 SCSI
* LSI FC909, FC909A, FC919, and FC929 Fibre Channel

Ported from the FreeBSD "mpt" driver, written by Greg Ansley. Thanks
to Frank van der Linden for testing and some bug finding.

This work was sponsored by Wasabi Systems, Inc.
 1.184 07-Nov-2002  martin Add a driver for the Myson Technology MTD803 3-in-1 Fast Ethernet Controller,
provided by Peter Bex in PR 18675.
 1.183 25-Oct-2002  leo Fritz!PCI v2.0 ISDN driver from FreeBSD.
 1.182 24-Oct-2002  junyoung Add machfb, ATI Mach64/Rage framebuffer display driver.

XXX this version is not fully functional yet. More to come shortly.
 1.181 11-Oct-2002  thorpej Fix up IPKDB_NE_PCI option dependencies:
* IPKDB_NE_PCISLOT does not need any dependencies (it is merely a
required parameter for IPKDB_NE_PCI).
* IPKDB_NE_PCI does should not have an option-dependency on IPKDB_NE_PCISLOT.
While IPKDB_NE_PCISLOT is a required parameter, that is not how option-
dependencies work, and we don't want IPKDB_NE_PCI to imply IPKDB_NE_PCISLOT,
as that would cause a bogus value for IPKDB_NE_PCISLOT to be used.

Also, the IPKDB_NE_PCI selector should be lower-case; make it so.
 1.180 08-Oct-2002  kent auvia:
- Add aurateconv
- Update comment
 1.179 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.178 24-Sep-2002  pooka Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.177 03-Sep-2002  augustss Replace the mr driver with the gtp driver. From OpenBSD.
 1.176 06-Aug-2002  augustss Pull in tea5757.c for the mr driver. Fixes kern/17864.
 1.175 23-Jun-2002  fvdl Add files for bge at pci attachment.
 1.174 02-Jun-2002  enami Collect random number from AMD 768MPX power management controller.
 1.173 18-May-2002  matt branches: 1.173.2;
Add lfmiop (LSILogic Fusion-MPT I/O Processor) placeholders for
driver to added latter.
 1.172 26-Apr-2002  ad branches: 1.172.2;
Add a driver for Adaptec FSA RAID controllers, as often found in Dell
servers. Based on the FreeBSD/OpenBSD versions.
 1.171 25-Apr-2002  kleink Add a joystick attachment to the ESS Solo-1 driver.
 1.170 22-Apr-2002  ad Add a driver for ICP-Vortex GDT and Intel Storage RAID controllers. Parts
taken from OpenBSD. Test hardware kindly provided by Intel. This still needs
management bits, and doesn't support older controllers, but that shouldn't
be hard to fix.
 1.169 22-Apr-2002  bouyer Add esiop at pci.
 1.168 22-Apr-2002  augustss Rename the audio "bus" attribute audiobus to avoid confusion with audio
device.
 1.167 17-Apr-2002  mycroft Remove TLP_MATCH_* options.
 1.166 30-Mar-2002  uwe Add (unfinished) igsfb driver.

While here g/c stale cprofb entry, it's not in the tree and I plan to
support CyberPro cards with igsfb driver eventually (where is my netwinder?)
 1.165 26-Mar-2002  thorpej Only build pciconf.o if pci is configured.
 1.164 25-Mar-2002  martin Now that we have all pieces in place (and enough granularity to specify
B-channel and D-channel drivers separately) split the Fritz!PCI card
driver out of the isic driver.

The new device is called "ifpci" and uses the same D-channel driver as the
isic devices, but has it's own B-channel driver.
 1.163 09-Mar-2002  kent Move sampling rate conversion functions to aurateconv.c.
Introduce "aurateconv" attribute for audio devices.
Add aurateconv to uaudio and auich.
(due to kern/15845 and kern/15848)
 1.162 02-Feb-2002  jdolecek Reduce the massive code duplication regarding joy(4). Split it into
MI and MD parts, and make ISA/ISAPNP/PCI joy(4) attachments MI.
 1.161 30-Jan-2002  ad Bare-bones driver for AMI RAID. Parts taken from FreeBSD. This was tried a
good while ago and it had problems under load. Changes were made to address
that, but I don't have the ability to test them. So, I'm committing it
before it rots.
 1.160 09-Jan-2002  augustss Split out some code so you can have cardbus ehci without pci.
 1.159 07-Jan-2002  jmcneill Re-enable radio at bktr, only if NRADIO > 0 and an FM tuner is present.
 1.158 07-Jan-2002  drochner "attach radio at radio":
using one word as both attribute and device doesn't work well,
radio.c is pulled in even with no such device in the configuration,
and the kernel doesn't link due to missing "radio_cd".
So call the attribute "radiodev" to avoid confusion.
 1.157 07-Jan-2002  tron Backout revision 1.155 which caused build failures if bktr(4) is used
without radio(4).
 1.156 06-Jan-2002  jmcneill Import driver for the ESS Allegro-1 / Maestro-3 based PCI Audio Accelerators.
 1.155 06-Jan-2002  jmcneill Add radio support to bktr.
 1.154 03-Jan-2002  thorpej Need ibm561.c for TGA.
 1.153 01-Jan-2002  augustss Add support for radio cards. Written by Maxim Tsyplakov and Vladimir Popov
for OpenBSD, from where it was imported.
 1.152 01-Jan-2002  hpeyerl Add stanza for PC Weasel/PCI.
 1.151 12-Dec-2001  elric Added support for the PowerStorm 4d20, initial support that is.
I plan on cleaning a few things up over the next few days, but this
appears to be working for me.
 1.150 05-Dec-2001  augustss Do SIR framing on incoming frames.
 1.149 05-Dec-2001  wiz Use defparam instead of defflags for some bktr(4) related options that need
a value. Add BKTR_REVERSE_MUTE to defflags.
 1.148 05-Dec-2001  simonb s/defopt/defparam/ in previous; from lukem.
 1.147 05-Dec-2001  simonb Change PCI_NETBSD_ENABLE_IDE back to a defopt - it's a mask.
 1.146 02-Dec-2001  augustss Add driver for the Toshiba's Oboe IrDA chip. From Jan Sparud.
 1.145 28-Nov-2001  lukem - convert usage of "defopt" to "defflag" where the relevant option does
not support a value (e.g., it's to be used as "options FOO" instead of
"options FOO=xxx"). options that take a value were converted to
defparam recently.
- minor whitespace & formatting cleanups
 1.144 18-Nov-2001  someya add Trident 4DWAVE based (4DWAVE DX/NX,SiS 7018,ALi M5451) PCI audio driver
 1.143 03-Nov-2001  tsutsui Add a driver for the Tekram DC-395U/UW/F and DC-315/U SCSI host adapters,
which have the Tekram TRM-S1040 ASIC.
This driver is written by Rui-Xiang Guo <rxg@ms25.url.com.tw>,
and a number of cosmetic changes by me.
Tested on i386 by the author, and on macppc and sparc64 by me.

XXX On arc, kernel got panic in ltsleep() called from scsipi_execute_xs(),
XXX but I'm not sure what is wrong...
 1.142 17-Oct-2001  jdolecek branches: 1.142.2;
Add driver for Creative Labs SBLive! EMU10000, possibly also PCI512.
Written by Yannick Montulet (thanks!), with only couple minor touches by me.
 1.141 13-Oct-2001  ichiro Add Intersil Prism2.5 Mini-PCI wavelan.
 1.140 16-Sep-2001  eeh Driver for Sun GEM gigabit ethernet, Sun ERI 10/100, and Apple GMAC.
 1.139 13-Sep-2001  thorpej Add an ioctl interface to the PCI bus. Add ioctls to read/write
PCI configuration space registers, and to fetch bus info.
 1.138 04-Sep-2001  itohy branches: 1.138.2;
Add "opl at cmpci" and "mpu at cmpci" attachment.
 1.137 27-Aug-2001  thorpej New driver for the AMD PCnet-PCI family of Ethernet chips. This
driver uses direct DMA to mbufs (like other PCI network drivers,
and unlike the old "le at pci" driver), and also supports communication
with the MII-connected PHYs on the 10/100 boards.
 1.136 22-Aug-2001  thorpej Add a PCI_NETBSD_ENABLE_IDE option, that goes along with
PCI_NETBSD_CONFIGURE, which tells machine dependent code
to enable the specified (by a bitmask) PCI IDE channels in
the southbridge, in the event that system firmware does not
do so.
 1.135 01-Aug-2001  ad Hook in the mly control interface on i386.
 1.134 30-Jul-2001  ad Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.133 25-Jul-2001  thorpej Driver for the Sundance Tech./Tamarack TC9021 Gigabit Ethernet
controller.
 1.132 07-Jul-2001  thorpej branches: 1.132.2;
Remove config glue for the old `ncr' driver.
 1.131 19-Jun-2001  thorpej Device driver for the Sundance Tech. ST-201 10/100 Ethernet. This
chip is found on the D-Link DFE-550TX.
 1.130 03-Jun-2001  tsutsui Add a driver for the Initio INIC-940/950 PCI SCSI controllers.
Based on OpenBSD's iha driver, and modified some structures by me.

Tested on arc, i386 and macppc.
 1.129 22-May-2001  thorpej Add mii_bitbang attribute to gsip, pointed out by Andrew Gillham.
 1.128 18-May-2001  thorpej Add a driver for the National Semiconductor DP83820 Gigabit Ethernet
chip. This is found on the NetGear GA-622 and Asante FriendlyNet
GigaNIX.
 1.127 30-Mar-2001  minoura Yamaha YMF724/740/744/754 (DS-1) PCI audio driver.
 1.126 25-Mar-2001  jmc Actually fix fwlynx correctly. Got the right filename this time.
 1.125 13-Mar-2001  jmc Fix typo on fwlynx_pci driver. Brett McCoy reported this in.
 1.124 08-Mar-2001  thorpej advlib.c and advmcode.c should be built for all adv, not
just adv_pci. From takashi.yamamoto@bigfoot.com, kern/12341.
 1.123 24-Feb-2001  lukem branches: 1.123.2;
whitespace police
 1.122 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.121 09-Feb-2001  briggs Add an option (defopt) PCI_NETBSD_CONFIGURE that provides PCI bus
configuration (assignment of bus numbers, BARs, timer values,
interrupt lines, etc.).
The interface must be called from m.d. code prior to probing the bus.
It is meant to be called once for each primary (bus == 0) PCI bus in
the system. It will configure any busses behind PCI-PCI bridges.
Section 9 man page for pci_configure_bus() will come soon.
In the meantime, sample usage is in arch/sandpoint/sandpoint/mainbus.c.
[ Reviewed by thorpej ]
 1.120 07-Feb-2001  tacha Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe@nabechan.org>.
 1.119 04-Feb-2001  ad Add a driver for the Mylex DAC960 family (including DEC SWXCR).
 1.118 22-Jan-2001  ad opt_twe.h isn't needed any more.
 1.117 22-Jan-2001  augustss Add clct driver for Cirrus Logic CrystalClear PCI Audio CS4281.
Driver written by Tatoku Ogaito.
 1.116 08-Jan-2001  thorpej Only build "esm" if it's included in the kernel config file.
 1.115 08-Jan-2001  rh Add esm audio driver.
 1.114 05-Jan-2001  martin Enable the imported ISDN4BSD based ISDN subsystem.

This is the kernel part (userland to follow soon) of the latest (and
very probably last) release (version 0.96) of ISDN4BSD. ISDN4BSD has a
homepage at http://www.freebsd-support.de/i4b/.

It gives the user various ways to use the isdn connection: raw data (via
the i4brbch "raw b-channel" device), ppp (via the isp "isdn PPP" device),
voice/answering machine (the i4btel "telephone" device) and ip over isdn
(the ipr device, "IP over raw ISDN").

Supported are a bunch of common and older cards, more to be added soon
after some cleanup. Currently only the european E-DSS1 variant of the
ISDN D channel protocol is supported.
 1.113 24-Dec-2000  augustss Add some placeholders for the EHCI (USB 2) driver.

Don't get your hopes up. I've not even finished reading the
(100+) page spec, and I have no hardware.
 1.112 14-Dec-2000  onoe Add PCI version of Aironet, not tested at all.
ISA/ISApnp version won't come since I don't know about isa...
 1.111 28-Nov-2000  thorpej Device driver for the built-in audio on Intel ICH, ICH0, ICH2,
and i440MX chipsets. Based on a driver by Michael Shalayeff,
modified somewhat by me to use bus_dma properly, and fix some
audio encoding emulation bugs.

Thanks to Manuel Bouyer for testing and feedback.
 1.110 26-Nov-2000  ad lsu -> ld, by popular request.
 1.109 14-Nov-2000  matt Add fwlynx PCI attachment
 1.108 08-Nov-2000  ad Add glue for iop.
 1.107 08-Nov-2000  ad Move lsu stuff to more logical locations, and push queueing into the lsu
driver.
 1.106 05-Nov-2000  thorpej Add NeoMagic 256 audio.
 1.105 05-Nov-2000  thorpej viaenv carries the sysmon_envsys attribute.
 1.104 20-Oct-2000  ad - tsleep()/wakeup_one() will hurt when under load, so use a queue instead.
- Don't copy to or from the aligned buffer unless there's a need to.
 1.103 19-Oct-2000  ad Hook in twe.
 1.102 12-Oct-2000  itojun hifn7751 crypto card driver. from openbsd.
does nothing useful at this moment - initailize the chip, that's all.
TODO: crypto logic framework in kernel (see openbsd sys/crypto)
TODO: ipsec frontend (need major rework in ipsec tree - should start with busywait)
TODO: character device frontend
 1.101 02-Aug-2000  bouyer PCIIDE_CMD0646U_UDMA->PCIIDE_CMD0646U_ENABLEUDMA for consistency with
PCIIDE_AMD756_ENABLEDMA
defopt PCIIDE_CMD0646U_ENABLEUDMA, PCIIDE_AMD756_ENABLEDMA,
PCIIDE_CMD064x_DISABLE
Fix a typo pointed out by John Hawkinson
 1.100 25-Jul-2000  jeffs Add code to allow the PCI com serial ports to be used as the system
console. This is not enabled by default, and is turned on with
options PUCCN. Done by castor@netbsd.org.
 1.99 25-Jun-2000  gmcgarry cmpci requires mulaw dependency.
 1.98 25-Jun-2000  sommerfeld Defopt TLP_MATCH_*
 1.97 24-Jun-2000  thorpej Add a clearing-house pseudo-device for system monitoring devices
such as the LM78 and VT82C686A (and eventually ACPI). Multiple
sensor devices can be hooked registered with `sysmon', and eventually
sysmon will also handle hardware (and software) watchdog timers.

Convert the `lm' and `viaenv' drivers to the new interface.
 1.96 06-Jun-2000  thorpej branches: 1.96.2;
Common routines for read/writing Cypress 82c693 control registers. Needed
by `pciide' and the Alpha `sio' (PCI-ISA bridge) driver.
 1.95 30-May-2000  matt Add the PCI attachment for IEEE 1394 OHCI controllers. Files to follow later.
 1.94 17-May-2000  thorpej branches: 1.94.2;
Add a device driver for the Cyclades-Z series of intelligent multi-port
serial boards. Written by Jason R. Thorpe and Bill Studenmund.
 1.93 15-May-2000  bouyer Update for siop split.
 1.92 10-May-2000  haya Move if_rl_pci.c:1.7 to if_rtk_pci.c.
 1.91 08-May-2000  joda VIA VT82C686A hardware monitor
 1.90 07-May-2000  wiz some glue for bktr-driver
 1.89 30-Apr-2000  augustss Add driver for C-Media CMI8x38 Audio Chip. From Takuya SHIOZAKI <AoiMoe@imou.to>
 1.88 21-Apr-2000  bouyer Snapshot of work in progress: new driver for the NCR 53c8xx SCSI controller
(the name 'siop' is still being discussed, may change).
Only basic disconnect/reselect for now, no sync/wide negotiation.
Tested with 810A, 875 and 895 on i386 only.
The bus-independant part should also be able to handle the 53c720 and 53c770.
A new driver with enhanced script should appear for the 825/875/895 'soon'.
 1.87 20-Apr-2000  nathanw Replace rcons console code with rasops console code.
Console text should now be supported on all TGA cards;
8- and 32-bit TGA and 8-bit TGA2 have been tested.

Implement accelerated character drawing, scrolling, and clearing.

Stop clearing "odd" in VHCR; it's unnecessary and hurts performance.

Use bus_space_vaddr() instead of a local hack.
 1.86 19-Apr-2000  haya Changes the name of RealTek driver. The new name is `rtk'. This used
to be called `rl' and it conflict with RL vax disks, canonical and
historical unix driver name.

This changes are minimal: it only changes the name of RealTek driver.
The filename of source code and a lot of the letter `rl' in source
files should be changed shortly.
 1.85 10-Apr-2000  haya Incorporate the changes of RL81x9 driver provided by M. Kanaoka
<kanaoka@ann.hi-ho.ne.jp>. He separated the driver into IC specific
portion and bus attachment portion and added cardbus attachent.
 1.84 05-Apr-2000  mrg add "hme at pci" support.
 1.83 02-Apr-2000  nathanw Move bt463 code to dev/ic and adapt to the new ramdac interface.
Set default window type to 24-bit truecolor.
Correctly set pseudocolor mode.
 1.82 31-Mar-2000  tsarna Add auvia, a driver for the integrated AC'97 audio on the VIA VT82C686A
southbridge.

Tested on a ASUS K7M (w/ AD1881 codec). Please report any problems.
 1.81 22-Mar-2000  ws Make IPKDB working again.
Add support for i386 debugging and pci-based ne2000 boards.
 1.80 22-Mar-2000  cgd add PCI_CONFIG_DUMP as a defopted option
 1.79 22-Mar-2000  cgd opt_pciverbose.h -> opt_pci.h (it's gonna be used by more things, soon)
 1.78 16-Mar-2000  ad Driver for Compaq array controllers and disks (cac(4)/ca(4)).
 1.77 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.76 25-Feb-2000  drochner add (minimal, PIO only) support for the popular "Tundra Universe"
PCI-VME interface chip and a frontend for the "Bit3 Mod. 2706"
PCI-VME adapter
 1.75 26-Jan-2000  thorpej Fix an oversight in the AIC-7xxx SEEPROM split.
 1.74 04-Jan-2000  chopps Add support for setting the clock and adapt the code to the new more
generic ic/hd56470.c core which now supports the isa version of the
same card.
 1.73 13-Dec-1999  augustss Add a device driver for the Cirrus Logic CS4280 sound chip.
The code has been contributed by Tatoku Ogaito.
 1.72 19-Nov-1999  thorpej Make the ThunderLAN and VIA Rhine drivers use the common MII bit-bang module.
 1.71 02-Nov-1999  augustss Add the midibus attribute to the fms driver.
 1.70 02-Nov-1999  thorpej Get fms MPU and OPL module inclusion right.
 1.69 01-Nov-1999  augustss Add FM801 audio device driver. From Witold J. Wnuk ww181302@zodiac.mimuw.edu.pl
Closes PR kern/8729.
 1.68 30-Oct-1999  augustss Use the right attribute for attaching USB controllers.
From MAEKAWA Masahide <bishop@rr.iij4u.or.jp>
 1.67 30-Oct-1999  augustss Add midibus attribute for eap.
 1.66 27-Oct-1999  augustss Add support for ES1371. From OpenBSD and Ezra Story <ezy@panix.com>.
 1.65 15-Oct-1999  haya branches: 1.65.2; 1.65.4;
This is the first check-in of CardBus driver. CardBus driver contains
CardBus bus stub, YENTA PCI-CardBus bridge (cbb), 3Com 3C575TX driver
(ex) and Intel fxp driver.

TODO:
o Conform to the KNF more strictly.
o Be unified with pcmcia code as much as possible.
o Add more drivers for CardBus card, such as APA-1480 or USB card.

The affected files are listed below.

sys/arch/i386/conf/files.i386
sys/arch/macppc/conf/files.macppc
sys/conf/files
sys/dev/ic/elinkxl.c
sys/dev/ic/elinkxlvar.h
sys/dev/ic/i82365.c
sys/dev/ic/i82365var.h
sys/dev/isa/i82365_isasubr.c
sys/dev/pci/files.pci
sys/dev/pcmcia/pcmcia.c
sys/dev/pcmcia/pcmciachip.h

The added files are listed below.

sys/arch/i386/conf/CARDBUS
sys/arch/i386/include/rbus_machdep.h
sys/arch/i386/i386/rbus_machdep.c
sys/arch/macppc/include/rbus_machdep.h
sys/arch/macppc/macppc/rbus_machdep.c
sys/dev/cardbus/if_ex_cardbus.c
sys/dev/cardbus/Makefile.cardbusdevs
sys/dev/cardbus/cardbus.c
sys/dev/cardbus/cardbus_map.c
sys/dev/cardbus/cardbusdevs
sys/dev/cardbus/cardbusdevs.h
sys/dev/cardbus/cardbusdevs_data.h
sys/dev/cardbus/cardbusvar.h
sys/dev/cardbus/cardslot.c
sys/dev/cardbus/cardslotvar.h
sys/dev/cardbus/devlist2h.awk
sys/dev/cardbus/files.cardbus
sys/dev/cardbus/if_fxp_cardbus.c
sys/dev/cardbus/pccardcis.h
sys/dev/cardbus/rbus.c
sys/dev/cardbus/rbus.h
sys/dev/pci/pccbb.c
sys/dev/pci/pccbbreg.h
sys/dev/pci/pccbbvar.h
 1.64 13-Oct-1999  thorpej Add declaration for the Adaptec AIC-6915 64-bit 10/100 Ethernet interface.

Note: this is a placeholder right now; the driver should be ready in the
next few days.
 1.63 27-Sep-1999  ad branches: 1.63.2;
Add glue for 'dpt' driver.
 1.62 01-Sep-1999  drochner add "ti" - Alteon Gigabit Ethernet
 1.61 01-Sep-1999  thorpej This is the long-awaited "new Tulip driver", a complete, from-scratch
rewrite of the driver for the DECchip 21x4x Ethernet chips, and a variety
of clones.

Currently, the driver supports the Winbond 89C840F (this works pretty
well), and the Lite-On PNIC (e.g. NetGear PCI boards), however Lite-On
support may be broken [I may simply have a busted test board].

Eventually, support for the Macronix and ASIX chips will filter into
this driver, and then, slowly, support for the genuine DEC chips,
and maybe even the DE-425 EISA model.
 1.60 02-Aug-1999  augustss Move the mpu device declaration to conf/files.
Let the mpu device attach at the sb device, and then midi at the mpu.
Update the mpu at eso attachment.
 1.59 12-Jul-1999  kleink Add a driver for the ESS Technology Solo-1 PCI AudioDrive line of chips.
 1.58 30-Jun-1999  drochner add driver for the Bit3 PCI-VME adapter, without the DMA parts for now
 1.57 27-Jun-1999  drochner add driver for realtek 8129/8139, from freebsd, with mii stuff kicked out
 1.56 20-Jun-1999  thorpej Intel i82557 driver is now split into bus and chip bits.
 1.55 01-Jun-1999  thorpej Glue in the SiS900 Ethernet controller driver.
 1.54 25-Mar-1999  explorer branches: 1.54.2; 1.54.4; 1.54.6;
Start commit of Lan Media Corp T1/HSSI/DS3 driver
 1.53 09-Feb-1999  sakamoto add "mii" to vr driver.
 1.52 21-Jan-1999  sakamoto Add VIA Rhine/Rhine II Fast Ethernet files.
 1.51 06-Jan-1999  thorpej Device declaration for the PCscsi-PCI SCSI chip driver.
 1.50 10-Dec-1998  augustss Add a driver for the S3 SonicVibes chip. From OpenBSD and
Constantine Paul Sapuntzakis (csapuntz@cvs.openbsd.org) with
some changes by me.
XXX The driver still needs work.
 1.49 04-Nov-1998  fvdl Add the 'ex' driver, a DMA driver for 3Com 90x and 90xB cards. Rename
constants from EP_ to ELINK_ since they're now used in the ex driver as well.
 1.48 31-Oct-1998  thorpej Use the rtl80x9 common code for media selection.
 1.47 12-Oct-1998  bouyer Merge bouyer-ide
 1.46 26-Sep-1998  dante Add AdvanSys ULTRA WIDE SCSI controllers
 1.45 26-Aug-1998  dante Add AdvanSys support
 1.44 11-Aug-1998  thorpej Adapt "tl" driver to the new MII code, and add the "mii" attribute to
the "fxp" driver.
 1.43 26-Jul-1998  explorer add ntwo* at pci? function ?, a T1 network driver.
 1.42 21-Jul-1998  drochner adapt to LANCE driver split; let PCNET/PCI use the 32-bit mode
 1.41 12-Jul-1998  augustss Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers
 1.40 26-Jun-1998  cgd add a driver for "PCI 'universal' communications" cards, that is, PCI cards
which contain 'standard' com- and lpt-type ports. Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not. (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.) Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
 1.39 02-Jun-1998  thorpej branches: 1.39.2;
Device driver for the SMC 83c170 Ethernet PCI Integrated Controller (EPIC/100)
used in the SMC EtherPower II.

Media control isn't yet supported, due to some MII infrastructure
problems which I hope to address soon. This isn't a huge deal, since
the PHY defaults to auto-negotiate mode.

Also, the device just programs the multicast hash table to accept all
multicast, to avoid a hardware bug that causes the multicast address
filter to lose in 10Mb/s mode. This bug will be fixed in a more sane
way once the media control issues are dealt with.
 1.38 31-May-1998  cgd dd a PCI 'quirks' mechanism, meant to be used as the mechanism
of last resort when trying to communicate information about
bogus behaviour of PCI devices to the MI autoconfiguration code.
In general, bogus behaviour should be handled by drivers, but there
are some types of bogons which can't be addressed that way. The
only quirk currently defined is one which indicates that the device
is multi-function even though the device's header says otherwise.
(Mmm, Intel 82371FB PCI-to-ISA Bridge (PIIX); you'd think that at least
Intel would have gotten it right...)
 1.37 14-May-1998  kml Driver for Essential Communications' RoadRunner HIPPI (800 Mb/sec network)
card. With some modification, this could probably also work for their
Gigabit Ethernet card based on the same chipset...
 1.36 01-May-1998  augustss Add a driver for the Ensoniq AudioPCI sound card. The driver still
needs some testing, but it seems to produce sound. The driver was written
by me, but since I don't have the hardware the debugging and testing was
done by Andreas Gustafsson <gson@araneus.fi>, Chuck Cranor
<chuck@maria.wustl.edu>, and Phil Nelson <phil@cs.wwu.edu>. Thanks.
 1.35 15-Apr-1998  drochner add mi PCI VGA and TGA
 1.34 04-Mar-1998  cgd add (commented out) device/file declarations for the MI PCI IDE
controller driver. These are commented out here until the wdc
declaration mess is resolved, and until then need to go into MD
files files in places where they play nice with the wdc declaration.
 1.33 16-Feb-1998  thorpej Remove "class" declarations, and add "devclass" declarations where
appropriate. Fix several inconsistencies between device class and
attributes. Mostly from Chris Demetriou.
 1.32 12-Jan-1998  thorpej Update for config changes.
 1.31 21-Oct-1997  bouyer Correct 'ThunderLAN' spelling
 1.30 17-Oct-1997  bouyer branches: 1.30.2;
Driver for Texas Instruments' thunderland network controller (present in some
Compaq products).
 1.29 14-Oct-1997  thorpej Pulldown from marc-pcmcia branch: PCI front-end for the "ne" driver.
 1.28 13-Sep-1997  enami Declare PCIVERBOSE by defopt in files.pci. Include opt_pciverbose.h
in pci_subr.c.
 1.27 12-Sep-1997  mycroft Fix bogus comment.
 1.26 30-Aug-1997  mycroft Pull in new file.
 1.25 20-Jul-1997  pk branches: 1.25.2;
config.new => config
 1.24 05-Jun-1997  thorpej Add device declaration for Intel EtherExpress PRO 10/100B driver.
 1.23 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.22 12-Mar-1997  cgd specs for ISP 10x0 (isp) driver PCI attachment. From Matt Jacob
 1.21 12-Nov-1996  thorpej branches: 1.21.4;
Centralize the declaration of the "en" driver (Efficient Networks, Inc.
155Mb/sec ATM interface).
 1.20 24-Sep-1996  christos New cyclades driver from Timo Rossi.
 1.19 01-Sep-1996  mycroft Update.
 1.18 14-Jul-1996  cgd alphabetize by driver name
 1.17 22-Jun-1996  chuck pci specific code for the eni155p card
 1.16 16-May-1996  mycroft New version, with changes from Justin Gibbs and Noriyuki Soda.
 1.15 07-May-1996  thorpej Make the MI LANCE driver standalone, and use cfattach to resolve
naming conflicts between bus attachments on ports that can have
multiple instances of the LANCE.

Add a real PCI front-end for PCnet-PCI Ethernet cards.

Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
 1.14 25-Apr-1996  thorpej Break up the ep driver into isa, eisa, and pci front-ends and a
bus-independent core driver. Tested on all three bus types, including
an isa 3c509 masquerading as an eisa device (use ep* at eisa? slot ? in
your kernel config file to catch this one).
XXX Driver still needs to be converted to <machine/bus.h>
 1.13 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.12 04-Mar-1996  cgd the i386 port no longer attaches isa, eisa, and pci at root.
 1.11 28-Feb-1996  cgd make PCI bus match/attach and sub-device attachment machine-independent,
add definition of 'ppb' (PCI-PCI bridge) device.
 1.10 27-Feb-1996  cgd alphabetize device list
 1.9 13-Jan-1996  thorpej Add the "ahe" driver, autoconfiguration support for the aic7xxx-based
Adaptec 2[78]4x SCSI controllers, from Michael Graff <explorer@flame.org>.
Fixes PR #1594 from Noriyuki Soda <soda@sra.co.jp> in a different way.
 1.8 10-Oct-1995  mycroft Add specs for ahc driver.
 1.7 19-Aug-1995  cgd add 'fpa' for Matt Thomas's driver for DEC PCI FDDI boards. alphabetize.
 1.6 27-Jul-1995  mycroft Add needs-flags for pci_subr.c.
 1.5 18-Jun-1995  cgd make a comment reflect the way things should be done
 1.4 17-Jun-1995  cgd more appropriate name, as this only has PCI support subroutines.
 1.3 05-Jun-1995  cgd enable the de driver
 1.2 17-Apr-1995  cgd try to actually (gasp!) describe the drivers.
 1.1 17-Apr-1995  cgd config.new files description for PCI mi files.
 1.21.4.1 09-Mar-1997  is netinet/if_ether.h -> netinet/if_inarp.h
 1.25.2.4 14-Oct-1997  thorpej Split off NE2000 support from the ISA "ed" driver, and create a new "ne"
driver that deals with NE2000s and compatibles on ISA, PCI, and PCMCIA
busses.

This driver uses the generic DP8390 core chipset back-end.
 1.25.2.3 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.2 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.1 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.30.2.1 21-Oct-1997  mrg pull up from trunk: Correct ThunderLAN spelling
 1.39.2.6 02-Oct-1998  bouyer Sync with HEAD.
 1.39.2.5 11-Sep-1998  bouyer Sync with HEAD.
 1.39.2.4 13-Aug-1998  bouyer - sync with -current
- full support of CMD PCI0640 chips. This needs a special probe routine, as
this chip doesn't honnor the "PCI_COMMAND_IO_ENABLE" bit. sigh.
- do not map the native pci interrupts if we don't have a native channel.
some chips (e.g. PCI0640) have a valid interrupt value which gets
established, which may prevent the compat channel or some other ISA
device from working properly later.
- b* -> mem*
 1.39.2.3 27-Jul-1998  bouyer Sync with -current
 1.39.2.2 02-Jul-1998  bouyer Sync with HEAD.
 1.39.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.54.6.2 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.54.6.1 28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.54.4.3 02-Aug-1999  thorpej Update from trunk.
 1.54.4.2 01-Jul-1999  thorpej Sync w/ -current.
 1.54.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.54.2.4 14-Aug-2000  he Pull up revision 1.101 (via patch, requested by bouyer):
Change PCIIDE_CMD0646U_UDMA to PCIIDE_CMD0646U_ENABLEUDMA
for consistency with PCIIDE_AMD756_ENABLEDMA.
 1.54.2.3 17-Jan-2000  he Pull up revision 1.63 (requested by ad):
Add driver for DPT SmartCache and SmartRAID III or IV SCSI
adapters.
 1.54.2.2 20-Oct-1999  he Pull up revision 1.57 (requested by bouyer):
Back-port of the Realtek ethernet driver.
 1.54.2.1 05-Oct-1999  he Pull up revision 1.62 (via patch, requested by drochner):
Back-port of driver for Alteon Gigabit Ethernet driver, originally
from FreeBSD.
 1.63.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.65.4.1 15-Nov-1999  fvdl Sync with -current
 1.65.2.9 21-Apr-2001  bouyer Sync with HEAD
 1.65.2.8 27-Mar-2001  bouyer Sync with HEAD.
 1.65.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.65.2.6 11-Feb-2001  bouyer Sync with HEAD.
 1.65.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.65.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.65.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.65.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.65.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.94.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.96.2.12 24-Jan-2002  he Pull up revision 1.156 (requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.96.2.11 19-Jan-2002  he Pull up revision 1.142 (requested by he):
Add driver for Creative Labs SBLive! EMU10000 and (probably) PCI512.
Fixes PR#15260.
 1.96.2.10 25-Oct-2001  he Apply patch (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.96.2.9 06-May-2001  he Pull up revisions 1.117,1.120 (requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.96.2.8 06-May-2001  he Pull up revision 1.106 (requested by sommerfeld):
Add a driver for the NeoMagic 256 AC'97 chip.
 1.96.2.7 03-May-2001  he Pull up revisions 1.115-1.116 (requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.96.2.6 01-May-2001  he Pull up revision 1.127 (requested by minoura):
Add Yamaha YMF724/740/744/745-based sound driver and
its subordinates.
 1.96.2.5 03-Aug-2000  bouyer Pull up (approved by thorpej):
sys/dev/pci/pciide.c 1.82 -> 1.84
sys/dev/pci/pciide_cmd_reg.h 1.8 -> 1.9
sys/dev/pci/files.pci 1.100 -> 1.101
share/man/man4/pciide.4 1.23 -> 1.24

Add support for the CMD PCI646U. Linux claims that this driver is brocken
with UDMA, so enable Ultra-DMA only if "options PCIIDE_CMD0646U_ENABLEUDMA"
is set.
defopt PCIIDE_CMD0646U_ENABLEUDMA, PCIIDE_AMD756_ENABLEDMA,
PCIIDE_CMD064x_DISABLE
Fix a typo pointed out by John Hawkinson
Update documentation.
 1.96.2.4 30-Jul-2000  bouyer Pull up (requested by thorpej):
lm_pnpbios.c 1.2->1.3
files 1.374->1.375
nslm7x.c 1.3->1.4
nslm7xvar.h 1.2->1.3
lm_isa.c 1.2->1.3
files.pci 1.96->1.97
viaenv.c 1.2->1.3
sysmon.c 1.1
sysmonvar.h 1.1

Add a clearing-house pseudo-device for system monitoring devices
such as the LM78 and VT82C686A (and eventually ACPI). Multiple
sensor devices can be hooked registered with `sysmon', and eventually
sysmon will also handle hardware (and software) watchdog timers.

Convert the `lm' and `viaenv' drivers to the new interface.
 1.96.2.3 03-Jul-2000  thorpej Pull up rev. 1.99:
cmpci requires mulaw dependency.
 1.96.2.2 26-Jun-2000  soren Remove part of sysmon change mistakenly included in previous pull-up.
 1.96.2.1 25-Jun-2000  sommerfeld defopt TLP_MATCH_*. pullup approved by thorpej
 1.123.2.18 11-Nov-2002  nathanw Catch up to -current
 1.123.2.17 18-Oct-2002  nathanw Catch up to -current.
 1.123.2.16 17-Sep-2002  nathanw Catch up to -current.
 1.123.2.15 13-Aug-2002  nathanw Catch up to -current.
 1.123.2.14 01-Aug-2002  nathanw Catch up to -current.
 1.123.2.13 20-Jun-2002  nathanw Catch up to -current.
 1.123.2.12 17-Apr-2002  nathanw Catch up to -current.
 1.123.2.11 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.123.2.10 28-Feb-2002  nathanw Catch up to -current.
 1.123.2.9 11-Jan-2002  nathanw More catchup.
 1.123.2.8 11-Jan-2002  nathanw Catch up to newer -current.
 1.123.2.7 08-Jan-2002  nathanw Catch up to -current.
 1.123.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.123.2.5 22-Oct-2001  nathanw Catch up to -current.
 1.123.2.4 21-Sep-2001  nathanw Catch up to -current.
 1.123.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.123.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.123.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.132.2.9 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.132.2.8 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.132.2.7 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.132.2.6 16-Mar-2002  jdolecek Catch up with -current.
 1.132.2.5 11-Feb-2002  jdolecek Sync w/ -current.
 1.132.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.132.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.132.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.132.2.1 03-Aug-2001  lukem update to -current
 1.138.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.142.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.172.2.4 29-Aug-2002  gehenna catch up with -current.
 1.172.2.3 15-Jul-2002  gehenna catch up with -current.
 1.172.2.2 20-Jun-2002  gehenna catch up with -current.
 1.172.2.1 30-May-2002  gehenna Catch up with -current.
 1.173.2.4 11-Nov-2004  he Pull up revision 1.217 (via patch, requested by itohy in ticket #1741):
Add support for the Workbit NinjaSCSI-32 PCI/Cardbus
SCSI driver, njs(4).
 1.173.2.3 05-Oct-2003  tron Pull up revision 1.194 (requested by mrg in ticket #1486):
add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by
yours truly.
XXX: missing mcast filter support.
thanks cliff!
 1.173.2.2 28-Jan-2003  jmc Pullup revisions 1.174-1.175 (requested by fvdl in ticket #1126)
Pullup support for bge device. (Broadcom Gigabit Ethernet)
 1.173.2.1 07-Aug-2002  lukem Pull up revision 1.176 (requested by augustss in ticket #643):
Pull in tea5757.c for the mr driver. Fixes kern/17864.
 1.187.2.16 11-Dec-2005  christos Sync with head.
 1.187.2.15 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.187.2.14 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.187.2.13 15-Feb-2005  skrll Sync with HEAD.
 1.187.2.12 24-Jan-2005  skrll Sync with HEAD.
 1.187.2.11 17-Jan-2005  skrll Sync with HEAD.
 1.187.2.10 18-Dec-2004  skrll Sync with HEAD.
 1.187.2.9 29-Nov-2004  skrll Sync with HEAD.
 1.187.2.8 02-Nov-2004  skrll Sync with HEAD.
 1.187.2.7 19-Oct-2004  skrll Sync with HEAD
 1.187.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.187.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.187.2.4 03-Sep-2004  skrll Sync with HEAD
 1.187.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.187.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.187.2.1 03-Aug-2004  skrll Sync with HEAD
 1.210.2.3 30-Aug-2004  tron branches: 1.210.2.3.2;
Pull up revision 1.217 via patch (requested by itohy in ticket #800):
Workbit NinjaSCSI-32 PCI/CardBus SCSI driver (njs)
 1.210.2.2 14-Jul-2004  tron Pull up revision 1.214 (requested by bouyer in ticket #644):
Add geodeide(4), a driver for the AMD Geode CS5530A IDE controller.
Tested by Ian Zagorskih (ianzag at megasignal.com).
 1.210.2.1 21-Jun-2004  tron Pull up revision 1.211 (requested by toshii in ticket #517):
Add re(4) RealTek 8139C+/8169/8169S/8110S PCI ethernet adapter driver,
from FreeBSD.
I haven't tested this code very well, but it seems to work fairly well
for me.
 1.210.2.3.2.2 11-Apr-2006  riz Pull up following revision(s) (requested by he in ticket #10409):
sys/dev/ic/cissreg.h: revision 1.1
sys/dev/pci/ciss_pci.c: revision 1.1
sys/dev/ic/cissvar.h: revision 1.1
sys/dev/pci/files.pci: revision 1.245
sys/dev/ic/ciss.c: revision 1.1 via patch
Add a driver, ciss(4), for the HP/Compaq drivers using the newer
"Command Interface to SCSI-3 Support" command interface. Driver
ported from OpenBSD by Tonnerre Lombard -- thanks!
 1.210.2.3.2.1 02-Apr-2005  he Pull up revision 1.224 (via patch, requested by bouyer in ticket #1019):
Add pdcsata(4), a driver for the Promise SATA150 (aka PDC203xx)
series of controllers.
 1.228.2.1 29-Apr-2005  kent sync with -current
 1.229.2.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.229.2.1 12-Feb-2005  yamt sync with head.
 1.232.2.10 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1609):
sys/arch/i386/conf/INSTALL: revision 1.298
sys/arch/i386/conf/GENERIC: revision 1.802
sys/dev/pci/files.pci: revision 1.274
sys/arch/amd64/conf/GENERIC: revision 1.122
sys/dev/pci/mfi_pci.c: revision 1.1 via patch
distrib/sets/lists/man/mi: revision 1.958
sys/arch/amd64/conf/INSTALL: revision 1.61
sys/dev/ic/mfireg.h: revision 1.1
share/man/man4/Makefile: revision 1.416 via patch
sys/dev/ic/mfi.c: revision 1.1
sys/arch/i386/conf/XEN2_DOM0: revision 1.19
sys/dev/ic/mfivar.h: revision 1.1
sys/conf/files: revision 1.821
share/man/man4/mfi.4: revision 1.1
share/man/man4/mfi.4: revision 1.2
sys/dev/pci/pcidevs via patch
Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
Punctuation issues.
 1.232.2.9 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1608):
sys/arch/i386/conf/INSTALL: revision 1.299 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.20 via patch
sys/arch/i386/conf/GENERIC: revision 1.803 via patch
sys/dev/pci/files.pci: revision 1.275 via patch
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218 via patch
sys/arch/amd64/conf/GENERIC: revision 1.123 via patch
sys/dev/pci/if_bnx.c: revision 1.1 via patch
share/man/man4/bnx.4: revision 1.1-1.2 via patch
distrib/sets/lists/man/mi: revision 1.959 via patch
sys/arch/amd64/conf/INSTALL: revision 1.62 via patch
sys/dev/microcode/bnx/bnxfw.h: revision 1.1-1.2 via patch
sys/dev/pci/if_bnxreg.h: revision 1.1 via patch
share/man/man4/Makefile: revision 1.417 via patch
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112 via patch
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
Add a NetBSD RCS tag.
Nx -> Ox; remove trailing whitespace.
 1.232.2.8 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.232.2.7 04-May-2006  tron Pull up following revision(s) (requested by jonathan in ticket #1298):
share/man/man4/pciide.4: revision 1.60
share/man/man4/Makefile: revision 1.376 via patch
sys/dev/pci/svwsata.c: revision 1.1
sys/dev/pci/files.pci: revision 1.243
sys/arch/i386/conf/INSTALL: revision 1.281
sys/dev/pci/pcidevs: revision 1.771 via patch
sys/dev/pci/pciidevar.h: revision 1.33
sys/arch/i386/conf/XEN0: revision 1.34
sys/arch/i386/conf/GENERIC: revision 1.732
sys/dev/pci/pciide_svwsata_reg.h: revision 1.1
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.232.2.6 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
sys/dev/pci/files.pci: revision 1.244 via patch
add nfe.
 1.232.2.5 08-Apr-2006  tron Pull up following revision(s) (requested by he in ticket #1247):
sys/dev/ic/cissreg.h: revision 1.1
sys/dev/pci/ciss_pci.c: revision 1.1
sys/dev/ic/cissvar.h: revision 1.1
sys/dev/pci/files.pci: revision 1.245
sys/dev/ic/ciss.c: revision 1.1
Add a driver, ciss(4), for the HP/Compaq drivers using the newer
"Command Interface to SCSI-3 Support" command interface. Driver
ported from OpenBSD by Tonnerre Lombard -- thanks!
 1.232.2.4 20-Feb-2006  tron Pull up following revision(s) (requested by tls in ticket #1179):
sys/dev/pci/amdpm.c: revision 1.11
sys/dev/i2c/files.i2c: revision 1.7
sys/dev/i2c/adt7463.c: revision 1.1
sys/dev/pci/files.pci: revision 1.242 via patch
sys/dev/pci/amdpmvar.h: revision 1.1
sys/dev/i2c/adt7463reg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.192 via patch
sys/dev/pci/amdpm_smbus.c: revision 1.1
sys/dev/pci/amdpm_smbusreg.h: revision 1.1
Add support for i2c bus on AMD-8111 used on many Opteron server motherboards,
and ADT 7463c thermal and voltage monitor found on the Tyan S2881 and S2882-D
(and probably other boards as well). We do not currently support any kind
of detection of the i2c address of the thermal monitor; it appears to be
at 0x2D on the S2881 and 0x2E on the S2882-D (kernel config examples
forthcoming).
From PR kern/32463 submitted by Anil Gopinath, anil_public@yahoo.com.
 1.232.2.3 29-Dec-2005  riz Pull up following revision(s) (requested by kent in ticket #916):
sys/dev/pci/azalia.h: revision 1.1
sys/dev/pci/azalia_codec.c: revision 1.1
sys/dev/pci/azalia.c: revision 1.13
sys/dev/pci/files.pci: revision 1.239
split azalia.c into three files.
* azalia_codec.c: code for specific codecs
* azalia.c: other code
* azalia.h: common definitions
 1.232.2.2 13-Sep-2005  tron Pull up following revision(s) (requested by ragge in ticket #768):
sys/dev/pci/if_xge.c: revision 1.1 via patch
sys/dev/pci/if_xgereg.h: revision 1.1
sys/dev/pci/files.pci: revision 1.238
Device driver for the Neterion (S2io) Xframe-I 10Gbit ethernet card.
Still missing: VLAN + IPv6 checksum support.
 1.232.2.1 02-Jul-2005  tron Pull up revision 1.233 (requested by kent in ticket #494):
An audio driver for High Definition Audio.
The driver is highly experimental at this moment:
- limieted support for playback
- support for no mixer controls
- support for no recording
 1.235.2.8 11-Feb-2008  yamt sync with head.
 1.235.2.7 21-Jan-2008  yamt sync with head
 1.235.2.6 07-Dec-2007  yamt sync with head
 1.235.2.5 15-Nov-2007  yamt sync with head.
 1.235.2.4 03-Sep-2007  yamt sync with head.
 1.235.2.3 26-Feb-2007  yamt sync with head.
 1.235.2.2 30-Dec-2006  yamt sync with head.
 1.235.2.1 21-Jun-2006  yamt sync with head.
 1.241.6.3 07-Jun-2006  kardel Sync with head.
 1.241.6.2 01-Jun-2006  kardel Sync with head.
 1.241.6.1 22-Apr-2006  simonb Sync with head.
 1.241.4.1 09-Sep-2006  rpaulo sync with head
 1.241.2.1 01-Mar-2006  yamt sync with head.
 1.242.2.7 14-Sep-2006  yamt sync with head.
 1.242.2.6 03-Sep-2006  yamt sync with head.
 1.242.2.5 11-Aug-2006  yamt sync with head
 1.242.2.4 26-Jun-2006  yamt sync with head.
 1.242.2.3 24-May-2006  yamt sync with head.
 1.242.2.2 01-Apr-2006  yamt sync with head.
 1.242.2.1 13-Mar-2006  yamt sync with head.
 1.243.2.2 11-May-2006  elad sync with head
 1.243.2.1 19-Apr-2006  elad sync with head.
 1.244.2.3 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.244.2.2 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.244.2.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.253.2.1 19-Jun-2006  chap Sync with head.
 1.258.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.262.2.2 15-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #153):
sys/dev/pci/if_skreg.h: revision 1.8
sys/dev/pci/if_msk.c: revision 1.1
sys/dev/pci/files.pci: revision 1.268
sys/dev/pci/if_mskvar.h: revision 1.1
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:
- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.
Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.262.2.1 15-Aug-2006  ghen Pull up following revision(s) (requested by jmcneill in ticket #18):
sys/dev/pci/files.pci: revision 1.265
Add rasops16 attribute to unichromefb.
 1.267.2.3 01-Feb-2007  ad Sync with head.
 1.267.2.2 12-Jan-2007  ad Sync with head.
 1.267.2.1 18-Nov-2006  ad Sync with head.
 1.268.2.3 18-Dec-2006  yamt sync with head.
 1.268.2.2 10-Dec-2006  yamt sync with head.
 1.268.2.1 22-Oct-2006  yamt sync with head
 1.273.2.5 19-Apr-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1128):
sys/dev/pci/if_lii.c: revisions 1.1, 1.3 via patch
sys/arch/i386/conf/ALL: revision 1.161 via patch
share/man/man4/lii.4: revision 1.1 via patch
sys/dev/pci/files.pci: revision 1.303 via patch
sys/dev/DEVNAMES: revision 1.238 via patch
sys/arch/i386/conf/GENERIC: revision 1.885 via patch
distrib/sets/lists/man/mi: revisions 1.1062, 1.1063 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.43 via patch
share/man/man4/Makefile: revision 1.460 via patch
sys/arch/i386/conf/INSTALL: revision 1.323 via patch
sys/dev/pci/if_liireg.h: revision 1.1 via patch
Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.
 1.273.2.4 11-Jan-2008  xtraeme Pull up following revision(s) (requested by christos in ticket #1037):
sys/dev/pci/arcmsr.c: patch
sys/dev/pci/arcmsrvar.h: patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/files.pci: patch
sys/arch/i386/conf/GENERIC: patch
sys/arch/i386/conf/XEN2_DOM0: patch
sys/arch/i386/conf/INSTALL_LARGE: patch
sys/arch/amd64/conf/GENERIC: patch
sys/arch/amd64/conf/INSTALL: patch
share/man/man4/Makefile: patch
share/man/man4/arcmsr.4: patch
distrib/sets/lists/man/mi: patch

Add the Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.
 1.273.2.3 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.273.2.2 21-Dec-2006  tron branches: 1.273.2.2.2;
Pull up following revision(s) (requested by bouyer in ticket #287):
sys/arch/i386/conf/INSTALL: revision 1.299
sys/arch/i386/conf/XEN2_DOM0: revision 1.20
sys/arch/i386/conf/GENERIC: revision 1.803
sys/dev/pci/files.pci: revision 1.275
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218
sys/arch/amd64/conf/GENERIC: revision 1.123
sys/dev/pci/if_bnx.c: revision 1.1
share/man/man4/bnx.4: revision 1.1
distrib/sets/lists/man/mi: revision 1.959
sys/arch/amd64/conf/INSTALL: revision 1.62
sys/dev/microcode/bnx/bnxfw.h: revision 1.1
sys/arch/i386/conf/ALL: revision 1.76
sys/dev/pci/if_bnxreg.h: revision 1.1
share/man/man4/Makefile: revision 1.417
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.273.2.1 21-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #286):
sys/arch/i386/conf/INSTALL: revision 1.298
sys/arch/i386/conf/GENERIC: revision 1.802
sys/dev/pci/files.pci: revision 1.274
sys/arch/amd64/conf/GENERIC: revision 1.122
sys/dev/pci/mfi_pci.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.958
sys/arch/amd64/conf/INSTALL: revision 1.61
sys/arch/i386/conf/ALL: revision 1.75
sys/dev/ic/mfireg.h: revision 1.1
share/man/man4/Makefile: revision 1.416
sys/dev/ic/mfi.c: revision 1.1
sys/arch/i386/conf/XEN2_DOM0: revision 1.19
sys/dev/ic/mfivar.h: revision 1.1
sys/conf/files: revision 1.821
share/man/man4/mfi.4: revision 1.1
Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
 1.273.2.2.2.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.273.2.2.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.277.10.1 29-Mar-2007  reinoud Pullup to -current
 1.277.8.1 11-Jul-2007  mjf Sync with head.
 1.277.6.4 20-Aug-2007  ad Sync with HEAD.
 1.277.6.3 15-Jul-2007  ad Sync with head.
 1.277.6.2 27-May-2007  ad Sync with head.
 1.277.6.1 10-Apr-2007  ad Sync with head.
 1.277.2.4 17-May-2007  yamt sync with head.
 1.277.2.3 07-May-2007  yamt sync with head.
 1.277.2.2 15-Apr-2007  yamt sync with head.
 1.277.2.1 24-Mar-2007  yamt sync with head.
 1.294.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.295.14.2 28-Jul-2007  kiyohara Add support for Intel ICH SMBus controller.
 1.295.14.1 28-Jul-2007  kiyohara file files.pci was added on branch matt-mips64 on 2007-07-28 10:51:58 +0000
 1.295.12.4 18-Feb-2008  mjf Sync with HEAD.
 1.295.12.3 27-Dec-2007  mjf Sync with HEAD.
 1.295.12.2 08-Dec-2007  mjf Sync with HEAD.
 1.295.12.1 19-Nov-2007  mjf Sync with HEAD.
 1.295.10.1 13-Nov-2007  bouyer Sync with HEAD
 1.295.6.3 23-Mar-2008  matt sync with HEAD
 1.295.6.2 09-Jan-2008  matt sync with HEAD
 1.295.6.1 08-Nov-2007  matt sync with -HEAD
 1.295.4.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.295.4.1 11-Nov-2007  joerg Sync with HEAD.
 1.296.2.2 26-Dec-2007  ad Sync with head.
 1.296.2.1 08-Dec-2007  ad Sync with head.
 1.298.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.298.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.302.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.302.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.302.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.302.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.303.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.303.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.303.4.7 11-Aug-2010  yamt sync with head.
 1.303.4.6 11-Mar-2010  yamt sync with head
 1.303.4.5 16-Sep-2009  yamt sync with head
 1.303.4.4 19-Aug-2009  yamt sync with head.
 1.303.4.3 18-Jul-2009  yamt sync with head.
 1.303.4.2 20-Jun-2009  yamt sync with head
 1.303.4.1 04-May-2009  yamt sync with head.
 1.303.2.1 04-Jun-2008  yamt sync with head
 1.304.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.304.4.1 19-Oct-2008  haad Sync with HEAD.
 1.304.2.1 28-Jul-2008  simonb Sync with head.
 1.306.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.306.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.308.8.2 05-Nov-2013  matt Pull down xhci support from HEAD
 1.308.8.1 21-Apr-2010  matt sync to netbsd-5
 1.308.2.7 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.308.2.6 28-Oct-2009  bouyer branches: 1.308.2.6.4;
Pull up the following revisions, requested by sborrill in ticket #1114:
share/man/man4/sdhc.4 1.1-1.2
sys/dev/pci/sdhc_pci.c 1.1-1.3
distrib/sets/lists/man/mi patch
share/man/man4/Makefile patch
sys/arch/amd64/conf/GENERIC patch
sys/arch/i386/conf/ALL patch
sys/arch/i386/conf/GENERIC patch
sys/dev/pci/files.pci patch
sys/dev/pci/pcidevs patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add sdhc(4), a driver for SD controllers following the SD Host
Controller Standard Simplified Specification.
 1.308.2.5 28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/conf/files: revision 1.956 via patch
sys/dev/pci/files.pci: revision 1.321
As, siisata attaches not just at pci, but for a while now, also at cardbus,
move siisata core driver config to the propper config file.
 1.308.2.4 28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.3
sys/dev/ic/siisatareg.h: revision 1.3
sys/dev/ic/siisatavar.h: revision 1.3
sys/dev/pci/files.pci: revision 1.315
sys/dev/pci/siisata_pci.c: revision 1.3
A few changes for siisata(4):
- Support detachment. From KIYOHARA Takashi.
- Add PCI detachment functionality (albeit not very interesting when
the bus can not yet be rescanned).
- Rework interrupt handlers to reduce near-duplicate code.
Borrowed from ahcisata(4).
- Attempt to make polled I/O work. Untested.
- Fix formatting of some messages.
- For always-polled commands, disable interrupt
at slot level rather than port level.
- Instead of busy-waiting indefinitely for completion of some commands
move on after 31 seconds. Use cv_timedwait(9) instead of DELAY(9).
- Use abstracted SATA FIS code.
- Enable use of disks that don't respond with the standard signature.
 1.308.2.3 26-Sep-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #946):
distrib/sets/lists/man/mi: revision 1.1155
doc/CHANGES: revision 1.1285
etc/MAKEDEV.tmpl: revision 1.128
share/man/man4/Makefile: revision 1.498 via patch
share/man/man4/hdaudio.4: revision 1.1-1.3
share/man/man8/MAKEDEV.8: revision 1.36
sys/arch/amd64/conf/GENERIC: revision 1.250-1.251
sys/arch/amd64/conf/XEN3_DOM0: revision 1.44-1.45
sys/arch/i386/conf/ALL: revision 1.206-1.207
sys/arch/i386/conf/GENERIC: revision 1.942-1.943
sys/arch/i386/conf/XEN3_DOM0: patch
sys/conf/majors: revision 1.47 via patch
sys/dev/pci/hdaudio/files.hdaudio: revision 1.1-1.2
sys/dev/pci/hdaudio/hdaudio.c: revision 1.1-1.4
sys/dev/pci/hdaudio/hdaudio_afg.c: revisions 1.1-1.14
sys/dev/pci/hdaudio/hdaudio_mixer.h: revisions 1.1-1.3
sys/dev/pci/hdaudio/hdaudio_pci.c: revisions 1.1-1.2
sys/dev/pci/hdaudio/hdaudioio.h: revisions 1.1-1.2
sys/dev/pci/hdaudio/hdaudioreg.h: revisions 1.1-1.3
sys/dev/pci/hdaudio/hdaudiovar.h: revisions 1.1-1.4
sys/dev/pci/files.pci: revisions 1.319 and 1.322 via patch
hdaudio(4) is a standards-compliant driver for High Definition Audio.
It will replace azalia(4) after testing.
To use, comment out azalia in your kernel configuration and uncomment the
hdaudio and hdafg lines so it reads:
hdaudio* at pci? dev ? function ?
hdafg* at hdaudiobus?
You should also:
cd /dev
sh MAKEDEV audio
 1.308.2.2 03-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #735):
sys/dev/pci/if_age.c: revisions 1.1-1.28
sys/dev/pci/if_agereg.h: revisions 1.1-1.2
sys/dev/pci/if_ale.c: revisions 1.1-1.3
sys/dev/pci/if_alereg.h: revisions 1.1-1.2
sys/dev/pci/files.pci: revisions 1.310-1.313
sys/dev/mii/atphy.c: revisions 1.1-1.5
sys/dev/mii/files.mii: revision 1.42
share/man/man4/age.4: revisions 1.1-1.3
share/man/man4/ale.4: revisions 1.1-1.2
share/man/man4/atphy.4: revisions 1.1-1.2
share/man/man4/Makefile: revisions 1.486, 1.489
distrib/sets/lists/man/mi: revisions 1.1118, 1.1132
sys/arch/i386/conf/GENERIC: revisions 1.928, 1.933
sys/arch/i386/conf/XEN2_DOM0: revisions 1.57, 1.60
sys/arch/amd64/conf/GENERIC: revisions 1.239, 1.241
sys/arch/amd64/conf/XEN3_DOM0: revisions 1.38, 1.42
Add the age(4) and ale(4) drivers for Attansic L1 and Atheros
AR8121/AR8113/AR8114 devices respectively.
 1.308.2.1 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #260):
sys/dev/pci/files.pci: revision 1.309
sys/dev/pci/gcscaudio.c: revision 1.1
sys/dev/pci/gcscaudioreg.h: revision 1.1
PR# port-i386/40284: add AMD Geode CS5536 audio driver; written by
SHIMIZU Ryo <ryo@nerv.org>
 1.308.2.6.4.1 07-Jan-2011  matt arcmsr needs sysmon_envsys
 1.312.2.2 23-Jul-2009  jym Sync with HEAD.
 1.312.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.324.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.324.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.324.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.326.2.3 21-Apr-2011  rmind sync with head
 1.326.2.2 05-Mar-2011  rmind sync with head
 1.326.2.1 30-May-2010  rmind sync with head
 1.335.4.3 05-Mar-2011  bouyer Sync with HEAD
 1.335.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.335.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.335.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.350.6.5 29-Apr-2012  mrg sync to latest -current.
 1.350.6.4 06-Mar-2012  mrg sync to -current
 1.350.6.3 06-Mar-2012  mrg sync to -current
 1.350.6.2 04-Mar-2012  mrg sync to latest -current.
 1.350.6.1 18-Feb-2012  mrg merge to -current.
 1.350.2.5 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.350.2.4 23-Jan-2013  yamt sync with head
 1.350.2.3 30-Oct-2012  yamt sync with head
 1.350.2.2 23-May-2012  yamt sync with head.
 1.350.2.1 17-Apr-2012  yamt sync with head
 1.354.2.1 23-Apr-2012  riz Pull up following revision(s) (requested by bouyer in ticket #193):
sys/arch/i386/conf/GENERIC: revision 1.1072
sys/dev/pci/mpii.c: revision 1.1
sys/arch/i386/conf/XEN3_DOM0: revision 1.66
sys/dev/pci/files.pci: revision 1.357
share/man/man4/Makefile: revision 1.584
distrib/sets/lists/man/mi: revision 1.1387
share/man/man4/mpii.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.354
sys/arch/amd64/conf/XEN3_DOM0: revision 1.83
sys/arch/i386/conf/ALL: revision 1.337
Add mpii(4), a driver for LSI Logic Fusion-MPT Message Passing Interface II
SAS controllers. Ported from OpenBSD.
 1.360.2.5 03-Dec-2017  jdolecek fix back some more incorrect sync
 1.360.2.4 03-Dec-2017  jdolecek update from HEAD
 1.360.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.360.2.2 23-Jun-2013  tls resync from head
 1.360.2.1 25-Feb-2013  tls resync with head
 1.364.6.3 04-Mar-2014  riastradh Rework drm2 configuration and modularization.

- Split drm2.kmod into drmkms_linux, drmkms, drmkms_pci.
- Split up drmkms-related files.* similarly.
- Make drm_agp_* routines hooks that the drmkms_pci module installs.
- Reuse drm device major 180 for (old) drm and drmkms.

Now old drm and new drmkms can coexist happily in the same tree, with
or without PCI, and require no changes to userland.
 1.364.6.2 29-Jan-2014  riastradh First draft of in-kernel drm2 attachment.

The drm2 `drm' device is now called `drmkms' (likewise `i915drmkms',
&c.) so that it can coexist with the old drm code to reduce diffs
from HEAD. (Can't call a device `drm2'.)
 1.364.6.1 23-Jul-2013  riastradh sync with HEAD
 1.364.4.2 18-May-2014  rmind sync with head
 1.364.4.1 28-Aug-2013  rmind sync with head
 1.371.4.5 25-Jul-2017  snj Apply patch (requested by nonaka in ticket #1413):
iwm(4): Add a driver for Intel Wireless 726x, 316x, 826x and 416x series.
Ported from OpenBSD.
 1.371.4.4 23-Dec-2016  snj Pull up following revision(s) (requested by bsiegert in ticket #1338):
sys/arch/amd64/conf/GENERIC: revision 1.418
sys/dev/pci/files.pci: revision 1.379
sys/dev/pci/vioscsi.c: revisions 1.1-1.8
sys/dev/pci/vioscsireg.h: revision 1.1
sys/dev/pci/virtioreg.h: revisions 1.5, 1.6
add the common flag bits
--
Add vioscsi, compile tested only (toxic)
--
this is working now, remove debugging.
--
add vioscsi
--
kill some more debugging.
--
Fake mode sense data for illegal targets. qemu reports 256 targets...
--
fix the status return.
--
Use SCSIPI_CHAN_NOSETTLE.
--
vioscsi_req_get()/virtio_enqueue_prep() failing is actually perfectly
normal - observed failures included 10, 27, 61 in-flight commands,
so probably depends on particular command mix; return with
XS_RESOURCE_SHORTAGE rather then panic
do vioscsi_req_put() when initial bus_dmamap_load() fails, as suggested
by the XXX; the vq_done hook is called by virtio, but in that case we
never get to commit the request to it
--
react on ADAPTER_REQ_SET_XFER_MODE so that we set tagged queuing
pass tag type and set id
 1.371.4.3 19-Apr-2015  riz branches: 1.371.4.3.4;
Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.371.4.2 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.371.4.1 02-Nov-2014  martin Pull up following revision(s) (requested by tls in ticket #174):
doc/CHANGES: revision 1.2005
sys/dev/pci/viornd.c: revision 1.1
sys/dev/pci/files.pci: revision 1.372
sys/arch/amd64/conf/GENERIC: revision 1.401
share/man/man4/viornd.4: revision 1.1
Add viornd(4), a driver for the VirtIO entropy source available on
QEMU, KVM, and Google Compute Engine. From OpenBSD.
 1.371.4.3.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.372.2.7 28-Aug-2017  skrll Sync with HEAD
 1.372.2.6 05-Dec-2016  skrll Sync with HEAD
 1.372.2.5 29-May-2016  skrll Sync with HEAD
 1.372.2.4 19-Mar-2016  skrll Sync with HEAD
 1.372.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.372.2.2 22-Sep-2015  skrll Sync with HEAD
 1.372.2.1 06-Apr-2015  skrll Sync with HEAD
 1.381.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.381.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.381.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.385.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.388.4.8 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.388.4.7 23-Oct-2021  martin Pull up the following, requested by msaitoh in ticket #1701:

share/man/man4/wm.4 1.42
sys/dev/pci/files.pci 1.434
sys/dev/pci/if_wm.c 1.686-1.687,1.692-1.693,
1.697,1.699-1.703,
1.706-1.715 via patch
sys/dev/pci/if_wmvar.h 1.46

- Add missing drain for pcq in wm_stop_locked().
- Add support for I219V 15-19 and I219LM 16-19.
- Fix Tx stall.
- Use wm_flush_desc_rings() workaround more on I219.
- Change DMA physical address in wm_flush_desc_rings() to match other
OSes.
- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Add new sysctl hw.wmN.debug_flags. This sysctl can be used if
WM_DEBUG is set.
- Add some sysctl values for debugging TX/RX queues.
- WM_EVENT_COUNTER is enabled by default on 64 bit architectures.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxq->rxq_ptr updating.
- Stop legacy interrupts before calling softint.
- Disable printf()s in wm_flush_desc_rings() because the code is
verified.
- Print I219's version number.
- Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.
- Fix return value of interrupt handler.
- Only print an error about missing I/O BARs for chips that need it.
- Do not return a void value from a void function.
- Add new flag named WM_F_CRC_STRIP and use it. No functional change.
- Whitespace fixes. Fix comments. No functional change.
 1.388.4.6 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.388.4.5 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.388.4.4 07-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1129):

sys/arch/amd64/conf/XEN3_DOM0: revision 1.159
sys/arch/amd64/conf/GENERIC: revision 1.508
sys/arch/i386/conf/ALL: revision 1.458
sys/dev/ic/mfi.c: revision 1.60
sys/dev/pci/mpiireg.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1628
sys/dev/pci/mfii.c: revision 1.1,1.2 (adapted)
sys/arch/i386/conf/GENERIC: revision 1.1194
sys/dev/pci/mpii.c: revision 1.13
sys/dev/ic/mfireg.h: revision 1.9
share/man/man4/mfii.4: revision 1.1
share/man/man4/Makefile: revision 1.673 (patch)
sys/dev/pci/files.pci: revision 1.410
share/man/man4/mfii.4: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.108
sys/arch/i386/conf/XEN3PAE_DOM0: revision 1.8 (patch, in XEN3_DOM0)

Add some definitions from OpenBSD, needed by the upcoming mfii driver.
No functionnal change.

-

Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.

-

Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.

Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.

Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.

-

Add my name in copyright list

-

add a man page for the new mpii, mostly from OpenBSD.

-

Sort SEE ALSO. Fix date. Whitespace fixes.
 1.388.4.3 31-Oct-2018  martin Add bwfm config glue, requested by maya in ticket #1072.
 1.388.4.2 23-Sep-2018  martin Pull up following revision(s) (requested by nakayama in ticket #1035):

sys/dev/pci/files.pci: revision 1.403

ixg and ixv depend on mii and mii_phy.
 1.388.4.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.394.2.7 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.394.2.6 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.394.2.5 30-Sep-2018  pgoyette Ssync with HEAD
 1.394.2.4 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.394.2.3 28-Jul-2018  pgoyette Sync with HEAD
 1.394.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.394.2.1 21-May-2018  pgoyette Sync with HEAD
 1.397.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.397.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.397.2.1 10-Jun-2019  christos Sync with HEAD
 1.400.2.1 24-Sep-2018  jdolecek partial HEAD sync - ISDN device removal
 1.412.2.1 05-May-2019  isaki Remove obsoleted au{,rate,vol}conv and mulaw attributes.
audio provides the equivalent of them inseparably.
 1.413.2.6 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.413.2.5 21-Oct-2021  martin Pull up the following, requested by msaitoh in ticket #1363:

share/man/man4/wm.4 1.42
sys/dev/pci/files.pci 1.434
sys/dev/pci/if_wm.c 1.690,1.692-1.693,1.697-1.704,
1.706-1.715 via patch

- Add missing drain for pcq in wm_stop_locked().
- Add support for I219V 15-19 and I219LM 16-19.
- Fix Tx stall.
- Use wm_flush_desc_rings() workaround more on I219.
- Change DMA physical address in wm_flush_desc_rings() to match other
OSes.
- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Add new sysctl hw.wmN.debug_flags. This sysctl can be used if
WM_DEBUG is set.
- Add some sysctl values for debugging TX/RX queues.
- Use atomic_{load,store}_relaxed for evcnt 64 bit counter.
- WM_EVENT_COUNTER is enabled by default on 64 bit architectures.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxq->rxq_ptr updating.
- Stop legacy interrupts before calling softint.
- Disable printf()s in wm_flush_desc_rings() because the code is
verified.
- Print I219's version number.
- Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.
- Fix return value of interrupt handler.
- Only print an error about missing I/O BARs for chips that need it.
- Do not return a void value from a void function.
- Fix comment.
- Whitespace fixes. No functional change.
 1.413.2.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.413.2.3 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.413.2.2 07-Jul-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #980):

sys/dev/pci/if_aq.c: revision 1.4
sys/dev/pci/if_aq.c: revision 1.5
sys/arch/amd64/conf/GENERIC: revision 1.553
sys/dev/pci/files.pci: revision 1.419
sys/arch/amd64/conf/XEN3_DOM0: revision 1.170
sys/dev/pci/if_aq.c: revision 1.9
share/man/man4/Makefile: revision 1.693
sys/dev/pci/pcidevs: revision 1.1411
share/man/man4/aq.4: revision 1.1
share/man/man4/aq.4: revision 1.3
sys/arch/i386/conf/ALL: revision 1.479
share/man/man4/aq.4: revision 1.4
sys/dev/pci/if_aq.c: revision 1.10
sys/dev/pci/files.pci: revision 1.421
sys/dev/pci/if_aq.c: revision 1.11
sys/dev/pci/if_aq.c: revision 1.12
sys/dev/pci/if_aq.c: revision 1.13
sys/dev/pci/if_aq.c: revision 1.14
sys/dev/pci/if_aq.c: revision 1.15
sys/dev/pci/if_aq.c: revision 1.16
sys/dev/pci/pcidevs: revision 1.1408
sys/arch/amd64/conf/ALL: revision 1.135
sys/net/ethertypes.h: revision 1.19
sys/arch/i386/conf/GENERIC: revision 1.1218
distrib/sets/lists/man/mi: revision 1.1668
sys/dev/pci/if_aq.c: revision 1.1
sys/dev/pci/if_aq.c: revision 1.2
sys/dev/pci/pcidevs: revision 1.1395
sys/dev/pci/if_aq.c: revision 1.3
sys/arch/evbarm/conf/GENERIC64: revision 1.125

Add the ETHERTYPE_QINQ for 802.1ad VLAN stacking

add Aquantia AQC 10G network adapters
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.

add aq(4)

Add Aquantia AQC100, AQC100S and D100.

add support VLAN HW filter

set/clear IFF_OACTIVE flag only on txring 0

make counters per queue

support internal PHY temperature sensor

Found by kUBSan:
- Use unsigned to avoid undefined behavior in aq_hw_init().
- Cast to unsigned to avoid undefined behavior in aq_set_mac_addr().

fix descriptions of register map in comment

return the ifmedia active status correctly even while the link is not up after attach.
pointed out by msaitoh@. thanks.

On FIBRE devices, there are times when linkstat interrupt doesn't occur?
reported from Andrius V. thanks.
- use polling instead of linkstat interrupt when FIBRE
- add AQ_FORCE_POLL_LINKSTAT options (not by default)

sort product table, and tabify

add support AQC100S and D100.
not tested, but they are probably the same as the AQC100.
 1.413.2.1 23-Sep-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #230):

sys/dev/pci/files.pci: revision 1.415
distrib/sets/lists/man/mi: revision 1.1655
sys/dev/pci/if_mcx.c: revision 1.1
share/man/man4/Makefile: revision 1.683
share/man/man4/mcx.4: revision 1.1
sys/arch/evbarm/conf/GENERIC64: revision 1.107
sys/dev/pci/files.pci: revision 1.414

Add support for Mellanox 5th generation ethernet devices. This driver
supports the ConnectX-4 Lx EN, ConnectX-4 EN, ConnectX-5 EN, and
ConnectX-6 EN adapters.

Driver ported from OpenBSD.

add mcx attachment.

Correct mcx comment, drop mii dependency
 1.419.2.3 29-Feb-2020  ad Sync with head.
 1.419.2.2 25-Jan-2020  ad Sync with head.
 1.419.2.1 17-Jan-2020  ad Sync with head.
 1.432.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.436.4.1 13-May-2021  thorpej Sync with HEAD.
 1.445.2.4 08-Aug-2025  martin Pull up following revision(s) (requested by skrll in ticket #1148):

sys/arch/evbarm/conf/GENERIC64: revision 1.227
sys/dev/pci/files.pci: revision 1.451
sys/dev/pci/pvscsi.c: revision 1.1
sys/dev/pci/pvscsi.c: revision 1.2
sys/dev/pci/pvscsi.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.617

Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.

Add the barrier that a comment describes.
 1.445.2.3 03-Nov-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #446):

sys/dev/pci/if_eqos_pci.c: revision 1.3
sys/arch/i386/conf/GENERIC: revision 1.1251
sys/arch/i386/conf/GENERIC: revision 1.1252
sys/arch/amd64/conf/GENERIC: revision 1.607
sys/arch/amd64/conf/GENERIC: revision 1.608
sys/dev/ic/dwc_eqos.c: revision 1.20
sys/dev/ic/dwc_eqos.c: revision 1.21
share/man/man4/eqos.4: revision 1.2
sys/dev/ic/dwc_eqos.c: revision 1.22
sys/dev/ic/dwc_eqos_reg.h: revision 1.7
sys/dev/ic/dwc_eqos.c: revision 1.23
sys/dev/ic/dwc_eqos_reg.h: revision 1.8
sys/dev/ic/dwc_eqos.c: revision 1.24
sys/dev/ic/dwc_eqos.c: revision 1.25
sys/dev/ic/dwc_eqos.c: revision 1.26
sys/dev/ic/dwc_eqos.c: revision 1.27
sys/dev/ic/dwc_eqos_var.h: revision 1.5
sys/dev/ic/dwc_eqos.c: revision 1.28
sys/dev/ic/dwc_eqos_var.h: revision 1.6
sys/dev/ic/dwc_eqos.c: revision 1.29
sys/dev/ic/dwc_eqos.c: revision 1.18
sys/dev/ic/dwc_eqos.c: revision 1.19
sys/dev/pci/files.pci: revision 1.448
sys/dev/pci/if_eqos_pci.c: revision 1.1
sys/dev/pci/if_eqos_pci.c: revision 1.2

eqos(4): Fix definition of GMAC_MAC_HW_FEATURE1_RXFIFOSIZE.

eqos(4): Fix a bug that the MAC address is swapped.
Don't swap the MAC address in eqos_get_eaddr(). Other OSes except FreeBSD
(which was based on NetBSD's) don't swap it. With this change, my own
OnLogic Helix 330's MAC address becomes correct. The OUI is 84:8b:cd:4d.
It's owned by Logic Supply and they were acquired by OnLogic.

On Quartz64 with UEFI, the MAC address is wrongly set and the multicast
bit might be set. To do workaround, clear the bit if it's set.

eqos(4): Add missing clock range.

eqos(4): Accept if snpsver == 0x52. Tested with Intel Elkhart Lake.

TODO:
Multiqueue support.
Add watchdog timer.
Add detach function.

eqos(4): Add initial support for Intel Elkhart Lake internal Ethernet devices.
- Only tested on PSE SGMII 1G Ethernet MAC with MaxLinear GPY115.
- I don't know why dmat64 doesn't work. eqos_attach() have a special
code if EQOS_HW_FEATURE_ADDR64_32BIT(sc) is true, but it seems it doesn't
work.
- TODO:
Multiqueue support.
Detach support.

eqos(4): Fix compile error for arch that sizeof(bus_size_t) == 4 (i386).
Trailing whitespace

eqos(4): Disable eqos(4) by default because it's not stable on x86.

eqos(4): KNF. No functional change.

eqos(4): Add and modify some DPRINTF()s.

eqos(4): Add sysctls for debugging.

eqos(4): Use EQOS_TXLOCK() more to be stable.
Fix a bug that sc_tx.{cur,next,queued} become inconsitent.
Use txlock when accessing TX data.

eqos(4): Set TX/RX DMA burst length to improve performance.

eqos(4): Set flow control correctly.

eqos_pci: Limit to 32bit DMA only for PSE devices.

eqos(4): Fix typo in comment.
 1.445.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.445.2.1 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #282):

sys/dev/pci/ichsmb.c: revision 1.82
sys/arch/amd64/conf/GENERIC: revision 1.602
sys/arch/x86/pci/tco.c: revision 1.10
sys/arch/x86/pci/tco.h: revision 1.5
sys/arch/x86/pci/ichlpcib.c: revision 1.59
sys/dev/ic/i82801lpcreg.h: revision 1.17
sys/arch/x86/pci/files.pci: revision 1.27
sys/dev/pci/files.pci: revision 1.446

ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.
Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.448.6.1 02-Aug-2025  perseant Sync with HEAD
 1.450.2.1 08-Aug-2025  martin Pull up following revision(s) (requested by skrll in ticket #6):

sys/arch/evbarm/conf/GENERIC64: revision 1.227
sys/dev/pci/files.pci: revision 1.451
sys/dev/pci/pvscsi.c: revision 1.1
sys/dev/pci/pvscsi.c: revision 1.2
sys/dev/pci/pvscsi.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.617

Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.

Add the barrier that a comment describes.
 1.3 26-Jul-2025  martin PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.2 28-Oct-2019  ozaki-r branches: 1.2.32;
Implement a front-end driver of virtio-9p called vio9p

In conjunction with mount_9p, it enables a NetBSD system running as a VM guest
to mount an exported filesystem by the host via virtio-9p. It exports a 9p
end-point of virtio-9p via a character device file for mount_9p.

Reviewed by yamaguchi@
 1.1 02-Aug-2017  cherry branches: 1.1.2; 1.1.4; 1.1.8;
Reorg the virtio(4) config(9) code to be explicitly pci specific.

We'll later use this for a non-pci virtio(4) usecase.

ok martin
 1.1.8.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.2 03-Dec-2017  jdolecek update from HEAD
 1.1.4.1 02-Aug-2017  jdolecek file files.virtio was added on branch tls-maxphys on 2017-12-03 11:37:07 +0000
 1.1.2.2 28-Aug-2017  skrll Sync with HEAD
 1.1.2.1 02-Aug-2017  skrll file files.virtio was added on branch nick-nhusb on 2017-08-28 17:52:05 +0000
 1.2.32.1 02-Aug-2025  perseant Sync with HEAD
 1.50 08-Jan-2024  chs mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.49 07-Aug-2021  thorpej branches: 1.49.6;
Merge thorpej-cfargs2.
 1.48 24-Apr-2021  thorpej branches: 1.48.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.47 08-Jun-2019  isaki branches: 1.47.12;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.46 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.45 16-Mar-2019  isaki branches: 1.45.2;
Use C99 style struct initializer to audio_hw_if.
 1.44 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.43 01-Jun-2017  chs branches: 1.43.8; 1.43.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.42 29-Mar-2014  christos branches: 1.42.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.41 27-Oct-2012  chs branches: 1.41.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.40 24-Nov-2011  mrg branches: 1.40.8;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.39 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.38 13-Nov-2010  uebayasi branches: 1.38.8; 1.38.10;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.37 26-Nov-2009  njoly branches: 1.37.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.36 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.35 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.34 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.33 28-Apr-2008  martin branches: 1.33.12; 1.33.14;
Remove clause 3 and 4 from TNF licenses
 1.32 10-Apr-2008  cegger branches: 1.32.2; 1.32.4;
use aprint_*_dev and device_xname
 1.31 01-Apr-2008  xtraeme Fix fallout from device_t/softc split to mpu(4):
always pass the mpu_softc to mpu_intr(). Found by Takeshi Nakayama.
 1.30 19-Oct-2007  ad branches: 1.30.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.29 04-Mar-2007  christos branches: 1.29.2; 1.29.14; 1.29.16; 1.29.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 16-Nov-2006  christos branches: 1.28.4; 1.28.6;
__unused removal on arguments; approved by core.
 1.27 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.26 30-Aug-2006  christos branches: 1.26.2; 1.26.4;
static goes first
 1.25 11-Dec-2005  christos branches: 1.25.4; 1.25.8;
merge ktrace-lwp.
 1.24 28-Jun-2005  thorpej branches: 1.24.2;
Use ANSI function decls and static.
 1.23 15-Jan-2005  kent ansify and KNF
 1.22 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.21 09-Nov-2004  kent branches: 1.21.2;
remove mixer setting code in *_attach() because ac97_attach() does it.
 1.20 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.19 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.18 03-May-2003  wiz branches: 1.18.2; 1.18.4;
DMA, not dma nor Dma.
 1.17 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.16 31-Jan-2003  thorpej Use aprint_*().
 1.15 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.14 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.13 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.12 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.11 13-Nov-2001  lukem add RCSID
 1.10 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.9 28-Dec-2000  sommerfeld branches: 1.9.2; 1.9.4; 1.9.6;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.8 07-Dec-2000  abs Wrap call to mpu_intr in NMPU - nowbuildswithout 'mpu at fms' in config
 1.7 14-Nov-2000  thorpej branches: 1.7.2;
NBPG -> PAGE_SIZE
 1.6 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.5 15-May-2000  thorpej branches: 1.5.4;
ac97.h -> ac97var.h
 1.4 08-Apr-2000  tsarna Fix fms_free like auvia_free
 1.3 02-Nov-1999  augustss branches: 1.3.4; 1.3.6;
Shorten some delay()s. From WITEK Wnuk <witek@atari.org>
 1.2 01-Nov-1999  augustss Fold some long lines and make it compile with the new auconv functions.
 1.1 01-Nov-1999  augustss Add FM801 audio device driver. From Witold J. Wnuk ww181302@zodiac.mimuw.edu.pl
Closes PR kern/8729.
 1.3.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.4.2 15-Nov-1999  fvdl Sync with -current
 1.3.4.1 02-Nov-1999  fvdl file fms.c was added on branch fvdl-softdep on 1999-11-15 00:41:00 +0000
 1.5.4.2 13-Dec-2000  he Pull up revision 1.8 (requested by abs):
Make this build without ``mpu at fms''.
 1.5.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.7.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.4 08-Dec-2000  bouyer Sync with HEAD.
 1.7.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.7.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 14-Nov-2000  bouyer file fms.c was added on branch thorpej_scsipi on 2000-11-20 11:42:19 +0000
 1.9.6.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.9.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.9.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.9.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.18.4.1 22-Sep-2004  jmc Pullup rev 1.19 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.18.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.18.2.3 14-Nov-2004  skrll Sync with HEAD.
 1.18.2.2 02-Nov-2004  skrll Sync with HEAD.
 1.18.2.1 24-Sep-2004  skrll Sync with HEAD.
 1.21.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.21.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.24.2.3 27-Oct-2007  yamt sync with head.
 1.24.2.2 03-Sep-2007  yamt sync with head.
 1.24.2.1 30-Dec-2006  yamt sync with head.
 1.25.8.1 03-Sep-2006  yamt sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.4.2 10-Dec-2006  yamt sync with head.
 1.26.4.1 22-Oct-2006  yamt sync with head
 1.26.2.1 18-Nov-2006  ad Sync with head.
 1.28.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.28.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.29.16.1 06-Nov-2007  matt sync with HEAD
 1.29.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.29.2.1 23-Oct-2007  ad Sync with head.
 1.30.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.30.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.4.3 11-Mar-2010  yamt sync with head
 1.32.4.2 16-May-2009  yamt sync with head
 1.32.4.1 16-May-2008  yamt sync with head.
 1.32.2.1 18-May-2008  yamt sync with head.
 1.33.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.37.4.1 05-Mar-2011  rmind sync with head
 1.38.10.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.38.10.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.38.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.8.2 30-Oct-2012  yamt sync with head
 1.38.8.1 17-Apr-2012  yamt sync with head
 1.40.8.3 03-Dec-2017  jdolecek update from HEAD
 1.40.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.41.2.1 18-May-2014  rmind sync with head
 1.42.6.1 28-Aug-2017  skrll Sync with HEAD
 1.43.10.1 10-Jun-2019  christos Sync with HEAD
 1.43.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.45.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.45.2.2 28-Apr-2019  isaki Adapt to audio2.
- Searching nearest frequency is unnecessary in audio2.
 1.45.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.47.12.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.48.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.49.6.1 14-Jan-2024  martin Pull up following revision(s) (requested by chs in ticket #542):

sys/dev/pci/yds.c: revision 1.69
sys/dev/pci/cmpci.c: revision 1.61
sys/dev/pci/sv.c: revision 1.62
sys/dev/pci/fms.c: revision 1.50

mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.7 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.6 23-Nov-2011  jmcneill branches: 1.6.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.5 06-May-2009  cegger branches: 1.5.12; 1.5.14;
struct device * -> device_t, no functional changes intended.
 1.4 28-Apr-2008  martin branches: 1.4.12; 1.4.14;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.28; 1.3.70; 1.3.72; 1.3.74;
merge ktrace-lwp.
 1.2 15-Jan-2005  kent ansify and KNF
 1.1 01-Nov-1999  augustss branches: 1.1.4; 1.1.6; 1.1.12; 1.1.36;
Add a missing file for the fms driver.
 1.1.36.1 17-Jan-2005  skrll Sync with HEAD.
 1.1.12.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.12.1 01-Nov-1999  bouyer file fmsvar.h was added on branch thorpej_scsipi on 2000-11-20 11:42:19 +0000
 1.1.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.2 15-Nov-1999  fvdl Sync with -current
 1.1.4.1 01-Nov-1999  fvdl file fmsvar.h was added on branch fvdl-softdep on 1999-11-15 00:41:00 +0000
 1.3.74.2 16-May-2009  yamt sync with head
 1.3.74.1 16-May-2008  yamt sync with head.
 1.3.72.1 18-May-2008  yamt sync with head.
 1.3.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.4.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.5.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.5.12.2 30-Oct-2012  yamt sync with head
 1.5.12.1 17-Apr-2012  yamt sync with head
 1.6.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19 29-Mar-2010  kiyohara Remove obsolete file.
 1.18 26-Nov-2009  njoly branches: 1.18.2; 1.18.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.17 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.16 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.15 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.14 28-Apr-2008  martin branches: 1.14.14;
Remove clause 3 and 4 from TNF licenses
 1.13 10-Apr-2008  cegger branches: 1.13.2; 1.13.4;
use aprint_*_dev and device_xname
 1.12 19-Oct-2007  ad branches: 1.12.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 11-Dec-2005  christos branches: 1.11.30; 1.11.44; 1.11.46; 1.11.50;
merge ktrace-lwp.
 1.10 27-Feb-2005  perry branches: 1.10.4;
nuke trailing whitespace
 1.9 04-Feb-2005  perry de-__P
 1.8 23-Apr-2004  itojun branches: 1.8.4; 1.8.6;
pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.7 31-Jan-2003  thorpej branches: 1.7.2;
Use aprint_*().
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.2 13-Nov-2001  lukem add RCSID
 1.1 06-Mar-2001  matt branches: 1.1.2; 1.1.4; 1.1.6;
Add the PCI frontend for the TI LYNX firewire chip. Note that the
backend still needs to be worked on.
 1.1.6.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.4 08-Jan-2002  nathanw Catch up to -current.
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 09-Apr-2001  nathanw Catch up with -current.
 1.1.4.1 06-Mar-2001  nathanw file fwlynx_pci.c was added on branch nathanw_sa on 2001-04-09 01:56:59 +0000
 1.1.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.1 06-Mar-2001  bouyer file fwlynx_pci.c was added on branch thorpej_scsipi on 2001-03-12 13:31:06 +0000
 1.7.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.6.1 12-Feb-2005  yamt sync with head.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.4.1 27-Oct-2007  yamt sync with head.
 1.11.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.46.1 06-Nov-2007  matt sync with HEAD
 1.11.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.30.1 23-Oct-2007  ad Sync with head.
 1.12.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.4.4 11-Aug-2010  yamt sync with head.
 1.13.4.3 11-Mar-2010  yamt sync with head
 1.13.4.2 16-May-2009  yamt sync with head
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 30-May-2010  rmind sync with head
 1.18.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.46 31-Mar-2018  sevan There was only one G3 PowerBook with Firewire support, the Pismo. Issue is not
exclusive to the Pismo, confirmed on a G4 Titanium PowerBook. Chip is a Texas
Instruments TSB41AB1.
 1.45 31-Mar-2018  sevan PG3_FW device has been renamed UNINORTH_FW in pcidevs.
 1.44 10-May-2017  msaitoh branches: 1.44.8;
Use pci_intr_establish_xname().
 1.43 07-Jul-2016  msaitoh branches: 1.43.8;
KNF. Remove extra spaces. No functional change.
 1.42 29-Mar-2014  christos branches: 1.42.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.41 04-Aug-2012  riastradh branches: 1.41.2; 1.41.4;
Fix error branches and config pending races in firewire init.

This way, if anything fails, it just fails; you don't panic. This can
happen if suspending and resuming of firewire is broken (e.g., as I
encountered in PR kern/44581).
 1.40 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.39 29-Apr-2010  kiyohara branches: 1.39.8; 1.39.12;
Adds hw quirk for SUN firewire controllers. From FreeBSD.
Thanks for cegger@.
 1.38 24-Apr-2010  kiyohara Support detach by drvctl(8).
 1.37 29-Mar-2010  kiyohara Bye-bye fw_port.h.
 1.36 24-Feb-2010  dyoung branches: 1.36.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.35 03-Feb-2010  macallan branches: 1.35.2;
do not attach to Powrbook G3 onboard Firewire controllers until someone with
access to the hardware can figure out why it deadlocks during device
discovery
 1.34 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.33 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32 28-Apr-2008  martin branches: 1.32.10; 1.32.14;
Remove clause 3 and 4 from TNF licenses
 1.31 29-Mar-2008  kiyohara branches: 1.31.2; 1.31.4;
Sorry forgot.
Split device_t/softc, and cosmetic change.
 1.30 29-Mar-2008  ad Make it compile again.
 1.29 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.28 09-Dec-2007  jmcneill branches: 1.28.6; 1.28.10;
Merge jmcneill-pm branch.
 1.27 06-Nov-2007  kiyohara branches: 1.27.2; 1.27.4;
The argument of *_intr_establish() is changed to fwohci_flit.
Our ieee1394 coordinates from FreeBSD implementation.
Add fwohci_pci_shutdown() and fwohci_pci_power().
Move __KERNEL_RCSID to ahead.
 1.26 19-Oct-2007  ad branches: 1.26.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.25 16-Nov-2006  christos branches: 1.25.8; 1.25.22; 1.25.24; 1.25.28;
__unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 11-Dec-2005  christos branches: 1.23.20; 1.23.22;
merge ktrace-lwp.
 1.22 11-Jul-2005  kiyohara ieee1394 import from FreeBSD.
 1.21 27-Feb-2005  perry branches: 1.21.4;
nuke trailing whitespace
 1.20 04-Feb-2005  perry de-__P
 1.19 23-Apr-2004  itojun branches: 1.19.4; 1.19.6;
pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.18 31-Jan-2003  thorpej branches: 1.18.2;
Use aprint_*().
 1.17 04-Dec-2002  haya New Feature: add pseudo device for IEEE 1394 isochronous stream and
isochronous reception routine for IEEE 1394 OHCI (fwohci). The
transmission part is under construction.

The minimum configuration options for this feature are:

# IEEE 1394 (i.LINK)
fwohci* at pci? dev ? function ?
pseudo-device fwiso 1
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 26-Jan-2002  ichiro OCHI -> OHCI
 1.12 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.11 13-Nov-2001  lukem add RCSID
 1.10 01-May-2001  jmc branches: 1.10.2;
Change to IPL_BIO
 1.9 12-Apr-2001  thorpej Use IPL_NET for now -- the only use of 1394 right now is for network
interfaces (IPv{4,6}-over-1394), and this allows us to get rid of
some evil interrupt mixing issues in the 1394 network code right now.
 1.8 15-Mar-2001  enami Make fwohci works on big endian cpu (e.g., powermac g4).
 1.7 15-Mar-2001  enami Fix indentation and white space usage.
 1.6 28-Dec-2000  sommerfeld branches: 1.6.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.5 13-Dec-2000  enami Add RCS Id.
 1.4 05-Nov-2000  matt branches: 1.4.2;
Merge in my some of my stuff.
 1.3 05-Nov-2000  onoe First Prototype implementation of network interface part for IEEE1394 (if_fw).

Current status:
Only OHCI chip is supported (fwohci).
ping (IPv4) works with Sony's implementation (SmartConnect) on Win98.
sometimes works but not stable.
Not implemented yet:
IRM (Isochronous Resource Manager) functionality.
Link layer fragmentation.
Topology map.
More to do:
clean ups
MCAP
charactor device part
dhcp

There is no entry in GENERIC config file yet.
Follow sys/dev/ieee1394/IMPLEMENTATION to enable if_fw.
 1.2 30-May-2000  augustss branches: 1.2.4;
Make this compile too.
 1.1 30-May-2000  matt Beginning of a IEEE 1394 framework. An attachment for PCI OHCI controllers
and bus-independent module that just begins to print things out. No real
code behind it. THIS IS A WORK IN PROGRESS. The *reg.h are woefully
incomplete.
 1.2.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.2.4.1 30-May-2000  minoura file fwohci_pci.c was added on branch minoura-xpg4dl on 2000-06-22 17:07:23 +0000
 1.4.2.7 21-Apr-2001  bouyer Sync with HEAD
 1.4.2.6 27-Mar-2001  bouyer Sync with HEAD.
 1.4.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.4.2.4 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.4.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 05-Nov-2000  bouyer file fwohci_pci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:20 +0000
 1.6.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.6.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.6.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.6.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.6.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.10.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.10.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.18.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.19.6.1 12-Feb-2005  yamt sync with head.
 1.19.4.1 29-Apr-2005  kent sync with -current
 1.21.4.6 17-Mar-2008  yamt sync with head.
 1.21.4.5 21-Jan-2008  yamt sync with head
 1.21.4.4 15-Nov-2007  yamt sync with head.
 1.21.4.3 27-Oct-2007  yamt sync with head.
 1.21.4.2 30-Dec-2006  yamt sync with head.
 1.21.4.1 21-Jun-2006  yamt sync with head.
 1.23.22.2 10-Dec-2006  yamt sync with head.
 1.23.22.1 22-Oct-2006  yamt sync with head
 1.23.20.1 18-Nov-2006  ad Sync with head.
 1.25.28.2 13-Nov-2007  bouyer Sync with HEAD
 1.25.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.25.24.4 23-Mar-2008  matt sync with HEAD
 1.25.24.3 09-Jan-2008  matt sync with HEAD
 1.25.24.2 08-Nov-2007  matt sync with -HEAD
 1.25.24.1 06-Nov-2007  matt sync with HEAD
 1.25.22.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.25.22.4 01-Dec-2007  jmcneill If fwohci happens to fail to attach, register a NULL power handler.
 1.25.22.3 14-Nov-2007  joerg Convert to suspend/resume framework. Not fully functional, but a start.
 1.25.22.2 06-Nov-2007  joerg Sync with HEAD.
 1.25.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.25.8.1 23-Oct-2007  ad Sync with head.
 1.26.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.26.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.27.4.1 11-Dec-2007  yamt sync with head.
 1.27.2.1 26-Dec-2007  ad Sync with head.
 1.28.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.28.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.28.6.1 24-Mar-2008  keiichi sync with head.
 1.31.4.4 11-Aug-2010  yamt sync with head.
 1.31.4.3 11-Mar-2010  yamt sync with head
 1.31.4.2 16-May-2009  yamt sync with head
 1.31.4.1 16-May-2008  yamt sync with head.
 1.31.2.1 18-May-2008  yamt sync with head.
 1.32.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.10.1 21-Nov-2010  riz Pull up following revision(s) (requested by macallan in ticket #1470):
sys/dev/pci/fwohci_pci.c: revision 1.35
do not attach to Powrbook G3 onboard Firewire controllers until =20
someone with
access to the hardware can figure out why it deadlocks during device
discovery
 1.35.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.36.2.1 30-May-2010  rmind sync with head
 1.39.12.1 18-Feb-2012  mrg merge to -current.
 1.39.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.8.2 30-Oct-2012  yamt sync with head
 1.39.8.1 17-Apr-2012  yamt sync with head
 1.41.4.1 18-May-2014  rmind sync with head
 1.41.2.2 03-Dec-2017  jdolecek update from HEAD
 1.41.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.6.2 28-Aug-2017  skrll Sync with HEAD
 1.42.6.1 09-Jul-2016  skrll Sync with HEAD
 1.43.8.1 11-May-2017  pgoyette Sync with HEAD
 1.44.8.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.20 07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.19 29-Feb-2020  isaki round_blocksize must return a multiple of the framesize.
It's not divisible when blk=GCSCAUDI_PRD_SIZE_MAX and channels=4.
 1.18 08-Jun-2019  isaki branches: 1.18.2; 1.18.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.17 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.16 09-Dec-2018  jdolecek branches: 1.16.2;
use pci_intr_establish_xname() everywhere
 1.15 01-Jun-2017  chs branches: 1.15.8; 1.15.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.14 29-Mar-2014  christos branches: 1.14.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.13 31-Jan-2014  ryo fix a problem to set sample rate of AC97 codec.
 1.12 02-Mar-2012  nonaka branches: 1.12.2; 1.12.4;
convert to device_t.
 1.11 25-Nov-2011  jmcneill branches: 1.11.2;
remove an unnecessary call to vtbl->unlock
 1.10 25-Nov-2011  jmcneill need to hold thread lock when using AC97_IS_* macros
 1.9 24-Nov-2011  mrg put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.8 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.7 09-Jun-2011  joerg branches: 1.7.2; 1.7.4;
Use a format string when printing strings
 1.6 13-Nov-2010  uebayasi branches: 1.6.6;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.5 24-Feb-2010  dyoung branches: 1.5.2; 1.5.4;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.4 08-Jan-2010  dyoung branches: 1.4.2;
Expand PMF_FN_* macros.
 1.3 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.2 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.1 28-Dec-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
PR# port-i386/40284: add AMD Geode CS5536 audio driver; written by
SHIMIZU Ryo <ryo@nerv.org>
 1.1.10.4 11-Mar-2010  yamt sync with head
 1.1.10.3 16-May-2009  yamt sync with head
 1.1.10.2 04-May-2009  yamt sync with head.
 1.1.10.1 28-Dec-2008  yamt file gcscaudio.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:55 +0000
 1.1.8.2 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #260):
sys/dev/pci/files.pci: revision 1.309
sys/dev/pci/gcscaudio.c: revision 1.1
sys/dev/pci/gcscaudioreg.h: revision 1.1
PR# port-i386/40284: add AMD Geode CS5536 audio driver; written by
SHIMIZU Ryo <ryo@nerv.org>
 1.1.8.1 28-Dec-2008  snj file gcscaudio.c was added on branch netbsd-5 on 2009-05-01 01:19:09 +0000
 1.1.6.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.4.1 28-Dec-2008  skrll file gcscaudio.c was added on branch nick-hppapmap on 2009-01-19 13:18:25 +0000
 1.1.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.2.1 28-Dec-2008  mjf file gcscaudio.c was added on branch mjf-devfs2 on 2009-01-17 13:28:59 +0000
 1.4.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.4.2 21-Apr-2010  matt sync to netbsd-5
 1.5.4.1 24-Feb-2010  matt file gcscaudio.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:40 +0000
 1.5.2.2 12-Jun-2011  rmind sync with head
 1.5.2.1 05-Mar-2011  rmind sync with head
 1.6.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.4.4 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.7.4.3 20-Nov-2011  jmcneill need to hold intr_lock when calling audio_pint/audio_rint
 1.7.4.2 19-Nov-2011  jmcneill add gcscaudio_get_locks()
 1.7.4.1 19-Nov-2011  jmcneill adapt to audiomp api changes
 1.7.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.2.1 17-Apr-2012  yamt sync with head
 1.11.2.3 06-Mar-2012  mrg sync to -current
 1.11.2.2 06-Mar-2012  mrg sync to -current
 1.11.2.1 04-Mar-2012  mrg sync to latest -current.
 1.12.4.1 18-May-2014  rmind sync with head
 1.12.2.2 03-Dec-2017  jdolecek update from HEAD
 1.12.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.6.1 28-Aug-2017  skrll Sync with HEAD
 1.15.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.10.1 10-Jun-2019  christos Sync with HEAD
 1.15.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.16.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.16.2.3 04-May-2019  isaki Remove obsoleted methods in audio_hw_if.
- drain: is handled in audio upper layer now.
- mappage: is handled in audio upper layer now.
- setfd: no one uses and it's meaningless now.
 1.16.2.2 28-Apr-2019  isaki Adapt to audio2.
 1.16.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.18.4.1 29-Feb-2020  ad Sync with head.
 1.18.2.1 21-Mar-2020  martin Pull up following revision(s) (requested by isaki in ticket #792):

sys/arch/amiga/dev/aucc.c: revision 1.48
sys/dev/pci/auixp.c: revision 1.49
sys/dev/pci/gcscaudio.c: revision 1.19
sys/dev/pci/auich.c: revision 1.159
sys/dev/sbus/dbri.c: revision 1.42
sys/dev/pci/auvia.c: revision 1.85
sys/dev/pci/auacer.c: revision 1.39

Drop 512 bytes limit on auvia_round_blocksize().

This fixes attach on 6 channels device.
PR kern/55017.

round_blocksize must return a multiple of the framesize.
aucc(4) supports 3 channels mode.

round_blocksize must return a multiple of the framesize
even if passed blocksize is greater than the upper limit.

round_blocksize must return a multiple of the framesize.

It's not divisible when blk=GCSCAUDI_PRD_SIZE_MAX and channels=4.
round_blocksize must return a multiple of the framesize
even if 6 channels mode.

I believe that keeping "good alignment" is just a wish, not constraint.
 1.2 07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.1 28-Dec-2008  jmcneill branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.16;
PR# port-i386/40284: add AMD Geode CS5536 audio driver; written by
SHIMIZU Ryo <ryo@nerv.org>
 1.1.16.2 21-Apr-2010  matt sync to netbsd-5
 1.1.16.1 28-Dec-2008  matt file gcscaudioreg.h was added on branch matt-nb5-mips64 on 2010-04-21 00:27:40 +0000
 1.1.10.2 04-May-2009  yamt sync with head.
 1.1.10.1 28-Dec-2008  yamt file gcscaudioreg.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:55 +0000
 1.1.8.2 01-May-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #260):
sys/dev/pci/files.pci: revision 1.309
sys/dev/pci/gcscaudio.c: revision 1.1
sys/dev/pci/gcscaudioreg.h: revision 1.1
PR# port-i386/40284: add AMD Geode CS5536 audio driver; written by
SHIMIZU Ryo <ryo@nerv.org>
 1.1.8.1 28-Dec-2008  snj file gcscaudioreg.h was added on branch netbsd-5 on 2009-05-01 01:19:09 +0000
 1.1.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.4.1 28-Dec-2008  skrll file gcscaudioreg.h was added on branch nick-hppapmap on 2009-01-19 13:18:25 +0000
 1.1.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.2.1 28-Dec-2008  mjf file gcscaudioreg.h was added on branch mjf-devfs2 on 2009-01-17 13:28:59 +0000
 1.45 02-Oct-2022  rin PR kern/57035

s/lower/higher/ in comment; for little endian, 2nd word is higher
both in numeric and address. It seems that I'm too absorbed into
big endian machines these days ;)

No binary changes.
 1.44 01-Oct-2022  rin Use appropriate macros. No binary changes for GCC/amd64.
 1.43 01-Oct-2022  rin Remove confusing braces. No binary changes.
 1.42 01-Oct-2022  rin trailing whitespace
 1.41 01-Oct-2022  rin PR kern/57035

genfb(4): Fix blank screen after switching to WSDISPLAYIO_MODE_EMUL for
some GPU models like Ice Lake integrated GPU:

- Restore lower words of 64-bit BARs correctly.
- Do not disable expansion ROM if exists.

Thanks ryoon@ for testing!
 1.40 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.39 24-Apr-2021  thorpej branches: 1.39.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.38 07-Jul-2016  msaitoh branches: 1.38.34;
KNF. Remove extra spaces. No functional change.
 1.37 24-Jul-2014  riastradh branches: 1.37.4;
Add enable/disable polling hooks to genfb_ops.
 1.36 27-Jan-2014  macallan branches: 1.36.2;
back out 1.35 since it completely breaks the mechanism for wsdisplay drivers
to determine wether to become console or not.
See http://mail-index.netbsd.org/tech-kern/2014/01/15/msg016421.html
for fixing this properly.
 1.35 16-Jan-2014  jakllsch Fix PR kern/46376 with Nat Sloss's patch (with slight modification).
Serial console now works on x86 with genfb enabled.
 1.34 13-Mar-2012  elad branches: 1.34.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.33 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.32 08-Mar-2011  macallan branches: 1.32.4; 1.32.8;
only try to map the framebuffer if we don't already have an address
With this radeondrm works with genfb and r6xx.
 1.31 13-Feb-2011  phx Determine BAR type with pci_mapreg_probe() instead of pci_mapreg_type(),
to skip unimplemented BARs.
Do not probe non-BAR registers (like subsystem id). This fixes potential
panics in pci_mem_find().
 1.30 10-Feb-2011  jmcneill add support for 64-bit BARs
 1.29 10-Feb-2011  jmcneill Use BUS_SPACE_MAP_PREFETCHABLE when mapping the framebuffer.
 1.28 09-Feb-2011  jmcneill switch genfb to polling mode at shutdown
 1.27 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.26 16-Dec-2010  cegger branches: 1.26.2; 1.26.4;
ioctl: KNF switch-case, remove useless brackets
 1.25 07-Oct-2010  macallan finish device_t-ification
 1.24 25-Feb-2010  macallan branches: 1.24.2;
add a comment on PCI_MAGIC_IO_RANGE
 1.23 24-Aug-2009  jmcneill branches: 1.23.2;
Move softc definition to genfb_pcivar.h
 1.22 24-Aug-2009  jmcneill Expose genfb_restore_palette and allow MD code to specify PMF callbacks.
 1.21 24-Aug-2009  jmcneill Register NULL pmf handlers, and note that firmware & MD code is responsible
for restoring the display device.
 1.20 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.19 06-May-2009  elad Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.18 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.17 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.16 23-Feb-2009  jmcneill Turn "bogus parameters" aprint_error into aprint_debug, and change the
message to say that the framebuffer was not configured by the firmware.
 1.15 17-Feb-2009  jmcneill Use aprint_*
 1.14 16-Feb-2009  jmcneill Provide callbacks so MD code can explicitly prevent genfb from matching;
works around vga/genfb deathmatches.
 1.13 15-Feb-2009  jmcneill Introduce genfb_ops genfb_borrow callback to allow the bus frontend to
lend mappings to drm.
 1.12 14-Feb-2009  jmcneill Provide a stub genfb_cnattach for md code to call to give a hint to the
bus driver's match function to return a higher confidence (so it can
beat out vga(4), for example). genfb needs-flag so md code can determine
if the genfb driver is present.
 1.11 05-May-2008  jmcneill branches: 1.11.8; 1.11.14;
Change autoconf message 'direct rendering on dev unsupported' to
the more accurate 'drm at dev not configured'.
 1.10 29-Apr-2008  martin Convert to new 2 clause license
 1.9 10-Apr-2008  cegger branches: 1.9.2; 1.9.4;
use aprint_*_dev and device_xname
 1.8 01-Apr-2008  mrg if genfb_pci can't map regs, don't panic() just return.
 1.7 09-Mar-2008  phx Do not attach genfb when the frame buffer is not flagged as being console
(e.g. when a serial console is used).
Approved by macallan.
 1.6 27-Feb-2008  macallan get rid of the last #ifdef macppc and use PCI_MAGIC_IO_RANGE to select
at which offset we mmap PCI IO space
 1.5 21-Dec-2007  macallan branches: 1.5.2; 1.5.6;
only enable the fb mapping at offset 0 after attempting to mmap page 0
This way we avoid a conflict with PCI resources on some Sun graphics cards
which have firmware that likes to put memory resources at low addresses.
For instance, if we have 1MB framebuffer and registers at 0x30000 we'll
get the registers when mmap()ing 0x30000 until someone tries to mmap(0),
then we'll get framebuffer memory for the entire 1st MB.
This needs an ioctl() to switch between fb-at-0 and PCI ranges.
 1.4 01-Dec-2007  ad branches: 1.4.2; 1.4.6;
Back out previous.
 1.3 01-Dec-2007  ad Noisy printfs.
 1.2 19-Nov-2007  macallan various fixes and additions:
- deal with bogus parameters - just return instead of panic()ing
- try to attach a drm
- save and restore BARs in case X messes them up
 1.1 10-Apr-2007  macallan branches: 1.1.2; 1.1.6; 1.1.8; 1.1.14; 1.1.16; 1.1.18; 1.1.22; 1.1.24;
move genfb's PCI frontend to dev/pci
 1.1.24.2 27-Dec-2007  mjf Sync with HEAD.
 1.1.24.1 08-Dec-2007  mjf Sync with HEAD.
 1.1.22.1 21-Nov-2007  bouyer Sync with HEAD
 1.1.18.5 17-Mar-2008  yamt sync with head.
 1.1.18.4 21-Jan-2008  yamt sync with head
 1.1.18.3 07-Dec-2007  yamt sync with head
 1.1.18.2 03-Sep-2007  yamt sync with head.
 1.1.18.1 10-Apr-2007  yamt file genfb_pci.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:50 +0000
 1.1.16.2 23-Mar-2008  matt sync with HEAD
 1.1.16.1 09-Jan-2008  matt sync with HEAD
 1.1.14.1 21-Nov-2007  joerg Sync with HEAD.
 1.1.8.2 11-Jul-2007  mjf Sync with head.
 1.1.8.1 10-Apr-2007  mjf file genfb_pci.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:29 +0000
 1.1.6.2 15-Apr-2007  yamt sync with head.
 1.1.6.1 10-Apr-2007  yamt file genfb_pci.c was added on branch yamt-idlelwp on 2007-04-15 16:03:24 +0000
 1.1.2.2 10-Apr-2007  ad Sync with head.
 1.1.2.1 10-Apr-2007  ad file genfb_pci.c was added on branch vmlocking on 2007-04-10 13:24:23 +0000
 1.4.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.2.1 26-Dec-2007  ad Sync with head.
 1.5.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.5.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.2.1 24-Mar-2008  keiichi sync with head.
 1.9.4.6 09-Oct-2010  yamt sync with head
 1.9.4.5 11-Mar-2010  yamt sync with head
 1.9.4.4 16-Sep-2009  yamt sync with head
 1.9.4.3 16-May-2009  yamt sync with head
 1.9.4.2 04-May-2009  yamt sync with head.
 1.9.4.1 16-May-2008  yamt sync with head.
 1.9.2.1 18-May-2008  yamt sync with head.
 1.11.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.8.1 03-Mar-2009  skrll Sync with HEAD.
 1.23.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.23.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.24.2.2 21-Apr-2011  rmind sync with head
 1.24.2.1 05-Mar-2011  rmind sync with head
 1.26.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.26.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.26.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.8.2 05-Apr-2012  mrg sync to latest -current.
 1.32.8.1 18-Feb-2012  mrg merge to -current.
 1.32.4.1 17-Apr-2012  yamt sync with head
 1.34.2.2 03-Dec-2017  jdolecek update from HEAD
 1.34.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.2.1 10-Aug-2014  tls Rebase.
 1.37.4.1 09-Jul-2016  skrll Sync with HEAD
 1.38.34.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.39.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 18-Oct-2011  dyoung Add an #include for the genfb_softc type.
 1.1 24-Aug-2009  jmcneill branches: 1.1.2;
Move softc definition to genfb_pcivar.h
 1.1.2.2 16-Sep-2009  yamt sync with head
 1.1.2.1 24-Aug-2009  yamt file genfb_pcivar.h was added on branch yamt-nfs-mp on 2009-09-16 13:37:50 +0000
 1.25 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.24 31-Jul-2012  bouyer branches: 1.24.2; 1.24.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.23 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.22 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.21 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.20 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.19 04-Apr-2011  dyoung branches: 1.19.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.18 13-Nov-2010  uebayasi branches: 1.18.2;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.17 05-Nov-2010  jakllsch Pave the way for detachment of pciide(4)-family ATA controllers.
 1.16 19-Oct-2009  bouyer branches: 1.16.2; 1.16.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.15 18-Mar-2008  cube branches: 1.15.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.14 09-Feb-2007  ad branches: 1.14.20; 1.14.36; 1.14.40;
Merge newlock2 to head.
 1.13 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 06-Jul-2005  thorpej branches: 1.10.2;
- When starting an ATA or ATAPI transfer, handle the case where (*dma_init)()
returns EINVAL, indicating that DMA cannot be done for this transfer.
Fall back to PIO in this case.
- Add a geodeide_dma_init() routine that checks to make sure that transfers
start on a 16 byte boundary, returning EINVAL if not. Works around a chip
bug that causes a hard system hang.

Problem reported and patch tested by Erik Fair.
 1.9 25-Jun-2005  fair According to FreeBSD and other references, the cs5530 IDE controller,
while capable of UDMA mode 2, is swamped if you actually go that
fast, which is not good for the other functions on this multifunction
southbridge chip, so limit UDMA to mode 1.
 1.8 27-Feb-2005  perry branches: 1.8.2;
nuke trailing whitespace
 1.7 21-Aug-2004  thorpej branches: 1.7.4; 1.7.6;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.6 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.5 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.4 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.3 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.2 27-Jul-2004  rumble branches: 1.2.2;
Add support for the controller found on the AMD (previously
NatSemi) Geode SC1100 controller (as found on the Soekris
NET4801). The chip has two bugs: the first requires dword
alignment, and the second cannot handle exact 64K transfers.

Also, fix a few typos while we're here.

Timings from FreeBSD. Reviewed by Manuel Bouyer.
 1.1 09-Jul-2004  bouyer branches: 1.1.2;
Add geodeide(4), a driver for the AMD Geode CS5530A IDE controller.
Tested by Ian Zagorskih (ianzag at megasignal.com).
 1.1.2.3 28-Jul-2004  tron branches: 1.1.2.3.2;
Pull up revision 1.2 (requested by rumble in ticket #718):
Add support for the controller found on the AMD (previously
NatSemi) Geode SC1100 controller (as found on the Soekris
NET4801). The chip has two bugs: the first requires dword
alignment, and the second cannot handle exact 64K transfers.
Also, fix a few typos while we're here.
Timings from FreeBSD. Reviewed by Manuel Bouyer.
 1.1.2.2 14-Jul-2004  tron Pull up revision 1.1 (requested by bouyer in ticket #644):
Add geodeide(4), a driver for the AMD Geode CS5530A IDE controller.
Tested by Ian Zagorskih (ianzag at megasignal.com).
 1.1.2.1 09-Jul-2004  tron file geodeide.c was added on branch netbsd-2-0 on 2004-07-14 09:08:28 +0000
 1.1.2.3.2.1 18-Jul-2005  riz Pull up revision 1.10 (requested by thorpej in ticket #2072):
- When starting an ATA or ATAPI transfer, handle the case where
(*dma_init)()
returns EINVAL, indicating that DMA cannot be done for this
transfer.
Fall back to PIO in this case.
- Add a geodeide_dma_init() routine that checks to make sure that
transfers
start on a 16 byte boundary, returning EINVAL if not. Works
around a chip
bug that causes a hard system hang.
Problem reported and patch tested by Erik Fair.
 1.2.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.4 25-Aug-2004  skrll Sync with HEAD.
 1.2.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 27-Jul-2004  skrll file geodeide.c was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.7.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.8.2.2 12-Jul-2005  tron Pull up revision 1.9 (requested by fair in ticket #555):
According to FreeBSD and other references, the cs5530 IDE controller,
while capable of UDMA mode 2, is swamped if you actually go that
fast, which is not good for the other functions on this multifunction
southbridge chip, so limit UDMA to mode 1.
 1.8.2.1 06-Jul-2005  tron Pull up revision 1.10 (requested by thorpej in ticket #553):
- When starting an ATA or ATAPI transfer, handle the case where (*dma_init)()
returns EINVAL, indicating that DMA cannot be done for this transfer.
Fall back to PIO in this case.
- Add a geodeide_dma_init() routine that checks to make sure that transfers
start on a 16 byte boundary, returning EINVAL if not. Works around a chip
bug that causes a hard system hang.
Problem reported and patch tested by Erik Fair.
 1.10.2.3 24-Mar-2008  yamt sync with head.
 1.10.2.2 26-Feb-2007  yamt sync with head.
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.14.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.36.1 24-Mar-2008  keiichi sync with head.
 1.14.20.1 23-Mar-2008  matt sync with HEAD
 1.15.4.1 11-Mar-2010  yamt sync with head
 1.16.4.2 21-Apr-2011  rmind sync with head
 1.16.4.1 05-Mar-2011  rmind sync with head
 1.16.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.4.1 30-Oct-2012  yamt sync with head
 1.24.4.1 18-May-2014  rmind sync with head
 1.24.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.29 14-Oct-2025  macallan support hardware rendering for mono fonts
 1.28 06-Oct-2025  macallan add backlight control for FX 5200 Go
 1.27 30-Aug-2025  macallan add backlight control
 1.26 30-Aug-2025  macallan put some RAMDAC initialization back, use 8bit writes this time
 1.25 29-Aug-2025  macallan support acceleration on nv3x, aka GeForce FX 5200U and FX Go 5200
 1.24 22-Jul-2025  macallan enable font loading
 1.23 21-Jul-2025  macallan match GeForce FX 5200 Ultra
 1.22 25-Sep-2022  thorpej branches: 1.22.10;
Remove unnecessary include of <sys/malloc.h>.
 1.21 15-Aug-2022  macallan nuke pasto in gffb_init()
 1.20 10-Mar-2022  andvar s/woud/would/ in comment.
 1.19 10-Mar-2022  riastradh gffb(4): Nix membar_sync and explain what's going on here.
 1.18 10-Mar-2022  riastradh gffb(4): Use bus_space_barrier, not membar_sync.
 1.17 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.16 24-Apr-2021  thorpej branches: 1.16.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.15 25-Feb-2021  macallan branches: 1.15.2;
match Geforce FX5200 Go found in some iMac G5 models
 1.14 21-May-2020  macallan branches: 1.14.2;
prune unneeded includes
 1.13 26-Jul-2018  macallan first step to support chips newer than geforce 2MX
 1.12 20-Jan-2017  maya branches: 1.12.12; 1.12.14;
Check pmf_device_register return value. NFC
Appeases static analyzers.
 1.11 11-Jul-2016  msaitoh branches: 1.11.2; 1.11.4;
KNF. No functional change.
 1.10 16-Sep-2015  macallan prop_dictionary_get_bool() doesn't return FALSE if the property doesn't
exist, so initialize things first.
No more console stealing on sparc64.
 1.9 29-Jun-2014  tsutsui branches: 1.9.4; 1.9.6;
Appease a printf format warning on LP64 machines.
 1.8 14-Mar-2014  mrg branches: 1.8.2; 1.8.4; 1.8.6;
remove various set-but-unused variables.
 1.7 23-Oct-2013  macallan fix copyright year
 1.6 23-Oct-2013  macallan minor cleanup:
- don't map more PCI space than we have video memory
- clarify some comments
 1.5 09-Oct-2013  macallan support WSDISPLAYIO_GET_FBINFO
 1.4 09-Oct-2013  macallan some cleanup:
- use macros to shorten a while lot of bus_space_write_4() lines
- update some comments
- remove debug goop and cargo culted leftovers
 1.3 09-Oct-2013  macallan add hardware acceleration
For now this supports only GeForce2 MX cards but most NV1x chips should work
once their PCI iDs are added to gffb_match()
Tested only on macppc.
 1.2 02-Oct-2013  macallan one step closer to graphics acceleration:
- probe and report actual amount of video memory
- add DMA machinery to feed commands to the graphics processor
- adapt a whole bunch of magic number initialization from xf86-video-nv, now
the chip actually reads commands from a buffer in video memory
 1.1 18-Sep-2013  macallan a preliminary driver for nvidia geforce graphics chips
so far it only supports the GeForce 2MX, tested on macppc only
no acceleration yet, just some DAC setup
the main advantage over genfb is that this driver knows how to setup the
palette registers for the 2nd output
 1.8.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.6.1 14-Mar-2014  yamt file gffb.c was added on branch yamt-pagecache on 2014-05-22 11:40:24 +0000
 1.8.4.2 18-May-2014  rmind sync with head
 1.8.4.1 14-Mar-2014  rmind file gffb.c was added on branch rmind-smpnet on 2014-05-18 17:45:39 +0000
 1.8.2.1 10-Aug-2014  tls Rebase.
 1.9.6.3 05-Feb-2017  skrll Sync with HEAD
 1.9.6.2 05-Oct-2016  skrll Sync with HEAD
 1.9.6.1 22-Sep-2015  skrll Sync with HEAD
 1.9.4.3 03-Dec-2017  jdolecek update from HEAD
 1.9.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.4.1 29-Jun-2014  tls file gffb.c was added on branch tls-maxphys on 2014-08-20 00:03:42 +0000
 1.11.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.12.14.1 10-Jun-2019  christos Sync with HEAD
 1.12.12.1 28-Jul-2018  pgoyette Sync with HEAD
 1.14.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.16.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.22.10.1 02-Aug-2025  perseant Sync with HEAD
 1.6 06-Oct-2025  macallan add backlight control for FX 5200 Go
 1.5 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.4 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.3 23-Oct-2013  macallan branches: 1.3.4; 1.3.6; 1.3.10; 1.3.48;
fix copyright year
 1.2 02-Oct-2013  macallan add a bunch more constants from xf86-video-nv
 1.1 18-Sep-2013  macallan a preliminary driver for nvidia geforce graphics chips
so far it only supports the GeForce 2MX, tested on macppc only
no acceleration yet, just some DAC setup
the main advantage over genfb is that this driver knows how to setup the
palette registers for the 2nd output
 1.3.48.1 20-Apr-2020  bouyer Sync with HEAD
 1.3.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.10.1 23-Oct-2013  tls file gffbreg.h was added on branch tls-maxphys on 2014-08-20 00:03:42 +0000
 1.3.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.6.1 23-Oct-2013  yamt file gffbreg.h was added on branch yamt-pagecache on 2014-05-22 11:40:24 +0000
 1.3.4.2 18-May-2014  rmind sync with head
 1.3.4.1 23-Oct-2013  rmind file gffbreg.h was added on branch rmind-smpnet on 2014-05-18 17:45:39 +0000
 1.20 11-Jul-2016  msaitoh KNF. No functional change.
 1.19 27-Oct-2012  chs branches: 1.19.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.18 30-Jan-2012  drochner branches: 1.18.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.17 12-May-2009  cegger branches: 1.17.12; 1.17.16;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.16 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.15 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.14 19-Oct-2007  ad branches: 1.14.20; 1.14.34;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 16-Nov-2006  christos branches: 1.13.8; 1.13.22; 1.13.24; 1.13.28;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 29-Mar-2006  thorpej branches: 1.11.8; 1.11.10;
Use device_cfdata().
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.6; 1.10.8; 1.10.10; 1.10.12;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.7 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.6 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.5 31-Jan-2003  thorpej branches: 1.5.2;
Use aprint_*().
 1.4 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.3 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 03-Sep-2002  augustss branches: 1.1.2; 1.1.4;
Replace the mr driver with the gtp driver. From OpenBSD.
 1.1.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.2 17-Sep-2002  nathanw Catch up to -current.
 1.1.4.1 03-Sep-2002  nathanw file gtp.c was added on branch nathanw_sa on 2002-09-17 21:20:16 +0000
 1.1.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.1 03-Sep-2002  jdolecek file gtp.c was added on branch kqueue on 2002-09-06 08:45:13 +0000
 1.5.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.2.3 27-Oct-2007  yamt sync with head.
 1.9.2.2 30-Dec-2006  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.10.10.1 19-Apr-2006  elad sync with head.
 1.10.8.1 01-Apr-2006  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.10.2 10-Dec-2006  yamt sync with head.
 1.11.10.1 22-Oct-2006  yamt sync with head
 1.11.8.1 18-Nov-2006  ad Sync with head.
 1.13.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.24.1 06-Nov-2007  matt sync with HEAD
 1.13.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.14.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.20.1 16-May-2009  yamt sync with head
 1.17.16.1 18-Feb-2012  mrg merge to -current.
 1.17.12.2 30-Oct-2012  yamt sync with head
 1.17.12.1 17-Apr-2012  yamt sync with head
 1.18.6.2 03-Dec-2017  jdolecek update from HEAD
 1.18.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.14.1 05-Oct-2016  skrll Sync with HEAD
 1.13 13-Sep-2022  msaitoh Add Intel 600 series PCH-LP devices support.
 1.12 21-Mar-2022  jmcneill hdaudio: pci: PCIe config space fixes and Intel PCH snoop support

The HD audio specification does not cover PCI config space, and this
driver was unconditionally writing to a vendor specific register. Reduce
scope of config space accesses based on PCI IDs.

With this cleaned up, add support for Intel PCH devices which require
some additional vendor specific configuration to bypass no snoop mode.
 1.11 28-Oct-2021  msaitoh Support devices that the PCI subclass is not PCI_SUBCLASS_MULTIMEDIA_HDAUDIO.

- Not tested well.
- If audioX is not attached, add HDAUDIO_ENABLE_DISPLAYPORT and
HDAUDIO_ENABLE_HDMI to your kernel config.
 1.10 12-Sep-2018  mrg use pa_dmat64 if pci_dma64_available().
 1.9 12-Sep-2018  mrg use pci_mapreg_type() instead of assuming PCI_MAPREG_TYPE_MEM.
suggested by riastradh@.

fixes hdaudio on thinkpad P51 where the registers are mapped
over 4GB range. probably fixes intel X10-based systems that
map hdaudio high as well, but i was able to work around that
in the BIOS. not so for the P51.

XXX: pullup-7, pullup-8.
 1.8 04-Jun-2017  pgoyette branches: 1.8.4; 1.8.6; 1.8.8;
Move the hdaudio_cd out of the hdaudio_pci module and into the main
hdaudio module. Rearrange the inter-module dependencies accordingly.

Should resolve (my) PR kern/49836

XXX Pull-ups needed for netbsd-8 branch
 1.7 27-Apr-2017  msaitoh branches: 1.7.2;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.6 31-Jan-2017  khorben branches: 1.6.4;
Always allow hdaudio(4) to suspend

Sometimes hdaudio(4) can fail to attach, but the device remains in the
tree. Even though the PMF registration is performed, it is explicitly
de-registered in the code path for errors - therefore preventing suspending
later. This patch makes sure PMF registration is performed accordingly upon
errors as well.

No objection on tech-kern@.

Tested on a Lenovo ThinkPad T440s (amd64).

XXX pull-up to netbsd-7
 1.5 16-Dec-2016  nonaka branches: 1.5.2;
hdaudio(4): Use pci_intr_alloc(9)/pci_intr_release(9).
 1.4 14-Jul-2016  msaitoh branches: 1.4.2;
KNF. No functional change.
 1.3 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.2 05-Jul-2015  nonaka Deregister pmf hook when attach failed.
 1.1 28-Mar-2015  jmcneill branches: 1.1.2;
Split hdaudio and PCI attach glue. Even though the driver was written with
this separation in mind, all of the code lived in sys/dev/pci/hdaudio. Move
common parts to sys/dev/hdaudio and PCI attach glue to sys/dev/pci.
 1.1.2.7 28-Aug-2017  skrll Sync with HEAD
 1.1.2.6 05-Feb-2017  skrll Sync with HEAD
 1.1.2.5 05-Oct-2016  skrll Sync with HEAD
 1.1.2.4 09-Jul-2016  skrll Sync with HEAD
 1.1.2.3 22-Sep-2015  skrll Sync with HEAD
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 28-Mar-2015  skrll file hdaudio_pci.c was added on branch nick-nhusb on 2015-04-06 15:18:10 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.5.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.6.4.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.7.2.2 23-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1022):

sys/dev/pci/hdaudio_pci.c: revision 1.9
sys/dev/pci/hdaudio_pci.c: revision 1.10

use pci_mapreg_type() instead of assuming PCI_MAPREG_TYPE_MEM.
suggested by riastradh@.

fixes hdaudio on thinkpad P51 where the registers are mapped
over 4GB range. probably fixes intel X10-based systems that
map hdaudio high as well, but i was able to work around that
in the BIOS. not so for the P51.

XXX: pullup-7, pullup-8.

use pa_dmat64 if pci_dma64_available().
 1.7.2.1 05-Jun-2017  snj Pull up following revision(s) (requested by pgoyette in ticket #6):
sys/dev/hdaudio/hdaudio.c: revision 1.5
sys/dev/pci/hdaudio_pci.c: revision 1.8
Move the hdaudio_cd out of the hdaudio_pci module and into the main
hdaudio module. Rearrange the inter-module dependencies accordingly.
Should resolve (my) PR kern/49836
 1.8.8.1 10-Jun-2019  christos Sync with HEAD
 1.8.6.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.8.4.2 03-Dec-2017  jdolecek update from HEAD
 1.8.4.1 04-Jun-2017  jdolecek file hdaudio_pci.c was added on branch tls-maxphys on 2017-12-03 11:37:07 +0000
 1.2 21-Mar-2022  jmcneill hdaudio: pci: PCIe config space fixes and Intel PCH snoop support

The HD audio specification does not cover PCI config space, and this
driver was unconditionally writing to a vendor specific register. Reduce
scope of config space accesses based on PCI IDs.

With this cleaned up, add support for Intel PCH devices which require
some additional vendor specific configuration to bypass no snoop mode.
 1.1 28-Mar-2015  jmcneill branches: 1.1.2; 1.1.18;
Split hdaudio and PCI attach glue. Even though the driver was written with
this separation in mind, all of the code lived in sys/dev/pci/hdaudio. Move
common parts to sys/dev/hdaudio and PCI attach glue to sys/dev/pci.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 28-Mar-2015  jdolecek file hdaudio_pci.h was added on branch tls-maxphys on 2017-12-03 11:37:07 +0000
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 28-Mar-2015  skrll file hdaudio_pci.h was added on branch nick-nhusb on 2015-04-06 15:18:10 +0000
 1.82 04-Aug-2023  riastradh entropy(9): Simplify stages. Split interrupt vs non-interrupt paths.

- Nix the entropy stage (cold, warm, hot). Just use the usual kernel
`cold' (cold: single-core, single-thread; interrupts may happen),
and don't make any three-way distinction about whether interrupts
or threads or other CPUs can be running.

Instead, while cold, use splhigh/splx or forbid paths to come from
interrupt context, and while warm, use mutex or the per-CPU hard
and soft interrupt paths for low latency. This comes at a small
cost to some interrupt latency, since we may stir the pool in
interrupt context -- but only for a very short window early at boot
between configure and configure2, so it's hard to imagine it
matters much.

- Allow rnd_add_uint32 to run in hard interrupt context or with spin
locks held, but defer processing to softint and drop samples on the
floor if buffer is full. This is mainly used for cheaply tossing
samples from drivers for non-HWRNG devices into the entropy pool,
so it is often used from interrupt context and/or under spin locks.

- New rnd_add_data_intr provides the interrupt-like data entry path
for arbitrary buffers and driver-specified entropy estimates: defer
processing to softint and drop samples on the floor if buffer is
full.

- Document that rnd_add_data is forbidden under spin locks outside
interrupt context (will crash in LOCKDEBUG), and inadvisable in
interrupt context (but technically permitted just in case there are
compatibility issues for now); later we can forbid it altogether in
interrupt context or under spin locks.

- Audit all uses of rnd_add_data to use rnd_add_data_intr where it
might be used in interrupt context or under a spin lock.

This fixes a regression from last year when the global entropy lock
was changed from IPL_VM (spin) to IPL_SOFTSERIAL (adaptive). Thought
I'd caught all the problems from that, but another one bit three
different people this week, presumably because of recent changes that
led to more non-HWRNG drivers entering the entropy consolidation
path from rnd_add_uint32.

In my attempt to preserve the rnd(9) API for the (now long-since
abandoned) prospect of pullup to netbsd-9 in my rewrite of the
entropy subsystem in 2020, I didn't introduce a separate entry point
for entering entropy from interrupt context or equivalent, i.e., spin
locks held, and instead made rnd_add_data rely on cpu_intr_p() to
decide whether to process the whole sample under a lock or only take
as much as there's buffer space for before scheduling a softint. In
retrospect, that was a mistake (though perhaps not as much of a
mistake as other entropy API decisions...), a mistake which is
finally getting rectified now by rnd_add_data_intr.

XXX pullup-10
 1.81 06-May-2023  andvar s/Regiser/Register/ and s/regester/register/ in comments.
 1.80 22-May-2022  riastradh branches: 1.80.4;
opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.
 1.79 22-May-2022  riastradh hifn(4): Prune dead branches. Assert session id validity.
 1.78 22-May-2022  riastradh hifn(4): Make ERESTART return more obvious.
 1.77 22-May-2022  riastradh hifn(4): Nix dead code. crp and callback are guaranteed nonnull.
 1.76 22-May-2022  riastradh hifn(4): hifn_compression always returns zero. Prune dead branches.
 1.75 22-May-2022  riastradh hifn(4): Fix error branches to do crypto_done, not return error.
 1.74 17-May-2020  riastradh pool_cache_prime, not pool_cache_lowat, as suggested by nick.
 1.73 17-May-2020  riastradh Missed a spot.
 1.72 17-May-2020  riastradh Rework hifn(4) RNG logic.

Previously we would read 34 bits of entropy into the pool and stop,
never to try again. This change finishes the conversion to an
on-demand source, although we still use a callout to (a) try again in
another second if the 7811 FIFO was emptied, and (b) wait at least
0.4 sec after we start the RNG to read anything from it as the
alleged documentation allegedly recommends.
 1.71 17-May-2020  riastradh Tweak locking and use a pool cache for commands and dmamaps.

This is enough to get the crypto decelerator working in LOCKDEBUG;
previously it would crash the moment you looked at it.
 1.70 17-May-2020  riastradh Merge updates from OpenBSD's hifn(4) crypto decelerator driver.

Highlights:

- Apply a ten-year-old fix to the driver's misuse of previously
exposed ciphertext as IV for the next ciphertext with CBC.

(Someone^TM should make sure there are no other drivers still doing
this...)

- Various zeroing of buffers.

- Various minor cosmetic changes.
 1.69 17-May-2020  riastradh Remove bogus comment.
 1.68 17-May-2020  riastradh De-#ifdef __OpenBSD__ify hifn7751.c.

Not really helpful; we can just use diff3 to merge updates.
 1.67 30-Apr-2020  riastradh rnd_attach_source calls the callback itself now.

No need for every driver to explicitly call it to prime the pool.

Eliminate now-unused <sys/rndpool.h>.
 1.66 30-Apr-2020  riastradh Don't attach rndsource until it's actually ready to run.
 1.65 29-Feb-2020  mlelstv Fix signed/unsigned comparisons. Send data little endian.
 1.64 18-Feb-2020  msaitoh No functional change:

- u_int*_t -> uint*_t
- whitespace fixes.
- KNF.
 1.63 27-Dec-2018  maxv branches: 1.63.6;
Remove M_COPY_PKTHDR, M_MOVE_PKTHDR, M_ALIGN and MH_ALIGN.
 1.62 05-Oct-2018  msaitoh Use pci_intr_establish_xname().
 1.61 14-May-2015  maxv branches: 1.61.16; 1.61.18;
Use-after-free. Found by Brainy.

ok christos@
 1.60 09-May-2015  riastradh Defer to a callout in hifn_rng_get. Fixes lock-against-self.

Still can't call rnd_add_data directly from an rndsource callback.

(Still plan to fix this with further rnd rototilling.)

XXX pullup netbsd-7
 1.59 09-May-2015  mrg initialise sc_mtx slightly earlier, before it is used on systems with rng.

fixes problem reported by msaitoh@.
 1.58 27-Apr-2015  christos fix mbuf leak on failure (Brainy)
 1.57 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.56 10-Aug-2014  tls branches: 1.56.2; 1.56.4;
Merge tls-earlyentropy branch into HEAD.
 1.55 03-Jun-2014  msaitoh Avoid buffer overflow which was added in rev. 1.52.
This change fix a panic at boot time (PR#47950 Reported by Bert Kiers).

OK'd by tls.
 1.54 29-Mar-2014  christos branches: 1.54.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.53 03-Jan-2014  pgoyette Modularize
 1.52 13-Jun-2013  tls branches: 1.52.2;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.51 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.50 02-Feb-2012  tls branches: 1.50.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.49 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.48 29-Nov-2011  tls branches: 1.48.2;
Remove rnd_extract_data from the public kernel API (it is for use by the
stream generators only). Clean up some related minor issues.
 1.47 19-Nov-2011  tls First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.46 13-Nov-2010  uebayasi branches: 1.46.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.45 16-Jun-2010  hubertf Make debug message print more than the device name

OK mbalmer, jmcneill
 1.44 01-Feb-2010  hubertf branches: 1.44.2; 1.44.4;
Use uppercase for acronyms on output: DRAM, SRAM
 1.43 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.42 28-Apr-2009  dyoung Use device_t, cfdata_t, and device_private().
 1.41 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.40 18-Mar-2009  cegger bcopy -> memcpy
 1.39 18-Mar-2009  cegger bzero -> memset
 1.38 18-Mar-2009  cegger bcmp -> memcmp
 1.37 10-Apr-2008  cegger branches: 1.37.4; 1.37.12; 1.37.18;
use aprint_*_dev and device_xname
 1.36 02-Feb-2008  tls branches: 1.36.6;
From Darran Hunt at Coyote Point: don't truncate HMAC to 96 bits unless
actually asked to.

Fixed in FreeBSD a while ago, discussed on tech-kern and tech-crypto.
 1.35 09-Jul-2007  ad branches: 1.35.8; 1.35.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.34 04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 16-Nov-2006  christos branches: 1.33.4;
__unused removal on arguments; approved by core.
 1.32 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.31 30-Aug-2006  christos branches: 1.31.2; 1.31.4;
static goes first
 1.30 28-Mar-2006  thorpej Use device_unit().
 1.29 25-Nov-2005  thorpej branches: 1.29.4; 1.29.6; 1.29.8; 1.29.10; 1.29.12;
- De-couple the software crypto implementation from the rest of the
framework. There is no need to waste the space if you are only using
algoritms provided by hardware accelerators. To get the software
implementations, add "pseudo-device swcr" to your kernel config.
- Lazily initialize the opencrypto framework when crypto drivers
(either hardware or swcr) register themselves with the framework.
 1.28 16-Oct-2005  tls branches: 1.28.6;
From Gilles Roy <groy@qnx.com>: don't increment buffer pointer twice
(once before callback, once *in* callback) for MAC transforms. How did
this driver ever work at all without this?
 1.27 16-Oct-2005  tls HAVE_CRYPTO_LZS, not HAVE_CRYPTO_LSZ (worse, it was inconsistently used)
 1.26 16-Oct-2005  tls Don't use rnd_extract_data to set up IVs for new sessions; it is very
expensive, and pointless. As elsewhere in the kernel (and as approved
under FIPS-140-2 by multiple test labs, incidentally) we use arc4 to
generate IVs here; there is no benefit to their being cryptographically
strong so long as there is a sufficient Hamming distance between them.
 1.25 15-Oct-2005  tls Add support for the hardware random number generator on the Hifn 7811
and 795x. This was present in the driver before, but disabled due to
problems with the actual randomness of generated numbers on the
ubiquitious 7900-series parts. The code here is far, far more
conservative than anyone else's driver for this RNG is -- but I
believe that conservatism is called for, because the 79xx RNG
design is missing a number of pieces from Hifn's "reference" 6500
RNG, and thus the numbers it generates must be treated with some
care.

Support for the 7811 RNG (which is a full-fledged 6500 type
generator) is pretty much the same here as in other variants of
this driver, except that it uses Hifn's "worst case" estimate of
actual entropy per output bit, so it will accumulate bits much
more slowly. The 7811 support is untested.
 1.24 15-Oct-2005  tls From OpenBSD hifn7751.c revision 1.149: enable the command-wait interrupt
even if there's only one request in the queue. Sometimes we seem to miss
multiple interrupts, and command-wait saves us.
 1.23 28-Jun-2005  thorpej branches: 1.23.2;
Use ANSI function decls and static.
 1.22 27-Feb-2005  perry nuke trailing whitespace
 1.21 29-Apr-2004  jonathan branches: 1.21.4; 1.21.6;
Identify AES-capable chips (7955, 7956) in the driver attach message.
 1.20 16-Nov-2003  jonathan branches: 1.20.2;
Support symmetric crypto ops, including AES, on hifn 7955 and 7956.
Not tested on 795[56], but compiles and matches FreeBSD-tested diffs.

Suggested by Sam Leffler <sam@errno.com>, as imported into FreeBSD by Sam.
Submitted to FreeBSD by Rajesh Vaidyanath <RVaidyanath@hifn.com>.
 1.19 28-Aug-2003  thorpej Remove an unnececssary PCI config read.
 1.18 28-Aug-2003  thorpej Hi/Fn is now spelled Hifn.
 1.17 28-Aug-2003  thorpej ANSI'ify (matches change in openbsd v1.140 of this file).
 1.16 28-Aug-2003  thorpej Print out a bit more information about which part is present at attach
time, generally tidy up autoconfiguration messages.
 1.15 30-Jul-2003  jonathan Discard previous driver; it didnt really do anything.

Replace with a new from-scratch port of recent OpenBSD hifn7751 source,
with changes to the crypto-framework calls to fit Sam Leffler's rework.
(Some of the attach-time changes from the previous driver were carried over).
Many thanks to Quentin Garnier (cube@cubidou.net) for testing an pre-release
of the driver and finding a couple of missing initializations.

Note that RNG support is temporarily disabled, until a potential issue
with RNG quality is investigated and resolved.
 1.14 03-May-2003  wiz branches: 1.14.2;
DMA, not dma nor Dma.
 1.13 31-Jan-2003  thorpej Use aprint_*().
 1.12 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.11 06-Jan-2003  wiz interrupt with two rs.
 1.10 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.9 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.7 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.6 13-Nov-2001  lukem add RCSID
 1.5 07-Jul-2001  thorpej branches: 1.5.2;
bcmp -> memcmp
 1.4 07-Jul-2001  thorpej bzero -> memset
 1.3 07-Jul-2001  thorpej bcopy -> memcpy
 1.2 28-Dec-2000  sommerfeld branches: 1.2.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.1 12-Oct-2000  itojun branches: 1.1.2;
hifn7751 crypto card driver. from openbsd.
does nothing useful at this moment - initailize the chip, that's all.
TODO: crypto logic framework in kernel (see openbsd sys/crypto)
TODO: ipsec frontend (need major rework in ipsec tree - should start with busywait)
TODO: character device frontend
 1.1.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 12-Oct-2000  bouyer file hifn7751.c was added on branch thorpej_scsipi on 2000-11-20 11:42:20 +0000
 1.2.2.5 07-Jan-2003  thorpej Sync with HEAD.
 1.2.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.5.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.6 11-Dec-2005  christos Sync with head.
 1.14.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.2.1 05-May-2004  tron Pull up revision 1.21 (requested by jonathan in ticket #239):
Identify AES-capable chips (7955, 7956) in the driver attach message.
 1.21.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.4.1 29-Apr-2005  kent sync with -current
 1.23.2.4 04-Feb-2008  yamt sync with head.
 1.23.2.3 03-Sep-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 21-Jun-2006  yamt sync with head.
 1.28.6.1 29-Nov-2005  yamt sync with head.
 1.29.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.29.10.1 19-Apr-2006  elad sync with head.
 1.29.8.2 03-Sep-2006  yamt sync with head.
 1.29.8.1 01-Apr-2006  yamt sync with head.
 1.29.6.1 22-Apr-2006  simonb Sync with head.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.31.4.2 10-Dec-2006  yamt sync with head.
 1.31.4.1 22-Oct-2006  yamt sync with head
 1.31.2.1 18-Nov-2006  ad Sync with head.
 1.33.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.35.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.35.8.1 23-Mar-2008  matt sync with HEAD
 1.36.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.37.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.37.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.37.4.3 11-Aug-2010  yamt sync with head.
 1.37.4.2 11-Mar-2010  yamt sync with head
 1.37.4.1 04-May-2009  yamt sync with head.
 1.44.4.2 05-Mar-2011  rmind sync with head
 1.44.4.1 03-Jul-2010  rmind sync with head
 1.44.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.46.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.8.2 30-Oct-2012  yamt sync with head
 1.46.8.1 17-Apr-2012  yamt sync with head
 1.48.2.1 18-Feb-2012  mrg merge to -current.
 1.50.6.4 03-Dec-2017  jdolecek update from HEAD
 1.50.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.6.2 23-Jun-2013  tls resync from head
 1.50.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.52.2.1 18-May-2014  rmind sync with head
 1.54.2.2 10-Aug-2014  tls Rebase.
 1.54.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.56.4.1 06-Jun-2015  skrll Sync with HEAD
 1.56.2.3 15-May-2015  snj Pull up following revision(s) (requested by maxv in ticket #763):
sys/dev/pci/hifn7751.c: revisions 1.58, 1.61
fix mbuf leak on failure (Brainy)
--
Use-after-free. Found by Brainy.
 1.56.2.2 11-May-2015  msaitoh Pull up following revision(s) (requested by mrg in ticket #750):
sys/dev/pci/hifn7751.c: revision 1.59
initialise sc_mtx slightly earlier, before it is used on systems with rng.
fixes problem reported by msaitoh@.
 1.56.2.1 11-May-2015  msaitoh Pull up following revision(s) (requested by riastradh in ticket #748):
sys/dev/pci/hifn7751.c: revision 1.60
Defer to a callout in hifn_rng_get. Fixes lock-against-self.
Still can't call rnd_add_data directly from an rndsource callback.
(Still plan to fix this with further rnd rototilling.)
XXX pullup netbsd-7
 1.61.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.61.18.1 10-Jun-2019  christos Sync with HEAD
 1.61.16.2 18-Jan-2019  pgoyette Synch with HEAD
 1.61.16.1 20-Oct-2018  pgoyette Sync with head
 1.63.6.1 29-Feb-2020  ad Sync with head.
 1.80.4.1 11-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #319):

sys/dev/pci/ubsec.c: revision 1.64
sys/dev/pci/hifn7751.c: revision 1.82
lib/libc/gen/getentropy.3: revision 1.5
lib/libc/gen/getentropy.3: revision 1.6
share/man/man4/rnd.4: revision 1.41
lib/libc/sys/getrandom.2: revision 1.2
lib/libc/sys/getrandom.2: revision 1.3
share/man/man5/rc.conf.5: revision 1.193
share/man/man7/entropy.7: revision 1.5
share/man/man7/entropy.7: revision 1.6
share/man/man7/entropy.7: revision 1.7
share/man/man7/entropy.7: revision 1.8
etc/security: revision 1.130
share/man/man7/entropy.7: revision 1.9
etc/security: revision 1.131
sys/crypto/cprng_fast/cprng_fast.c: revision 1.19
sys/sys/rndio.h: revision 1.3
tests/lib/libc/sys/t_getrandom.c: revision 1.5
etc/defaults/rc.conf: revision 1.164
etc/defaults/rc.conf: revision 1.165
sys/sys/rndsource.h: revision 1.10
sys/kern/kern_entropy.c: revision 1.62
sys/kern/kern_entropy.c: revision 1.63
sys/kern/kern_entropy.c: revision 1.64
sys/kern/subr_cprng.c: revision 1.44
sys/kern/kern_entropy.c: revision 1.65
sys/kern/kern_clock.c: revision 1.149
sys/dev/pci/viornd.c: revision 1.22
share/man/man9/rnd.9: revision 1.32
sys/kern/subr_prf.c: revision 1.202
sys/sys/rndsource.h: revision 1.8
sys/sys/rndsource.h: revision 1.9
share/man/man7/entropy.7: revision 1.10

1. Reinstate netbsd<=9 entropy estimator to unblock /dev/random, in
parallel with assessment of only confident entropy sources (seed,
HWRNG) for security warnings like sshd keys in motd and daily
insecurity report.

2. Make multiuser boot wait for first /dev/random output soon after
loading a seed and configuring rndctl, so that getentropy(3) meets
its contract starting early at boot without introducing blocking
paths that could cause hangs in init(8) or single-user mode.
Operators can choose to disable this wait in rc.conf.

3. Fix some bugs left over from reducing the global entropy lock from
a spin lock at IPL_VM to an adaptive lock at IPL_SOFTSERIAL.

4. Update man pages.
 1.9 17-May-2020  riastradh Reduce diffs from OpenBSD hifn(4) header files.
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 27-Feb-2005  perry nuke trailing whitespace
 1.6 13-Feb-2004  wiz branches: 1.6.8; 1.6.10;
Spell length with h after t. Inspired by a commit by brad@openbsd.
 1.5 16-Nov-2003  jonathan Support symmetric crypto ops, including AES, on hifn 7955 and 7956.
Not tested on 795[56], but compiles and matches FreeBSD-tested diffs.

Suggested by Sam Leffler <sam@errno.com>, as imported into FreeBSD by Sam.
Submitted to FreeBSD by Rajesh Vaidyanath <RVaidyanath@hifn.com>.
 1.4 30-Jul-2003  jonathan Discard previous driver; it didnt really do anything.

Replace with a new from-scratch port of recent OpenBSD hifn7751 source,
with changes to the crypto-framework calls to fit Sam Leffler's rework.
(Some of the attach-time changes from the previous driver were carried over).
Many thanks to Quentin Garnier (cube@cubidou.net) for testing an pre-release
of the driver and finding a couple of missing initializations.

Note that RNG support is temporarily disabled, until a potential issue
with RNG quality is investigated and resolved.
 1.3 13-May-2003  wiz branches: 1.3.2;
Typos from Jean-Francois Brousseau, via jmc@openbsd.
 1.2 06-Jan-2003  wiz descriptor with a c.
 1.1 12-Oct-2000  itojun branches: 1.1.2; 1.1.4;
hifn7751 crypto card driver. from openbsd.
does nothing useful at this moment - initailize the chip, that's all.
TODO: crypto logic framework in kernel (see openbsd sys/crypto)
TODO: ipsec frontend (need major rework in ipsec tree - should start with busywait)
TODO: character device frontend
 1.1.4.1 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 12-Oct-2000  bouyer file hifn7751reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:20 +0000
 1.3.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.18 03-Dec-2021  andvar fix various typos in comments, log messages and documentation.
 1.17 17-May-2020  riastradh Rework hifn(4) RNG logic.

Previously we would read 34 bits of entropy into the pool and stop,
never to try again. This change finishes the conversion to an
on-demand source, although we still use a callout to (a) try again in
another second if the 7811 FIFO was emptied, and (b) wait at least
0.4 sec after we start the RNG to read anything from it as the
alleged documentation allegedly recommends.
 1.16 17-May-2020  riastradh Tweak locking and use a pool cache for commands and dmamaps.

This is enough to get the crypto decelerator working in LOCKDEBUG;
previously it would crash the moment you looked at it.
 1.15 17-May-2020  riastradh Merge updates from OpenBSD's hifn(4) crypto decelerator driver.

Highlights:

- Apply a ten-year-old fix to the driver's misuse of previously
exposed ciphertext as IV for the next ciphertext with CBC.

(Someone^TM should make sure there are no other drivers still doing
this...)

- Various zeroing of buffers.

- Various minor cosmetic changes.
 1.14 17-May-2020  riastradh Reduce diffs from OpenBSD hifn(4) header files.
 1.13 17-May-2020  riastradh De-#ifdef __OpenBSD__ify hifn7751.c.

Not really helpful; we can just use diff3 to merge updates.
 1.12 14-Apr-2015  riastradh Include <sys/rndsource.h> where it is actually used.

I had removed <sys/rnd.h> from files that didn't mention anything of
the rnd(9) API. But they included other files which assumed
<sys/rnd.h> had already been included.
 1.11 03-Jan-2014  pgoyette branches: 1.11.6;
Modularize
 1.10 13-Jun-2013  tls branches: 1.10.2;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.9 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.8 19-Nov-2011  tls branches: 1.8.8;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.7 11-Dec-2005  christos branches: 1.7.110;
merge ktrace-lwp.
 1.6 15-Oct-2005  tls Add support for the hardware random number generator on the Hifn 7811
and 795x. This was present in the driver before, but disabled due to
problems with the actual randomness of generated numbers on the
ubiquitious 7900-series parts. The code here is far, far more
conservative than anyone else's driver for this RNG is -- but I
believe that conservatism is called for, because the 79xx RNG
design is missing a number of pieces from Hifn's "reference" 6500
RNG, and thus the numbers it generates must be treated with some
care.

Support for the 7811 RNG (which is a full-fledged 6500 type
generator) is pretty much the same here as in other variants of
this driver, except that it uses Hifn's "worst case" estimate of
actual entropy per output bit, so it will accumulate bits much
more slowly. The 7811 support is untested.
 1.5 27-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 16-Nov-2003  jonathan branches: 1.4.8; 1.4.10;
Support symmetric crypto ops, including AES, on hifn 7955 and 7956.
Not tested on 795[56], but compiles and matches FreeBSD-tested diffs.

Suggested by Sam Leffler <sam@errno.com>, as imported into FreeBSD by Sam.
Submitted to FreeBSD by Rajesh Vaidyanath <RVaidyanath@hifn.com>.
 1.3 30-Jul-2003  jonathan Discard previous driver; it didnt really do anything.

Replace with a new from-scratch port of recent OpenBSD hifn7751 source,
with changes to the crypto-framework calls to fit Sam Leffler's rework.
(Some of the attach-time changes from the previous driver were carried over).
Many thanks to Quentin Garnier (cube@cubidou.net) for testing an pre-release
of the driver and finding a couple of missing initializations.

Note that RNG support is temporarily disabled, until a potential issue
with RNG quality is investigated and resolved.
 1.2 13-May-2003  wiz branches: 1.2.2;
Typos from Jean-Francois Brousseau, via jmc@openbsd.
 1.1 12-Oct-2000  itojun branches: 1.1.2;
hifn7751 crypto card driver. from openbsd.
does nothing useful at this moment - initailize the chip, that's all.
TODO: crypto logic framework in kernel (see openbsd sys/crypto)
TODO: ipsec frontend (need major rework in ipsec tree - should start with busywait)
TODO: character device frontend
 1.1.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 12-Oct-2000  bouyer file hifn7751var.h was added on branch thorpej_scsipi on 2000-11-20 11:42:20 +0000
 1.2.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.8.1 29-Apr-2005  kent sync with -current
 1.5.4.1 21-Jun-2006  yamt sync with head.
 1.7.110.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.110.2 30-Oct-2012  yamt sync with head
 1.7.110.1 17-Apr-2012  yamt sync with head
 1.8.8.4 03-Dec-2017  jdolecek update from HEAD
 1.8.8.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.8.2 23-Jun-2013  tls resync from head
 1.8.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.10.2.1 18-May-2014  rmind sync with head
 1.11.6.1 06-Jun-2015  skrll Sync with HEAD
 1.35 28-May-2022  andvar fix various typos in comments.
 1.34 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.33 31-Jul-2012  bouyer branches: 1.33.2; 1.33.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.32 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.31 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.30 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.29 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.28 04-Apr-2011  dyoung branches: 1.28.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.27 05-Nov-2010  jakllsch branches: 1.27.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.26 19-Oct-2009  bouyer branches: 1.26.2; 1.26.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.25 18-Mar-2008  cube branches: 1.25.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.24 09-Feb-2007  ad branches: 1.24.20; 1.24.36; 1.24.40;
Merge newlock2 to head.
 1.23 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.22 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21 05-Aug-2006  xtraeme branches: 1.21.4; 1.21.6;
HPT368 support. Patch from Jonathan A. Kollasch via PR kern/34097.

Thanks.
 1.20 16-Jan-2006  bouyer branches: 1.20.2; 1.20.6;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.19 11-Dec-2005  christos branches: 1.19.2;
merge ktrace-lwp.
 1.18 24-May-2005  lukem branches: 1.18.2;
add __KERNEL_RCSID
 1.17 27-Feb-2005  perry branches: 1.17.2;
nuke trailing whitespace
 1.16 21-Aug-2004  thorpej branches: 1.16.4; 1.16.6;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.15 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.14 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.13 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.12 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.11 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.10 02-Aug-2004  bouyer branches: 1.10.2;
Don't map the interrupt in pciide_mapregs_compat().
In default_chip_map() we'll do further checks to see if the channel should
really be enabled, and in case it's not we would keep the interrupt mapped.
Fix kern/26502 from Christian Biere.
 1.9 03-Jan-2004  thorpej branches: 1.9.2;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.8 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.7 28-Nov-2003  chs add support for HPT302 and HPT371. simplify timing selection.
adapted from OpenBSD. tested on an HPT302, review by bouyer@.
 1.6 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.5 29-Oct-2003  mycroft Rework slightly to remove bogus initializer.
 1.4 25-Oct-2003  christos Fix uninitialized variable warnings
 1.3 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.9.2.1 11-Aug-2004  jmc Pullup rev 1.10 (requested by bouyer in ticket #734)

Don't map the interrupt in pciide_mapregs_compat().
In default_chip_map() we'll do further checks to see if the channel should
really be enabled, and in case it's not we would keep the interrupt mapped.
PR#26502
 1.10.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.10.2.2 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 02-Aug-2004  skrll file hptide.c was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.16.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.16.4.1 29-Apr-2005  kent sync with -current
 1.17.2.1 06-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1455):
sys/dev/pci/hptide.c: revision 1.21
sys/dev/pci/pciide_hpt_reg.h: revision 1.14
HPT368 support. Patch from Jonathan A. Kollasch via PR kern/34097.
Thanks.
 1.18.2.4 24-Mar-2008  yamt sync with head.
 1.18.2.3 26-Feb-2007  yamt sync with head.
 1.18.2.2 30-Dec-2006  yamt sync with head.
 1.18.2.1 21-Jun-2006  yamt sync with head.
 1.19.2.1 01-Feb-2006  yamt sync with head.
 1.20.6.1 11-Aug-2006  yamt sync with head
 1.20.2.1 09-Sep-2006  rpaulo sync with head
 1.21.6.2 10-Dec-2006  yamt sync with head.
 1.21.6.1 22-Oct-2006  yamt sync with head
 1.21.4.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.21.4.1 18-Nov-2006  ad Sync with head.
 1.24.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.36.1 24-Mar-2008  keiichi sync with head.
 1.24.20.1 23-Mar-2008  matt sync with HEAD
 1.25.4.1 11-Mar-2010  yamt sync with head
 1.26.4.2 21-Apr-2011  rmind sync with head
 1.26.4.1 05-Mar-2011  rmind sync with head
 1.26.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.4.1 30-Oct-2012  yamt sync with head
 1.33.4.1 18-May-2014  rmind sync with head
 1.33.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.5 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.4 19-Jan-2001  martin Nuke all uses of splimp() in the isdn subsystem, replace by splnet().
 1.3 11-Jan-2001  martin Move interrupt mapping before initialization of the card (which might
cause interrupts). This works around a problem on sparc64, where
interrupts without installed handler seem to cause heavy lossage (and
interrupts are already enabled at this stage of autoconfiguration).
 1.2 10-Jan-2001  martin Make the driver try mapping memory first, the try io.
 1.1 05-Jan-2001  martin branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jan-2001  martin branches: 1.1.1.1.2;
Initial import of ISDN4BSD release 0.96
 1.1.1.1.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.1.1.1.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.1.1.1.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.1.1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.1.1.2.1 05-Jan-2001  bouyer file i4b_avm_fritz_pci.c was added on branch thorpej_scsipi on 2001-01-05 17:36:04 +0000
 1.3 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.2 10-Jan-2001  martin Prefer memory mapping over io mapping for this card too,
although it doesn't have a chance to work on a no-io system because
of an io based BAR lacking a mem counterpart.
 1.1 05-Jan-2001  martin branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jan-2001  martin branches: 1.1.1.1.2;
Initial import of ISDN4BSD release 0.96
 1.1.1.1.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.1.1.1.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.1.1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.1.1.2.1 05-Jan-2001  bouyer file i4b_elsa_qs1p.c was added on branch thorpej_scsipi on 2001-01-05 17:36:04 +0000
 1.33 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.32 17-Sep-2009  tsutsui branches: 1.32.12; 1.32.22;
Misc KNF and cosmetics, and remove unnecessary casts etc.
 1.31 14-Sep-2009  tsutsui Use device_private(), proper types or variables for device_t and softc.
(not yet split though)

No crash on gxemul emulating hpcmips mobilepro.
 1.30 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.29 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.28 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.27 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.26 26-Jun-2008  drochner branches: 1.26.4; 1.26.10;
constify the pcmcia/cardbus method tables
 1.25 10-Apr-2008  cegger branches: 1.25.4; 1.25.6; 1.25.8;
use aprint_*_dev and device_xname
 1.24 16-Nov-2006  christos branches: 1.24.48;
__unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 30-Aug-2006  christos branches: 1.22.2; 1.22.4;
add missing initializers.
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.8;
merge ktrace-lwp.
 1.20 30-May-2005  christos branches: 1.20.2;
- const poisoning
- avoid variable shadowing.
 1.19 04-Feb-2005  perry de-__P
 1.18 11-Aug-2004  mycroft branches: 1.18.4; 1.18.6;
Rather than having a call up from the low-level driver to get the card type,
instead have a call down from the PCMCIA mid-layer to set it. Use this from
pcmcia_function_enable(). (Currently the policy is the same, but this would
allow for more flexibility in deciding which mode to use.)

Now it is safe to hold the socket enabled during attach, so do that. Only
one enable/disable cycle to attach a card now!
 1.17 31-Jan-2003  thorpej branches: 1.17.2;
Use aprint_*().
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.12 13-Nov-2001  lukem add RCSID
 1.11 24-Feb-2000  itohy branches: 1.11.6; 1.11.8;
Delete a superfluous newline in attach message.
 1.10 22-Feb-2000  enami Include dev/isa/isavar.h so that this file compiles again.
 1.9 22-Feb-2000  thorpej Don't use void * for chipset tags. Bad hacker, no biscuit.
 1.8 01-Feb-2000  chopps implement probing for available irqs on non-cirrus pcmcia controllers
including cardbus controllers running in pcic mode
 1.7 20-Dec-1998  nathanw branches: 1.7.8;
Fix up support for PCI attachments of pcic devices on i386 in general,
and the Cirrus Logic CL-PD6729 in particular.

From danw@mit.edu in PR port-i386/6436.
 1.6 17-Dec-1998  msaitoh fix an invalid panic message.
 1.5 30-Nov-1998  jtk Per PR/6172 (Johnny Lam, lamj@stat.cmu.edu), fix pcidevs identification
of CL-PD6729. See <http://www.cirrus.com/products/overviews/pd6729.html>.
 1.4 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.3 23-May-1998  matt Changes so that these compile on NetBSD/alpha as well as NetBSD/i386.
 1.2 16-Oct-1997  thorpej Pull marc-pcmcia branch down from trunk.
 1.1 28-Aug-1997  marc branches: 1.1.2;
file i82365_pci.c was initially added on branch marc-pcmcia.
 1.1.2.4 16-Oct-1997  thorpej Copyright/license update.
 1.1.2.3 16-Oct-1997  thorpej KNF.
 1.1.2.2 27-Sep-1997  marc add io bus info. this whole file is a hack, really, so it's ok that
this is, too.
 1.1.2.1 28-Aug-1997  marc pci-specific code from i82365 driver bus split. This code needs some
serious help before it's likely to work, let alone be reasonable.
 1.7.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.11.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.11.6.1 14-Nov-2001  nathanw Catch up to -current.
 1.17.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.17.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.1 12-Aug-2004  skrll Sync with HEAD.
 1.18.6.1 12-Feb-2005  yamt sync with head.
 1.18.4.1 29-Apr-2005  kent sync with -current
 1.20.2.1 30-Dec-2006  yamt sync with head.
 1.21.8.1 03-Sep-2006  yamt sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.22.4.2 10-Dec-2006  yamt sync with head.
 1.22.4.1 22-Oct-2006  yamt sync with head
 1.22.2.1 18-Nov-2006  ad Sync with head.
 1.24.48.2 29-Jun-2008  mjf Sync with HEAD.
 1.24.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.8.1 27-Jun-2008  simonb Sync with head.
 1.25.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.25.4.4 11-Mar-2010  yamt sync with head
 1.25.4.3 16-Sep-2009  yamt sync with head
 1.25.4.2 16-May-2009  yamt sync with head
 1.25.4.1 04-May-2009  yamt sync with head.
 1.26.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.32.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.32.12.1 30-Oct-2012  yamt sync with head
 1.7 17-Sep-2009  tsutsui Misc KNF and cosmetics, and remove unnecessary casts etc.
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.70; 1.5.72; 1.5.74;
merge ktrace-lwp.
 1.4 27-Feb-2005  perry nuke trailing whitespace
 1.3 04-Feb-2005  perry de-__P
 1.2 22-Feb-2000  thorpej branches: 1.2.28; 1.2.36; 1.2.38;
Don't use void * for chipset tags. Bad hacker, no biscuit.
 1.1 20-Dec-1998  nathanw branches: 1.1.8;
Fix up support for PCI attachments of pcic devices on i386 in general,
and the Cirrus Logic CL-PD6729 in particular.

From danw@mit.edu in PR port-i386/6436.
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.38.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.38.1 12-Feb-2005  yamt sync with head.
 1.2.36.1 29-Apr-2005  kent sync with -current
 1.2.28.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.28.1 04-Feb-2005  skrll Sync with HEAD.
 1.5.74.2 11-Mar-2010  yamt sync with head
 1.5.74.1 16-May-2008  yamt sync with head.
 1.5.72.1 18-May-2008  yamt sync with head.
 1.5.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.18 21-Sep-2018  maxv Remove iavc(4).
 1.17 11-Jul-2016  msaitoh branches: 1.17.16; 1.17.18;
KNF. No functional change.
 1.16 29-Mar-2014  christos branches: 1.16.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.15 25-Sep-2013  martin Avoid using unmaped PCI registers. From Wolfgang Stukenbrock in
PR kern/48236.
 1.14 27-Oct-2012  chs branches: 1.14.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.13 06-Dec-2009  dyoung branches: 1.13.12; 1.13.22;
Delete dead code: a device-activation hook.
 1.12 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.11 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.10 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.9 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.8 10-Apr-2008  cegger branches: 1.8.4; 1.8.18;
use aprint_*_dev and device_xname
 1.7 19-Oct-2007  ad branches: 1.7.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 16-Nov-2006  christos branches: 1.6.8; 1.6.22; 1.6.24; 1.6.28;
__unused removal on arguments; approved by core.
 1.5 16-Oct-2006  pooka * __unused games + other relevant fixes
* give me ANSI C or give me death (at least where it could be easily spotted)
 1.4 11-Dec-2005  christos branches: 1.4.20; 1.4.22;
merge ktrace-lwp.
 1.3 11-May-2005  martin branches: 1.3.2;
From Wolfgang Stukenbrock in PR kern/30197: wrong type in CFATTACH_DECL.
 1.2 03-Oct-2003  pooka branches: 1.2.4; 1.2.8; 1.2.16;
Ready the kernel side of i4b for primary rate interface support by
removing assumptions that there are only two B channels and by
adding support for a varying number of channels.

Due to this, rename previously used isdn identified "bri" to "isdnif",
which better describes the current situation.
 1.1 25-Sep-2003  pooka Add a driver for the CAPI-compliant AVM B1/T1 cards.

The driver backend is capable of supporting also ISA cards (no DMA)
and primary rate (PRI) cards in addition to the basic rate ones,
but I don't any to test on right now, so we don't support those
currently.

This code was originally written by Juha-Matti Liukkonen <jml@cubical.fi>
of Cubical Solutions Ltd. for FreeBSD, and was ported to NetBSD by
myself for the same company.
 1.2.16.1 11-May-2005  tron Pull up revision 1.3 (requested by martin in ticket #295):
From Wolfgang Stukenbrock in PR kern/30197: wrong type in CFATTACH_DECL.
 1.2.8.1 16-May-2005  riz Pull up revision 1.3 (requested by martin in ticket #1513):
From Wolfgang Stukenbrock in PR kern/30197: wrong type in CFATTACH_DECL.
 1.2.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 03-Oct-2003  skrll file iavc_pci.c was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.3.2.2 27-Oct-2007  yamt sync with head.
 1.3.2.1 30-Dec-2006  yamt sync with head.
 1.4.22.2 10-Dec-2006  yamt sync with head.
 1.4.22.1 22-Oct-2006  yamt sync with head
 1.4.20.1 18-Nov-2006  ad Sync with head.
 1.6.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.24.1 06-Nov-2007  matt sync with HEAD
 1.6.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.8.1 23-Oct-2007  ad Sync with head.
 1.7.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.4.2 11-Mar-2010  yamt sync with head
 1.8.4.1 16-May-2009  yamt sync with head
 1.13.22.3 03-Dec-2017  jdolecek update from HEAD
 1.13.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.13.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.12.1 30-Oct-2012  yamt sync with head
 1.14.2.1 18-May-2014  rmind sync with head
 1.16.6.1 05-Oct-2016  skrll Sync with HEAD
 1.17.18.1 10-Jun-2019  christos Sync with HEAD
 1.17.16.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.5 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.4 24-Apr-2021  thorpej branches: 1.4.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.3 20-Jan-2017  maya branches: 1.3.30;
Check pmf_device_register return value. NFC
Appeases static analyzers.
 1.2 14-Jul-2016  msaitoh branches: 1.2.2; 1.2.4;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.1 17-Dec-2012  mbalmer branches: 1.1.2; 1.1.6; 1.1.18;
Adding ibmcd(4), a device driver for the IBM 4810 BSP cash drawer port as
found e.g. in SurePOS 300 series point of sale terminals. The driver
provides a gpio(4) device with three pins: pin 0 to open drawer, pin 1
to read the status and pin 2 to read whether a cash drawer is connected or
not.
 1.1.18.2 05-Feb-2017  skrll Sync with HEAD
 1.1.18.1 05-Oct-2016  skrll Sync with HEAD
 1.1.6.3 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 25-Feb-2013  tls resync with head
 1.1.6.1 17-Dec-2012  tls file ibmcd.c was added on branch tls-maxphys on 2013-02-25 00:29:17 +0000
 1.1.2.2 23-Jan-2013  yamt sync with head
 1.1.2.1 17-Dec-2012  yamt file ibmcd.c was added on branch yamt-pagecache on 2013-01-23 00:06:08 +0000
 1.2.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3.30.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.4.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 26-Aug-2007  xtraeme Move the ICH SMB defs to dev/ic/i82801lpcreg.h, it's where it belongs.
This is to avoid code duplication.
 1.1 28-Jul-2007  kiyohara branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add support for Intel ICH SMBus controller.
 1.1.10.2 28-Jul-2007  kiyohara Add support for Intel ICH SMBus controller.
 1.1.10.1 28-Jul-2007  kiyohara file ichreg.h was added on branch matt-mips64 on 2007-07-28 10:51:57 +0000
 1.1.8.3 09-Oct-2007  ad Sync with head.
 1.1.8.2 20-Aug-2007  ad Sync with HEAD.
 1.1.8.1 28-Jul-2007  ad file ichreg.h was added on branch vmlocking on 2007-08-20 22:07:04 +0000
 1.1.6.3 03-Sep-2007  skrll Sync with HEAD.
 1.1.6.2 15-Aug-2007  skrll Sync with HEAD.
 1.1.6.1 28-Jul-2007  skrll file ichreg.h was added on branch nick-csl-alignment on 2007-08-15 13:48:29 +0000
 1.1.4.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.87 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.86 18-Jan-2025  mrg match meteor lake's smbus.
 1.85 07-Aug-2023  msaitoh branches: 1.85.6;
ichsmb(4),ismt(4): Add Snow Ridge support.
 1.84 23-Jul-2023  msaitoh Add support Intel 700 series chipset and Alder Lake-N devices.
 1.83 30-May-2023  msaitoh Use device_printf() instead of aprint_error_dev().
 1.82 12-Apr-2023  riastradh ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.

Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.81 22-Sep-2022  riastradh branches: 1.81.4;
ichsmb(4): Remove confusing `lpcib_' prefix on register names.
 1.80 22-Sep-2022  riastradh ichsmb(4): Only rescan i2cbus child if requested.

This will let us rescan tcoichbus later too on devices where the TCO
(Intel platform controller hub watchdog timer) hangs off ichsmb(4)
instead of ichlpcib(4).
 1.79 22-Sep-2022  riastradh ichsmb(4): Use config_detach_children to simplify.
 1.78 22-Sep-2022  riastradh ichsmb(4): Attach i2c bus only once.

The child could be detached, e.g. with drvctl, and then the bus
rescanned, at which point it would reinitialize a mutex without
destroying it.
 1.77 13-Sep-2022  msaitoh Add Intel 600 series PCH-LP devices support.
 1.76 25-Jan-2022  msaitoh Add Intel 600 Series PCH (desktop) support.
 1.75 27-Oct-2021  msaitoh Add Elkhart Lake support.
 1.74 12-Oct-2021  msaitoh Add Intel 400 Series PCH-V devices.
 1.73 11-Oct-2021  msaitoh Add Intel 500 Series PCH-H SMBus.
 1.72 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.71 12-Jul-2021  msaitoh branches: 1.71.2;
Add Jasper Lake support.
 1.70 24-Apr-2021  thorpej branches: 1.70.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.69 15-Jan-2021  thorpej branches: 1.69.2;
- Match 400-, 495-, and 500-series controllers.
- Apply OpenBSD rev 1.38, which ignores the SMBALERT# interrupt that
fires spuriously on some systems (ignored by Linux and FreeBSD, as
well).
 1.68 22-Apr-2020  msaitoh branches: 1.68.2;
Add Whiskey Lake U and Amber Lake Y support.
 1.67 16-Apr-2020  msaitoh Add Comet Lake support.
 1.66 18-Feb-2020  msaitoh branches: 1.66.4;
Whitespace fix. No functional change.
 1.65 24-Dec-2019  thorpej branches: 1.65.2;
Make ichsmb and piixpm MP-safe:
- Synchronize with the interrupt handler using a mutex.
- Use a condvar to wait for completion, rather than tsleep().
- Mark our interrupt handler as such.

Also, other general correctness fixes:
- Loop around testing the completion condition to protect aginst
spurious wakes.
- The "i2c exec" function returns an error code, so actually do so.
 1.64 23-Dec-2019  thorpej ichsmb_i2c_exec(): No need to check 'cold' to force I2C_F_POLL; the i2c
upper layer does it for us.
 1.63 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.62 09-Dec-2019  ad Fix LOCKDEBUG panic on detach.
 1.61 21-Nov-2019  ad If attach fails, don't panic on detach.
 1.60 10-Dec-2018  jdolecek branches: 1.60.4;
call pci_intr_release() when pci_intr_establish_xname() fails; I got confused
by the opposite conditionals compared to other drivers

found by Masanobu SAITOH
 1.59 09-Dec-2018  jdolecek try to detach on shutdown; for now the only practical reason is to test that
the driver detach paths work
 1.58 09-Dec-2018  jdolecek convert to pci_intr_alloc() to possibly allow MSI/MSI-X; has no effect
on my system, where the device only supports INTx
 1.57 09-Apr-2018  msaitoh branches: 1.57.2;
Add 300 series chipset support.
 1.56 02-Mar-2018  msaitoh branches: 1.56.2;
Add Apollo Lake and Gemini Lake devices.
 1.55 28-Feb-2018  pgoyette Teach the ichsmb(4) driver how to detach.
 1.54 27-Feb-2018  pgoyette Add dependency on iic module to get access to iicbus_print()
 1.53 26-Feb-2018  pgoyette Modularize the ichsmb(4) driver. No functional changes.
 1.52 22-Feb-2018  msaitoh Add C620 devices.
 1.51 17-Aug-2017  msaitoh Add C3000 devices.
 1.50 31-Mar-2017  msaitoh branches: 1.50.6;
Remove extra 0x. This bug was added when replacing bitmask_snprintf(9) with
snprintb(3) (in between NetBSD 5 and 6). Old bitmask_snprint(9) didn't add
0x" automatically for hexadecimal value, so old code used it with "0x%s".
 1.49 15-Mar-2017  msaitoh Add another 100 Series SMBus (100SERIES_LP_SMB)
 1.48 15-Jan-2017  msaitoh branches: 1.48.2;
Add Intel 200 series devices.
 1.47 13-Oct-2016  jdolecek provide intr xname
 1.46 07-Jul-2016  msaitoh branches: 1.46.2;
KNF. Remove extra spaces. No functional change.
 1.45 10-Dec-2015  pgoyette Initialize the mutex before calling xxx_rescan(). Otherwise if we
load/attach an i2cbus at a later time (ie, load the iic module),
we'll end-up re-initializing the mutex.

(Caught with a LOCKDEBUG kernel)
 1.44 01-Dec-2015  msaitoh Add Intel 100 Series chipset's devices.
 1.43 16-Nov-2015  msaitoh Add Braswell PCU SMBus.
 1.42 03-May-2015  pgoyette Teach a couple of i2cbus controllers how to rescan. This enables
{,un}loading and {at,de}taching of the iic(4) driver/module at a
later time. Tested piixpm on QEMU, and ichsmb on my live server.
 1.41 02-Apr-2015  tnn attach Mobile 5th Gen. Core SMBus
 1.40 20-Mar-2015  msaitoh Add Intel C61x and X99 devices.
 1.39 18-Mar-2015  msaitoh Add 9 Series support.
 1.38 15-Dec-2014  msaitoh - Rename PCI_PRODUCT_INTEL_DH89XX_SMB to PCI_PRODUCT_INTEL_DH89XXCC_SMB
- Add PCI_PRODUCT_INTEL_DH89XXCL_SMB
 1.37 02-Jul-2014  riastradh branches: 1.37.2; 1.37.4;
Register a null pmf handler even if we failed to attach.

Keeps ichsmb(4) from preventing suspend even if it's broken because
of ichlpcib(4) grodiness.
 1.36 09-Jun-2014  msaitoh Add Tolapai, Coleto Creek and Bay Trail.
 1.35 29-Mar-2014  christos branches: 1.35.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.34 28-Dec-2013  msaitoh Add Intel C2000 PCU SMBus
 1.33 07-Nov-2013  msaitoh Add some Mobile 4th generation Intel Core Processor devices
(Lynx Point-LP).
 1.32 18-Jul-2013  soren Clear errors before beginning a transfer.

Closes PR port-i386/46792.
 1.31 18-Jul-2013  msaitoh Add Intel 8 Series SMBus.
 1.30 12-Jan-2013  riastradh branches: 1.30.2; 1.30.8;
Match the C600's other smbus controller.
 1.29 29-Nov-2012  msaitoh Add C600(and X79) SMBus devices.
 1.28 26-Nov-2012  riastradh Match the Intel 7 Series SMBus Controller in ichsmb(4).

Tested on a Thinkpad W530.
 1.27 14-Feb-2012  pgoyette branches: 1.27.2; 1.27.6;
Replace the xxx_acquire()/xxx_release() rwlocks with mutexes. There are
only RW_WRITERs for these, and no RW_READERs, so no need to incur the
extra overhead of allowing for both. As discussed on tech-kern.

For piixpm and ichsmb, the acquire/release protocol needs to be used,
even if the request is I2C_F_POLL'd (or if the device supports only
polled mode). Otherwise multiple requests can be running at the same
time, and they stomp on each other and create anomolous results.

Part 2 addresses my PR kern/45889

3 ACKs from releng
 1.26 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.25 15-May-2011  msaitoh branches: 1.25.4; 1.25.8;
Add support for Intel 6 series.
 1.24 10-Feb-2011  hannken Make the SMbus Send/Receive functions work.

If cmdlen = 0 and len = 1 use the XXX_HC_CMD_BYTE protocol, send
data through XXX_SMB_HCMD or receive data from XXX_SMB_HD0.

Ok: Paul Goyette
 1.23 30-Jul-2010  njoly branches: 1.23.2; 1.23.4;
Adjust for Intel ICH10 devices update.
 1.22 06-Feb-2010  tnn branches: 1.22.2; 1.22.4;
Attach to SMBus on Intel P55 chipset.
 1.21 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.20 18-Mar-2009  cegger bzero -> memset
 1.19 03-Feb-2009  pgoyette branches: 1.19.2;
Update the i2c_exec() functions to handle quick_read/quick_write protocol.

Although interface routines i2c_smbus_*() exist, nothing in NetBSD actually
uses them yet.
 1.18 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.17 01-Oct-2008  christos branches: 1.17.2;
ICH10 support from Brad du Plessis
 1.16 08-Sep-2008  njoly Add missing newline in debug message.
 1.15 08-Sep-2008  njoly Improve message for SMI interrupts.
 1.14 08-Sep-2008  njoly Fix compilation with ICHIIC_DEBUG.
 1.13 10-Apr-2008  cegger branches: 1.13.4; 1.13.6; 1.13.10;
use aprint_*_dev and device_xname
 1.12 28-Mar-2008  kiyohara Split device_t/softc.
 1.11 09-Dec-2007  jmcneill branches: 1.11.10;
Merge jmcneill-pm branch.
 1.10 19-Oct-2007  ad branches: 1.10.4; 1.10.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.9 01-Sep-2007  riz branches: 1.9.2; 1.9.6;
For SMBus, add the ability to enumerate devices on the bus.
This does NOT identify the devices, merely indicates the
presence of devices at certain addresses. Tested on ichsmb
and nfsmb - other SMBus devices will need to ensure the
proper bus type is set. (I2C_TYPE_SMBUS)

From Nicolas Joly, via Paul Goyette, in PR#36744.
 1.8 27-Aug-2007  xtraeme branches: 1.8.2;
Use rwlock(9) rather than lockmgr(9).
 1.7 27-Aug-2007  xtraeme Attach to the ICH9 SMBus device too.
 1.6 27-Aug-2007  xtraeme Add missing __KERNEL_RCSID().
 1.5 26-Aug-2007  xtraeme Move the ICH SMB defs to dev/ic/i82801lpcreg.h, it's where it belongs.
This is to avoid code duplication.
 1.4 09-Aug-2007  kiyohara branches: 1.4.2; 1.4.4;
Use bitmask_snprintf().
 1.3 05-Aug-2007  xtraeme branches: 1.3.2;
Repeat after me: %zu for size_t, %zd for ssize_t. Reminded by yamt@.
 1.2 05-Aug-2007  xtraeme Use %zd to printf size_t.
 1.1 28-Jul-2007  kiyohara branches: 1.1.4;
Add support for Intel ICH SMBus controller.
 1.1.4.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.1.4.5 23-Nov-2007  joerg Register with PM framework.
 1.1.4.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.4.3 03-Sep-2007  jmcneill Sync with HEAD.
 1.1.4.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.1.4.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.3.2.2 05-Aug-2007  xtraeme Repeat after me: %zu for size_t, %zd for ssize_t. Reminded by yamt@.
 1.3.2.1 05-Aug-2007  xtraeme file ichsmb.c was added on branch matt-mips64 on 2007-08-05 23:05:03 +0000
 1.4.4.4 23-Oct-2007  ad Sync with head.
 1.4.4.3 09-Oct-2007  ad Sync with head.
 1.4.4.2 20-Aug-2007  ad Sync with HEAD.
 1.4.4.1 09-Aug-2007  ad file ichsmb.c was added on branch vmlocking on 2007-08-20 22:07:04 +0000
 1.4.2.3 03-Sep-2007  skrll Sync with HEAD.
 1.4.2.2 15-Aug-2007  skrll Sync with HEAD.
 1.4.2.1 09-Aug-2007  skrll file ichsmb.c was added on branch nick-csl-alignment on 2007-08-15 13:48:30 +0000
 1.8.2.2 09-Jan-2008  matt sync with HEAD
 1.8.2.1 06-Nov-2007  matt sync with HEAD
 1.9.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.9.2.4 21-Jan-2008  yamt sync with head
 1.9.2.3 27-Oct-2007  yamt sync with head.
 1.9.2.2 03-Sep-2007  yamt sync with head.
 1.9.2.1 01-Sep-2007  yamt file ichsmb.c was added on branch yamt-lazymbuf on 2007-09-03 14:36:51 +0000
 1.10.6.1 11-Dec-2007  yamt sync with head.
 1.10.4.1 26-Dec-2007  ad Sync with head.
 1.11.10.5 17-Jan-2009  mjf Sync with HEAD.
 1.11.10.4 05-Oct-2008  mjf Sync with HEAD.
 1.11.10.3 28-Sep-2008  mjf Sync with HEAD.
 1.11.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.10.1 19-Oct-2008  haad Sync with HEAD.
 1.13.6.2 10-Oct-2008  skrll Sync with HEAD.
 1.13.6.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.13.4.4 11-Aug-2010  yamt sync with head.
 1.13.4.3 11-Mar-2010  yamt sync with head
 1.13.4.2 16-May-2009  yamt sync with head
 1.13.4.1 04-May-2009  yamt sync with head.
 1.17.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.17.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.17.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.22.4.2 31-May-2011  rmind sync with head
 1.22.4.1 05-Mar-2011  rmind sync with head
 1.22.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.23.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.23.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.8.1 18-Feb-2012  mrg merge to -current.
 1.25.4.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.4.3 23-Jan-2013  yamt sync with head
 1.25.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.25.4.1 17-Apr-2012  yamt sync with head
 1.27.6.3 03-Dec-2017  jdolecek update from HEAD
 1.27.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.6.1 25-Feb-2013  tls resync with head
 1.27.2.1 29-Sep-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1123):
sys/dev/pci/ichsmb.c: revision 1.37
Register a null pmf handler even if we failed to attach.
Keeps ichsmb(4) from preventing suspend even if it's broken because
of ichlpcib(4) grodiness.
 1.30.8.1 23-Jul-2013  riastradh sync with HEAD
 1.30.2.2 18-May-2014  rmind sync with head
 1.30.2.1 28-Aug-2013  rmind sync with head
 1.35.2.1 10-Aug-2014  tls Rebase.
 1.37.4.7 28-Aug-2017  skrll Sync with HEAD
 1.37.4.6 05-Feb-2017  skrll Sync with HEAD
 1.37.4.5 05-Dec-2016  skrll Sync with HEAD
 1.37.4.4 09-Jul-2016  skrll Sync with HEAD
 1.37.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.37.4.2 06-Jun-2015  skrll Sync with HEAD
 1.37.4.1 06-Apr-2015  skrll Sync with HEAD
 1.37.2.3 09-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1294):
sys/dev/pci/ichsmb.c: revisions 1.43-1.44
ichsmb(4): Add Braswell PCU SMBus and Intel 100 Series SMBus.
 1.37.2.2 30-Apr-2015  snj branches: 1.37.2.2.4;
Pull up following revision(s) (requested by msaitoh in ticket #725):
sys/arch/x86/pci/ichlpcib.c: revisions 1.47, 1.48
sys/dev/pci/ichsmb.c: revisions 1.39, 1.40, 1.41
sys/dev/pci/pucdata.c: revision 1.94
Add 9 Series support.
--
Add Intel C61x and X99 devices.
--
attach Mobile 5th Gen. Core SMBus
 1.37.2.1 17-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #528):
sys/dev/pci/ichsmb.c: revision 1.38
sys/dev/pci/pcidevs: revision 1.1206
sys/dev/pci/pcidevs: revision 1.1207
sys/arch/x86/pci/ichlpcib.c: revision 1.44
Change Intel 0x0434 entry:
- Rename DH89XX_QA to DH89XXCC_IQIA
- Modify the description to DH89xxCC PCIe Endpoint and QuickAssist
(include typo fix)
- Rename DH89xxCC's names from DH89XX_ to DH89XXCC_.
- Add some DH89xxCC's devices.
- Add DH89XXCL's devices.
- Rename PCI_PRODUCT_INTEL_DH89XX_SMB to PCI_PRODUCT_INTEL_DH89XXCC_SMB
- Add PCI_PRODUCT_INTEL_DH89XXCL_SMB
Add DH89xxC[CL] LPC devices.
 1.37.2.2.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.46.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.46.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.46.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.48.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.50.6.8 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1891):

sys/dev/pci/ichsmb.c: revision 1.85
sys/dev/pci/ismt.c: revision 1.11

ichsmb(4),ismt(4): Add Snow Ridge support.
 1.50.6.7 29-Jul-2023  martin Pull up the following revisions, via patch, requested by msaitoh in
ticket #1856:

sys/dev/pci/ichsmb.c 1.83-1.84

- Add support Intel 700 series chipset and Alder Lake-N devices.
- Use device_printf() instead of aprint_error_dev() in
ichsmb_i2c_exec().
 1.50.6.6 15-Oct-2022  martin Pull up the following (via patch), requested by msaitoh in ticket #1776:

sys/dev/pci/ichsmb.c 1.76-1.77

Add Intel 600 Series PCH support.
 1.50.6.5 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1711:

sys/dev/pci/ichsmb.c 1.69, 1.71, 1.73-1.75 via patch

- Add Intel 400, 495, and 500 series support.
- Add Intel Jasper Lake and Elkhart Lake support.
- Ignores the SMBALERT# interrupt. Same as other OSes.
 1.50.6.4 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1586:

sys/dev/pci/ichsmb.c 1.66-1.68 via patch

- Add Comet Lake, Whiskey Lake U and Amber Lake Y support.
- Whitespace fix.
 1.50.6.3 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #926):
sys/dev/pci/ichsmb.c: 1.52, 1.56
Add C620 devices.
--
Add Apollo Lake and Gemini Lake devices.
 1.50.6.2 16-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #763):

sys/dev/pci/ichsmb.c: revision 1.57
sys/dev/pci/pucdata.c: revision 1.101

Add 300 series chipset support.
 1.50.6.1 26-Feb-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #565):
sys/dev/pci/ichsmb.c: 1.51
sys/dev/pci/ismt.c: 1.6
Add C3000 devices.
 1.56.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.56.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.57.2.3 21-Apr-2020  martin Sync with HEAD
 1.57.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.57.2.1 10-Jun-2019  christos Sync with HEAD
 1.60.4.6 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1723):

sys/dev/pci/ichsmb.c: revision 1.85
sys/dev/pci/ismt.c: revision 1.11

ichsmb(4),ismt(4): Add Snow Ridge support.
 1.60.4.5 29-Jul-2023  martin Pull up the following revisions, via patch, requested by msaitoh in
ticket #1672:

sys/dev/pci/ichsmb.c 1.83-1.84

- Add support Intel 700 series chipset and Alder Lake-N devices.
- Use device_printf() instead of aprint_error_dev() in
ichsmb_i2c_exec().
 1.60.4.4 15-Oct-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1544:

sys/dev/pci/ichsmb.c 1.76-1.77

Add Intel 600 Series PCH support.
 1.60.4.3 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1381:

sys/dev/pci/ichsmb.c 1.69, 1.71, 1.73-1.75 via patch

- Add Intel 400, 495, and 500 series support.
- Add Intel Jasper Lake and Elkhart Lake support.
- Ignore the SMBALERT# interrupt. Same as other OSes.
 1.60.4.2 10-Jul-2020  martin Pull up the following revisions, via patch, requested by msaitoh in
ticket #996:

sys/dev/pci/ichsmb.c 1.62, 1.66-1.68

- Fix LOCKDEBUG panic on detach when attach failed.
- Add Comet Lake, Whiskey Lake U and Amber Lake Y support.
- Whitespace fix.
 1.60.4.1 01-Mar-2020  martin Pull up following revision(s) (requested by riastradh in ticket #748):

sys/dev/pci/ichsmb.c: revision 1.61

If attach fails, don't panic on detach.
 1.65.2.1 29-Feb-2020  ad Sync with head.
 1.66.4.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.66.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.68.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.69.2.1 24-Mar-2021  thorpej Don't filter interface attributes in rescan functions for devices that
carry only a single interface attribute. The autoconfiguration machinery
already considers interface attributes when searching for possible parents.
 1.70.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.71.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.81.4.3 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #338):

sys/dev/pci/ichsmb.c: revision 1.85
sys/dev/pci/ismt.c: revision 1.11

ichsmb(4),ismt(4): Add Snow Ridge support.
 1.81.4.2 01-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #282):

sys/dev/pci/ichsmb.c: revision 1.82
sys/arch/amd64/conf/GENERIC: revision 1.602
sys/arch/x86/pci/tco.c: revision 1.10
sys/arch/x86/pci/tco.h: revision 1.5
sys/arch/x86/pci/ichlpcib.c: revision 1.59
sys/dev/ic/i82801lpcreg.h: revision 1.17
sys/arch/x86/pci/files.pci: revision 1.27
sys/dev/pci/files.pci: revision 1.446

ichsmb(4), tco(4): Add support for TCO on newer Intel chipsets.

TCO (`Total Cost of Ownership', Intel's bizarre name for a watchdog
timer) used to hang off the Intel I/O platform controller hub's (ICH)
low-pin-count interface bridge (LPC IB), or ichlpcib(4). On newer
devices, it hangs off the ICH SMBus instead.
Tested on INTEL 100SERIES_SMB (works) and INTEL 100SERIES_LP_SMB
(doesn't work, still not sure why).

XXX kernel revbump: This breaks the module ABI -- tco(4) modules
older than the change to make ta_has_rcba into ta_version will
incorrectly attach at buses they do not understand. (However, the
tco(4) driver is statically built into GENERIC, so maybe it's safe
for pullup since the module wouldn't have worked anyway.)
 1.81.4.1 29-Jul-2023  martin Pull up the following revisions, via patch, requested by msaitoh in
ticket #253:

sys/dev/pci/ichsmb.c 1.83-1.84

- Add support Intel 700 series chipset and Alder Lake-N devices.
- Use device_printf() instead of aprint_error_dev() in
ichsmb_i2c_exec().
 1.85.6.1 02-Aug-2025  perseant Sync with HEAD
 1.25 05-Jan-2022  andvar fix typos, mainly s/comand/command/
 1.24 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.23 27-Sep-2016  pgoyette branches: 1.23.14; 1.23.16;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.22 29-Mar-2014  christos branches: 1.22.6; 1.22.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.21 27-Oct-2012  chs branches: 1.21.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.20 13-Nov-2010  uebayasi branches: 1.20.8; 1.20.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.19 26-Nov-2009  njoly branches: 1.19.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.18 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.17 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.16 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.15 28-Apr-2008  martin branches: 1.15.14;
Remove clause 3 and 4 from TNF licenses
 1.14 19-Oct-2007  ad branches: 1.14.16; 1.14.18; 1.14.20;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 16-Nov-2006  christos branches: 1.13.8; 1.13.22; 1.13.24; 1.13.28;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 27-Feb-2005  perry branches: 1.10.4;
nuke trailing whitespace
 1.9 29-Jun-2003  thorpej branches: 1.9.2; 1.9.10; 1.9.12;
Only need to report the PCI product ID in the management ioctls.
From Achim Leubner @ ICP.
 1.8 13-May-2003  thorpej Add support for the user-generated command interface and event logging
required by the ICP-Vortex management tools. Many thanks to Achim Leubner
at ICP-Vortex for a few bug fixes and for testing.
 1.7 31-Jan-2003  thorpej Use aprint_*().
 1.6 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.5 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 24-Apr-2002  ad branches: 1.2.6; 1.2.8;
Match anything with PCI_VENDOR_VORTEX, then use a heuristic to determine the
board's interface, and list only exceptions in icp_pci_ident[].
 1.1 22-Apr-2002  ad Add a driver for ICP-Vortex GDT and Intel Storage RAID controllers. Parts
taken from OpenBSD. Test hardware kindly provided by Intel. This still needs
management bits, and doesn't support older controllers, but that shouldn't
be hard to fix.
 1.2.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 24-Apr-2002  jdolecek file icp_pci.c was added on branch kqueue on 2002-06-23 17:47:38 +0000
 1.2.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.2.6.1 24-Apr-2002  nathanw file icp_pci.c was added on branch nathanw_sa on 2002-06-20 03:45:23 +0000
 1.9.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.10.1 29-Apr-2005  kent sync with -current
 1.9.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.4.2 27-Oct-2007  yamt sync with head.
 1.10.4.1 30-Dec-2006  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.13.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.24.1 06-Nov-2007  matt sync with HEAD
 1.13.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.14.20.3 11-Mar-2010  yamt sync with head
 1.14.20.2 16-May-2009  yamt sync with head
 1.14.20.1 16-May-2008  yamt sync with head.
 1.14.18.1 18-May-2008  yamt sync with head.
 1.14.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.20.18.3 03-Dec-2017  jdolecek update from HEAD
 1.20.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.20.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.8.1 30-Oct-2012  yamt sync with head
 1.21.2.1 18-May-2014  rmind sync with head
 1.22.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.22.6.1 05-Oct-2016  skrll Sync with HEAD
 1.23.16.1 10-Jun-2019  christos Sync with HEAD
 1.23.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.74 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.73 17-Sep-2022  thorpej age_start(): Remove redundant IFQ_IS_EMPTY(). This very same condition
is checked as soon as we enter the loop 2 statements later.
 1.72 22-Aug-2022  thorpej age_start(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success (or fatal error)".
 1.71 22-Aug-2022  thorpej age_encap(): Use m_defrag(), not m_pullup(), to compact an mbuf chain
if it has too many DMA segments. Let the caller handle dispose of the
packet on fatal errors.
 1.70 31-May-2022  andvar fix various typos in comments, documentation and messages.
 1.69 01-Mar-2020  thorpej - Use the 64-bit PCI DMA tag if available.
- In age_dma_alloc(), ensure that all of the control data end up in the
same 4GB segment, because the hardware requires this.
 1.68 01-Mar-2020  thorpej It doesn't make any sense to pass ETHER_ALIGN as the alignment constraint
to bus_dmamem_alloc(). Use PAGE_SIZE instead.
 1.67 04-Feb-2020  thorpej Use ifmedia_fini().
 1.66 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.65 01-Dec-2019  msaitoh branches: 1.65.2;
Use unsigned to avoid undefined behavoir. Found by kUBSan.
 1.64 21-Nov-2019  msaitoh Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.
 1.63 21-Nov-2019  msaitoh Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash. Same as OpenBSD.
 1.62 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.61 20-Sep-2019  maxv Fix direction of the loop.

Found by the lgtm bot.
 1.60 09-Jul-2019  msaitoh branches: 1.60.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.59 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.58 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.57 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.56 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.55 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.54 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.53 26-Jun-2018  msaitoh branches: 1.53.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.52 01-Jun-2018  maxv Fix M_PKTHDR use in if_alc, if_age and if_ena.

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

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

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).
 1.51 26-Sep-2017  knakahara branches: 1.51.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.50 15-Dec-2016  ozaki-r branches: 1.50.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.49 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.48 10-Jun-2016  ozaki-r branches: 1.48.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.47 17-Feb-2016  christos PR/50817: David Binderman: Delete dead code (copy from if_et.c)
 1.46 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.45 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.44 29-Mar-2014  christos branches: 1.44.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.43 21-Feb-2014  christos PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.
 1.42 30-Mar-2013  christos branches: 1.42.4;
remove trailing whitespace
 1.41 22-Jul-2012  matt branches: 1.41.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.40 25-Oct-2011  bouyer branches: 1.40.2;
age_init() is called from age_watchdog() which is interrupt context, we
can't sleep here or we get a DIAGNOSTIC panic when age_watchdog() fires.
More correct bus_dma(9) usage in age_encap()
Introduce a age_shutdown() to be called by pmf(9) at shutdown time,
to stop the DMA engine. My system would't properly reboot without this.
Be consistent in WAIT/NOWAIT use in init routines
Use BUS_DMA_COHERENT where appropriate
Rework the interrupt routine a bit, and ACK but do not disable interrupts
here. There seems to be a race where interrupts would not be properly
reenabled after this, leading do watchdog timeouts.

With these changes, the on-board age(4) on ftp.fr.netbsd.org seems to
be finally working properly.
 1.39 20-Jul-2010  cegger PR kern/38871: Fix VLAN
 1.38 05-Apr-2010  joerg branches: 1.38.2;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.37 24-Feb-2010  dyoung branches: 1.37.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.36 19-Jan-2010  pooka branches: 1.36.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.35 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.34 08-Oct-2009  cegger Use m_pullup to handle defragmentation.
Reinject mbuf into TX queue when it couldn't be loaded.

diff for age(4) reviewed/discussed with plunky@ several weeks ago.
 1.33 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.32 05-Aug-2009  cegger make RX hw checksum available by default.
TX hw checksum locks up interface.
 1.31 05-Aug-2009  cegger fix typo
 1.30 05-Aug-2009  cegger - Don't access VPD even if hardware advertised the capability.
It seems that some revisions of the controllers hang while accessing
the VPD. Because VPD access routine is now unused, nuke it.
- Let TWSI reload EEPROM if VPD capability is detected. Reloading
the EEPROM will also set the Ethernet address, so age(4) now reads
AGE_PAR0 and AGE_PAR1 register to get the Ethernet address. This removes
removes a lot of hacks and enhance readability a lot.
- Double PHY reset timeout as it takes more time to take the PHY out of
power-saving state.
- Explicitly check power-saving state by checking undocumented PHY
registers. If link is not up, poke undocumented registers to take
PHY out of power-saving state. This is the same thing done by the
Linux driver.
- Don't rely on auto-clearing feature of master reset bit, just wait
1ms and check idle status of MAC.

From FreeBSD via OpenBSD.
 1.29 04-Aug-2009  cegger support flow control. from OpenBSD.
tested by hans@
 1.28 28-Apr-2009  cegger branches: 1.28.2; 1.28.4;
on detach, deregister from pmf and free resource
 1.27 26-Apr-2009  cegger age_intr: don't return w/o ack. the interrupt.
Add a comment when this special case can happen.
 1.26 21-Apr-2009  tsutsui Fix wrong arguments of bus_dmamem_free(9).

XXX: not all resouces are freed properly on error path in age_dma_alloc().
 1.25 03-Mar-2009  cegger mimic fix from nfe(4):
when bus_dmamap_create fails, then the map pointer is undefined.
age_dma_free() assumes, the map pointer is NULL. Make the assumption
always true by setting the map pointer to NULL in bus_dmamap_create()
error path in order to prevent age_dma_free() to call bus_dmamap_destroy()
on an invalid map.
 1.24 03-Mar-2009  cegger make multicast working.
Diff from OpenBSD's if_age.c rev. 1.2.
 1.23 23-Feb-2009  cegger when attach routine fails, also free DMA memory and interrupt mapping.
Diff from OpenBSD's if_age.c rev. 1.2.
ok cube@
 1.22 16-Feb-2009  cegger make this compile w/o VLAN
 1.21 11-Feb-2009  cegger age_dma_free: set smb pointers to NULL for consistency
age_stop: call mii_down()
ok cube@
 1.20 05-Feb-2009  dyoung branches: 1.20.2;
If the bus_dmamap_load_mbuf() status was non-zero, then the DMA
map is undefined, so do not try to unload it.
 1.19 05-Feb-2009  dyoung Initialize ec_mii, and re-use more ethernet common code for media
handling.

Replace an anonymous constant by PCI_COMMAND_INTERRUPT_DISABLE.

These changes have been compile-tested, only.
 1.18 03-Feb-2009  cegger Adapt age_stop() as our ethernet stack expects it.
This makes 'ifconfig age0 down' working.
Ok cube@
 1.17 30-Jan-2009  cegger age_dma_alloc(): Don't allocate more than really required.
It is less likely to fail with ENOMEM when we are short on dma-safe memory.
This happens more likely when running NetBSD as Xen Dom0.
 1.16 30-Jan-2009  cegger age_dma_alloc(): print error code to figure out why it failed.
 1.15 30-Jan-2009  cegger remove brackets from return statements.
No functional change.
 1.14 29-Jan-2009  cegger fix error path: don't crash when age_dma_alloc() fails.
 1.13 24-Jan-2009  cegger - fix test for IPv4 csum.
- No need to double negate TCP/UDP csum test
 1.12 23-Jan-2009  cegger Improve handling of transmitting large packets.
Sending large packets works better, but still needs investigations.
 1.11 22-Jan-2009  cegger struct device -> device_t
 1.10 22-Jan-2009  cegger fix crash when bringing up the device and no cable is plugged in
 1.9 21-Jan-2009  cegger Roll our own ETHER_ALIGN #define like many other driver do.
Use ETHER_ALIGN to calculate number of segments correctly (actually the same way as FreeBSD and OpenBSD do).
Also use ETHER_ALIGN to correctly adjust new mbufs.
This makes the driver finally work. Tested by Jochen Kunz:
ping -nf 192.168.2.1
PING 192.168.2.1 (192.168.2.1): 56 data bytes

----192.168.2.1 PING Statistics----
28949 packets transmitted, 28949 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.157/0.364/2.272/0.023 ms
2710.6 packets/sec sent, 2710.6 packets/sec received


XXX Shouldn't if_ether.h provide ETHER_ALIGN instead of defining it in all drivers?
 1.8 18-Jan-2009  cegger branches: 1.8.2;
fix botched age_ioctl(): don't try to roll its own handling when ether_ioctl() is doing all of it right.
Tested by Jochen Kunz.
 1.7 18-Jan-2009  cegger beautify dmesg output
 1.6 17-Jan-2009  cegger branches: 1.6.2;
Until we do WOL, the PCI power management suspend code is a noop.
 1.5 16-Jan-2009  cegger don't call age_stop and age_init in suspend/resume.
pmf network class is already doing that.
pointed out by jmcneill
 1.4 16-Jan-2009  cegger rename PCI_PMCSR_PME to PCI_PMCSR_PME_STS.
Per request from jmcneill
 1.3 16-Jan-2009  cegger - fix age_read_vpd_word().
- add power management support. From FreeBSD.
 1.2 16-Jan-2009  cegger add RCSID
 1.1 16-Jan-2009  cegger Driver for Attansic L1 gigabit ethernet driver.

Written by Pyun YongHyeon for FreeBSD, ported to DragonFlyBSD
by Sepherosa Ziehau, ported to OpenBSD by Kevin Lo and then
ported to NetBSD by me.

XXX Driver needs testing.
 1.6.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.6.2.1 17-Jan-2009  mjf file if_age.c was added on branch mjf-devfs2 on 2009-01-17 13:28:59 +0000
 1.8.2.4 28-Apr-2009  skrll Sync with HEAD.
 1.8.2.3 03-Mar-2009  skrll Sync with HEAD.
 1.8.2.2 19-Jan-2009  skrll Sync with HEAD.
 1.8.2.1 18-Jan-2009  skrll file if_age.c was added on branch nick-hppapmap on 2009-01-19 13:18:25 +0000
 1.20.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.4.6 11-Aug-2010  yamt sync with head.
 1.28.4.5 11-Mar-2010  yamt sync with head
 1.28.4.4 16-Sep-2009  yamt sync with head
 1.28.4.3 19-Aug-2009  yamt sync with head.
 1.28.4.2 04-May-2009  yamt sync with head.
 1.28.4.1 28-Apr-2009  yamt file if_age.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:55 +0000
 1.28.2.6 18-Nov-2011  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1694):
sys/dev/pci/if_age.c: revision 1.40 via patch

- age_init() is called from age_watchdog() which is in interrupt context; we
can't sleep here or we get a DIAGNOSTIC panic when age_watchdog() fires.
- More correct bus_dma(9) usage in age_encap()
- Introduce a age_shutdown() to be called by pmf(9) at shutdown time,
to stop the DMA engine.
- Be consistent in WAIT/NOWAIT use in init routines
- Use BUS_DMA_COHERENT where appropriate
- Rework the interrupt routine a bit, and ACK but do not disable interrupts
here. There seems to be a race where interrupts would not be properly
reenabled after this, leading do watchdog timeouts.
 1.28.2.5 08-Nov-2009  snj Pull up following revision(s) (requested by cegger in ticket #1124):
sys/dev/pci/if_age.c: revision 1.34
sys/dev/pci/if_ale.c: revision 1.9
Use m_pullup to handle defragmentation.
Reinject mbuf into TX queue when it couldn't be loaded.
diff for age(4) reviewed/discussed with plunky@ several weeks ago.
 1.28.2.4 08-Nov-2009  snj Pull up following revision(s) (requested by cegger in ticket #1124):
sys/dev/pci/if_age.c: revision 1.30
- Don't access VPD even if hardware advertised the capability.
It seems that some revisions of the controllers hang while accessing
the VPD. Because VPD access routine is now unused, nuke it.
- Let TWSI reload EEPROM if VPD capability is detected. Reloading
the EEPROM will also set the Ethernet address, so age(4) now reads
AGE_PAR0 and AGE_PAR1 register to get the Ethernet address. This removes
removes a lot of hacks and enhance readability a lot.
- Double PHY reset timeout as it takes more time to take the PHY out of
power-saving state.
- Explicitly check power-saving state by checking undocumented PHY
registers. If link is not up, poke undocumented registers to take
PHY out of power-saving state. This is the same thing done by the
Linux driver.
- Don't rely on auto-clearing feature of master reset bit, just wait
1ms and check idle status of MAC.
From FreeBSD via OpenBSD.
 1.28.2.3 08-Nov-2009  snj Pull up following revision(s) (requested by cegger in ticket #1124):
sys/dev/pci/if_age.c: revision 1.29
support flow control. from OpenBSD.
tested by hans@
 1.28.2.2 03-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #735):
sys/dev/pci/if_age.c: revisions 1.1-1.28
sys/dev/pci/if_agereg.h: revisions 1.1-1.2
sys/dev/pci/if_ale.c: revisions 1.1-1.3
sys/dev/pci/if_alereg.h: revisions 1.1-1.2
sys/dev/pci/files.pci: revisions 1.310-1.313
sys/dev/mii/atphy.c: revisions 1.1-1.5
sys/dev/mii/files.mii: revision 1.42
share/man/man4/age.4: revisions 1.1-1.3
share/man/man4/ale.4: revisions 1.1-1.2
share/man/man4/atphy.4: revisions 1.1-1.2
share/man/man4/Makefile: revisions 1.486, 1.489
distrib/sets/lists/man/mi: revisions 1.1118, 1.1132
sys/arch/i386/conf/GENERIC: revisions 1.928, 1.933
sys/arch/i386/conf/XEN2_DOM0: revisions 1.57, 1.60
sys/arch/amd64/conf/GENERIC: revisions 1.239, 1.241
sys/arch/amd64/conf/XEN3_DOM0: revisions 1.38, 1.42
Add the age(4) and ale(4) drivers for Attansic L1 and Atheros
AR8121/AR8113/AR8114 devices respectively.
 1.28.2.1 28-Apr-2009  snj file if_age.c was added on branch netbsd-5 on 2009-05-03 23:45:47 +0000
 1.36.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.37.2.2 05-Mar-2011  rmind sync with head
 1.37.2.1 30-May-2010  rmind sync with head
 1.38.2.2 21-Apr-2010  matt sync to netbsd-5
 1.38.2.1 05-Apr-2010  matt file if_age.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:40 +0000
 1.40.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.40.2.1 30-Oct-2012  yamt sync with head
 1.41.2.3 03-Dec-2017  jdolecek update from HEAD
 1.41.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.2.1 23-Jun-2013  tls resync from head
 1.42.4.1 18-May-2014  rmind sync with head
 1.44.6.4 05-Feb-2017  skrll Sync with HEAD
 1.44.6.3 09-Jul-2016  skrll Sync with HEAD
 1.44.6.2 19-Mar-2016  skrll Sync with HEAD
 1.44.6.1 06-Jun-2015  skrll Sync with HEAD
 1.48.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.50.8.3 05-Dec-2019  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1462):
sys/dev/pci/if_age.c: revision 1.61, 1.63-1.64 via patch

- Fix direction of the loop in age_get_macaddr().
- Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash.
- Fix a bug that IFF_ALLMULTI is almost always set.
 1.50.8.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.50.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.51.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.51.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.51.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.51.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.53.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.53.2.1 10-Jun-2019  christos Sync with HEAD
 1.60.2.5 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.60.2.4 26-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #483):

sys/dev/pci/if_cas.c: revision 1.36
sys/dev/pci/if_alc.c: revision 1.44
sys/dev/pci/if_ale.c: revision 1.35
sys/dev/pci/if_ale.c: revision 1.36
sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

Remove accidentally committed debug code. Sorry.
 1.60.2.3 26-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #482):

sys/dev/pci/if_age.c: revision 1.63

Fix multicast handling. All Atheros controllers use big-endian form
when computing multicast hash. Same as OpenBSD.
 1.60.2.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.60.2.1 22-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #216):

sys/dev/pci/if_age.c: revision 1.61

Fix direction of the loop.
 1.65.2.1 29-Feb-2020  ad Sync with head.
 1.3 28-Jul-2009  cegger branches: 1.3.6;
add TWSI registers. from OpenBSD.
 1.2 23-Feb-2009  cegger branches: 1.2.2; 1.2.4;
remove unused age_if_flags softc member
 1.1 16-Jan-2009  cegger branches: 1.1.2; 1.1.4; 1.1.6;
Driver for Attansic L1 gigabit ethernet driver.

Written by Pyun YongHyeon for FreeBSD, ported to DragonFlyBSD
by Sepherosa Ziehau, ported to OpenBSD by Kevin Lo and then
ported to NetBSD by me.

XXX Driver needs testing.
 1.1.6.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.4.3 03-Mar-2009  skrll Sync with HEAD.
 1.1.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.4.1 16-Jan-2009  skrll file if_agereg.h was added on branch nick-hppapmap on 2009-01-19 13:18:25 +0000
 1.1.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.2.1 16-Jan-2009  mjf file if_agereg.h was added on branch mjf-devfs2 on 2009-01-17 13:28:59 +0000
 1.2.4.3 19-Aug-2009  yamt sync with head.
 1.2.4.2 04-May-2009  yamt sync with head.
 1.2.4.1 23-Feb-2009  yamt file if_agereg.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:55 +0000
 1.2.2.3 08-Nov-2009  snj Pull up following revision(s) (requested by cegger in ticket #1124):
sys/dev/pci/if_agereg.h: revision 1.3
add TWSI registers. from OpenBSD.
 1.2.2.2 03-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #735):
sys/dev/pci/if_age.c: revisions 1.1-1.28
sys/dev/pci/if_agereg.h: revisions 1.1-1.2
sys/dev/pci/if_ale.c: revisions 1.1-1.3
sys/dev/pci/if_alereg.h: revisions 1.1-1.2
sys/dev/pci/files.pci: revisions 1.310-1.313
sys/dev/mii/atphy.c: revisions 1.1-1.5
sys/dev/mii/files.mii: revision 1.42
share/man/man4/age.4: revisions 1.1-1.3
share/man/man4/ale.4: revisions 1.1-1.2
share/man/man4/atphy.4: revisions 1.1-1.2
share/man/man4/Makefile: revisions 1.486, 1.489
distrib/sets/lists/man/mi: revisions 1.1118, 1.1132
sys/arch/i386/conf/GENERIC: revisions 1.928, 1.933
sys/arch/i386/conf/XEN2_DOM0: revisions 1.57, 1.60
sys/arch/amd64/conf/GENERIC: revisions 1.239, 1.241
sys/arch/amd64/conf/XEN3_DOM0: revisions 1.38, 1.42
Add the age(4) and ale(4) drivers for Attansic L1 and Atheros
AR8121/AR8113/AR8114 devices respectively.
 1.2.2.1 23-Feb-2009  snj file if_agereg.h was added on branch netbsd-5 on 2009-05-03 23:45:47 +0000
 1.3.6.2 21-Apr-2010  matt sync to netbsd-5
 1.3.6.1 28-Jul-2009  matt file if_agereg.h was added on branch matt-nb5-mips64 on 2010-04-21 00:27:40 +0000
 1.56 09-Mar-2025  mlelstv Add MBUFTRACE
 1.55 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.54 29-Jun-2024  riastradh branches: 1.54.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.53 17-Sep-2022  thorpej alc_start(): Remove redundant IFQ_IS_EMPTY(). This very same condition
is checked as soon as we enter the loop.
 1.52 01-Mar-2020  thorpej Upon further reflection, we actually do need to ensure that the Rx
ring and the Rx Return ring are both in the same 4GB segment.
 1.51 01-Mar-2020  thorpej - Use the 64-bit PCI DMA tag if available.
- Add a comment explaining that if we were to use more than one
Rx ring / Rx Return ring, all of the Rx-related control data
would need to be in the same 4G segment.
 1.50 01-Mar-2020  thorpej It doesn't make any sense to pass ETHER_ALIGN as the alignment constraint
to bus_dmamem_alloc(). Use PAGE_SIZE instead.
 1.49 08-Feb-2020  maxv constify
 1.48 04-Feb-2020  thorpej Use ifmedia_fini().
 1.47 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.46 18-Dec-2019  msaitoh branches: 1.46.2;
Cast to uint32_t to avoid undefined behavior. Found by kUBSan.
 1.45 01-Dec-2019  msaitoh Use unsigned to avoid undefined behavoir. Found by kUBSan.
 1.44 21-Nov-2019  msaitoh Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.
 1.43 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.42 17-Oct-2019  msaitoh Add support for Killer E2400 and E2500.
 1.41 17-Oct-2019  msaitoh Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.
 1.40 15-Oct-2019  msaitoh Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.
 1.39 15-Oct-2019  msaitoh Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
 1.38 09-Jul-2019  msaitoh branches: 1.38.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.37 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.36 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.35 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.34 01-May-2019  msaitoh Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

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

XXX pullup-8
 1.32 22-Apr-2019  msaitoh This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.
 1.31 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.30 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.29 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.28 26-Jun-2018  msaitoh branches: 1.28.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.27 25-Jun-2018  msaitoh Remove duplicated inclusion of net/bpf.h.
 1.26 01-Jun-2018  maxv Fix M_PKTHDR use in if_alc, if_age and if_ena.

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

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

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).
 1.25 26-Sep-2017  knakahara branches: 1.25.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.24 21-Dec-2016  maya branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.
 1.23 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.22 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.21 10-Jun-2016  ozaki-r branches: 1.21.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.20 17-Feb-2016  christos PR/50818: David Binderman: Delete dead code (copied from if_et.c)
 1.19 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.18 26-Jan-2016  christos PR/50694: David Binderman: Fix wrong pasto constant.
 1.17 24-Nov-2015  leot Add NetBSD RCS Id.
 1.16 24-Nov-2015  christos kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.
 1.15 08-Sep-2015  leot Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

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

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

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

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

ok mrg@
 1.14 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.13 19-Jan-2015  christos CID 1245802: Result always 0.
 1.12 18-Jan-2015  christos PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets
 1.11 29-Mar-2014  christos branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.10 21-Feb-2014  christos PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.
 1.9 21-Apr-2013  msaitoh branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.
 1.8 30-Mar-2013  christos remove trailing whitespace
 1.7 09-Dec-2012  mrg avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.
 1.6 22-Jul-2012  matt branches: 1.6.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.5 29-Aug-2011  jmcneill branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it
 1.4 23-Jun-2011  matt When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".
 1.3 08-Apr-2011  sborrill branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.
 1.2 23-Feb-2011  jmcneill branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips
 1.1 23-Feb-2011  jmcneill add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto
 1.2.4.3 21-Apr-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 23-Feb-2011  rmind file if_alc.c was added on branch rmind-uvmplock on 2011-03-05 20:53:38 +0000
 1.2.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.1 23-Feb-2011  bouyer file if_alc.c was added on branch bouyer-quota2 on 2011-03-05 15:10:23 +0000
 1.3.4.2 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 08-Apr-2011  jruoho file if_alc.c was added on branch jruoho-x86intr on 2011-06-06 09:08:10 +0000
 1.5.8.1 13-Jun-2013  msaitoh Pull up following revision(s) (requested by mrg in ticket #898):
sys/dev/pci/if_alc.c: revision 1.7
avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.
 1.5.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.5.2.1 30-Oct-2012  yamt sync with head
 1.6.2.4 03-Dec-2017  jdolecek update from HEAD
 1.6.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.2 23-Jun-2013  tls resync from head
 1.6.2.1 25-Feb-2013  tls resync with head
 1.9.4.1 18-May-2014  rmind sync with head
 1.11.6.7 05-Feb-2017  skrll Sync with HEAD
 1.11.6.6 09-Jul-2016  skrll Sync with HEAD
 1.11.6.5 19-Mar-2016  skrll Sync with HEAD
 1.11.6.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.11.6.3 22-Sep-2015  skrll Sync with HEAD
 1.11.6.2 06-Jun-2015  skrll Sync with HEAD
 1.11.6.1 06-Apr-2015  skrll Sync with HEAD
 1.11.4.1 04-Feb-2015  snj Pull up following revision(s) (requested by nonaka in ticket #473):
share/man/man4/lii.4: revision 1.3
sys/dev/pci/if_alc.c: revision 1.12
sys/dev/pci/pcidevs: revision 1.1213
sys/dev/pci/if_alcreg.h: revision 1.3
share/man/man4/atphy.4: revision 1.3
share/man/man4/alc.4: revision 1.4
PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets
 1.21.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.8.5 05-Dec-2019  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1464):
sys/dev/pci/if_alc.c 1.44 via patch
sys/dev/pci/if_ale.c 1.35-1.36 via patch
sys/dev/pci/if_cas.c 1.36 via patch
- Fix a bug that IFF_ALLMULTI is almost always set.
- Whitespace fixes.
 1.24.8.4 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.24.8.3 14-May-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1268):

sys/dev/pci/if_alc.c: revision 1.33
sys/dev/pci/if_alc.c: revision 1.34

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

This bug was added in if_alc.c rev. 1.16.
XXX pullup-8

-

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

XXX need cleanup.
 1.24.8.2 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.24.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.25.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.25.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.25.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.25.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.28.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.28.2.1 10-Jun-2019  christos Sync with HEAD
 1.38.2.4 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.38.2.3 26-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #483):

sys/dev/pci/if_cas.c: revision 1.36
sys/dev/pci/if_alc.c: revision 1.44
sys/dev/pci/if_ale.c: revision 1.35
sys/dev/pci/if_ale.c: revision 1.36
sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

Remove accidentally committed debug code. Sorry.
 1.38.2.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.38.2.1 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #375):

sys/dev/pci/if_alc.c: revision 1.40
sys/dev/pci/if_alc.c: revision 1.41
sys/dev/pci/if_alc.c: revision 1.42
sys/dev/pci/if_alc.c: revision 1.39
sys/dev/pci/if_alcreg.h: revision 1.8
share/man/man4/alc.4: revision 1.6

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

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

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

- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.

- Use static.

- Whitespace fix. Remove extra backslash.

Add support for Killer E2400 and E2500.
 1.46.2.1 29-Feb-2020  ad Sync with head.
 1.54.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.9 08-Feb-2020  maxv constify
 1.8 17-Oct-2019  msaitoh branches: 1.8.2;
Add support for Killer E2400 and E2500.
 1.7 03-Sep-2019  msaitoh No functional change to reduce diff against {Free,Open}BSD:
- Fix typo in comment.
- Modify white spaces.
 1.6 29-Dec-2016  leot branches: 1.6.16; 1.6.22;
Do not access `sc' directly via the CSR_{READ,WRITE}_[124] macros.

Patch provided by Amol via PR kern/51708.

ok <Riastradh>
 1.5 24-Nov-2015  leot branches: 1.5.2;
Add NetBSD RCS Id.
 1.4 08-Sep-2015  leot Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

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

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

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

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

ok mrg@
 1.3 18-Jan-2015  christos PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets
 1.2 23-Feb-2011  jmcneill branches: 1.2.2; 1.2.4; 1.2.8; 1.2.20; 1.2.36; 1.2.38;
catch up with FreeBSD driver, adds support for AR815x chips
 1.1 23-Feb-2011  jmcneill add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto
 1.2.38.4 05-Feb-2017  skrll Sync with HEAD
 1.2.38.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.38.2 22-Sep-2015  skrll Sync with HEAD
 1.2.38.1 06-Apr-2015  skrll Sync with HEAD
 1.2.36.1 04-Feb-2015  snj Pull up following revision(s) (requested by nonaka in ticket #473):
share/man/man4/lii.4: revision 1.3
sys/dev/pci/if_alc.c: revision 1.12
sys/dev/pci/pcidevs: revision 1.1213
sys/dev/pci/if_alcreg.h: revision 1.3
share/man/man4/atphy.4: revision 1.3
share/man/man4/alc.4: revision 1.4
PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets
 1.2.20.1 03-Dec-2017  jdolecek update from HEAD
 1.2.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 23-Feb-2011  jruoho file if_alcreg.h was added on branch jruoho-x86intr on 2011-06-06 09:08:11 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 23-Feb-2011  rmind file if_alcreg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:38 +0000
 1.2.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.1 23-Feb-2011  bouyer file if_alcreg.h was added on branch bouyer-quota2 on 2011-03-05 15:10:23 +0000
 1.5.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.22.1 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #375):

sys/dev/pci/if_alc.c: revision 1.40
sys/dev/pci/if_alc.c: revision 1.41
sys/dev/pci/if_alc.c: revision 1.42
sys/dev/pci/if_alc.c: revision 1.39
sys/dev/pci/if_alcreg.h: revision 1.8
share/man/man4/alc.4: revision 1.6

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

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

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

- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.

- Use static.

- Whitespace fix. Remove extra backslash.

Add support for Killer E2400 and E2500.
 1.6.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8.2.1 29-Feb-2020  ad Sync with head.
 1.44 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.43 22-Aug-2022  thorpej ale_encap(): Fix error logic in previous change for when the defrag works,
but DMA mapping fails to use DMA resource shortage.
 1.42 22-Aug-2022  thorpej ale_start(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success (or fatal error)".
 1.41 22-Aug-2022  thorpej ale_encap(): Use m_defrag(), not m_pullup(), to compact an mbuf chain
if it has too many DMA segments. Let the caller handle dispose of the
packet on fatal errors.
 1.40 01-Mar-2020  thorpej It doesn't make any sense to pass ETHER_ALIGN as the alignment constraint
to bus_dmamem_alloc(). Use PAGE_SIZE instead.
 1.39 04-Feb-2020  thorpej Use ifmedia_fini().
 1.38 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.37 01-Dec-2019  msaitoh branches: 1.37.2;
Use unsigned to avoid undefined behavoir. Found by kUBSan.
 1.36 21-Nov-2019  msaitoh Remove accidentally committed debug code. Sorry.
 1.35 21-Nov-2019  msaitoh Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.
 1.34 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.33 09-Jul-2019  msaitoh branches: 1.33.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.32 28-May-2019  msaitoh Add missing ETHER_LOCK().
 1.31 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.30 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.29 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.28 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.27 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.26 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.25 15-Nov-2018  maxv Remove the 'copy' argument from m_devget(), unused. While here rename
off0->off.
 1.24 26-Jun-2018  msaitoh branches: 1.24.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.23 26-Sep-2017  knakahara branches: 1.23.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.22 23-May-2017  ozaki-r branches: 1.22.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.
 1.21 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.20 09-Feb-2016  ozaki-r branches: 1.20.2;
Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.19 26-Jan-2016  christos PR/50693: David Binderman: Fix constant pasto.
 1.18 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.17 29-Mar-2014  christos branches: 1.17.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.16 21-Feb-2014  christos PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.
 1.15 30-Mar-2013  christos branches: 1.15.4;
remove trailing whitespace
 1.14 22-Jul-2012  matt branches: 1.14.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.13 22-Jan-2011  cegger branches: 1.13.4;
Fixes from PR kern/44395 Masanori Kanaoka:
- Fix register address in ale_phy_reset(). from linux
- Fix mask value in ale_stop_mac().
- Fix multicast handling. from openbsd
- Fix phy reset handling.
 1.12 20-Jul-2010  cegger branches: 1.12.2; 1.12.4;
PR kern/38871: Fix VLAN
 1.11 05-Apr-2010  joerg branches: 1.11.2;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.10 19-Jan-2010  pooka branches: 1.10.2; 1.10.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.9 08-Oct-2009  cegger Use m_pullup to handle defragmentation.
Reinject mbuf into TX queue when it couldn't be loaded.

diff for age(4) reviewed/discussed with plunky@ several weeks ago.
 1.8 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.7 18-Aug-2009  cegger fix multicast.
 1.6 18-Aug-2009  cegger don't read/write 1000baseT specific MII registers on 10/100M only device.
from OpenBSD.
 1.5 05-Aug-2009  cegger support flow control. from OpenBSD.
tested by Kevin Lahey
 1.4 28-Jul-2009  cegger print chipset name. From OpenBSD.
 1.3 28-Apr-2009  cegger branches: 1.3.2; 1.3.4; 1.3.6;
on detach, deregister from pmf
 1.2 25-Apr-2009  tsutsui branches: 1.2.2;
Add RCS Id.
 1.1 20-Apr-2009  cegger Add ale(4), a driver for Attansic/Atheros L1E gigabit ethernet device.
Ported by me from OpenBSD, improvements from Kevin Lahey,
successfully tested by Kevin Lahey and Stephen Borrill.
 1.2.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.2.2.1 25-Apr-2009  skrll file if_ale.c was added on branch nick-hppapmap on 2009-04-28 07:35:56 +0000
 1.3.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.6.1 28-Apr-2009  jym file if_ale.c was added on branch jym-xensuspend on 2009-05-13 17:20:24 +0000
 1.3.4.6 11-Aug-2010  yamt sync with head.
 1.3.4.5 11-Mar-2010  yamt sync with head
 1.3.4.4 16-Sep-2009  yamt sync with head
 1.3.4.3 19-Aug-2009  yamt sync with head.
 1.3.4.2 04-May-2009  yamt sync with head.
 1.3.4.1 28-Apr-2009  yamt file if_ale.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:55 +0000
 1.3.2.4 08-Nov-2009  snj Pull up following revision(s) (requested by cegger in ticket #1124):
sys/dev/pci/if_age.c: revision 1.34
sys/dev/pci/if_ale.c: revision 1.9
Use m_pullup to handle defragmentation.
Reinject mbuf into TX queue when it couldn't be loaded.
diff for age(4) reviewed/discussed with plunky@ several weeks ago.
 1.3.2.3 10-Sep-2009  snj Pull up following revision(s) (requested by sborrill in ticket #941):
sys/dev/pci/if_ale.c: revision 1.4
sys/dev/pci/if_ale.c: revision 1.5
sys/dev/pci/if_ale.c: revision 1.6
sys/dev/pci/if_ale.c: revision 1.7
print chipset name. From OpenBSD.
support flow control. from OpenBSD.
tested by Kevin Lahey
don't read/write 1000baseT specific MII registers on 10/100M only device.
from OpenBSD.
fix multicast.
 1.3.2.2 03-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #735):
sys/dev/pci/if_age.c: revisions 1.1-1.28
sys/dev/pci/if_agereg.h: revisions 1.1-1.2
sys/dev/pci/if_ale.c: revisions 1.1-1.3
sys/dev/pci/if_alereg.h: revisions 1.1-1.2
sys/dev/pci/files.pci: revisions 1.310-1.313
sys/dev/mii/atphy.c: revisions 1.1-1.5
sys/dev/mii/files.mii: revision 1.42
share/man/man4/age.4: revisions 1.1-1.3
share/man/man4/ale.4: revisions 1.1-1.2
share/man/man4/atphy.4: revisions 1.1-1.2
share/man/man4/Makefile: revisions 1.486, 1.489
distrib/sets/lists/man/mi: revisions 1.1118, 1.1132
sys/arch/i386/conf/GENERIC: revisions 1.928, 1.933
sys/arch/i386/conf/XEN2_DOM0: revisions 1.57, 1.60
sys/arch/amd64/conf/GENERIC: revisions 1.239, 1.241
sys/arch/amd64/conf/XEN3_DOM0: revisions 1.38, 1.42
Add the age(4) and ale(4) drivers for Attansic L1 and Atheros
AR8121/AR8113/AR8114 devices respectively.
 1.3.2.1 28-Apr-2009  snj file if_ale.c was added on branch netbsd-5 on 2009-05-03 23:45:47 +0000
 1.10.4.2 05-Mar-2011  rmind sync with head
 1.10.4.1 30-May-2010  rmind sync with head
 1.10.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.10.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.2.2 21-Apr-2010  matt sync to netbsd-5
 1.11.2.1 05-Apr-2010  matt file if_ale.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:40 +0000
 1.12.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.4.1 30-Oct-2012  yamt sync with head
 1.14.2.3 03-Dec-2017  jdolecek update from HEAD
 1.14.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1 23-Jun-2013  tls resync from head
 1.15.4.1 18-May-2014  rmind sync with head
 1.17.6.4 28-Aug-2017  skrll Sync with HEAD
 1.17.6.3 05-Feb-2017  skrll Sync with HEAD
 1.17.6.2 19-Mar-2016  skrll Sync with HEAD
 1.17.6.1 06-Jun-2015  skrll Sync with HEAD
 1.20.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.2.3 05-Dec-2019  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1464):
sys/dev/pci/if_alc.c 1.44 via patch
sys/dev/pci/if_ale.c 1.35-1.36 via patch
sys/dev/pci/if_cas.c 1.36 via patch
- Fix a bug that IFF_ALLMULTI is almost always set.
- Whitespace fixes.
 1.22.2.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.22.2.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.23.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.23.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.23.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.23.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.24.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.24.2.1 10-Jun-2019  christos Sync with HEAD
 1.33.2.3 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.33.2.2 26-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #483):

sys/dev/pci/if_cas.c: revision 1.36
sys/dev/pci/if_alc.c: revision 1.44
sys/dev/pci/if_ale.c: revision 1.35
sys/dev/pci/if_ale.c: revision 1.36
sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

Remove accidentally committed debug code. Sorry.
 1.33.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.37.2.1 29-Feb-2020  ad Sync with head.
 1.4 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.3 03-Sep-2019  msaitoh No functional change to reduce diff against {Free,Open}BSD:
- Fix typo in comment.
- Modify white spaces.
 1.2 25-Apr-2009  tsutsui branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14; 1.2.74;
Add RCS Id.
 1.1 20-Apr-2009  cegger Add ale(4), a driver for Attansic/Atheros L1E gigabit ethernet device.
Ported by me from OpenBSD, improvements from Kevin Lahey,
successfully tested by Kevin Lahey and Stephen Borrill.
 1.2.74.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.14.2 21-Apr-2010  matt sync to netbsd-5
 1.2.14.1 25-Apr-2009  matt file if_alereg.h was added on branch matt-nb5-mips64 on 2010-04-21 00:27:40 +0000
 1.2.8.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.8.1 25-Apr-2009  jym file if_alereg.h was added on branch jym-xensuspend on 2009-05-13 17:20:24 +0000
 1.2.6.2 04-May-2009  yamt sync with head.
 1.2.6.1 25-Apr-2009  yamt file if_alereg.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:56 +0000
 1.2.4.2 03-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #735):
sys/dev/pci/if_age.c: revisions 1.1-1.28
sys/dev/pci/if_agereg.h: revisions 1.1-1.2
sys/dev/pci/if_ale.c: revisions 1.1-1.3
sys/dev/pci/if_alereg.h: revisions 1.1-1.2
sys/dev/pci/files.pci: revisions 1.310-1.313
sys/dev/mii/atphy.c: revisions 1.1-1.5
sys/dev/mii/files.mii: revision 1.42
share/man/man4/age.4: revisions 1.1-1.3
share/man/man4/ale.4: revisions 1.1-1.2
share/man/man4/atphy.4: revisions 1.1-1.2
share/man/man4/Makefile: revisions 1.486, 1.489
distrib/sets/lists/man/mi: revisions 1.1118, 1.1132
sys/arch/i386/conf/GENERIC: revisions 1.928, 1.933
sys/arch/i386/conf/XEN2_DOM0: revisions 1.57, 1.60
sys/arch/amd64/conf/GENERIC: revisions 1.239, 1.241
sys/arch/amd64/conf/XEN3_DOM0: revisions 1.38, 1.42
Add the age(4) and ale(4) drivers for Attansic L1 and Atheros
AR8121/AR8113/AR8114 devices respectively.
 1.2.4.1 25-Apr-2009  snj file if_alereg.h was added on branch netbsd-5 on 2009-05-03 23:45:47 +0000
 1.2.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.2.2.1 25-Apr-2009  skrll file if_alereg.h was added on branch nick-hppapmap on 2009-04-28 07:35:56 +0000
 1.38 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.37 18-Feb-2020  msaitoh Whitespace fix. No functional change.
 1.36 09-Dec-2018  jdolecek branches: 1.36.6;
use pci_intr_establish_xname() everywhere
 1.35 29-Mar-2014  christos branches: 1.35.28; 1.35.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.34 23-Sep-2012  chs branches: 1.34.2;
match some more devices.
 1.33 30-Jan-2012  drochner branches: 1.33.2; 1.33.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.32 26-Jul-2011  dyoung branches: 1.32.2; 1.32.6;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.31 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.30 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.29 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.28 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.27 03-Jul-2008  drochner branches: 1.27.10;
split device/softc (tested with an@pcmcia)
 1.26 28-Apr-2008  martin branches: 1.26.2; 1.26.4;
Remove clause 3 and 4 from TNF licenses
 1.25 10-Apr-2008  cegger branches: 1.25.2; 1.25.4;
use aprint_*_dev and device_xname
 1.24 09-Dec-2007  jmcneill branches: 1.24.10;
Merge jmcneill-pm branch.
 1.23 19-Oct-2007  ad branches: 1.23.4; 1.23.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.22 06-Apr-2007  rumble branches: 1.22.8; 1.22.10; 1.22.14;
If we fail to attach, use the size determined by pci_mapreg_map() rather
than a constant, since this will be incorrect on some chips (MPI350) and
lead to a panic.
 1.21 16-Nov-2006  christos branches: 1.21.4; 1.21.8; 1.21.10;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 11-Dec-2005  christos branches: 1.19.20; 1.19.22;
merge ktrace-lwp.
 1.18 22-Jun-2005  dyoung branches: 1.18.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.17 27-Feb-2005  perry nuke trailing whitespace
 1.16 21-Aug-2004  thorpej branches: 1.16.4; 1.16.6;
Use ANSI function decls and make use of static.
 1.15 05-Aug-2004  mycroft Fix an Aironet product name, and normalize the usage of "Mini-PCI".
 1.14 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.13 29-Jan-2004  martin Fix copy&pasto in last revision that (luckily) broke compilation on sparc64.
Noticed by MOCHIZUKI Tomomitsu.
 1.12 28-Jan-2004  onoe Adopt to new 802.11 framework.
Add support of version 5.30.17 firmware of PCMCIA 350 series.
MPI350 mini-PCI is NOT YET supported.
MONITOR mode is still not yet working.
 1.11 13-Oct-2003  dyoung Switch an(4) to using the header files in the new 802.11 layer.
 1.10 31-Jan-2003  thorpej branches: 1.10.2;
Use aprint_*().
 1.9 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.8 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.7 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.6 13-Nov-2001  lukem add RCSID
 1.5 08-Jul-2001  thorpej branches: 1.5.2;
Remove unnecessary include files. From Onno van der Linden.
 1.4 18-Jun-2001  onoe Add Cisco/Aironet 350
Reported by Wolfgang Rupprecht <wolfgang@wsrcc.com>.
This doesn't fix PR 13181, which says the card doesn't work well.
 1.3 12-Jun-2001  thorpej Don't need NS-related headers here.
 1.2 28-Dec-2000  sommerfeld branches: 1.2.2; 1.2.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.1 14-Dec-2000  onoe Add PCI version of Aironet, not tested at all.
ISA/ISApnp version won't come since I don't know about isa...
 1.2.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.2.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.1 28-Dec-2000  bouyer file if_an_pci.c was added on branch thorpej_scsipi on 2001-01-05 17:36:04 +0000
 1.5.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.10.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.16.4.1 29-Apr-2005  kent sync with -current
 1.18.2.4 21-Jan-2008  yamt sync with head
 1.18.2.3 27-Oct-2007  yamt sync with head.
 1.18.2.2 03-Sep-2007  yamt sync with head.
 1.18.2.1 30-Dec-2006  yamt sync with head.
 1.19.22.2 10-Dec-2006  yamt sync with head.
 1.19.22.1 22-Oct-2006  yamt sync with head
 1.19.20.1 18-Nov-2006  ad Sync with head.
 1.21.10.1 11-Jul-2007  mjf Sync with head.
 1.21.8.2 23-Oct-2007  ad Sync with head.
 1.21.8.1 10-Apr-2007  ad Sync with head.
 1.21.4.1 15-Apr-2007  yamt sync with head.
 1.22.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.10.2 09-Jan-2008  matt sync with HEAD
 1.22.10.1 06-Nov-2007  matt sync with HEAD
 1.22.8.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.22.8.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.22.8.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.8.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.22.8.1 04-Sep-2007  joerg Convert an(4) to new style power management.
 1.23.6.1 11-Dec-2007  yamt sync with head.
 1.23.4.1 26-Dec-2007  ad Sync with head.
 1.24.10.2 28-Sep-2008  mjf Sync with HEAD.
 1.24.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.4.5 11-Mar-2010  yamt sync with head
 1.25.4.4 16-Sep-2009  yamt sync with head
 1.25.4.3 16-May-2009  yamt sync with head
 1.25.4.2 04-May-2009  yamt sync with head.
 1.25.4.1 16-May-2008  yamt sync with head.
 1.25.2.1 18-May-2008  yamt sync with head.
 1.26.4.1 18-Jul-2008  simonb Sync with head.
 1.26.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.27.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.6.1 18-Feb-2012  mrg merge to -current.
 1.32.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.2.2 30-Oct-2012  yamt sync with head
 1.32.2.1 17-Apr-2012  yamt sync with head
 1.33.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.33.2.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #691):
sys/dev/pci/aac_pci.c: revision 1.34
sys/dev/pci/if_sip.c: revision 1.155
sys/dev/pci/if_tlp_pci.c: revision 1.122
sys/dev/pci/if_an_pci.c: revision 1.34
match some more devices.
 1.34.2.1 18-May-2014  rmind sync with head
 1.35.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.30.1 10-Jun-2019  christos Sync with HEAD
 1.35.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.36.6.1 29-Feb-2020  ad Sync with head.
 1.50 26-Feb-2025  andvar Fix typos in comments, mainly s/calcurate/calculate/.
 1.49 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.48 29-Jun-2024  riastradh branches: 1.48.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.47 09-Mar-2024  mrg aq(4): always poll for link status

some devices don't have working link status and rather than have
a likely incomplete list of issues, always poll as well as use
the interrupt if possible.

fixes link status on this device:

aq0 at pci5 dev 0 function 0: Aquantia AQC107 10 Gigabit Network Adapter (rev. 0x02)
aq0: Atlantic revision B1, F/W version 3.1.88

(was otherwise functional, just didn't report status, which likely
meant eg, dhcpcd would be upset?)

idea via mlelstv@ from linux.

remove sc_detect_linkstat and rename sc_poll_linkstat to
sc_no_link_intr, as the meaning has changed. simplify the signature
for aq_setup_msix() and aq_establish_msix_intr(), removing forward
decls that aren't required. obsolete AQ_FORCE_POLL_LINKSTAT.
 1.46 07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.45 29-May-2023  rin aq(4): if_transmit: Invoke softint_schedule(9) with kpreempt disabled.

XXX
Pull up to netbsd-10 and netbsd-9.
 1.44 26-Jan-2023  ryo - Don't discard a packet even if the TX descriptor is temporarily not enough,
and error messages are not output.
- The argument to aq_encap_txring() need not be an mbuf reference, pass an entity.

pointed out by nisimura@. thanks
 1.43 14-Jan-2023  ryo Added support for the Aquantia (Marvell) AQC113 10G Network Adapter and the variants, to aq(4)
 1.42 14-Jan-2023  ryo fix indentation
 1.41 14-Jan-2023  ryo - avoid panic when failing during attach or detach with modload/drvctl.
- free workqueue resources when detaching.
- remove debug message.
 1.40 14-Jan-2023  ryo fix build error in sys/module/if_aq/

avoid error of "comparison of integer expressions of different signedness" and -Werror=sign-compare
 1.39 02-Nov-2022  andvar branches: 1.39.2;
fix various typos in comments and messages.
 1.38 21-Oct-2022  riastradh aq(4): Remove incorrect ASSERT_SLEEPABLE introduced in 1.33.

It is true that aq_stop must be sleepable, and that aq_stop_locked
may sleep, but aq_stop_locked will release sc->sc_mutex when it
sleeps, which ASSERT_SLEEPABLE doesn't know about. Since that is a
spin lock, ASSERT_SLEEPABLE trips over it and crashes.

This is not quite right: aq_stop should really only take the lock
over specific things that need the lock to synchronize with other
threads, like mii_down; aq_init and aq_stop are already serialized by
IFNET_LOCK. sc->sc_mutex is used for too much and should have its
scope narrowed like I did recently in usbnet(9). But this small
change will at least remove a source of crashes for now.
 1.37 17-Oct-2022  riastradh aq(4): Annotate boolean parameters with names for legibility.

No functional change intended.
 1.36 17-Oct-2022  riastradh aq(4): Unconditionally halt callout in aq_stop.

Fixes panic with callout still running on detach after we destroy the
lock, reported by andvar@:

fatal page fault in supervisor mode
trap type 6 code 0 rip 0xffffffff80dfafec cs 0x8 rflags 0x10286 cr2 0xfffffffffffffff0 ilevel 0x2 rsp 0xffffcd085b291ee0
Skipping crash dump on recursive panic
panic: trap
cpu0: Begin traceback...
vpanic() at netbsd:vpanic+0x183
panic() at netbsd:panic+0x3c
trap() at netbsd:trap+0xb27
--- trap (number 6) ---
mutex_oncpu() at netbsd:mutex_oncpu+0x1e
mutex_vector_enter() at netbsd:mutex_vector_enter+0xb7
aq_tick() at netbsd:aq_tick+0x23
callout_softclock() at netbsd:callout_softclock+0xbd
softint_dispatch() at netbsd:softint_dispatch+0xf9
DDB lost frame for netbsd:Xsoftintr+0x4c, trying 0xffffcd085b2920f0
Xsoftintr() at netbsd:Xsoftintr+0x4c
--- interrupt ---
fa0b2181724b21c1:
cpu0: End traceback...
 1.35 22-Sep-2022  skrll Take and release IFNET_LOCK around aq_stop in aq_detach. Also, call with
the disable flag set so that interrupts and the callout are halted.
 1.34 22-Sep-2022  riastradh aq(4): Don't schedule tick callout on interrupt if stopping.

Make sure to take the lock around access to sc_detect_linkstat too.
 1.33 16-Sep-2022  skrll Some MP improvements

- Remove use of IFF_OACTIVE

- Remove use of if_timer and provide an MP safe multiqueue watchdog

- Sprinkle some lock assertions.

Tested by ryo@. Thanks.
 1.32 08-Sep-2022  skrll Sprinkle const. Same binary before and after.
 1.31 13-Nov-2021  ryo firmware ver1 doesn't seem to work with linkstat interrupt, so in this case also set it to polling mode.

- Make the version acquisition (aq_fw_reset) timing earlier.
- Unmap registers when terminating with attach after failing to set interrupt
 1.30 11-Nov-2021  ryo Fixed a panic problem at attach with aq(4) F/W version 1.

- Don't use cprng(9) when attaching, since it's not available yet.
- Wait up to 10 seconds because delay is not enough.
- Even if the delay is not enough, it will fail attach without panic.
- Checked on the actual card D107 (F/W version 1.5.58)
 1.29 11-Oct-2021  msaitoh Add pmf_device_register().
 1.28 05-Oct-2021  ryo fix a panic "m_verify_packet: inconsistent mbuf length" on aq(4).

- If mbuf cannot be allocated or some errors occur when receiving a jumboframe,
it is necessary to free mbuf chains of the packet being received, and ignore
the subsequent segments that make up the packet.
- Even if aq_rx_intr() is completed in the middle of the jumboframe
reception process, it will resume normally at the next aq_rx_intr().
 1.27 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.26 13-Jun-2021  mlelstv Don't ignore errors of sysmon_envsys_register().
 1.25 16-Apr-2021  ryo branches: 1.25.2;
fix typo
 1.24 16-Apr-2021  ryo when the packet size was just n*MCLBYTES, there was an inconsistency in the length of mbuf.
 1.23 15-Apr-2021  ryo mtu for revision B0 and B1 is supported up to 16338 bytes
 1.22 15-Apr-2021  ryo fixed the problem of instability when changing mtu in IFF_UP state
 1.21 15-Apr-2021  ryo add support hardware tcp/udp rx checksum offloading
 1.20 18-Feb-2021  ryo branches: 1.20.2;
- use if_initialize() and if_register() instead of if_attach()
- add IFEF_MPSAFE to if_extflags

pointed out by msaitoh@, thanks
 1.19 24-Sep-2020  ryo branches: 1.19.2;
add __aligned() to all __packed structures.

suppress warnings, and allow to compiler to generate more efficent code.
 1.18 24-Sep-2020  ryo no need to swap 32bit-packed macaddr on big endian
 1.17 14-May-2020  msaitoh branches: 1.17.2;
Remove extra semicolon.
 1.16 24-Apr-2020  ryo fix typo
 1.15 24-Apr-2020  ryo add support AQC100S and D100.
not tested, but they are probably the same as the AQC100.
 1.14 23-Apr-2020  ryo sort product table, and tabify
 1.13 23-Apr-2020  ryo On FIBRE devices, there are times when linkstat interrupt doesn't occur?
reported from Andrius V. thanks.

- use polling instead of linkstat interrupt when FIBRE
- add AQ_FORCE_POLL_LINKSTAT options (not by default)
 1.12 22-Apr-2020  christos Add AQUANTIA AQC100 from Andrius V.
 1.11 15-Feb-2020  ryo branches: 1.11.4; 1.11.6;
return the ifmedia active status correctly even while the link is not up after attach.

pointed out by msaitoh@. thanks.
 1.10 10-Feb-2020  ryo add support VLAN HW filter
 1.9 10-Feb-2020  ryo fix descriptions of register map in comment
 1.8 08-Feb-2020  maxv constify
 1.7 04-Feb-2020  thorpej Use ifmedia_fini().
 1.6 31-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.5 25-Jan-2020  msaitoh Found by kUBSan:

- Use unsigned to avoid undefined behavior in aq_hw_init().
- Cast to unsigned to avoid undefined behavior in aq_set_mac_addr().
 1.4 17-Jan-2020  ryo support internal PHY temperature sensor
 1.3 17-Jan-2020  ryo make counters per queue
 1.2 17-Jan-2020  ryo set/clear IFF_OACTIVE flag only on txring 0
 1.1 01-Jan-2020  ryo branches: 1.1.2;
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.
 1.1.2.3 29-Feb-2020  ad Sync with head.
 1.1.2.2 25-Jan-2020  ad Sync with head.
 1.1.2.1 17-Jan-2020  ad Sync with head.
 1.11.6.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.11.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.4.1 15-Feb-2020  martin file if_aq.c was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.17.2.4 03-Jun-2023  martin Pull up following revision(s) (requested by rin in ticket #1637):

sys/dev/pci/if_aq.c: revision 1.45

aq(4): if_transmit: Invoke softint_schedule(9) with kpreempt disabled.
 1.17.2.3 07-Jul-2020  martin Also pull up more cosmetic revisions to minimize diffs with HEAD, requested
by jmcneill in ticket #980:

sys/dev/pci/if_aq.c 1.8,1.17

constify, remove duplicate ;
 1.17.2.2 07-Jul-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #980):

sys/dev/pci/if_aq.c: revision 1.4
sys/dev/pci/if_aq.c: revision 1.5
sys/arch/amd64/conf/GENERIC: revision 1.553
sys/dev/pci/files.pci: revision 1.419
sys/arch/amd64/conf/XEN3_DOM0: revision 1.170
sys/dev/pci/if_aq.c: revision 1.9
share/man/man4/Makefile: revision 1.693
sys/dev/pci/pcidevs: revision 1.1411
share/man/man4/aq.4: revision 1.1
share/man/man4/aq.4: revision 1.3
sys/arch/i386/conf/ALL: revision 1.479
share/man/man4/aq.4: revision 1.4
sys/dev/pci/if_aq.c: revision 1.10
sys/dev/pci/files.pci: revision 1.421
sys/dev/pci/if_aq.c: revision 1.11
sys/dev/pci/if_aq.c: revision 1.12
sys/dev/pci/if_aq.c: revision 1.13
sys/dev/pci/if_aq.c: revision 1.14
sys/dev/pci/if_aq.c: revision 1.15
sys/dev/pci/if_aq.c: revision 1.16
sys/dev/pci/pcidevs: revision 1.1408
sys/arch/amd64/conf/ALL: revision 1.135
sys/net/ethertypes.h: revision 1.19
sys/arch/i386/conf/GENERIC: revision 1.1218
distrib/sets/lists/man/mi: revision 1.1668
sys/dev/pci/if_aq.c: revision 1.1
sys/dev/pci/if_aq.c: revision 1.2
sys/dev/pci/pcidevs: revision 1.1395
sys/dev/pci/if_aq.c: revision 1.3
sys/arch/evbarm/conf/GENERIC64: revision 1.125

Add the ETHERTYPE_QINQ for 802.1ad VLAN stacking

add Aquantia AQC 10G network adapters
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.

add aq(4)

Add Aquantia AQC100, AQC100S and D100.

add support VLAN HW filter

set/clear IFF_OACTIVE flag only on txring 0

make counters per queue

support internal PHY temperature sensor

Found by kUBSan:
- Use unsigned to avoid undefined behavior in aq_hw_init().
- Cast to unsigned to avoid undefined behavior in aq_set_mac_addr().

fix descriptions of register map in comment

return the ifmedia active status correctly even while the link is not up after attach.
pointed out by msaitoh@. thanks.

On FIBRE devices, there are times when linkstat interrupt doesn't occur?
reported from Andrius V. thanks.
- use polling instead of linkstat interrupt when FIBRE
- add AQ_FORCE_POLL_LINKSTAT options (not by default)

sort product table, and tabify

add support AQC100S and D100.
not tested, but they are probably the same as the AQC100.
 1.17.2.1 14-May-2020  martin file if_aq.c was added on branch netbsd-9 on 2020-07-07 10:29:05 +0000
 1.19.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.20.2.1 17-Apr-2021  thorpej Sync with HEAD.
 1.25.2.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.39.2.2 03-Jun-2023  martin Pull up following revision(s) (requested by rin in ticket #187):

sys/dev/pci/if_aq.c: revision 1.45

aq(4): if_transmit: Invoke softint_schedule(9) with kpreempt disabled.
 1.39.2.1 30-Jan-2023  martin Pull up following revision(s) (requested by ryo in ticket #60):

sys/dev/pci/if_aq.c: revision 1.40
sys/dev/pci/if_aq.c: revision 1.41
sys/dev/pci/if_aq.c: revision 1.42
sys/dev/pci/if_aq.c: revision 1.43
sys/dev/pci/if_aq.c: revision 1.44
share/man/man4/aq.4: revision 1.5

fix build error in sys/module/if_aq/

avoid error of "comparison of integer expressions of different signedness" and -Werror=sign-compare
- avoid panic when failing during attach or detach with modload/drvctl.
- free workqueue resources when detaching.
- remove debug message.

fix indentation

Added support for the Aquantia (Marvell) AQC113 10G Network Adapter and the variants, to aq(4)
- add AQC113 and the variants
- fix first appeared version to 9.1. it was backported.
- Don't discard a packet even if the TX descriptor is temporarily not enough,
and error messages are not output.
- The argument to aq_encap_txring() need not be an mbuf reference, pass an entity.
pointed out by nisimura@. thanks
 1.48.2.1 02-Aug-2025  perseant Sync with HEAD
 1.50 09-Dec-2018  jdolecek put back the intr establish to ath_pci_resume() to avoid possibility of
functionality change, but add XXX comment that it shouldn't be necessary
 1.49 09-Dec-2018  jdolecek use pci_intr_establish_xname()

upon code inspection, remove intr re-establish from ath_pci_resume() -
not needed to re-establish interrupt there, no other driver does this,
and very likely it would actually fail nowadays
 1.48 29-Mar-2014  christos branches: 1.48.28; 1.48.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.47 30-Mar-2013  christos branches: 1.47.4;
remove trailing whitespace
 1.46 04-Aug-2012  riastradh branches: 1.46.2;
Fix error branches in ath pci attachment.

Should fix double pci_intr_disestablish if ath_attach fails.

(Still not sure why ath_attach sometimes fails here.)
 1.45 18-Oct-2011  dyoung branches: 1.45.2; 1.45.8;
Reduce differences from if_ath_cardbus.c.
 1.44 07-Oct-2011  dyoung Stop calling ATH_LOCK_{INIT,DESTROY}(), they don't exist any more.
 1.43 29-Aug-2011  jmcneill have pci register itself as a module, and make PCI driver modules depend on it
 1.42 26-Jul-2011  dyoung Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.41 21-Feb-2011  jmcneill print the device name at attach, like so:

ath0 at pci4 dev 0 function 0: Atheros 9280
 1.40 20-Feb-2011  jmcneill support building as a module
 1.39 26-Jan-2011  dyoung Improve error reporting during attachment to PCI ath(4).
 1.38 28-Apr-2010  dyoung branches: 1.38.2; 1.38.4;
To reduce differences between ath(4)'s PCI attachment and its CardBus
attachment, delete several unnecessary #includes, re-order subroutines,
move around line breaks, change to different names for the same
constant, et cetera. Comparing this version of if_ath_pci.c with my
uncommitted version of if_ath_cardbus.c, only about five lines are
different.
 1.37 24-Feb-2010  dyoung branches: 1.37.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.36 08-Jan-2010  dyoung branches: 1.36.2;
Expand PMF_FN_* macros.
 1.35 16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.34 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.33 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32 11-Dec-2008  alc branches: 1.32.2;
Sync ath(4) with the new HAL, mostly based on <jmcneill>'s patches.

Everything should be fine again !
 1.31 09-Jul-2008  joerg branches: 1.31.2; 1.31.4; 1.31.10;
- device/softc split for ath(4)
 1.30 12-Mar-2008  dyoung branches: 1.30.4; 1.30.6; 1.30.8; 1.30.10;
Use device_t and its accessors throughout. Use aprint_*_dev().

Improve PMF-ability.

Add a 'flags' argument to suspend/resume handlers and
callers such as pmf_system_suspend().

Define a flag, PMF_F_SELF, which indicates to PMF that a
device is suspending/resuming itself. Add helper routines,
pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
that call pmf_device_suspend(dev, PMF_F_SELF) and
pmf_device_resume(dev, PMF_F_SELF), respectively. Use
PMF_F_SELF to suspend/resume self in ath(4), audio(4),
rtw(4), and sip(4).

In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
callbacks, provided by the bus front-end, with
self-suspension/resumption. Also, clean up the bus
front-ends. Make sure that the interrupt handler is
disestablished during suspension. Get rid of driver-private
flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
device_is_active()/device_has_power() calls, instead.

In the network-class suspend handler, call if_stop(, 0)
instead of if_stop(, 1), because the latter is superfluous
(bus- and driver-suspension hooks will 'disable' the NIC),
and it may cause recursion.

In the network-class resume handler, prevent infinite
recursion through if_init() by getting out early if we are
self-suspending (PMF_F_SELF).

rtw(4) improvements:

Destroy rtw(4) callouts when we detach it. Make rtw at
pci detachable. Print some more information with the "rx
frame too long" warning.

Remove activate() methods:

Get rid of rtw_activate() and ath_activate(). The device
activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

Introduce a boolean device property, "pmf-powerdown". If
pmf-powerdown is present and false, it indicates that a
bus back-end should not remove power from a device.

Honor this property in cardbus_child_suspend().

Set this property to 'false' in ath_attach(), since removing
power from an ath at cardbus seems to lobotomize the WPA
crypto engine. XXX Should the pmf-powerdown property
propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

Warn if ath(4) tries to write crypto keys to suspended
hardware.

Reduce differences between FreeBSD and NetBSD in ath(4)
multicast filter setup.

Make ath_printrxbuf() print an rx descriptor's status &
key index, to help debug crypto errors.

Shorten a staircase in ath_ioctl(). Don't check for
ieee80211_ioctl() return code ERESTART, it never happens.
 1.29 07-Mar-2008  dyoung In ath_pci_detach(), only disestablish the interrupt handler if it
is established.
 1.28 28-Jan-2008  dyoung branches: 1.28.2; 1.28.6;
Remove dead code and associated comments.
 1.27 21-Dec-2007  dyoung Initialize and destroy the ATH_LOCK.
 1.26 15-Dec-2007  dyoung In ath_pci_detach(), unmap bus memory.
 1.25 14-Dec-2007  dyoung Comment-out calls to pci_disable_retry() and cardbus_disable_retry().
They do not seem well-justified according to anyone's understanding
of what they really do, and it seems especially inappropriate to
call them at attach- and resume-time.
 1.24 14-Dec-2007  mjf Reorder the previous commit so we remember to disestablish pci interrupts
if we fail to attach ath(4).

Thanks dyoung!
 1.23 14-Dec-2007  mjf Fix a crash at shutdown/reboot that was caused by ath(4) registering with
pmf's network class even though the ath device may not have attached
properly.

OK jmcneill
 1.22 09-Dec-2007  jmcneill branches: 1.22.2;
Merge jmcneill-pm branch.
 1.21 17-Apr-2007  dyoung branches: 1.21.6; 1.21.8; 1.21.14; 1.21.16; 1.21.18;
Cosmetic: fix whitespace, join two lines, remove extraneous #includes.
#Define a bitmask using __BITS() instead of a hex constant, for
easy comparison with paper documentation.
 1.20 17-Apr-2007  dyoung Add prototype for ath_pci_detach(). Alphabetize prototypes.

Extract the code for disabling PCI retries, creating ath_disable_retry(),
and call it both during device initialization and on ->PWR_RESUME
transitions. Comment out the code in ath_disable_retry() for now,
because it is not clear what problem it solves, if any.

Set a reasonable PCI Latency Timer. Apparently, it is too much to
ask any BIOS to do. The PCI framework ought to set latency timers,
instead of individual drivers setting latency timers.
 1.19 16-Nov-2006  christos branches: 1.19.4; 1.19.8; 1.19.10;
__unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.16 01-Aug-2006  martin branches: 1.16.4; 1.16.6;
If the card presents 64bit memory, map it as that.
Fixes PR kern/34045.
 1.15 14-Jul-2006  seanb Consistently establish / disestablish shutdown hook
in the bus layer and remove from common ath_attach().
Having it in both layers (on some bus architectures)
was causing a double call to ath_stop() on shutdown
which in turn was tickling the bus lockup described
therin on slower machines.
 1.14 20-Jun-2006  perry Power hook for ath pci front end.

Written and tested by George Michaelson [ggm at apnic.net]
 1.13 05-Jun-2006  gdamore branches: 1.13.2;
Import new HAL 0.9.17.2. Approved by sam@

New HAL includes some driver changes to register accesses.
Adds support for WLAN devices on AR5312 family devices.
Adds support 32-bit SPARC ath devices (untested).
ath enabled in SPARC64 GENERIC builds.
This HAL is tested and known to work for i386 PCI devices, SPARC64 PCI devices,
and AR5312 WiSoC devices. MIPS PCI devices appear to be busted (possibly only
on Alchemy hardware, unconfirmed), and cardbus support is untested due to
lack of test hardware.

Please report any new problems with this import to garrett@.
 1.12 02-Apr-2006  gdamore branches: 1.12.2;
Reorganize ath layout as requested by sam@ and suggested by dyoung@ in
http://mail-index.netbsd.org/tech-net/2006/03/15/0000.html.

The new layout almost precisely matches FreeBSD, and should make
future imports much easier.

At the same time, import the current 0.9.16.16 HAL from FreeBSD. According
to sam@, this is the proper version we should be using.
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10; 1.11.12;
merge ktrace-lwp.
 1.10 22-Jun-2005  martin branches: 1.10.2;
Remove unused <atomic.h> include; add <sys/device.h> includes where
needed.
 1.9 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.8 27-Feb-2005  perry nuke trailing whitespace
 1.7 30-Jun-2004  mycroft branches: 1.7.2; 1.7.6; 1.7.8;
This should be done in the HAL, but until then...
Hack the match function to accept an alternate Atheros vendor ID by munging it
to look like the expected one. This is needed for DWL-G520 cards (which
otherwise "just work").
 1.6 30-Apr-2004  dyoung Synchronize with FreeBSD by adding two comments.
 1.5 16-Dec-2003  dyoung branches: 1.5.2;
Synchronize with FreeBSD:

* add constants to enums

* HAL update: stops panics, fixes ad hoc-mode beacons, some API
changes

* get and use mac/phy/rf front-end revision codes

* add a custom ath(4) ic_node_getrssi callback which does RSSI
averaging

* do not immediately scan, but re-associate after missing beacons.

* bug fix: don't if_init after detach.

* HAL diagnostics ioctl, SIOCGATHDIAG

* send DS parameters element in beacons

* const-ify some pointers

* consolidate rx-filter settings into ath_calcrxfilter

* abstract FreeBSD `ticks', NetBSD `hardclock_ticks' with ATH_TICKS()

* misc. other changes
 1.4 15-Oct-2003  itojun $NetBSD$
 1.3 15-Oct-2003  itojun translate pci device ID until HAL gets updated. suggested by sam leffler
 1.2 13-Oct-2003  dyoung ath(4) PCI front-end for NetBSD, heavily modified from FreeBSD's.
Substantially influenced by the patch from Bruce J.A. Nourish.
 1.1 07-Oct-2003  dyoung branches: 1.1.1;
Initial revision
 1.1.1.4 21-Jun-2005  dyoung Import FreeBSD's ath(4) of 2005-05-18
 1.1.1.3 29-Apr-2004  dyoung Import FreeBSD's ath of 28-apr-2004
 1.1.1.2 15-Dec-2003  dyoung Import FreeBSD's ath of 12-dec-2003
 1.1.1.1 07-Oct-2003  dyoung Initial import of ath(4) from FreeBSD.
 1.5.2.1 02-Jul-2004  he Pull up revision 1.7 (requested by mycroft in ticket #582):
Accept an alternate Atheros vendor ID by munging it to look
like the expected one. This is needed for DWL-G520 cards
which otherwise ``just work''. This should eventually be
dealt with in the HAL.
 1.7.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.6.1 29-Apr-2005  kent sync with -current
 1.7.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 30-Jun-2004  skrll file if_ath_pci.c was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.10.2.6 17-Mar-2008  yamt sync with head.
 1.10.2.5 04-Feb-2008  yamt sync with head.
 1.10.2.4 21-Jan-2008  yamt sync with head
 1.10.2.3 03-Sep-2007  yamt sync with head.
 1.10.2.2 30-Dec-2006  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.11.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.11.10.1 19-Apr-2006  elad sync with head.
 1.11.8.3 11-Aug-2006  yamt sync with head
 1.11.8.2 26-Jun-2006  yamt sync with head.
 1.11.8.1 11-Apr-2006  yamt sync with head
 1.11.6.2 07-Jun-2006  kardel Sync with head.
 1.11.6.1 22-Apr-2006  simonb Sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.2.1 19-Jun-2006  chap Sync with head.
 1.13.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.16.6.2 10-Dec-2006  yamt sync with head.
 1.16.6.1 22-Oct-2006  yamt sync with head
 1.16.4.1 18-Nov-2006  ad Sync with head.
 1.19.10.1 11-Jul-2007  mjf Sync with head.
 1.19.8.1 27-May-2007  ad Sync with head.
 1.19.4.1 07-May-2007  yamt sync with head.
 1.21.18.1 11-Dec-2007  yamt sync with head.
 1.21.16.1 26-Dec-2007  ad Sync with head.
 1.21.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.21.8.2 23-Mar-2008  matt sync with HEAD
 1.21.8.1 09-Jan-2008  matt sync with HEAD
 1.21.6.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.21.6.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.21.6.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.21.6.1 23-Aug-2007  joerg Convert ath(4) to new style power management.
Remove the resetting of the PCI retry register on resume,
the restored configuration should have it already.
 1.22.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.28.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.28.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.28.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.28.2.1 24-Mar-2008  keiichi sync with head.
 1.30.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.30.10.1 19-Oct-2008  haad Sync with HEAD.
 1.30.8.1 18-Jul-2008  simonb Sync with head.
 1.30.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.4.5 11-Aug-2010  yamt sync with head.
 1.30.4.4 11-Mar-2010  yamt sync with head
 1.30.4.3 16-Sep-2009  yamt sync with head
 1.30.4.2 16-May-2009  yamt sync with head
 1.30.4.1 04-May-2009  yamt sync with head.
 1.31.10.1 21-Apr-2010  matt sync to netbsd-5
 1.31.4.1 07-Aug-2009  snj Pull up following revision(s) (requested by sborrill in ticket #903):
sys/dev/cardbus/if_ath_cardbus.c: revision 1.32
sys/dev/pci/if_ath_pci.c: revision 1.32
Sync ath(4) with the new HAL, mostly based on <jmcneill>'s patches.
Everything should be fine again !
 1.31.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.32.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.37.2.2 05-Mar-2011  rmind sync with head
 1.37.2.1 30-May-2010  rmind sync with head
 1.38.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.38.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.38.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.8.1 12-Aug-2012  martin Pull up following revision(s) (requested by riastradh in ticket #476):
sys/dev/pci/if_ath_pci.c: revision 1.46
Fix error branches in ath pci attachment.
Should fix double pci_intr_disestablish if ath_attach fails.
(Still not sure why ath_attach sometimes fails here.)
 1.45.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.2.1 30-Oct-2012  yamt sync with head
 1.46.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.2.1 23-Jun-2013  tls resync from head
 1.47.4.1 18-May-2014  rmind sync with head
 1.48.30.1 10-Jun-2019  christos Sync with HEAD
 1.48.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.14 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.13 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.12 24-Nov-2015  jakllsch branches: 1.12.16; 1.12.18;
Revert previous. At least AR9280 and AR9285 apparently do not have
working-by-default MSI functionality, despite advertising such.

Fixes PR kern/50465.
 1.11 17-Nov-2015  jakllsch Switch PCI athn(4) attachment from pci_intr_map() to
pci_intr_alloc()/pci_intr_release(), this enables MSI where available.
 1.10 29-Mar-2014  christos branches: 1.10.4; 1.10.8;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.9 08-Dec-2013  martin Cosmectic: use the same define in all places when referencing the BAR.
No functional change.
 1.8 21-Apr-2013  msaitoh branches: 1.8.4; 1.8.6;
Delete "PCI_" from PCIX and PICE capability registers.
 1.7 06-Apr-2013  martin Prefer this driver over the old ath(4)
 1.6 05-Apr-2013  martin Move interrupt printout past main attach message
 1.5 03-Apr-2013  christos instead of ifnet use ethercom.
 1.4 31-Mar-2013  martin setup interface backpointer
 1.3 31-Mar-2013  martin Initialize sc_dev
 1.2 31-Mar-2013  martin Fix obvious copy&pasto
 1.1 30-Mar-2013  christos This is the initial port of OpenBSD's athn(4) driver. It supports
quite a few Atheros 802.11n devices. See the athn(4) manpage for a
list.

This port has only been tested with a TP-LINK TL-WN722N USB adapter
which has an AR9271 chipset (VENDOR: 0x0cf3, PRODUCT: 0x9271). The
BSS, Monitor, and HostAP modes all seem to work on that adapter,
though the later has not been tested much.

The driver also supports PCI and CardBUS devices, but those interfaces
are completely untested and probably won't work at this point.

If someone can provide me with other adapters that should be
supported, particularly PCI or CardBUS adapters, or tell me where I
can get one cheaply, I would be happy to try to get the driver working
on those devices as well.
 1.8.6.1 18-May-2014  rmind sync with head
 1.8.4.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.4.2 23-Jun-2013  tls resync from head
 1.8.4.1 21-Apr-2013  tls file if_athn_pci.c was added on branch tls-maxphys on 2013-06-23 06:20:18 +0000
 1.10.8.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.10.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.4.1 29-Mar-2014  yamt file if_athn_pci.c was added on branch yamt-pagecache on 2014-05-22 11:40:24 +0000
 1.12.18.2 10-Jun-2019  christos Sync with HEAD
 1.12.18.1 12-Jul-2018  phil State save. New kernel config for this brach only. TESTWIFI does
produce a kernel. It is not working. athn files not compiling yet
and commented out of the TESTWIFI kernel, which only has urtwn 802.11
driver enabled. ieee80211_alq.c and ieee80211_ddb.c not compiling yet.
 1.12.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.29 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.28 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.27 14-Jul-2016  msaitoh branches: 1.27.16; 1.27.18;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.26 29-Mar-2014  christos branches: 1.26.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.25 26-Jul-2011  dyoung branches: 1.25.2; 1.25.12; 1.25.16;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.24 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.23 08-Jan-2010  dyoung branches: 1.23.2;
Expand PMF_FN_* macros.
 1.22 16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.21 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.20 09-Jul-2008  joerg branches: 1.20.8;
- device/softc split
 1.19 28-Apr-2008  martin branches: 1.19.2; 1.19.4; 1.19.6;
Remove clause 3 and 4 from TNF licenses
 1.18 21-Mar-2008  dyoung branches: 1.18.2; 1.18.4;
Use aprint_*_dev() instead of accessing struct device member dv_xname
directly.
 1.17 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.16 07-Mar-2008  dyoung Use device_t and accessors.
 1.15 19-Oct-2007  ad branches: 1.15.12; 1.15.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.14 16-Nov-2006  christos branches: 1.14.8; 1.14.22; 1.14.24; 1.14.28;
__unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 17-Jun-2006  christos branches: 1.12.4; 1.12.6;
re-factor the pci powestate api. reviewed by gimpy
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.8; 1.11.14; 1.11.16;
merge ktrace-lwp.
 1.10 22-Jun-2005  dyoung branches: 1.10.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.9 27-Feb-2005  perry nuke trailing whitespace
 1.8 21-Aug-2004  thorpej branches: 1.8.4; 1.8.6;
Use ANSI function decls and make use of static.
 1.7 23-Jul-2004  dyoung branches: 1.7.2;
Print and store Cardbus/PCI revision number.

Begin conditioning device configuration on revision number. Four
revisions are known:

1.1/1.5 -> ADM8211A,
2.0 -> ADM8211B,
3.0 -> ADM8211C.

The B and C parts, which are not supported yet, have AP capability.
 1.6 17-Feb-2004  dyoung Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.
 1.5 29-Jan-2004  dyoung Get rid of __P.
 1.4 29-Jan-2004  dyoung Add atw_pci_enable, atw_pci_disable. Fixes a panic at "ifconfig
down" that was reported by Darren Reed.
 1.3 16-Nov-2003  dyoung Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
 1.2 13-Oct-2003  dyoung Adapt atw(4) to the new 802.11 layer.

Simplify atw_start, atw_newstate.

Synchronize access to atw_start by bracketing the call to
ieee80211_next_scan in atw_next_scan with splnet()/splx().
 1.1 06-Jul-2003  dyoung Oops. Add the atw(4) sources, too.
 1.7.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.4 25-Aug-2004  skrll Sync with HEAD.
 1.7.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 23-Jul-2004  skrll file if_atw_pci.c was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.8.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.2.5 24-Mar-2008  yamt sync with head.
 1.10.2.4 17-Mar-2008  yamt sync with head.
 1.10.2.3 27-Oct-2007  yamt sync with head.
 1.10.2.2 30-Dec-2006  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.11.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.11.14.1 19-Jun-2006  chap Sync with head.
 1.11.8.1 26-Jun-2006  yamt sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.6.2 10-Dec-2006  yamt sync with head.
 1.12.6.1 22-Oct-2006  yamt sync with head
 1.12.4.1 18-Nov-2006  ad Sync with head.
 1.14.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.14.24.2 23-Mar-2008  matt sync with HEAD
 1.14.24.1 06-Nov-2007  matt sync with HEAD
 1.14.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.8.1 23-Oct-2007  ad Sync with head.
 1.15.16.3 28-Sep-2008  mjf Sync with HEAD.
 1.15.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.15.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.12.1 24-Mar-2008  keiichi sync with head.
 1.18.4.4 11-Mar-2010  yamt sync with head
 1.18.4.3 16-May-2009  yamt sync with head
 1.18.4.2 04-May-2009  yamt sync with head.
 1.18.4.1 16-May-2008  yamt sync with head.
 1.18.2.1 18-May-2008  yamt sync with head.
 1.19.6.1 19-Oct-2008  haad Sync with HEAD.
 1.19.4.1 18-Jul-2008  simonb Sync with head.
 1.19.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.20.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.25.16.1 18-May-2014  rmind sync with head
 1.25.12.2 03-Dec-2017  jdolecek update from HEAD
 1.25.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.6.1 05-Oct-2016  skrll Sync with HEAD
 1.27.18.1 10-Jun-2019  christos Sync with HEAD
 1.27.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.65 10-Feb-2024  andvar s/alloted/allotted/ in comments.
 1.64 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.63 27-Jun-2023  nisimura correct register function annotation as it's for receive coalesce.
 1.62 25-Sep-2022  andvar s/inerrupt/interrupt/ and s/intrrupt/interrupt/ in comments.
 1.61 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.60 22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.59 10-Sep-2021  jakllsch No need to #include "vlan.h", as NVLAN is not used in these drivers now.
 1.58 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.57 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.56 18-Oct-2019  msaitoh branches: 1.56.2;
From OpenBSD:
- Mark ETHERCAP_VLAN_MTU.
- Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
- Set proper LED modes.
 1.55 18-Oct-2019  msaitoh - Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unneccesary inclusion.
 1.54 18-Oct-2019  msaitoh s/initalize/initialize/ in comment or printf message.
 1.53 17-Oct-2019  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.52 30-May-2019  msaitoh branches: 1.52.2;
Simplify MII structure initialization and reference. No functional change.
 1.51 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.50 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.49 10-Jan-2019  msaitoh Remove extra register read in bce_mii_write().
 1.48 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.47 26-Jun-2018  msaitoh branches: 1.47.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.46 19-Apr-2017  msaitoh branches: 1.46.4; 1.46.10;
Add another BCM4401 chip support.
 1.45 19-Apr-2017  msaitoh Use macro. No binary change.
 1.44 15-Dec-2016  ozaki-r branches: 1.44.2;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.43 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.42 10-Jun-2016  ozaki-r branches: 1.42.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.41 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.40 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.39 10-Aug-2014  tls branches: 1.39.4;
Merge tls-earlyentropy branch into HEAD.
 1.38 29-Mar-2014  christos branches: 1.38.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.37 22-Jul-2012  matt branches: 1.37.2; 1.37.4;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.36 20-Feb-2012  mrg convert to device_t.
been running on my inspiron 8500 for a couple of months.
 1.35 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.34 19-Nov-2011  tls branches: 1.34.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.33 13-Nov-2010  uebayasi branches: 1.33.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.32 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.31 24-Feb-2010  dyoung branches: 1.31.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.30 19-Jan-2010  pooka branches: 1.30.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.29 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.28 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.27 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.26 16-Jul-2009  jakllsch Correctly bus_dmamap_sync() the transmit descriptors.
Previously the sync could run off the end and not sync
the beginning of the ring. Logic gleaned from if_nfe.
 1.25 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.24 18-Jan-2009  mrg branches: 1.24.2;
Enable flow control and poll the status appropriately.

contributed anonymously.
 1.23 11-Mar-2008  dyoung branches: 1.23.4; 1.23.12;
Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.22 22-Feb-2008  dyoung use device_t and accessors. Use aprint_*_dev(). Do not cast the
softc to 'struct device *', but use &sc->bce_dev instead. Use
PMF_FN_*.
 1.21 30-Jan-2008  simonb branches: 1.21.2; 1.21.6;
Add a simple resume hook that just calls bce_reset(), and register
this with pmf_device_register().

Makes suspend/resume with bce happy. Much thanks to Jared for help here.
 1.20 30-Jan-2008  simonb WextraRemove unused DPRINTF/DPRINTFN macros.
Remove NetBSD 1.6 compatibility checks (way out of date).
Be somewhat consistent (and closer to KNF) with whitespace.
Use uintN_t instead of u_intN_t.

No functional changes.
 1.19 19-Jan-2008  dyoung Use the common code for ethernet media handling. Compiles on i386.
 1.18 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.17 19-Jul-2007  dsl branches: 1.17.6; 1.17.12; 1.17.14; 1.17.16; 1.17.18; 1.17.20;
include sys/cdefs.h
 1.16 09-Jul-2007  ad branches: 1.16.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.15 21-Mar-2007  dan teach bce(4) about being an rnd(4) source
 1.14 04-Mar-2007  christos branches: 1.14.2; 1.14.4; 1.14.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 21-Feb-2007  mrg add a pair of new bus_dma(9) functions:
int _bus_dmatag_subregion(bus_dma_tag_t tag,
bus_addr_t min_addr,
bus_addr_t max_addr,
bus_dma_tag_t *newtag,
int flags)
void _bus_dmatag_destroy(bus_dma_tag_t tag)

that allow a (normally broken/limited) device to restrict the bus address
range it can talk to. this is used by bce(4) to limit DMA addresses to
1GB range, the maximum the chip can address.

all this is from Yorick Hardy <yhardy@uj.ac.za> with input from several
people on tech-kern.

XXX: bus_dma(9) needs an update still.
 1.12 16-Nov-2006  christos branches: 1.12.4;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 07-Jul-2006  simonb branches: 1.10.4; 1.10.6;
s/writting/writing/.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.8; 1.9.16;
merge ktrace-lwp.
 1.8 02-Feb-2005  christos branches: 1.8.6;
PR/29196: Robert Elz: Add support for Broadcom BCM4401-B0 ethernet
 1.7 30-Jan-2005  thorpej Eliminate use of M_HASFCS.
 1.6 21-Aug-2004  thorpej branches: 1.6.4; 1.6.6;
Use ANSI function decls and make use of static.
 1.5 09-Jul-2004  mycroft branches: 1.5.2;
Keep track of what we set the interrupt mask to, rather than reading it from
the chip.
 1.4 23-Apr-2004  joda fix obvious past-o where the activity led register gets overwritten by
the traffic meter led register
 1.3 29-Sep-2003  mrg branches: 1.3.2;
- convert to new aprint*() autoconfig print mechanism
- clean up some magic numbers
- make 1.6 friendly
 1.2 28-Sep-2003  mrg from Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>:
- if_bcereg.h should only have register definitions, so declarations
of softc structure etc. should be in if_bce.c.
- The types of DMA descriptors should be u_int32_t, not unsigned long.
- netinet headers are not required here.
- Values passed via bce_tx_ring should also be byte-swapped.
- byte-swapping is not needed for bus_space access.

from me:
- KNF
- mark all magic numbers with /* MAGIC */ so they can be identified at
some point. there are 33 in total though many appear to be the same
value, or related (eg, the 6 emac points.)

leaves these issues:
- RX pre-packet headers need to be byte-swapped or not?
- PAGE_SIZE bytes are allocated for both TX and RX DMA ring descriptors,
but they should be 1024 (== sizeof(struct bce_dma_slot) * N[TR]XDESC).
- the mcast filter.
 1.1 27-Sep-2003  mrg add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by
yours truly.

XXX: missing mcast filter support.

thanks cliff!
 1.3.2.4 05-Oct-2003  tron Pull up revision 1.3 (requested by mrg in ticket #1486):
- convert to new aprint*() autoconfig print mechanism
- clean up some magic numbers
- make 1.6 friendly
 1.3.2.3 05-Oct-2003  tron Pull up revision 1.2 (requested by mrg in ticket #1486):
from Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>:
- if_bcereg.h should only have register definitions, so declarations
of softc structure etc. should be in if_bce.c.
- The types of DMA descriptors should be u_int32_t, not unsigned long.
- netinet headers are not required here.
- Values passed via bce_tx_ring should also be byte-swapped.
- byte-swapping is not needed for bus_space access.
from me:
- KNF
- mark all magic numbers with /* MAGIC */ so they can be identified at
some point. there are 33 in total though many appear to be the same
value, or related (eg, the 6 emac points.)
leaves these issues:
- RX pre-packet headers need to be byte-swapped or not?
- PAGE_SIZE bytes are allocated for both TX and RX DMA ring descriptors,
but they should be 1024 (== sizeof(struct bce_dma_slot) * N[TR]XDESC).
- the mcast filter.
 1.3.2.2 05-Oct-2003  tron Pull up revision 1.1 (requested by mrg in ticket #1486):
add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by
yours truly.
XXX: missing mcast filter support.
thanks cliff!
 1.3.2.1 29-Sep-2003  tron file if_bce.c was added on branch netbsd-1-6 on 2003-10-05 11:47:15 +0000
 1.5.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.5.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 09-Jul-2004  skrll file if_bce.c was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.6.6.1 12-Feb-2005  yamt sync with head.
 1.6.4.1 29-Apr-2005  kent sync with -current
 1.8.6.7 17-Mar-2008  yamt sync with head.
 1.8.6.6 27-Feb-2008  yamt sync with head.
 1.8.6.5 04-Feb-2008  yamt sync with head.
 1.8.6.4 21-Jan-2008  yamt sync with head
 1.8.6.3 03-Sep-2007  yamt sync with head.
 1.8.6.2 26-Feb-2007  yamt sync with head.
 1.8.6.1 30-Dec-2006  yamt sync with head.
 1.9.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.9.8.1 11-Aug-2006  yamt sync with head
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.6.2 10-Dec-2006  yamt sync with head.
 1.10.6.1 22-Oct-2006  yamt sync with head
 1.10.4.1 18-Nov-2006  ad Sync with head.
 1.12.4.3 24-Mar-2007  yamt sync with head.
 1.12.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.12.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.14.6.1 29-Mar-2007  reinoud Pullup to -current
 1.14.4.1 11-Jul-2007  mjf Sync with head.
 1.14.2.3 20-Aug-2007  ad Sync with HEAD.
 1.14.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.14.2.1 10-Apr-2007  ad Sync with head.
 1.16.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.17.20.2 19-Jul-2007  dsl include sys/cdefs.h
 1.17.20.1 19-Jul-2007  dsl file if_bce.c was added on branch matt-mips64 on 2007-07-19 22:04:23 +0000
 1.17.18.2 20-Jan-2008  bouyer Sync with HEAD
 1.17.18.1 13-Dec-2007  bouyer Sync with HEAD
 1.17.16.1 11-Dec-2007  yamt sync with head.
 1.17.14.1 26-Dec-2007  ad Sync with head.
 1.17.12.1 18-Feb-2008  mjf Sync with HEAD.
 1.17.6.2 23-Mar-2008  matt sync with HEAD
 1.17.6.1 09-Jan-2008  matt sync with HEAD
 1.21.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.2.1 24-Mar-2008  keiichi sync with head.
 1.23.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.23.4.6 11-Aug-2010  yamt sync with head.
 1.23.4.5 11-Mar-2010  yamt sync with head
 1.23.4.4 16-Sep-2009  yamt sync with head
 1.23.4.3 18-Jul-2009  yamt sync with head.
 1.23.4.2 16-May-2009  yamt sync with head
 1.23.4.1 04-May-2009  yamt sync with head.
 1.24.2.2 23-Jul-2009  jym Sync with HEAD.
 1.24.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.31.2.2 05-Mar-2011  rmind sync with head
 1.31.2.1 30-May-2010  rmind sync with head
 1.33.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.8.2 30-Oct-2012  yamt sync with head
 1.33.8.1 17-Apr-2012  yamt sync with head
 1.34.2.2 24-Feb-2012  mrg sync to -current.
 1.34.2.1 18-Feb-2012  mrg merge to -current.
 1.37.4.1 18-May-2014  rmind sync with head
 1.37.2.2 03-Dec-2017  jdolecek update from HEAD
 1.37.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.39.4.5 28-Aug-2017  skrll Sync with HEAD
 1.39.4.4 05-Feb-2017  skrll Sync with HEAD
 1.39.4.3 09-Jul-2016  skrll Sync with HEAD
 1.39.4.2 19-Mar-2016  skrll Sync with HEAD
 1.39.4.1 06-Jun-2015  skrll Sync with HEAD
 1.42.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.42.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.44.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.46.10.4 26-Jan-2019  pgoyette Sync with HEAD
 1.46.10.3 18-Jan-2019  pgoyette Synch with HEAD
 1.46.10.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.46.10.1 28-Jul-2018  pgoyette Sync with HEAD
 1.46.4.1 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1415):

sys/dev/pci/if_bce.c: revision 1.55
sys/dev/pci/if_bce.c: revision 1.56
sys/dev/pci/if_bcereg.h: revision 1.5

- Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unnecessary inclusion.

-

From OpenBSD:
- Mark ETHERCAP_VLAN_MTU.
- Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
- Set proper LED modes.
 1.47.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.47.2.1 10-Jun-2019  christos Sync with HEAD
 1.52.2.2 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.52.2.1 23-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #370):

sys/dev/pci/if_bce.c: revision 1.55
sys/dev/pci/if_bce.c: revision 1.56
sys/dev/pci/if_bcereg.h: revision 1.5

- Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unnecessary inclusion.

From OpenBSD:
- Mark ETHERCAP_VLAN_MTU.
- Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
- Set proper LED modes.
 1.56.2.1 29-Feb-2020  ad Sync with head.
 1.6 27-Jun-2023  nisimura correct register function annotation as it's for receive coalesce.
 1.5 18-Oct-2019  msaitoh From OpenBSD:
- Mark ETHERCAP_VLAN_MTU.
- Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
- Set proper LED modes.
 1.4 11-Dec-2005  christos branches: 1.4.156; 1.4.164; 1.4.170;
merge ktrace-lwp.
 1.3 29-Sep-2003  mrg branches: 1.3.2; 1.3.6;
- convert to new aprint*() autoconfig print mechanism
- clean up some magic numbers
- make 1.6 friendly
 1.2 28-Sep-2003  mrg from Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>:
- if_bcereg.h should only have register definitions, so declarations
of softc structure etc. should be in if_bce.c.
- The types of DMA descriptors should be u_int32_t, not unsigned long.
- netinet headers are not required here.
- Values passed via bce_tx_ring should also be byte-swapped.
- byte-swapping is not needed for bus_space access.

from me:
- KNF
- mark all magic numbers with /* MAGIC */ so they can be identified at
some point. there are 33 in total though many appear to be the same
value, or related (eg, the 6 emac points.)

leaves these issues:
- RX pre-packet headers need to be byte-swapped or not?
- PAGE_SIZE bytes are allocated for both TX and RX DMA ring descriptors,
but they should be 1024 (== sizeof(struct bce_dma_slot) * N[TR]XDESC).
- the mcast filter.
 1.1 27-Sep-2003  mrg add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by
yours truly.

XXX: missing mcast filter support.

thanks cliff!
 1.3.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.6.2 03-Aug-2004  skrll Sync with HEAD
 1.3.6.1 29-Sep-2003  skrll file if_bcereg.h was added on branch ktrace-lwp on 2004-08-03 10:49:07 +0000
 1.3.2.4 05-Oct-2003  tron Pull up revision 1.3 (requested by mrg in ticket #1486):
- convert to new aprint*() autoconfig print mechanism
- clean up some magic numbers
- make 1.6 friendly
 1.3.2.3 05-Oct-2003  tron Pull up revision 1.2 (requested by mrg in ticket #1486):
from Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>:
- if_bcereg.h should only have register definitions, so declarations
of softc structure etc. should be in if_bce.c.
- The types of DMA descriptors should be u_int32_t, not unsigned long.
- netinet headers are not required here.
- Values passed via bce_tx_ring should also be byte-swapped.
- byte-swapping is not needed for bus_space access.
from me:
- KNF
- mark all magic numbers with /* MAGIC */ so they can be identified at
some point. there are 33 in total though many appear to be the same
value, or related (eg, the 6 emac points.)
leaves these issues:
- RX pre-packet headers need to be byte-swapped or not?
- PAGE_SIZE bytes are allocated for both TX and RX DMA ring descriptors,
but they should be 1024 (== sizeof(struct bce_dma_slot) * N[TR]XDESC).
- the mcast filter.
 1.3.2.2 05-Oct-2003  tron Pull up revision 1.1 (requested by mrg in ticket #1486):
add new driver for broadcom BCM4401 chipset (as seen on recent dell
laptops) written by Cliff Wright <cliff@snipe444.org> and tested by
yours truly.
XXX: missing mcast filter support.
thanks cliff!
 1.3.2.1 29-Sep-2003  tron file if_bcereg.h was added on branch netbsd-1-6 on 2003-10-05 11:47:15 +0000
 1.4.170.1 23-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #370):

sys/dev/pci/if_bce.c: revision 1.55
sys/dev/pci/if_bce.c: revision 1.56
sys/dev/pci/if_bcereg.h: revision 1.5

- Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unnecessary inclusion.

From OpenBSD:
- Mark ETHERCAP_VLAN_MTU.
- Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
- Set proper LED modes.
 1.4.164.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.156.1 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1415):

sys/dev/pci/if_bce.c: revision 1.55
sys/dev/pci/if_bce.c: revision 1.56
sys/dev/pci/if_bcereg.h: revision 1.5

- Add missing splnet()/splx() around mii_tick(). Same as OpenBSD rev. 1.23
- Use device_printf() instead of aprint_error_dev)() in bce_watchdog().
- Remove unnecessary inclusion.

-

From OpenBSD:
- Mark ETHERCAP_VLAN_MTU.
- Clear the powerdown mode. Fixes PR kern/24911 reported by Werner Backes.
- Set proper LED modes.
 1.399 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.398 26-May-2025  bouyer Mark the interrupt handler MPSAFE; the driver was made MPSAFE 2 years
ago but it seems that pci_intr_setattr(PCI_INTR_MPSAFE) was missed.
OK skrll@
 1.397 10-Nov-2024  mlelstv Add MBUFTRACE
 1.396 14-Sep-2024  skrll Update bge_if_flags in bge_ifflags_cb before calling bge_setmulti so the
new setting of IFF_PROMISC is used by bge_setmulti
 1.395 07-Sep-2024  skrll Conditionally call mutex_obj_free for the mutexes in bge_release_resources
as there are code path where they might not have been allocated (yat).
 1.394 28-Aug-2024  skrll Apply changes from PR/58584 after testing (and fixing).

Tested on an Apple M1.
 1.393 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.392 29-Jun-2024  riastradh branches: 1.392.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.391 01-Apr-2024  andvar s/Doucments/Documents/ in comment.
 1.390 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.389 01-Aug-2023  andvar s/diabled/disabled/ in comments.
 1.388 11-Oct-2022  andvar branches: 1.388.2;
fix typos in log messages s/bus_dmamem_create/bus_dmamap_create/ and
s/bus_dmamem_load/bus_dmamap_load/.
Inspired by recent similar fixes in OpenBSD.
 1.387 04-Sep-2022  skrll bge(4): Use BUS_DMA_WAITOK in ring initilization now that it's safe
 1.386 04-Sep-2022  skrll bge(4): fix the MP improvements and improve some more.

- Have two locks sc_core_lock at IPL_NONE and sc_intr_lock at IPL_NET and
use appropriately.

- Use stopping flags instead of bge_if_flags so that bge_if_flags only
needs to be protected by the sc_core_lock

- Use ifmedia_init_with_lock and provide the sc_intr_lock. mii operatiions
are done from the interrupt handler.

- Fixup locking in bge_detach.

- Rename bge_watchdog to bge_watchdog_tick to avoid confusion with the
if_watchdog method.

- Sprinkle some more asserts.
 1.385 04-Sep-2022  skrll bge(4): use a local variable to make bge_ifmedia initialization pretty.

NFC
 1.384 27-Aug-2022  skrll Convert bge_pending_rxintr_change to a bool (from int)
 1.383 27-Aug-2022  skrll Include headers once (and don't pretend this compiles without INET)
 1.382 27-Aug-2022  skrll Correct the abbreviation of approximately to 'approx.'
 1.381 25-Aug-2022  skrll G/C
 1.380 19-Aug-2022  skrll Make bge_detaching a bool. NFC.
 1.379 19-Aug-2022  skrll softc member naming consistency with wm(4). (Taylor made me do it... not
really)
 1.378 19-Aug-2022  skrll Should be checking ifp->if_flags in bge_init and not sc->bge_if_flags.

Spotted by Taylor.
 1.377 14-Aug-2022  skrll bge: Use BUS_DMA_WAITOK in attach routines.
 1.376 14-Aug-2022  skrll bge: Mirror the bus_dma RX buffer changes in the OpenBSD driver

This change reduces the amount of work done in the interrupt handler.
 1.375 14-Aug-2022  skrll Make bge(4) MP safe

This started out as a fix so that LOCKDEBUG wouldn't explode with kernel
lock spinout. LOCKDEBUG is too aggressive now and really should be
relaxed.
 1.374 14-Aug-2022  skrll bge: Fix bge_ring_map bus_dmamap_sync POST{READ,WRITE} operations.

When the range of ring entries wraps around sync from the start of the
ring to the last entry.
 1.373 07-Aug-2022  skrll Provide and use (when appropriate) a bge_free_jumbo_mem.
 1.372 07-Aug-2022  skrll Misc tidyup. NFC.
 1.371 07-Aug-2022  skrll Unwrap a long line and remove unecessary brackets. NFC.
 1.370 07-Aug-2022  skrll Fix the KNF. oops.
 1.369 07-Aug-2022  skrll whitespace
 1.368 07-Aug-2022  skrll KNF
 1.367 26-Jul-2022  skrll Whitespace
 1.366 22-Jul-2022  skrll malloc -> kmem.
 1.365 03-Jul-2022  skrll *** empty log message ***
 1.364 03-Jul-2022  skrll KNF
 1.363 03-Jul-2022  skrll Perform a BUS_DMASYNC_POSTREAD on the bge_status_block before reading from
it as required by bus_dma(9).
 1.362 02-Jul-2022  skrll KNF. Remove brackets around return values.
 1.361 02-Jul-2022  skrll One timeout message (the write one) in bge_miibus_writereg is enough.
 1.360 02-Jul-2022  skrll Modernise bge_update_all_threshes. Same code before and after.
 1.359 02-Jul-2022  skrll Simplification. Same code before and after.
 1.358 02-Jul-2022  skrll More const. Remove strange ifp assignments in bge_init.
 1.357 30-Jun-2022  skrll KNF some comments
 1.356 30-Jun-2022  skrll Remove strange (duplicate) assignment.
 1.355 30-Jun-2022  skrll KNF
 1.354 28-Jun-2022  skrll Sprinkle some const. Same code before and after.
 1.353 19-May-2022  buhrow For chips which contain an ASF/IPMI firmware, instruct the chip to shut the host ASF firmware
down when attaching the device so the IPMI BMC can use the same physical port even when NetBSD
doesn't have a network configuration on the device. By contrast, when the device gets a
network configuration assigned to it and bge_init() is called, the host ASF firmware is brought
up so both NetBSD and the IPMI BMc can use the same
physical port.

This now matches FreeBSD behavior, as well as behavior from NetBSD-5.2.

Tested on a Sunfire X2200-M2 system with the following chip:

bge1 at pci7 dev 4 function 1: Broadcom BCM5715 Gigabit Ethernet
bge1: interrupting at ioapic0 pin 11
bge1: HW config 000000d4, 00000014, 00000000, 00000000 00000000
bge1: ASIC BCM5715 A3 (0x9003), Ethernet address 00:1e:68:XX:XX:XX
bge1: setting short Tx thresholds
brgphy1 at bge1 phy 1: BCM5714 1000BASE-T/X media interface, rev. 0
brgphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 1.352 07-Apr-2022  andvar fix various typos in comments.
 1.351 22-Jan-2022  martin Explicitly cast a 40-bit mask to bus_addr_t in a dead branch (gcc apparently
is not clever enough and warns about the truncation)
 1.350 22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.349 16-Sep-2021  andvar fix various typos, mainly in comments.
 1.348 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.347 30-Aug-2021  jmcneill bge_txeof/bge_rxeof may be called with no pending descriptors, so skip
bus_dmamap_sync with len=0
 1.346 02-Jul-2020  msaitoh prop_data_data_nocopy -> prop_data_value
 1.345 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.344 04-Feb-2020  thorpej Use ifmedia_fini().
 1.343 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.342 25-Nov-2019  msaitoh branches: 1.342.2;
Modify PHY initialization code. This change fix a bug that SK-9D21 doesn't
detect MII PHY.
- Add error check to bge_miibus_writereg().
- Change return value of bge_miibus_readreg() when a read error occurred.
It also add error message using with aprint_debug_dev(). This error occurs
on some devices while detecting MII devices.
- Move the location of BGE_MI_MODE register's initialization to next to
bge_chipinit().
- Set BGE_MAC_MODE before calling ifmedia_init() and/or mii_attach().
- Add retry code for mii_attach() failed. Same as FreeBSD.
 1.341 25-Nov-2019  msaitoh - Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.
 1.340 25-Nov-2019  msaitoh Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.
 1.339 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.338 23-Sep-2019  maxv Remove (unused) reference to m_pktdat.
 1.337 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.336 30-Jul-2019  msaitoh - Avoid undefined behavior in bge_setmulti(). found by kUBSan.
- Avoid undefined behavior when setting the MAC address in bge_init().
found by kUBSan.
 1.335 09-Jul-2019  msaitoh branches: 1.335.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.334 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.333 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.332 24-May-2019  msaitoh No functional change:
- ac -> ec
- KNF.
 1.331 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.330 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.329 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.328 05-Apr-2019  bouyer Fix ASIC check, BGE_ASICREV(sc->bge_chipid) is not a chipid.
Fixes bogus input error reporting in stat. This is cosmetic, exept for
routed(8) which thinks that the interface is broken and stops accepting routes
from it.
 1.327 20-Feb-2019  msaitoh - Add support for BCM5762 ASIC devices.
- Add BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787.
 1.326 20-Feb-2019  msaitoh Add BCM5702FE, another BCM5704S and SysKonnect SK-9Mxx support.
 1.325 20-Feb-2019  msaitoh Simplify PCI device table. No functional change.
 1.324 20-Feb-2019  msaitoh Add BCM5717's another device ID support.
 1.323 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.322 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.321 16-Jan-2019  msaitoh Remove the definition of BRGPHY_MII_1000CTL and use MII_GTCR.
 1.320 02-Dec-2018  bouyer Don't destroy the dma maps if we're not disabling the adapter, avoids
a KASSERT() when bus_dmamap_destroy() is called from interrupt
context via bge_watchdog()
Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage.
Otherwise we may set IFF_OACTIVE while no transmit is in progress, and
nothing will clear it.
If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry.
Refine the check for the 4GB boundary workaround (a fragment should also
not cross the boundary), and do it only for TSO.
If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet.
Bring in more hardware bug workarounds from freebsd.

With these it seems that a BCM5720 A0 can survive a few hours of internet
load with TSO4 enabled.
 1.319 30-Nov-2018  jdolecek allow MSI-X if supported by the hardware, discussed with Manuel
 1.318 30-Nov-2018  jdolecek simplify intr establish code - rely on pci_intr_alloc() to return
interrupt types which are possible for pci_intr_establish(); remove
fallbacks to retry with MSI explicitly disabled

bge(4) specifically needs to disable MSI on some boards which are
known to have broken MSI support, so this can't use pci_intr_alloc()
with just NULL counts

discussed on tech-kern@, and specifically bge(4) with Manuel

https://mail-index.netbsd.org/tech-kern/2018/11/27/msg024240.html
 1.317 27-Nov-2018  bouyer More TSO4 fixes, from the freebsd driver:
- the chip doens't want the lenght of options, but the complete lenght of
ip headers (ip + tcp + options). Fix this for the BGE_IS_5717_PLUS()
and BGE_IS_5705_PLUS() cases; FreeBSD doens't cover the last case so
leave it as is for now. This fixes checksum failures for heavy transfers.
- It looks like the transmit engine hangs if the TCP segment crosses a 4GB
boundary. FreeBSD fixes it by mapping everything below 4GB; instead
try detect when this happens and do the bounce only when needed.

With these fixes I could transfers 3GB images over ftp at gigabit speed
(112MB/s with wget) without problems. Tested on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0
 1.316 24-Nov-2018  bouyer 5717 and newer handle TSO in a sighly different way. From FreeBSD.
While there, use different lowat/hiwat values if MTU is larger than ETHERMTU,
from FreeBSD.
Tested at LIP6 on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0
with all ipv4 checksums and TSO4 enabled.
 1.315 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.314 26-Jun-2018  msaitoh branches: 1.314.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.313 22-Nov-2017  msaitoh branches: 1.313.2;
Revert part of if_bge.c 1.312. It's not reqired to mask other than VLAN ID
bits in VLAN tag.
 1.312 28-Sep-2017  christos - only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
 1.311 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.310 27-Apr-2017  msaitoh branches: 1.310.2;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.309 25-Apr-2017  snj branches: 1.309.2;
fix typo
 1.308 20-Apr-2017  msaitoh 5776[0156], 5778[02568] and 5779[015] are not Fast Ethernet but
Gigabit Ethernet.
 1.307 20-Apr-2017  msaitoh Fix device timeout problem when MSI is used on BCM57762, BCM57765 and
BCM57785. Check correctly for BGEF_TAGGED_STATUS. These devices' ASCI core is
BCM5776[56]. Other BSD's BGE_IS_5717_PLUS() include BCM5776[56] but ours
doesn't (because Linux tg3 does so).

Tested with snj's MacBook (BCM57765 (BCM57765 B0 ASIC)) and my Acer Aspire
One 756 (BCM57785(BCM57765 B0 ASIC)). Also Thunderbolt Ethernet
(BCM57762 (BCM57766 A0 ASIC)) should work.
 1.306 13-Apr-2017  msaitoh Add forgotten BGE_EVCNT_INCR() for spurious interrupt.
 1.305 13-Apr-2017  msaitoh - Read chip ID correctly on BCM57782 and BCM57786.
- Add BXCM57766 A0 string.
- Add comment for BCM5776[56]'s workaround.
 1.304 12-Apr-2017  msaitoh Add a workaround for BCM57780 to prevent device timeout. This change prevent
L1PM feature do wrongy. Tested with Dell latitude 2120.
 1.303 12-Apr-2017  msaitoh Fix a bug that BCM5785 write wrongly to the PCI config area.
 1.302 12-Apr-2017  msaitoh Add counters for spurious interrupts.
 1.301 12-Apr-2017  msaitoh Detach sysctl and event counters in bge_release_resources().
 1.300 15-Dec-2016  ozaki-r branches: 1.300.2;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.299 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.298 11-Jul-2016  knakahara branches: 1.298.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.297 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.296 12-May-2016  ozaki-r Protect ifnet list with psz and psref

The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
 1.295 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.294 18-Nov-2015  msaitoh Delete #ifdef __HAVE_PCI_MSI_MSIX and use pci_intr_allo()/pci_intr_release()
on any systems. The third argument of pci_intr_alloc() is left because we will
use the code to support MSI-X in future.
 1.293 21-Jul-2015  knakahara mofity for if_wm and if_bge to use pci_intr_alloc()
 1.292 14-Jun-2015  martin Make sure not to re-arm the statistics callout when we are about to detach.
 1.291 23-May-2015  msaitoh Remove debug printf().
 1.290 18-May-2015  msaitoh Add missing pci_intr_release() for the detach.
 1.289 17-May-2015  msaitoh Fix compile error on non-__HAVE_PCI_MSI_MSIX machines.
 1.288 17-May-2015  msaitoh - Add MSI support.
- Use tagged status function for 5717 and newer devices. All controllers
except BCM5700 support tagged status but we use tagged status only for MSI
case on BCM5717. Otherwise MSI on BCM5717 does not work. Same as other *BSDs.
 1.287 01-May-2015  msaitoh Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
 1.286 01-May-2015  msaitoh Remove PCI_PRODUCT_BROADCOM_BCM5724 and PCI_PRODUCT_BROADCOM_BCM5750M.
These devices have not released to public. Same as OpenBSD and Linux.
 1.285 30-Apr-2015  msaitoh Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30 minutes
on HP ML110 G6 reported enami@ in PR#49657.
 1.284 30-Apr-2015  msaitoh - BGE_CHIPID_BCM5784_A1 is not 0x5784100 but 0x5784001. Only dmesg output
is affected.
- Add BGE_CHIPREV_5784_AX and BGE_CHIPID_BCM5784_B0.
 1.283 27-Apr-2015  christos fix mbuf leak on failure (Brainy)
 1.282 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.281 06-Apr-2015  martin Make sure to halt (not just stop) the bge_tick callout during detach.
 1.280 17-Feb-2015  enami Make this file compiles again with BGE_DEBUG defined.
 1.279 17-Feb-2015  msaitoh Print bit setting of bge_asf_mode if BGE_DEBUG is set.
 1.278 11-Feb-2015  msaitoh Fix three bugs reported by enami@:
- bge_miibus_writereg(): Fix a bug that BCM5906 may leave an APE lock.
- Fix hwcfg4 isn't printed correctly.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some PCIe devices.
 1.277 10-Aug-2014  tls branches: 1.277.2; 1.277.4;
Merge tls-earlyentropy branch into HEAD.
 1.276 05-Aug-2014  msaitoh In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
 1.275 24-Jul-2014  msaitoh Yet another change for PR#48451. Don't use prefetchable memory for BAR0, too.
Reported by taca@.
 1.274 24-Jul-2014  msaitoh - Fix a bug that bge can't be initialized correctly on some sparc64 systems
(PR#49018).
See also: http://mail-index.netbsd.org/port-sparc64/2013/10/28/msg002036.html
- Change initializaton order as the same as the document, Linux tg3 and FreeBSD
(part of r241436).
 1.273 22-Jul-2014  msaitoh Add workaround for PR#48451. Some BCM5717-5720 based systems get NMI on boot.
This problem doesn't occur when we don't use prefetchable memory in the APE
area. I don't know the reason... The way to not to use prefetchable memory
was adviced by Riastradh. Tested with HP MicroServer Gen8.
 1.272 02-Jul-2014  msaitoh Don't use the PHY Auto Poll Mode on many chips. This fixes a bug that MII
Fiber NIC drop packet about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot. Thanks zafer@ for testing.
 1.271 23-Jun-2014  msaitoh Print APE firmware correctly.
 1.270 17-Jun-2014  msaitoh Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
 1.269 17-Jun-2014  msaitoh - Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4). The auto negotiation may have some bugs.
- Add 2500SX support (not tested).
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
 1.268 17-Jun-2014  msaitoh Fix a variable name in last commit.
 1.267 17-Jun-2014  msaitoh - Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5) for
BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
 1.266 29-Mar-2014  christos branches: 1.266.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.265 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.264 07-Nov-2013  msaitoh Revert previos. Sorry.
 1.263 07-Nov-2013  msaitoh Add Quark X1000 devices.
 1.262 31-Oct-2013  msaitoh Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD (part of r199670).
This workaround is for 5714/5715 controllers and is not actually a MAC
controller bug but an issue with the embedded PCIe to PCI-X bridge in the
device.
This change uses bus_dmatag_subregion(), so this workaround won't work on some
archs which doesn't support bus_dmatag_subregion().
 1.261 31-Oct-2013  msaitoh Cleanup flag setting. No functional change.
- Split flags into bge_flags and bge_phy_flags.
- Rename flags. PHY related flags are prefixed with BGEPHYF_*.
Other flags are prefixed with BGEF_*.
 1.260 28-Oct-2013  msaitoh Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
For PCI-X BCM5704, set maximum outstanding split transactions to 0.
Same as Linux tg3 and FreeBSD (part of FreeBSD r204978).
 1.259 12-Sep-2013  martin Remove unused variable
 1.258 08-Jul-2013  msaitoh - Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
 1.257 08-Jul-2013  msaitoh 57765 series is not based on 5717 series. 5717 series is based on 57765
series.
 1.256 05-Jul-2013  msaitoh Fix a link detect bug on non-autopoll systems. Same as OpenBSD
(rev.1.329 and 1.336) and FreeBSD (r213710).
 1.255 03-Jul-2013  msaitoh Fix the setting of sc->bge_flags for 5717 and newer devices. Reported by
Mike Belopuhov.
 1.254 03-Jul-2013  msaitoh Add BGE_JUMBO_CAPABLE flag to some chips. Before this commit,
the following chips support the jumbo frame function:

5700
5701
5702
5703
5704

With this commit, the following chip support it, too:

5714
5780
5717
5718
5719 (exclude rev. A0)
5720
57765
57766
 1.253 31-May-2013  msaitoh branches: 1.253.2;
- Revert rev. 1.250. I really misunderstood. Add some comments.
- Set DMA watermark depend on the PCI max payload size.
 1.252 30-May-2013  msaitoh 0x4B657654(BGE_SRAM_FW_MB_MAGIC) == ~0xB49A89AB(BGE_SRAM_FW_MB_RESET_MAGIC),
so the same code I added in rev. 1.223 exists in bge_poll_fw(), too. Remove it.

And then, call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
 1.251 29-May-2013  msaitoh Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL register
to not to modify some GPIO bits.
 1.250 28-May-2013  msaitoh Fix a bug that the MAC_MODE register is incorrectly set in bge_reset().
 1.249 28-May-2013  msaitoh Fix a bug that the PHY address bits in MI_MODE register is wrongly cleard.
Set the PHY address correctly.
 1.248 24-May-2013  msaitoh On sparc64, the memory arbiter may be disabled by OF.
Move the HW config checking stuff to after bge_reset(). bge_reset()
initializes both byte order settings and the memory arbiter.

The hwcfg stuff will be required in bge_reset() in future, so we should
rethink about hwconfig and bge_reset().
 1.247 24-May-2013  msaitoh Document says 5717 and newer chips have no BGE_PCISTATE_INTR_NOT_ACTIVE bit,
so don't use the bit on those chips. Same as OpenBSD.
 1.246 24-May-2013  msaitoh bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT. Same as
OpenBSD's if_bge.c rev. 1.86.
 1.245 21-May-2013  martin Stopgap: disable access to BGE_SRAM_DATA_SIG, it is not implemented in all
variants and access may crash the kernel.
msaitoh: please fix properly, I have no idea how.
 1.244 13-May-2013  msaitoh For BGE_IS_575X_PLUS() devices, don't set BGE_RXLPSTATCONTROL_DACK_FIX bits because
these bits are reserved.
 1.243 13-May-2013  msaitoh Set BGE_MISC_CTL's byte/word swap options before using bge_readmem_ind().
Fixes PR#47716.

Re-enable NVRAM lock stuff again (i.e. revert rev. 1.233).
 1.242 10-May-2013  christos no need for vlan.h here.
 1.241 08-May-2013  msaitoh Check the hardware config words and print them. This change only read them
and print the values.
 1.240 08-May-2013  msaitoh Add missing bus_dmamap_sync() in bge_intr(). The status word is in DMAed area.
Same as *BSDs.
 1.239 05-May-2013  msaitoh Check whether sc->bge_dmatag != NULL or not. Fix a bug that
bge_release_resources() panics when bge_attach failed.
 1.238 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.237 12-Apr-2013  msaitoh Cleanup. No functional change.
 1.236 11-Apr-2013  msaitoh Update comments from 57XX-PG105-R.pdf and 5718-PG106-R.pdf.
No functional change.
 1.235 08-Apr-2013  msaitoh Fix the setting of Tx Random Backoff Register.
 1.234 08-Apr-2013  msaitoh Check BGE_SGDIG_STS when the chip is NOT a 5717 A0, like freebsd
(OpenBSD rev. 1.327).
 1.233 08-Apr-2013  msaitoh Temporary disable the NVRAM locking stuff for PR#47716.
I'll get PowerMac G5 in a few days and will fix correctly.
 1.232 02-Apr-2013  msaitoh Fix a bug that the NVRAM lock timeout occured on sparc64 onboard bge.
Tested by martin.
- Don't acquire NVRAM lock if no EEPROM(or NVRAM?).
- Reset NVRAM before bge_reset(). It's required to acquire NVRAM lock in
bge_reset().
 1.231 02-Apr-2013  msaitoh Fix APE lock bug for PHYs (FreeBSD r248993)
 1.230 30-Mar-2013  christos remove trailing whitespace
 1.229 27-Mar-2013  msaitoh Revert 1.228 except BGE_NO_EEPROM flag for BCM5906. Sorry.
 1.228 27-Mar-2013  msaitoh Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
 1.227 24-Mar-2013  msaitoh - Add detach function.
- Remove old unused bge_vpd_*.
 1.226 24-Mar-2013  msaitoh Back out rev. 1.210. The PCI config registers of bge are shadowed in the
device register window, so don't use pci_conf_*() again because those
access are slow.
 1.225 23-Mar-2013  msaitoh Change the order of register settings a little to match both Broadcom's
document and Linux tg3.
 1.224 23-Mar-2013  msaitoh 5718 and 57785 document say we should wait 100us.
 1.223 21-Mar-2013  msaitoh Wait for the bootcode to complete initialization for 5717 and newer devices.
See BCM5718 programmer's guide's "step 13, Device reset Procedure, Section 7".
57781's document has the same note.

I verified the loop really looped on those chips.

But, I don't know why tg3 doesn't it.
 1.222 21-Mar-2013  msaitoh - Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that do not
have jumbo support
- Add/sync some of the comments
- Use macro.
- Remove unused code.
 1.221 19-Mar-2013  msaitoh Fix compile error if BGE_DEBUG is set.
 1.220 19-Mar-2013  msaitoh - Rename PHY related flags for the consistency. It's the same as FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT flag to
not to check Gigabit flags. It's the same as FreeBSD.
 1.219 19-Mar-2013  msaitoh Fix three bugs:
- An workaround for TX data corruption is only for 5719 "A0".
Fix the wrong evaluation.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link checking.
FreeBSD has the same delay().
 1.218 19-Mar-2013  msaitoh Fix Buffer Manager Mbuf Pool settings which was modified in rev. 1.202.
 1.217 17-Mar-2013  msaitoh No functional change:
- Fix comment
- Use macro
- Remove unused macro
 1.216 17-Mar-2013  msaitoh - ADD support for BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Use macros.
- Remove unused code.
- Sync with the latest {Free,Open}BSD's bge.
 1.215 14-Mar-2013  msaitoh Sync with *BSD. No functional change:
- make bge_chipid() and use it.
- use switch() instead of a lot of if()s.
- sort lines.
 1.214 13-Mar-2013  msaitoh - Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Use macro.
 1.213 07-Mar-2013  msaitoh Add DELAY(40) after turning on write DMA state machine.
 1.212 07-Mar-2013  msaitoh BCM5720 is not supported yet.
 1.211 07-Mar-2013  msaitoh Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
 1.210 07-Mar-2013  msaitoh Fix a bug that some PCI config registers are accessed not using
pci_conf_{read,write}. Registers named BGE_PCI_* are PCI config
registers.
 1.209 07-Mar-2013  msaitoh Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G and BCM5787F.
 1.208 03-Mar-2013  msaitoh Style fix. No functional change.
 1.207 27-Feb-2013  msaitoh No functional change:
- Fix comments.
- Change macro name.
- Change sysctl related functions for consistency.
 1.206 26-Feb-2013  msaitoh Add some bugfixes and enhancement from FreeBSD:

- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may cause
internal chip delays that may result in subsequent valid frames being
dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)

- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)

- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)

- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
 1.205 26-Feb-2013  msaitoh Use macro. Remove extra semicolon. No functional change.
 1.204 25-Feb-2013  msaitoh Use macro. Remove duplicated macro. Remove unused variable.
No functional Change.
 1.203 22-Feb-2013  msaitoh Style change. It's mainly intended to reduce the diff between Fx and Nx.
 1.202 17-Sep-2012  tsutsui Add support for BCM57762, found in Apple's Thunderbolt to Gigabit Ethernet
Adapter. PR kern/46961 from Ryo ONODERA.

Also revert weird BGE_MAX_FRAMELEN macro definition to sync its usage
with the original FreeBSD's bge.
 1.201 22-Jul-2012  matt branches: 1.201.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.200 02-Feb-2012  tls branches: 1.200.2; 1.200.6; 1.200.8;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.199 02-Nov-2011  yamt branches: 1.199.2; 1.199.6;
allow disabling interrupt mitigation
 1.198 09-Jun-2011  cegger the BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe.
Fixes 'firmware handshake timeout'. Tested with root on nfs.

patch from msaitoh@
 1.197 03-Jun-2011  cegger fix crash by NULL pointer dereferencing I get everytime
right after this message:

bge0: discarding oversize frame (len=-4)
 1.196 22-May-2011  mrg branches: 1.196.2;
match some fujitsu bge interfaces seen on PRIMEPOWER 250/450 systems.
from Michael Moll <kvedulv@kvedulv.de>, taken from openbsd.
 1.195 02-May-2011  jym Fix BCM5709 PHY detection for ethernet PHYs (the SerDes case being already
handled):
- export bge(4) and bnx(4) CHIP ID and PHY flags to brgphy(4). Move to
"unsigned int" rather than "int", and reuse the same softc members for
chipid and phyflags (behavior controlled by the sc_isbge/isbnx boolean).
- apply bug fix for revisions A and B, so that autonegotiation can
complete (from OpenBSD).

Bug reported by Rivo Nurges via private mail, patch tested and
confirmed working by him (with thanks!)
 1.194 18-Apr-2011  buhrow Fixes for kern/40018.

Our driver initializes the Broadcom hardware to peform a tcp and udp
checksum on only the payload of the tcp or udp packet, rather than the
entire packet. The FreeBSD, OpenBSD and Linux drivers instruct the hardware to compute
the checksum for the entire packet. I believe the bug is that some revisions
of the BCM hardware, under certain circumstances, revert to doing the
complete checksum calculation, as the FreeBSD, OpenBSD and Linux drivers
request, while things are running. As
a result, when we pull the computed checksum from the hardware and pass it
up to the upper layers, we assume the checksum is the more minimal
one, and the upper layers perform the appropriate checks, which, when this
happens, cause the packet to be rejected because the resultant checksum is
decidedly incorrect.
This patch changes the driver to instruct the hardware to perform the
checksum over the entire packet, just as the FreeBSD, OpenBSD and
Linux drivers do, and to notify the upper layers appropriately.

This patch appears to work on all revisions of the hardware that have been
tested. (See the list in the bug report.)

this patch is approved by tls.
 1.193 08-Apr-2011  sborrill Revert previous couple of commits. bge_setvlan() is only called by
bge_init() and so does not get called when a vlan child is added. Calling
bge_setvlan() from bge_ifflags_cb() doesn't work either as it appears that
the callback is called before ec_capenable is updated by if_vlan.c.
 1.192 08-Apr-2011  sborrill Fix typo in previous commit that would have stopped relevant bit being set.
 1.191 08-Apr-2011  sborrill PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.
 1.190 09-Jan-2011  jruoho branches: 1.190.2;
Don't use SYSCTL_SETUP in a driver.
 1.189 05-Jan-2011  sketch Use aprint_verbose_dev.
 1.188 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.187 16-Oct-2010  taca Remove a variable which assigned but never used, I found while reading
if_bge.c yesterday.
 1.186 21-Jul-2010  msaitoh Use ether_set_ifflags_cb()
 1.185 03-Jun-2010  msaitoh Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166. Sorry...
 1.184 11-May-2010  njoly Fix some typos in comments.
 1.183 25-Apr-2010  ad console spam
 1.182 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.181 01-Apr-2010  msaitoh Fix the code for 5822 B0 errata. Use pci_conf_read() and access at
32bit alignment.
 1.180 03-Feb-2010  msaitoh branches: 1.180.2; 1.180.4;
- Make the initialize sequence close to the document.
- Fix ASF heartbeat sending bug (FreeBSD rev. 1.271 (r202821))
- Use new handshake command for BCM5750 or new controllers (FreeBSD rev. 1.272
(r202822))
 1.179 01-Feb-2010  msaitoh Fix the bug that unaligned access occurs on amd64. It also fixes the bug
that error bits aren't cleard because these bits are W2C (in other word, W1C).

Reported by Michael van Elst.
 1.178 28-Jan-2010  msaitoh ANSI C, KNF and tabify
 1.177 28-Jan-2010  msaitoh - Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- remove an unused structure.
- KNF
 1.176 25-Jan-2010  martin Back out part of my device property change: the mac-address part was already
done better in another place which I overlooked when merging local
changes.
 1.175 24-Jan-2010  martin Do not try to read the EEPROM if we already know we don't have one.
 1.174 24-Jan-2010  martin Add support for device properties to override the mac address and set
the BGE_NO_EEPROM flag if we have an onboard device w/o SEEPROM.
 1.173 24-Jan-2010  msaitoh Fix a printf() message in debug code reported by Bert Kiers.
 1.172 24-Jan-2010  msaitoh Many changes from FreeBSD and OpenBSD:
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Many other bugfixes.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
 1.171 24-Jan-2010  msaitoh Fix the bug that both BGE_PCIE and BGE_PCIX are set on PCI-Express devices.
 1.170 24-Jan-2010  msaitoh KNF & fix typo in comment.
No functional change.
 1.169 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.168 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.167 25-Jul-2009  msaitoh Call prop_dictionary_set_uint32() before mii_attach(), so that brgphy
can do prop_dictionary_get_uint32() correctly.
 1.166 23-Jul-2009  msaitoh Reduce the difference against FreeBSD and OpenBSD

Define BGE_IS_JUMBO_CAPABLE and use it. No functional change.

Cleanup the code for BGE_PCI_DMA_RW_CTL regster setting. No functional
change.

Fix a printf message.
 1.165 05-May-2009  msaitoh Doesn't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs and
Linux don't print the error message for all registers.
 1.164 23-Apr-2009  msaitoh use proplib
 1.163 23-Apr-2009  msaitoh remove obsolete code.
 1.162 19-Apr-2009  msaitoh Some fixes and enhancements:

Both if_bge* and brgphy.[ch]:
Check the parent's MAC and use the quirk code for the bug like OpenBSD and
FreeBSD. Some bugs can't identify the PHY ID. For example, 5704 Ax has the
ADC bug, but 5704 A3 and 5704 B0 have the same PHY ID and revision. Add
BGE_PHY_CRC_BUG, BGE_PHY_ADC_BUG, BGE_PHY_5704_A0_BUG, BGE_PHY_JITTER_BUG,
BGE_PHY_ADJUST_TRIM and BGE_PHY_BER_BUG for this flag. Some of the DSP
patches are newly taken from OpenBSD and FreeBSD.

if_bge*:
Remove duplicated BGE_CHIPID_BCM5714_A0 entry in the known CHIPID table.
Fix obsolete comments.

brgphy.[ch]:
Add some PHY IDs.

TODO:
Add more three quirk code into bge and brgphy (the brgphy side's are
currently #if0'ed).
Add support for bnx into brgphy (currently #if0'ed)
 1.161 16-Apr-2009  msaitoh Take some code from FreeBSD and OpenBSD:

Fix some bugs that the driver unable to detect link loss (OpenBSD 1.135,
FreeBSD 1.102)

bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)

Acknowledge link change interrupts by setting the 'link changed' bit
in the status register (used to have no effect). FreeBSD 1.44 (OpenBSD 1.21)

Add some fiber support (OpenBSD 1.220)

Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.

Add special case code to fix a problem with the BCM5704 in TBI mode
(FreeBSD rev. 1.71, OpenBSD rev. 1.35)

Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD rev.
1.242)

Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev. 1.21)

Add some known CHIPID entries.
 1.160 16-Apr-2009  msaitoh Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL (on conventional PCI)
again.
 1.159 22-Mar-2009  msaitoh Take some code from FreeBSD and OpenBSD

-Add some known CHIPID entries.
-Add a code for BCM5906 into bge_chipinit(). We have to do more work for
BCM5906.
-Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL (on conventional PCI).
 1.158 22-Mar-2009  msaitoh Make bge(4) close to FreBSD and OpenBSD.

NO FUNCTIONAL CHANGE BY THIS COMMIT.
 1.157 22-Mar-2009  msaitoh Make bge(4) close to FreBSD and OpenBSD.

NO FUNCTIONAL CHANGE BY THIS COMMIT.
 1.156 22-Mar-2009  msaitoh eliminate PHY_1 quirk (like OpenBSD (rev. 1.110) and FreeBSD (rev. 1.44))
 1.155 30-Jan-2009  he branches: 1.155.2;
Make fibre cards, at least 5701 models, work, by initializing the
bge_ifmedia.ifm_media field, which is not done by ifmedia_set().
Patch lifted from FreeBSD's revision 1.71.
 1.154 10-Nov-2008  cegger PR kern/39608: bge(4) constant freeze on BCM5906M:
Correct DMA values. Patch from Karl Uwe Lockhoff via tech-kern.
 1.153 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.152 31-Aug-2008  tron branches: 1.152.2; 1.152.4;
Make multicast setup work again which got broken by the last commit.
Patch provided by Matthias Drochner. This fixes PR kern/39439.
 1.151 25-Aug-2008  cegger PR 39241: Add support for Broadcom BCM5906(M) from Karl Uwe Lockhoff
 1.150 25-Jul-2008  dsl Add {} around VLAN_INPUT_TAG() - VLAN_INPUT_TAG() can't be a do ... while (0).
 1.149 24-Jul-2008  sborrill Add support for Broadcom 5722 and identify 5755 ASICs.
 1.148 17-Jun-2008  mlelstv branches: 1.148.2;
add rnd(4) hooks. Note that interrupts on bge hardware may occur
with certain patterns, especially when the interrupt mitigation
logic kicks in. So this might be a very weak entropy source.
 1.147 17-Jun-2008  mlelstv No longer try to start sending packets from status change handler.
This is already handled by the general status change code.

For non-TBI devices always call mii_tick(). This fixes ifwatchd
signalling.
 1.146 08-Jun-2008  mlelstv branches: 1.146.2;
really set Tx thresholds
 1.145 07-Feb-2008  dyoung branches: 1.145.6; 1.145.8; 1.145.10; 1.145.12;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.144 04-Feb-2008  mlelstv Check wether interrupts originate from the bge hardware.
Fixes PR kern/33433.
 1.143 02-Feb-2008  tron Avoid using a stale PCI chipset tag pointer. This avoids panics while
attaching a 3Com 3C996B-T on my ULTRA60. Reviewed by Matthew Green.
 1.142 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.141 09-Dec-2007  jmcneill branches: 1.141.2;
Merge jmcneill-pm branch.
 1.140 07-Nov-2007  ad branches: 1.140.2; 1.140.4;
Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.139 28-Sep-2007  msaitoh branches: 1.139.2; 1.139.4;
Fix three bugs.

1) Move a magic number writing code.
Fix a watchdog timeout and "block failed to stop" problem on BCM5701 B5 card.

2) Fix incorrect register write.
Fix a watchdog timeout "block failed to stop" problem on BCM5700 B2 card.

3) Wait more long time for PCISTATE register to return to its original
pre-reset state.
Fix "pcistate failed to revert" problem on BCM5703 A2 card.
 1.138 24-Sep-2007  joerg Convert bge(4) to device/softc separation. Use aprint_* instead of
printf all over the place. Only the debug macros are kept. Place the TSO
message about the hard case under debug.
 1.137 29-Aug-2007  dyoung branches: 1.137.2;
Constify: LLADDR() -> CLLADDR().
 1.136 26-Aug-2007  dyoung branches: 1.136.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.135 10-Aug-2007  taca Add support for BCM5786 with simply adding its PCI product id.

Testing on Fujitsu FMV-D5240 and works fine.
 1.134 07-Aug-2007  markd branches: 1.134.2;
Disable firmware fastboot on 5754 and 5755. From FreeBSD by way of Phil
Nelson.
 1.133 06-Aug-2007  markd Add support for BCM5755 and BCM5754/5787. Suggestions from Jonathan
Stone and fixes from OpenBSD for various hardware bugs/errata.
 1.132 09-Jul-2007  ad branches: 1.132.2; 1.132.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.131 09-Jun-2007  mlelstv Do not check link state before starting transmitter. Otherwise
mbufs will just pile up in the interface queue.
 1.130 21-May-2007  cube Add support for BCM5715. Works seemingly well on hardware provided by
pavel@. Thanks, Pavel!
 1.129 25-Apr-2007  joerg Fix a NULL reference on failing mbuf allocation.
In bge_start return if IFF_OACTIVE is set in combination with
IFF_RUNNING, drop obscure check for length of interface queue.
Remove message about failing bge_encap, it can happen just too easily
because of full descriptor rings.
 1.128 16-Apr-2007  tron Add support for Broadcom BCM5753 and Broadcom BCM5753M Gigabit Ethernet.
Patch supplied by Mustafa Dogan in PR kern/36139, confirmed to work
by Tonnerre Lombard on #NetBSD IRC channel.
 1.127 05-Mar-2007  tsutsui branches: 1.127.2; 1.127.4;
Pass (char *) to mtod(9) for pointer arith
(in #ifndef __NO_STRICT_ALIGNMENT part).
 1.126 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.125 19-Feb-2007  bouyer We have to bus_mapmap_load() after m_adj, otherwise the map will point at
the wrong place in the buffer. Fix an issue in the !sc->bge_rx_alignment_bug
case reported by Nicolas Joly.
While there remove a duplicate m_adj(), and add a missing bus_dmamap_unload().
 1.124 17-Feb-2007  bouyer bus_dma fixes for bge(4). It now works on amd64 with more than 4GB physical
RAM (jumbo frames untested yet).
 1.123 09-Feb-2007  ad branches: 1.123.2;
Merge newlock2 to head.
 1.122 26-Nov-2006  tsutsui branches: 1.122.2;
Sync two alternative IDs with pcidevs.
 1.121 26-Nov-2006  tsutsui Fix a typo.
 1.120 26-Nov-2006  tsutsui Add and fix some BGE_CHIPIDs. From FreeBSD and OpenBSD.
 1.119 26-Nov-2006  tsutsui Add support for BCM5752M. from Matt Kolb on tech-kern and OpenBSD.
 1.118 26-Nov-2006  tsutsui Pull some bge_encap() fixes from OpenBSD:
> - Move TX ring full sanity check further up and check the number of DMA
> segments from the DMA map, instead of counting the DMA segments in the
> for loop and breaking out later.
> - Unload the DMA map if encountering an error condition.
 1.117 25-Nov-2006  tsutsui BCM5701 B2 requires BGE_QUIRK_ONLY_PHY_1 quirk. From Brian Baird
in PR kern/23778.
 1.116 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.115 28-Oct-2006  tsutsui - bcopy -> strcpy (in debug message)
- bcopy -> memcpy
 1.114 28-Oct-2006  tsutsui - use continue for an empty statement in for() loop
- remove an empty statement in if() clause by inverting logic
- use KDASSERT(9) rather than #ifdef DEBUG + KASSERT(9)
- replace commented out M_WRITABLE() with !M_READONLY(9)
 1.113 28-Oct-2006  tsutsui M_TRALINGSPACE(m) returns 0 if M_READONLY(m) is true,
so no need to call both. Pointed out by Pavel Cahyna.
 1.112 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.111 29-Sep-2006  christos Coverity CID 3666: Remove debug to expose KASSERT's (from Arnaud Lacombe)
 1.110 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.109 01-Jun-2006  jonathan branches: 1.109.6; 1.109.8;
Rework bge_reset() to more closely follow the Broadcom-supplied Linux driver:

1. Instead of enabling the buffer manager hardware-FSM only on
pre-5705 devices, initialize the buffer manager on all bge devices.
Modelled on the Broadcom-authored Linux driver.

2. Instead of enabling the memory arbiter hardware-FSM only on
pre-5705 devices, initialize the memory arbiter on all bge devices.
Modelled on the Broadcom-authored Linux driver.

3. Ditto the second copy of code which enables the memory arbiter.
Also, add an XXX asking, why taunt the chip this way a second time?
(The most plausible explanatoin is that enabling the memory arbiter
twice is my own darn fault, likely a cut-and-paste glitch I made many
moons ago, when re-ordering hardware enables to match the Linux drivers.)
 1.108 01-Jun-2006  jonathan Fix a minor thinko in ascertaining whether or not a bge(4) device is
attached via PCI-Express:

The previous code first checked that the bge ASIC-revision matched the
5750 ASIC-revisoin (the bcm5721 has the same ASIC revision). However, the
bcm5752 is also a PCI-Express device, but has a different ASIC revision.
Thus, we were setting sc->bge_pcie to zero for bcm5752s, which in turn
causes bge_reset() to not perform required PCI-Express setup.

The test for a 5750 ASIC revision may (or may not) have been carried
across from the FreeBSD bge(4) driver. FreeBSD's bge(4) does not
properly detect or handle post-5750 bge devices. Instead, FreeBSD's
bge(4) keeps a sofc copy of the ASIC revision, and for post-5750
devices (5752, 5714, ...) overwrites that softc copy of the
ASIC-revision with the 5750 ASIC revision. Thus, the test (mutatis
mutandis, using FreeBDS's softc asic-revision field), was correct for
FreeBSD; but manifestly incorrect for NetBSD.

Mark Davies (mark at mcs.vuw.ac..nz) has confirmed via private email
that this change fixes PR kern/kern/33509: his bcm5752 now works.
 1.107 28-May-2006  blymn Clean up bogus whitespace
 1.106 27-Apr-2006  jonathan branches: 1.106.2;
Add an default entry to bge_majorrevs[] for bge chips with the 5780
ASIC revision.

Add (accidentally omitted) PCI product-ID entries for the BCM5780 and
BCM5780 (Serverworks HT-2000 to bge_products[], so that bge_probe()
will attach bcm5780 variants. Tested on a bcm5780.

Handling for the bcm5780S with 1000base-X PHY almost certainly has the
wrong quirks; our quirk entries are driven off ASIC ID. However, the
5780 (usually integral copper) and 5780S (TBI?) have the same ASIC ID.
The Linux drivers ascertain whether to use integral copper phy or external
PHY via EEPROM bits.

I suspect the only way we're going to handle the 5780 vs. 5780S
properly is to add exact chip-id matches for all 5780/5780S variants
to bge_revisions[]. However, I don't know those ids until other users
with bcm5780s hardware can get this revision, try it, and report the output.
So, here goes.
 1.105 18-Apr-2006  christos PR/33828: Pawel Chwalowski: Add support for Broadcom BCM5789 chip
 1.104 04-Mar-2006  thorpej branches: 1.104.2; 1.104.4; 1.104.6;
Static'ify.
 1.103 22-Feb-2006  rpaulo In bge_ioctl(), don't call bge_init() if the interface is already up.
Makes ifwatchd work on this interface.
 1.102 24-Dec-2005  perry branches: 1.102.2; 1.102.4; 1.102.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.101 19-Dec-2005  skrll Typo in comment.
 1.100 12-Dec-2005  jonathan Fix silly cut-and-paste typo (CSR_READ(sc, BGE_MARBMODE_ENABLE),
should obviously have been CSR_READ(sc, BGE_MARB_MODE) incurred during
my backport of 5714/5715 support from my netbsd-3 development branch,
back into -current.
 1.99 12-Dec-2005  jonathan Add support for bcm5714 and (possibly incorrect) support for the
bcm5715 PCI-Express dual-port NICs. Taken from the Broadcom-supplied
Linux driver, bcm-8.3.13a.

Add nascent support for the bcm5780, but (since I have no bcm5780 to
test), don't yet add an entry which allows us to match or attach to a
5780.

Change 5752 support: Follow the lead of the Broadcom-supplied Linux
driver (bcm) and the Linux tg3 driver, and treat the 5752 like a 5750.
 1.98 07-Dec-2005  jonathan Add PCI device-ids to sys/dev/pci/pcidevs for newer Broadcom gigabit
ethernet devices: bcm5714, bcm5752 (previously the 5789, but fvdl
committed that whilst I was musing).

Add definitions to sys/dev/pci/if_bgereg.h for the Broadcom 57xx-family
ASIC revisions on these newer chips.

Add entries to the PCI-device-version and bge-internal-asic-revision
tables in sys/dev/pci/if_bge.c to use these new devices. Pending
further information, follow the lead of FreeBSD's if_bge.c driver and,
pending further info, treat these new chips as we do the 5750.
 1.97 06-Dec-2005  fvdl Match the 5789.
 1.96 24-Nov-2005  martin Use %zd for size_t. Noticed by Kurt Schreiner on current-users.
 1.95 24-Nov-2005  jonathan Add TSO support to bge(4) for PCI-Express bge devices, which are
shipped from the factory with TSO-capable firmware. The TSO support
here may also work on 5705 chips, but that is (so far) untested.

TSO support written after careful reading of the Linux tg3 driver,
and (after attempting to deconstruct the cut-and-paste mess therein)
very close reading of the Broadcom-supplied Linux driver, particularly
the building of Tx-DMA buffer descriptors (bds). The TSO code herein was
then rewritten from scratch, circa 4am local time, October 27 2005.
(In other words: this is 4am software; caveat emptor.)

Other magic register settings in this patch are required; without
them, attepmting to use TSO locks up the chip. The required register
settings were extracted from the cited Linux drivers.

Note that TSO-capable firmware for the 5703/5704 is distributed in
non-GPL form with the aforementioned Linux drivers. Once the 5705 case
is debugged, (particularly the pseudo-header checksum precalculation
flagged with an XXX) downloading that TSO-capable firmware to the
5703/5704 should, in principle, enable TSO support on all but the
original bcm5700 (I forget if the 5701 can support TSO, or not).

Note also that the ``hard case '' of IP/TCP headers spanning more than
one mbuf is not handled; I haven't been able to trigger it. In any
case, since TSO applies only to packets generated by the local TCP,
and our TCP always leaves space for TCP headers and a normal IP
header, TSO on an IP/TCP header spanning multiple headers can only
arise due to insertion of IP options. I beleive that we are clearly
better off outlawing that case, and requiring ip_insertoptions()
to pull-up TCP headers on any packets with M_CSUM_TSOv4 set.

As far as I know, bge hardwar does not support TSO for IPv6.
 1.94 15-Nov-2005  jonathan Correct a performance bug from Bill Paul's original FreeBSD bge(4) driver:

Each call to the FreeBSD bge_start() routine the transmit producer
pointer index from the chip mailbox register BGE_MBX_TX_HOST_PROD0_LO.
The local copy of that value is then updated by bge_encap() as
bge_encap() encapsulates packets in the Tx ring. If bge_encap()
succeds in encpuslating one or more packets, bge_start() tells the
chip to start sending the newly-encinitiates writes the new value back
to the chip mailbox register.

However, comparison of the Linux drivers (Broadcom-supplied and
open-source tg3.c) and to the OpenSolaris driver confirms that
register BGE_MBX_TX_HOST_PROD0_LO is write-only to software.
Thus, we can just keep a copy in the softc, and eliminate the
(expensive) PCI register write on each call to bge_start().

``Make it so''.
 1.93 06-Sep-2005  tsarna branches: 1.93.6;
Allow reception of VLAN sized frames. From FreeBSD.

Reviewed by cube.
 1.92 22-Aug-2005  gavan Add quirk for BGE_CHIPID_BCM5751_A1. From Kurt Schreiner <ks at ub.uni-mainz
dot de> via PR kern/31028.
 1.91 21-Aug-2005  gavan Recognise Broadcom 5751M Gigabit Ethernet, as found on ThinkPad T43p.
 1.90 20-Jun-2005  atatat branches: 1.90.2;
Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.89 22-May-2005  christos No 0x in front of %p...
 1.88 02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.87 27-Feb-2005  perry branches: 1.87.2;
nuke trailing whitespace
 1.86 21-Feb-2005  thorpej Define M_CSUM_DATA_IPv4_IPHL() and M_CSUM_DATA_IPv4_OFFSET() macros
to extract data from csum_data, rather than just open-coding it.
 1.85 20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition

also restructure and simplify input VLAN ID code handling somewhat, to not use
local have_vlan/vlan_tag variables, and use the appropriate cur_rx condition
on the one place where it's needed
 1.84 18-Feb-2005  heas Adjust csum_data usage; mask off the high 16 bits.
 1.83 26-Jan-2005  jmcneill Missed a break in the powerhook (shouldn't matter functionally, but
fix anyway for correctness).
 1.82 26-Jan-2005  jmcneill Add powerhook to bge(4)
 1.81 24-Jan-2005  matt branches: 1.81.2;
Add IFNET_FOREACH and IFADDR_FOREACH macros and start using them.
 1.80 08-Jan-2005  fredb branches: 1.80.2;
Recognize the Broadcom 5721 Gigabit Ethernet, as found on SuperMicro P8SCi
motherboards.
 1.79 19-Nov-2004  jmmv Fix typo in previous commit that was breaking the build (hi, tacha@!).
 1.78 19-Nov-2004  tacha Add support for Broadcom BCM5705K.
 1.77 30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.76 28-Oct-2004  cube Add support for the BCM575x variants. They're close to the 5705 one, with
some special cases for the PCI-Express versions. As there is no
documentation available, all of this is inspired from Linux or taken from
FreeBSD (itself inspired from Linux). There are a lot of magic numbers.

Tested on two BCM5751 devices as found in newer Dell computers.
 1.75 29-Sep-2004  yamt - mbuf external storage is of (caddr_t), not (caddr_t *).
- remove a needless cast.
 1.74 21-Sep-2004  yamt introduce M_EXT_RW to allow mbuf external storage R/W.
discussed on tech-net@.
 1.73 25-May-2004  atatat Remaining sysctl descriptions under hw subtree (ath and bge)
 1.72 15-May-2004  thorpej Add PAUSE-related event counters. Slightly modified from patch supplied by
HITOSHI Osada.
 1.71 15-May-2004  thorpej Patches from HITOSHI Osada:
* Set buffer management high water marks for MTU > 1514.
* Set BGE_MAX_RX_FRAME_LOWAT (from Linux driver).
 1.70 12-May-2004  tron Add support for Broadcom BCM5788 GbE. Patches supplied by FUKAUMI Naoki
in PR kern/25166.
 1.69 10-Apr-2004  thorpej Add 802.3x flow control support. From HITOSHI Osada.
 1.68 06-Apr-2004  keihan s/netbsd.org/NetBSD.org/g
 1.67 04-Apr-2004  jonathan Fix mistaken arguments to bge_set_thresh(); the prior revision would
pass the bge_softc * to a function expecting the struct ifnet*,
triggering a panic every time the Rx-mitigation value is changed via sysctl.
(Testing via kernel debugger before Andrew's recent sysctl(9) changes
was done with the exact same mistaken argument.)
 1.66 27-Mar-2004  atatat branches: 1.66.2;
GC ath_node_root as well, but modify to work around the single
(tightly scoped) reason for recording the node address by recording
the assigned number. Dink pci/if_bge.c to match, since ic/ath.c was
used as the archetype.
 1.65 27-Mar-2004  atatat GC bge_node_root, since it's not needed and probably wrong.
 1.64 27-Mar-2004  jonathan Update yesterday's if_bge sysctl hooks for hw.bge.* (based on
yesterday's sys/dev/ic/ath.c) to match today's ath.c driver.
Commit now in the hope that Andrew Brown will pick up this file for
any more pending changes.
 1.63 20-Mar-2004  jonathan Add a table of Rx interrupt-threshold register values for mitigating
Rx interrupts, functions to post a request for new table entries, and
code to apply pending Rx-interrupt control values at the next hardware
interrupt.

As used in a third-party proprietary tree since at least March 2003.
As discussed on tech-kern/tech-net in January 2004 (in the context of
NetBSD for packet capture, bpf, and FreeBSD-sylte IFF_POLL), and as
posted to tech-net for comments in mid-March 2004.

Still missing sysctl or other knobs to acutally change the config-time
values, due to my ignorance of any accepted per-device sysctl namespace.
 1.62 20-Mar-2004  jonathan Possibloe fix for some bge chip revisions taking a long time to reset
(e.g., polling for a half-second or more at splnet(), blocking most
interrupts, durin an ifconfig down/ifconfig up).

Appears to help for a 5704C rev A3, which is the only chip I've
ever seen that had even a mild version of the reported problem.
 1.61 20-Mar-2004  jonathan Check for BGE_PCI_PCISTATE register failing to revert on reset.
if it occurs, print a message indicating why the reset took so long.
 1.60 10-Mar-2004  drochner use "=" instead of "|=" on first assignment to mbuf.csum_flags
(probably unnecessary because zero-initialized on mget, but
cheaper anyway)
 1.59 06-Mar-2004  martin Set BGE_JUMBO_RXRING_VALID in bge_flags when allocating jumbo ring buffers,
so it can be freed later. From HITOSHI Osada in PR kern/24686.
 1.58 22-Jan-2004  jonathan Add hooks to dynamically change the bge Rx interrupt thresholds. I
found empiricaly that (at least on bcm5700s) the Rx coalesce and bd
counts cannot be updated on-the-fly; attempting to do so (even at
splhigh()) causes weird behaviour.

Instead, add a softc flag to record that the desired softc values for
Rx-interrupt thresholds have changed; check that boolean in the interrupt
routine. If set, apply the new values there and clear the flag.
 1.57 14-Dec-2003  jonathan Do 5704-specific setup of DMA control register for all 5704 variants,
including chips that matched only the asic-revision fallback table.

When dong DMA setup for 5703 and 5704, use the new BGE_ASICREV() macro
to extract the ASIC revision.
 1.56 09-Dec-2003  pooka The highest 16 bits of chipid identify the ASIC, so print only them.
 1.55 08-Dec-2003  pooka Match 5703 ASIC A3.

Also, when printing the ASIC ID, print the revision in hex in all
cases to avoid extra confusion if only the "superclass" of the ASIC
is recognized.
 1.54 11-Nov-2003  fvdl From FreeBSD:

* erratum: disable the nocrc RX bit, as it may cause problems on the 570{1-4}.
adjust the length of the incoming packet accordingly to trim it.
* the 5704 has a smaller MBUF_POOL, so set a smaller value

Local change:
* Pass the autoneg force flag to mii_attach. Some PHYs need to be kicked
out of their falsely autoneged 10baseT state with this.
 1.53 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.52 23-Oct-2003  fvdl Need the NOCRC bit, or my 5704B5 will start acting up.
 1.51 23-Oct-2003  fvdl * match more cards (from FreeBSD)
* don't set the NOCRC bit in the mode control register, it can cause
problems on some chips (from the broadcom errata via FreeBSD)
* implement a fallback quirktable that is searched only using the
major asic revision, so that the driver has a shot at supporting
newer versions properly without modification
* rename asicrev -> chipid, like the FreeBSD driver
 1.50 05-Sep-2003  tron From FreeBSD as suggested by Nicolas Joly in PR kern/22682:
Do not initalize the LED's to 0x00. The default configuration
the chip comes up in should yeild proper operation of the LED's.
 1.49 27-Aug-2003  fvdl Support the BCM5704C rev 3. From Nicolas Joly, PR 22620
 1.48 26-Aug-2003  hannken Finish last commit (Make this compile with options DEBUG).
NetBSD has no M_WRITABLE().
 1.47 23-Aug-2003  cjep Make this compile with options DEBUG (part of PR#22582 from Frank Kardel).
 1.46 22-Aug-2003  jonathan Check in hooks to fix checksum offload on bge devices. Empirical
observation is that some 570x devices can get themselves into a state
where they miscompute off-loaded TCP or UDP checksums on packets so
small that Ethernet padding is required. Further obsevation suggests
that the bge checksum-offload hardware is adding those padding bytes
into its TCP checksum computation. (Once a 5700 gets in this state,
even a warm boot won't fix it: it needs a hard powerdown.)

Work around the problem by padding such runts with zeros: even if the
checksum-offload adds in extra zeros, the resulting sum will be correct.

Also, dont trust the checksum-offload on received packets smaller than
the minimum ethernet frame, in case the Rx-side has a similar bug.

Finally, on packets where we do trust the outboard Rx-side TCP or UDP
checksum, the bge did not include the pseudo-header. Set the
M_CSUM_NO_PSEUDOHDR bit as well as M_CSUM_DATA, and rely on
udp_input() or tcp_input() adding in the sum via in_cksum_phdr().
 1.45 22-Aug-2003  jonathan Fix a bug in compaction of `DMA runt' fragmented packet chains:
if we m_dup() a packet to compactify it, and later run out of DMA
descriptors, bge_encap() will return ENOBUFS, hoping the driver will
try again later. But we have just m_freem()'d the original chain
which was m_dup()'d, leaving a pointer to the just-freed packet header
in the tx queue.

Fix by always walking the chain, shuffling data towards the head;
except if we find a runt in the very last mbuf, we must borrow data
from its predecessor.

(Patch is verbatim from a third-party tree, apologies for any style woes.)
 1.44 17-Jul-2003  hannken Add support for the BCM5705:
- Only BCM5705M asic rev A1 was tested.

Thanks to Bill Paul (wpaul@freebsd.org) for help and support.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.43 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.42 30-Jun-2003  ragge branches: 1.42.2;
Set the send queue to max(BGE_TX_RING_CNT - 1, IFQ_MAXLEN); sometimes
IFQ_MAXLEN may be choosen to a larger value than number of descriptors.
Why this setting from the beginning???
 1.41 15-Jun-2003  fvdl Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.40 01-Jun-2003  fvdl Add newer 5704 asic revs, and add them to the table, with the
BGE_QUIRK_ONLY_PHY_1 quirk in their entry.
 1.39 03-May-2003  wiz DMA, not dma nor Dma.
 1.38 24-Mar-2003  tron Don't print a kernel message like "bge0: gigabit link up" when a Gigabit
link is detected. No other ethernet driver does this and this driver
doesn't do it for other modes.
 1.37 07-Mar-2003  jonathan Commit workaround for hardware bug: 5701 chips running in PCI-X mode
require that the DMA receive buffers be aligned. The driver was
deliberately mis-aligning by 2 bytes, to force the layer-2/3
headers to 32-bit alignment.

Workaround: if chip is a 5701, and is in PCI-X mode, leave the DMA
buffers aligned. If the host CPU requires alignment, copy the buffer
after reception to force aligment.

Tested on an i386 in PCI-X bus, with __NO_STRICT_ALIGNMENT forced off.

Patch and comments reworked to minimize drift from
FreeBSD if_bge.c rev 1.14.
 1.36 07-Mar-2003  jonathan Fix typo: PRODUCER_BUG quirk mask overlapped the PCIX register-bug quirk.
(Harmless, since we dont use the latter; but we will use it very soon.)
 1.35 06-Mar-2003  jonathan Commit the FreeBSD alternative of a private patch to check NIC internal
ram for using TBI, versus MII/GMII.

FreeBSD commit log and versions:
Obtain the media type from the shared memory and only use the eeprom
as a fallback.

if_bge.c: rev 1.30
if_bgereg.h: rev 1.13

Thanks to Paul Saab @mu.org.
 1.34 06-Mar-2003  jonathan FreeBSD fix for problems reported (to FreeBSD) with 16-bit accesses
to 32-bit device registers. Add (untested) NetBSD fix for big-endian hosts.
From FreeBSD versions:
if_bge.c: 1.26 and 1.27
if_bgereg.h: 1.12

FreeBSD (MFC) comment:

MFC: Avoid 16-bit accesses to device memory. Use volatile where
appropriate in referencing device memory. Parenthesize BGE_HOSTADDR
define properly.
 1.33 22-Feb-2003  tsutsui hz -> Hz
 1.32 09-Feb-2003  tron Correct typo in an e-mail address.
 1.31 31-Jan-2003  thorpej Change ext_size to a size_t, and update the signature of ext_free.
 1.30 31-Jan-2003  thorpej Use aprint_*().
 1.29 17-Jan-2003  itojun branches: 1.29.2;
correct the use of m_tag. correct indentation (:set sw=8 ts=8 please,
jonathan)
 1.28 17-Jan-2003  itojun switch from kame-based m_aux mbuf auxiliary data, to openbsd m_tag
implementation. it will simplify porting across *bsd (such as kame/altq),
and make us more synchronized. from Joel Wilsson
 1.27 17-Jan-2003  jonathan Grr. Fix consistent typo, to match what i actually tested before committing.
 1.26 17-Jan-2003  jonathan Enable the 5700 DMA bug and producer-pointer fixes, by setting the
quirk on all 5700 revision B devices. (These fixes have not been
tested against NetBSD recently; committing the fix and the enable separately
gives us flexibility about which fixes get pulled into the NetBSD-1.6 branch.)
 1.25 17-Jan-2003  jonathan Commit accumulated bge fixes:
* Add support for 5704C dual-channel chip with integral copper PHY (tested)
and 5704S dual-channel SERDES/TBI gbic (untested). Add PHY DSP patch
for 5704.
* Update PHY DSP-code patch for bcm5401 to match latest Linux driver.

* Add PHY DSP-code patch for 5703 (untested).

* Update onchip buffer tunables to recommended values from Linux drivers.

* Disable MWI access. This chip family cannot hanlde PCI stalls
in the middle of an MWI burst. The driver has heuristics to detect PCI
line size, but under load, some PCI bridges may force stalls which
the attach-time heruistics do not catch. Some PCI bridges never
do this, so maybe it should be a tunable option.

* bcm5700 rev Bx chips have a race condition, where updating the
Tx producer pointer goes un-noticed by the chip. Workaround is to
write the new producer-pointer value twice.

* bcm5700 chips rev Bx wedge up if given DMA descriptors of
eight bytes or less. Once hit, only reovery is a watchdog timeout/reset.
If the offending packet is retransmitted, the chip will wedge again...
Check for teeny fragments in a Tx request, and either fold the
teeny chunk residue into an adjacent mbuf, or m_dup the entire buffer.
(NB: quirk not yet enabled; in-place folding tested only on FreeBSD.)

* Add workaround for revision Bx bcm5700: chip bugs in decoding
of PCI register writes may leave the hardware in (partial) powersave state,
such that writes to "indirect" registers do not work.
Explicitly force chip into D0 state at attach time.

* Accessing PHY registers with the bge chip in autopoll mode, when
link-state is the process of changing, may cause the bge chip to
assert PCI errors. Workaround: when doing miibus register access,
save autopoll state, disable around access, and restore autopoll state.
NB: issuing PHY resets may give a window where the problem still occurs.

* Increase Tx interrupt-coalescing thresholds, to reduce Tx-done interrupts.
 1.24 26-Dec-2002  matt Recognize BCM5702X and BCM5703X. Add a ONLY_PHY_1 quirk and use it.
Add support for getting the macaddr for 5703 (taken from FreeBSD).
 1.23 06-Oct-2002  kristerw Do not try to print uninitialized variable.
 1.22 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.21 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.20 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.19 18-Jul-2002  mjl branches: 1.19.2; 1.19.4;
Correct obviously switched args to memset()
 1.18 13-Jul-2002  thorpej branches: 1.18.2;
Add a BGE_QUIRK_CSUM_BROKEN quirk, and give it to BCM5700 B0, rather
than testing for the revision all over the driver. If the chip has
broken checksums, then don't advertise the capability to the stack.
 1.17 13-Jul-2002  thorpej Give BCM5700 Ax and Bx revs the BGE_QUIRK_LINK_STATE_BROKEN quirk,
and test for that, rather than checking revision where the quirk is
handled.
 1.16 13-Jul-2002  thorpej Add a lookup table with ASIC revision, name, and any quirks. Print
ASIC revision at attach time. Add BCM5703 revisions.
 1.15 13-Jul-2002  thorpej Move the BCM5401 DSP patch out of the bge driver and into
the brgphy driver; all users of the BCM5400 and BCM5401 need
the DSP patch and the sledgehammer-reset-at-media-set-time.

Also add a DSP patch for the BCM5411 gleaned from Apple's
GMAC driver for Darwin.

Tested with a 3Com 3c996-T (BCM5700 + BCM5401).
 1.14 12-Jul-2002  enami Match Altima AC1001.
 1.13 01-Jul-2002  thorpej Fix multicast filter programming.
 1.12 28-Jun-2002  thorpej Fix a comment.
 1.11 28-Jun-2002  thorpej When stopping the various functional blocks of the chip, clear the
bit and then read it back in a loop (with appropriate delays) waiting
for it to read back clear.

This fixes a problem where the bus would hang when bringing down
the interface or changing interface flags on a system with a
sufficiently fast CPU (e.g. 2GHz P4 Xeon).
 1.10 28-Jun-2002  fvdl Rearrange alignment code a bit.
 1.9 28-Jun-2002  thorpej Increase previously added delays from 2us to 10us.
 1.8 28-Jun-2002  thorpej * Only set the jumbo frame capability if we are able to allocate
jumbo frame buffers.
* Garbage-collect some stuff we don't need.
* Fix timeout detection in the firmware handshake.
 1.7 27-Jun-2002  thorpej Use a table to match BCM570x products.
 1.6 27-Jun-2002  thorpej Don't call m_aux_find() in the inner loop when creating the Tx
descriptor list. Instead, call it once and remember the result,
and only call it looking for VLAN tags if VLANs are configured
on the interface.
 1.5 27-Jun-2002  thorpej Put some delay in the loops that poll for MII transaction
completion. Without this, reading the PHY can hang the bus
on a sufficiently fast CPU.
 1.4 27-Jun-2002  fvdl Disable TCP/UDP checksums on the receive side again.
 1.3 26-Jun-2002  cjs Match newer NetGear GA302T cards.
 1.2 24-Jun-2002  fvdl According to the Linux driver from Broadcom, only the 5700 B0 revision had
rx checksum problems. So only disable rx checksum for that revision.
 1.1 22-Jun-2002  fvdl Driver for Broadcom 570x / Altima AC 1000 gigabit ethernet cards.
Written by Bill Paul for FreeBSD. This port started out with the
port done to OpenBSD by nate@openbsd.org, but ended up looking much
more like the port of the ti driver done by drochner@netbsd.org
(they are similar in structure).
 1.18.2.3 20-Jul-2002  gehenna catch up with -current.
 1.18.2.2 15-Jul-2002  gehenna catch up with -current.
 1.18.2.1 13-Jul-2002  gehenna file if_bge.c was added on branch gehenna-devsw on 2002-07-15 10:35:36 +0000
 1.19.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.19.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.19.4.1 18-Jul-2002  jdolecek file if_bge.c was added on branch kqueue on 2002-09-06 08:45:14 +0000
 1.19.2.5 17-Jan-2003  thorpej Sync with HEAD.
 1.19.2.4 29-Dec-2002  thorpej Sync with HEAD.
 1.19.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.19.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.19.2.1 18-Jul-2002  nathanw file if_bge.c was added on branch nathanw_sa on 2002-08-01 02:45:14 +0000
 1.29.2.7 15-Mar-2004  jmc Pullup rev 1.59 (requested by martin in ticket #1622)

Set BGE_JUMBO_RXRING_VALID in bge_flags when allocating jumbo ring buffers
so it can be freed later. PR#24686
 1.29.2.6 20-Oct-2003  cyber Pull up revision 1.50 (requested by tron in ticket #1447):
From FreeBSD as suggested by Nicolas Joly in PR kern/22682:
Do not initalize the LED's to 0x00. The default configuration
the chip comes up in should yeild proper operation of the LED's.
 1.29.2.5 16-Jun-2003  grant Pull up revision 1.35 (requested by tron in ticket #1250):

Commit the FreeBSD alternative of a private patch to check NIC internal
ram for using TBI, versus MII/GMII.

FreeBSD commit log and versions:
Obtain the media type from the shared memory and only use the eeprom
as a fallback.

if_bge.c: rev 1.30
if_bgereg.h: rev 1.13

Thanks to Paul Saab @mu.org.
 1.29.2.4 16-Jun-2003  grant Pull up revision 1.34 (requested by tron in ticket #1249):

FreeBSD fix for problems reported (to FreeBSD) with 16-bit accesses
to 32-bit device registers. Add (untested) NetBSD fix for big-endian hosts.
From FreeBSD versions:
if_bge.c: 1.26 and 1.27
if_bgereg.h: 1.12

FreeBSD (MFC) comment:

MFC: Avoid 16-bit accesses to device memory. Use volatile where
appropriate in referencing device memory. Parenthesize BGE_HOSTADDR
define properly.
 1.29.2.3 16-Jun-2003  grant Pull up revision 1.38 (requested by tron in ticket #1230):

Don't print a kernel message like "bge0: gigabit link up" when a Gigabit
link is detected. No other ethernet driver does this and this driver
doesn't do it for other modes.
 1.29.2.2 28-Jan-2003  jmc Pullup from -current (lots of revisions 1.1-1.19,1.22-1.27
(requested by fvdl in ticket #1126)
Pullup support for bge device. (Broadcom Gigabit Ethernet)
 1.29.2.1 17-Jan-2003  jmc file if_bge.c was added on branch netbsd-1-6 on 2003-01-28 06:19:13 +0000
 1.42.2.12 11-Dec-2005  christos Sync with head.
 1.42.2.11 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.42.2.10 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.42.2.9 04-Feb-2005  skrll Sync with HEAD.
 1.42.2.8 17-Jan-2005  skrll Sync with HEAD.
 1.42.2.7 29-Nov-2004  skrll Sync with HEAD.
 1.42.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.42.2.5 19-Oct-2004  skrll Sync with HEAD
 1.42.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.42.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.42.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.42.2.1 03-Aug-2004  skrll Sync with HEAD
 1.66.2.3 29-May-2004  tron branches: 1.66.2.3.2;
Pull up revision 1.73 (requested by atatat in ticket #392):
Remaining sysctl descriptions under hw subtree (ath and bge)
 1.66.2.2 13-May-2004  jdc Pull up revision 1.70 (requested by tron in ticket #316)

Add support for Broadcom BCM5788 GbE. Patches supplied by FUKAUMI Naoki
in PR kern/25166.
 1.66.2.1 05-Apr-2004  tron Pull up revision 1.67 (requested by jonathan in ticket #59):
Fix mistaken arguments to bge_set_thresh(); the prior revision would
pass the bge_softc * to a function expecting the struct ifnet*,
triggering a panic every time the Rx-mitigation value is changed via sysctl.
(Testing via kernel debugger before Andrew's recent sysctl(9) changes
was done with the exact same mistaken argument.)
 1.66.2.3.2.1 24-Jan-2005  he Pull up revision 1.77 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.80.2.1 29-Apr-2005  kent sync with -current
 1.81.2.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.81.2.1 12-Feb-2005  yamt sync with head.
 1.87.2.7 19-Nov-2007  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1862):
sys/dev/pci/if_bge.c 1.89,1.95,1.97,1.101,1.103,
1.105,1.107,1.117-1.122,
1.128-1.131,1.133-1.135,1.139
via patch
sys/dev/pci/if_bgereg.h 1.31,1.34-1.39,1.42-1.43
sys/dev/pci/pcidevs patch

Some cleanups(typo, whitespace, debug message).
Add TSO support to bge(4)
Add support for BCM5715, BCM5752M, BCM5754, BCM5755, BCM5786 and 5787.
Add support for BCM5789. Fixes PR/33828 from Pawel Chwalowskibg.
Add support for BCM5753 and BCM5753M Fixes PR kern/36139 from Mustafa Dogan.
Add and fix some BGE_CHIPIDs. From FreeBSD and OpenBSD.
In bge_ioctl(), don't call bge_init() if the interface is already up
(Makes ifwatchd work on this interface).
BCM5701 B2 requires BGE_QUIRK_ONLY_PHY_1 quirk. From Brian Baird in kern/23778.
Move TX ring full sanity check further up and check the number of DMA
segments from the DMA map, instead of counting the DMA segments in the
for loop and breaking out later.
Unload the DMA map if encountering an error condition.
Fix a NULL reference on failing mbuf allocation.
In bge_start return if IFF_OACTIVE is set in combination with
IFF_RUNNING, drop obscure check for length of interface queue.
Remove message about failing bge_encap, it can happen just too easily
because of full descriptor rings.
Fix some watchdog timeout and "block failed to stop" problems on
some cards.
Fix "pcistate failed to revert" problem on many cards.
 1.87.2.6 05-Mar-2007  ghen Pull up following revision(s) (requested by bouyer in ticket #1671):
sys/dev/pci/if_bgereg.h: revision 1.40
sys/dev/pci/if_bge.c: revision 1.124
sys/dev/pci/if_bge.c: revision 1.125
bus_dma fixes for bge(4). It now works on amd64 with more than 4GB physical
RAM (jumbo frames untested yet).
We have to bus_mapmap_load() after m_adj, otherwise the map will point at
the wrong place in the buffer. Fix an issue in the !sc->bge_rx_alignment_bug
case reported by Nicolas Joly.
While there remove a duplicate m_adj(), and add a missing bus_dmamap_unload().
 1.87.2.5 04-Jun-2006  tron Apply patch (requested by jonathan in ticket #1351):
Add support to bge(4) for bcm5714, bcm5715, bcm5780/HT-2000 and
bcm5752 chip variants.
 1.87.2.4 22-Nov-2005  tron Pull up following revision(s) (requested by jonathan in ticket #985):
sys/dev/pci/if_bgereg.h: revision 1.27
sys/dev/pci/if_bge.c: revision 1.94
Correct a performance bug from Bill Paul's original FreeBSD bge(4) driver:
Each call to the FreeBSD bge_start() routine the transmit producer
pointer index from the chip mailbox register BGE_MBX_TX_HOST_PROD0_LO.
The local copy of that value is then updated by bge_encap() as
bge_encap() encapsulates packets in the Tx ring. If bge_encap()
succeds in encpuslating one or more packets, bge_start() tells the
chip to start sending the newly-encinitiates writes the new value back
to the chip mailbox register.
However, comparison of the Linux drivers (Broadcom-supplied and
open-source tg3.c) and to the OpenSolaris driver confirms that
register BGE_MBX_TX_HOST_PROD0_LO is write-only to software.
Thus, we can just keep a copy in the softc, and eliminate the
(expensive) PCI register write on each call to bge_start().
``Make it so''.
 1.87.2.3 15-Sep-2005  snj Pull up following revision(s) (requested by tron in ticket #757):
sys/dev/pci/if_bge.c: revision 1.93
Allow reception of VLAN sized frames. From FreeBSD.
Reviewed by cube.
 1.87.2.2 08-Sep-2005  tron Pull up following revision(s) (requested by gavan in ticket #752):
sys/dev/pci/if_bgereg.h: revision 1.25
sys/dev/pci/if_bge.c: revision 1.92
Add quirk for BGE_CHIPID_BCM5751_A1. From Kurt Schreiner <ks at ub.uni-mainz
dot de> via PR kern/31028.
 1.87.2.1 08-Sep-2005  tron Pull up following revision(s) (requested by gavan in ticket #752):
sys/dev/pci/if_bge.c: revision 1.91
Recognise Broadcom 5751M Gigabit Ethernet, as found on ThinkPad T43p.
 1.90.2.9 11-Feb-2008  yamt sync with head.
 1.90.2.8 04-Feb-2008  yamt sync with head.
 1.90.2.7 21-Jan-2008  yamt sync with head
 1.90.2.6 15-Nov-2007  yamt sync with head.
 1.90.2.5 27-Oct-2007  yamt sync with head.
 1.90.2.4 03-Sep-2007  yamt sync with head.
 1.90.2.3 26-Feb-2007  yamt sync with head.
 1.90.2.2 30-Dec-2006  yamt sync with head.
 1.90.2.1 21-Jun-2006  yamt sync with head.
 1.93.6.2 29-Nov-2005  yamt sync with head.
 1.93.6.1 22-Nov-2005  yamt sync with head.
 1.102.6.2 01-Jun-2006  kardel Sync with head.
 1.102.6.1 22-Apr-2006  simonb Sync with head.
 1.102.4.1 09-Sep-2006  rpaulo sync with head
 1.102.2.1 01-Mar-2006  yamt sync with head.
 1.104.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.104.4.2 11-May-2006  elad sync with head
 1.104.4.1 19-Apr-2006  elad sync with head.
 1.104.2.2 26-Jun-2006  yamt sync with head.
 1.104.2.1 24-May-2006  yamt sync with head.
 1.106.2.1 19-Jun-2006  chap Sync with head.
 1.109.8.2 10-Dec-2006  yamt sync with head.
 1.109.8.1 22-Oct-2006  yamt sync with head
 1.109.6.3 06-Feb-2007  ad Quieten noisy boot messages.
 1.109.6.2 12-Jan-2007  ad Sync with head.
 1.109.6.1 18-Nov-2006  ad Sync with head.
 1.122.2.12 13-Jun-2012  sborrill Pull up the following revisions(s) (requested by buhrow in ticket #1449):
sys/dev/pci/if_bge.c: 1.194 via patch

Instruct hardware to perform checksumming over the entire packet not just
over the payload and notify upper layers appropriately. Fixes PR kern/40018.
 1.122.2.11 18-Aug-2009  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1342):
sys/dev/pci/if_bge.c: revisions 1.135, 1.146, 1.151-1.152,
1.155-1.167 via patch
sys/dev/pci/if_bgereg.h: revisions 1.43, 1.48-1.52
sys/dev/pci/if_bgevar.h: revision 1.1
sys/dev/mii/brgphy.c: revisions 1.36, 1.40, 1.43-1.44 and
1.47-1.48 via patch
sys/dev/mii/brgphyreg.h: revisions 1.3-1.4
sys/dev/mii/miidevs: revisions 1.75, 1.77, 1.85
sys/dev/mii/miidevs.h: regen
sys/dev/mii/miidevs_data.h: regen
sys/dev/mii/miivar.h: revision 1.54
For bge:
- Really set Tx threshold.
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the "link changed" bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
- Add BCM5786 support.
for brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2, BCM5708C, BCM5722, and BCM5906.
 1.122.2.10 20-Aug-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1172):
sys/dev/pci/if_bge.c: revision 1.149
sys/dev/pci/if_bgereg.h: revision 1.47
Add support for Broadcom 5722 and identify 5755 ASICs.
 1.122.2.9 17-May-2008  bouyer Pull up following revision(s) (requested by mlelstv in ticket #1144):
sys/dev/pci/if_bge.c: revision 1.144 via patch
Check wether interrupts originate from the bge hardware.
Fixes PR kern/33433.
 1.122.2.8 15-Oct-2007  xtraeme Pull up following revision(s) (requested by msaitoh in ticket #934):
sys/dev/pci/if_bge.c: patch

Shut up a debug message.
 1.122.2.7 07-Oct-2007  xtraeme Pull up following revision(s) (requested by msaitoh in ticket #918):
sys/dev/pci/if_bge.c: revision 1.139
Fix three bugs.
1) Move a magic number writing code.
Fix a watchdog timeout and "block failed to stop" problem on BCM5701 B5 card.
2) Fix incorrect register write.
Fix a watchdog timeout "block failed to stop" problem on BCM5700 B2 card.
3) Wait more long time for PCISTATE register to return to its original
pre-reset state.
Fix "pcistate failed to revert" problem on BCM5703 A2 card.
 1.122.2.6 31-Aug-2007  xtraeme Pull up following revision(s) (requested by phil in ticket #819):
sys/dev/mii/miidevs.h: regen
sys/dev/mii/miidevs: revision 1.71
sys/dev/pci/if_bge.c: revision 1.133
sys/dev/pci/if_bge.c: revision 1.134
sys/dev/pci/if_bgereg.h: revision 1.43
sys/dev/mii/brgphy.c: revision 1.34
sys/dev/mii/miidevs_data.h: regen
Add BCM5755 and 5754 Gig-E PHYs.
Regen for BCM5755 and 5754.
Add support for BCM5754 and BCM5755. From suggestions from Jonathan
Stone.
Add a couple more BGE_CHIPIDs
Add support for BCM5755 and BCM5754/5787. Suggestions from Jonathan
Stone and fixes from OpenBSD for various hardware bugs/errata.
Disable firmware fastboot on 5754 and 5755. From FreeBSD by way of Phil
Nelson.
 1.122.2.5 21-Aug-2007  liamjfoy Pull up following revision(s) (requested by pavel in ticket #821):
sys/dev/pci/if_bge.c: revision 1.130
Add support for BCM5715. Works seemingly well on hardware provided by
pavel@. Thanks, Pavel!
 1.122.2.4 10-Jun-2007  bouyer Pull up following revision(s) (requested by mlelstv in ticket #714):
sys/dev/pci/if_bge.c: revision 1.131
Do not check link state before starting transmitter. Otherwise
mbufs will just pile up in the interface queue.
 1.122.2.3 28-Apr-2007  bouyer branches: 1.122.2.3.2;
Pull up following revision(s) (requested by joerg in ticket #594):
sys/dev/pci/if_bge.c: revision 1.129
Fix a NULL reference on failing mbuf allocation.
In bge_start return if IFF_OACTIVE is set in combination with
IFF_RUNNING, drop obscure check for length of interface queue.
Remove message about failing bge_encap, it can happen just too easily
because of full descriptor rings.
 1.122.2.2 16-Apr-2007  bouyer Pull up following revision(s) (requested by tron in ticket #578):
sys/dev/pci/if_bge.c: revision 1.128
Add support for Broadcom BCM5753 and Broadcom BCM5753M Gigabit Ethernet.
Patch supplied by Mustafa Dogan in PR kern/36139, confirmed to work
by Tonnerre Lombard on #NetBSD IRC channel.
 1.122.2.1 27-Feb-2007  riz Pull up following revision(s) (requested by bouyer in ticket #466):
sys/dev/pci/if_bgereg.h: revision 1.40
sys/dev/pci/if_bge.c: revision 1.124-1.125
bus_dma fixes for bge(4). It now works on amd64 with more than 4GB physical
RAM (jumbo frames untested yet).
We have to bus_mapmap_load() after m_adj, otherwise the map will point at
the wrong place in the buffer. Fix an issue in the !sc->bge_rx_alignment_bug
case reported by Nicolas Joly.
While there remove a duplicate m_adj(), and add a missing bus_dmamap_unload().
 1.122.2.3.2.4 04-Sep-2008  skrll Sync with netbsd-4.
 1.122.2.3.2.3 03-Jun-2008  skrll Sync with netbsd-4.
 1.122.2.3.2.2 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.122.2.3.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.123.2.3 07-May-2007  yamt sync with head.
 1.123.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.123.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.127.4.1 11-Jul-2007  mjf Sync with head.
 1.127.2.6 09-Oct-2007  ad Sync with head.
 1.127.2.5 01-Sep-2007  ad Update for pool_cache API changes.
 1.127.2.4 20-Aug-2007  ad Sync with HEAD.
 1.127.2.3 15-Jul-2007  ad Sync with head.
 1.127.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.127.2.1 27-May-2007  ad Sync with head.
 1.132.6.10 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.132.6.9 11-Nov-2007  joerg Sync with HEAD.
 1.132.6.8 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.132.6.7 02-Oct-2007  joerg Sync with HEAD.
 1.132.6.6 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.132.6.5 03-Sep-2007  jmcneill Sync with HEAD.
 1.132.6.4 23-Aug-2007  joerg Introduce pci_net_generic_power, which should be enough for most
network drivers and be a good foundation for C&P for the rest.

For iwi(4), don't reset the PCI retry register again, pci_conf_restore
should take care of that already.

For bge(4), add a NetBSD style if_stop.
 1.132.6.3 21-Aug-2007  joerg Make bge(4) a bit more like other drivers in the tree with regard to
the data stored in the softc. Convert to pnp_register.
 1.132.6.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.132.6.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.132.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.132.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.134.2.2 07-Aug-2007  markd Disable firmware fastboot on 5754 and 5755. From FreeBSD by way of Phil
Nelson.
 1.134.2.1 07-Aug-2007  markd file if_bge.c was added on branch matt-mips64 on 2007-08-07 01:13:57 +0000
 1.136.2.4 23-Mar-2008  matt sync with HEAD
 1.136.2.3 09-Jan-2008  matt sync with HEAD
 1.136.2.2 08-Nov-2007  matt sync with -HEAD
 1.136.2.1 06-Nov-2007  matt sync with HEAD
 1.137.2.1 06-Oct-2007  yamt sync with head.
 1.139.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.139.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.139.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.139.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.140.4.1 11-Dec-2007  yamt sync with head.
 1.140.2.1 26-Dec-2007  ad Sync with head.
 1.141.2.1 20-Jan-2008  bouyer Sync with HEAD
 1.145.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.145.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.145.10.6 11-Aug-2010  yamt sync with head.
 1.145.10.5 11-Mar-2010  yamt sync with head
 1.145.10.4 16-Sep-2009  yamt sync with head
 1.145.10.3 19-Aug-2009  yamt sync with head.
 1.145.10.2 16-May-2009  yamt sync with head
 1.145.10.1 04-May-2009  yamt sync with head.
 1.145.8.1 17-Jun-2008  yamt sync with head.
 1.145.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.145.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.145.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.146.2.2 28-Jul-2008  simonb Sync with head.
 1.146.2.1 18-Jun-2008  simonb Sync with head.
 1.148.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.148.2.1 19-Oct-2008  haad Sync with HEAD.
 1.152.4.7 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.152.4.6 24-Apr-2011  riz Pull up following revision(s) (requested by buhrow in ticket #1601):
sys/dev/pci/if_bge.c: revision 1.194
Fixes for kern/40018.
Our driver initializes the Broadcom hardware to peform a tcp and udp
checksum on only the payload of the tcp or udp packet, rather than the
entire packet. The FreeBSD, OpenBSD and Linux drivers instruct the hardware
to compute
the checksum for the entire packet. I believe the bug is that some revisions
of the BCM hardware, under certain circumstances, revert to doing the
complete checksum calculation, as the FreeBSD, OpenBSD and Linux drivers
request, while things are running. As
a result, when we pull the computed checksum from the hardware and pass it
up to the upper layers, we assume the checksum is the more minimal
one, and the upper layers perform the appropriate checks, which, when this
happens, cause the packet to be rejected because the resultant checksum is
decidedly incorrect.
This patch changes the driver to instruct the hardware to perform the
checksum over the entire packet, just as the FreeBSD, OpenBSD and
Linux drivers do, and to notify the upper layers appropriately.
This patch appears to work on all revisions of the hardware that have been
tested. (See the list in the bug report.)
this patch is approved by tls.
 1.152.4.5 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1359):
sys/dev/pci/if_bge.c 1.170-1.181
sys/dev/pci/if_bgereg.h 1.53-1.56
sys/dev/pci/if_bgevar.h 1.2-1.5
sys/dev/pci/pcidevs 1.1017, 1.1021
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/miidevs 1.89, 1.93
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/dev/mii/brgphy.c 1.49, 1.52

- Fix a bug of BGE_RDMA_MODE_FIFO_LONG_BURST definition.
- Fix the bug that both BGE_PCIE and BGE_PCIX are set on PCI-Express devices.
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
- (brgphy(4)) Add support for BCM5461, BCM5464, BCM5784 and BCM5761.
- (brgphy(4)) Enable brgphy_jumbo_settings().
- (brgphy(4)) Enable the Ethernet@Wirespeed function.
- Add support for device properties to override the mac address and set
the BGE_NO_EEPROM flag if we have an onboard device w/o SEEPROM.
- Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- Fixes the bug that error bits arent cleard because these bit are W2C
(in other words W1C).
- Many other bugfixes from FreeBSD and OpenBSD.
- remove an unused structure.
- ANSI C, KNF and tabify
- fix typo in comment.
 1.152.4.4 04-Aug-2009  snj Pull up following revision(s) (requested by msaitoh in ticket #870):
sys/dev/pci/if_bge.c: revision 1.167
Call prop_dictionary_set_uint32() before mii_attach() so that brgphy
can do prop_dictionary_get_uint32() correctly.
 1.152.4.3 04-Aug-2009  snj Apply patch (requested by msaitoh in ticket #866):
For bge:
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the 'link changed' bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
For brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2 and BCM5722.
 1.152.4.2 02-Feb-2009  snj branches: 1.152.4.2.4;
Pull up following revision(s) (requested by he in ticket #384):
sys/dev/pci/if_bge.c: revision 1.155
Make fibre cards, at least 5701 models, work, by initializing the
bge_ifmedia.ifm_media field, which is not done by ifmedia_set().
Patch lifted from FreeBSD's revision 1.71.
 1.152.4.1 15-Nov-2008  snj Pull up following revision(s) (requested by cegger in ticket #44):
sys/dev/pci/if_bge.c: revision 1.154
PR kern/39608: bge(4) constant freeze on BCM5906M:
Correct DMA values. Patch from Karl Uwe Lockhoff via tech-kern.
 1.152.4.2.4.1 21-Apr-2010  matt sync to netbsd-5
 1.152.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.152.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.152.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.155.2.2 23-Jul-2009  jym Sync with HEAD.
 1.155.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.180.4.6 12-Jun-2011  rmind sync with head
 1.180.4.5 31-May-2011  rmind sync with head
 1.180.4.4 21-Apr-2011  rmind sync with head
 1.180.4.3 05-Mar-2011  rmind sync with head
 1.180.4.2 03-Jul-2010  rmind sync with head
 1.180.4.1 30-May-2010  rmind sync with head
 1.180.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.180.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.180.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.190.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.196.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.199.6.1 18-Feb-2012  mrg merge to -current.
 1.199.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.199.2.2 30-Oct-2012  yamt sync with head
 1.199.2.1 17-Apr-2012  yamt sync with head
 1.200.8.1 29-Nov-2014  martin Pullup revision 1.260 (via patch), requested by msaitoh in #1200:

Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
For PCI-X BCM5704, set maximum outstanding split transactions to 0.
This change fixes a serious stability problem on those chips.
 1.200.6.1 29-Nov-2014  martin Pullup revision 1.260 (via patch), requested by msaitoh in #1200:

Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
For PCI-X BCM5704, set maximum outstanding split transactions to 0.
This change fixes a serious stability problem on those chips.
 1.200.2.5 16-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #1256):
sys/dev/pci/if_bge.c: revision 1.278
Fix three bugs reported by enami@:
- bge_miibus_writereg(): Fix a bug that BCM5906 may leave an APE lock.
- Fix hwcfg4 isn't printed correctly.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some PCIe devices.
 1.200.2.4 07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:

sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6

Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
 1.200.2.3 17-Nov-2013  bouyer Apply patch, requested by msaitoh in ticket #983:
sys/dev/mii/brgphy.c 1.68 via patch
sys/dev/pci/if_bge.c 1.260-1.262 via patch
sys/dev/pci/if_bgereg.h 1.85-1.86 via patch
sys/dev/pci/if_bgevar.h 1.17 via patch

Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
For PCI-X BCM5704, set maximum outstanding split transactions to 0.
Same as Linux tg3 and FreeBSD (part of FreeBSD r204978).
Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD
(part of r199670). This workaround is for 5714/5715 controllers and
is not actually a MAC controller bug but an issue with the embedded
PCIe to PCI-X bridge in the device. This change
uses bus_dmatag_subregion(), so this workaround won't work on some
archs which doesn't support bus_dmatag_subregion().
 1.200.2.2 07-Sep-2013  bouyer sys/dev/pci/if_bge.c 1.203-1.237, 1.239-1.241, 1.243-1.258 via patch
sys/dev/pci/if_bgereg.h 1.58-1.74, 1.76-1.83 via patch
sys/dev/pci/if_bgevar.h 1.10-1.16 via patch
sys/dev/pci/pcidevs 1.1149 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/brgphy.c 1.61-1.63, 1.65, 1.67 via patch
sys/dev/mii/miivar.h 1.61 via patch
sys/dev/mii/miidevs 1.112-1.113 via patch
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/bge.4 1.13-1.15 via patch

Add some device support, fix a lot of bugs and add some enahcements.
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F,
BCM5785G, BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- brgphy(4): Add BCM5756, BCM5717C, BCM5719C, BCM5720C and BCM57780.
- Add some bugfixes and enhancement from FreeBSD:
- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Sync with *BSD. No functional change:
- make bge_chipid() and use it.
- use switch() instead of a lot of if()s.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the
capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking. FreeBSD has the same delay().
- Rename PHY related flags for the consistency. It's the same as
FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT
flag to not to check Gigabit flags. It's the same as FreeBSD.
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this commit,
only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK calls MI
mii_phy_auto(). That was not intended.
- Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that
do not have jumbo support
- Wait for the bootcode to complete initialization for 5717 and newer
devices. See BCM5718 programmer's guide's "step 13,
Device reset Procedure, Section7".
57781's document has the same note.
- 5718 and 57785 document say we should wait 100us.
- Change the order of register settings a little to match both
Broadcom's document and Linux tg3.
- Add detach function.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix a bug that the NVRAM lock timeout occured on sparc64 onboard bge.
- Check BGE_SGDIG_STS when the chip is NOT a 5717 A0, like freebsd
(OpenBSD rev. 1.327).
- Fix the setting of Tx Random Backoff Register.
- Add BGE_PCIMISCCTL_PCISTATE_RW in BGE_INIT. It's required to set the
PCISTATE register correctly.
- Update comments from 57XX-PG105-R.pdf and 5718-PG106-R.pdf.
- Add missing bus_dmamap_sync() in bge_intr(). The status word is
in DMAed area. Same as other *BSDs.
- Check the hardware config words and print them. This change only
read them and print the values.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind().
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT.
Same as OpenBSD's if_bge.c rev. 1.86.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
- Set DMA watermark depend on the PCI max payload size.
- Add BGE_JUMBO_CAPABLE flag to some chips. With this commit, 5714,
5780, 5717, 5718, 5719 (exclude rev. A0), 5720, 57765 and 57766 are
added to support jumbo frame.
- Fix the setting of sc->bge_flags for 5717 and newer devices.
- Fix a link detect bug on non-autopoll systems. Same as OpenBSD
(rev.1.329 and 1.336) and FreeBSD (r213710).
- 57765 series is not based on 5717 series. 5717 series is based on
57765 series.
- Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
- Change sysctl related functions for consistency.
- Style change.
- Use macro. Remove duplicated macro. Remove unused variable.
- Fix comments. Add comments.
- Remove extra semicolon. Remove unused code.
[msaitoh, ticket #939]
 1.200.2.1 26-Aug-2013  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #652):
sys/dev/mii/brgphy.c 1.60
sys/dev/pci/if_bge.c 1.202
sys/dev/pci/if_bgereg.h 1.57
Add support for BCM57762 and BCM57765, found in Apple's Thunderbolt
to Gigabit Ethernet adapter. PR kern/46961.
 1.201.2.5 03-Dec-2017  jdolecek update from HEAD
 1.201.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.201.2.3 23-Jun-2013  tls resync from head
 1.201.2.2 25-Feb-2013  tls resync with head
 1.201.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.253.2.2 18-May-2014  rmind sync with head
 1.253.2.1 28-Aug-2013  rmind sync with head
 1.266.2.2 10-Aug-2014  tls Rebase.
 1.266.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.277.4.10 28-Aug-2017  skrll Sync with HEAD
 1.277.4.9 05-Feb-2017  skrll Sync with HEAD
 1.277.4.8 05-Oct-2016  skrll Sync with HEAD
 1.277.4.7 09-Jul-2016  skrll Sync with HEAD
 1.277.4.6 29-May-2016  skrll Sync with HEAD
 1.277.4.5 19-Mar-2016  skrll Sync with HEAD
 1.277.4.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.277.4.3 22-Sep-2015  skrll Sync with HEAD
 1.277.4.2 06-Jun-2015  skrll Sync with HEAD
 1.277.4.1 06-Apr-2015  skrll Sync with HEAD
 1.277.2.3 30-Jul-2015  martin Pull up following revision(s) (requested by maxv in ticket #889):
sys/dev/pci/if_bge.c: revision 1.283
sys/dev/pci/if_pcn.c: revision 1.60
Fix mbuf leaks in error branches (found by the Brainy code scanner)
 1.277.2.2 09-May-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #740):
sys/dev/pci/if_bge.c: revision 1.285
sys/dev/pci/if_bgereg.h: revision 1.90
Use another firmware command in bge_asf_driver_up(). Same as Lunux.
This change fixes a bug that watchdog timeout occurs every 25-30 minutes
on HP ML110 G6 reported enami@ in PR#49657.
 1.277.2.1 17-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #526):
sys/dev/pci/if_bge.c: revision 1.278
Fix three bugs reported by enami@:
- bge_miibus_writereg(): Fix a bug that BCM5906 may leave an APE lock.
- Fix hwcfg4 isn't printed correctly.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some PCIe devices.
 1.298.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.298.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.300.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.309.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.310.2.8 05-Dec-2019  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1462):
sys/dev/pci/if_bge.c: revision 1.340
sys/dev/pci/if_bge.c: revision 1.341
sys/dev/pci/if_bge.c: revision 1.336
- Avoid undefined behavior in bge_setmulti(). found by kUBSan.
- Avoid undefined behavior when setting the MAC address in bge_init().
found by kUBSan.
Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.
- Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.
 1.310.2.7 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.310.2.6 07-Apr-2019  martin Pull up following revision(s) (requested by bouyer in ticket #1228):

sys/dev/pci/if_bge.c: revision 1.328

Fix ASIC check, BGE_ASICREV(sc->bge_chipid) is not a chipid.

Fixes bogus input error reporting in stat. This is cosmetic, exept for
routed(8) which thinks that the interface is broken and stops accepting routes
from it.
 1.310.2.5 07-Mar-2019  martin Pull up the following, requested by msaitoh in ticket #1209:

sys/dev/pci/if_bge.c 1.323-1.327
sys/dev/pci/if_bgereg.h 1.95
sys/dev/mii/brgphy.c 1.80
share/man/man4/bge.4 1.16

- Add BCM5717's another device ID support.
- Add BCM5702FE, another BCM5704S and SysKonnect SK-9Mxx support.
- Add support for BCM5762 ASIC devices.
- Add BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787.
- Simplify PCI device table.
- Add /* FALLTHROUGH */
 1.310.2.4 08-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1130):

sys/dev/pci/if_bge.c: revision 1.320
sys/dev/pci/if_bgevar.h: revision 1.24
sys/dev/pci/if_bge.c: revision 1.317
sys/dev/pci/if_bgereg.h: revision 1.94

More TSO4 fixes, from the freebsd driver:
- the chip doens't want the lenght of options, but the complete lenght of
ip headers (ip + tcp + options). Fix this for the BGE_IS_5717_PLUS()
and BGE_IS_5705_PLUS() cases; FreeBSD doens't cover the last case so
leave it as is for now. This fixes checksum failures for heavy transfers.
- It looks like the transmit engine hangs if the TCP segment crosses a 4GB
boundary. FreeBSD fixes it by mapping everything below 4GB; instead
try detect when this happens and do the bounce only when needed.

With these fixes I could transfers 3GB images over ftp at gigabit speed
(112MB/s with wget) without problems. Tested on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0

-

Don't destroy the dma maps if we're not disabling the adapter, avoids
a KASSERT() when bus_dmamap_destroy() is called from interrupt
context via bge_watchdog()

Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage.
Otherwise we may set IFF_OACTIVE while no transmit is in progress, and
nothing will clear it.

If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry.
Refine the check for the 4GB boundary workaround (a fragment should also
not cross the boundary), and do it only for TSO.

If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet.

Bring in more hardware bug workarounds from freebsd.

With these it seems that a BCM5720 A0 can survive a few hours of internet
load with TSO4 enabled.
 1.310.2.3 26-Nov-2018  snj Pull up following revision(s) (requested by bouyer in ticket #1107):
sys/dev/pci/if_bge.c: revision 1.316
5717 and newer handle TSO in a sighly different way. From FreeBSD.
While there, use different lowat/hiwat values if MTU is larger than ETHERMTU,
from FreeBSD.
Tested at LIP6 on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0
with all ipv4 checksums and TSO4 enabled.
 1.310.2.2 24-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #389):
sys/net/if_ether.h: revision 1.69
sys/net/if_vlan.c: revision 1.108
sys/dev/pci/if_bge.c: revision 1.313
sys/net/if_vlanvar.h: revision 1.11
sys/net/if_vlanvar.h: revision 1.12
sys/net/if_ether.h: revision 1.70
sys/net/if_vlan.c: revision 1.110
sys/dev/pci/if_wm.c: revision 1.544
sys/dev/pci/if_wmreg.h: revision 1.105
Fix a bug that a vlan packet which has priority or CFI bit in the tag causes
panic.
Revert part of if_bge.c 1.312. It's not required to mask other than VLAN ID
bits in VLAN tag.
Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
No functional change:
- u_int16_t -> uint16_t
- u_short -> uint16_t
- tag_hash_func -> vlan_tag_hash
- 0 -> NULL because vlr_parent is a pointer.
 1.310.2.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.313.2.6 26-Jan-2019  pgoyette Sync with HEAD
 1.313.2.5 18-Jan-2019  pgoyette Synch with HEAD
 1.313.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.313.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.313.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.313.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.314.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.314.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.314.2.1 10-Jun-2019  christos Sync with HEAD
 1.335.2.2 19-May-2022  martin Pull up following revision(s) (requested by buhrow in ticket #1456):

sys/dev/pci/if_bge.c: revision 1.353

For chips which contain an ASF/IPMI firmware, instruct the chip to shut
the host ASF firmware down when attaching the device so the IPMI BMC
can use the same physical port even when NetBSD doesn't have a
network configuration on the device.
By contrast, when the device gets a network configuration assigned to
it and bge_init() is called, the host ASF firmware is brought up so
both NetBSD and the IPMI BMc can use the same physical port.

This now matches FreeBSD behavior, as well as behavior from NetBSD-5.2.

Tested on a Sunfire X2200-M2 system with the following chip:

bge1 at pci7 dev 4 function 1: Broadcom BCM5715 Gigabit Ethernet
bge1: interrupting at ioapic0 pin 11
bge1: HW config 000000d4, 00000014, 00000000, 00000000 00000000
bge1: ASIC BCM5715 A3 (0x9003), Ethernet address 00:1e:68:XX:XX:XX
bge1: setting short Tx thresholds
brgphy1 at bge1 phy 1: BCM5714 1000BASE-T/X media interface, rev. 0
brgphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 1.335.2.1 27-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #487):

sys/dev/pci/if_bge.c: revision 1.340
sys/dev/pci/if_bge.c: revision 1.341
sys/dev/pci/if_bge.c: revision 1.342
sys/dev/pci/if_bge.c: revision 1.336

- Avoid undefined behavior in bge_setmulti(). found by kUBSan.
- Avoid undefined behavior when setting the MAC address in bge_init().
found by kUBSan.

Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.

- Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.

Modify PHY initialization code. This change fix a bug that SK-9D21 doesn't
detect MII PHY.
- Add error check to bge_miibus_writereg().
- Change return value of bge_miibus_readreg() when a read error occurred.
It also add error message using with aprint_debug_dev(). This error occurs
on some devices while detecting MII devices.
- Move the location of BGE_MI_MODE register's initialization to next to
bge_chipinit().
- Set BGE_MAC_MODE before calling ifmedia_init() and/or mii_attach().
- Add retry code for mii_attach() failed. Same as FreeBSD.
 1.342.2.1 29-Feb-2020  ad Sync with head.
 1.388.2.1 13-Oct-2024  martin Pull up following revision(s) (requested by skrll in ticket #968):

sys/dev/pci/if_bgevar.h: revision 1.41
sys/dev/pci/if_bgevar.h: revision 1.42
sys/dev/pci/if_bge.c: revision 1.394

s/jumo/jumbo/ in comments.

Apply changes from PR/58584 after testing (and fixing).
Tested on an Apple M1.
 1.392.2.1 02-Aug-2025  perseant Sync with HEAD
 1.98 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.97 02-Jul-2022  skrll Use C99 types. same code before and after.
 1.96 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.95 20-Feb-2019  msaitoh - Add support for BCM5762 ASIC devices.
- Add BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787.
 1.94 02-Dec-2018  bouyer Don't destroy the dma maps if we're not disabling the adapter, avoids
a KASSERT() when bus_dmamap_destroy() is called from interrupt
context via bge_watchdog()
Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage.
Otherwise we may set IFF_OACTIVE while no transmit is in progress, and
nothing will clear it.
If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry.
Refine the check for the 4GB boundary workaround (a fragment should also
not cross the boundary), and do it only for TSO.
If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet.
Bring in more hardware bug workarounds from freebsd.

With these it seems that a BCM5720 A0 can survive a few hours of internet
load with TSO4 enabled.
 1.93 13-Apr-2017  msaitoh branches: 1.93.4; 1.93.10; 1.93.12;
- Read chip ID correctly on BCM57782 and BCM57786.
- Add BXCM57766 A0 string.
- Add comment for BCM5776[56]'s workaround.
 1.92 12-Apr-2017  msaitoh Add a workaround for BCM57780 to prevent device timeout. This change prevent
L1PM feature do wrongy. Tested with Dell latitude 2120.
 1.91 17-May-2015  msaitoh branches: 1.91.2; 1.91.4;
- Add MSI support.
- Use tagged status function for 5717 and newer devices. All controllers
except BCM5700 support tagged status but we use tagged status only for MSI
case on BCM5717. Otherwise MSI on BCM5717 does not work. Same as other *BSDs.
 1.90 30-Apr-2015  msaitoh Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30 minutes
on HP ML110 G6 reported enami@ in PR#49657.
 1.89 30-Apr-2015  msaitoh - BGE_CHIPID_BCM5784_A1 is not 0x5784100 but 0x5784001. Only dmesg output
is affected.
- Add BGE_CHIPREV_5784_AX and BGE_CHIPID_BCM5784_B0.
 1.88 17-Jun-2014  msaitoh branches: 1.88.2; 1.88.4;
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5) for
BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
 1.87 27-May-2014  msaitoh Fix typo in a comment.
 1.86 31-Oct-2013  msaitoh branches: 1.86.2;
Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD (part of r199670).
This workaround is for 5714/5715 controllers and is not actually a MAC
controller bug but an issue with the embedded PCIe to PCI-X bridge in the
device.
This change uses bus_dmatag_subregion(), so this workaround won't work on some
archs which doesn't support bus_dmatag_subregion().
 1.85 31-Oct-2013  msaitoh Cleanup flag setting. No functional change.
- Split flags into bge_flags and bge_phy_flags.
- Rename flags. PHY related flags are prefixed with BGEPHYF_*.
Other flags are prefixed with BGEF_*.
 1.84 13-Jul-2013  msaitoh Fix the chip revision of 57765_AX.
 1.83 08-Jul-2013  msaitoh - Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
 1.82 08-Jul-2013  msaitoh 57765 series is not based on 5717 series. 5717 series is based on 57765
series.
 1.81 31-May-2013  msaitoh branches: 1.81.2;
Remove unused macros.
 1.80 30-May-2013  msaitoh 0x4B657654(BGE_SRAM_FW_MB_MAGIC) == ~0xB49A89AB(BGE_SRAM_FW_MB_RESET_MAGIC),
so the same code I added in rev. 1.223 exists in bge_poll_fw(), too. Remove it.

And then, call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
 1.79 28-May-2013  msaitoh Fix a bug that the PHY address bits in MI_MODE register is wrongly cleard.
Set the PHY address correctly.
 1.78 14-May-2013  msaitoh Add some definitions.
Fix compile error.
 1.77 08-May-2013  msaitoh No functional change:
- Fix typo
- Add comment
- Remove duplicated definitions
 1.76 08-May-2013  msaitoh Check the hardware config words and print them. This change only read them
and print the values.
 1.75 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.74 11-Apr-2013  msaitoh Fix typo in comment.
 1.73 11-Apr-2013  msaitoh Add BGE_PCIMISCCTL_PCISTATE_RW in BGE_INIT. It's required to set the PCISTATE
register correctly.
 1.72 08-Apr-2013  msaitoh Fix the setting of Tx Random Backoff Register.
 1.71 27-Mar-2013  msaitoh Add BGE_SRAM_FW_MB_RESET_MAGIC again.
 1.70 27-Mar-2013  msaitoh Revert rev. 1.68.
 1.69 27-Mar-2013  msaitoh Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
 1.68 21-Mar-2013  msaitoh Wait for the bootcode to complete initialization for 5717 and newer devices.
See BCM5718 programmer's guide's "step 13, Device reset Procedure, Section 7".
57781's document has the same note.

I verified the loop really looped on those chips.

But, I don't know why tg3 doesn't it.
 1.67 21-Mar-2013  msaitoh - Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that do not
have jumbo support
- Add/sync some of the comments
- Use macro.
- Remove unused code.
 1.66 19-Mar-2013  msaitoh - Rename PHY related flags for the consistency. It's the same as FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT flag to
not to check Gigabit flags. It's the same as FreeBSD.
 1.65 19-Mar-2013  msaitoh Fix three bugs:
- An workaround for TX data corruption is only for 5719 "A0".
Fix the wrong evaluation.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link checking.
FreeBSD has the same delay().
 1.64 17-Mar-2013  msaitoh No functional change:
- Fix comment
- Use macro
- Remove unused macro
 1.63 17-Mar-2013  msaitoh - ADD support for BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Use macros.
- Remove unused code.
- Sync with the latest {Free,Open}BSD's bge.
 1.62 13-Mar-2013  msaitoh - Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Use macro.
 1.61 27-Feb-2013  msaitoh No functional change:
- Fix comments.
- Change macro name.
- Change sysctl related functions for consistency.
 1.60 26-Feb-2013  msaitoh Add some bugfixes and enhancement from FreeBSD:

- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may cause
internal chip delays that may result in subsequent valid frames being
dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)

- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)

- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)

- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
 1.59 26-Feb-2013  msaitoh Use macro. Remove extra semicolon. No functional change.
 1.58 25-Feb-2013  msaitoh Use macro. Remove duplicated macro. Remove unused variable.
No functional Change.
 1.57 17-Sep-2012  tsutsui Add support for BCM57762, found in Apple's Thunderbolt to Gigabit Ethernet
Adapter. PR kern/46961 from Ryo ONODERA.

Also revert weird BGE_MAX_FRAMELEN macro definition to sync its usage
with the original FreeBSD's bge.
 1.56 03-Feb-2010  msaitoh branches: 1.56.12; 1.56.18; 1.56.22;
- Make the initialize sequence close to the document.
- Fix ASF heartbeat sending bug (FreeBSD rev. 1.271 (r202821))
- Use new handshake command for BCM5750 or new controllers (FreeBSD rev. 1.272
(r202822))
 1.55 28-Jan-2010  msaitoh - Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- remove an unused structure.
- KNF
 1.54 24-Jan-2010  msaitoh Many changes from FreeBSD and OpenBSD:
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Many other bugfixes.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
 1.53 04-Aug-2009  taca Fix a bug of BGE_RDMA_MODE_FIFO_LONG_BURST definition.

Confirmed by msaito@.
 1.52 23-Apr-2009  msaitoh use proplib
 1.51 19-Apr-2009  msaitoh Some fixes and enhancements:

Both if_bge* and brgphy.[ch]:
Check the parent's MAC and use the quirk code for the bug like OpenBSD and
FreeBSD. Some bugs can't identify the PHY ID. For example, 5704 Ax has the
ADC bug, but 5704 A3 and 5704 B0 have the same PHY ID and revision. Add
BGE_PHY_CRC_BUG, BGE_PHY_ADC_BUG, BGE_PHY_5704_A0_BUG, BGE_PHY_JITTER_BUG,
BGE_PHY_ADJUST_TRIM and BGE_PHY_BER_BUG for this flag. Some of the DSP
patches are newly taken from OpenBSD and FreeBSD.

if_bge*:
Remove duplicated BGE_CHIPID_BCM5714_A0 entry in the known CHIPID table.
Fix obsolete comments.

brgphy.[ch]:
Add some PHY IDs.

TODO:
Add more three quirk code into bge and brgphy (the brgphy side's are
currently #if0'ed).
Add support for bnx into brgphy (currently #if0'ed)
 1.50 16-Apr-2009  msaitoh Take some code from FreeBSD and OpenBSD:

Fix some bugs that the driver unable to detect link loss (OpenBSD 1.135,
FreeBSD 1.102)

bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)

Acknowledge link change interrupts by setting the 'link changed' bit
in the status register (used to have no effect). FreeBSD 1.44 (OpenBSD 1.21)

Add some fiber support (OpenBSD 1.220)

Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.

Add special case code to fix a problem with the BCM5704 in TBI mode
(FreeBSD rev. 1.71, OpenBSD rev. 1.35)

Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD rev.
1.242)

Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev. 1.21)

Add some known CHIPID entries.
 1.49 22-Mar-2009  msaitoh Make bge(4) close to FreBSD and OpenBSD.

NO FUNCTIONAL CHANGE BY THIS COMMIT.
 1.48 25-Aug-2008  cegger branches: 1.48.2; 1.48.4; 1.48.8; 1.48.12;
PR 39241: Add support for Broadcom BCM5906(M) from Karl Uwe Lockhoff
 1.47 24-Jul-2008  sborrill Add support for Broadcom 5722 and identify 5755 ASICs.
 1.46 17-Jun-2008  mlelstv branches: 1.46.2;
add rnd(4) hooks. Note that interrupts on bge hardware may occur
with certain patterns, especially when the interrupt mitigation
logic kicks in. So this might be a very weak entropy source.
 1.45 09-Dec-2007  jmcneill branches: 1.45.10; 1.45.12; 1.45.14; 1.45.16; 1.45.18;
Merge jmcneill-pm branch.
 1.44 24-Sep-2007  joerg branches: 1.44.6; 1.44.8;
Convert bge(4) to device/softc separation. Use aprint_* instead of
printf all over the place. Only the debug macros are kept. Place the TSO
message about the hard case under debug.
 1.43 06-Aug-2007  markd branches: 1.43.2; 1.43.4; 1.43.6;
Add a couple more BGE_CHIPIDs
 1.42 18-May-2007  pavel branches: 1.42.2; 1.42.6;
from FreeBSD's src/sys/dev/bge/if_bgereg.h rev 1.22:
Fix a typo. BGE_HCC_TX_MAX_COAL_BDS_INT is at offset 0x3C24, not 0x3C34
Noticed by Patrick Welche on tech-kern@, ok cube.
 1.41 04-Mar-2007  christos branches: 1.41.2; 1.41.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.40 17-Feb-2007  bouyer bus_dma fixes for bge(4). It now works on amd64 with more than 4GB physical
RAM (jumbo frames untested yet).
 1.39 26-Nov-2006  tsutsui branches: 1.39.2; 1.39.4;
Revert a CHIPID entry in the previous:
In OpenBSD's if_bgereg.h, CHIPID 0x4101000 is defined as BCM5750_B1
but our PR kern/31028 says it's BCM5751_A1 on BCM5751M on IBM T43p,
and the value seems reasonable.
 1.38 26-Nov-2006  tsutsui Add and fix some BGE_CHIPIDs. From FreeBSD and OpenBSD.
 1.37 26-Nov-2006  tsutsui TAB/space cleanup.
 1.36 26-Nov-2006  tsutsui Add support for BCM5752M. from Matt Kolb on tech-kern and OpenBSD.
 1.35 26-Nov-2006  tsutsui make DMA descriptor members volatile.
 1.34 18-Apr-2006  christos branches: 1.34.8; 1.34.10;
PR/33828: Pawel Chwalowski: Add support for Broadcom BCM5789 chip
 1.33 16-Feb-2006  perry branches: 1.33.2; 1.33.4; 1.33.6;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.32 24-Dec-2005  perry branches: 1.32.2; 1.32.4; 1.32.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.31 12-Dec-2005  jonathan Add support for bcm5714 and (possibly incorrect) support for the
bcm5715 PCI-Express dual-port NICs. Taken from the Broadcom-supplied
Linux driver, bcm-8.3.13a.

Add nascent support for the bcm5780, but (since I have no bcm5780 to
test), don't yet add an entry which allows us to match or attach to a
5780.

Change 5752 support: Follow the lead of the Broadcom-supplied Linux
driver (bcm) and the Linux tg3 driver, and treat the 5752 like a 5750.
 1.30 07-Dec-2005  jonathan Add PCI device-ids to sys/dev/pci/pcidevs for newer Broadcom gigabit
ethernet devices: bcm5714, bcm5752 (previously the 5789, but fvdl
committed that whilst I was musing).

Add definitions to sys/dev/pci/if_bgereg.h for the Broadcom 57xx-family
ASIC revisions on these newer chips.

Add entries to the PCI-device-version and bge-internal-asic-revision
tables in sys/dev/pci/if_bge.c to use these new devices. Pending
further information, follow the lead of FreeBSD's if_bge.c driver and,
pending further info, treat these new chips as we do the 5750.
 1.29 25-Nov-2005  tsutsui Remove unnecessary byteswap code so that bge(4) should work
at least on macppc.
 1.28 24-Nov-2005  jonathan Add TSO support to bge(4) for PCI-Express bge devices, which are
shipped from the factory with TSO-capable firmware. The TSO support
here may also work on 5705 chips, but that is (so far) untested.

TSO support written after careful reading of the Linux tg3 driver,
and (after attempting to deconstruct the cut-and-paste mess therein)
very close reading of the Broadcom-supplied Linux driver, particularly
the building of Tx-DMA buffer descriptors (bds). The TSO code herein was
then rewritten from scratch, circa 4am local time, October 27 2005.
(In other words: this is 4am software; caveat emptor.)

Other magic register settings in this patch are required; without
them, attepmting to use TSO locks up the chip. The required register
settings were extracted from the cited Linux drivers.

Note that TSO-capable firmware for the 5703/5704 is distributed in
non-GPL form with the aforementioned Linux drivers. Once the 5705 case
is debugged, (particularly the pseudo-header checksum precalculation
flagged with an XXX) downloading that TSO-capable firmware to the
5703/5704 should, in principle, enable TSO support on all but the
original bcm5700 (I forget if the 5701 can support TSO, or not).

Note also that the ``hard case '' of IP/TCP headers spanning more than
one mbuf is not handled; I haven't been able to trigger it. In any
case, since TSO applies only to packets generated by the local TCP,
and our TCP always leaves space for TCP headers and a normal IP
header, TSO on an IP/TCP header spanning multiple headers can only
arise due to insertion of IP options. I beleive that we are clearly
better off outlawing that case, and requiring ip_insertoptions()
to pull-up TCP headers on any packets with M_CSUM_TSOv4 set.

As far as I know, bge hardwar does not support TSO for IPv6.
 1.27 15-Nov-2005  jonathan Correct a performance bug from Bill Paul's original FreeBSD bge(4) driver:

Each call to the FreeBSD bge_start() routine the transmit producer
pointer index from the chip mailbox register BGE_MBX_TX_HOST_PROD0_LO.
The local copy of that value is then updated by bge_encap() as
bge_encap() encapsulates packets in the Tx ring. If bge_encap()
succeds in encpuslating one or more packets, bge_start() tells the
chip to start sending the newly-encinitiates writes the new value back
to the chip mailbox register.

However, comparison of the Linux drivers (Broadcom-supplied and
open-source tg3.c) and to the OpenSolaris driver confirms that
register BGE_MBX_TX_HOST_PROD0_LO is write-only to software.
Thus, we can just keep a copy in the softc, and eliminate the
(expensive) PCI register write on each call to bge_start().

``Make it so''.
 1.26 28-Aug-2005  thorpej branches: 1.26.6;
Remove unused and incorrect macro BGE_HOSTADDR().
 1.25 22-Aug-2005  gavan Add quirk for BGE_CHIPID_BCM5751_A1. From Kurt Schreiner <ks at ub.uni-mainz
dot de> via PR kern/31028.
 1.24 27-Feb-2005  perry branches: 1.24.2; 1.24.4;
nuke trailing whitespace
 1.23 26-Jan-2005  jmcneill Add powerhook to bge(4)
 1.22 28-Oct-2004  cube branches: 1.22.4; 1.22.6;
Add support for the BCM575x variants. They're close to the 5705 one, with
some special cases for the PCI-Express versions. As there is no
documentation available, all of this is inspired from Linux or taken from
FreeBSD (itself inspired from Linux). There are a lot of magic numbers.

Tested on two BCM5751 devices as found in newer Dell computers.
 1.21 15-May-2004  thorpej Add PAUSE-related event counters. Slightly modified from patch supplied by
HITOSHI Osada.
 1.20 15-May-2004  thorpej Patches from HITOSHI Osada:
* Set buffer management high water marks for MTU > 1514.
* Set BGE_MAX_RX_FRAME_LOWAT (from Linux driver).
 1.19 10-Apr-2004  thorpej Add 802.3x flow control support. From HITOSHI Osada.
 1.18 20-Mar-2004  jonathan branches: 1.18.4;
Possibloe fix for some bge chip revisions taking a long time to reset
(e.g., polling for a half-second or more at splnet(), blocking most
interrupts, durin an ifconfig down/ifconfig up).

Appears to help for a 5704C rev A3, which is the only chip I've
ever seen that had even a mild version of the reported problem.
 1.17 22-Jan-2004  jonathan Add hooks to dynamically change the bge Rx interrupt thresholds. I
found empiricaly that (at least on bcm5700s) the Rx coalesce and bd
counts cannot be updated on-the-fly; attempting to do so (even at
splhigh()) causes weird behaviour.

Instead, add a softc flag to record that the desired softc values for
Rx-interrupt thresholds have changed; check that boolean in the interrupt
routine. If set, apply the new values there and clear the flag.
 1.16 22-Jan-2004  jonathan Add some extra register definitions from FreeBSD and Linux:
BGE_MISC_TIMER register definition, and more bit definitions for
HCC-mode. (I would credit individuals, but the attributions are buried
deep in my own tree.)
 1.15 08-Dec-2003  pooka Match 5703 ASIC A3.

Also, when printing the ASIC ID, print the revision in hex in all
cases to avoid extra confusion if only the "superclass" of the ASIC
is recognized.
 1.14 02-Nov-2003  wiz boundary, not boundry. Inspired by Tom Cosgrove.
 1.13 23-Oct-2003  fvdl * match more cards (from FreeBSD)
* don't set the NOCRC bit in the mode control register, it can cause
problems on some chips (from the broadcom errata via FreeBSD)
* implement a fallback quirktable that is searched only using the
major asic revision, so that the driver has a shot at supporting
newer versions properly without modification
* rename asicrev -> chipid, like the FreeBSD driver
 1.12 27-Aug-2003  fvdl Support the BCM5704C rev 3. From Nicolas Joly, PR 22620
 1.11 17-Jul-2003  hannken Add support for the BCM5705:
- Only BCM5705M asic rev A1 was tested.

Thanks to Bill Paul (wpaul@freebsd.org) for help and support.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.10 01-Jun-2003  fvdl branches: 1.10.2;
Add newer 5704 asic revs, and add them to the table, with the
BGE_QUIRK_ONLY_PHY_1 quirk in their entry.
 1.9 07-Mar-2003  jonathan Commit workaround for hardware bug: 5701 chips running in PCI-X mode
require that the DMA receive buffers be aligned. The driver was
deliberately mis-aligning by 2 bytes, to force the layer-2/3
headers to 32-bit alignment.

Workaround: if chip is a 5701, and is in PCI-X mode, leave the DMA
buffers aligned. If the host CPU requires alignment, copy the buffer
after reception to force aligment.

Tested on an i386 in PCI-X bus, with __NO_STRICT_ALIGNMENT forced off.

Patch and comments reworked to minimize drift from
FreeBSD if_bge.c rev 1.14.
 1.8 06-Mar-2003  jonathan Commit the FreeBSD alternative of a private patch to check NIC internal
ram for using TBI, versus MII/GMII.

FreeBSD commit log and versions:
Obtain the media type from the shared memory and only use the eeprom
as a fallback.

if_bge.c: rev 1.30
if_bgereg.h: rev 1.13

Thanks to Paul Saab @mu.org.
 1.7 06-Mar-2003  jonathan FreeBSD fix for problems reported (to FreeBSD) with 16-bit accesses
to 32-bit device registers. Add (untested) NetBSD fix for big-endian hosts.
From FreeBSD versions:
if_bge.c: 1.26 and 1.27
if_bgereg.h: 1.12

FreeBSD (MFC) comment:

MFC: Avoid 16-bit accesses to device memory. Use volatile where
appropriate in referencing device memory. Parenthesize BGE_HOSTADDR
define properly.
 1.6 17-Jan-2003  fvdl branches: 1.6.2;
Add local_ctl_reg field to softc.
 1.5 17-Jan-2003  jonathan Add register definitions for 5704 internal ASIC revision.
Add cpp definitions for the DMA control register fields needed for
5703/5704 configuration on PCI-X.
Add softc copy of internal"local control" register clobbered by reset.
 1.4 13-Jul-2002  thorpej branches: 1.4.2; 1.4.4; 1.4.6;
Give BCM5700 Ax and Bx revs the BGE_QUIRK_LINK_STATE_BROKEN quirk,
and test for that, rather than checking revision where the quirk is
handled.
 1.3 13-Jul-2002  thorpej Add a lookup table with ASIC revision, name, and any quirks. Print
ASIC revision at attach time. Add BCM5703 revisions.
 1.2 24-Jun-2002  fvdl Add a few revision definitions.
 1.1 22-Jun-2002  fvdl Driver for Broadcom 570x / Altima AC 1000 gigabit ethernet cards.
Written by Bill Paul for FreeBSD. This port started out with the
port done to OpenBSD by nate@openbsd.org, but ended up looking much
more like the port of the ti driver done by drochner@netbsd.org
(they are similar in structure).
 1.4.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.6.1 13-Jul-2002  jdolecek file if_bgereg.h was added on branch kqueue on 2002-09-06 08:45:14 +0000
 1.4.4.3 17-Jan-2003  thorpej Sync with HEAD.
 1.4.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.4.4.1 13-Jul-2002  nathanw file if_bgereg.h was added on branch nathanw_sa on 2002-08-01 02:45:14 +0000
 1.4.2.2 15-Jul-2002  gehenna catch up with -current.
 1.4.2.1 13-Jul-2002  gehenna file if_bgereg.h was added on branch gehenna-devsw on 2002-07-15 10:35:36 +0000
 1.6.2.4 16-Jun-2003  grant Pull up revision 1.8 (requested by tron in ticket #1250):

Commit the FreeBSD alternative of a private patch to check NIC internal
ram for using TBI, versus MII/GMII.

FreeBSD commit log and versions:
Obtain the media type from the shared memory and only use the eeprom
as a fallback.

if_bge.c: rev 1.30
if_bgereg.h: rev 1.13

Thanks to Paul Saab @mu.org.
 1.6.2.3 16-Jun-2003  grant Pull up revision 1.7 (requested by tron in ticket #1249):

FreeBSD fix for problems reported (to FreeBSD) with 16-bit accesses
to 32-bit device registers. Add (untested) NetBSD fix for big-endian hosts.
From FreeBSD versions:
if_bge.c: 1.26 and 1.27
if_bgereg.h: 1.12

FreeBSD (MFC) comment:

MFC: Avoid 16-bit accesses to device memory. Use volatile where
appropriate in referencing device memory. Parenthesize BGE_HOSTADDR
define properly.
 1.6.2.2 28-Jan-2003  jmc Pullup from -current (lots of revisions 1.1-1.6
(requested by fvdl in ticket #1126)
Pullup support for bge device. (Broadcom Gigabit Ethernet)
 1.6.2.1 17-Jan-2003  jmc file if_bgereg.h was added on branch netbsd-1-6 on 2003-01-28 06:20:12 +0000
 1.10.2.8 11-Dec-2005  christos Sync with head.
 1.10.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.10.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.4.1 01-Dec-2005  riz Pull up following revision(s) (requested by tsutsui in ticket #10169):
sys/dev/pci/if_bgereg.h: revision 1.29
Remove unnecessary byteswap code so that bge(4) should work
at least on macppc.
 1.22.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.6.1 12-Feb-2005  yamt sync with head.
 1.22.4.1 29-Apr-2005  kent sync with -current
 1.24.4.6 21-Jan-2008  yamt sync with head
 1.24.4.5 27-Oct-2007  yamt sync with head.
 1.24.4.4 03-Sep-2007  yamt sync with head.
 1.24.4.3 26-Feb-2007  yamt sync with head.
 1.24.4.2 30-Dec-2006  yamt sync with head.
 1.24.4.1 21-Jun-2006  yamt sync with head.
 1.24.2.6 19-Nov-2007  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1862):
sys/dev/pci/if_bge.c 1.89,1.95,1.97,1.101,1.103,
1.105,1.107,1.117-1.122,
1.128-1.131,1.133-1.135,1.139
via patch
sys/dev/pci/if_bgereg.h 1.31,1.34-1.39,1.42-1.43
sys/dev/pci/pcidevs patch

Some cleanups(typo, whitespace, debug message).
Add TSO support to bge(4)
Add support for BCM5715, BCM5752M, BCM5754, BCM5755, BCM5786 and 5787.
Add support for BCM5789. Fixes PR/33828 from Pawel Chwalowskibg.
Add support for BCM5753 and BCM5753M Fixes PR kern/36139 from Mustafa Dogan.
Add and fix some BGE_CHIPIDs. From FreeBSD and OpenBSD.
In bge_ioctl(), don't call bge_init() if the interface is already up
(Makes ifwatchd work on this interface).
BCM5701 B2 requires BGE_QUIRK_ONLY_PHY_1 quirk. From Brian Baird in kern/23778.
Move TX ring full sanity check further up and check the number of DMA
segments from the DMA map, instead of counting the DMA segments in the
for loop and breaking out later.
Unload the DMA map if encountering an error condition.
Fix a NULL reference on failing mbuf allocation.
In bge_start return if IFF_OACTIVE is set in combination with
IFF_RUNNING, drop obscure check for length of interface queue.
Remove message about failing bge_encap, it can happen just too easily
because of full descriptor rings.
Fix some watchdog timeout and "block failed to stop" problems on
some cards.
Fix "pcistate failed to revert" problem on many cards.
 1.24.2.5 05-Mar-2007  ghen Pull up following revision(s) (requested by bouyer in ticket #1671):
sys/dev/pci/if_bgereg.h: revision 1.40
sys/dev/pci/if_bge.c: revision 1.124
sys/dev/pci/if_bge.c: revision 1.125
bus_dma fixes for bge(4). It now works on amd64 with more than 4GB physical
RAM (jumbo frames untested yet).
We have to bus_mapmap_load() after m_adj, otherwise the map will point at
the wrong place in the buffer. Fix an issue in the !sc->bge_rx_alignment_bug
case reported by Nicolas Joly.
While there remove a duplicate m_adj(), and add a missing bus_dmamap_unload().
 1.24.2.4 04-Jun-2006  tron Apply patch (requested by jonathan in ticket #1351):
Add support to bge(4) for bcm5714, bcm5715, bcm5780/HT-2000 and
bcm5752 chip variants.
 1.24.2.3 27-Nov-2005  riz Pull up following revision(s) (requested by tsutsui in ticket #1004):
sys/dev/pci/if_bgereg.h: revision 1.29
Remove unnecessary byteswap code so that bge(4) should work
at least on macppc.
 1.24.2.2 22-Nov-2005  tron Pull up following revision(s) (requested by jonathan in ticket #985):
sys/dev/pci/if_bgereg.h: revision 1.27
sys/dev/pci/if_bge.c: revision 1.94
Correct a performance bug from Bill Paul's original FreeBSD bge(4) driver:
Each call to the FreeBSD bge_start() routine the transmit producer
pointer index from the chip mailbox register BGE_MBX_TX_HOST_PROD0_LO.
The local copy of that value is then updated by bge_encap() as
bge_encap() encapsulates packets in the Tx ring. If bge_encap()
succeds in encpuslating one or more packets, bge_start() tells the
chip to start sending the newly-encinitiates writes the new value back
to the chip mailbox register.
However, comparison of the Linux drivers (Broadcom-supplied and
open-source tg3.c) and to the OpenSolaris driver confirms that
register BGE_MBX_TX_HOST_PROD0_LO is write-only to software.
Thus, we can just keep a copy in the softc, and eliminate the
(expensive) PCI register write on each call to bge_start().
``Make it so''.
 1.24.2.1 08-Sep-2005  tron Pull up following revision(s) (requested by gavan in ticket #752):
sys/dev/pci/if_bgereg.h: revision 1.25
sys/dev/pci/if_bge.c: revision 1.92
Add quirk for BGE_CHIPID_BCM5751_A1. From Kurt Schreiner <ks at ub.uni-mainz
dot de> via PR kern/31028.
 1.26.6.2 29-Nov-2005  yamt sync with head.
 1.26.6.1 22-Nov-2005  yamt sync with head.
 1.32.6.1 22-Apr-2006  simonb Sync with head.
 1.32.4.1 09-Sep-2006  rpaulo sync with head
 1.32.2.1 18-Feb-2006  yamt sync with head.
 1.33.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.33.4.1 19-Apr-2006  elad sync with head.
 1.33.2.1 24-May-2006  yamt sync with head.
 1.34.10.1 10-Dec-2006  yamt sync with head.
 1.34.8.1 12-Jan-2007  ad Sync with head.
 1.39.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.39.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.39.2.5 18-Aug-2009  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1342):
sys/dev/pci/if_bge.c: revisions 1.135, 1.146, 1.151-1.152,
1.155-1.167 via patch
sys/dev/pci/if_bgereg.h: revisions 1.43, 1.48-1.52
sys/dev/pci/if_bgevar.h: revision 1.1
sys/dev/mii/brgphy.c: revisions 1.36, 1.40, 1.43-1.44 and
1.47-1.48 via patch
sys/dev/mii/brgphyreg.h: revisions 1.3-1.4
sys/dev/mii/miidevs: revisions 1.75, 1.77, 1.85
sys/dev/mii/miidevs.h: regen
sys/dev/mii/miidevs_data.h: regen
sys/dev/mii/miivar.h: revision 1.54
For bge:
- Really set Tx threshold.
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the "link changed" bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
- Add BCM5786 support.
for brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2, BCM5708C, BCM5722, and BCM5906.
 1.39.2.4 20-Aug-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1172):
sys/dev/pci/if_bge.c: revision 1.149
sys/dev/pci/if_bgereg.h: revision 1.47
Add support for Broadcom 5722 and identify 5755 ASICs.
 1.39.2.3 31-Aug-2007  xtraeme Pull up following revision(s) (requested by phil in ticket #819):
sys/dev/mii/miidevs.h: regen
sys/dev/mii/miidevs: revision 1.71
sys/dev/pci/if_bge.c: revision 1.133
sys/dev/pci/if_bge.c: revision 1.134
sys/dev/pci/if_bgereg.h: revision 1.43
sys/dev/mii/brgphy.c: revision 1.34
sys/dev/mii/miidevs_data.h: regen
Add BCM5755 and 5754 Gig-E PHYs.
Regen for BCM5755 and 5754.
Add support for BCM5754 and BCM5755. From suggestions from Jonathan
Stone.
Add a couple more BGE_CHIPIDs
Add support for BCM5755 and BCM5754/5787. Suggestions from Jonathan
Stone and fixes from OpenBSD for various hardware bugs/errata.
Disable firmware fastboot on 5754 and 5755. From FreeBSD by way of Phil
Nelson.
 1.39.2.2 30-May-2007  riz Pull up following revision(s) (requested by pavel in ticket #671):
sys/dev/pci/if_bgereg.h: revision 1.42
from FreeBSD's src/sys/dev/bge/if_bgereg.h rev 1.22:
Fix a typo. BGE_HCC_TX_MAX_COAL_BDS_INT is at offset 0x3C24, not 0x3C34
Noticed by Patrick Welche on tech-kern@, ok cube.
 1.39.2.1 27-Feb-2007  riz branches: 1.39.2.1.2;
Pull up following revision(s) (requested by bouyer in ticket #466):
sys/dev/pci/if_bgereg.h: revision 1.40
sys/dev/pci/if_bge.c: revision 1.124-1.125
bus_dma fixes for bge(4). It now works on amd64 with more than 4GB physical
RAM (jumbo frames untested yet).
We have to bus_mapmap_load() after m_adj, otherwise the map will point at
the wrong place in the buffer. Fix an issue in the !sc->bge_rx_alignment_bug
case reported by Nicolas Joly.
While there remove a duplicate m_adj(), and add a missing bus_dmamap_unload().
 1.39.2.1.2.3 04-Sep-2008  skrll Sync with netbsd-4.
 1.39.2.1.2.2 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.39.2.1.2.1 04-Jun-2007  wrstuden Update to today's netbsd-4.
 1.41.4.1 11-Jul-2007  mjf Sync with head.
 1.41.2.3 09-Oct-2007  ad Sync with head.
 1.41.2.2 20-Aug-2007  ad Sync with HEAD.
 1.41.2.1 27-May-2007  ad Sync with head.
 1.42.6.4 02-Oct-2007  joerg Sync with HEAD.
 1.42.6.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.42.6.2 21-Aug-2007  joerg Make bge(4) a bit more like other drivers in the tree with regard to
the data stored in the softc. Convert to pnp_register.
 1.42.6.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.42.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.43.6.2 06-Aug-2007  markd Add a couple more BGE_CHIPIDs
 1.43.6.1 06-Aug-2007  markd file if_bgereg.h was added on branch matt-mips64 on 2007-08-06 12:23:09 +0000
 1.43.4.1 06-Oct-2007  yamt sync with head.
 1.43.2.2 09-Jan-2008  matt sync with HEAD
 1.43.2.1 06-Nov-2007  matt sync with HEAD
 1.44.8.1 11-Dec-2007  yamt sync with head.
 1.44.6.1 26-Dec-2007  ad Sync with head.
 1.45.18.2 28-Jul-2008  simonb Sync with head.
 1.45.18.1 18-Jun-2008  simonb Sync with head.
 1.45.16.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.45.16.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.45.14.3 11-Mar-2010  yamt sync with head
 1.45.14.2 19-Aug-2009  yamt sync with head.
 1.45.14.1 04-May-2009  yamt sync with head.
 1.45.12.1 17-Jun-2008  yamt sync with head.
 1.45.10.2 28-Sep-2008  mjf Sync with HEAD.
 1.45.10.1 29-Jun-2008  mjf Sync with HEAD.
 1.46.2.1 19-Oct-2008  haad Sync with HEAD.
 1.48.12.1 21-Apr-2010  matt sync to netbsd-5
 1.48.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.48.4.3 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.48.4.2 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1359):
sys/dev/pci/if_bge.c 1.170-1.181
sys/dev/pci/if_bgereg.h 1.53-1.56
sys/dev/pci/if_bgevar.h 1.2-1.5
sys/dev/pci/pcidevs 1.1017, 1.1021
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/miidevs 1.89, 1.93
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/dev/mii/brgphy.c 1.49, 1.52

- Fix a bug of BGE_RDMA_MODE_FIFO_LONG_BURST definition.
- Fix the bug that both BGE_PCIE and BGE_PCIX are set on PCI-Express devices.
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
- (brgphy(4)) Add support for BCM5461, BCM5464, BCM5784 and BCM5761.
- (brgphy(4)) Enable brgphy_jumbo_settings().
- (brgphy(4)) Enable the Ethernet@Wirespeed function.
- Add support for device properties to override the mac address and set
the BGE_NO_EEPROM flag if we have an onboard device w/o SEEPROM.
- Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- Fixes the bug that error bits arent cleard because these bit are W2C
(in other words W1C).
- Many other bugfixes from FreeBSD and OpenBSD.
- remove an unused structure.
- ANSI C, KNF and tabify
- fix typo in comment.
 1.48.4.1 04-Aug-2009  snj Apply patch (requested by msaitoh in ticket #866):
For bge:
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the 'link changed' bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
For brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2 and BCM5722.
 1.48.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.56.22.4 03-Dec-2017  jdolecek update from HEAD
 1.56.22.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56.22.2 23-Jun-2013  tls resync from head
 1.56.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.56.18.4 07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:

sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6

Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
 1.56.18.3 17-Nov-2013  bouyer Apply patch, requested by msaitoh in ticket #983:
sys/dev/mii/brgphy.c 1.68 via patch
sys/dev/pci/if_bge.c 1.260-1.262 via patch
sys/dev/pci/if_bgereg.h 1.85-1.86 via patch
sys/dev/pci/if_bgevar.h 1.17 via patch

Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
For PCI-X BCM5704, set maximum outstanding split transactions to 0.
Same as Linux tg3 and FreeBSD (part of FreeBSD r204978).
Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD
(part of r199670). This workaround is for 5714/5715 controllers and
is not actually a MAC controller bug but an issue with the embedded
PCIe to PCI-X bridge in the device. This change
uses bus_dmatag_subregion(), so this workaround won't work on some
archs which doesn't support bus_dmatag_subregion().
 1.56.18.2 07-Sep-2013  bouyer sys/dev/pci/if_bge.c 1.203-1.237, 1.239-1.241, 1.243-1.258 via patch
sys/dev/pci/if_bgereg.h 1.58-1.74, 1.76-1.83 via patch
sys/dev/pci/if_bgevar.h 1.10-1.16 via patch
sys/dev/pci/pcidevs 1.1149 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/brgphy.c 1.61-1.63, 1.65, 1.67 via patch
sys/dev/mii/miivar.h 1.61 via patch
sys/dev/mii/miidevs 1.112-1.113 via patch
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/bge.4 1.13-1.15 via patch

Add some device support, fix a lot of bugs and add some enahcements.
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F,
BCM5785G, BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- brgphy(4): Add BCM5756, BCM5717C, BCM5719C, BCM5720C and BCM57780.
- Add some bugfixes and enhancement from FreeBSD:
- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Sync with *BSD. No functional change:
- make bge_chipid() and use it.
- use switch() instead of a lot of if()s.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the
capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking. FreeBSD has the same delay().
- Rename PHY related flags for the consistency. It's the same as
FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT
flag to not to check Gigabit flags. It's the same as FreeBSD.
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this commit,
only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK calls MI
mii_phy_auto(). That was not intended.
- Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that
do not have jumbo support
- Wait for the bootcode to complete initialization for 5717 and newer
devices. See BCM5718 programmer's guide's "step 13,
Device reset Procedure, Section7".
57781's document has the same note.
- 5718 and 57785 document say we should wait 100us.
- Change the order of register settings a little to match both
Broadcom's document and Linux tg3.
- Add detach function.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix a bug that the NVRAM lock timeout occured on sparc64 onboard bge.
- Check BGE_SGDIG_STS when the chip is NOT a 5717 A0, like freebsd
(OpenBSD rev. 1.327).
- Fix the setting of Tx Random Backoff Register.
- Add BGE_PCIMISCCTL_PCISTATE_RW in BGE_INIT. It's required to set the
PCISTATE register correctly.
- Update comments from 57XX-PG105-R.pdf and 5718-PG106-R.pdf.
- Add missing bus_dmamap_sync() in bge_intr(). The status word is
in DMAed area. Same as other *BSDs.
- Check the hardware config words and print them. This change only
read them and print the values.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind().
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT.
Same as OpenBSD's if_bge.c rev. 1.86.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
- Set DMA watermark depend on the PCI max payload size.
- Add BGE_JUMBO_CAPABLE flag to some chips. With this commit, 5714,
5780, 5717, 5718, 5719 (exclude rev. A0), 5720, 57765 and 57766 are
added to support jumbo frame.
- Fix the setting of sc->bge_flags for 5717 and newer devices.
- Fix a link detect bug on non-autopoll systems. Same as OpenBSD
(rev.1.329 and 1.336) and FreeBSD (r213710).
- 57765 series is not based on 5717 series. 5717 series is based on
57765 series.
- Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
- Change sysctl related functions for consistency.
- Style change.
- Use macro. Remove duplicated macro. Remove unused variable.
- Fix comments. Add comments.
- Remove extra semicolon. Remove unused code.
[msaitoh, ticket #939]
 1.56.18.1 26-Aug-2013  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #652):
sys/dev/mii/brgphy.c 1.60
sys/dev/pci/if_bge.c 1.202
sys/dev/pci/if_bgereg.h 1.57
Add support for BCM57762 and BCM57765, found in Apple's Thunderbolt
to Gigabit Ethernet adapter. PR kern/46961.
 1.56.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.56.12.1 30-Oct-2012  yamt sync with head
 1.81.2.2 18-May-2014  rmind sync with head
 1.81.2.1 28-Aug-2013  rmind sync with head
 1.86.2.1 10-Aug-2014  tls Rebase.
 1.88.4.2 28-Aug-2017  skrll Sync with HEAD
 1.88.4.1 06-Jun-2015  skrll Sync with HEAD
 1.88.2.1 09-May-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #740):
sys/dev/pci/if_bge.c: revision 1.285
sys/dev/pci/if_bgereg.h: revision 1.90
Use another firmware command in bge_asf_driver_up(). Same as Lunux.
This change fixes a bug that watchdog timeout occurs every 25-30 minutes
on HP ML110 G6 reported enami@ in PR#49657.
 1.91.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.91.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.93.12.1 10-Jun-2019  christos Sync with HEAD
 1.93.10.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.93.4.2 07-Mar-2019  martin Pull up the following, requested by msaitoh in ticket #1209:

sys/dev/pci/if_bge.c 1.323-1.327
sys/dev/pci/if_bgereg.h 1.95
sys/dev/mii/brgphy.c 1.80
share/man/man4/bge.4 1.16

- Add BCM5717's another device ID support.
- Add BCM5702FE, another BCM5704S and SysKonnect SK-9Mxx support.
- Add support for BCM5762 ASIC devices.
- Add BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787.
- Simplify PCI device table.
- Add /* FALLTHROUGH */
 1.93.4.1 08-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1130):

sys/dev/pci/if_bge.c: revision 1.320
sys/dev/pci/if_bgevar.h: revision 1.24
sys/dev/pci/if_bge.c: revision 1.317
sys/dev/pci/if_bgereg.h: revision 1.94

More TSO4 fixes, from the freebsd driver:
- the chip doens't want the lenght of options, but the complete lenght of
ip headers (ip + tcp + options). Fix this for the BGE_IS_5717_PLUS()
and BGE_IS_5705_PLUS() cases; FreeBSD doens't cover the last case so
leave it as is for now. This fixes checksum failures for heavy transfers.
- It looks like the transmit engine hangs if the TCP segment crosses a 4GB
boundary. FreeBSD fixes it by mapping everything below 4GB; instead
try detect when this happens and do the bounce only when needed.

With these fixes I could transfers 3GB images over ftp at gigabit speed
(112MB/s with wget) without problems. Tested on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0

-

Don't destroy the dma maps if we're not disabling the adapter, avoids
a KASSERT() when bus_dmamap_destroy() is called from interrupt
context via bge_watchdog()

Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage.
Otherwise we may set IFF_OACTIVE while no transmit is in progress, and
nothing will clear it.

If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry.
Refine the check for the 4GB boundary workaround (a fragment should also
not cross the boundary), and do it only for TSO.

If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet.

Bring in more hardware bug workarounds from freebsd.

With these it seems that a BCM5720 A0 can survive a few hours of internet
load with TSO4 enabled.
 1.42 28-Aug-2024  skrll Apply changes from PR/58584 after testing (and fixing).

Tested on an Apple M1.
 1.41 21-Feb-2023  andvar branches: 1.41.6;
s/jumo/jumbo/ in comments.
 1.40 04-Sep-2022  skrll branches: 1.40.4;
bge(4): fix the MP improvements and improve some more.

- Have two locks sc_core_lock at IPL_NONE and sc_intr_lock at IPL_NET and
use appropriately.

- Use stopping flags instead of bge_if_flags so that bge_if_flags only
needs to be protected by the sc_core_lock

- Use ifmedia_init_with_lock and provide the sc_intr_lock. mii operatiions
are done from the interrupt handler.

- Fixup locking in bge_detach.

- Rename bge_watchdog to bge_watchdog_tick to avoid confusion with the
if_watchdog method.

- Sprinkle some more asserts.
 1.39 02-Sep-2022  skrll Whitespace - mostly align the line continutation characters
 1.38 27-Aug-2022  skrll Convert bge_pending_rxintr_change to a bool (from int)
 1.37 26-Aug-2022  skrll G/C unused softc members
 1.36 19-Aug-2022  skrll Make bge_detaching a bool. NFC.
 1.35 19-Aug-2022  skrll softc member naming consistency with wm(4). (Taylor made me do it... not
really)
 1.34 14-Aug-2022  skrll bge: Mirror the bus_dma RX buffer changes in the OpenBSD driver

This change reduces the amount of work done in the interrupt handler.
 1.33 14-Aug-2022  skrll Make bge(4) MP safe

This started out as a fix so that LOCKDEBUG wouldn't explode with kernel
lock spinout. LOCKDEBUG is too aggressive now and really should be
relaxed.
 1.32 14-Aug-2022  skrll Whitespace
 1.31 07-Aug-2022  skrll Provide and use (when appropriate) a bge_free_jumbo_mem.
 1.30 25-Jul-2022  skrll Some more BITS(3)
 1.29 25-Jul-2022  skrll G/C the unused bge_rx_mini_chain member from bge_chain_data. It was removed
from the FreeBSD driver in 2003.
 1.28 02-Jul-2022  skrll Sprinkle some BITS(3). Same code before and after.
 1.27 02-Jul-2022  skrll Use BUS_ADDR_{LO,HI}32. NFCI.
 1.26 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.25 13-Sep-2019  msaitoh branches: 1.25.2;
if_flags is neither int nor short. It's unsigned short.
 1.24 27-Nov-2018  bouyer More TSO4 fixes, from the freebsd driver:
- the chip doens't want the lenght of options, but the complete lenght of
ip headers (ip + tcp + options). Fix this for the BGE_IS_5717_PLUS()
and BGE_IS_5705_PLUS() cases; FreeBSD doens't cover the last case so
leave it as is for now. This fixes checksum failures for heavy transfers.
- It looks like the transmit engine hangs if the TCP segment crosses a 4GB
boundary. FreeBSD fixes it by mapping everything below 4GB; instead
try detect when this happens and do the bounce only when needed.

With these fixes I could transfers 3GB images over ftp at gigabit speed
(112MB/s with wget) without problems. Tested on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0
 1.23 12-Apr-2017  msaitoh branches: 1.23.4; 1.23.10; 1.23.12;
Add counters for spurious interrupts.
 1.22 12-Apr-2017  msaitoh Detach sysctl and event counters in bge_release_resources().
 1.21 18-Nov-2015  msaitoh branches: 1.21.2; 1.21.4;
Delete #ifdef __HAVE_PCI_MSI_MSIX and use pci_intr_allo()/pci_intr_release()
on any systems. The third argument of pci_intr_alloc() is left because we will
use the code to support MSI-X in future.
 1.20 14-Jun-2015  martin Make sure not to re-arm the statistics callout when we are about to detach.
 1.19 17-May-2015  msaitoh - Add MSI support.
- Use tagged status function for 5717 and newer devices. All controllers
except BCM5700 support tagged status but we use tagged status only for MSI
case on BCM5717. Otherwise MSI on BCM5717 does not work. Same as other *BSDs.
 1.18 14-Apr-2015  riastradh Include <sys/rndsource.h> where it is actually used.

I had removed <sys/rnd.h> from files that didn't mention anything of
the rnd(9) API. But they included other files which assumed
<sys/rnd.h> had already been included.
 1.17 31-Oct-2013  msaitoh branches: 1.17.6;
Cleanup flag setting. No functional change.
- Split flags into bge_flags and bge_phy_flags.
- Rename flags. PHY related flags are prefixed with BGEPHYF_*.
Other flags are prefixed with BGEF_*.
 1.16 31-May-2013  msaitoh branches: 1.16.2;
- Revert rev. 1.250. I really misunderstood. Add some comments.
- Set DMA watermark depend on the PCI max payload size.
 1.15 24-May-2013  msaitoh bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT. Same as
OpenBSD's if_bge.c rev. 1.86.
 1.14 24-Mar-2013  msaitoh - Add detach function.
- Remove old unused bge_vpd_*.
 1.13 21-Mar-2013  msaitoh - Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that do not
have jumbo support
- Add/sync some of the comments
- Use macro.
- Remove unused code.
 1.12 17-Mar-2013  msaitoh - ADD support for BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Use macros.
- Remove unused code.
- Sync with the latest {Free,Open}BSD's bge.
 1.11 07-Mar-2013  msaitoh Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
 1.10 27-Feb-2013  msaitoh Fix macro definitions. No binary change.
 1.9 02-Feb-2012  tls branches: 1.9.2; 1.9.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.8 19-Nov-2011  tls branches: 1.8.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.7 18-May-2011  dyoung branches: 1.7.4;
#include <sys/bus.h>, not <machine/bus.h>.
 1.6 09-Jan-2011  jruoho branches: 1.6.2;
Don't use SYSCTL_SETUP in a driver.
 1.5 03-Feb-2010  msaitoh branches: 1.5.4; 1.5.6;
s/u_int/uint/
 1.4 03-Feb-2010  msaitoh - Make the initialize sequence close to the document.
- Fix ASF heartbeat sending bug (FreeBSD rev. 1.271 (r202821))
- Use new handshake command for BCM5750 or new controllers (FreeBSD rev. 1.272
(r202822))
 1.3 28-Jan-2010  msaitoh - Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- remove an unused structure.
- KNF
 1.2 24-Jan-2010  msaitoh Many changes from FreeBSD and OpenBSD:
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Many other bugfixes.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
 1.1 23-Apr-2009  msaitoh branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
use proplib
 1.1.10.3 21-Aug-2009  bouyer The wrong version of this file was added to the branch when processing
ticket #1342: use the file provided via patch in #1342 instead of
version from HEAD.
 1.1.10.2 18-Aug-2009  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1342):
sys/dev/pci/if_bge.c: revisions 1.135, 1.146, 1.151-1.152,
1.155-1.167 via patch
sys/dev/pci/if_bgereg.h: revisions 1.43, 1.48-1.52
sys/dev/pci/if_bgevar.h: revision 1.1
sys/dev/mii/brgphy.c: revisions 1.36, 1.40, 1.43-1.44 and
1.47-1.48 via patch
sys/dev/mii/brgphyreg.h: revisions 1.3-1.4
sys/dev/mii/miidevs: revisions 1.75, 1.77, 1.85
sys/dev/mii/miidevs.h: regen
sys/dev/mii/miidevs_data.h: regen
sys/dev/mii/miivar.h: revision 1.54
For bge:
- Really set Tx threshold.
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the "link changed" bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
- Add BCM5786 support.
for brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2, BCM5708C, BCM5722, and BCM5906.
 1.1.10.1 23-Apr-2009  bouyer file if_bgevar.h was added on branch netbsd-4 on 2009-08-18 10:10:19 +0000
 1.1.8.4 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.1.8.3 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1359):
sys/dev/pci/if_bge.c 1.170-1.181
sys/dev/pci/if_bgereg.h 1.53-1.56
sys/dev/pci/if_bgevar.h 1.2-1.5
sys/dev/pci/pcidevs 1.1017, 1.1021
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/miidevs 1.89, 1.93
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/dev/mii/brgphy.c 1.49, 1.52

- Fix a bug of BGE_RDMA_MODE_FIFO_LONG_BURST definition.
- Fix the bug that both BGE_PCIE and BGE_PCIX are set on PCI-Express devices.
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
- (brgphy(4)) Add support for BCM5461, BCM5464, BCM5784 and BCM5761.
- (brgphy(4)) Enable brgphy_jumbo_settings().
- (brgphy(4)) Enable the Ethernet@Wirespeed function.
- Add support for device properties to override the mac address and set
the BGE_NO_EEPROM flag if we have an onboard device w/o SEEPROM.
- Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- Fixes the bug that error bits arent cleard because these bit are W2C
(in other words W1C).
- Many other bugfixes from FreeBSD and OpenBSD.
- remove an unused structure.
- ANSI C, KNF and tabify
- fix typo in comment.
 1.1.8.2 04-Aug-2009  snj Apply patch (requested by msaitoh in ticket #866):
For bge:
- Fix the case of setting a flag in BGE_PCI_DMA_RW_CTL on
conventional PCI.
- Fix some bugs that the driver unable to detect link loss
(OpenBSD 1.135, FreeBSD 1.102)
- bge_tick(): fix some extra input error (OpenBSD 1.221 FreeBSD 1.212)
- Acknowledge link change interrupts by setting the 'link changed' bit
in the status register (used to have no effect). FreeBSD 1.44
(OpenBSD 1.21)
- Add some fiber support (OpenBSD 1.220)
- Set BGE_MISCCFG_KEEP_GPHY_POWER as {Open,Free}BSD and linux.
- Add special case code to fix a problem with the BCM5704 in TBI
mode (FreeBSD rev. 1.71, OpenBSD rev. 1.35)
- Force an interrupt in bge_ifmedia_upd (FreeBSD rev. 1.205, OpenBSD
rev. 1.242)
- Add missing workaround for 5705 (FreeBSD rev. 1.44, OpenBSD rev.
1.21)
- Don't print error message only when the register is BGE_SRS_MODE.
It occurs on some environment (and once after boot?). Other *BSDs
and Linux don't print the error message for all registers.
- Fix comments.
- Remove obsolete codes.
For brgphy:
- Add some quirk codes.
- Add support for BCM5462, BCM54K2 and BCM5722.
 1.1.8.1 23-Apr-2009  snj file if_bgevar.h was added on branch netbsd-5 on 2009-08-04 19:46:20 +0000
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 23-Apr-2009  jym file if_bgevar.h was added on branch jym-xensuspend on 2009-05-13 17:20:24 +0000
 1.1.4.3 11-Mar-2010  yamt sync with head
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 23-Apr-2009  yamt file if_bgevar.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:56 +0000
 1.1.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1 23-Apr-2009  skrll file if_bgevar.h was added on branch nick-hppapmap on 2009-04-28 07:35:56 +0000
 1.5.6.2 21-Apr-2010  matt sync to netbsd-5
 1.5.6.1 03-Feb-2010  matt file if_bgevar.h was added on branch matt-nb5-mips64 on 2010-04-21 00:27:41 +0000
 1.5.4.2 31-May-2011  rmind sync with head
 1.5.4.1 05-Mar-2011  rmind sync with head
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.4.1 17-Apr-2012  yamt sync with head
 1.8.2.1 18-Feb-2012  mrg merge to -current.
 1.9.6.3 03-Dec-2017  jdolecek update from HEAD
 1.9.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.6.1 23-Jun-2013  tls resync from head
 1.9.2.2 17-Nov-2013  bouyer Apply patch, requested by msaitoh in ticket #983:
sys/dev/mii/brgphy.c 1.68 via patch
sys/dev/pci/if_bge.c 1.260-1.262 via patch
sys/dev/pci/if_bgereg.h 1.85-1.86 via patch
sys/dev/pci/if_bgevar.h 1.17 via patch

Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
For PCI-X BCM5704, set maximum outstanding split transactions to 0.
Same as Linux tg3 and FreeBSD (part of FreeBSD r204978).
Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD
(part of r199670). This workaround is for 5714/5715 controllers and
is not actually a MAC controller bug but an issue with the embedded
PCIe to PCI-X bridge in the device. This change
uses bus_dmatag_subregion(), so this workaround won't work on some
archs which doesn't support bus_dmatag_subregion().
 1.9.2.1 07-Sep-2013  bouyer sys/dev/pci/if_bge.c 1.203-1.237, 1.239-1.241, 1.243-1.258 via patch
sys/dev/pci/if_bgereg.h 1.58-1.74, 1.76-1.83 via patch
sys/dev/pci/if_bgevar.h 1.10-1.16 via patch
sys/dev/pci/pcidevs 1.1149 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/brgphy.c 1.61-1.63, 1.65, 1.67 via patch
sys/dev/mii/miivar.h 1.61 via patch
sys/dev/mii/miidevs 1.112-1.113 via patch
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/bge.4 1.13-1.15 via patch

Add some device support, fix a lot of bugs and add some enahcements.
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F,
BCM5785G, BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- brgphy(4): Add BCM5756, BCM5717C, BCM5719C, BCM5720C and BCM57780.
- Add some bugfixes and enhancement from FreeBSD:
- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Sync with *BSD. No functional change:
- make bge_chipid() and use it.
- use switch() instead of a lot of if()s.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the
capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking. FreeBSD has the same delay().
- Rename PHY related flags for the consistency. It's the same as
FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT
flag to not to check Gigabit flags. It's the same as FreeBSD.
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this commit,
only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK calls MI
mii_phy_auto(). That was not intended.
- Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that
do not have jumbo support
- Wait for the bootcode to complete initialization for 5717 and newer
devices. See BCM5718 programmer's guide's "step 13,
Device reset Procedure, Section7".
57781's document has the same note.
- 5718 and 57785 document say we should wait 100us.
- Change the order of register settings a little to match both
Broadcom's document and Linux tg3.
- Add detach function.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix a bug that the NVRAM lock timeout occured on sparc64 onboard bge.
- Check BGE_SGDIG_STS when the chip is NOT a 5717 A0, like freebsd
(OpenBSD rev. 1.327).
- Fix the setting of Tx Random Backoff Register.
- Add BGE_PCIMISCCTL_PCISTATE_RW in BGE_INIT. It's required to set the
PCISTATE register correctly.
- Update comments from 57XX-PG105-R.pdf and 5718-PG106-R.pdf.
- Add missing bus_dmamap_sync() in bge_intr(). The status word is
in DMAed area. Same as other *BSDs.
- Check the hardware config words and print them. This change only
read them and print the values.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind().
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT.
Same as OpenBSD's if_bge.c rev. 1.86.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
- Set DMA watermark depend on the PCI max payload size.
- Add BGE_JUMBO_CAPABLE flag to some chips. With this commit, 5714,
5780, 5717, 5718, 5719 (exclude rev. A0), 5720, 57765 and 57766 are
added to support jumbo frame.
- Fix the setting of sc->bge_flags for 5717 and newer devices.
- Fix a link detect bug on non-autopoll systems. Same as OpenBSD
(rev.1.329 and 1.336) and FreeBSD (r213710).
- 57765 series is not based on 5717 series. 5717 series is based on
57765 series.
- Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
- Change sysctl related functions for consistency.
- Style change.
- Use macro. Remove duplicated macro. Remove unused variable.
- Fix comments. Add comments.
- Remove extra semicolon. Remove unused code.
[msaitoh, ticket #939]
 1.16.2.1 18-May-2014  rmind sync with head
 1.17.6.4 28-Aug-2017  skrll Sync with HEAD
 1.17.6.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.6.2 22-Sep-2015  skrll Sync with HEAD
 1.17.6.1 06-Jun-2015  skrll Sync with HEAD
 1.21.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.21.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.23.12.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.23.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.23.12.1 10-Jun-2019  christos Sync with HEAD
 1.23.10.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.23.4.1 08-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1130):

sys/dev/pci/if_bge.c: revision 1.320
sys/dev/pci/if_bgevar.h: revision 1.24
sys/dev/pci/if_bge.c: revision 1.317
sys/dev/pci/if_bgereg.h: revision 1.94

More TSO4 fixes, from the freebsd driver:
- the chip doens't want the lenght of options, but the complete lenght of
ip headers (ip + tcp + options). Fix this for the BGE_IS_5717_PLUS()
and BGE_IS_5705_PLUS() cases; FreeBSD doens't cover the last case so
leave it as is for now. This fixes checksum failures for heavy transfers.
- It looks like the transmit engine hangs if the TCP segment crosses a 4GB
boundary. FreeBSD fixes it by mapping everything below 4GB; instead
try detect when this happens and do the bounce only when needed.

With these fixes I could transfers 3GB images over ftp at gigabit speed
(112MB/s with wget) without problems. Tested on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0

-

Don't destroy the dma maps if we're not disabling the adapter, avoids
a KASSERT() when bus_dmamap_destroy() is called from interrupt
context via bge_watchdog()

Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage.
Otherwise we may set IFF_OACTIVE while no transmit is in progress, and
nothing will clear it.

If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry.
Refine the check for the 4GB boundary workaround (a fragment should also
not cross the boundary), and do it only for TSO.

If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet.

Bring in more hardware bug workarounds from freebsd.

With these it seems that a BCM5720 A0 can survive a few hours of internet
load with TSO4 enabled.
 1.25.2.1 29-Feb-2020  ad Sync with head.
 1.40.4.1 13-Oct-2024  martin Pull up following revision(s) (requested by skrll in ticket #968):

sys/dev/pci/if_bgevar.h: revision 1.41
sys/dev/pci/if_bgevar.h: revision 1.42
sys/dev/pci/if_bge.c: revision 1.394

s/jumo/jumbo/ in comments.

Apply changes from PR/58584 after testing (and fixing).
Tested on an Apple M1.
 1.41.6.1 02-Aug-2025  perseant Sync with HEAD
 1.116 10-Nov-2024  mlelstv Add MBUFTRACE
 1.115 29-Jun-2024  riastradh branches: 1.115.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.114 23-Apr-2024  hans Sync the statistics DMA memory correctly before it is accessed.
 1.113 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.112 01-Aug-2023  andvar fix various typos in comments.
 1.111 04-Aug-2022  andvar s/bufferred/buffered/ in memory description.L:
 1.110 05-Dec-2021  msaitoh s/exisit/exist/ in comment.
 1.109 13-Aug-2021  andvar s/struture/structure/ s/structre/structure/
 1.108 14-Feb-2021  jakllsch if_bnx.c: fix misleading indentation

suggested by rillig@
 1.107 13-Feb-2021  jakllsch Curb aprint_*() abuse in bnx(4)
 1.106 13-Feb-2021  jakllsch Revert bnx(4) to INTx interrupts.

Should fix PR kern/55974.

This driver does not yet do the special MSI and MSI-X setup that the
chip apparently requires.
 1.105 17-Jul-2020  jdolecek branches: 1.105.2;
if bnx_tx_encap() fails because mbuf is too fragmented or too long,
drop the mbuf instead of wedging the TX queue forever; found by code inspection

this is quite unlikely scenario since it requires mbuf chain consisting of
more than 8 frags and m_defrag() failing, so probably unrelated to PR kern/47229
 1.104 17-Jul-2020  jdolecek make sure bnx_alloc_pkts() always clears BNX_ALLOC_PKTS_FLAG and IFF_OACTIVE,
even on dmamap allocation failure; remove unnecessary IFF_UP condition
 1.103 17-Jul-2020  jdolecek remove mistakely committed in-progress code from previous commit
 1.102 17-Jul-2020  jdolecek re-enable MSI/MSI-X, the TX timeouts were caused by the IFF_OACTIVE handling,
which was fixed in previous revision
 1.101 16-Jul-2020  jdolecek need to clear IFF_OACTIVE after allocating more pkts in order to actually
start processing the queue in bnx_start()
 1.100 16-Jul-2020  jdolecek disable MSI/MSI-X for time being, it causes interrupt timeouts and needs
to be investigated before enabling this again
 1.99 14-Jul-2020  jdolecek make bnx_wk (used to trigger bnx_alloc_pkts()) part of softc instead
of using a static variable, so it's independant for each adapter
 1.98 14-Jul-2020  jdolecek remove call to bnx_alloc_pkts() from bnx_init_tx_chain() - it can
be called from softint context via bnx_watchdog(), and bnx_alloc_pkts()
dmamap allocation can't run in (soft)interrupt context
 1.97 14-Jul-2020  jdolecek only destroy the TX pkgs and dmamaps in bnx_dma_free() called on detach, don't
do it anymore in bnx_free_tx_chain(), called from bnx_init()

avoid occassional panic triggered by the free code having to allocate
memory from interrupt context when bnx_init() is called from bnx_watchdog()
 1.96 12-Jul-2020  jdolecek enable MSI/MSI-X if supported by adapter

tested MSI-X with Broadcom NetXtreme II BCM5709 1000Base-T
 1.95 18-May-2020  msaitoh Fix typo in comment.
 1.94 28-Feb-2020  msaitoh Replace bnx_ifmedia_upd() in bnx_init() with mii_ifmedia_change() for future
locking changes.
 1.93 28-Feb-2020  msaitoh Replace bnx_ifmedia_upd() in bnx_mgmt_init() with mii_ifmedia_change() for
future locking changes. Suggested by thorpej@.

XXX Need more work for bnx_ifmedia_upd() itself.
 1.92 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.91 04-Feb-2020  thorpej Use ifmedia_fini().
 1.90 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.89 27-Dec-2019  msaitoh branches: 1.89.2;
s/recive/receive/ in comment.
 1.88 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.87 26-Jul-2019  msaitoh Calculate the multicast hash table correctly to avoid undefined behavior.
Found by KUBSan.
 1.86 09-Jul-2019  msaitoh Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.85 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.84 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.83 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.82 24-Apr-2019  msaitoh This driver uses MII(4) and have hook SIOCGIFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.
 1.81 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.80 08-Apr-2019  msaitoh Make it compilable with BNX_DEBUG.
 1.79 05-Apr-2019  msaitoh BCM5709 is PCIe based. To wait for pending PCI transactions to complete,
wait until PCIe's transaction pending bit is cleared.
 1.78 05-Apr-2019  msaitoh - Allow time for the management firmware to enter the running state.
- Enable/Disable management frames (NC-SI) to flow to the MCP if MFW exists.
- Print the boot code version, management firmware version and some flags.
- Gbps -> GT/s for PCIe speed.
- Use aprint_*() in bnx_print_adapter_info().
- Use braces for some macors' argument.
- Remove unused macros.
- KNF.
 1.77 05-Apr-2019  msaitoh Fix a bug that BNX_MISC_ENABLE_SET_BITS is not correctly set on BCM5709.
 1.76 04-Apr-2019  msaitoh 0 -> NULL.
 1.75 01-Apr-2019  msaitoh s/adddress/address/
 1.74 29-Mar-2019  msaitoh - Use m_defrag() when bus_dmamap_load_mbuf() returned with EFBIG.
- Style change to reduce diff against {Free,Open}BSD.
- Make it compilable with BNX_DEBUG.
- Use __nothing for null macro.
 1.73 29-Mar-2019  msaitoh Sync with OpenBSD:
- Don't need to clear if_timer during attach. (OpenBSD rev. 1.23)
- Do the minimal initialization of the firmware so that ASF always works.
From ambrisko@FreeBSD (OpenBSD rev. 1.32)
- Move the interrupt establishment till after everything in the softc is set up
(OpenBSD rev. 1.40)
- Let mii_attach() know where the PHY is located instead of scanning for it
since we know where it will be anyway and remove the code from the MII bus
read/write functions to force reading/writing from the predetermined
location. Copied from bge(4) and this is what the upstream FreeBSD bce(4)
driver has done once FreBSD gained a mii_attach().
 1.72 28-Mar-2019  msaitoh - Remove extra cast (from OpenBSD rev. 1.95)
- Add support flow control (from OpenBSD rev. 1.97 and 1.100).
The main difference between NetBSD and other *BSDs is that the flow control
does really works. The lower 8bit of BNX_L2CTX_CTX_TYPE should be 0xff
(from Linux). Note that I have NetXtremeII-PG203-R.pdf and it says the field
is reserved and should be 0.
 1.71 27-Mar-2019  msaitoh - Remove extra check (because the same check is done in
if_schedule_deferred_start().
- Remove extra space.
 1.70 27-Mar-2019  msaitoh Apply OpenBSD rev. 1.94:

> ido not disable interrupts in the isr and then enable them again
> when leaving. when you're handling an interrupt it is masked.
> whacking the chip is work for no gain.
>
> modify the interrupt handler so it only processes the rings once
> rather than looping over them until it runs out of work to do
>
> looping in the isr is bad for several reasons:
>
> firstly, the chip does interrupt mitigation so you have a
> decent/predictable amount of work to do in the isr. your first loop
> will do that chunk of work (ie, it pulls off 50ish packets), and
> then the successive looping aggressively pull one or two packets
> off the rx ring. these extra loops work against the benefit that
> interrupt mitigation provides.
>
> bus space reads are slow. we should avoid doing them where possible
> (but we should always do them when necessary).
>
> doing the loop 5 times per isr works against the mclgeti semantics.
> it knows a nic is busy and therefore needs more rx descriptors by
> watching to see when the nic uses all of its descriptors between
> interrupts. if we're aggressively pulling packets off by looping
> in the isr then we're skewing this check.
>
> ok deraadt@
 1.69 27-Mar-2019  msaitoh Sync with other *BSDs:

From OpenBSD's rev. 1.93:
> to quote from the gospel of bus_dma.9:
>
> Synchronization operations are expressed from the perspective of the host
> RAM, e.g., a device -> memory operation is a READ and a memory -> device
> operation is a WRITE.
>
> the status block that the isr reads is written to by the device.
> the chip writes to memory, it is therefore a READ.
>
> this also adds the preread sync when the map is set up and the postread
> sync when the map is torn down for better symmetry. there are probably
> more issues like this in the code, but this is a start.
>
> discovered while discussing another diff with claudio@
 1.68 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.67 08-Jan-2019  msaitoh Fix a bug that bnx_miibus_read_reg() returns wrong value when
BNX_PHY_INT_MODE_AUTO_POLLING_FLAG is set. This bug doesn't cause a real
problem because BNX_PHY_INT_MODE_AUTO_POLLING_FLAG is not set.
 1.66 08-Jan-2019  msaitoh KNF. No functional change.
 1.65 26-Jun-2018  msaitoh branches: 1.65.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.64 08-May-2018  msaitoh - Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
 1.63 08-Feb-2018  dholland branches: 1.63.2;
Typos.
 1.62 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.61 15-Dec-2016  ozaki-r branches: 1.61.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.60 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.59 10-Jun-2016  ozaki-r branches: 1.59.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.58 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.57 09-Jul-2014  msaitoh branches: 1.57.4;
Call bnx_print_adapter_info() before mii_attach() to not to
split bnx's dmesg into two parts by brgphy's dmesg.
 1.56 01-Jul-2014  msaitoh Print some information (ASIC revision, PCI status, etc). From FreeBSD.
 1.55 01-Jul-2014  msaitoh No functional change.
- s/u_int/uint/
- Modify comment a bit (sync with OpenBSD)
 1.54 24-Jun-2014  msaitoh No functional change:
- Tabify.
- Remove trailing white spaces.
- Fix typo in comment.
 1.53 17-Jun-2014  msaitoh - Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4). The auto negotiation may have some bugs.
- Add 2500SX support (not tested).
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
 1.52 12-Jun-2014  msaitoh No functional change:
- Remove BRGPHY_SERDES_ANAR_* and BRGPHY_SERDES_ANLPAR_*. Those registers
are the same as MII_ANAR_* and MII_ANLPAR_*.
- Fix typo.
- Remove trailing white spaces.
- KNF.
 1.51 29-Mar-2014  christos branches: 1.51.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.50 13-Mar-2014  hannken Add __diagused.
 1.49 13-Sep-2013  martin #ifdef variable declarations/initializations like their use
 1.48 30-Mar-2013  christos branches: 1.48.4;
remove trailing whitespace
 1.47 22-Jul-2012  matt branches: 1.47.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.46 06-Mar-2012  bouyer bnx_start() is not MP-safe, so do not create the bnx_alloc_pkts()'s
workqueue MPSAFE. This could lead to bnx_start() being running at
the same time on 2 CPUs, with packets being sent twice.
Problem found and reported by Beverly Schwartz and Greg Troxel.
 1.45 22-Sep-2011  jym branches: 1.45.2; 1.45.6; 1.45.8;
The bnx(4) handler runs at IPL_NET (works with spin mutexes), while
allocations can be deferred to a workqueue(9): set its highest IPL to
IPL_NET and not IPL_NONE, which is protected by an adaptive/sleeping mutex.
 1.44 15-Jul-2011  jym Use a workqueue(9) to defer allocation of TX packets. Loosely inspired
from the OpenBSD bnx(4) driver.

Tested by Roger Pau Monné, roger.pau at entel.upc.edu.

Fixes kern/45051.
 1.43 02-May-2011  jym Fix BCM5709 PHY detection for ethernet PHYs (the SerDes case being already
handled):
- export bge(4) and bnx(4) CHIP ID and PHY flags to brgphy(4). Move to
"unsigned int" rather than "int", and reuse the same softc members for
chipid and phyflags (behavior controlled by the sc_isbge/isbnx boolean).
- apply bug fix for revisions A and B, so that autonegotiation can
complete (from OpenBSD).

Bug reported by Rivo Nurges via private mail, patch tested and
confirmed working by him (with thanks!)
 1.42 26-Jan-2011  dyoung Get out of the interrupt handler early if !IFF_RUNNING.
 1.41 06-Jan-2011  jym branches: 1.41.2; 1.41.4;
bnx(4) SERDES NICs will definitely work better with the PHY initialization
code... rather than without.

(forgot to commit it two weeks ago -- should be part of the BCM 5709S
patch)
 1.40 06-Jan-2011  jym Reflect 5709S support in bnx(4) (comment fix)
 1.39 11-Dec-2010  martin Sanitize names a bit, still could use more namespace cleanup
 1.38 11-Dec-2010  pgoyette Fix a couple of name-space changes that fell through the cracks.

Hello, martin!
 1.37 09-Dec-2010  jym Remove htolexx calls, as bnx(4) NICs are capable of swapping endianess.

The macros for PAGE_SIZE were fixed with the previous patch (if_bnxreg.h
splitting, rev 1.11).

From OpenBSD. Their commit log reads:

bnx(4) is a bit special. The chip itself is capable of swapping endianess
so there is no need for htoleXX calls. The only thing needed is the correct
layout of the DMA-ed structures. Additionally it uses PAGE_SIZE but assumed
that it is always 4k. Fix the macros that failed to respect that so that it
works on 8k PAGE_SIZE systems. This makes bnx(4) work on sparc64.
 1.36 09-Dec-2010  jym Similar to bge(4), split if_bnxreg.h in two parts:
- if_bnxreg.h: general register values, flags... for bnx(4), that can
be included in other drivers
- if_bnxvar.h: PCI or device specific code (device state data, debug
macros etc.), which should remain private to bnx(4)

No comments, no objections on current-users@.

See discussion:
http://mail-index.netbsd.org/current-users/2010/12/01/msg014926.html
 1.35 27-Nov-2010  jym Missing break in switch case. From OpenBSD.
 1.34 26-Nov-2010  dholland Don't test flags with &&. From Henning Petersen in PR 44151.
 1.33 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.32 11-Mar-2010  msaitoh branches: 1.32.2;
Add missing ifmedia_delete_instance() in bnx_detach().
 1.31 19-Jan-2010  pooka branches: 1.31.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.30 20-Nov-2009  bouyer Remove duplicate PCI_PRODUCT_BROADCOM_BCM5709 entries.
BNX_MAX_MRU is now the 1500-bytes MTU; use BNX_MAX_JUMBO_MRU instead.
 1.29 18-Nov-2009  bouyer Sync with OpenBSD: if_bnx.c,v 1.85. Major changes:
Add support for the Broadcom BCM5709 and BCM5716 chips. This upgrade
the B06 firmware, and add the B09 firmware required by the BCM5709.
Remplace TX dmamap array with a dynamically-grown list.

Tested with:
bnx0 at pci4 dev 0 function 0: Broadcom NetXtreme II BCM5708 1000Base-T
and
bnx0 at pci0 dev 0 function 0: Broadcom NetXtreme II BCM5709 1000Base-SX
 1.28 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.27 05-May-2009  cegger Attach on BCM5709 chip.
XXX Firmware fails to complete initialization on this chip.
 1.26 17-Apr-2009  dyoung Bug fix: don't release the Rx DMA maps twice.
 1.25 07-Apr-2009  dyoung Destroy sc->bnx_timeout in bnx_detach().
 1.24 03-Apr-2009  dyoung Fix SIOCSIFFLAGS. Mark as safe to detach at shutdown.
 1.23 18-Mar-2009  cegger bzero -> memset
 1.22 18-Mar-2009  cegger bcmp -> memcmp
 1.21 27-Jan-2009  dyoung branches: 1.21.2;
Protect against spurious "bnx0: Double mbuf allocation failure!"
panics.

Extract a new function, bnx_add_buf(), from bnx_get_buf().
bnx_add_buf() just tries to add an mbuf to the Rx chain. bnx_get_buf()
tries to allocate an mbuf, first, and then to add the mbuf to the
chain. Use bnx_add_buf() to try to put an mbuf that we took off
of the chain back onto the chain, and use bnx_get_buf() everywhere
else.

This change seems to be in keeping with the author's intent, but
it looks like the code broke at some point.

Thanks to Jarle Greipsland, David Dudley, and others for reporting
this bug and for testing patches.
 1.20 09-Sep-2008  mhitch branches: 1.20.2; 1.20.4; 1.20.10;
Add support for SerDes controllers; from the OpenBSD driver. Tested on a
Dell Blade server by me, and an HP Blade server by Havard.
 1.19 09-Sep-2008  mhitch In bnx_release_resources(), don't de-reference a NULL pointer if the
rx_mbuf_map has not been allocated yet. From Havard Eidnes.
 1.18 07-Feb-2008  dyoung branches: 1.18.6; 1.18.10; 1.18.12; 1.18.16;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.17 06-Feb-2008  joerg Don't use misaligned PCI config access. Reported by Christoph Egger.
 1.16 31-Dec-2007  dyoung Don't buffer packets while the link is down, but drop them on the
floor like most other ethernet drivers do.

bnx(4) has "vanilla" MII media-handling, so use ether_mediachange
and ether_mediastatus.
 1.15 30-Dec-2007  dyoung For consistency with other softc members, s/ethercom/bnx_ec/.
 1.14 29-Dec-2007  dyoung Get rid of bnx_suspend_resume(), it did redundant resets.

Merge bnx_if_stop() and bnx_stop(). Handle bnx_stop(, 1) by doing
a reset.

Protect the bnx_stop() call in bnx_detach() with splnet().

Thanks to joerg@ for suggesting the above.

In bnx_stop(), deactivate the PHYs with mii_down(). Return right
away if !IFF_RUNNING.

Use LIST_EMPTY().

In bnx_ifmedia_upd(), propagate all mii_mediachg() return codes to
the caller except for ENXIO, which just means that the PHY is
suspended. In bnx_init(), propagate bnx_ifmedia_upd() return codes
to the caller.

In bnx_intr(), replace a common subexpression with a variable,
'sblk'.

In bnx_tick(), let the MII bus keep ticking after the link is up:
check link status and exit after calling mii_tick(), not before.
 1.13 26-Dec-2007  dyoung Add device suspend/resume/detach. (Tested with drvctl -S bnx0,
drvctl -Q bnx0, drvctl -d bnx0.)

Separate device_t storage from softc storage and use CFATTACH_DECL_NEW().
 1.12 15-Dec-2007  perry __FUNCTION__ -> __func__
 1.11 04-Dec-2007  dyoung branches: 1.11.4;
Reprogram multicast filter after SIOCADDMULTI / SIOCDELMULTI.
Fixes IPv6 stateless address configuration problems reported on
tech-net@. Patch tested and found to work by Martti Kuparinen.
 1.10 09-Nov-2007  martti branches: 1.10.2;
Added missing newline.
 1.9 29-Aug-2007  dyoung branches: 1.9.4; 1.9.6;
Constify: LLADDR() -> CLLADDR().
 1.8 09-Aug-2007  bouyer branches: 1.8.2;
Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work.
 1.7 09-Jul-2007  ad branches: 1.7.2; 1.7.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6 10-Apr-2007  bouyer Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.5 09-Apr-2007  bouyer RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.

Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.
 1.4 09-Apr-2007  bouyer Protect bnx_tick() with splnet.

Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.

From scottl@FreeBSD

revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.

From scottl@FreeBSD

revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.

revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.

From scottl@FreeBSD

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

revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.

In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.

Correct a couple of inaccurate comments.

From jdp@FreeBSD

revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.

From Mike Karels via FreeBSD

Tested by Brad, biorn@ and Johan M:son Lindman
 1.3 04-Mar-2007  christos branches: 1.3.2; 1.3.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 15-Feb-2007  bouyer branches: 1.2.2;
Fix 2 panics with DIAGNOSTIC kernels:
- remove the code to bring down the PHY in bnx_stop(), it's wrong
(ifm_data isn't updated) and lead to a panic in mii_phy_setmedia(),
or reading past the end mii_media_table[].
- make sure the dma_map matches the mbuf in the rx structures. We would
sync/unload the wrong map, leading to a DIAGNOSTIC panic, or eventually
leaking memory when bounce buffers are needed.
 1.1 17-Dec-2006  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.1.10.2 12-Jan-2007  ad Sync with head.
 1.1.10.1 17-Dec-2006  ad file if_bnx.c was added on branch newlock2 on 2007-01-12 00:57:41 +0000
 1.1.8.8 11-Feb-2008  yamt sync with head.
 1.1.8.7 21-Jan-2008  yamt sync with head
 1.1.8.6 07-Dec-2007  yamt sync with head
 1.1.8.5 15-Nov-2007  yamt sync with head.
 1.1.8.4 03-Sep-2007  yamt sync with head.
 1.1.8.3 26-Feb-2007  yamt sync with head.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 17-Dec-2006  yamt file if_bnx.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:44 +0000
 1.1.6.6 19-Nov-2007  bouyer Pull up following revision(s) (requested by martti in ticket #1876):
sys/dev/pci/if_bnx.c: revision 1.10
Added missing newline.
 1.1.6.5 17-Sep-2007  msaitoh Pull up following revision(s) (requested by bouyer in ticket #1827):
sys/dev/pci/if_bnx.c: revision 1.8
Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work.
 1.1.6.4 25-Apr-2007  ghen Pull up following revision(s) (requested by bouyer in ticket #1762):
sys/dev/pci/if_bnx.c: revision 1.4
sys/dev/pci/if_bnx.c: revision 1.5
sys/dev/pci/if_bnx.c: revision 1.6
sys/dev/pci/if_bnxreg.h: revision 1.2
Protect bnx_tick() with splnet.
Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.
From scottl@FreeBSD
revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.
From scottl@FreeBSD
revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.
revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.
From scottl@FreeBSD
revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.
revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.
In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.
Correct a couple of inaccurate comments.
From jdp@FreeBSD
revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.
From Mike Karels via FreeBSD
Tested by Brad, biorn@ and Johan M:son Lindman
RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.
Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.
Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.1.6.3 19-Feb-2007  tron Pull up following revision(s) (requested by bouyer in ticket #1667):
sys/dev/pci/if_bnx.c: revision 1.2
Fix 2 panics with DIAGNOSTIC kernels:
- remove the code to bring down the PHY in bnx_stop(), it's wrong
(ifm_data isn't updated) and lead to a panic in mii_phy_setmedia(),
or reading past the end mii_media_table[].
- make sure the dma_map matches the mbuf in the rx structures. We would
sync/unload the wrong map, leading to a DIAGNOSTIC panic, or eventually
leaking memory when bounce buffers are needed.
 1.1.6.2 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1608):
sys/arch/i386/conf/INSTALL: revision 1.299 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.20 via patch
sys/arch/i386/conf/GENERIC: revision 1.803 via patch
sys/dev/pci/files.pci: revision 1.275 via patch
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218 via patch
sys/arch/amd64/conf/GENERIC: revision 1.123 via patch
sys/dev/pci/if_bnx.c: revision 1.1 via patch
share/man/man4/bnx.4: revision 1.1-1.2 via patch
distrib/sets/lists/man/mi: revision 1.959 via patch
sys/arch/amd64/conf/INSTALL: revision 1.62 via patch
sys/dev/microcode/bnx/bnxfw.h: revision 1.1-1.2 via patch
sys/dev/pci/if_bnxreg.h: revision 1.1 via patch
share/man/man4/Makefile: revision 1.417 via patch
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112 via patch
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
Add a NetBSD RCS tag.
Nx -> Ox; remove trailing whitespace.
 1.1.6.1 17-Dec-2006  ghen file if_bnx.c was added on branch netbsd-3 on 2006-12-23 14:43:47 +0000
 1.1.4.7 01-Feb-2008  riz Pull up following revision(s) (requested by dyoung in ticket #1011):
sys/dev/pci/if_bnx.c: revision 1.11
Reprogram multicast filter after SIOCADDMULTI / SIOCDELMULTI.
Fixes IPv6 stateless address configuration problems reported on
tech-net@. Patch tested and found to work by Martti Kuparinen.
 1.1.4.6 25-Nov-2007  xtraeme Pull up following revision(s) (requested by martti in ticket #986):
sys/dev/pci/if_bnx.c: revision 1.10
Added missing newline.
 1.1.4.5 24-Aug-2007  liamjfoy branches: 1.1.4.5.2;
Pull up following revision(s) (requested by bouyer in ticket #826):
sys/dev/pci/if_bnx.c: revision 1.8
Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work.
 1.1.4.4 20-Apr-2007  pavel branches: 1.1.4.4.2;
Pull up following revision(s) (requested by bouyer in ticket #566):
sys/dev/pci/if_bnx.c: revision 1.4
sys/dev/pci/if_bnx.c: revision 1.5
sys/dev/pci/if_bnx.c: revision 1.6
sys/dev/pci/if_bnxreg.h: revision 1.2
Protect bnx_tick() with splnet.
Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.
From scottl@FreeBSD
revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.
From scottl@FreeBSD
revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.
revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.
From scottl@FreeBSD
revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.
revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.
In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.
Correct a couple of inaccurate comments.
From jdp@FreeBSD
revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.
From Mike Karels via FreeBSD
Tested by Brad, biorn@ and Johan M:son Lindman

RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.
Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.

Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.1.4.3 17-Feb-2007  tron Pull up following revision(s) (requested by bouyer in ticket #451):
sys/dev/pci/if_bnx.c: revision 1.2
Fix 2 panics with DIAGNOSTIC kernels:
- remove the code to bring down the PHY in bnx_stop(), it's wrong
(ifm_data isn't updated) and lead to a panic in mii_phy_setmedia(),
or reading past the end mii_media_table[].
- make sure the dma_map matches the mbuf in the rx structures. We would
sync/unload the wrong map, leading to a DIAGNOSTIC panic, or eventually
leaking memory when bounce buffers are needed.
 1.1.4.2 21-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #287):
sys/arch/i386/conf/INSTALL: revision 1.299
sys/arch/i386/conf/XEN2_DOM0: revision 1.20
sys/arch/i386/conf/GENERIC: revision 1.803
sys/dev/pci/files.pci: revision 1.275
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218
sys/arch/amd64/conf/GENERIC: revision 1.123
sys/dev/pci/if_bnx.c: revision 1.1
share/man/man4/bnx.4: revision 1.1
distrib/sets/lists/man/mi: revision 1.959
sys/arch/amd64/conf/INSTALL: revision 1.62
sys/dev/microcode/bnx/bnxfw.h: revision 1.1
sys/arch/i386/conf/ALL: revision 1.76
sys/dev/pci/if_bnxreg.h: revision 1.1
share/man/man4/Makefile: revision 1.417
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.1.4.1 17-Dec-2006  tron file if_bnx.c was added on branch netbsd-4 on 2006-12-21 13:44:01 +0000
 1.1.4.5.2.1 25-Nov-2007  xtraeme Pull up following revision(s) (requested by martti in ticket #986):
sys/dev/pci/if_bnx.c: revision 1.10
Added missing newline.
 1.1.4.4.2.3 03-Jun-2008  skrll Sync with netbsd-4.
 1.1.4.4.2.2 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.1.4.4.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.2.2 18-Dec-2006  yamt sync with head.
 1.1.2.1 17-Dec-2006  yamt file if_bnx.c was added on branch yamt-splraiseipl on 2006-12-18 11:42:13 +0000
 1.2.2.2 15-Apr-2007  yamt sync with head.
 1.2.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.4.1 11-Jul-2007  mjf Sync with head.
 1.3.2.4 09-Oct-2007  ad Sync with head.
 1.3.2.3 20-Aug-2007  ad Sync with HEAD.
 1.3.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.3.2.1 10-Apr-2007  ad Sync with head.
 1.7.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.7.6.3 11-Nov-2007  joerg Sync with HEAD.
 1.7.6.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.7.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.7.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.7.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.8.2.3 23-Mar-2008  matt sync with HEAD
 1.8.2.2 09-Jan-2008  matt sync with HEAD
 1.8.2.1 06-Nov-2007  matt sync with HEAD
 1.9.6.4 18-Feb-2008  mjf Sync with HEAD.
 1.9.6.3 27-Dec-2007  mjf Sync with HEAD.
 1.9.6.2 08-Dec-2007  mjf Sync with HEAD.
 1.9.6.1 19-Nov-2007  mjf Sync with HEAD.
 1.9.4.1 13-Nov-2007  bouyer Sync with HEAD
 1.10.2.2 26-Dec-2007  ad Sync with head.
 1.10.2.1 08-Dec-2007  ad Sync with head.
 1.11.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.18.16.1 19-Oct-2008  haad Sync with HEAD.
 1.18.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.18.10.5 11-Aug-2010  yamt sync with head.
 1.18.10.4 11-Mar-2010  yamt sync with head
 1.18.10.3 16-Sep-2009  yamt sync with head
 1.18.10.2 16-May-2009  yamt sync with head
 1.18.10.1 04-May-2009  yamt sync with head.
 1.18.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.20.10.1 21-Apr-2010  matt sync to netbsd-5
 1.20.4.3 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.20.4.2 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1268):
sys/dev/mii/miidevs: revision 1.90
sys/dev/pci/pcidevs: revision 1.1001
sys/dev/mii/brgphy.c: revision 1.51
sys/dev/microcode/bnx/bnxfw.h: revision 1.3
sys/dev/pci/if_bnx.c: revision 1.29
sys/dev/pci/if_bnxreg.h: revision 1.9
sys/dev/pci/if_bnx.c: revision 1.30

Add support for the Broadcom BCM5709 and BCM5716 chips. Upgrade
the B06 firmware and add the B09 firmware required by the BCM5709.
Replace TX dmamap array with a dynamically-grown list.
Support associated BCM5709CAX and BCM5709C PHYs.
 1.20.4.1 18-May-2009  bouyer Pull up following revision(s) (requested by kefren in ticket #760):
sys/dev/pci/if_bnx.c: revision 1.21
Protect against spurious "bnx0: Double mbuf allocation failure!"
panics.
Extract a new function, bnx_add_buf(), from bnx_get_buf().
bnx_add_buf() just tries to add an mbuf to the Rx chain. bnx_get_buf()
tries to allocate an mbuf, first, and then to add the mbuf to the
chain. Use bnx_add_buf() to try to put an mbuf that we took off
of the chain back onto the chain, and use bnx_get_buf() everywhere
else.
This change seems to be in keeping with the author's intent, but
it looks like the code broke at some point.
Thanks to Jarle Greipsland, David Dudley, and others for reporting
this bug and for testing patches.
 1.20.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.20.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.21.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.2.3 31-May-2011  rmind sync with head
 1.32.2.2 05-Mar-2011  rmind sync with head
 1.32.2.1 30-May-2010  rmind sync with head
 1.41.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.41.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.8.2 07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:

sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6

Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
 1.45.8.1 07-Mar-2012  riz Pull up following revision(s) (requested by bouyer in ticket #100):
sys/dev/pci/if_bnx.c: revision 1.46
bnx_start() is not MP-safe, so do not create the bnx_alloc_pkts()'s
workqueue MPSAFE. This could lead to bnx_start() being running at
the same time on 2 CPUs, with packets being sent twice.
Problem found and reported by Beverly Schwartz and Greg Troxel.
 1.45.6.1 11-Mar-2012  mrg sync to latest -current
 1.45.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.2.2 30-Oct-2012  yamt sync with head
 1.45.2.1 17-Apr-2012  yamt sync with head
 1.47.2.3 03-Dec-2017  jdolecek update from HEAD
 1.47.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.47.2.1 23-Jun-2013  tls resync from head
 1.48.4.1 18-May-2014  rmind sync with head
 1.51.2.1 10-Aug-2014  tls Rebase.
 1.57.4.3 05-Feb-2017  skrll Sync with HEAD
 1.57.4.2 09-Jul-2016  skrll Sync with HEAD
 1.57.4.1 19-Mar-2016  skrll Sync with HEAD
 1.59.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.61.8.3 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.61.8.2 09-May-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #814):

sys/dev/pci/if_bnxvar.h: revision 1.7
sys/dev/pci/if_bnx.c: revision 1.64

- Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
 1.61.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.63.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.63.2.3 18-Jan-2019  pgoyette Synch with HEAD
 1.63.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.63.2.1 21-May-2018  pgoyette Sync with HEAD
 1.65.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.65.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.65.2.1 10-Jun-2019  christos Sync with HEAD
 1.89.2.1 29-Feb-2020  ad Sync with head.
 1.105.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.115.2.1 02-Aug-2025  perseant Sync with HEAD
 1.30 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.29 05-Feb-2024  andvar triple "r" typos, mainly s/interrrupt/interrupt/ in comments and one definition.
 1.28 12-Dec-2021  andvar fix various typos, mainly in comments.
 1.27 13-Feb-2021  jakllsch Curb aprint_*() abuse in bnx(4)
 1.26 24-May-2019  msaitoh branches: 1.26.10;
Whilespace fix. No functional change.
 1.25 05-Apr-2019  msaitoh Add BNX_PCICFG_DEVICE_CONTROL.
 1.24 05-Apr-2019  msaitoh - Allow time for the management firmware to enter the running state.
- Enable/Disable management frames (NC-SI) to flow to the MCP if MFW exists.
- Print the boot code version, management firmware version and some flags.
- Gbps -> GT/s for PCIe speed.
- Use aprint_*() in bnx_print_adapter_info().
- Use braces for some macors' argument.
- Remove unused macros.
- KNF.
 1.23 04-Apr-2019  msaitoh No functional change. This change reduces diff against DragonFly:
- Fix BNX_PCI_GRC_WINDOW_ADDR_VALUE's name. Note that this macro is not used.
- Whitespace change.
- Sort some lines.
 1.22 29-Mar-2019  msaitoh - Use m_defrag() when bus_dmamap_load_mbuf() returned with EFBIG.
- Style change to reduce diff against {Free,Open}BSD.
- Make it compilable with BNX_DEBUG.
- Use __nothing for null macro.
 1.21 28-Mar-2019  msaitoh No functional change:
- Fix DB_AND_RANDOMFALSE(). It has no real bug because the macro is not used
from anywhere.
- Wse const.
- Whitespace change.
 1.20 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.19 03-Jun-2018  maxv branches: 1.19.2;
Constify the microcode variables used by BNX. This moves 38 pages of kernel
memory from .data to .rodata.
 1.18 01-Jul-2014  msaitoh branches: 1.18.26;
Print some information (ASIC revision, PCI status, etc). From FreeBSD.
 1.17 01-Jul-2014  msaitoh No functional change.
- s/u_int/uint/
- Modify comment a bit (sync with OpenBSD)
 1.16 24-Jun-2014  msaitoh No functional change:
- Tabify.
- Remove trailing white spaces.
- Fix typo in comment.
 1.15 17-Jun-2014  msaitoh - Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4). The auto negotiation may have some bugs.
- Add 2500SX support (not tested).
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
 1.14 02-May-2011  jym branches: 1.14.10; 1.14.14; 1.14.28;
Fix BCM5709 PHY detection for ethernet PHYs (the SerDes case being already
handled):
- export bge(4) and bnx(4) CHIP ID and PHY flags to brgphy(4). Move to
"unsigned int" rather than "int", and reuse the same softc members for
chipid and phyflags (behavior controlled by the sc_isbge/isbnx boolean).
- apply bug fix for revisions A and B, so that autonegotiation can
complete (from OpenBSD).

Bug reported by Rivo Nurges via private mail, patch tested and
confirmed working by him (with thanks!)
 1.13 11-Dec-2010  martin branches: 1.13.2;
Sanitize names a bit, still could use more namespace cleanup
 1.12 11-Dec-2010  martin Namespace police: don't use very broad names like CTX_MASK (which accidently
collide with sparc* specific MD macros), mechanically prefix with BNX_.
 1.11 09-Dec-2010  jym Similar to bge(4), split if_bnxreg.h in two parts:
- if_bnxreg.h: general register values, flags... for bnx(4), that can
be included in other drivers
- if_bnxvar.h: PCI or device specific code (device state data, debug
macros etc.), which should remain private to bnx(4)

No comments, no objections on current-users@.

See discussion:
http://mail-index.netbsd.org/current-users/2010/12/01/msg014926.html
 1.10 19-Jan-2010  pooka branches: 1.10.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.9 18-Nov-2009  bouyer Sync with OpenBSD: if_bnx.c,v 1.85. Major changes:
Add support for the Broadcom BCM5709 and BCM5716 chips. This upgrade
the B06 firmware, and add the B09 firmware required by the BCM5709.
Remplace TX dmamap array with a dynamically-grown list.

Tested with:
bnx0 at pci4 dev 0 function 0: Broadcom NetXtreme II BCM5708 1000Base-T
and
bnx0 at pci0 dev 0 function 0: Broadcom NetXtreme II BCM5709 1000Base-SX
 1.8 14-Apr-2009  dyoung Delete two unused data members, the powerhook and the shutdownhook
handles.
 1.7 24-Jun-2008  gmcgarry branches: 1.7.4; 1.7.6; 1.7.10; 1.7.14;
Replace gcc variadic macros with c99 variadic macros.
 1.6 06-Feb-2008  joerg branches: 1.6.6; 1.6.10; 1.6.12; 1.6.14;
Don't use misaligned PCI config access. Reported by Christoph Egger.
 1.5 31-Dec-2007  dyoung Don't buffer packets while the link is down, but drop them on the
floor like most other ethernet drivers do.

bnx(4) has "vanilla" MII media-handling, so use ether_mediachange
and ether_mediastatus.
 1.4 30-Dec-2007  dyoung For consistency with other softc members, s/ethercom/bnx_ec/.
 1.3 26-Dec-2007  dyoung Add device suspend/resume/detach. (Tested with drvctl -S bnx0,
drvctl -Q bnx0, drvctl -d bnx0.)

Separate device_t storage from softc storage and use CFATTACH_DECL_NEW().
 1.2 09-Apr-2007  bouyer branches: 1.2.10; 1.2.16; 1.2.18; 1.2.22;
Protect bnx_tick() with splnet.

Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.

From scottl@FreeBSD

revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.

From scottl@FreeBSD

revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.

revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.

From scottl@FreeBSD

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

revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.

In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.

Correct a couple of inaccurate comments.

From jdp@FreeBSD

revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.

From Mike Karels via FreeBSD

Tested by Brad, biorn@ and Johan M:son Lindman
 1.1 17-Dec-2006  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12; 1.1.16; 1.1.18;
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.1.18.1 11-Jul-2007  mjf Sync with head.
 1.1.16.1 10-Apr-2007  ad Sync with head.
 1.1.12.1 15-Apr-2007  yamt sync with head.
 1.1.10.2 12-Jan-2007  ad Sync with head.
 1.1.10.1 17-Dec-2006  ad file if_bnxreg.h was added on branch newlock2 on 2007-01-12 00:57:41 +0000
 1.1.8.5 11-Feb-2008  yamt sync with head.
 1.1.8.4 21-Jan-2008  yamt sync with head
 1.1.8.3 03-Sep-2007  yamt sync with head.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 17-Dec-2006  yamt file if_bnxreg.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:44 +0000
 1.1.6.3 25-Apr-2007  ghen Pull up following revision(s) (requested by bouyer in ticket #1762):
sys/dev/pci/if_bnx.c: revision 1.4
sys/dev/pci/if_bnx.c: revision 1.5
sys/dev/pci/if_bnx.c: revision 1.6
sys/dev/pci/if_bnxreg.h: revision 1.2
Protect bnx_tick() with splnet.
Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.
From scottl@FreeBSD
revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.
From scottl@FreeBSD
revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.
revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.
From scottl@FreeBSD
revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.
revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.
In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.
Correct a couple of inaccurate comments.
From jdp@FreeBSD
revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.
From Mike Karels via FreeBSD
Tested by Brad, biorn@ and Johan M:son Lindman
RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.
Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.
Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.1.6.2 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1608):
sys/arch/i386/conf/INSTALL: revision 1.299 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.20 via patch
sys/arch/i386/conf/GENERIC: revision 1.803 via patch
sys/dev/pci/files.pci: revision 1.275 via patch
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218 via patch
sys/arch/amd64/conf/GENERIC: revision 1.123 via patch
sys/dev/pci/if_bnx.c: revision 1.1 via patch
share/man/man4/bnx.4: revision 1.1-1.2 via patch
distrib/sets/lists/man/mi: revision 1.959 via patch
sys/arch/amd64/conf/INSTALL: revision 1.62 via patch
sys/dev/microcode/bnx/bnxfw.h: revision 1.1-1.2 via patch
sys/dev/pci/if_bnxreg.h: revision 1.1 via patch
share/man/man4/Makefile: revision 1.417 via patch
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112 via patch
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
Add a NetBSD RCS tag.
Nx -> Ox; remove trailing whitespace.
 1.1.6.1 17-Dec-2006  ghen file if_bnxreg.h was added on branch netbsd-3 on 2006-12-23 14:43:47 +0000
 1.1.4.3 20-Apr-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #566):
sys/dev/pci/if_bnx.c: revision 1.4
sys/dev/pci/if_bnx.c: revision 1.5
sys/dev/pci/if_bnx.c: revision 1.6
sys/dev/pci/if_bnxreg.h: revision 1.2
Protect bnx_tick() with splnet.
Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.
From scottl@FreeBSD
revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.
From scottl@FreeBSD
revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.
revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.
From scottl@FreeBSD
revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.
revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.
In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.
Correct a couple of inaccurate comments.
From jdp@FreeBSD
revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.
From Mike Karels via FreeBSD
Tested by Brad, biorn@ and Johan M:son Lindman

RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.
Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.

Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.1.4.2 21-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #287):
sys/arch/i386/conf/INSTALL: revision 1.299
sys/arch/i386/conf/XEN2_DOM0: revision 1.20
sys/arch/i386/conf/GENERIC: revision 1.803
sys/dev/pci/files.pci: revision 1.275
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218
sys/arch/amd64/conf/GENERIC: revision 1.123
sys/dev/pci/if_bnx.c: revision 1.1
share/man/man4/bnx.4: revision 1.1
distrib/sets/lists/man/mi: revision 1.959
sys/arch/amd64/conf/INSTALL: revision 1.62
sys/dev/microcode/bnx/bnxfw.h: revision 1.1
sys/arch/i386/conf/ALL: revision 1.76
sys/dev/pci/if_bnxreg.h: revision 1.1
share/man/man4/Makefile: revision 1.417
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.1.4.1 17-Dec-2006  tron file if_bnxreg.h was added on branch netbsd-4 on 2006-12-21 13:44:01 +0000
 1.1.2.2 18-Dec-2006  yamt sync with head.
 1.1.2.1 17-Dec-2006  yamt file if_bnxreg.h was added on branch yamt-splraiseipl on 2006-12-18 11:42:13 +0000
 1.2.22.1 02-Jan-2008  bouyer Sync with HEAD
 1.2.18.1 26-Dec-2007  ad Sync with head.
 1.2.16.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.10.2 23-Mar-2008  matt sync with HEAD
 1.2.10.1 09-Jan-2008  matt sync with HEAD
 1.6.14.1 27-Jun-2008  simonb Sync with head.
 1.6.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.6.10.2 11-Mar-2010  yamt sync with head
 1.6.10.1 04-May-2009  yamt sync with head.
 1.6.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.7.14.1 21-Apr-2010  matt sync to netbsd-5
 1.7.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.6.2 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.7.6.1 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1268):
sys/dev/mii/miidevs: revision 1.90
sys/dev/pci/pcidevs: revision 1.1001
sys/dev/mii/brgphy.c: revision 1.51
sys/dev/microcode/bnx/bnxfw.h: revision 1.3
sys/dev/pci/if_bnx.c: revision 1.29
sys/dev/pci/if_bnxreg.h: revision 1.9
sys/dev/pci/if_bnx.c: revision 1.30

Add support for the Broadcom BCM5709 and BCM5716 chips. Upgrade
the B06 firmware and add the B09 firmware required by the BCM5709.
Replace TX dmamap array with a dynamically-grown list.
Support associated BCM5709CAX and BCM5709C PHYs.
 1.7.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.4.2 31-May-2011  rmind sync with head
 1.10.4.1 05-Mar-2011  rmind sync with head
 1.13.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.28.1 10-Aug-2014  tls Rebase.
 1.14.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.10.1 07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:

sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6

Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
 1.18.26.1 25-Jun-2018  pgoyette Sync with HEAD
 1.19.2.1 10-Jun-2019  christos Sync with HEAD
 1.26.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.14 14-Jul-2020  jdolecek make bnx_wk (used to trigger bnx_alloc_pkts()) part of softc instead
of using a static variable, so it's independant for each adapter
 1.13 12-Jul-2020  jdolecek enable MSI/MSI-X if supported by adapter

tested MSI-X with Broadcom NetXtreme II BCM5709 1000Base-T
 1.12 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.11 11-Apr-2019  kamil branches: 1.11.6;
Fix CVS Id usage
 1.10 05-Apr-2019  msaitoh - Allow time for the management firmware to enter the running state.
- Enable/Disable management frames (NC-SI) to flow to the MCP if MFW exists.
- Print the boot code version, management firmware version and some flags.
- Gbps -> GT/s for PCIe speed.
- Use aprint_*() in bnx_print_adapter_info().
- Use braces for some macors' argument.
- Remove unused macros.
- KNF.
 1.9 29-Mar-2019  msaitoh Sync with OpenBSD:
- Don't need to clear if_timer during attach. (OpenBSD rev. 1.23)
- Do the minimal initialization of the firmware so that ASF always works.
From ambrisko@FreeBSD (OpenBSD rev. 1.32)
- Move the interrupt establishment till after everything in the softc is set up
(OpenBSD rev. 1.40)
- Let mii_attach() know where the PHY is located instead of scanning for it
since we know where it will be anyway and remove the code from the MII bus
read/write functions to force reading/writing from the predetermined
location. Copied from bge(4) and this is what the upstream FreeBSD bce(4)
driver has done once FreBSD gained a mii_attach().
 1.8 28-Mar-2019  msaitoh - Remove extra cast (from OpenBSD rev. 1.95)
- Add support flow control (from OpenBSD rev. 1.97 and 1.100).
The main difference between NetBSD and other *BSDs is that the flow control
does really works. The lower 8bit of BNX_L2CTX_CTX_TYPE should be 0xff
(from Linux). Note that I have NetXtremeII-PG203-R.pdf and it says the field
is reserved and should be 0.
 1.7 08-May-2018  msaitoh branches: 1.7.2;
- Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
 1.6 01-Jul-2014  msaitoh branches: 1.6.8; 1.6.22; 1.6.28;
Print some information (ASIC revision, PCI status, etc). From FreeBSD.
 1.5 01-Jul-2014  msaitoh No functional change.
- s/u_int/uint/
- Modify comment a bit (sync with OpenBSD)
 1.4 24-Jun-2014  msaitoh No functional change:
- Tabify.
- Remove trailing white spaces.
- Fix typo in comment.
 1.3 26-Apr-2012  gdt branches: 1.3.2; 1.3.12;
Use RX_PAGES for rx_bd_chain_{,r}seq.

Before, TX_PAGES was used, but no harm was done because TX_PAGES ==
RX_PAGES == 2. Found by Frank Kastenholz of BBN.
 1.2 15-Jul-2011  jym branches: 1.2.2; 1.2.6; 1.2.8;
Use a workqueue(9) to defer allocation of TX packets. Loosely inspired
from the OpenBSD bnx(4) driver.

Tested by Roger Pau Monné, roger.pau at entel.upc.edu.

Fixes kern/45051.
 1.1 09-Dec-2010  jym branches: 1.1.6;
Similar to bge(4), split if_bnxreg.h in two parts:
- if_bnxreg.h: general register values, flags... for bnx(4), that can
be included in other drivers
- if_bnxvar.h: PCI or device specific code (device state data, debug
macros etc.), which should remain private to bnx(4)

No comments, no objections on current-users@.

See discussion:
http://mail-index.netbsd.org/current-users/2010/12/01/msg014926.html
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 09-Dec-2010  rmind file if_bnxvar.h was added on branch rmind-uvmplock on 2011-03-05 20:53:39 +0000
 1.2.8.2 07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:

sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6

Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
 1.2.8.1 07-May-2012  riz Pull up following revision(s) (requested by gdt in ticket #208):
sys/dev/pci/if_bnxvar.h: revision 1.3
Use RX_PAGES for rx_bd_chain_{,r}seq.
Before, TX_PAGES was used, but no harm was done because TX_PAGES ==
RX_PAGES == 2. Found by Frank Kastenholz of BBN.
 1.2.6.1 29-Apr-2012  mrg sync to latest -current.
 1.2.2.1 23-May-2012  yamt sync with head.
 1.3.12.1 10-Aug-2014  tls Rebase.
 1.3.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.28.1 21-May-2018  pgoyette Sync with HEAD
 1.6.22.1 09-May-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #814):

sys/dev/pci/if_bnxvar.h: revision 1.7
sys/dev/pci/if_bnx.c: revision 1.64

- Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
 1.6.8.2 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.6.8.1 01-Jul-2014  sborrill file if_bnxvar.h was added on branch netbsd-5 on 2015-11-09 12:35:32 +0000
 1.7.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.11.6.1 29-Feb-2020  ad Sync with head.
 1.14 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.13 23-May-2022  rin branches: 1.13.10;
Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.12 24-Apr-2022  skrll Trailing whitespace
 1.11 26-Aug-2021  andvar Add missing RCSID in header files and one __KERNEL_RCSID().
 1.10 08-May-2021  thorpej Use pci_compatible_match().
 1.9 30-May-2020  jdolecek branches: 1.9.6;
discussed with thorpej@, and it seems it's better to allocate the bss
alignment buffer statically (as part of softc) just to be sure to not
affect performance
 1.8 30-May-2020  jdolecek constify, and make static where possible
 1.7 25-Mar-2020  thorpej - Refactor the firmware loading code into a set of common routines in the
core driver that understand how to find model-specific files before the
generic files. This greatly simplifies the firmware loading procedure
in each of the bus front ends. Adding additional firmware file types
(such as CLM files) much simpler.
- Make firmware image selection table-driven rather than a set of switch()
and if() statements.
- Add several additional firmware image entries.
 1.6 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.5 01-Nov-2018  martin Make this compilable with 32bit paddr_t.
 1.4 15-Oct-2018  maya branches: 1.4.2;
Apply OpenBSD if_bwfm_pci.c:1.25 by patrick:

Add bus_dmamap_sync(9) calls to bwfm(4) so that we make sure the data
is synced properly before the CPU or the WiFi chip access the supplied
memory. Makes PCIe-connected bwfm(4) work on ARM-based machines.
 1.3 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.2 01-Sep-2018  riastradh bwfm has only one tx descriptor; limit mbuf chains to one segment.

PR kern/53287

Can't use m_defrag because it always yields two segments.

Discussion on tech-net:
https://mail-index.netbsd.org/tech-net/2018/09/01/msg007031.html

Diagnosed and tested by maya.
 1.1 11-May-2018  maya branches: 1.1.2; 1.1.4;
add bwfm pci support, from openbsd

Tested on BCM43602.
 1.1.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.1 10-Jun-2019  christos Sync with HEAD
 1.1.2.6 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.4 20-Oct-2018  pgoyette Sync with head
 1.1.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.2.2 21-May-2018  pgoyette Sync with HEAD
 1.1.2.1 11-May-2018  pgoyette file if_bwfm_pci.c was added on branch pgoyette-compat on 2018-05-21 04:36:06 +0000
 1.4.2.3 02-Nov-2018  martin Additional pullup for ticket #1072:

sys/dev/pci/if_bwfm_pci.c 1.5

Make this compilable with 32bit paddr_t.
 1.4.2.2 31-Oct-2018  martin Backport of bfwm code, requested by maya in ticket #1072:

sys/dev/ic/bwfm.c 1.14
sys/dev/ic/bwfmreg.h 1.3
sys/dev/ic/bwfmvar.h 1.3
sys/dev/pci/if_bwfm_pci.c 1.4
sys/dev/pci/if_bwfm_pci.h 1.8
sys/dev/usb/if_bwfm_usb.c 1.8

via patch.
 1.4.2.1 15-Oct-2018  martin file if_bwfm_pci.c was added on branch netbsd-8 on 2018-10-31 09:23:00 +0000
 1.9.6.1 13-May-2021  thorpej Sync with HEAD.
 1.13.10.1 02-Aug-2025  perseant Sync with HEAD
 1.2 26-Aug-2021  andvar Add missing RCSID in header files and one __KERNEL_RCSID().
 1.1 11-May-2018  maya branches: 1.1.2; 1.1.8;
add bwfm pci support, from openbsd

Tested on BCM43602.
 1.1.8.2 31-Oct-2018  martin Backport of bfwm code, requested by maya in ticket #1072:

sys/dev/ic/bwfm.c 1.14
sys/dev/ic/bwfmreg.h 1.3
sys/dev/ic/bwfmvar.h 1.3
sys/dev/pci/if_bwfm_pci.c 1.4
sys/dev/pci/if_bwfm_pci.h 1.8
sys/dev/usb/if_bwfm_usb.c 1.8

via patch.
 1.1.8.1 11-May-2018  martin file if_bwfm_pci.h was added on branch netbsd-8 on 2018-10-31 09:23:00 +0000
 1.1.2.2 21-May-2018  pgoyette Sync with HEAD
 1.1.2.1 11-May-2018  pgoyette file if_bwfm_pci.h was added on branch pgoyette-compat on 2018-05-21 04:36:06 +0000
 1.18 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.17 08-May-2021  thorpej Use pci_compatible_match().
 1.16 09-Dec-2018  jdolecek branches: 1.16.16;
use pci_intr_establish_xname() everywhere
 1.15 07-Jul-2016  msaitoh branches: 1.15.16; 1.15.18;
KNF. Remove extra spaces. No functional change.
 1.14 29-Mar-2014  christos branches: 1.14.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.13 30-Mar-2013  christos branches: 1.13.4;
remove trailing whitespace
 1.12 26-Jul-2011  dyoung branches: 1.12.2; 1.12.12;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.11 18-May-2011  dyoung #include <sys/bus.h>, not <machine/bus.h>.
 1.10 09-Oct-2010  phx branches: 1.10.2;
Missing \n after printing device type.
 1.9 19-Jan-2010  pooka branches: 1.9.2; 1.9.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.8 26-Apr-2009  cegger branches: 1.8.2;
check error code from bwi_attach()
 1.7 26-Apr-2009  cegger fix error handling
 1.6 26-Apr-2009  cegger device_t/softc split
 1.5 26-Apr-2009  cegger prepare device_t/softc split
 1.4 23-Apr-2009  kefren Add power hooks. Proposed a couple of days ago on tech-kern@, no
objections received. Tested on Dell Inspiron 2200 with BCM4318
 1.3 10-Jan-2009  cegger branches: 1.3.2; 1.3.4; 1.3.6;
Attach on BCM4328. This chip supports 11n.
 1.2 09-Jan-2009  macallan Fix previous screwup.
This is the real bwi driver.
Ported by Taylor R. Campbell
 1.1 09-Jan-2009  macallan PCI attachment for the bwi driver
From Urban Boquist
 1.3.6.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.3.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.3.4.1 10-Jan-2009  skrll file if_bwi_pci.c was added on branch nick-hppapmap on 2009-01-19 13:18:25 +0000
 1.3.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.1 10-Jan-2009  mjf file if_bwi_pci.c was added on branch mjf-devfs2 on 2009-01-17 13:28:59 +0000
 1.8.2.3 11-Mar-2010  yamt sync with head
 1.8.2.2 04-May-2009  yamt sync with head.
 1.8.2.1 26-Apr-2009  yamt file if_bwi_pci.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:56 +0000
 1.9.4.2 31-May-2011  rmind sync with head
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.9.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.12.3 03-Dec-2017  jdolecek update from HEAD
 1.12.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.12.1 23-Jun-2013  tls resync from head
 1.12.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.4.1 18-May-2014  rmind sync with head
 1.14.6.1 09-Jul-2016  skrll Sync with HEAD
 1.15.18.1 10-Jun-2019  christos Sync with HEAD
 1.15.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.16.16.1 13-May-2021  thorpej Sync with HEAD.
 1.49 04-Oct-2025  thorpej Stop using the property dictionary directly.
 1.48 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.47 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.46 30-May-2021  joerg Unindent code to match the logical structure, ignoring the commented out if.

This code should be rewritten to use BUS_DMA_WAITOK, but that's a
project of its own.
 1.45 08-May-2021  thorpej branches: 1.45.2;
Use pci_compatible_match().
 1.44 15-Sep-2020  mrg branches: 1.44.6;
mii_detach() must come before ifmedia_fini(), otherwise mii_detach()
will have a NULL mutex and fault.

this appears to have been introduced in february, and may be a problem
in other drivers converted to use ifmedia_fini(). i've only fixed the
two that were faulting for me on sunblade 2000 during reboot.
 1.43 02-Jul-2020  msaitoh prop_data_data_nocopy -> prop_data_value
 1.42 08-Mar-2020  thorpej Use BUS_ADDR_{HI,LO}32().
 1.41 01-Mar-2020  thorpej Use the 64-bit PCI DMA tag if avalable.
 1.40 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.39 04-Feb-2020  thorpej Use ifmedia_fini().
 1.38 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.37 26-Dec-2019  msaitoh branches: 1.37.2;
Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.
 1.36 21-Nov-2019  msaitoh Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.
 1.35 28-May-2019  msaitoh branches: 1.35.2;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.34 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.33 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.32 06-Feb-2019  msaitoh Fix a bug that all ports' MAC address become the last port's address on
Non-OF environment.

The Saturn multi port card has only one VPD ROM and all ports share it.
If the card has four port, it has four "local-mac-address" entries.
Before this commit, the code keep the last one and use it for all ports.
The Saturn four port card has three bridge.

e.g.
 1.31 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.30 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.29 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.28 15-Nov-2018  maxv Remove the 'copy' argument from m_devget(), unused. While here rename
off0->off.
 1.27 26-Jun-2018  msaitoh branches: 1.27.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.26 15-Dec-2016  ozaki-r branches: 1.26.8; 1.26.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.25 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.24 09-Feb-2016  ozaki-r branches: 1.24.2;
Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.23 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.22 10-Aug-2014  tls branches: 1.22.4;
Merge tls-earlyentropy branch into HEAD.
 1.21 29-Mar-2014  christos branches: 1.21.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.20 13-Sep-2013  martin Remove unused variables
 1.19 30-Mar-2013  christos branches: 1.19.4;
remove trailing whitespace
 1.18 22-Jul-2012  matt branches: 1.18.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.17 03-Feb-2012  martin Add missing <sys/rnd.h> include, ack: jdc@
 1.16 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.15 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.14 29-Aug-2011  jmcneill branches: 1.14.2; 1.14.6;
have pci register itself as a module, and make PCI driver modules depend on it
 1.13 07-Jan-2011  jmcneill support building cas(4) as a module
 1.12 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.11 14-Jul-2010  jnemeth When searching PROM data to get a MAC address, search for National
Semiconductor Saturn data as well as Sun Cassini data.
 1.10 14-Jul-2010  jnemeth Don't leak kernel stack data when an enaddr can't be found.
 1.9 17-Jun-2010  mrg disable interrupts when resetting the device.
 1.8 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.7 11-Mar-2010  mrg branches: 1.7.2; 1.7.4;
various aprint_* fixes.
 1.6 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.5 22-Jan-2010  jdc branches: 1.5.2;
Remove port-specific code for determining MAC address, and use device
properties instead (c.f. gem(4) and hme(4)).
 1.4 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.3 17-Jan-2010  jdc Mask out (disable) cas interrupts on detach and suspend.
(Re-)enable interrupts on resume.
 1.2 09-Jan-2010  martin adapt to recent pmf changes
 1.1 07-Jan-2010  jdc Driver for Sun Cassini/Cassini+ (GigaSwift) Ethernet (also known as
National Semiconductor Saturn).
Based on the OpenBSD driver written by Mark Kettenis:
detach support added
MAC address lookup modified (only tested on sparc64)

Tested on single GigaSwift (UTP and MMF) and quad GigaSwift PCI cards.
 1.5.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.5.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.4.3 05-Mar-2011  rmind sync with head
 1.7.4.2 03-Jul-2010  rmind sync with head
 1.7.4.1 30-May-2010  rmind sync with head
 1.7.2.3 11-Aug-2010  yamt sync with head.
 1.7.2.2 11-Mar-2010  yamt sync with head
 1.7.2.1 11-Mar-2010  yamt file if_cas.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:45 +0000
 1.14.6.1 18-Feb-2012  mrg merge to -current.
 1.14.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.2 30-Oct-2012  yamt sync with head
 1.14.2.1 17-Apr-2012  yamt sync with head
 1.18.2.3 03-Dec-2017  jdolecek update from HEAD
 1.18.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.2.1 23-Jun-2013  tls resync from head
 1.19.4.1 18-May-2014  rmind sync with head
 1.21.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.22.4.3 05-Feb-2017  skrll Sync with HEAD
 1.22.4.2 19-Mar-2016  skrll Sync with HEAD
 1.22.4.1 06-Jun-2015  skrll Sync with HEAD
 1.24.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.26.14.4 26-Jan-2019  pgoyette Sync with HEAD
 1.26.14.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.26.14.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.26.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.26.8.1 05-Dec-2019  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1464):
sys/dev/pci/if_alc.c 1.44 via patch
sys/dev/pci/if_ale.c 1.35-1.36 via patch
sys/dev/pci/if_cas.c 1.36 via patch
- Fix a bug that IFF_ALLMULTI is almost always set.
- Whitespace fixes.
 1.27.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.27.2.1 10-Jun-2019  christos Sync with HEAD
 1.35.2.2 21-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #626):

sys/arch/amd64/conf/GENERIC: revision 1.552
sys/dev/pci/if_casreg.h: revision 1.2
sys/dev/pci/if_cas.c: revision 1.37
share/man/man4/cas.4: revision 1.4
sys/dev/pci/if_casvar.h: revision 1.7

Update supported device list with part number. From FreeBSD.

Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.

Add cas(4).
 1.35.2.1 26-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #483):

sys/dev/pci/if_cas.c: revision 1.36
sys/dev/pci/if_alc.c: revision 1.44
sys/dev/pci/if_ale.c: revision 1.35
sys/dev/pci/if_ale.c: revision 1.36
sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

Remove accidentally committed debug code. Sorry.
 1.37.2.1 29-Feb-2020  ad Sync with head.
 1.44.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.44.6.1 13-May-2021  thorpej Sync with HEAD.
 1.45.2.1 31-May-2021  cjep sync with head
 1.7 01-Mar-2025  andvar s/compete/complete/ in comment.
 1.6 28-May-2022  andvar branches: 1.6.10;
fix various typos, mainly in comments.
 1.5 09-Dec-2021  andvar s/atached/attached/ and removing double s in state.
 1.4 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.3 29-Jan-2020  msaitoh u_int{32,64}_t -> uint{32,64}_t. No functional change.
 1.2 26-Dec-2019  msaitoh branches: 1.2.2;
Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.
 1.1 07-Jan-2010  jdc branches: 1.1.4; 1.1.66; 1.1.72;
Driver for Sun Cassini/Cassini+ (GigaSwift) Ethernet (also known as
National Semiconductor Saturn).
Based on the OpenBSD driver written by Mark Kettenis:
detach support added
MAC address lookup modified (only tested on sparc64)

Tested on single GigaSwift (UTP and MMF) and quad GigaSwift PCI cards.
 1.1.72.1 21-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #626):

sys/arch/amd64/conf/GENERIC: revision 1.552
sys/dev/pci/if_casreg.h: revision 1.2
sys/dev/pci/if_cas.c: revision 1.37
share/man/man4/cas.4: revision 1.4
sys/dev/pci/if_casvar.h: revision 1.7

Update supported device list with part number. From FreeBSD.

Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.

Add cas(4).
 1.1.66.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.2 11-Mar-2010  yamt sync with head
 1.1.4.1 07-Jan-2010  yamt file if_casreg.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:45 +0000
 1.2.2.1 29-Feb-2020  ad Sync with head.
 1.6.10.1 02-Aug-2025  perseant Sync with HEAD
 1.9 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.8 29-Jan-2020  msaitoh u_int{32,64}_t -> uint{32,64}_t. No functional change.
 1.7 26-Dec-2019  msaitoh branches: 1.7.2;
Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.
 1.6 05-Mar-2019  msaitoh branches: 1.6.4;
Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.5 14-Apr-2015  riastradh branches: 1.5.18;
Include <sys/rndsource.h> where it is actually used.

I had removed <sys/rnd.h> from files that didn't mention anything of
the rnd(9) API. But they included other files which assumed
<sys/rnd.h> had already been included.
 1.4 02-Feb-2012  tls branches: 1.4.6; 1.4.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.3 19-Nov-2011  tls branches: 1.3.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.2 18-Jan-2010  jdc branches: 1.2.4; 1.2.14;
Add definitions for CAS_INTR_REG and CAS_INTR_PCI.
 1.1 07-Jan-2010  jdc Driver for Sun Cassini/Cassini+ (GigaSwift) Ethernet (also known as
National Semiconductor Saturn).
Based on the OpenBSD driver written by Mark Kettenis:
detach support added
MAC address lookup modified (only tested on sparc64)

Tested on single GigaSwift (UTP and MMF) and quad GigaSwift PCI cards.
 1.2.14.1 17-Apr-2012  yamt sync with head
 1.2.4.2 11-Mar-2010  yamt sync with head
 1.2.4.1 18-Jan-2010  yamt file if_casvar.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:45 +0000
 1.3.2.1 18-Feb-2012  mrg merge to -current.
 1.4.24.1 06-Jun-2015  skrll Sync with HEAD
 1.4.6.1 03-Dec-2017  jdolecek update from HEAD
 1.5.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.18.1 10-Jun-2019  christos Sync with HEAD
 1.6.4.1 21-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #626):

sys/arch/amd64/conf/GENERIC: revision 1.552
sys/dev/pci/if_casreg.h: revision 1.2
sys/dev/pci/if_cas.c: revision 1.37
share/man/man4/cas.4: revision 1.4
sys/dev/pci/if_casvar.h: revision 1.7

Update supported device list with part number. From FreeBSD.

Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.

Add cas(4).
 1.7.2.1 29-Feb-2020  ad Sync with head.
 1.166 19-Jan-2020  thorpej Remove the de(4) driver, which has long since been supplanted by the
tlp(4) driver, which supports more chips and more board variants.
 1.165 06-Jan-2020  msaitoh branches: 1.165.2;
Protect ec_multicnt.
 1.164 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.163 29-May-2019  msaitoh branches: 1.163.2;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.162 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.161 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.160 21-May-2019  msaitoh - I think it's not required to test "#if defined(IFM_ETHER)" now.
- Fix compile error. It seems no one use this file. Is it OK to remove this
file?
 1.159 24-Apr-2019  msaitoh Remove extra test of SIOCSIFMEDIA.
 1.158 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.157 08-Jan-2019  msaitoh KNF. No functional change.
 1.156 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.155 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.154 26-Jun-2018  msaitoh branches: 1.154.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.153 22-Jun-2018  msaitoh Remove bpf_tap() call in rx. It's done in if_percpuq_softint().
 1.152 22-Jun-2018  msaitoh It's not required to include net/bpfdesc.h. Remove it.
 1.151 19-Mar-2018  msaitoh s/been been/been/ in comment.
 1.150 15-Dec-2016  ozaki-r branches: 1.150.8; 1.150.14;
Move bpf_mtap in Tx hardware intrrupt to if_start

The intention of the change is to prevent bpf_mtap from running in
hardware interrupt context. if_start is a usual place to do bpf_mtap
on Tx.

Proposed on tech-kern and tech-net
 1.149 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.148 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.147 10-Jun-2016  ozaki-r branches: 1.147.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.146 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.145 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.144 10-Aug-2014  tls branches: 1.144.4;
Merge tls-earlyentropy branch into HEAD.
 1.143 18-May-2014  christos remove stray line accidentally committed.
 1.142 29-Mar-2014  christos branches: 1.142.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.141 30-Mar-2013  christos branches: 1.141.4;
remove trailing whitespace
 1.140 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.139 02-Feb-2012  tls branches: 1.139.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.138 13-Nov-2010  uebayasi branches: 1.138.8; 1.138.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.137 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.136 02-Feb-2010  wiz branches: 1.136.2; 1.136.4;
Add missing parentheses, found by cppcheck and reported by
Henning Petersen in PR 42718.
 1.135 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.134 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.133 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.132 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.131 29-Mar-2009  dholland Merge patch from PR 12605, which tidies up allocation of transmit DMA maps.
Generalize it to also tidy up allocation of receive DMA maps. And change a
few of the symbol names involved to (1) make sure all uses have been fixed
and (2) make it clearer what's actually going on.

Previously the driver was using DMA maps off the free list without fully
allocating them, apparently in order to save two or three lines releasing
them on error paths. According to the submitter of the PR (H.Saito) this
was causing it to reuse a map already in use when under load, resulting
in panics.

I'm not sure if that ought to have been possible or if it reflected an
interrupt handling bug somewhere else, but the change is an improvement
regardless, so we'll go with it.

Compile-tested only, but I've crosschecked the diffs and all that and it's
a pretty noninvasive change.

(Is anyone actually using this driver rather than tlp?)
 1.130 18-Mar-2009  cegger bzero -> memset
 1.129 07-Nov-2008  dyoung branches: 1.129.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.128 10-Apr-2008  cegger branches: 1.128.4; 1.128.10; 1.128.12;
use aprint_*_dev and device_xname
 1.127 07-Feb-2008  dyoung branches: 1.127.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.126 19-Oct-2007  ad branches: 1.126.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.125 01-Sep-2007  dyoung branches: 1.125.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.124 09-Jul-2007  ad branches: 1.124.2; 1.124.6; 1.124.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.123 04-Mar-2007  christos branches: 1.123.2; 1.123.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.122 24-Oct-2006  drochner branches: 1.122.4;
add zero initializers to make that compile again
 1.121 07-Sep-2006  dogcow branches: 1.121.2; 1.121.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.120 15-May-2006  christos Move the lmc match test in the right place (not in the bsdi match). From
David Boggs.
 1.119 20-Apr-2006  christos Put back the code that avoids matching the lmc card. As pointed out by David
Boggs, it does not matter if the lmc driver routine returns 100 for the match,
because if the lmc driver is loaded via an LKM after boot, the other drivers
would have claimed the card already.
 1.118 24-Dec-2005  perry branches: 1.118.4; 1.118.6; 1.118.8; 1.118.10; 1.118.12;
__inline__ -> inline
 1.117 06-Dec-2005  christos Remove the "don't match lmc cards" test, because the lmc driver returns a
match of 100 which will supersede the de and tlp match if present. If not
present, then these two drivers will fail to match an mii. Thanks to thorpej
for the explanation.
 1.116 06-Dec-2005  thorpej Don't use magic constants in previous. (Not that we should be doing this
here in the first place...)
 1.115 06-Dec-2005  christos Don't match lmc cards by accident.
 1.114 01-Jun-2005  drochner branches: 1.114.2;
more cast-qual and shadow fallout
 1.113 27-Feb-2005  perry nuke trailing whitespace
 1.112 30-Oct-2004  thorpej branches: 1.112.4; 1.112.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.111 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.110 03-May-2003  wiz branches: 1.110.2; 1.110.6;
DMA, not dma nor Dma.
 1.109 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.108 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.107 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.106 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.105 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.104 08-Jun-2002  yamt make an auto const variable static.
 1.103 13-Nov-2001  lukem branches: 1.103.8;
add RCSID
 1.102 07-Jul-2001  thorpej branches: 1.102.2;
bcmp -> memcmp
 1.101 07-Jul-2001  thorpej bzero -> memset
 1.100 07-Jul-2001  thorpej bcopy -> memcpy, strcpy
 1.99 13-Jun-2001  wiz withough -> without
 1.98 16-May-2001  lukem delint: zero sized array initalisation is a gccism
 1.97 04-Mar-2001  kim branches: 1.97.2;
Help messages appear each on their own line when
discovering additional ports on a multi-port card.
 1.96 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.95 15-Nov-2000  thorpej Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.94 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.93 28-Sep-2000  tsutsui 6 -> ETHER_ADDR_LEN
 1.92 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.91 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.90 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.89 23-Feb-2000  fair Fix a missing closing parenthesis in an error diagnostic
 1.88 15-Jan-2000  matt Fixes for 21143 and MII in full-duplex mode.
 1.87 04-Dec-1999  ragge CL* discarding.
 1.86 01-Jun-1999  thorpej branches: 1.86.2; 1.86.8;
Make sure bus mastering is enabled; some broken BIOSes don't set this
up properly.
 1.85 18-May-1999  thorpej Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.84 12-Apr-1999  cjs PR 6852 from Chris Jones <cjones@hideo.nervana.montana.edu>.
This handles the interrupt structure of Compex boards.
 1.83 01-Apr-1999  tsubai branches: 1.83.2;
Fix big-endian support.
TULIP_BUSMODE_BIGENDIAN does bswap packet buffers also, so we should use
TULIP_BUSMODE_DESC_BIGENDIAN on big-endian machines. (PR 7027)

XXX 21040 doesn't have this bit, but supporting only 21041+ is better than
nothing.
 1.82 28-Feb-1999  explorer Update to slightly altered rnd_attach_source() api
 1.81 09-Nov-1998  matt branches: 1.81.2;
Cleanup media set on Alpha. ring txpoll after setting proper tx
interrupt mask.
 1.80 25-Sep-1998  matt Fix transmit underflow messages. (\0128 != \0 128)
 1.79 22-Sep-1998  matt Fix the accton support. Only set the board type it isn't an ISV.
 1.78 15-Sep-1998  matt Fix a problem where txput could "lose" dmamaps if it couldn't actually
place the packet into the ring for some reason.
 1.77 15-Sep-1998  matt This commit fixes two bugs in the de driver. The first is that the
descriptor count gets miscounted on txprobes. The second (and more
important) is that transmit stalls should now be fixed. The problem
was not due to lack of ring resources but dmamaps. When Jason changed
the driver to use pre-allocated maps (instead of the dynamic ones I
used), and when there were no more maps, the driver just gave up instead
of calling tx_intr to free any transmitted but unreclaimed dma maps.
Since there was nothing being transmitted, no transmit interrupts
would fire to restore things (and OACTIVE prevented other transmits
from happenning). So it stayed starved until another interrupt cause
(like a received packet) "woke" it up.
 1.76 28-Aug-1998  drochner some fixes:
-use of uninitialized variable in attach (mostly harmless)
-removal of dead code in attach()
-fix of interpretation of SIA blocks on >=21142 (serious, caused strange
things with 10Mbit)
 1.75 24-Aug-1998  matt Fix bug in transmit logic that would transmits to stop. Boolean dyslexia
stricks again.
 1.74 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.73 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.72 05-Jul-1998  jonathan branches: 1.72.2;
defopt NS, NSIP.
 1.71 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.70 21-Jun-1998  matt Workaround problem with stalling output. Fix later after I've moved.
 1.69 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.68 25-May-1998  mark Don't make the inclusion of machine/intr.h alpha specific as other ports
require this as well.
 1.67 22-May-1998  matt Change 21040 modes slightly. Prevent infinite autosense loop of 21143 that
is not connected. Make TULIP_STS_LINFAIL only valid for chips with that
status bit defined.
 1.66 02-Apr-1998  mycroft Make sure to unload and recycle the DMA map for a bad received packet.
This was (indirectly) the reason for machines `hanging' (actually, looping in
tulip_rx_intr()) with de cards.
 1.65 29-Mar-1998  mycroft Oops; make the table const.
 1.64 29-Mar-1998  mycroft Use a 4-bit table to speed up the CRC even further, without increasing the
code size too much.
 1.63 29-Mar-1998  mycroft Optimize the address CRC routines a bit.
 1.62 11-Feb-1998  thorpej Don't try to dynamically create and destroy DMA maps. Instead, keep
it simple, and allocate one for each transmit and receive descriptor.

In addition to being simpler and faster, this fixes a serious memory leak
in the transmit path.
 1.61 07-Feb-1998  thorpej Properly handle error conditions from bus_dmamap_load_mbuf().
 1.60 07-Feb-1998  thorpej Use BUS_DMA_NOWAIT where appropriate. Don't create DMA maps with
BUS_DMA_ALLOCNOW.
 1.59 06-Feb-1998  matt A version of the de driver which does bus_dma. Note that it has not been
tested on any other platform other than i386. Use of bus_dma(9) can be
turned by defining TULIP_BUS_DMA_NOTX and TULIP_BUS_DMA_NORX. These allow
one to determine if the problem is in the transmit or receive path.
A problem reported by mycroft is also fixed.
 1.58 12-Jan-1998  thorpej Update for config changes.
 1.57 27-Oct-1997  thorpej Print interrupt information like all of the other PCI drivers.
 1.56 20-Oct-1997  matt branches: 1.56.2;
21142 / 21143 chips always use ISVSROM format. (print out message is
SROM checksum is invalid).
 1.55 16-Oct-1997  matt Fix pr's port-i386/4127 kern/4190 kern/3700.
 1.54 16-Oct-1997  matt Fix a thinko in last night fix. We must set the media if we have reset
the chip but if we haven't the the media isn't changing, don't do anything.
 1.53 15-Oct-1997  matt Fix media/console interaction problem on Alpha. Fix 21142/21143 problems
with 10Mb/s links.
 1.52 13-Oct-1997  explorer o Make usage of /dev/random dependant on
pseudo-device rnd # /dev/random and in-kernel generator
in config files.

o Add declaration to all architectures.

o Clean up copyright message in rnd.c, rnd.h, and rndpool.c to include
that this code is derived in part from Ted Tyso's linux code.
 1.51 10-Oct-1997  explorer Add hooks to insert timing info into the random system
 1.50 24-Sep-1997  thorpej Mimmick the logic used by other drivers to determine if we should use
memory-mapped or i/o-mapped access to the device registers, and always
choose memory-mapped if it is enabled. In particular, do _not_ explictly
disable the space we decide to not use, as this confuses some versions
of Alpha console software (which are arguably buggy because of this
problem).

Also, fix a logic error pointed out by Ross Harvey <ross@teraflop.com>
that would cause memory-mapped access to never be enabled.
 1.49 12-Sep-1997  thorpej Add missing "break;" statements in the code that determines the
media setup by the Alpha SRM console software.

From Ross Harvey <ross@teraflop.com>.
 1.48 25-Aug-1997  thorpej - Add RCS tags that got lost.
- Fix a couple of typos in PCI space configuration.
 1.47 25-Aug-1997  thorpej Merge with 970703 snapshot of Matt Thomas's de driver.
 1.46 19-Jul-1997  cgd branches: 1.46.2;
don't expect/provide pci_decompose_tag to be a MI, public function. It
wasn't intended to be to begin with, and uses of it (e.g. the one in the
'de' driver) are quite likely to be incorrect.
 1.45 09-Jun-1997  thorpej Fix a slight bogon in merge of this driver; make the device map all of
its space, and pick the space used by default based on what is appropriate
for the CPU we're running on.
 1.44 08-Jun-1997  thorpej Correct a couple of typos so that this compiles with TULIP_DEBUG,
per PR 3723, submitted by enami tsugutomo <enami@ba2.so-net.or.jp>.
 1.43 08-Jun-1997  thorpej Put back Matt Thomas's revision ID, per PR 3723, submitted by
enami tsugutomo <enami@ba2.so-net.or.jp>.
 1.42 06-Jun-1997  mellon Clean up conflicts during merge (thomas de-970603)
 1.41 07-May-1997  thorpej Merge 970327 "de" update.
 1.40 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.39 13-Apr-1997  cgd use pci_map_register(). map both mem and I/O spaces, preferring mem space
by default if it's usable, but falling back to I/O space if mem isn't usable.
If TULIP_IOMAPPED is defined (default on the x86), prefer I/O space
then fall back to mem.
 1.38 26-Mar-1997  thorpej Resolve conflicts from merge.
 1.37 23-Mar-1997  veego Resolve conflicts from merge.
 1.36 19-Mar-1997  thorpej Resolve conflicts from merge.
 1.35 17-Mar-1997  thorpej Resolve conflicts from merge.
 1.34 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.33 06-Mar-1997  thorpej Patch from Matt Thomas to deal with the fact that Pass 2.[012] of
the 21140A-A[CDE] have a buggy receiver which may hand and/or corrupt
data on receive overflows.
 1.32 13-Jan-1997  thorpej branches: 1.32.4;
Fix a couple of minor nits so that this compiles on the alpha.
Noticed by Matt Jacob (mjacob@feral.com).
 1.31 11-Jan-1997  thorpej Merge into mainline, tidy up some debug code.
 1.30 05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.29 25-Oct-1996  cgd update alpha_XXX_dmamap() invocations to match prototype.
 1.28 23-Oct-1996  cgd update drivers to use the new NetBSD/alpha DMA mapping hack, since
the old one is not workable with the new bus.h.
 1.27 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.26 13-Oct-1996  christos backout kprintf changes
 1.25 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.24 15-Jul-1996  cgd before #defining the vtophys() hack for the alpha, #undef vtophys since
it may be a macro.
 1.23 03-Jun-1996  cgd convert alpha vtophys() #defines to use __alpha_bus_XXX_dmamap(), to
get rid of the nasty (vtophys(va) | 0x40000000) expressions, and to make
the code more correct.
 1.22 13-May-1996  mycroft branches: 1.22.4;
Use intr.h.
 1.21 11-May-1996  mycroft There was no need to change ac_ipaddr here.
 1.20 07-May-1996  christos #ifdef FreeBSD out unit which is not used by NetBSD.
 1.19 07-May-1996  thorpej Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
 1.18 03-May-1996  christos Remove unused printf arguments
 1.17 01-Apr-1996  cgd fix inverted sense of tests in DE500 media select function. (Would
auto-detect as 100Mbps if 10Mbps, 10Mbps if 100Mbps.)
 1.16 30-Mar-1996  cgd make sure that chipset tags are used properly (because the alpha cares),
and include <machine/intr.h> on the alpha, for interrupt information.
(i386 will probably switch to this eventually.)
 1.15 27-Mar-1996  cgd modify these to use the new PCI interfaces:
(1) use pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register, and bus_{io,mem}_map() to map it.
(2) use pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.14 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.13 14-Mar-1996  cgd include pcireg before pcivar.h
 1.12 11-Mar-1996  cgd mostly convert to use interfaces provided by <machine/bus.h>. (For now,
assumes that pci_map_mem/pci_map_io provide interfaces which utilitize
bus_{io,mem}_handle_t's, or types which are compatible. This works on the
i386, and will change eventually anyway.)
 1.11 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.10 23-Dec-1995  tls merge latest Thomas version with our minimal changes
 1.9 19-Aug-1995  mycroft Fix oversights in previous change.
Remove ugly casts and correct spelling.
 1.8 19-Aug-1995  cgd use I/O ports on the i386
 1.7 17-Aug-1995  cgd clean up 7/26 de snapshot import
 1.6 24-Jul-1995  cgd merge updated version from Matt Thomas, which includes dc21041 support.
There are a couple of questionable changes in here, that i'm going to
hammer out of him in the next week or so...
 1.5 28-Jun-1995  cgd header file got renamed
 1.4 06-Jun-1995  cgd update from matt thomas
 1.3 05-Jun-1995  cgd set a shutdown hook
 1.2 05-Jun-1995  cgd kill old Id, add NetBSD Id
 1.1 05-Jun-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.12 25-Aug-1997  thorpej Import the 970703 snapshot of Matt Thomas's "de" driver.
 1.1.1.11 06-Jun-1997  mellon Matt Thomas's if_de driver, 1997/6/3 snapshot
 1.1.1.10 07-May-1997  thorpej Update from Matt Thomas (oof, this has been on my todo list for a while!)
This adds support for the Cogent 4-port cards.
 1.1.1.9 26-Mar-1997  thorpej Update from Matt Thomas <matt@3am-software.com>. Fixes a couple of
media-related bugs, and now properly groks Asante versions of Tulip
cards.
 1.1.1.8 23-Mar-1997  veego New DEC Tulip driver from Matt Thomas <matt@3am-software.com>.
- Fix the mbuf leak while probing.
- Stop probing after saying "autosense problem" if the interface is down.
 1.1.1.7 19-Mar-1997  thorpej Update from Matt Thomas. Fixes several media-selection and full-duplex
related bugs. Also, fix a bug that was causing hangs and machine-checks
on Alpha systems in some cases.
 1.1.1.6 17-Mar-1997  thorpej New DEC Tulip driver from Matt Thomas <matt@3am-software.com>.
Highligts:
- Supports media selection via if_media
- Support for Asante and better support for ZNYX boards
- Support for 21143 chips (such as found on the DE500-BA)
- Should be able to pick the BNC on the on-board 21040-based
interface in DEC Multias.
- Squish a bug here and there.
 1.1.1.5 11-Jan-1997  thorpej Update from Matt Thomas <matt@3am-software.com>. Supports more
Tulip-based cards, including new SMC and Kingston cards.
 1.1.1.4 14-Dec-1995  tls 95/12/12 snapshot of Matt Thomas's 'de' driver
 1.1.1.3 17-Aug-1995  cgd Matt Thomas's dc21040 'de' driver, July 26, '95 snapshot.
 1.1.1.2 22-Jul-1995  cgd latest if_de, from Matt Thomas
 1.1.1.1 05-Jun-1995  cgd dc21040 driver, from Matt Thomas
 1.22.4.1 03-Jun-1996  cgd pull up from trunk:
>convert alpha vtophys() #defines to use __alpha_bus_XXX_dmamap(), to
>get rid of the nasty (vtophys(va) | 0x40000000) expressions, and to make
>the code more correct.
 1.32.4.3 12-Mar-1997  is Merge in changes from The Trunk
 1.32.4.2 09-Mar-1997  is netinet/if_ether.h -> netinet/if_inarp.h
 1.32.4.1 27-Feb-1997  is This is a maze of twisty little #ifdef's., all different. I hope I didn't
break anything when converting it.
 1.46.2.4 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.46.2.3 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.46.2.2 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.46.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.56.2.1 27-Oct-1997  thorpej Pull up from trunk:

Print interrupt information like all of the other PCI drivers.
 1.72.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.81.2.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.83.2.2 21-Jun-1999  perry pullup 1.85->1.86 (thorpej): Make sure bus mastering is enabled
 1.83.2.1 28-Apr-1999  perry branches: 1.83.2.1.2; 1.83.2.1.4;
pullup 1.83->1.84 (cjs): recognise/support Comtex boards.
 1.83.2.1.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.83.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.86.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.86.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.86.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.86.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.86.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.97.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.97.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.97.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.97.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.97.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.102.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.102.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.102.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.103.8.1 20-Jun-2002  gehenna catch up with -current.
 1.110.6.1 24-Jan-2005  he Pull up revision 1.112 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.110.2.7 11-Dec-2005  christos Sync with head.
 1.110.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.110.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.110.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.110.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.110.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.110.2.1 03-Aug-2004  skrll Sync with HEAD
 1.112.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.112.4.1 29-Apr-2005  kent sync with -current
 1.114.2.5 11-Feb-2008  yamt sync with head.
 1.114.2.4 27-Oct-2007  yamt sync with head.
 1.114.2.3 03-Sep-2007  yamt sync with head.
 1.114.2.2 30-Dec-2006  yamt sync with head.
 1.114.2.1 21-Jun-2006  yamt sync with head.
 1.118.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.118.10.1 11-May-2006  elad sync with head
 1.118.8.2 14-Sep-2006  yamt sync with head.
 1.118.8.1 24-May-2006  yamt sync with head.
 1.118.6.2 01-Jun-2006  kardel Sync with head.
 1.118.6.1 22-Apr-2006  simonb Sync with head.
 1.118.4.1 09-Sep-2006  rpaulo sync with head
 1.121.4.1 10-Dec-2006  yamt sync with head.
 1.121.2.1 18-Nov-2006  ad Sync with head.
 1.122.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.123.4.1 11-Jul-2007  mjf Sync with head.
 1.123.2.3 23-Oct-2007  ad Sync with head.
 1.123.2.2 09-Oct-2007  ad Sync with head.
 1.123.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.124.8.2 23-Mar-2008  matt sync with HEAD
 1.124.8.1 06-Nov-2007  matt sync with HEAD
 1.124.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.124.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.124.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.125.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.126.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.127.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.127.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.128.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.128.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.128.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.128.4.4 11-Aug-2010  yamt sync with head.
 1.128.4.3 11-Mar-2010  yamt sync with head
 1.128.4.2 16-May-2009  yamt sync with head
 1.128.4.1 04-May-2009  yamt sync with head.
 1.129.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.136.4.2 05-Mar-2011  rmind sync with head
 1.136.4.1 30-May-2010  rmind sync with head
 1.136.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.138.12.1 18-Feb-2012  mrg merge to -current.
 1.138.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.138.8.2 30-Oct-2012  yamt sync with head
 1.138.8.1 17-Apr-2012  yamt sync with head
 1.139.6.4 03-Dec-2017  jdolecek update from HEAD
 1.139.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.139.6.2 23-Jun-2013  tls resync from head
 1.139.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.141.4.1 18-May-2014  rmind sync with head
 1.142.2.2 10-Aug-2014  tls Rebase.
 1.142.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.144.4.4 05-Feb-2017  skrll Sync with HEAD
 1.144.4.3 09-Jul-2016  skrll Sync with HEAD
 1.144.4.2 19-Mar-2016  skrll Sync with HEAD
 1.144.4.1 06-Jun-2015  skrll Sync with HEAD
 1.147.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.150.14.6 18-Jan-2019  pgoyette Synch with HEAD
 1.150.14.5 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.150.14.4 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.150.14.3 28-Jul-2018  pgoyette Sync with HEAD
 1.150.14.2 25-Jun-2018  pgoyette Sync with HEAD
 1.150.14.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.150.8.2 31-Jul-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #947):

sys/dev/pci/if_de.c: revision 1.153

Remove bpf_tap() call in rx. It's done in if_percpuq_softint().
 1.150.8.1 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.154.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.154.2.1 10-Jun-2019  christos Sync with HEAD
 1.163.2.1 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #662):

sys/dev/pcmcia/if_xi.c: revision 1.93
sys/arch/x86/pci/if_vmx.c: revision 1.54
sys/dev/pci/if_de.c: revision 1.165
sys/arch/arm/ti/if_cpsw.c: revision 1.10
sys/arch/arm/omap/if_cpsw.c: revision 1.26
sys/dev/isa/if_iy.c: revision 1.112
sys/dev/pcmcia/if_ray.c: revision 1.96

Add ETHER_LOCK() and ETHER_UNLOCK() to protect ec_multiaddrs.

XXX These drivers don't check whether enm_addrlo and enm_addrhi are the same
or not, so it won't work correctly if an multicast address entry has a range.

Protect ec_multicnt.
 1.165.2.1 25-Jan-2020  ad Sync with head.
 1.64 19-Jan-2020  thorpej Remove the de(4) driver, which has long since been supplanted by the
tlp(4) driver, which supports more chips and more board variants.
 1.63 27-Dec-2019  msaitoh branches: 1.63.2;
s/recevive/receive/ in comment.
 1.62 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.61 08-Jan-2019  msaitoh KNF. No functional change.
 1.60 06-Sep-2015  dholland branches: 1.60.16; 1.60.18;
More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.59 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.58 27-Oct-2012  chs branches: 1.58.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.57 02-Feb-2012  tls branches: 1.57.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.56 19-Nov-2011  tls branches: 1.56.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.55 05-Apr-2010  joerg branches: 1.55.8;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.54 19-Jan-2010  pooka branches: 1.54.2; 1.54.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.53 18-Jan-2010  pooka Remove unused macro definition (the NetBSD version would just not go
through a compiler).
 1.52 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.51 29-Mar-2009  dholland Merge patch from PR 12605, which tidies up allocation of transmit DMA maps.
Generalize it to also tidy up allocation of receive DMA maps. And change a
few of the symbol names involved to (1) make sure all uses have been fixed
and (2) make it clearer what's actually going on.

Previously the driver was using DMA maps off the free list without fully
allocating them, apparently in order to save two or three lines releasing
them on error paths. According to the submitter of the PR (H.Saito) this
was causing it to reuse a map already in use when under load, resulting
in panics.

I'm not sure if that ought to have been possible or if it reflected an
interrupt handling bug somewhere else, but the change is an improvement
regardless, so we'll go with it.

Compile-tested only, but I've crosschecked the diffs and all that and it's
a pretty noninvasive change.

(Is anyone actually using this driver rather than tlp?)
 1.50 12-Jun-2008  cegger branches: 1.50.4; 1.50.10;
use device_lookup_private to get softc
 1.49 22-May-2008  dyoung branches: 1.49.2;
Delete non-illuminating #ifdef-OTHER_OPERATING_SYSTEM code that
confuses ctags(1).
 1.48 04-Mar-2007  chris branches: 1.48.36; 1.48.38; 1.48.40; 1.48.42;
Fix caddr_t fallout for cats kernel builds.
 1.47 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.46 22-Nov-2006  uebayasi branches: 1.46.4;
Use C99 initializers where needed.
 1.45 29-May-2006  drochner branches: 1.45.6; 1.45.8;
gcc4 found that it can't store
#define TULIP_TXTIMER 4
in
u_int32_t tulip_txtimer : 2; /* transmission timer */

gcc4 appears to be right. "tulip_txtimer" is purely used by software,
so give it the full integer.
(Appearently the txtimer could never work.)
 1.44 16-Feb-2006  perry branches: 1.44.2; 1.44.8;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.43 24-Dec-2005  perry branches: 1.43.2; 1.43.4; 1.43.6;
__inline__ -> inline
 1.42 24-Dec-2005  perry __asm__ -> __asm
 1.41 11-Dec-2005  christos merge ktrace-lwp.
 1.40 27-Feb-2005  perry branches: 1.40.4;
nuke trailing whitespace
 1.39 11-Feb-2005  simonb White space nit- don't put a space before/after increment/decrement
operators.
 1.38 01-Oct-2002  thorpej branches: 1.38.6; 1.38.14; 1.38.16;
Remove uneecessary extern decl of de_ca.
 1.37 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.36 13-Jun-2001  wiz branches: 1.36.2;
withough -> without
 1.35 03-May-2000  thorpej branches: 1.35.6;
`typedef void ifnet_ret_t;' isn't valid C -- use #define, instead.
 1.34 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.33 15-Jan-2000  matt Fixes for 21143 and MII in full-duplex mode.
 1.32 01-Apr-1999  tsubai branches: 1.32.8;
Fix typo. (From PR 7027)
 1.31 29-Sep-1998  matt branches: 1.31.4;
Invert the RXCOPY test. Note that most new platforms will not
have relaxed alignment so the de driver should just work on them.
 1.30 15-Sep-1998  matt Fix a problem where txput could "lose" dmamaps if it couldn't actually
place the packet into the ring for some reason.
 1.29 15-Sep-1998  matt This commit fixes two bugs in the de driver. The first is that the
descriptor count gets miscounted on txprobes. The second (and more
important) is that transmit stalls should now be fixed. The problem
was not due to lack of ring resources but dmamaps. When Jason changed
the driver to use pre-allocated maps (instead of the dynamic ones I
used), and when there were no more maps, the driver just gave up instead
of calling tx_intr to free any transmitted but unreclaimed dma maps.
Since there was nothing being transmitted, no transmit interrupts
would fire to restore things (and OACTIVE prevented other transmits
from happenning). So it stayed starved until another interrupt cause
(like a received packet) "woke" it up.
 1.28 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.27 25-May-1998  mark branches: 1.27.2;
Define TULIP_COPY_RXDATA for arm32 as well as alpha.
 1.26 11-Feb-1998  thorpej Don't try to dynamically create and destroy DMA maps. Instead, keep
it simple, and allocate one for each transmit and receive descriptor.

In addition to being simpler and faster, this fixes a serious memory leak
in the transmit path.
 1.25 07-Feb-1998  thorpej Create RX DMA maps with ALLOCNOW. These maps are essentially always
loaded, and recovering from a resource shortage error is much harder
in the receive case.
 1.24 07-Feb-1998  thorpej Use BUS_DMA_NOWAIT where appropriate. Don't create DMA maps with
BUS_DMA_ALLOCNOW.
 1.23 06-Feb-1998  matt A version of the de driver which does bus_dma. Note that it has not been
tested on any other platform other than i386. Use of bus_dma(9) can be
turned by defining TULIP_BUS_DMA_NOTX and TULIP_BUS_DMA_NORX. These allow
one to determine if the problem is in the transmit or receive path.
A problem reported by mycroft is also fixed.
 1.22 20-Oct-1997  matt 21142 / 21143 chips always use ISVSROM format. (print out message is
SROM checksum is invalid).
 1.21 16-Oct-1997  matt Fix pr's port-i386/4127 kern/4190 kern/3700.
 1.20 15-Oct-1997  matt Fix media/console interaction problem on Alpha. Fix 21142/21143 problems
with 10Mb/s links.
 1.19 15-Oct-1997  explorer Add and/or update rnd_*() hooks
 1.18 13-Oct-1997  explorer o Make usage of /dev/random dependant on
pseudo-device rnd # /dev/random and in-kernel generator
in config files.

o Add declaration to all architectures.

o Clean up copyright message in rnd.c, rnd.h, and rndpool.c to include
that this code is derived in part from Ted Tyso's linux code.
 1.17 10-Oct-1997  explorer Add hooks to insert timing info into the random system
 1.16 25-Aug-1997  thorpej Add RCS tags that got lost.
 1.15 25-Aug-1997  thorpej Merge with 970703 snapshot of Matt Thomas's de driver.
 1.14 19-Jul-1997  cgd branches: 1.14.2;
don't expect/provide pci_decompose_tag to be a MI, public function. It
wasn't intended to be to begin with, and uses of it (e.g. the one in the
'de' driver) are quite likely to be incorrect.
 1.13 08-Jun-1997  thorpej Put back Matt Thomas's revision ID, per PR 3723, submitted by
enami tsugutomo <enami@ba2.so-net.or.jp>.
 1.12 06-Jun-1997  mellon Clean up conflicts during merge (thomas de-970603)
 1.11 07-May-1997  thorpej Merge 970327 "de" update.
 1.10 13-Apr-1997  cgd clean up space/tag comments
 1.9 26-Mar-1997  thorpej Resolve conflicts from merge.
 1.8 23-Mar-1997  veego Resolve conflicts from merge.
 1.7 19-Mar-1997  thorpej Resolve conflicts from merge.
 1.6 17-Mar-1997  thorpej Resolve conflicts from merge.
 1.5 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.4 06-Mar-1997  thorpej Patch from Matt Thomas to deal with the fact that Pass 2.[012] of
the 21140A-A[CDE] have a buggy receiver which may hand and/or corrupt
data on receive overflows.
 1.3 13-Jan-1997  thorpej branches: 1.3.4;
Fix a couple of minor nits so that this compiles on the alpha.
Noticed by Matt Jacob (mjacob@feral.com).
 1.2 11-Jan-1997  thorpej Merge into mainline, tidy up some debug code.
 1.1 11-Jan-1997  thorpej branches: 1.1.1;
Initial revision
 1.1.1.8 25-Aug-1997  thorpej Import the 970703 snapshot of Matt Thomas's "de" driver.
 1.1.1.7 06-Jun-1997  mellon Matt Thomas's if_de driver, 1997/6/3 snapshot
 1.1.1.6 07-May-1997  thorpej Update from Matt Thomas (oof, this has been on my todo list for a while!)
This adds support for the Cogent 4-port cards.
 1.1.1.5 26-Mar-1997  thorpej Update from Matt Thomas <matt@3am-software.com>. Fixes a couple of
media-related bugs, and now properly groks Asante versions of Tulip
cards.
 1.1.1.4 23-Mar-1997  veego New DEC Tulip driver from Matt Thomas <matt@3am-software.com>.
- Fix the mbuf leak while probing.
- Stop probing after saying "autosense problem" if the interface is down.
 1.1.1.3 19-Mar-1997  thorpej Update from Matt Thomas. Fixes several media-selection and full-duplex
related bugs. Also, fix a bug that was causing hangs and machine-checks
on Alpha systems in some cases.
 1.1.1.2 17-Mar-1997  thorpej New DEC Tulip driver from Matt Thomas <matt@3am-software.com>.
Highligts:
- Supports media selection via if_media
- Support for Asante and better support for ZNYX boards
- Support for 21143 chips (such as found on the DE500-BA)
- Should be able to pick the BNC on the on-board 21040-based
interface in DEC Multias.
- Squish a bug here and there.
 1.1.1.1 11-Jan-1997  thorpej Update from Matt Thomas <matt@3am-software.com>. Supports more
Tulip-based cards, including new SMC and Kingston cards.
 1.3.4.2 12-Mar-1997  is Merge in changes from The Trunk
 1.3.4.1 27-Feb-1997  is This is a maze of twisty little #ifdef's., all different. I hope I didn't
break anything when converting it.
 1.14.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.27.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.31.4.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.32.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.35.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.35.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.36.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.38.16.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.38.16.1 12-Feb-2005  yamt sync with head.
 1.38.14.1 29-Apr-2005  kent sync with -current
 1.38.6.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.38.6.1 15-Feb-2005  skrll Sync with HEAD.
 1.40.4.3 03-Sep-2007  yamt sync with head.
 1.40.4.2 30-Dec-2006  yamt sync with head.
 1.40.4.1 21-Jun-2006  yamt sync with head.
 1.43.6.2 01-Jun-2006  kardel Sync with head.
 1.43.6.1 22-Apr-2006  simonb Sync with head.
 1.43.4.1 09-Sep-2006  rpaulo sync with head
 1.43.2.1 18-Feb-2006  yamt sync with head.
 1.44.8.1 19-Jun-2006  chap Sync with head.
 1.44.2.1 26-Jun-2006  yamt sync with head.
 1.45.8.1 10-Dec-2006  yamt sync with head.
 1.45.6.1 12-Jan-2007  ad Sync with head.
 1.46.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.48.42.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.40.4 11-Aug-2010  yamt sync with head.
 1.48.40.3 11-Mar-2010  yamt sync with head
 1.48.40.2 16-May-2009  yamt sync with head
 1.48.40.1 04-May-2009  yamt sync with head.
 1.48.38.2 17-Jun-2008  yamt sync with head.
 1.48.38.1 04-Jun-2008  yamt sync with head
 1.48.36.2 29-Jun-2008  mjf Sync with HEAD.
 1.48.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.49.2.1 18-Jun-2008  simonb Sync with head.
 1.50.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.54.4.1 30-May-2010  rmind sync with head
 1.54.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.55.8.2 30-Oct-2012  yamt sync with head
 1.55.8.1 17-Apr-2012  yamt sync with head
 1.56.2.1 18-Feb-2012  mrg merge to -current.
 1.57.6.2 03-Dec-2017  jdolecek update from HEAD
 1.57.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.58.14.2 22-Sep-2015  skrll Sync with HEAD
 1.58.14.1 06-Jun-2015  skrll Sync with HEAD
 1.60.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.60.18.1 10-Jun-2019  christos Sync with HEAD
 1.60.16.1 18-Jan-2019  pgoyette Synch with HEAD
 1.63.2.1 25-Jan-2020  ad Sync with head.
 1.65 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.64 09-Feb-2024  andvar branches: 1.64.2;
fix spelling mistakes, mainly in comments and log messages.
 1.63 31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.62 05-Dec-2021  msaitoh s/checkum/checksum/ in comment.
 1.61 10-Nov-2021  msaitoh s/threshhold/threshold/ in comment.
 1.60 09-Aug-2021  andvar s/aligment/alignment/ + one more typo fix in comments.
 1.59 08-May-2021  thorpej Use pci_compatible_match().
 1.58 01-Mar-2020  thorpej branches: 1.58.10;
Support 64-bit DMA addressing, and use the 64-bit PCI DMA tag if available.
 1.57 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.56 10-Nov-2019  chs branches: 1.56.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.55 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.54 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.53 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.52 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.51 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.50 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.49 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.48 26-Jun-2018  msaitoh branches: 1.48.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.47 15-Dec-2016  ozaki-r branches: 1.47.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.46 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.45 07-Jul-2016  msaitoh branches: 1.45.2;
KNF. Remove extra spaces. No functional change.
 1.44 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.43 01-Jun-2016  pgoyette Fix typo that somehow snuck in.
 1.42 01-Jun-2016  pgoyette Add support for Intel 82597EX_SR - from PR kern/47750
 1.41 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.40 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.39 11-Jan-2015  chs fix device/softc split botch.
 1.38 10-Aug-2014  tls branches: 1.38.2; 1.38.4;
Merge tls-earlyentropy branch into HEAD.
 1.37 29-Mar-2014  christos branches: 1.37.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.36 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.35 27-Oct-2012  chs branches: 1.35.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.34 02-Feb-2012  tls branches: 1.34.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.33 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.32 19-Nov-2011  tls branches: 1.32.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.31 13-Nov-2010  uebayasi branches: 1.31.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.30 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.29 19-Jan-2010  pooka branches: 1.29.2; 1.29.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.28 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.27 27-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only.
 1.26 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.25 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.24 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.23 13-Feb-2009  abs avoid long/unsigned long printf warning on some platforms
 1.22 07-Nov-2008  dyoung branches: 1.22.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.21 10-Apr-2008  cegger branches: 1.21.4; 1.21.10; 1.21.12; 1.21.14; 1.21.18;
use aprint_*_dev and device_xname
 1.20 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.19 07-Feb-2008  dyoung branches: 1.19.2; 1.19.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.18 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.17 19-Oct-2007  ad branches: 1.17.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 26-Aug-2007  dyoung branches: 1.16.2; 1.16.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.15 04-Mar-2007  christos branches: 1.15.2; 1.15.10; 1.15.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 16-Nov-2006  christos branches: 1.14.4;
__unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 11-Dec-2005  christos branches: 1.12.20; 1.12.22;
merge ktrace-lwp.
 1.11 02-May-2005  yamt branches: 1.11.2;
split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.10 27-Feb-2005  perry nuke trailing whitespace
 1.9 21-Feb-2005  thorpej Define M_CSUM_DATA_IPv4_IPHL() and M_CSUM_DATA_IPv4_OFFSET() macros
to extract data from csum_data, rather than just open-coding it.
 1.8 18-Feb-2005  heas Adjust csum_data usage; mask off the high 16 bits for L4 header stuff offset
and make use of the L3 header length from the high 16 bits such that an
m_pullup is no londer necessary.
 1.7 30-Oct-2004  thorpej branches: 1.7.4; 1.7.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.6 21-Sep-2004  yamt introduce M_EXT_RW to allow mbuf external storage R/W.
discussed on tech-net@.
 1.5 10-May-2004  thorpej branches: 1.5.2;
Fix a couple of whitespace nits.
 1.4 22-Apr-2004  itojun sprintf -> snprintf
 1.3 14-Apr-2004  ragge The 82597 chip may write back some receive descriptors off-by-one when
the PCIX bus start to get heavily loaded. This only happen when using
chained descriptors, therefore work-around it by providing a private
pool of receive buffers able to contain a full-sized packet.
 1.2 13-Apr-2004  ragge Make it possible to use 16k MTU.
 1.1 12-Mar-2004  ragge branches: 1.1.2;
Add driver for Intel PRO/10GbE ethernet adapter. Now NetBSD has no
problem with intercontinental TCP connections of over 4Gbit/s, which is
where my test hardware runs out of bus bandwidth.

Stuff that is on the TODO list:
* HW VLAN support.
* Large jumbo buffers (16k).
* TCP Segmentation Offload
* RAIDC (receive interrupt delay adaptation)
* Understand how to use memory above 4GB.
 1.1.2.2 16-Apr-2004  tron branches: 1.1.2.2.2;
Pull up revision 1.3 (requested by ragge in ticket #139):
The 82597 chip may write back some receive descriptors off-by-one when
the PCIX bus start to get heavily loaded. This only happen when using
chained descriptors, therefore work-around it by providing a private
pool of receive buffers able to contain a full-sized packet.
 1.1.2.1 16-Apr-2004  tron Pull up revision 1.2 (requested by ragge in ticket #139):
Make it possible to use 16k MTU.
 1.1.2.2.2.1 24-Jan-2005  he Pull up revision 1.7 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.5.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.5.2.5 24-Sep-2004  skrll Sync with HEAD.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 10-May-2004  skrll file if_dge.c was added on branch ktrace-lwp on 2004-08-03 10:49:08 +0000
 1.7.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.11.2.5 17-Mar-2008  yamt sync with head.
 1.11.2.4 11-Feb-2008  yamt sync with head.
 1.11.2.3 15-Nov-2007  yamt sync with head.
 1.11.2.2 27-Oct-2007  yamt sync with head.
 1.11.2.1 03-Sep-2007  yamt sync with head.
 1.12.22.2 10-Dec-2006  yamt sync with head.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.14.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.14.3 11-Nov-2007  joerg Sync with HEAD.
 1.15.14.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.15.14.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.15.10.1 03-Sep-2007  skrll Sync with HEAD.
 1.15.2.3 23-Oct-2007  ad Sync with head.
 1.15.2.2 09-Oct-2007  ad Sync with head.
 1.15.2.1 01-Sep-2007  ad Update for pool_cache API changes.
 1.16.6.2 13-Nov-2007  bouyer Sync with HEAD
 1.16.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.2.3 23-Mar-2008  matt sync with HEAD
 1.16.2.2 08-Nov-2007  matt sync with -HEAD
 1.16.2.1 06-Nov-2007  matt sync with HEAD
 1.17.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.17.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.19.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.19.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.19.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.19.2.1 24-Mar-2008  keiichi sync with head.
 1.21.18.1 21-Apr-2010  matt sync to netbsd-5
 1.21.14.1 30-Sep-2009  snj Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/dev/pci/if_dge.c: revision 1.23
avoid long/unsigned long printf warning on some platforms
 1.21.12.2 03-Mar-2009  skrll Sync with HEAD.
 1.21.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.21.4.4 11-Aug-2010  yamt sync with head.
 1.21.4.3 11-Mar-2010  yamt sync with head
 1.21.4.2 16-May-2009  yamt sync with head
 1.21.4.1 04-May-2009  yamt sync with head.
 1.22.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.29.4.2 05-Mar-2011  rmind sync with head
 1.29.4.1 30-May-2010  rmind sync with head
 1.29.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.31.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31.8.2 30-Oct-2012  yamt sync with head
 1.31.8.1 17-Apr-2012  yamt sync with head
 1.32.2.1 18-Feb-2012  mrg merge to -current.
 1.34.6.3 03-Dec-2017  jdolecek update from HEAD
 1.34.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.35.2.1 18-May-2014  rmind sync with head
 1.37.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.38.4.5 05-Feb-2017  skrll Sync with HEAD
 1.38.4.4 09-Jul-2016  skrll Sync with HEAD
 1.38.4.3 19-Mar-2016  skrll Sync with HEAD
 1.38.4.2 06-Jun-2015  skrll Sync with HEAD
 1.38.4.1 06-Apr-2015  skrll Sync with HEAD
 1.38.2.1 11-Jan-2015  martin Pull up following revision(s) (requested by chs in ticket #406):
sys/dev/pci/if_dge.c: revision 1.39
fix device/softc split botch.
 1.45.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.47.14.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.47.14.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.47.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.48.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.48.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48.2.1 10-Jun-2019  christos Sync with HEAD
 1.56.2.1 29-Feb-2020  ad Sync with head.
 1.58.10.1 13-May-2021  thorpej Sync with HEAD.
 1.64.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 25-Dec-2007  perry Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.2 11-Dec-2005  christos branches: 1.2.46; 1.2.52; 1.2.56; 1.2.60;
merge ktrace-lwp.
 1.1 12-Mar-2004  ragge branches: 1.1.4; 1.1.18;
Add driver for Intel PRO/10GbE ethernet adapter. Now NetBSD has no
problem with intercontinental TCP connections of over 4Gbit/s, which is
where my test hardware runs out of bus bandwidth.

Stuff that is on the TODO list:
* HW VLAN support.
* Large jumbo buffers (16k).
* TCP Segmentation Offload
* RAIDC (receive interrupt delay adaptation)
* Understand how to use memory above 4GB.
 1.1.18.1 21-Jan-2008  yamt sync with head
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 12-Mar-2004  skrll file if_dgereg.h was added on branch ktrace-lwp on 2004-08-03 10:49:08 +0000
 1.2.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.2.56.1 26-Dec-2007  ad Sync with head.
 1.2.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.46.1 09-Jan-2008  matt sync with HEAD
 1.38 06-Sep-2018  maxv Retire the 'midway' driver. Discussed on tech-net@ recently and also three
years ago, part of removing the network ATM code.
 1.37 29-Mar-2014  christos branches: 1.37.28; 1.37.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.36 26-Jul-2011  dyoung branches: 1.36.2; 1.36.12; 1.36.16;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.35 18-Jul-2011  mrg convert the remaining dev/sbus drivers to CFATTACH_DECL_NEW, cfdata_t
and device_t, including the pci frontend and backend for en(4).
 1.34 01-Feb-2011  chuck udpate license clauses on my code to match the new-style BSD licenses.
remove no-longer-valid wustl email address for me.
based on diff that rmind@ sent me.

no functional change with this commit.
 1.33 26-Nov-2009  njoly branches: 1.33.4; 1.33.6; 1.33.8;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.32 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.31 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.30 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.29 15-Mar-2009  cegger ansify function definitions
 1.28 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.27 10-Apr-2008  cegger branches: 1.27.4; 1.27.12; 1.27.18;
use aprint_*_dev and device_xname
 1.26 16-Nov-2006  christos branches: 1.26.48;
__unused removal on arguments; approved by core.
 1.25 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.24 11-May-2006  mrg branches: 1.24.8; 1.24.10;
don't try to #define bus_space_read_1() if defined(sparc).
 1.23 11-Dec-2005  christos branches: 1.23.4; 1.23.6; 1.23.8; 1.23.10; 1.23.12;
merge ktrace-lwp.
 1.22 27-Feb-2005  perry branches: 1.22.4;
nuke trailing whitespace
 1.21 04-Feb-2005  perry de-__P
 1.20 30-Oct-2003  simonb branches: 1.20.8; 1.20.10;
Remove some assigned-to but otherwise unused variables.
 1.19 31-Jan-2003  thorpej branches: 1.19.2;
Use aprint_*().
 1.18 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.17 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.16 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.15 13-Nov-2001  lukem add RCSID
 1.14 28-Dec-2000  sommerfeld branches: 1.14.2; 1.14.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.13 01-Jul-1999  itojun branches: 1.13.2;
IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
 1.12 24-Mar-1999  cgd branches: 1.12.4; 1.12.6;
in general, it's a good idea to make sure you at least have all of the
variables you reference, before you commit something...
 1.11 24-Mar-1999  thorpej Make sure bus mastering is enabled.
 1.10 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.9 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.8 13-Apr-1997  cgd use pci_map_register().
 1.7 20-Mar-1997  chuck add support for adaptec PCI atm cards (see midway.c log for details)
 1.6 05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.5 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.4 13-Oct-1996  christos backout kprintf changes
 1.3 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.2 27-Aug-1996  cgd remove include of <sys/types.h> (it's implied by including
<sys/param.h>, and historically has been), and add include of
<sys/systm.h> for prototypes.
 1.1 22-Jun-1996  chuck pci specific code for the eni155p card
 1.12.6.2 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.12.6.1 28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.12.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.13.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.14.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.14.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.14.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.19.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.10.1 12-Feb-2005  yamt sync with head.
 1.20.8.1 29-Apr-2005  kent sync with -current
 1.22.4.2 30-Dec-2006  yamt sync with head.
 1.22.4.1 21-Jun-2006  yamt sync with head.
 1.23.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.23.10.1 11-May-2006  elad sync with head
 1.23.8.1 24-May-2006  yamt sync with head.
 1.23.6.1 01-Jun-2006  kardel Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.24.10.2 10-Dec-2006  yamt sync with head.
 1.24.10.1 22-Oct-2006  yamt sync with head
 1.24.8.1 18-Nov-2006  ad Sync with head.
 1.26.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.4.3 11-Mar-2010  yamt sync with head
 1.27.4.2 16-May-2009  yamt sync with head
 1.27.4.1 04-May-2009  yamt sync with head.
 1.33.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.33.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.33.4.1 05-Mar-2011  rmind sync with head
 1.36.16.1 18-May-2014  rmind sync with head
 1.36.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.30.1 10-Jun-2019  christos Sync with HEAD
 1.37.28.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.43 26-Feb-2025  andvar Fix typos in comments, mainly s/calcurate/calculate/.
 1.42 29-Jun-2024  riastradh branches: 1.42.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.41 20-Dec-2023  skrll Remove unnecssary #include
 1.40 05-Nov-2023  jdolecek ena(4): stop management first when detaching

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.39 05-Nov-2023  jdolecek ena(4): establish interrupt after setting up resources

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.38 05-Nov-2023  jdolecek ena(4): prevent AENQ handler from use-after-free

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.37 05-Nov-2023  jdolecek ena(4) is MP-ready, always use MPSAFE

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.36 05-Nov-2023  jdolecek ena(4): support RSS and delete FreeBSD-specified code

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.35 05-Nov-2023  jdolecek ena(4): replace malloc(9) to kmem(9)

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.34 21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.33 23-May-2022  rin branches: 1.33.4;
Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.32 23-Sep-2021  jmcneill ena: fix packet reordering issue

A reorder occures when
- memory allocation fails in bus_dmamap_load_mbuf() or
- submission queue is full

This patch makes ena(4) to
- allocate memory in advance (BUS_DMA_ALLOCNOW flag in bus_dmamap_create())
- check if the queue is vacant before pcq_get()

Patch from KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.31 16-Sep-2021  andvar fix typos in word "successfully", mainly s/succesfully/successfully/.
 1.30 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.29 19-Jul-2021  jmcneill Various ena(4) bug fixes, from KUSABA Takeshi <t-kusaba@iij.ad.jp>:

[PATCH 01/32] include device_xname for evcnt group.
[PATCH 02/32] fix improper NULL check.
[PATCH 03/32] add tx drop counter
[PATCH 04/32] remove unimplemented m_getjcl
[PATCH 05/32] make ENA_MEM_{ALLOC,FREE}_COHERENT symmetric.
[PATCH 06/32] disestablish the correct interrupt.
[PATCH 07/32] fix null check target.
[PATCH 08/32] use if_initialize() and if_register() instead of
[PATCH 09/32] free all pci-related resource.
[PATCH 10/32] no need to call if_free(), but to call if_detach
[PATCH 11/32] add some locking assertions.
[PATCH 12/32] use bus_size_t for bus_dma instead of uint32_t.
[PATCH 13/32] no need to pass interlock, ena_timer_service does not
[PATCH 14/32] enable ena(4) to down I/F
[PATCH 15/32] destroy I/O queues before disestablishing msix
[PATCH 16/32] count input/output packet stats.
[PATCH 17/32] fix missing #ifdef LRO, NetBSD does not support LRO
[PATCH 18/32] MP-ify TX, allocate mbuf queue to each TX ring.
[PATCH 19/32] down the interface first when to detach, to prevent
[PATCH 20/32] default link speed should be unknown.
[PATCH 21/32] protect ena_adapter members only by "global_mtx".
[PATCH 22/32] lower global_mtx interrupt level
[PATCH 23/32] reorder function declaration
[PATCH 24/32] add locking notes and some marking.
[PATCH 25/32] process RX in workqueue context, as same as FreeBSD
[PATCH 26/32] count rx_drops correctly.
[PATCH 27/32] no need to lock when attach/detach, down/up
[PATCH 28/32] fix memory leak.
[PATCH 29/32] add "stopping" flag to ena_ring.
[PATCH 30/32] make the flags atomic.
[PATCH 31/32] do not schedule timer when device is down.
[PATCH 32/32] no need to start timer if I/F is down.
 1.28 01-Jul-2021  jmcneill port-evbarm/56274: no network on ec2 arm64 9.99.85

Remove custom SIOCSIFFLAGS handling and rely on ether_ioctl to DTRT
 1.27 23-Jan-2021  jmcneill branches: 1.27.4;
kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.26 18-Jan-2021  skrll Trailing whitespace
 1.25 03-Aug-2020  jmcneill branches: 1.25.2;
port-arm/55532: kernel panic with ena on AWS a1.2xlarge

Do not mark callout and workqueues as mpsafe unless the NET_MPSAFE option
is present.
 1.24 03-Mar-2020  jdolecek replace #if condition for irq_slot with __diagused on the cleanup path

fixes PR kern/55044 by Uwe Toenjes
 1.23 24-Feb-2020  rin 0x%p --> %p for non-external codes.
 1.22 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.21 04-Feb-2020  thorpej Use ifmedia_fini().
 1.20 01-Feb-2020  riastradh Use atomic_load/store_* in ena(4), not questionable membar_sync.
 1.19 02-Dec-2019  msaitoh branches: 1.19.2;
Use PCI_MSIX_"TBL"BIR_MASK instead of PCI_MSIX_"PBA"BIR_MASK for MSI-X table.
This is not a real bug because both macros have the same value.
 1.18 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.17 18-Oct-2019  msaitoh s/initalize/initialize/ in comment or printf message.
 1.16 01-Aug-2019  msaitoh If the memory space's BAR and the MSI-X table is on the same BAR,
reserve the space. Almost the same as nvme_pci.c and xhci_pci.c.
Tested by ryoon@.
 1.15 29-May-2019  msaitoh branches: 1.15.2;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.14 26-Apr-2019  msaitoh Remove duplicated inclusion of sys/bus.h.
 1.13 23-Jan-2019  ryoon Fix no options DEBUG nor DIAGNOSTIC build
 1.12 22-Dec-2018  roy remove needless parens, makes clang happy
 1.11 30-Nov-2018  jmcneill Get this driver into a functional state.
 1.10 30-Nov-2018  jmcneill workqueue and callout fixes
 1.9 28-Nov-2018  jmcneill Add calls to if_attach and if_deferred_start_init
 1.8 28-Nov-2018  jmcneill Our softc is the private data of self, not parent. Spotted by mlelstv@
 1.7 28-Nov-2018  jdolecek whitespace fix, NFC
 1.6 28-Nov-2018  bad Adapt ena_rx_checksum() to NetBSD.
It wasn't ported to the NetBSD conventions of indicating hardware checkum
status.

Compile tested only.
 1.5 26-Jun-2018  msaitoh branches: 1.5.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.4 16-Jun-2018  jdolecek make ena(4) compile, with best efford exercised to convert code to NetBSD
equivalents; where possible left the original code intact to make it
easier to compare against FreeBSD original

made non-working stubs for some functions which don't have direct
equivalent yet - this includes all of <sys/buf_ring.h>, m_getjcl(),
m_append, and m_collapse(); these need to be adressed

left XXX/TODO in if_enavar.h, colocated with the non-working stubs
 1.3 01-Jun-2018  maxv Fix M_PKTHDR use in if_alc, if_age and if_ena.

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

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

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).
 1.2 19-May-2018  jdolecek branches: 1.2.2;
Intermediate changes to make it further into actually at least compile, not nearly yet
complete. Committed so that others can possibly pick it off, as discussed
on tech-userlevel@ with Martin
 1.1 19-May-2018  jdolecek branches: 1.1.1;
Initial revision
 1.1.1.1 19-May-2018  jdolecek Import source for FreeBSD Amazon Elastic Network Adapter (ENA) NIC driver
for reference. Needs a lot of work to port over.

Remapped filenames from FreeBSD to NetBSD structure:
sys/dev/ena/ena.c -> sys/dev/pci/if_ena.c
sys/dev/ena/ena.h -> sys/dev/pci/if_enavar.h

ena_sysctl.* not imported, if needed later will be merged into if_ena.c
 1.2.2.6 26-Jan-2019  pgoyette Sync with HEAD
 1.2.2.5 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.2.4 28-Jul-2018  pgoyette Sync with HEAD
 1.2.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.2.2.2 21-May-2018  pgoyette Sync with HEAD
 1.2.2.1 19-May-2018  pgoyette file if_ena.c was added on branch pgoyette-compat on 2018-05-21 04:36:06 +0000
 1.5.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.15.2.4 23-Jan-2021  martin Pull up following revision(s) (requested by jmcneill in ticket #1186):

sys/dev/pci/if_ena.c: revision 1.27

PR kern/55942: destroyed ena(4) evcnts cause panic

Fix event counter teardown code. From KUSABA Takeshi
 1.15.2.3 05-Aug-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #1038):

sys/dev/pci/if_ena.c: revision 1.25

PR port-arm/55532: kernel panic with ena on AWS a1.2xlarge

Do not mark callout and workqueues as mpsafe unless the NET_MPSAFE option
is present.
 1.15.2.2 08-Mar-2020  martin Pull up following revision(s) (requested by jdolecek in ticket #759):

sys/dev/pci/if_ena.c: revision 1.24

replace #if condition for irq_slot with __diagused on the cleanup path

fixes PR kern/55044 by Uwe Toenjes
 1.15.2.1 09-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #37):

doc/3RDPARTY: revision 1.1641
sys/dev/pci/if_ena.c: revision 1.16
sys/arch/amd64/conf/GENERIC: revision 1.532

If the memory space's BAR and the MSI-X table is on the same BAR,
reserve the space. Almost the same as nvme_pci.c and xhci_pci.c.
Tested by ryoon@.

Add ena(4).
 1.19.2.1 29-Feb-2020  ad Sync with head.
 1.25.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.27.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.33.4.1 26-Nov-2023  bouyer Pull up following revision(s) (requested by jdolecek in ticket #460):
sys/dev/pci/if_ena.c: revision 1.35
sys/dev/pci/if_ena.c: revision 1.36
sys/dev/pci/if_ena.c: revision 1.37
sys/dev/pci/if_ena.c: revision 1.38
sys/dev/pci/if_ena.c: revision 1.39
sys/external/bsd/ena-com/ena_plat.h: revision 1.10
sys/dev/pci/if_enavar.h: revision 1.9
sys/external/bsd/ena-com/ena_com.c: revision 1.2
sys/external/bsd/ena-com/ena_com.c: revision 1.3
sys/external/bsd/ena-com/ena_com.c: revision 1.4
sys/dev/pci/if_ena.c: revision 1.40
sys/external/bsd/ena-com/ena_com.h: revision 1.2
ena(4): replace malloc(9) to kmem(9)
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): prevent AENQ handler from use-after-free
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): destroy all wait_event
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): support RSS and delete FreeBSD-specified code
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4) is MP-ready, always use MPSAFE
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): establish interrupt after setting up resources
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): stop management first when detaching
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.42.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.9 05-Nov-2023  jdolecek ena(4): support RSS and delete FreeBSD-specified code

Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.8 19-Jul-2021  jmcneill branches: 1.8.10;
Various ena(4) bug fixes, from KUSABA Takeshi <t-kusaba@iij.ad.jp>:

[PATCH 01/32] include device_xname for evcnt group.
[PATCH 02/32] fix improper NULL check.
[PATCH 03/32] add tx drop counter
[PATCH 04/32] remove unimplemented m_getjcl
[PATCH 05/32] make ENA_MEM_{ALLOC,FREE}_COHERENT symmetric.
[PATCH 06/32] disestablish the correct interrupt.
[PATCH 07/32] fix null check target.
[PATCH 08/32] use if_initialize() and if_register() instead of
[PATCH 09/32] free all pci-related resource.
[PATCH 10/32] no need to call if_free(), but to call if_detach
[PATCH 11/32] add some locking assertions.
[PATCH 12/32] use bus_size_t for bus_dma instead of uint32_t.
[PATCH 13/32] no need to pass interlock, ena_timer_service does not
[PATCH 14/32] enable ena(4) to down I/F
[PATCH 15/32] destroy I/O queues before disestablishing msix
[PATCH 16/32] count input/output packet stats.
[PATCH 17/32] fix missing #ifdef LRO, NetBSD does not support LRO
[PATCH 18/32] MP-ify TX, allocate mbuf queue to each TX ring.
[PATCH 19/32] down the interface first when to detach, to prevent
[PATCH 20/32] default link speed should be unknown.
[PATCH 21/32] protect ena_adapter members only by "global_mtx".
[PATCH 22/32] lower global_mtx interrupt level
[PATCH 23/32] reorder function declaration
[PATCH 24/32] add locking notes and some marking.
[PATCH 25/32] process RX in workqueue context, as same as FreeBSD
[PATCH 26/32] count rx_drops correctly.
[PATCH 27/32] no need to lock when attach/detach, down/up
[PATCH 28/32] fix memory leak.
[PATCH 29/32] add "stopping" flag to ena_ring.
[PATCH 30/32] make the flags atomic.
[PATCH 31/32] do not schedule timer when device is down.
[PATCH 32/32] no need to start timer if I/F is down.
 1.7 23-Dec-2018  jmcneill branches: 1.7.16;
Use ___STRING instead of __STRING to expand driver version numbers properly
 1.6 30-Nov-2018  jmcneill Get this driver into a functional state.
 1.5 28-Nov-2018  jmcneill Use correct PCI BAR offsets
 1.4 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.3 16-Jun-2018  jdolecek branches: 1.3.2;
make ena(4) compile, with best efford exercised to convert code to NetBSD
equivalents; where possible left the original code intact to make it
easier to compare against FreeBSD original

made non-working stubs for some functions which don't have direct
equivalent yet - this includes all of <sys/buf_ring.h>, m_getjcl(),
m_append, and m_collapse(); these need to be adressed

left XXX/TODO in if_enavar.h, colocated with the non-working stubs
 1.2 19-May-2018  jdolecek branches: 1.2.2;
Intermediate changes to make it further into actually at least compile, not nearly yet
complete. Committed so that others can possibly pick it off, as discussed
on tech-userlevel@ with Martin
 1.1 19-May-2018  jdolecek branches: 1.1.1;
Initial revision
 1.1.1.1 19-May-2018  jdolecek Import source for FreeBSD Amazon Elastic Network Adapter (ENA) NIC driver
for reference. Needs a lot of work to port over.

Remapped filenames from FreeBSD to NetBSD structure:
sys/dev/ena/ena.c -> sys/dev/pci/if_ena.c
sys/dev/ena/ena.h -> sys/dev/pci/if_enavar.h

ena_sysctl.* not imported, if needed later will be merged into if_ena.c
 1.2.2.5 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.2.4 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.2.2.2 21-May-2018  pgoyette Sync with HEAD
 1.2.2.1 19-May-2018  pgoyette file if_enavar.h was added on branch pgoyette-compat on 2018-05-21 04:36:06 +0000
 1.3.2.1 10-Jun-2019  christos Sync with HEAD
 1.7.16.1 01-Aug-2021  thorpej Sync with HEAD.
 1.8.10.1 26-Nov-2023  bouyer Pull up following revision(s) (requested by jdolecek in ticket #460):
sys/dev/pci/if_ena.c: revision 1.35
sys/dev/pci/if_ena.c: revision 1.36
sys/dev/pci/if_ena.c: revision 1.37
sys/dev/pci/if_ena.c: revision 1.38
sys/dev/pci/if_ena.c: revision 1.39
sys/external/bsd/ena-com/ena_plat.h: revision 1.10
sys/dev/pci/if_enavar.h: revision 1.9
sys/external/bsd/ena-com/ena_com.c: revision 1.2
sys/external/bsd/ena-com/ena_com.c: revision 1.3
sys/external/bsd/ena-com/ena_com.c: revision 1.4
sys/dev/pci/if_ena.c: revision 1.40
sys/external/bsd/ena-com/ena_com.h: revision 1.2
ena(4): replace malloc(9) to kmem(9)
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): prevent AENQ handler from use-after-free
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): destroy all wait_event
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): support RSS and delete FreeBSD-specified code
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4) is MP-ready, always use MPSAFE
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): establish interrupt after setting up resources
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
ena(4): stop management first when detaching
Code contributed by KUSABA Takeshi <t-kusaba@iij.ad.jp>
 1.55 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.54 23-Jun-2018  maxv branches: 1.54.2;
constify
 1.53 29-Mar-2014  christos branches: 1.53.28;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.52 26-Jul-2011  dyoung branches: 1.52.2; 1.52.12; 1.52.16;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.51 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.50 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.49 27-Aug-2008  christos branches: 1.49.8;
device_t changes, pmf, minor knf.
 1.48 28-Apr-2008  martin branches: 1.48.2; 1.48.6;
Remove clause 3 and 4 from TNF licenses
 1.47 10-Apr-2008  cegger branches: 1.47.2; 1.47.4;
use aprint_*_dev and device_xname
 1.46 19-Oct-2007  ad branches: 1.46.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.45 16-Nov-2006  christos branches: 1.45.8; 1.45.22; 1.45.24; 1.45.28;
__unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 11-Dec-2005  christos branches: 1.43.20; 1.43.22;
merge ktrace-lwp.
 1.42 27-Feb-2005  perry branches: 1.42.4;
nuke trailing whitespace
 1.41 21-Aug-2004  thorpej branches: 1.41.4; 1.41.6;
Use ANSI function decls and make use of static.
 1.40 31-Jan-2003  thorpej branches: 1.40.2;
Use aprint_*().
 1.39 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.38 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.37 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.36 13-Nov-2001  lukem add RCSID
 1.35 08-Jul-2001  thorpej branches: 1.35.2;
Remove unnecessary include files. From Onno van der Linden.
 1.34 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.33 28-Dec-2000  sommerfeld branches: 1.33.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.32 19-Feb-1999  thorpej branches: 1.32.8;
Improve card descriptions.
 1.31 09-Nov-1998  thorpej Const poisoning.
 1.30 07-Nov-1998  fvdl Rely on priority match to resolve conflict with the ex driver, not on
a define.
 1.29 04-Nov-1998  fvdl Add the 'ex' driver, a DMA driver for 3Com 90x and 90xB cards. Rename
constants from EP_ to ELINK_ since they're now used in the ex driver as well.
 1.28 12-Aug-1998  thorpej Completely rewrite media selection. Add support for the MII/PHY on
the 3Com 3c905-TX and 3c905-T4. Fix handling of the MII on the
3c595-MII and 3c597-MII (can't talk to the PHYs on these cards; just
use "manual" for the external MII port).

Fixes kern/4782 (Chris Demetriou).
 1.27 05-Jul-1998  jonathan defopt NS, NSIP.
 1.26 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.25 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.24 14-Oct-1997  thorpej Pull down from marc-pcmcia branch:

Minor tweaks to deal with PCMCIA differences, and support for power
management.
 1.23 13-Apr-1997  cgd branches: 1.23.4;
rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.22 13-Apr-1997  cgd use pci_map_register().
 1.21 30-Mar-1997  jonathan Add ifmedia hooks: include <ifmedia.h> and add sc_media to softc.
 1.20 30-Mar-1997  jonathan Match missing variants:
3c900 twisted-pair only, 3c595 mii, 3c595 100bT4, 3c905 100bT4.
Is there an MII version of the 3c905?
 1.19 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.18 18-Feb-1997  jonathan Move if_ep media-sense code from front ends to inside back end,
to prepare for if_media, and to support EISA 3c59x cards:

* change epconfig() to take a short that encodes the chipset
type (3c509, or Demon/Vortex/Boomerang).
* add distinct 3c509 and Demon/Vortex/Boomerang media-sense
functions to back end.
* Add EISA match/attach support for the 3c592 and 3c597
(Demon) cards as well as the 3c509-comatibl EISA 3c509/3c579.

* Assume that ISA and ISA PnP cards are 3c509-style, until
proof to the contrary (e.g. large packet support).

Tested on 3c595, 3c590, and 3c509b. Not tested on 3c515 or Demon.
 1.17 31-Dec-1996  jonathan branches: 1.17.4;
Use the same symbolic cnames for 100Mbit media as epconfig().
 1.16 30-Dec-1996  jonathan * make sure 100mbit media-present bits don't collied with 3c509
CONFIG_CNTRL bits by making the "conn" argument to epconfig()
a u_int, not a u_int16_t, and by defining 100mbit media
bits in the upper 16 bits.

A redesigned interface that fixes this properly is in the pipeline.
 1.15 29-Dec-1996  jonathan * Accept 100baseT4, MII variants of 3c595 as 3c595-model devices,
rather than unknown.

* Look for 100mbit interfaces, and for any present, set corresponding
bits in `conn' argument to epconfig(). epconfig() will now print
100Mbit media by name.
 1.14 05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.13 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.12 15-Oct-1996  christos Use the official 3com part names; from Curt Sampson
 1.11 13-Oct-1996  christos Apply PR/2840: Recognize more 3com models...
 1.10 13-Oct-1996  christos backout kprintf changes
 1.9 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 29-Sep-1996  christos Don't epstop() at the and of the attach
 1.7 13-May-1996  mycroft branches: 1.7.4;
Use intr.h.
 1.6 12-May-1996  thorpej Value returned by pci_conf_read() is a pcireg_t, so don't try to store
it in a u_short.
 1.5 12-May-1996  thorpej Don't use home-grown macros to extract PCI vendor and product IDs.
Also, be truthful; We're actually looking for Configuration Base IO
Address, not Configuration Base Memory Address.
 1.4 10-May-1996  thorpej Update Herb's e-mail address; beer.org feels a lot more friendly.
 1.3 03-May-1996  christos - include <sys/systm.h>
- remove unused variables
 1.2 30-Apr-1996  thorpej Convert the Etherlink III (ep) driver to use <machine/bus.h>.
 1.1 25-Apr-1996  thorpej Break up the ep driver into isa, eisa, and pci front-ends and a
bus-independent core driver. Tested on all three bus types, including
an isa 3c509 masquerading as an eisa device (use ep* at eisa? slot ? in
your kernel config file to catch this one).
XXX Driver still needs to be converted to <machine/bus.h>
 1.7.4.2 04-Mar-1997  mycroft Recognize 3c900 and 3c905 cards.
 1.7.4.1 04-Mar-1997  mycroft Update for new pcidevs.
 1.17.4.3 09-Mar-1997  is netinet/if_ether.h -> netinet/if_inarp.h
 1.17.4.2 20-Feb-1997  is Merged in recent changes from Trunk.
 1.17.4.1 07-Feb-1997  is Snapshot of new ARP code.

Our old ARP code was hardwired for 6-byte length medium
addresses, while the protocol is designed for any size.

This snapshot contains a first hack at getting rid of
Ethernet specific data structures. The ep driver is updated
(and tested on the PCI bus), the iy and fpa drivers have been
updated, but not real life tested yet.

If you want to test this with other drivers, you have to update
them first yourself, and probably tag the relevant directories.
Better contact me if you want to do this.
 1.23.4.2 27-Sep-1997  marc initialize enable/disable hooks to NULL so the bus independent code
dtrt.
 1.23.4.1 30-Jul-1997  marc added pcmcia infrastructure and a few devices
 1.32.8.1 05-Jan-2001  bouyer Sync with HEAD
 1.33.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.33.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.33.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.33.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.35.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.35.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.40.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.40.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.40.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.40.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.41.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.41.4.1 29-Apr-2005  kent sync with -current
 1.42.4.2 27-Oct-2007  yamt sync with head.
 1.42.4.1 30-Dec-2006  yamt sync with head.
 1.43.22.2 10-Dec-2006  yamt sync with head.
 1.43.22.1 22-Oct-2006  yamt sync with head
 1.43.20.1 18-Nov-2006  ad Sync with head.
 1.45.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.45.24.1 06-Nov-2007  matt sync with HEAD
 1.45.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.45.8.1 23-Oct-2007  ad Sync with head.
 1.46.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.46.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.47.4.4 11-Mar-2010  yamt sync with head
 1.47.4.3 16-May-2009  yamt sync with head
 1.47.4.2 04-May-2009  yamt sync with head.
 1.47.4.1 16-May-2008  yamt sync with head.
 1.47.2.1 18-May-2008  yamt sync with head.
 1.48.6.1 19-Oct-2008  haad Sync with HEAD.
 1.48.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.49.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.52.16.1 18-May-2014  rmind sync with head
 1.52.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.53.28.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.53.28.1 25-Jun-2018  pgoyette Sync with HEAD
 1.54.2.1 10-Jun-2019  christos Sync with HEAD
 1.43 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.42 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.41 29-Mar-2014  christos branches: 1.41.28; 1.41.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.40 30-Jan-2012  drochner branches: 1.40.6; 1.40.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.39 26-Jul-2011  dyoung branches: 1.39.2; 1.39.6;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.38 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.37 06-Jul-2008  tsutsui Split device_t/softc with misc cosmetic changes.
 1.36 28-Apr-2008  martin branches: 1.36.2; 1.36.4;
Remove clause 3 and 4 from TNF licenses
 1.35 21-Mar-2008  dyoung branches: 1.35.2; 1.35.4;
Use aprint_*_dev() instead of accessing struct device member dv_xname
directly.
 1.34 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.33 19-Oct-2007  ad branches: 1.33.12; 1.33.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.32 16-Nov-2006  christos branches: 1.32.8; 1.32.22; 1.32.24; 1.32.28;
__unused removal on arguments; approved by core.
 1.31 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.30 17-Jun-2006  christos branches: 1.30.4; 1.30.6;
re-factor the pci powestate api. reviewed by gimpy
 1.29 11-Dec-2005  christos branches: 1.29.4; 1.29.8; 1.29.14; 1.29.16;
merge ktrace-lwp.
 1.28 27-Feb-2005  perry branches: 1.28.4;
nuke trailing whitespace
 1.27 21-Aug-2004  thorpej branches: 1.27.4; 1.27.6;
Use ANSI function decls and make use of static.
 1.26 31-Jan-2003  thorpej branches: 1.26.2;
Use aprint_*().
 1.25 23-Dec-2002  tsutsui Always print the device name first in epic_pci_attach().
 1.24 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.23 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.22 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.21 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20 15-Jul-2002  drochner recognize a SMC9432BTX from PCI subsys id and tell the bus independant
backend that it bas a BNC port (just like the SMC9432BTX1)
 1.19 13-Nov-2001  lukem branches: 1.19.8;
add RCSID
 1.18 08-Jul-2001  thorpej branches: 1.18.2;
Remove unnecessary include files. From Onno van der Linden.
 1.17 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.16 17-May-2001  drochner check PCI subsystem ID for a SMC9432BTX1 or SMC9432FTX and tell the common
driver about their media support (BNC and 100FX, respectively)
 1.15 28-Dec-2000  sommerfeld branches: 1.15.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.14 17-Jul-2000  tron Don't make assumptions of the actual value of PCI_PMCSR_STATE_D0.
Problem noted by John Hawkinson.
 1.13 17-Jul-2000  tron Don't clobber bits from 2 to 31 when trying to change the power state.
Problem noted by John Hawkinson.
 1.12 16-Jul-2000  tron If card is in power state D3 put it into power state D0 so that it will
at least work after the next reboot.
 1.11 15-Jul-2000  tron Avoid printing duplicate colon when card is waked up.
 1.10 15-Jul-2000  tron Un-__P'ify kernel prototypes.
 1.9 15-Jul-2000  tron Improve kernel message when card is in power state D3. Instead of...

epic0 at pci0 dev 11 function 0 epic0: unable to wake up from ...

... print this:

epic0 at pci0 dev 11 function 0: unable to wake up from power state D3
 1.8 14-Jul-2000  tron Check if card was put into sleep mode using PCI/ACPI power management
and try to restart it. This patch based on hints by Jason Thorpe.
 1.7 27-Jul-1999  thorpej branches: 1.7.2; 1.7.12;
Add support for the SMC 83c175. Also, print out the chip rev when
we attach.
 1.6 24-Mar-1999  thorpej branches: 1.6.4;
Make sure bus mastering is enabled.
 1.5 11-Aug-1998  thorpej Adapt to new MII code.
 1.4 05-Jul-1998  jonathan defopt NS, NSIP.
 1.3 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.2 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.1 02-Jun-1998  thorpej Device driver for the SMC 83c170 Ethernet PCI Integrated Controller (EPIC/100)
used in the SMC EtherPower II.

Media control isn't yet supported, due to some MII infrastructure
problems which I hope to address soon. This isn't a huge deal, since
the PHY defaults to auto-negotiate mode.

Also, the device just programs the multicast hash table to accept all
multicast, to avoid a hardware bug that causes the multicast address
filter to lose in 10Mb/s mode. This bug will be fixed in a more sane
way once the media control issues are dealt with.
 1.6.4.1 02-Aug-1999  thorpej Update from trunk.
 1.7.12.4 16-Jul-2000  tron Sync with NetBSD-current (pull up approved by thorpej):

syssrc/sys/dev/pci/if_epic_pci.c, 1.12
syssrc/sys/dev/pci/if_tlp_pci.c, 1.43

If card is in power state D3 put it into power state D0 so that it will
at least work after the next reboot.
 1.7.12.3 15-Jul-2000  tron Sync with NetBSD-current (pull up approved by thorpej):

syssrc/sys/dev/pci/if_epic_pci.c, 1.11
syssrc/sys/dev/pci/if_tlp_pci.c, 1.42

Avoid printing duplicate colon when card is waked up.
 1.7.12.2 15-Jul-2000  tron Sync with NetBSD-current (pull up approved by thorpej):

syssrc/sys/dev/pci/if_epic_pci.c, 1.9
syssrc/sys/dev/pci/if_tlp_pci.c, 1.41

Improve kernel message when card is in power state D3. Instead of...

epic0 at pci0 dev 11 function 0 epic0: unable to wake up from ...

... print this:

epic0 at pci0 dev 11 function 0: unable to wake up from power state D3
 1.7.12.1 14-Jul-2000  tron Pull up revision 1.8 (approved by thorpej):
Check if card was put into sleep mode using PCI/ACPI power management
and try to restart it. This patch based on hints by Jason Thorpe.
 1.7.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.15.2.6 29-Dec-2002  thorpej Sync with HEAD.
 1.15.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.15.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.15.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.18.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.18.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.8.1 20-Jul-2002  gehenna catch up with -current.
 1.26.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.26.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.26.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.27.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.27.4.1 29-Apr-2005  kent sync with -current
 1.28.4.4 24-Mar-2008  yamt sync with head.
 1.28.4.3 27-Oct-2007  yamt sync with head.
 1.28.4.2 30-Dec-2006  yamt sync with head.
 1.28.4.1 21-Jun-2006  yamt sync with head.
 1.29.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.29.14.1 19-Jun-2006  chap Sync with head.
 1.29.8.1 26-Jun-2006  yamt sync with head.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.30.6.2 10-Dec-2006  yamt sync with head.
 1.30.6.1 22-Oct-2006  yamt sync with head
 1.30.4.1 18-Nov-2006  ad Sync with head.
 1.32.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.32.24.2 23-Mar-2008  matt sync with HEAD
 1.32.24.1 06-Nov-2007  matt sync with HEAD
 1.32.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.32.8.1 23-Oct-2007  ad Sync with head.
 1.33.16.3 28-Sep-2008  mjf Sync with HEAD.
 1.33.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.33.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.33.12.1 24-Mar-2008  keiichi sync with head.
 1.35.4.3 11-Mar-2010  yamt sync with head
 1.35.4.2 04-May-2009  yamt sync with head.
 1.35.4.1 16-May-2008  yamt sync with head.
 1.35.2.1 18-May-2008  yamt sync with head.
 1.36.4.1 18-Jul-2008  simonb Sync with head.
 1.36.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.39.6.1 18-Feb-2012  mrg merge to -current.
 1.39.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.2.1 17-Apr-2012  yamt sync with head
 1.40.10.1 18-May-2014  rmind sync with head
 1.40.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.30.1 10-Jun-2019  christos Sync with HEAD
 1.41.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.4 19-Dec-2023  skrll Remove unnecessary #include
 1.3 31-Oct-2023  msaitoh branches: 1.3.2;
eqos_pci: Limit to 32bit DMA only for PSE devices.
 1.2 26-Oct-2023  msaitoh eqos(4): Set TX/RX DMA burst length to improve performance.
 1.1 20-Oct-2023  msaitoh eqos(4): Add initial support for Intel Elkhart Lake internal Ethernet devices.

- Only tested on PSE SGMII 1G Ethernet MAC with MaxLinear GPY115.
- I don't know why dmat64 doesn't work. eqos_attach() have a special
code if EQOS_HW_FEATURE_ADDR64_32BIT(sc) is true, but it seems it doesn't
work.
- TODO:
Multiqueue support.
Detach support.
 1.3.2.2 03-Nov-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #446):

sys/dev/pci/if_eqos_pci.c: revision 1.3
sys/arch/i386/conf/GENERIC: revision 1.1251
sys/arch/i386/conf/GENERIC: revision 1.1252
sys/arch/amd64/conf/GENERIC: revision 1.607
sys/arch/amd64/conf/GENERIC: revision 1.608
sys/dev/ic/dwc_eqos.c: revision 1.20
sys/dev/ic/dwc_eqos.c: revision 1.21
share/man/man4/eqos.4: revision 1.2
sys/dev/ic/dwc_eqos.c: revision 1.22
sys/dev/ic/dwc_eqos_reg.h: revision 1.7
sys/dev/ic/dwc_eqos.c: revision 1.23
sys/dev/ic/dwc_eqos_reg.h: revision 1.8
sys/dev/ic/dwc_eqos.c: revision 1.24
sys/dev/ic/dwc_eqos.c: revision 1.25
sys/dev/ic/dwc_eqos.c: revision 1.26
sys/dev/ic/dwc_eqos.c: revision 1.27
sys/dev/ic/dwc_eqos_var.h: revision 1.5
sys/dev/ic/dwc_eqos.c: revision 1.28
sys/dev/ic/dwc_eqos_var.h: revision 1.6
sys/dev/ic/dwc_eqos.c: revision 1.29
sys/dev/ic/dwc_eqos.c: revision 1.18
sys/dev/ic/dwc_eqos.c: revision 1.19
sys/dev/pci/files.pci: revision 1.448
sys/dev/pci/if_eqos_pci.c: revision 1.1
sys/dev/pci/if_eqos_pci.c: revision 1.2

eqos(4): Fix definition of GMAC_MAC_HW_FEATURE1_RXFIFOSIZE.

eqos(4): Fix a bug that the MAC address is swapped.
Don't swap the MAC address in eqos_get_eaddr(). Other OSes except FreeBSD
(which was based on NetBSD's) don't swap it. With this change, my own
OnLogic Helix 330's MAC address becomes correct. The OUI is 84:8b:cd:4d.
It's owned by Logic Supply and they were acquired by OnLogic.

On Quartz64 with UEFI, the MAC address is wrongly set and the multicast
bit might be set. To do workaround, clear the bit if it's set.

eqos(4): Add missing clock range.

eqos(4): Accept if snpsver == 0x52. Tested with Intel Elkhart Lake.

TODO:
Multiqueue support.
Add watchdog timer.
Add detach function.

eqos(4): Add initial support for Intel Elkhart Lake internal Ethernet devices.
- Only tested on PSE SGMII 1G Ethernet MAC with MaxLinear GPY115.
- I don't know why dmat64 doesn't work. eqos_attach() have a special
code if EQOS_HW_FEATURE_ADDR64_32BIT(sc) is true, but it seems it doesn't
work.
- TODO:
Multiqueue support.
Detach support.

eqos(4): Fix compile error for arch that sizeof(bus_size_t) == 4 (i386).
Trailing whitespace

eqos(4): Disable eqos(4) by default because it's not stable on x86.

eqos(4): KNF. No functional change.

eqos(4): Add and modify some DPRINTF()s.

eqos(4): Add sysctls for debugging.

eqos(4): Use EQOS_TXLOCK() more to be stable.
Fix a bug that sc_tx.{cur,next,queued} become inconsitent.
Use txlock when accessing TX data.

eqos(4): Set TX/RX DMA burst length to improve performance.

eqos(4): Set flow control correctly.

eqos_pci: Limit to 32bit DMA only for PSE devices.

eqos(4): Fix typo in comment.
 1.3.2.1 31-Oct-2023  martin file if_eqos_pci.c was added on branch netbsd-10 on 2023-11-03 08:56:36 +0000
 1.34 19-Jan-2020  thorpej Remove HIPPI support and the esh(4) driver that uses it. There have not
been any users of HIPPI for some time, and it is unlikely to be resurrected.
 1.33 09-Dec-2018  jdolecek branches: 1.33.6;
use pci_intr_establish_xname() everywhere
 1.32 07-Jul-2016  msaitoh branches: 1.32.16; 1.32.18;
KNF. Remove extra spaces. No functional change.
 1.31 29-Mar-2014  christos branches: 1.31.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.30 27-Oct-2012  chs branches: 1.30.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.29 26-Jul-2011  dyoung branches: 1.29.2; 1.29.12;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.28 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.27 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.26 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.25 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.24 28-Apr-2008  martin branches: 1.24.14;
Remove clause 3 and 4 from TNF licenses
 1.23 10-Apr-2008  cegger branches: 1.23.2; 1.23.4;
use aprint_*_dev and device_xname
 1.22 19-Oct-2007  ad branches: 1.22.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.21 16-Nov-2006  christos branches: 1.21.8; 1.21.22; 1.21.24; 1.21.28;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 11-Dec-2005  christos branches: 1.19.20; 1.19.22;
merge ktrace-lwp.
 1.18 30-May-2005  christos branches: 1.18.2;
- const poisoning
- avoid variable shadowing.
 1.17 27-Feb-2005  perry nuke trailing whitespace
 1.16 28-Oct-2004  yamt branches: 1.16.4; 1.16.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.15 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.14 31-Jan-2003  thorpej branches: 1.14.2;
Use aprint_*().
 1.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 13-Nov-2001  lukem add RCSID
 1.9 08-Jul-2001  thorpej branches: 1.9.2;
Remove unnecessary include files. From Onno van der Linden.
 1.8 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.7 28-Dec-2000  sommerfeld branches: 1.7.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.6 21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.5 05-Jul-1998  jonathan branches: 1.5.14;
defopt NS, NSIP.
 1.4 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.3 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.2 17-May-1998  kml Correct copyright date.
 1.1 14-May-1998  kml Driver for Essential Communications' RoadRunner HIPPI (800 Mb/sec network)
card. With some modification, this could probably also work for their
Gigabit Ethernet card based on the same chipset...
 1.5.14.2 05-Jan-2001  bouyer Sync with HEAD
 1.5.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.9.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.16.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.16.4.1 29-Apr-2005  kent sync with -current
 1.18.2.2 27-Oct-2007  yamt sync with head.
 1.18.2.1 30-Dec-2006  yamt sync with head.
 1.19.22.2 10-Dec-2006  yamt sync with head.
 1.19.22.1 22-Oct-2006  yamt sync with head
 1.19.20.1 18-Nov-2006  ad Sync with head.
 1.21.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.21.24.1 06-Nov-2007  matt sync with HEAD
 1.21.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.21.8.1 23-Oct-2007  ad Sync with head.
 1.22.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.4.3 11-Mar-2010  yamt sync with head
 1.23.4.2 16-May-2009  yamt sync with head
 1.23.4.1 16-May-2008  yamt sync with head.
 1.23.2.1 18-May-2008  yamt sync with head.
 1.24.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.29.12.3 03-Dec-2017  jdolecek update from HEAD
 1.29.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29.2.1 30-Oct-2012  yamt sync with head
 1.30.2.1 18-May-2014  rmind sync with head
 1.31.6.1 09-Jul-2016  skrll Sync with HEAD
 1.32.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.18.1 10-Jun-2019  christos Sync with HEAD
 1.32.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.33.6.1 25-Jan-2020  ad Sync with head.
 1.36 01-Aug-2023  andvar s/diabled/disabled/ in comments.
 1.35 10-Sep-2021  jakllsch if_et.c: nothing in this driver needs netinet includes now,
so drop #include "opt_inet.h" and the includes of netinet headers
conditioned on it.
 1.34 10-Sep-2021  jakllsch No need to #include "vlan.h", as NVLAN is not used in these drivers now.
 1.33 08-May-2021  thorpej Use pci_compatible_match().
 1.32 01-Mar-2020  thorpej branches: 1.32.10;
Use the 64-bit PCI DMA tag if available.
 1.31 28-Feb-2020  msaitoh Move PHY_RESET() in the media change path from if_et.c to etphy.c.

I don't know if the reset is required or not. I tested some media
transitions without the reset and it worked. It might be OK to remove
but Linux does it only in et1011c_config_aneg(). So move the reset to
etphy_service(,,MII_MEDIACHG)'s autonego case. This change is also
required for future locking changes.
 1.30 04-Feb-2020  thorpej Use ifmedia_fini().
 1.29 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.28 28-Nov-2019  maxv branches: 1.28.2;
localify
 1.27 12-Oct-2019  msaitoh Fix a bug that multicast address filter doesn't work correctly.

XXX pullup-[789].
 1.26 01-Aug-2019  msaitoh Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.
 1.25 31-Jul-2019  msaitoh Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.
 1.24 28-May-2019  msaitoh branches: 1.24.2;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.23 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.22 22-Apr-2019  msaitoh On drivers which use MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.
 1.21 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.20 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.19 22-Dec-2018  maxv Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
 1.18 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.17 26-Jun-2018  msaitoh branches: 1.17.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.16 08-Feb-2018  mrg branches: 1.16.2;
update for GCC 6:

- fix an array bounds violation and pass the right address to ether_crc32_be().

(i assume this actually makes et(4) multicast work.)
 1.15 29-Jul-2017  riastradh Check for MCLGET failure in et_newbuf.

From Ilja Van Sprundel.
 1.14 15-Dec-2016  ozaki-r branches: 1.14.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.13 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.12 10-Jun-2016  ozaki-r branches: 1.12.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.11 17-Feb-2016  christos PR/50819: David Binderman: Delete dead code.
 1.10 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.9 29-Jun-2015  maxv Use-after-free.

ok christos@

Found by Brainy.
 1.8 29-Mar-2014  christos branches: 1.8.4; 1.8.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.7 30-Mar-2013  christos branches: 1.7.4;
remove trailing whitespace
 1.6 08-Nov-2012  dyoung Use native NetBSD macros instead of compatibility macros.

This change compiles, but I don't have an et(4) with which to test.
 1.5 29-Oct-2012  msaitoh Don't use old NBPFILTER macro and use new bpf_mtap() API.
It fixes a bug that et(4) can't use bpf.
 1.4 22-Jul-2012  matt branches: 1.4.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.3 30-Jan-2012  drochner branches: 1.3.2; 1.3.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.2 18-May-2011  dyoung branches: 1.2.4; 1.2.8;
#include <sys/bus.h>, not <machine/bus.h>.
 1.1 13-Nov-2010  jnemeth branches: 1.1.2; 1.1.6;
PR/39094 - Kaspar Brand -- Add et (Agere ET1310/ET1301) network driver

The et(4) driver supports PCI Express Ethernet adapters based on
the Agere/LSI ET1310/ET1301 integrated MAC/PHY.

The et(4) driver was written by Sepherosa Ziehau for DragonFlyBSD,
ported to OpenBSD by Jonathan Gray and subsequently ported to NetBSD
by Kaspar Brand.
 1.1.6.3 31-May-2011  rmind sync with head
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 13-Nov-2010  rmind file if_et.c was added on branch rmind-uvmplock on 2011-03-05 20:53:40 +0000
 1.1.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 18-Feb-2012  mrg merge to -current.
 1.2.4.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.2.4.2 30-Oct-2012  yamt sync with head
 1.2.4.1 17-Apr-2012  yamt sync with head
 1.3.6.1 18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1474):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.3.2.2 18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1474):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.3.2.1 19-Nov-2012  riz branches: 1.3.2.1.2;
Pull up following revision(s) (requested by msaitoh in ticket #655):
sys/dev/pci/if_et.c: revision 1.5
Don't use old NBPFILTER macro and use new bpf_mtap() API.
It fixes a bug that et(4) can't use bpf.
 1.3.2.1.2.1 18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1474):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.4.2.4 03-Dec-2017  jdolecek update from HEAD
 1.4.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.2.2 23-Jun-2013  tls resync from head
 1.4.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.7.4.1 18-May-2014  rmind sync with head
 1.8.6.5 28-Aug-2017  skrll Sync with HEAD
 1.8.6.4 05-Feb-2017  skrll Sync with HEAD
 1.8.6.3 09-Jul-2016  skrll Sync with HEAD
 1.8.6.2 19-Mar-2016  skrll Sync with HEAD
 1.8.6.1 22-Sep-2015  skrll Sync with HEAD
 1.8.4.2 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1470):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.8.4.1 04-Aug-2015  snj branches: 1.8.4.1.2; 1.8.4.1.6;
Pull up following revision(s) (requested by maxv in ticket #914):
sys/dev/pci/if_et.c: revision 1.9
Use-after-free.
ok christos@
Found by Brainy.
 1.8.4.1.6.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1470):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.8.4.1.2.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1470):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.12.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.14.8.4 17-Oct-2019  martin Pull up the following revision, requested by msaitoh in ticket #1407:

sys/dev/pci/if_et.c 1.27 via patch

Fix a bug that multicast address filter doesn't work correctly.
 1.14.8.3 06-Aug-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1329:

sys/dev/pci/if_etreg.h 1.2-1.3
sys/dev/pci/if_et.c 1.23,1.25 and 1.26
via patch

Make et(4) work:
- Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags
controllable.
- Enabling TX/RX in et_init() will always fail when cable is not
plugged in. If this happens, we delay TX/RX enablement until link is
up.
- Modify flow control stuff a little. It still doesn't work.
- Avoid undefined behavior when reset the chip.
- Code cleanup.
 1.14.8.2 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.14.8.1 05-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #183):
sys/dev/pci/if_et.c: revision 1.15
Check for MCLGET failure in et_newbuf.
From Ilja Van Sprundel.
 1.16.2.3 26-Jan-2019  pgoyette Sync with HEAD
 1.16.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.16.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.17.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17.2.1 10-Jun-2019  christos Sync with HEAD
 1.24.2.2 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #346):

sys/dev/pci/if_et.c: revision 1.27

Fix a bug that multicast address filter doesn't work correctly.
XXX pullup-[789].
 1.24.2.1 09-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #36):

sys/dev/pci/if_et.c: revision 1.25
sys/dev/pci/if_et.c: revision 1.26
sys/dev/pci/if_etreg.h: revision 1.2
sys/dev/pci/if_etreg.h: revision 1.3

Avoid undefined behavior when reset the chip. found by kUBSan.

Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.

Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.
 1.28.2.1 29-Feb-2020  ad Sync with head.
 1.32.10.1 13-May-2021  thorpej Sync with HEAD.
 1.5 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.4 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.3 01-Aug-2019  msaitoh Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.
 1.2 30-Jul-2019  msaitoh Avoid undefined behavior when reset the chip. found by kUBSan.
 1.1 13-Nov-2010  jnemeth branches: 1.1.6; 1.1.54; 1.1.62; 1.1.68;
PR/39094 - Kaspar Brand -- Add et (Agere ET1310/ET1301) network driver

The et(4) driver supports PCI Express Ethernet adapters based on
the Agere/LSI ET1310/ET1301 integrated MAC/PHY.

The et(4) driver was written by Sepherosa Ziehau for DragonFlyBSD,
ported to OpenBSD by Jonathan Gray and subsequently ported to NetBSD
by Kaspar Brand.
 1.1.68.1 09-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #36):

sys/dev/pci/if_et.c: revision 1.25
sys/dev/pci/if_et.c: revision 1.26
sys/dev/pci/if_etreg.h: revision 1.2
sys/dev/pci/if_etreg.h: revision 1.3

Avoid undefined behavior when reset the chip. found by kUBSan.

Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.

Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.
 1.1.62.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.54.1 06-Aug-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1329:

sys/dev/pci/if_etreg.h 1.2-1.3
sys/dev/pci/if_et.c 1.23,1.25 and 1.26
via patch

Make et(4) work:
- Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags
controllable.
- Enabling TX/RX in et_init() will always fail when cable is not
plugged in. If this happens, we delay TX/RX enablement until link is
up.
- Modify flow control stuff a little. It still doesn't work.
- Avoid undefined behavior when reset the chip.
- Code cleanup.
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 13-Nov-2010  rmind file if_etreg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:40 +0000
 1.58 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.57 29-Mar-2014  christos branches: 1.57.28; 1.57.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.56 13-Sep-2013  martin Remove unused variable
 1.55 30-Mar-2013  christos branches: 1.55.4;
remove trailing whitespace
 1.54 26-Jul-2011  dyoung branches: 1.54.2; 1.54.12;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.53 22-Mar-2010  dyoung ex_softc.ex_bustype is written but never read. Just get rid of it.
 1.52 22-Mar-2010  dyoung psc_pwrmgmt_csr_reg was never initialized to the actual offset of the
PCI PMCSR! Just delete psc_pwrmgmt_csr_reg and all uses of it. In this
way, ex_pci_disable() becomes a no-op, so delete it, too.
 1.51 26-Feb-2010  dyoung branches: 1.51.2;
Move the definitions for PCI_BAR0, PCI_BAR1, PCI_BAR2, PCI_BAR3,
PCI_BAR4, and PCI_BAR5 to pcireg.h for re-use.
 1.50 05-May-2009  cegger branches: 1.50.2;
print autoconf error message with aprint_error
 1.49 28-Apr-2008  martin branches: 1.49.14;
Remove clause 3 and 4 from TNF licenses
 1.48 14-Apr-2008  cegger branches: 1.48.2; 1.48.4;
- ansify
- use POSIX integers
 1.47 14-Apr-2008  spz pretty up if_ex: pmf'ify, device split, and improve printing a bit too.

Reviewed and function-tested on if_ex_cardbus by cube (thanks).
Function-tested on if_ex_pci by myself.
 1.46 10-Apr-2008  cegger use aprint_*_dev and device_xname
 1.45 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.44 19-Oct-2007  ad branches: 1.44.12; 1.44.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.43 16-Nov-2006  christos branches: 1.43.8; 1.43.22; 1.43.24; 1.43.28;
__unused removal on arguments; approved by core.
 1.42 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.41 17-Jun-2006  christos branches: 1.41.4; 1.41.6;
re-factor the pci powestate api. reviewed by gimpy
 1.40 11-Dec-2005  christos branches: 1.40.4; 1.40.8; 1.40.14; 1.40.16;
merge ktrace-lwp.
 1.39 27-Feb-2005  perry branches: 1.39.4;
nuke trailing whitespace
 1.38 24-Feb-2005  martin Fix the size of psc_regs (0x3c >> 2 is the biggest index used to access
it now, so pick 0x40 >> 2). Fixes "Bug 6", reported by Ted Unangst on
tech-kern.
 1.37 21-Aug-2004  thorpej branches: 1.37.4; 1.37.6;
Use ANSI function decls and make use of static.
 1.36 15-Jul-2004  junyoung Add support for 3Com 3c920B-EMB-WNM Integrated Fast Ethernet,
as found on Asus P4R800-VM motherboards.

From BL on Korea BSD User Forum (sorry but I don't know his real name).
 1.35 05-Jun-2003  dogcow branches: 1.35.2; 1.35.4;
Some models of the 556B don't turn on the transmitter without magic
values getting written. Fix from FreeBSD; cf sys/pci/if_xl.c, rev 1.110
 1.34 19-Apr-2003  christos Put back bits of pr 9286 that got lost. Thanks to Onno van der Linden for
pointing this.
 1.33 12-Apr-2003  christos PR/9286: Steven Grunza: Win98 warm boot puts 3c905B in state D3 and causes
ex driver failure
 1.32 31-Jan-2003  thorpej Use aprint_*().
 1.31 16-Jan-2003  gendalia Add support for 3com 3c905CX-TX found on nForce2 MCP-T.
 1.30 23-Dec-2002  tsutsui Set PCI_PMCSR more properly.
 1.29 23-Dec-2002  tsutsui Save PCI_PMCSR value correctly.
 1.28 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.27 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.26 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.25 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.24 01-Jul-2002  thorpej Also save/restore the PCI_INTERRUPT_REG.
 1.23 20-Jun-2002  itojun more proper fix to ex_disable.
 1.22 20-Jun-2002  itojun make it compile (ex_disable).
not sure if it is 100% right.
 1.21 20-Jun-2002  thorpej If the chip supports ACPI power management:
* Go to D3 if IFF_UP == 0.
* Go to D0 if IFF_UP == 1.

Saves battery life on my T21, mmm.
 1.20 07-Feb-2002  christos branches: 1.20.8;
Turn on mii on 3C980CTXM
 1.19 13-Nov-2001  lukem add RCSID
 1.18 18-Aug-2001  kanaoka Improve intr_ack code to support for 3c556,3c556B.
Some cards don't have an interrupt acknowledge
register in PCI config space, so we map and write
it, such as CardBus driver does.
 1.17 08-Jul-2001  thorpej branches: 1.17.2;
Remove unnecessary include files. From Onno van der Linden.
 1.16 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.15 28-Dec-2000  sommerfeld branches: 1.15.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.14 19-Sep-2000  fvdl Add support for the 3c555, 556 and 556B MiniPCI cards. Based on the
cardbus code and the FreeBSD xl driver.
 1.13 07-Aug-2000  billc Added PCI IDs for 3Com's Home Connect (3c450) and Office Connect (3cSOHO100).
They both are register compat with later versions of the 3c905 (tornado/
vortex) series.
 1.12 12-May-2000  thorpej branches: 1.12.4;
Treat the 3c980C-TXM like the 3c980 Server Adapter. From Paul J. Lavoie,
kern/10037.
 1.11 23-Mar-2000  mycroft Rather than guessing at the location of the PMCSR, use the pointer returned by
pci_get_capability(). (This is, after all, a standardized interface...)
 1.10 13-Jan-2000  mycroft Remove EX_CONF_MII for the 3c980. At least 2 people need this for the card
to work.
 1.9 30-Nov-1999  drochner -support 3c905B-COMBO - somewhat preliminary: the chip has both an internal
MII PHY capable of NWAY (according to the Linux driver) and plain BNC/
transceiver connectors. The shared code can't handle this yet, so leave
out MII/NWAY for now.
-print out revision number from PCI config header, this has been useful to
identify buggy chips
 1.8 01-Sep-1999  fvdl branches: 1.8.2; 1.8.8;
Don't assume that an -FX card has MII (because it doesn't).
 1.7 15-Jul-1999  ross Recognize 3c905C.
 1.6 29-May-1999  fvdl Recognize 900B-TPC. From Robert Elz.
 1.5 20-Feb-1999  ross branches: 1.5.2; 1.5.4; 1.5.6;
Fix typo.
 1.4 19-Feb-1999  thorpej Improve product descriptions, and add 3c905-FX and 3c980 Server Adapter
products.
 1.3 09-Nov-1998  thorpej Make the device lookup table-driven, like if_ep_pci.c.
 1.2 07-Nov-1998  drochner use common code for extended capability (power management)
let "match" return 2 (> ep_pci)
 1.1 04-Nov-1998  fvdl Add the 'ex' driver, a DMA driver for 3Com 90x and 90xB cards. Rename
constants from EP_ to ELINK_ since they're now used in the ex driver as well.
 1.5.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.5.4.2 02-Aug-1999  thorpej Update from trunk.
 1.5.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.4 11-Sep-2000  he Pull up revision 1.13 (requested by billc):
Recognize 3Com's Home Connect (3c450) and Office Connect (3cSOHO100)
Ethernet cards.
 1.5.2.3 15-Jan-2000  he Pull up revision 1.10 (requested by mycroft):
Make the 3c980 actually work.
 1.5.2.2 29-Aug-1999  he Pull up revision 1.7:
Recognize 3c905C-TX card. (bouyer)
 1.5.2.1 22-Jun-1999  perry pullup 1.5->1.6 (fvdl): recognize another 390xB card
 1.8.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.4.3 01-Jan-2002  he Pull up revision 1.18 (requested by kanaoka):
Improve intr_ack code to support 3c556 and 3c556B.
 1.12.4.2 20-Mar-2001  he Pull up revision 1.14 (requested by chuck):
Add support for the 3Com 3c555, 3c556 and 3c556B MiniPCI Ethernet
cards.
 1.12.4.1 19-Oct-2000  he Pull up revision 1.13 (requested by billc):
Add PCI IDs for 3Com Home Connect (3c450) and Office Connect
(3cSOHO100), register compatible with later versions of 3c905.
 1.15.2.8 17-Jan-2003  thorpej Sync with HEAD.
 1.15.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.15.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.15.2.5 01-Aug-2002  nathanw Catch up to -current.
 1.15.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.15.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.17.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.17.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.17.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.17.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.20.8.1 15-Jul-2002  gehenna catch up with -current.
 1.35.4.1 22-Aug-2004  tron Pull up revision 1.36 (requested by junyoung in ticket #781):
Add support for 3Com 3c920B-EMB-WNM Integrated Fast Ethernet,
as found on Asus P4R800-VM motherboards.
From BL on Korea BSD User Forum (sorry but I don't know his real name).
 1.35.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.35.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.35.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.35.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.35.2.1 03-Aug-2004  skrll Sync with HEAD
 1.37.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.37.4.1 29-Apr-2005  kent sync with -current
 1.39.4.4 24-Mar-2008  yamt sync with head.
 1.39.4.3 27-Oct-2007  yamt sync with head.
 1.39.4.2 30-Dec-2006  yamt sync with head.
 1.39.4.1 21-Jun-2006  yamt sync with head.
 1.40.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.40.14.1 19-Jun-2006  chap Sync with head.
 1.40.8.1 26-Jun-2006  yamt sync with head.
 1.40.4.1 09-Sep-2006  rpaulo sync with head
 1.41.6.2 10-Dec-2006  yamt sync with head.
 1.41.6.1 22-Oct-2006  yamt sync with head
 1.41.4.1 18-Nov-2006  ad Sync with head.
 1.43.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.43.24.2 23-Mar-2008  matt sync with HEAD
 1.43.24.1 06-Nov-2007  matt sync with HEAD
 1.43.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.43.8.1 23-Oct-2007  ad Sync with head.
 1.44.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.44.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.44.12.1 24-Mar-2008  keiichi sync with head.
 1.48.4.4 11-Aug-2010  yamt sync with head.
 1.48.4.3 11-Mar-2010  yamt sync with head
 1.48.4.2 16-May-2009  yamt sync with head
 1.48.4.1 16-May-2008  yamt sync with head.
 1.48.2.1 18-May-2008  yamt sync with head.
 1.49.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.2.1 30-May-2010  rmind sync with head
 1.54.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.12.1 23-Jun-2013  tls resync from head
 1.54.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.55.4.1 18-May-2014  rmind sync with head
 1.57.30.1 10-Jun-2019  christos Sync with HEAD
 1.57.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.64 20-Jan-2020  thorpej Remove FDDI support.
 1.63 10-Nov-2019  chs branches: 1.63.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.62 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.61 22-Jun-2018  msaitoh branches: 1.61.2;
It's not required to include net/bpfdesc.h. Remove it.
 1.60 25-Jan-2015  martin branches: 1.60.10; 1.60.16;
Fix obviously missing "sc->sc_dev = self" initialization.
Might help PR port-i386/49602.
 1.59 29-Mar-2014  christos branches: 1.59.4; 1.59.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.58 27-Oct-2012  chs branches: 1.58.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.57 19-Jan-2010  pooka branches: 1.57.12; 1.57.22;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.56 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.55 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.54 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.53 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.52 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.51 18-Mar-2009  cegger bcopy -> memcpy
 1.50 12-Jun-2008  cegger branches: 1.50.4; 1.50.10;
use device_lookup_private to get softc
 1.49 10-Apr-2008  cegger branches: 1.49.2; 1.49.4; 1.49.6; 1.49.8;
use aprint_*_dev and device_xname
 1.48 04-Mar-2007  christos branches: 1.48.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.47 16-Nov-2006  christos branches: 1.47.4;
__unused removal on arguments; approved by core.
 1.46 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.45 11-Dec-2005  christos branches: 1.45.20; 1.45.22;
merge ktrace-lwp.
 1.44 27-Feb-2005  perry branches: 1.44.4;
nuke trailing whitespace
 1.43 31-Jan-2003  thorpej branches: 1.43.2; 1.43.10; 1.43.12;
Use aprint_*().
 1.42 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.41 02-Oct-2002  thorpej Remove unnecessary extern decl of fpa_ca.
 1.40 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.39 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.38 14-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of bzero() after malloc().

XXX It seems these attachments need to be rewritten for modern config(9)..
 1.37 13-Nov-2001  lukem add RCSID
 1.36 07-Jul-2001  thorpej branches: 1.36.2;
bcopy -> strcpy
 1.35 13-Jun-2001  wiz withough -> without
 1.34 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.33 28-Dec-2000  sommerfeld branches: 1.33.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.32 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.31 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.30 30-Mar-2000  augustss Remove register declarations.
 1.29 01-Jun-1999  thorpej branches: 1.29.2;
Make sure bus mastering is enabled; some broken BIOSes don't set this
up properly.
 1.28 13-Aug-1998  eeh branches: 1.28.4; 1.28.6; 1.28.8; 1.28.10;
Merge paddr_t changes into the main branch.
 1.27 05-Jul-1998  jonathan branches: 1.27.2;
defopt INET, NETATALK.
 1.26 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.25 21-May-1998  matt Add bus_dma(9) support for the DEFxA FDDI driver
 1.24 12-Jan-1998  thorpej Update for config changes.
 1.23 09-Jun-1997  thorpej Duplicate register mapping logic from Tulip driver.
 1.22 08-Jun-1997  thorpej Merge pdq-970604 update.
 1.21 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.20 13-Apr-1997  cgd use pci_map_register(). map both mem and I/O spaces, preferring mem
space if it's usable, but falling back to I/O space if mem isn't usable.
 1.19 11-Apr-1997  cgd add a missing newline
 1.18 24-Mar-1997  thorpej Resolve conflicts from merge.
 1.17 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.16 05-Dec-1996  cgd branches: 1.16.4;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.15 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.14 13-Oct-1996  christos backout kprintf changes
 1.13 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.12 17-Jun-1996  cgd FPA probe would always return zero, because of incorrect return statement.
Patch provided by Peter Galbavy in PR 2555.
 1.11 20-May-1996  thorpej branches: 1.11.2;
Remove some extra printfs, now that Matt has lessened my confusion.
 1.10 20-May-1996  thorpej Fix conflicts from import, clean up a few printfs, and use the
generic PCI vendor/product definitions, rather than home-grown versions.
 1.9 13-May-1996  mycroft Use intr.h.
 1.8 07-May-1996  thorpej Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
 1.7 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.6 14-Mar-1996  cgd include pcireg before pcivar.h
 1.5 11-Mar-1996  thorpej Resolve conflicts from merge.
 1.4 09-Mar-1996  thorpej Fill in the missing pieces and make the NetBSD version of Matt Thomas's
DEFPA FDDI driver actually compile and link.
 1.3 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.2 19-Aug-1995  cgd local adaptations, and fix a could of compilation errors
 1.1 19-Aug-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.5 08-Jun-1997  thorpej Update of DEC PDQ FDDI driver, from Matt Thomas <matt@3am-software.com>.
 1.1.1.4 24-Mar-1997  thorpej Update from Matt Thomas <matt@3am-software.com>. Notable highlight:
the DEFTA (TurboChannel) card now works on the Alpha!
 1.1.1.3 20-May-1996  thorpej Update to the Digital Equipment PDQ-based FDDI controllers, from
Matt Thomas. Now includes support for EISA (DEFEA) and first-cut of
support for TurboChannel (DEFTA) cards.
 1.1.1.2 11-Mar-1996  thorpej New snapshot of DEC PDQ-based FDDI driver, from Matt Thomas.
 1.1.1.1 19-Aug-1995  cgd Generic FDDI support by Matt Thomas. Support for DEC "PDQ" FDDI chipset
and for the PCI attachment of said chipset ("if_fpa"), also from Matt Thomas.
Arguably, pdq* doesn't belong in sys/dev/ic, but it's going to be shared by
various bus attachment devices at some point in the future, and there's no
other place that seems to fit as well.
 1.11.2.1 17-Jun-1996  cgd pull up from trunk:
>FPA probe would always return zero, because of incorrect return statement.
>Patch provided by Peter Galbavy in PR 2555.
 1.16.4.4 09-Mar-1997  is netinet/if_ether.h -> netinet/if_inarp.h
 1.16.4.3 27-Feb-1997  is Removed #include <route.h> and #include <netisr.h>. They're not needed, and
the latter will go away soon.
 1.16.4.2 20-Feb-1997  is Give fddi_ifattach() a 2nd parameter, like ether_ifattach(): a pointer to the
link level address. xxx_ifattach() copy it to the sockaddr_dl structure
associated with the interface.

Change pdq to pass that parameter.
Change frontend to not copy the l.l.a. itself.
 1.16.4.1 07-Feb-1997  is Snapshot of new ARP code.

Our old ARP code was hardwired for 6-byte length medium
addresses, while the protocol is designed for any size.

This snapshot contains a first hack at getting rid of
Ethernet specific data structures. The ep driver is updated
(and tested on the PCI bus), the iy and fpa drivers have been
updated, but not real life tested yet.

If you want to test this with other drivers, you have to update
them first yourself, and probably tag the relevant directories.
Better contact me if you want to do this.
 1.27.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.28.10.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.28.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.28.6.1 21-Jun-1999  perry pullup 1.28->1.29 (thorpej): Make sure bus mastering is enabled
 1.28.4.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.29.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.29.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.33.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.33.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.33.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.33.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.33.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.36.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.36.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.36.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.43.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.43.10.1 29-Apr-2005  kent sync with -current
 1.43.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.44.4.1 03-Sep-2007  yamt sync with head.
 1.45.22.2 10-Dec-2006  yamt sync with head.
 1.45.22.1 22-Oct-2006  yamt sync with head
 1.45.20.1 18-Nov-2006  ad Sync with head.
 1.47.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.48.36.2 29-Jun-2008  mjf Sync with HEAD.
 1.48.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.49.8.1 18-Jun-2008  simonb Sync with head.
 1.49.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.49.4.3 11-Mar-2010  yamt sync with head
 1.49.4.2 16-May-2009  yamt sync with head
 1.49.4.1 04-May-2009  yamt sync with head.
 1.49.2.1 17-Jun-2008  yamt sync with head.
 1.50.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.57.22.3 03-Dec-2017  jdolecek update from HEAD
 1.57.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.57.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.57.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.57.12.1 30-Oct-2012  yamt sync with head
 1.58.2.1 18-May-2014  rmind sync with head
 1.59.6.1 06-Apr-2015  skrll Sync with HEAD
 1.59.4.1 31-Jan-2015  snj Pull up following revision(s) (requested by martin in ticket #469):
sys/dev/pci/if_fpa.c: revision 1.60
Fix obviously missing "sc->sc_dev = self" initialization.
Might help PR port-i386/49602.
 1.60.16.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.60.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.60.10.1 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.61.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.61.2.1 10-Jun-2019  christos Sync with HEAD
 1.63.2.1 25-Jan-2020  ad Sync with head.
 1.35 20-Jun-1999  thorpej Intel i82557 driver is now split into bus and chip bits.
 1.34 18-May-1999  thorpej Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.33 23-Mar-1999  thorpej branches: 1.33.2; 1.33.4; 1.33.6;
Make sure bus mastering is enabled.
 1.32 28-Feb-1999  explorer Update to slightly altered rnd_attach_source() api
 1.31 18-Feb-1999  thorpej Fix omission in previous.
 1.30 18-Feb-1999  thorpej Don't reset the interface when the media changes.
 1.29 18-Feb-1999  thorpej Back out to the previous stable revision of the fxp driver. The latest
one had too many stability problems.
 1.28 13-Feb-1999  thorpej Restructure the interrupt handler and 1-second timer a bit, and tidy up
the lazy-transmit-interrupt logic, fixing a few minor logic problems.

Now unable to reproduce the lockup problem described in PR #6767. Changing
PR's state to "feedback".
 1.27 19-Dec-1998  thorpej Changes from FreeBSD:

Implemented a more sophisticated mechanism for handling transmitter
interrupts which now defers them until the transmit queue if filled
up with completed buffers. This has two advantages: first, it reduces
the number of transmitter interrupts to just 1/120th of the rate
that they occured previously, and two, running down many buffers
at once has much improved cache effects.

Defer rundown (m_freem) of completed transmit buffers for no longer
than 1 second.

This brings us up-to-date with the most recent "fxp" driver in FreeBSD.
 1.26 17-Dec-1998  explorer teach fxp about rnd_*()
 1.25 25-Nov-1998  bouyer branches: 1.25.2;
Use bus_dma(9) for the DMA ops in fxp_init() too. Without this the driver
was stuck in the while (!(cbp->cb_status & FXP_CB_STATUS_C)); loop,
I think because the relevent CPU cache entry was never updated.
This was on a compaq deskpro system.
 1.24 03-Nov-1998  thorpej Add support for the Seeq 80c24 AutoDUPLEX media interface which was nuked
when this driver was changed to use the MAC-independent MII code. This
"PHY" does not have a programming interface, but simply senses the duplex
mode from the link partner. Since it is not possible to read the 80c24
to determine the link type or status, we consider this to be "manual".
 1.23 03-Nov-1998  thorpej Make sure that a delay loop actually has some delay in it, and use IFF_OACTIVE
as appropriate.
 1.22 19-Oct-1998  thorpej Fix a memory leak in fxp_stop(), from the FreeBSD driver.
 1.21 25-Aug-1998  thorpej Change the 32-bit fields of the RFA to an arrays of bytes, so that
egcs won't attempt to optimize inline copies of them into a single
load/store (the RFA is not 4-byte aligned in the DMA area).

Just use memcpy() to copy those fields, now, not our own home-grown.
 1.20 11-Aug-1998  thorpej Adapt to new MII code.
 1.19 08-Aug-1998  mycroft Use splnet, not splimp.
 1.18 05-Jul-1998  jonathan defopt NS, NSIP.
 1.17 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.16 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.15 18-May-1998  cgd check that memory access is enabled before bothering to do the
pci_mapreg_info() call. pci_mapreg_map() implies this check,
but code which calls pci_mapreg_info() has to check it explicitly.
Otherwise, if memory space is disabled, the driver does the wrong
thing, and tries to use memory space anyway, potentially resulting
incorrect driver operation and no useful error message.
 1.14 04-Feb-1998  thorpej Add necessary bus_dmamap_sync() calls for memory mapped with the COHERENT
hint, per bus_dma(9).
 1.13 04-Feb-1998  thorpej Add offset and length parameters to bus_dmamap_sync(), used for specifiying
partial syncs of a DMA mapping.
 1.12 04-Feb-1998  thorpej Add dm_mapsize to bus_dmamap_t and rename BUS_DMAMEM_NOSYNC to
BUS_DMA_COHERENT.
 1.11 28-Jan-1998  thorpej Add support for the 82553[AC] PHY by treating it like an 82555. From
Soren S. Jorvang <soren@t.dk>, PR #4840.
 1.10 28-Jan-1998  thorpej Convert this driver to use the bus_dma interfaces.
 1.9 22-Jan-1998  thorpej Sync w/ FreeBSD-current-980122:
- Rewrite fxp_start() for better clarity and efficiency.
- Remove unused #includes.
 1.8 22-Jan-1998  thorpej Fix two register mapping problems:
- Fall back on i/o space if mem space isn't available.
- Card reports mem space as prefetchable, but mapping the card into dense
space fails in nasty ways on the Alpha. Force mapping into sparse
space by clearing the BUS_SPACE_MAP_CACHEABLE bit (XXX!).
 1.7 12-Jan-1998  thorpej Update for config changes.
 1.6 11-Nov-1997  thorpej Type/alignment cleanup in EEPROM code.
 1.5 20-Oct-1997  thorpej branches: 1.5.2;
Port the latest FreeBSD "fxp" driver to NetBSD-current. Changes include:
- Work around a bug in the 82557 that causes the receiver to lock up
in certain conditions by kicking the multicast address filter if we
haven't heard anything come down the wire for some period of time.
- Fix a bug that could cause TxCB descriptor chains to cross page boundaries
on the Alpha.
- Remove some unneeded register masking.
- Fix a bug where too much data was copied from the config template, causing
memory corruption.
- Fix handing of if_timer (it was be cleared too early in some cases).
- Attempt to reduce the chances of receiver overrun by doubling the
number of receive DMA segments, and processing receive interrupts
before transmit interrupts.
- Remove a gratuitous assignment.
- Fix a bug where incoming packets were counted twice.
 1.4 25-Aug-1997  thorpej Use if_media to change media type, not IFF_LINK*.
 1.3 23-Aug-1997  thorpej Merge the FreeBSD-current-970823 version of the "fxp" driver, adds support
for more PHYs. Closes PR #3953.
 1.2 05-Jun-1997  thorpej branches: 1.2.4;
Changes to support NetBSD, written by me, tested by Matthias Drochner:
- Add NetBSD autoconfiguration support.
- Rearrange code slightly to minimize the number of #ifdefs.
- Don't use a structure to access CSRs. Use macros that DTRT for
the NetBSD and FreeBSD cases.
- Deal with alignment contraint on Alpha - add 2-byte padding at the
beginning of the RFA, so that the data will be 4-byte aligned, after
the 14-byte Ethernet header.
Thanks to Matthias Drochner for the testing, and David Greenman for
the feedback on the changes.
 1.1 05-Jun-1997  thorpej branches: 1.1.1;
Initial revision
 1.1.1.4 22-Jan-1998  thorpej Import FreeBSD's latest "fxp" driver, as of Jan 22, 1998.
 1.1.1.3 20-Oct-1997  thorpej Import the latest FreeBSD "fxp" driver, as of 971019.
 1.1.1.2 23-Aug-1997  thorpej Import the latest "fxp" driver from FreeBSD-current, adds support for
additional PHYs.
 1.1.1.1 05-Jun-1997  thorpej Import FreeBSD's Intel EtherExpress PRO 10/100B driver, written
by David Greenman.
 1.2.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.2.3 07-Feb-1998  mellon Pull up 1.11 (thorpej)
 1.5.2.2 07-Feb-1998  mellon Pull up 1.8 (thorpej)
 1.5.2.1 11-Nov-1997  thorpej Sync w/ trunk: type/alignment cleanup.
 1.25.2.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.33.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.33.4.2 01-Jul-1999  thorpej Sync w/ -current.
 1.33.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.33.2.2 01-Jun-2000  he Apply patch (requested by jhawk):
Calibrate the timeouts by using DELAY(1) so their values are less
machine-dependant. Fixes PR#10141, where spurious timeouts were
being seen. Also report the line numbers of the timeouts so it
can be determined which is being seen.
 1.33.2.1 13-May-2000  he Apply patch (requested by jhawk):
Fix the fxp driver so that it works after a warm-boot from windows
and across an APM suspend/resume or hibernate/resume cycle. Fixes
PR#9370, PR#9548, PR#9571 and PR#9573.
 1.87 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.86 08-May-2021  thorpej Use pci_compatible_match().
 1.85 23-Jan-2019  msaitoh branches: 1.85.16;
Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them expilicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.84 23-Jan-2019  msaitoh KNF. No functional change.
 1.83 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.82 13-Apr-2015  riastradh branches: 1.82.10; 1.82.16; 1.82.18;
Convert sys/dev to use <sys/rndsource.h>.
 1.81 29-Mar-2014  christos branches: 1.81.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.80 30-Mar-2013  christos branches: 1.80.4;
remove trailing whitespace
 1.79 02-Feb-2012  tls branches: 1.79.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.78 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.77 05-Sep-2011  msaitoh branches: 1.77.2; 1.77.6;
Change 0x1229's product name from 82557 to 8255x.
82550, 82551, 82558 and 82559 share the same product id.
This change makes "pcictl dump" happy.
 1.76 02-Sep-2011  msaitoh Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.
 1.75 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.74 22-Mar-2010  dyoung branches: 1.74.2;
Add a detach routine. Enable detachment at shutdown.

psc_pwrmgmt_csr_reg was never initialized to the actual offset of the
PCI PMCSR! Just delete psc_pwrmgmt_csr_reg and all uses of it. In
this way, fxp_pci_disable() becomes a no-op, so delete it, too.
 1.73 24-Feb-2010  dyoung branches: 1.73.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.72 08-Jan-2010  dyoung branches: 1.72.2;
Expand PMF_FN_* macros.
 1.71 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.70 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.69 17-Apr-2009  tsutsui Check revisions and print names of i82551/i82551ER, per Intel manual.
 1.68 16-Apr-2009  tsutsui There is a report that 82559ER doesn't have RX hardware checksum support
(even though it has a newer revision number than 82559_A0),
so handle it separately per its own PCI device ID.
 1.67 19-Mar-2009  tsutsui Add braces missed on RX hardware cksum support.
Fixes RX failure on 82557/82558.
 1.66 11-Mar-2009  tsutsui u_intNN_t -> uintNN_t
 1.65 07-Mar-2009  tsutsui Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.
 1.64 06-Mar-2009  tsutsui The Intel manual says that ICH and 82562 chips are compatible with 82559,
not 82550, so don't set FXPF_EXT_RFA (available only on 82550/82551)
for those variants.

Tested on Intel PRO/100 VM with 82562EM/EX PHY by ISHII Kimio
on current-users, and should also fix PR kern/40431.
 1.63 03-Mar-2009  mrg enable FXPF_EXT_RFA the same way the cardbus frontend does.
 1.62 20-Feb-2009  mrg - remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.
 1.61 18-Jan-2009  mrg branches: 1.61.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.
 1.60 09-Jul-2008  joerg branches: 1.60.2;
- device/softc split for fxp(4)
 1.59 28-Apr-2008  martin branches: 1.59.2; 1.59.4; 1.59.6;
Remove clause 3 and 4 from TNF licenses
 1.58 10-Apr-2008  cegger branches: 1.58.2; 1.58.4;
use aprint_*_dev and device_xname
 1.57 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.56 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.55 24-Dec-2007  hamajima branches: 1.55.2; 1.55.6;
Match on board ethernet controller on VGN-TX91PS.
 1.54 10-Dec-2007  degroote branches: 1.54.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.
 1.53 19-Oct-2007  ad branches: 1.53.4; 1.53.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.52 26-Nov-2006  enami branches: 1.52.8; 1.52.22; 1.52.24; 1.52.28;
Match on board ethernet controller on VGN-TX72PZ.
 1.51 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.50 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.49 27-Sep-2006  cube Make fxp(4) support the PRO/100 VE variant just added to pcidevs.

Reported by rix on #NetBSD-code on freenode.
 1.48 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.47 30-Jul-2006  oster branches: 1.47.4; 1.47.6;
Recognize another Intel PRO/100 VM Network Controller.
 1.46 19-Jun-2006  jmcneill Restore PCI configuration space on resume.
 1.45 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.44 10-Jan-2006  christos branches: 1.44.2; 1.44.6; 1.44.12; 1.44.14;
PR/32494: Dennis Chernoivanov: Intel PRO/100 VE (LOM) not detected on Sony Vaio
 1.43 11-Dec-2005  christos branches: 1.43.2;
merge ktrace-lwp.
 1.42 29-Jul-2005  cube New Dell Day, continued: add support for the fxp(4) variant in the
802801G* family of SB.
 1.41 18-May-2005  riz branches: 1.41.2;
Add support for the 82801FB (ICH6) 10/100 ethernet appearing
on new Intel motherboards. From Brian Buhrow in PR#30025.
Approved by jmcneill.
 1.40 27-Feb-2005  perry branches: 1.40.2;
nuke trailing whitespace
 1.39 21-Aug-2004  thorpej branches: 1.39.4; 1.39.6;
Use ANSI function decls and make use of static.
 1.38 28-Apr-2004  briggs Add a default case to the product ID attachment to print the chip
description and revision information if a chip is matched and this
switch statement isn't updated to match. Addresses PR kern/18019.
 1.37 12-Mar-2004  drochner branches: 1.37.2;
deal with 82801EB/ER (ICH5) Network Controller
 1.36 13-Sep-2003  jdolecek fix description of Intel PRO/100 VM Network Controller with 82562ET/EZ PHY
don't activate any quirks for VM_6 variant
problem reported by Lars Heidieker on current-users

also don't activate any quirks for VM_3 - VM_5 variants, neither
VE_2 - VE_4, in anticipation that the more modern variants don't need
the quirks
 1.35 14-Aug-2003  nonaka Add support for another Intel Pro/100 variant.
 1.34 28-Jun-2003  bouyer branches: 1.34.2;
Add support for another Intel Pro/100 variant. From Quentin Garnier in
private mail.
 1.33 14-Mar-2003  jdolecek apparently this driver works fine for Intel PRO/100 VM with 82562EM/EX PHY,
so make driver match it
while here, also make the driver match 'Intel PRO/100 VM with
82562EM/EX (CNR) PHY', with anticipation it would work fine too
activate the resume and dynamic standby bug workaround for these; might
not be necessary (not confirmed to be needed), but better safe than sorry

Adresses PR kern/20689
 1.32 18-Feb-2003  grant add Intel PRO/100M.

from Quentin Garnier in PR kern/20400.
 1.31 31-Jan-2003  thorpej Use aprint_*().
 1.30 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.29 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.28 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.27 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.26 27-Sep-2002  itojun don't go into D3 state if revision <= 82558_B0. PR 18011
 1.25 18-Sep-2002  abs Recognise the Intel PRO/100 VM Network Controller as seen in the HP
omnibook 6100.
 1.24 22-Jul-2002  msaitoh add support intel C-ICH's embeded Ether MACs.
Tested on RadiSys Endura CH815C (http://www.radisys.com/)
 1.23 22-Jun-2002  cjs Match PCI IDs of new PRO/100 chips.
 1.22 04-Apr-2002  thorpej branches: 1.22.2; 1.22.4;
Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.
 1.21 13-Nov-2001  lukem add RCSID
 1.20 02-Nov-2001  itojun recognize fxp on IBM thinkpad T23. from akimichi@wide.ad.jp
 1.19 05-Aug-2001  thorpej branches: 1.19.4;
Add enable/disable hooks on devices that have ACPI power management
capability, using D3 and D0 power states. This saves me quite a bit
of battery when not using the built-in Ethernet on my IBM T-20 during
long IETF meetings.
 1.18 08-Jul-2001  thorpej branches: 1.18.2;
Remove unnecessary include files. From Onno van der Linden.
 1.17 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.16 22-May-2001  thorpej Enable the PCI MWI command for memory writes on the i82558 and
higher.
 1.15 22-May-2001  thorpej Report 82558, 82559, etc. based on chip revision. Also, remember which
revsion we have for feature enables later.
 1.14 21-May-2001  thorpej The ICH3 also has the Resume Bug.
 1.13 21-May-2001  thorpej The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.
 1.12 28-Dec-2000  sommerfeld branches: 1.12.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.11 27-Sep-2000  ad Match the i82562.
 1.10 15-Jul-2000  jhawk Fix uninitialized variable (reg) in fxp_pci_confreg_restore();
this could result in garbage being written to the PCI status register,
which is unlikely to have had a serious effect. This was with us from
an #if 0 added in rev 1.6.
 1.9 09-Jul-2000  mycroft Recognize the i82559ER.
 1.8 12-May-2000  jhawk branches: 1.8.4;
sc_ih (interrupt cookie) is not pci-specific data
and needs to remain in fxp_softc rather than fxp_pci_softc;
otherwise we break cardbus.
 1.7 12-May-2000  jhawk Move struct fxp_pci_softc declaration to if_fxp_pci.c removing an
unnecessary header file (if_fxp_pcivar.h); oh, how quickly the nascent
inodes are subject to infant mortality.
 1.6 12-May-2000  jhawk Fix bugs seen on Sony Vaios.
Address kern/9370, kern/9548, kern/9571, and kern/9573.

Save and restore critical PCI configuration registers because they are
sometimes bashed.
Add a powerhook to restore said PCI registers after APM events.
The fxp now works across a warm boot from windows (vaio).
The fxp now works across an apm suspend/resume or hibernate/resume cycle.
 1.5 16-Mar-2000  thorpej Recognize the Intel InBusiness.
 1.4 25-Jan-2000  drochner use BUS_SPACE_MAP_PREFETCHABLE instead BUS_SPACE_MAP_CACHEABLE where the
PCI BAR bit is referred to
(XXX is the hack still necessary?)
 1.3 12-Dec-1999  thorpej Take a stab at making this work on big-endian systems.
 1.2 30-Oct-1999  sommerfeld Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.
 1.1 20-Jun-1999  thorpej branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Intel i82557 driver is now split into bus and chip bits.
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.6.1 15-Nov-1999  fvdl Sync with -current
 1.1.4.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.2.1 20-Jun-1999  thorpej file if_fxp_pci.c was added on branch chs-ubc2 on 1999-07-01 23:34:06 +0000
 1.8.4.5 30-Sep-2002  itojun sys/dev/pci/if_fxp_pci.c 1.26

Don't go into D3 state if revision <= 82558_B0. Fixes PR#18011.

(itojun)
 1.8.4.4 06-Jun-2002  he Pull up revisions 1.13-1.18,1.20,1.22 (requested by mycroft):
Work around a bug which can cause some machines to randomly hang.
Drag along performance improvements and improved hardware support.
 1.8.4.3 16-Aug-2001  tv Pullup [he]:

sys/dev/pci/if_fxp_pci.c 1.19

Add enable/disable hooks on devices that have ACPI power management
capability, using D3 and D0 power states.
 1.8.4.2 22-Mar-2001  he Pull up revision 1.11 (requested by hubertf):
Make the Intel Pro/100 as e.g. found on Toshiba Satellite Pro
4600s work.
 1.8.4.1 16-Jul-2000  jhawk Pullup rev 1.9 (approved by jhawk), rev 1.10 (approved by thorpej):
revision 1.9:
Recognize the i82559ER.
revision 1.10:
Fix uninitialized variable (reg) in fxp_pci_confreg_restore();
this could result in garbage being written to the PCI status register,
which is unlikely to have had a serious effect. This was with us from
an #if 0 added in rev 1.6.
 1.12.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.12.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.5 01-Aug-2002  nathanw Catch up to -current.
 1.12.2.4 17-Apr-2002  nathanw Catch up to -current.
 1.12.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.12.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.18.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.18.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.18.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.19.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.22.4.8 26-Oct-2005  jmc Pullup (via patch) requested by riz in ticket #5773)
Add support for 82801FB 10/100 ethernet
 1.22.4.7 06-Apr-2004  jmc Pullup patch (requested by briggs in ticket #1648)

Pull in changes to support the Intel 82801EB/ER (ICH5) Controller. PR#25002
 1.22.4.6 15-Aug-2003  tron Pull up revision 1.34 via patch (requested by bouyer in ticket #1368):
Add support for another Intel Pro/100 variant. From Quentin Garnier in
private mail.
 1.22.4.5 30-Jun-2003  grant Apply patch (requested by drochner in ticket #1343):

add Intel PRO/100M.

apparently this driver works fine for Intel PRO/100 VM with 82562EM/EX
PHY, so make driver match it
while here, also make the driver match 'Intel PRO/100 VM with
82562EM/EX (CNR) PHY', with anticipation it would work fine too
activate the resume and dynamic standby bug workaround for these;
might not be necessary (not confirmed to be needed), but better safe
than sorry
 1.22.4.4 27-Jan-2003  jmc Pullup revisions 1.23-1.24 (requested by masanobu in ticket #1110)
Add support intel C-ICH's embeded Ether MACs.
 1.22.4.3 13-Oct-2002  lukem Pull up revision 1.25 (requested by abs in ticket #844):
Recognise the Intel PRO/100 VM Network Controller as seen in the HP
omnibook 6100.
 1.22.4.2 02-Oct-2002  lukem Pull up revision 1.26 (requested by itojun in ticket #870):
don't go into D3 state if revision <= 82558_B0. PR 18011
 1.22.4.1 25-Jun-2002  lukem Pull up revision 1.23 (requested by cjs in ticket #362):
Add new Intel Ethernet cards
 1.22.2.2 29-Aug-2002  gehenna catch up with -current.
 1.22.2.1 15-Jul-2002  gehenna catch up with -current.
 1.34.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.34.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.34.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.34.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.34.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.34.2.1 03-Aug-2004  skrll Sync with HEAD
 1.37.2.1 28-Apr-2004  tron branches: 1.37.2.1.2;
Pull up revision 1.38 (requested by briggs in ticket #220):
Add a default case to the product ID attachment to print the chip
description and revision information if a chip is matched and this
switch statement isn't updated to match. Addresses PR kern/18019.
 1.37.2.1.2.1 19-May-2005  tron Pull up revision 1.41 (requested by riz in ticket #1532):
Add support for the 82801FB (ICH6) 10/100 ethernet appearing
on new Intel motherboards. From Brian Buhrow in PR#30025.
Approved by jmcneill.
 1.39.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.39.4.1 29-Apr-2005  kent sync with -current
 1.40.2.3 27-Aug-2006  ghen Pull up following revision(s) (requested by oster in ticket #1479):
sys/dev/pci/pcidevs: revision 1.810
sys/dev/pci/if_fxp_pci.c: revision 1.44
sys/dev/pci/if_fxp_pci.c: revision 1.47
sys/dev/pci/pcidevs: revision 1.756
PR/32494: Add ID 0x1068 for Intel PRO/100 VE (LOM) found on Sony Vaio
S4HRP laptops.
PR/32494: Dennis Chernoivanov: Intel PRO/100 VE (LOM) not detected on Sony Vaio
Recognize another Intel PRO/100 VM Network Controller.
 1.40.2.2 21-Nov-2005  tron Pull up following revision(s) (requested by cube in ticket #957):
sys/dev/pci/if_fxp_pci.c: revision 1.42
New Dell Day, continued: add support for the fxp(4) variant in the
802801G* family of SB.
 1.40.2.1 28-May-2005  snj Pull up revision 1.41 (requested by riz in ticket #323):
Add support for the 82801FB (ICH6) 10/100 ethernet appearing
on new Intel motherboards. From Brian Buhrow in PR#30025.
Approved by jmcneill.
 1.41.2.6 24-Mar-2008  yamt sync with head.
 1.41.2.5 17-Mar-2008  yamt sync with head.
 1.41.2.4 21-Jan-2008  yamt sync with head
 1.41.2.3 27-Oct-2007  yamt sync with head.
 1.41.2.2 30-Dec-2006  yamt sync with head.
 1.41.2.1 21-Jun-2006  yamt sync with head.
 1.43.2.1 15-Jan-2006  yamt sync with head.
 1.44.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.44.12.2 22-Jun-2006  chap Complete a sync sys/ with head.
 1.44.12.1 19-Jun-2006  chap Sync with head.
 1.44.6.2 11-Aug-2006  yamt sync with head
 1.44.6.1 26-Jun-2006  yamt sync with head.
 1.44.2.1 09-Sep-2006  rpaulo sync with head
 1.47.6.2 10-Dec-2006  yamt sync with head.
 1.47.6.1 22-Oct-2006  yamt sync with head
 1.47.4.2 12-Jan-2007  ad Sync with head.
 1.47.4.1 18-Nov-2006  ad Sync with head.
 1.52.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.52.24.3 23-Mar-2008  matt sync with HEAD
 1.52.24.2 09-Jan-2008  matt sync with HEAD
 1.52.24.1 06-Nov-2007  matt sync with HEAD
 1.52.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.52.8.1 23-Oct-2007  ad Sync with head.
 1.53.6.1 11-Dec-2007  yamt sync with head.
 1.53.4.1 26-Dec-2007  ad Sync with head.
 1.54.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.55.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.55.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.55.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.55.2.1 24-Mar-2008  keiichi sync with head.
 1.58.4.5 11-Aug-2010  yamt sync with head.
 1.58.4.4 11-Mar-2010  yamt sync with head
 1.58.4.3 16-Sep-2009  yamt sync with head
 1.58.4.2 04-May-2009  yamt sync with head.
 1.58.4.1 16-May-2008  yamt sync with head.
 1.58.2.1 18-May-2008  yamt sync with head.
 1.59.6.1 19-Oct-2008  haad Sync with HEAD.
 1.59.4.1 18-Jul-2008  simonb Sync with head.
 1.59.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.60.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.60.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.60.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.61.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.72.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.73.2.2 31-May-2011  rmind sync with head
 1.73.2.1 30-May-2010  rmind sync with head
 1.74.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.77.6.1 18-Feb-2012  mrg merge to -current.
 1.77.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.77.2.1 17-Apr-2012  yamt sync with head
 1.79.6.3 03-Dec-2017  jdolecek update from HEAD
 1.79.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.79.6.1 23-Jun-2013  tls resync from head
 1.80.4.1 18-May-2014  rmind sync with head
 1.81.6.1 06-Jun-2015  skrll Sync with HEAD
 1.82.18.1 10-Jun-2019  christos Sync with HEAD
 1.82.16.2 26-Jan-2019  pgoyette Sync with HEAD
 1.82.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.82.10.1 27-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1172):

sys/dev/pci/nvme_pci.c: revision 1.26
sys/dev/pci/xhci_pci.c: revision 1.21
sys/dev/pci/ixgbe/ixv.c: revision 1.108
sys/dev/pci/ixgbe/ixgbe.c: revision 1.171
sys/dev/pci/if_fxp_pci.c: revision 1.84
sys/dev/pci/if_fxp_pci.c: revision 1.85
sys/dev/pci/xhci_pci.c: revision 1.16

remove #ifdef DEBUG printf, it seems to have outlived it's usefulness

-

KNF. No functional change.

-

Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them explicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.85.16.1 13-May-2021  thorpej Sync with HEAD.
 1.2 12-May-2000  jhawk Move struct fxp_pci_softc declaration to if_fxp_pci.c removing an
unnecessary header file (if_fxp_pcivar.h); oh, how quickly the nascent
inodes are subject to infant mortality.
 1.1 12-May-2000  jhawk Move pci-specific data to fxp_pci_softc from fxp_pci_softc.
Add some more pci-specific data to fxp_pci_softc.
 1.10 20-Jun-1999  thorpej Intel i82557 driver is now split into bus and chip bits.
 1.9 25-Aug-1998  thorpej branches: 1.9.8;
Change the 32-bit fields of the RFA to an arrays of bytes, so that
egcs won't attempt to optimize inline copies of them into a single
load/store (the RFA is not 4-byte aligned in the DMA area).

Just use memcpy() to copy those fields, now, not our own home-grown.
 1.8 11-Aug-1998  thorpej G/c the 83840 register definitions.
 1.7 05-Feb-1998  thorpej Fix the FXP_TXDESCOFF() macro.
 1.6 04-Feb-1998  thorpej Add necessary bus_dmamap_sync() calls for memory mapped with the COHERENT
hint, per bus_dma(9).
 1.5 28-Jan-1998  thorpej Convert this driver to use the bus_dma interfaces.
 1.4 20-Oct-1997  thorpej Port the latest FreeBSD "fxp" driver to NetBSD-current. Changes include:
- Work around a bug in the 82557 that causes the receiver to lock up
in certain conditions by kicking the multicast address filter if we
haven't heard anything come down the wire for some period of time.
- Fix a bug that could cause TxCB descriptor chains to cross page boundaries
on the Alpha.
- Remove some unneeded register masking.
- Fix a bug where too much data was copied from the config template, causing
memory corruption.
- Fix handing of if_timer (it was be cleared too early in some cases).
- Attempt to reduce the chances of receiver overrun by doubling the
number of receive DMA segments, and processing receive interrupts
before transmit interrupts.
- Remove a gratuitous assignment.
- Fix a bug where incoming packets were counted twice.
 1.3 23-Aug-1997  thorpej Merge the FreeBSD-current-970823 version of the "fxp" driver, adds support
for more PHYs. Closes PR #3953.
 1.2 05-Jun-1997  thorpej branches: 1.2.4;
Changes to support NetBSD, written by me, tested by Matthias Drochner:
- Add NetBSD autoconfiguration support.
- Rearrange code slightly to minimize the number of #ifdefs.
- Don't use a structure to access CSRs. Use macros that DTRT for
the NetBSD and FreeBSD cases.
- Deal with alignment contraint on Alpha - add 2-byte padding at the
beginning of the RFA, so that the data will be 4-byte aligned, after
the 14-byte Ethernet header.
Thanks to Matthias Drochner for the testing, and David Greenman for
the feedback on the changes.
 1.1 05-Jun-1997  thorpej branches: 1.1.1;
Initial revision
 1.1.1.3 20-Oct-1997  thorpej Import the latest FreeBSD "fxp" driver, as of 971019.
 1.1.1.2 23-Aug-1997  thorpej Import the latest "fxp" driver from FreeBSD-current, adds support for
additional PHYs.
 1.1.1.1 05-Jun-1997  thorpej Import FreeBSD's Intel EtherExpress PRO 10/100B driver, written
by David Greenman.
 1.2.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.8.1 01-Jul-1999  thorpej Sync w/ -current.
 1.10 20-Jun-1999  thorpej Intel i82557 driver is now split into bus and chip bits.
 1.9 18-Feb-1999  thorpej branches: 1.9.2; 1.9.4;
Back out to the previous stable revision of the fxp driver. The latest
one had too many stability problems.
 1.8 19-Dec-1998  thorpej Changes from FreeBSD:

Implemented a more sophisticated mechanism for handling transmitter
interrupts which now defers them until the transmit queue if filled
up with completed buffers. This has two advantages: first, it reduces
the number of transmitter interrupts to just 1/120th of the rate
that they occured previously, and two, running down many buffers
at once has much improved cache effects.

Defer rundown (m_freem) of completed transmit buffers for no longer
than 1 second.

This brings us up-to-date with the most recent "fxp" driver in FreeBSD.
 1.7 17-Dec-1998  explorer teach fxp about rnd_*()
 1.6 11-Aug-1998  thorpej Adapt to new MII code.
 1.5 28-Jan-1998  thorpej Convert this driver to use the bus_dma interfaces.
 1.4 22-Jan-1998  thorpej Sync w/ FreeBSD-current-980122:
- Rearrange softc for better cache line behavior.
 1.3 20-Oct-1997  thorpej Port the latest FreeBSD "fxp" driver to NetBSD-current. Changes include:
- Work around a bug in the 82557 that causes the receiver to lock up
in certain conditions by kicking the multicast address filter if we
haven't heard anything come down the wire for some period of time.
- Fix a bug that could cause TxCB descriptor chains to cross page boundaries
on the Alpha.
- Remove some unneeded register masking.
- Fix a bug where too much data was copied from the config template, causing
memory corruption.
- Fix handing of if_timer (it was be cleared too early in some cases).
- Attempt to reduce the chances of receiver overrun by doubling the
number of receive DMA segments, and processing receive interrupts
before transmit interrupts.
- Remove a gratuitous assignment.
- Fix a bug where incoming packets were counted twice.
 1.2 25-Aug-1997  thorpej Use if_media to change media type, not IFF_LINK*.
 1.1 05-Jun-1997  thorpej branches: 1.1.1; 1.1.4;
Changes to support NetBSD, written by me, tested by Matthias Drochner:
- Add NetBSD autoconfiguration support.
- Rearrange code slightly to minimize the number of #ifdefs.
- Don't use a structure to access CSRs. Use macros that DTRT for
the NetBSD and FreeBSD cases.
- Deal with alignment contraint on Alpha - add 2-byte padding at the
beginning of the RFA, so that the data will be 4-byte aligned, after
the 14-byte Ethernet header.
Thanks to Matthias Drochner for the testing, and David Greenman for
the feedback on the changes.
 1.1.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.1.2 22-Jan-1998  thorpej Import FreeBSD's latest "fxp" driver, as of Jan 22, 1998.
 1.1.1.1 20-Oct-1997  thorpej Import the latest FreeBSD "fxp" driver, as of 971019.
 1.9.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.9.2.1 13-May-2000  he Apply patch (requested by jhawk):
Fix the fxp driver so that it works after a warm-boot from windows
and across an APM suspend/resume or hibernate/resume cycle. Fixes
PR#9370, PR#9548, PR#9571 and PR#9573.
 1.57 04-Oct-2025  thorpej Use pci_compatible_{match,lookup}().
 1.56 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.55 15-Feb-2025  hannken Use "int" format for constant "GEM_TMP_BUFSIZE - 1".

Kernel ALL/amd64 builds again.
 1.54 13-Feb-2025  joe use the right buffer size for shared pin check and debug

avoid the use of sizeof(pointer) and use the Temp BUF limit
 1.53 13-Feb-2025  joe fix: wrong size of buffer limit used when reading through the pci bus

use the GEM_TMP_BUFSIZE rather than the sizeof pointer
 1.52 02-Jul-2020  msaitoh branches: 1.52.20; 1.52.26;
prop_data_data_nocopy -> prop_data_value
 1.51 30-May-2020  thorpej gem_pci_attach(): avoid allocating a 2K buffer on the stack.
 1.50 02-Mar-2020  msaitoh KNF. No functional change.
 1.49 01-Mar-2020  thorpej Use the 64-bit PCI DMA tag if available.
 1.48 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.47 29-Mar-2014  christos branches: 1.47.28; 1.47.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.46 30-Mar-2013  christos branches: 1.46.4;
remove trailing whitespace
 1.45 23-Sep-2012  chs fix a debug printf.
 1.44 30-Jan-2012  drochner branches: 1.44.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.43 13-Nov-2010  uebayasi branches: 1.43.8; 1.43.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.42 24-Feb-2010  dyoung branches: 1.42.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.41 21-Jan-2010  macallan branches: 1.41.2;
get rid of architecture-specific firmware calls to determine the MAC address
on sparc(64) and macppc - use device properties instead
tested by myself on macppc and martin on sparc64
 1.40 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.39 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.38 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.37 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.36 27-Jul-2009  dyoung Do a complete device_t/softc split for the PCI attachment. I have
not finished the device_t/softc split for the SBus attachment
because I don't have an SBus gem(4) to test with.

Convert from legacy shutdownhooks to a PMF shutdown hook. Add PMF
suspend/resume handlers.

Factor a detachment hook out of gem_attach(). During device
attachment, track which resources are reserved in sc_attach_state,
and release only those resources during detachment.

Tested on gem0 and gem1 at pci1 on a Sun Fire V120.
 1.35 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.34 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.33 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.31 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.30 25-May-2008  chs branches: 1.30.6; 1.30.12;
recognize the variant found in the last model of powermac G5.
 1.29 10-Apr-2008  cegger branches: 1.29.2; 1.29.4; 1.29.6;
use aprint_*_dev and device_xname
 1.28 04-Apr-2008  martin Make this compile w/o GEM_DEBUG on non-sparc systems
 1.27 01-Feb-2008  jdc branches: 1.27.6;
Set the chip revision in the softc.
 1.26 19-Jan-2008  aymeric recognize (again) the Intrepid 2 gem adapter in the Powerbook5,8
 1.25 05-Jan-2008  jdc Add support for Sun PCI X1141A (SX fibre) cards.
Add support for GEM cards on non-OFW machines.
 1.24 19-Oct-2007  ad branches: 1.24.2; 1.24.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.23 25-Jun-2007  aymeric branches: 1.23.6; 1.23.8; 1.23.12;
Recognize the Intrepid2 gem. Needed at least on the last PowerBook G4.
 1.22 24-Nov-2006  martin branches: 1.22.2; 1.22.8; 1.22.10; 1.22.16;
In preparation for gem @ sbus: split the GEM registers into two halfs
and provide a bus_space_handle_t for each. While there, fix a typo
in gem_bitwait().
 1.21 05-Aug-2006  sanjayl branches: 1.21.4; 1.21.6;
1st cut of Powermac G5 support (uses bridge mode).
 1.20 11-Dec-2005  christos branches: 1.20.4; 1.20.8;
merge ktrace-lwp.
 1.19 27-Feb-2005  perry branches: 1.19.4;
nuke trailing whitespace
 1.18 04-Feb-2005  perry de-__P
 1.17 17-Oct-2004  heas branches: 1.17.4; 1.17.6;
Adjust/add a few comments and add defines for PCS (aka GEM_MII) FSM and
interrupt registers.
drop some trailing WS.

no functional changes.
 1.16 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.15 17-Mar-2004  martin For sparc*: myetheraddr is no more
 1.14 31-Jan-2003  thorpej branches: 1.14.2;
Use aprint_*().
 1.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 09-Jul-2002  matt Match Apple GMAC id #3.
 1.9 21-May-2002  matt branches: 1.9.2;
Add code to distinguish between apple and sun gem cores.
 1.8 13-Nov-2001  lukem branches: 1.8.2; 1.8.10;
add RCSID
 1.7 18-Oct-2001  thorpej Remove more cruft left over from copying bits of other drivers.
 1.6 18-Oct-2001  thorpej Remove some more stuff left over from copying bits of the HME driver.
 1.5 18-Oct-2001  thorpej Remove some unneeded stuff from the gem_pci_softc.
 1.4 18-Oct-2001  thorpej Add goo to fetch the MAC address from OpenFirmware on the macppc
port. Copied from the macppc "gmac" driver, but otherwise untested.
 1.3 18-Oct-2001  thorpej - The GEM registers are always memory type registers. Don't use a
broken hueristic to determine memory vs. i/o (one should never make
an assumption that the bus_space_tag_t is a pointer, as this code
did).
- Fix the "can't map registers" error message.
- Garbage-collect some code that is not relevant to the GEM (which
was already #if 0'd out).
- Cluster all the SPARC-specific code into one place (will be
replaced with Properties once that is fleshed out).
 1.2 24-Sep-2001  eeh branches: 1.2.2;
Print out device details.
 1.1 16-Sep-2001  eeh branches: 1.1.2;
Driver for Sun GEM gigabit ethernet, Sun ERI 10/100, and Apple GMAC.
 1.1.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.6 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.5 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.4 22-Oct-2001  nathanw Catch up to -current.
 1.1.2.3 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.1.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.2.1 16-Sep-2001  nathanw file if_gem_pci.c was added on branch nathanw_sa on 2001-09-21 22:35:55 +0000
 1.2.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.2.1 24-Sep-2001  fvdl file if_gem_pci.c was added on branch thorpej-devvp on 2001-10-01 12:45:54 +0000
 1.8.10.2 15-Jul-2002  gehenna catch up with -current.
 1.8.10.1 30-May-2002  gehenna Catch up with -current.
 1.8.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.8.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.1 13-Nov-2001  thorpej file if_gem_pci.c was added on branch kqueue on 2002-01-10 19:56:40 +0000
 1.9.2.1 12-Jul-2002  thorpej pullup-1-6 ticket #491 (matt).

Original log message:
Match Apple GMAC id #3.
 1.14.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.14.2.4 19-Oct-2004  skrll Sync with HEAD
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.6.1 12-Feb-2005  yamt sync with head.
 1.17.4.1 29-Apr-2005  kent sync with -current
 1.19.4.5 04-Feb-2008  yamt sync with head.
 1.19.4.4 21-Jan-2008  yamt sync with head
 1.19.4.3 27-Oct-2007  yamt sync with head.
 1.19.4.2 03-Sep-2007  yamt sync with head.
 1.19.4.1 30-Dec-2006  yamt sync with head.
 1.20.8.1 11-Aug-2006  yamt sync with head
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.21.6.1 10-Dec-2006  yamt sync with head.
 1.21.4.1 12-Jan-2007  ad Sync with head.
 1.22.16.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.22.10.1 11-Jul-2007  mjf Sync with head.
 1.22.8.2 23-Oct-2007  ad Sync with head.
 1.22.8.1 15-Jul-2007  ad Sync with head.
 1.22.2.1 17-May-2008  bouyer Pull up following revision(s) (requested by jdc in ticket #1145):
src/share/man/man4/gem.4 1.5,1.6 via patch
src/sys/arch/sparc64/conf/GENERIC 1.97 via patch
src/sys/dev/ic/gem.c 1.59,1.61-1.68,1.70-1.73 via patch
src/sys/dev/ic/gemreg.h 1.11 via patch
src/sys/dev/ic/gemvar.h 1.16,1.18 via patch
src/sys/dev/mii/bmtphy.c 1.24 via patch
src/sys/dev/pci/if_gem_pci.c 1.25,1.27 via patch
src/sys/dev/pci/pcidevs 1.12 via patch
src/sys/dev/pci/pcidevs.h regenerate
src/sys/dev/pci/pcidevs_data.h regenerate
Add support for Sun PCI X1141A (SX fibre) cards.
Add improvements to the driver.
Disable HW UDP4 and RX TCP4 checksums because they are buggy (PR#34799)
Add improvements to bmtphy.
 1.23.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.8.3 23-Mar-2008  matt sync with HEAD
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.24.8.2 20-Jan-2008  bouyer Sync with HEAD
 1.24.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.24.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.27.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.4.5 11-Mar-2010  yamt sync with head
 1.29.4.4 16-Sep-2009  yamt sync with head
 1.29.4.3 19-Aug-2009  yamt sync with head.
 1.29.4.2 16-May-2009  yamt sync with head
 1.29.4.1 04-May-2009  yamt sync with head.
 1.29.2.1 04-Jun-2008  yamt sync with head
 1.30.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.41.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.2.1 05-Mar-2011  rmind sync with head
 1.43.12.1 18-Feb-2012  mrg merge to -current.
 1.43.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.43.8.2 30-Oct-2012  yamt sync with head
 1.43.8.1 17-Apr-2012  yamt sync with head
 1.44.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.44.6.2 23-Jun-2013  tls resync from head
 1.44.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.46.4.1 18-May-2014  rmind sync with head
 1.47.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.47.30.1 10-Jun-2019  christos Sync with HEAD
 1.47.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.52.26.1 02-Aug-2025  perseant Sync with HEAD
 1.52.20.2 22-Feb-2025  martin Pull up following revision(s) (requested by joe in ticket #1054):

sys/dev/pci/if_gem_pci.c: revision 1.54
sys/dev/pci/if_gem_pci.c: revision 1.55

use the right buffer size for shared pin check and debug
avoid the use of sizeof(pointer) and use the Temp BUF limit.

Use "int" format for constant "GEM_TMP_BUFSIZE - 1".
Kernel ALL/amd64 builds again.
 1.52.20.1 22-Feb-2025  martin Pull up following revision(s) (requested by joe in ticket #1053):

sys/dev/pci/if_gem_pci.c: revision 1.53

fix: wrong size of buffer limit used when reading through the pci bus
use the GEM_TMP_BUFSIZE rather than the sizeof pointer
 1.3 16-Dec-2007  dyoung Collect garbage. All of this code is in pci/if_sip.c, now.
 1.2 13-Nov-2001  lukem branches: 1.2.32; 1.2.90; 1.2.96; 1.2.100; 1.2.104;
add RCSID
 1.1 18-May-2001  thorpej branches: 1.1.2; 1.1.4;
Add a driver for the National Semiconductor DP83820 Gigabit Ethernet
chip. This is found on the NetGear GA-622 and Asante FriendlyNet
GigaNIX.
 1.1.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.1 18-May-2001  nathanw file if_gsip.c was added on branch nathanw_sa on 2001-06-21 20:04:43 +0000
 1.2.104.1 02-Jan-2008  bouyer Sync with HEAD
 1.2.100.1 26-Dec-2007  ad Sync with head.
 1.2.96.1 27-Dec-2007  mjf Sync with HEAD.
 1.2.90.1 23-Mar-2008  matt sync with HEAD
 1.2.32.1 21-Jan-2008  yamt sync with head
 1.41 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.40 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.39 02-Jul-2020  msaitoh prop_data_data_nocopy -> prop_data_value
 1.38 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.37 29-Mar-2014  christos branches: 1.37.28; 1.37.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.36 10-May-2011  dyoung branches: 1.36.4; 1.36.14; 1.36.18;
Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.35 23-Mar-2010  dyoung branches: 1.35.2;
In the #definition of PCI_HME_BASEADDR, use PCI_BAR(0) instead of the
anonymous constant 0x10.
 1.34 23-Mar-2010  dyoung Put back PCI_HME_BASEADDR.
 1.33 23-Mar-2010  dyoung Use the PCI BAR type to decide which I/O enables to set.

TBD: Put back the old BAR #definition, s/PCI_BAR(0)/PCI_HME_BASEADDR/.
 1.32 11-Mar-2010  mrg branches: 1.32.2;
various aprint_* fixes.
 1.31 20-Jan-2010  martin branches: 1.31.2;
Remove sparc specific code and HME_USE_LOCAL_MAC_ADDRESS hack, instead
use the "mac-address" device property if present.
 1.30 17-May-2009  tsutsui u_intNN_t -> uintNN_t
 1.29 17-May-2009  tsutsui Split device_t/softc.
Tested PCI HME on i386. Sbus HME is compile test only.
 1.28 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.27 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.26 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.25 29-May-2008  mrg branches: 1.25.12;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.24 10-Apr-2008  cegger branches: 1.24.2; 1.24.4; 1.24.6;
use aprint_*_dev and device_xname
 1.23 19-Oct-2007  ad branches: 1.23.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.22 16-Nov-2006  christos branches: 1.22.8; 1.22.22; 1.22.24; 1.22.28;
__unused removal on arguments; approved by core.
 1.21 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.20 11-Dec-2005  christos branches: 1.20.20; 1.20.22;
merge ktrace-lwp.
 1.19 26-Apr-2005  atatat branches: 1.19.2;
Reverse order of args in hmevpdoff()
 1.18 21-Apr-2005  christos simplify the mac address retrieval code.
 1.17 21-Apr-2005  christos PR/30018: Peter Eisch: Sun QFE support in non-sparc hardware
 1.16 27-Feb-2005  perry branches: 1.16.2;
nuke trailing whitespace
 1.15 04-Feb-2005  perry de-__P
 1.14 17-Mar-2004  martin branches: 1.14.6; 1.14.8; 1.14.10;
Fix hme for pci based sparcs (krups).
 1.13 26-Dec-2002  itohy branches: 1.13.2;
Lookup and use the Ethernet address in the FCode PROM,
and avoid using MD myetheraddr() function.
This makes the driver MI, and closes PR kern/13797.

The PCI HME is a PCIO chip, which is composed of two functions:
function 0: PCI-EBus2 bridge, and
function 1: HappyMeal Ethernet controller.

The Ethernet address is (expected to be) in the PCI FCode PROM connected
to the EBus bridge (function 0) of the device.
Since the HME is on function 1, some magic is used to access to the PROM.

We don't have MI EBus driver since no EBus device exists (besides the
FCode PROM) on add-on HME boards. The ``not configured'' message for
function 0 is what is expected.

The SPARC case is currently unchanged. It needs interaction with OpenBoot.
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 13-Nov-2001  lukem add RCSID
 1.8 18-Oct-2001  thorpej Add a missing return statement in an error case, and g/c some
cruft that's not relevant in the PCI world.
 1.7 05-Oct-2001  thorpej Minor tidying up of the HME driver attach:
- Print nicer-looking message.
- Use bus_space_subregion() when appropriate, rather than arithmetic
on a bus_space_handle_t.
 1.6 26-Sep-2001  eeh getprop* -> PROM_getprop*
 1.5 27-Aug-2001  augustss branches: 1.5.2;
Use #include <machine/intr.h> instead of #include <machine/cpu.h> to
improve portability.
 1.4 27-Aug-2001  augustss Remove an unneeded #include. This makes the file compilable on more
platforms.
 1.3 28-Dec-2000  sommerfeld branches: 1.3.2; 1.3.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.2 25-Jun-2000  eeh branches: 1.2.2;
Get PCI HME working.
 1.1 05-Apr-2000  mrg branches: 1.1.4;
add "hme at pci" support.
 1.1.4.1 31-Jul-2000  mrg pull up 1.2 (approved by thorpej):
>Get PCI HME working.
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 25-Jun-2000  bouyer file if_hme_pci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:22 +0000
 1.3.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.3.2.6 29-Dec-2002  thorpej Sync with HEAD.
 1.3.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.3 22-Oct-2001  nathanw Catch up to -current.
 1.3.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.3.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.5.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.5.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.13.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.10.1 12-Feb-2005  yamt sync with head.
 1.14.8.1 29-Apr-2005  kent sync with -current
 1.14.6.1 12-May-2005  riz Pull up revisions 1.15-1.19 (requested by christos in ticket #1444):

revision 1.19
date: 2005/04/26 13:02:06; author: atatat; state: Exp; lines: +3 -3
Reverse order of args in hmevpdoff()
 1.18 21-Apr-2005  christos simplify the mac address retrieval code.
 1.17 21-Apr-2005  christos PR/30018: Peter Eisch: Sun QFE support in non-sparc hardware
 1.16 27-Feb-2005  perry nuke trailing whitespace
 1.15 04-Feb-2005  perry de-__P
 1.16.2.3 26-Apr-2005  tron Pull up revision 1.19 (requested by atatat in ticket #208):
Reverse order of args in hmevpdoff()
 1.16.2.2 25-Apr-2005  tron Pull up revision 1.18 (requested by christos in ticket #191):
simplify the mac address retrieval code.
 1.16.2.1 25-Apr-2005  tron Pull up revision 1.17 (requested by christos in ticket #191):
PR/30018: Peter Eisch: Sun QFE support in non-sparc hardware
 1.19.2.2 27-Oct-2007  yamt sync with head.
 1.19.2.1 30-Dec-2006  yamt sync with head.
 1.20.22.2 10-Dec-2006  yamt sync with head.
 1.20.22.1 22-Oct-2006  yamt sync with head
 1.20.20.1 18-Nov-2006  ad Sync with head.
 1.22.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.24.1 06-Nov-2007  matt sync with HEAD
 1.22.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.8.1 23-Oct-2007  ad Sync with head.
 1.23.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.24.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.24.4.5 11-Aug-2010  yamt sync with head.
 1.24.4.4 11-Mar-2010  yamt sync with head
 1.24.4.3 20-Jun-2009  yamt sync with head
 1.24.4.2 16-May-2009  yamt sync with head
 1.24.4.1 04-May-2009  yamt sync with head.
 1.24.2.1 04-Jun-2008  yamt sync with head
 1.25.12.2 23-Jul-2009  jym Sync with HEAD.
 1.25.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.2.2 31-May-2011  rmind sync with head
 1.32.2.1 30-May-2010  rmind sync with head
 1.35.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.36.18.1 18-May-2014  rmind sync with head
 1.36.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.30.1 10-Jun-2019  christos Sync with HEAD
 1.37.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.20 23-Mar-2025  joe avoid NULL pointer dereference on failed memory allocation for sc_ihs
 1.19 25-Feb-2025  joe initialize post to 0

this prevents the use of unitialized variable when we hit an error branch
on the first attempt/iteration that will cause it to break out of the do while
loop
 1.18 29-Jun-2024  riastradh branches: 1.18.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.17 02-Jun-2024  andvar s/interuppts/interrupts/ and s/intruppts/interrupts/ in comment and log message.
 1.16 17-Jun-2022  yamaguchi ixl(4), iavf(4): fix endian bug in vlan tag
 1.15 06-Nov-2021  andvar s/invlaid/invalid/
 1.14 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.13 05-Mar-2021  yamaguchi branches: 1.13.4;
Fix missing IFM_FDX
 1.12 09-Feb-2021  jakllsch Zero interrupt handles upon allocation.

Might prevent detach-time bugs.
 1.11 10-Dec-2020  yamaguchi Add a string literal for IAVF_VC_OP_CONFIG_RSS_LUT
 1.10 10-Dec-2020  yamaguchi remove unnecessary lock acquire and release
 1.9 10-Dec-2020  yamaguchi Fix a wrong value about HENA configuration
 1.8 08-Dec-2020  yamaguchi Change the default interrupt-affinity of iavf(4)
 1.7 01-Dec-2020  yamaguchi Dequeue aqb from sc_atq_live even when the last command is failed

iavf(4) didn't dequeue aqb from sc_atq_live that is a list for
buffer in use when a command is failed by ETIMEDOUT.

This causes a panic in the following sequence:

1. enqueue an aqb to sc_atq_live at iavf_aqb_post()
2. the last command is failed by ETIMEDOUT
3. enqueue the aqb used in the failed command to sc_atq_idle
at an error handling in iavf_attach()
4. dequeue the same aqb from sc_atq_live and enqueue sc_atq_idle
again at iavf_cleanup_admin_queue()
- sc_atq_idle is broken at that time
5. free the aqb in sc_atq_idle more than once

Fix PR/55822

reviewed by knakahara@n.o.
 1.6 17-Sep-2020  yamaguchi branches: 1.6.2;
Fix a panic caused while detaching iavf(4)

The sequence of the panic is follow:
1. failed to disable queues in iavf_stop()
2. release ec->ec_lock in ether_ifdetach()
3. do reset scheduled at iavf_stop()
4. acquire ec->ec_lock in iavf_reset_finish()
- panic

reviewed by knakahara@n.o, thanks.
 1.5 10-Sep-2020  yamaguchi Fix a possible deadlock in iavf(4)
 1.4 09-Sep-2020  yamaguchi Added the explain about locking order in iavf(4)
 1.3 09-Sep-2020  jakllsch fix bad conditional in iavf_parse_modprop()

found by clang
 1.2 08-Sep-2020  jakllsch iaq_datalen is 16-bit, always use htole16

fixes build failure on big endian
 1.1 08-Sep-2020  yamaguchi Added iavf(4) that is based on OpenBSD's iavf(4) implementation

reviewed by msaitoh@n.o and knakahara@n.o
 1.6.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.6.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.13.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.18.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 08-Sep-2020  yamaguchi Added iavf(4) that is based on OpenBSD's iavf(4) implementation

reviewed by msaitoh@n.o and knakahara@n.o
 1.77 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.76 22-Aug-2022  thorpej ipw_start(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".
 1.75 22-Aug-2022  thorpej We come into our if_start routine via ether_output(), therefore there is
no need to check-and-pullup to sizeof(struct ether_header). Instead, we
can simply assert it.
 1.74 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.73 30-Jan-2020  thorpej branches: 1.73.10;
Adopt <net/if_stats.h>.
 1.72 03-Feb-2019  mrg branches: 1.72.6;
- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.71 22-Dec-2018  maxv Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
 1.70 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.69 26-Jun-2018  msaitoh branches: 1.69.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.68 01-May-2018  maya GC private 802.11 rateset declarations, use the standard ones.

Build tested only.
 1.67 16-Jan-2018  maxv branches: 1.67.2;
Fix overflow.
 1.66 23-Oct-2017  msaitoh If if_initialize() failed in the attach function, free resources and return.
 1.65 29-Jul-2017  riastradh Null out sbuf->m on failure to avoid double-free later.

From Ilja Van Sprundel.

Also null out sbuf->map out of paranoia.
 1.64 23-May-2017  ozaki-r branches: 1.64.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.
 1.63 02-Feb-2017  nonaka wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.62 01-Feb-2017  nonaka sync only mapped size.
 1.61 08-Dec-2016  ozaki-r branches: 1.61.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.60 10-Jun-2016  ozaki-r branches: 1.60.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.59 20-Nov-2015  christos use copyout instead of suword.
 1.58 07-Jan-2015  ozaki-r Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.
 1.57 29-Mar-2014  christos branches: 1.57.4; 1.57.6; 1.57.8; 1.57.12;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.56 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.55 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.54 27-Oct-2012  chs branches: 1.54.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.53 30-Jan-2012  drochner branches: 1.53.2; 1.53.6; 1.53.8; 1.53.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.52 15-Nov-2010  uebayasi branches: 1.52.8; 1.52.12;
tsleep needs sys/proc.h.
 1.51 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.50 19-Jan-2010  pooka branches: 1.50.2; 1.50.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.49 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.48 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.47 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.46 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.45 09-Jan-2009  jmcneill branches: 1.45.2;
Make the "EULA not accepted" message a bit more informative, now reads:

EULA not accepted; please see the <driver>(4) man page.
 1.44 07-Nov-2008  joerg Match image name with upstream distfiles.
 1.43 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.42 30-Oct-2008  joerg branches: 1.42.2;
Add glue to ship Intel firmware images. For ipw and iwi require user to
accept the EULA via sysctl as discussed with core@.
 1.41 27-May-2008  dyoung branches: 1.41.4; 1.41.6;
Initialize the channel info in the tx/rx radiotap headers in
ipw_newstate(), instead of reinitializing every time a packet is
sent or received. Drop the unused radiotap 'flags' field.
 1.40 25-May-2008  jmcneill PR#34477: Don't dereference ni_chan if it points to the special
``any channel'' token IEEE80211_CHAN_ANYC
 1.39 10-Apr-2008  cegger branches: 1.39.2; 1.39.4; 1.39.6;
use aprint_*_dev and device_xname
 1.38 11-Mar-2008  dyoung pci_disable_retry() is now a no-op, so don't call it any more.
 1.37 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.36 20-Dec-2007  dyoung branches: 1.36.2; 1.36.6;
Constify struct ifnet->if_sadl and every use throughout the tree.
Add if_set_sadl() that both sets the link-layer address length and
replaces the current link-layer address with a new one, and use it
throughout the tree.
 1.35 09-Dec-2007  jmcneill branches: 1.35.2;
Merge jmcneill-pm branch.
 1.34 19-Oct-2007  ad branches: 1.34.4; 1.34.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.33 01-Sep-2007  dyoung branches: 1.33.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.32 04-Mar-2007  christos branches: 1.32.2; 1.32.10; 1.32.14; 1.32.16;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.31 16-Nov-2006  christos branches: 1.31.2; 1.31.4; 1.31.8;
__unused removal on arguments; approved by core.
 1.30 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.29 29-Sep-2006  christos Coverity CID 4151: Don't forget to close the firmware file (from Arnaud Lacombe)
 1.28 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.27 02-Aug-2006  rpaulo branches: 1.27.4; 1.27.6;
Don't read the firmware twice. Noticed by Nick.
 1.26 28-May-2006  blymn Clean up bogus whitespace
 1.25 01-May-2006  rpaulo branches: 1.25.2;
aprint_debug -> aprint_error.
 1.24 29-Apr-2006  rpaulo Describe the capabilities supported.
 1.23 29-Apr-2006  rpaulo There's no power management support under ipw, so don't announce it to
the net80211 stack.
 1.22 28-Apr-2006  rpaulo bzero -> memset
bcopy -> memcpy
 1.21 28-Apr-2006  rpaulo Print the Ethernet address on attachement.
 1.20 18-Apr-2006  rpaulo Use strlcpy instead of strncpy and sizeof. Requested by Luke.
 1.19 17-Apr-2006  rpaulo Remove SIOCKILLFW.
 1.18 17-Apr-2006  rpaulo Oops, 16 is not enough to store the firmware filenames, use 24.
 1.17 17-Apr-2006  rpaulo Use the firmload API to retrive the firmware from the filesystem.
 1.16 24-Dec-2005  perry branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.15 20-Dec-2005  skrll Merge the FreeBSD code and adapt to NetBSD:

- add power management.
- update ioctl handling.

Fix PR 27439 as the FreeBSD code has joerg's fix for when the RX intr
routine can't allocate a new mbuf.

Fix PR 30806. Thanks to cube@ for testing and some struct ipw_soft_hdr
handling code.

XXX The state machine doesn't sync with the net80211 layer, but that's
XXX not a surprise.
 1.14 11-Dec-2005  christos merge ktrace-lwp.
 1.13 06-Jul-2005  dyoung Avoid an unnecessary API difference between NetBSD and FreeBSD:
back out my change to ieee80211_crypto_encap that made it free its
mbuf argument on error. I had thought it was a bug. It was not.
It's the drivers that are broken. Make an(4), atw(4), ipw(4),
iwi(4), ral(4), rtw(4), ural(4), and wi(4) free the mbuf when
ieee80211_crypto_encap returns NULL. Also, return ath(4) to the
way it was---i.e., free the mbuf.

Thanks to Sam Leffler to pointing out my mistake.
 1.12 22-Jun-2005  dyoung branches: 1.12.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.11 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.10 19-Jan-2005  dyoung Keep a count of free transmit/command descriptors, sc->txfree.
Make the transmit section reserve one descriptor for issuing a
command at all times. If either transmit descriptors run out, or
header/buffer software descriptors run out, set IFF_OACTIVE and
get out of ipw_start, rather than re-using a descriptor or trying
to use a NULL descriptor that comes off the front of an empty
descriptor tailqueue.

This ought to fix port-i386/27439 and kern/28683.
 1.9 18-Jan-2005  dyoung Use IFQ_DEQUEUE instead of IF_DEQUEUE on if->if_snd to be consistent
with IFQ_SET_READY(&if->if_snd) elsewhere, and also to enable
ALTQ(9) on ipw(4).
 1.8 14-Sep-2004  lukem branches: 1.8.4;
Whitespace tweaks.
Remove vendor RCSID, since it's out of sync already (due to manual patches).
 1.7 14-Sep-2004  lukem Use ieee80211_find_rxnode() function instead of ieee80211_find_node()
and ieee80211_ref_node(). From Damien Bergamini.
 1.6 14-Sep-2004  lukem Correctly synchronize DMA mapping for transmission buffer descriptors.
From Damien Bergamini.
 1.5 14-Sep-2004  lukem Improve monitor mode support. From Damien Bergamini
 1.4 14-Sep-2004  lukem Add IEEE802.11 radiotap support. From Damien Bergamini.
 1.3 27-Aug-2004  lukem Minor cosmetic consistency tweaks, from Damien.
 1.2 23-Aug-2004  lukem branches: 1.2.2;
NetBSD RCSID
 1.1 23-Aug-2004  lukem branches: 1.1.1;
Initial revision
 1.1.1.2 20-Dec-2005  skrll Import of the ipw(4) FreeBSD sources from 14-Nov-2005 (just after the
last net80211 merge) as a step towards a working driver and to make
future merging easier.
 1.1.1.1 23-Aug-2004  lukem ipw(4) - Intel PRO/Wireless 2100 driver.
Written by Damien Bergamini, from http://damien.bergamini.free.fr/ipw/
 1.2.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.6 24-Jan-2005  skrll Sync with HEAD.
 1.2.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.3 03-Sep-2004  skrll Sync with HEAD
 1.2.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.2.2.1 23-Aug-2004  skrll file if_ipw.c was added on branch ktrace-lwp on 2004-08-25 06:58:05 +0000
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.12.2.6 17-Mar-2008  yamt sync with head.
 1.12.2.5 21-Jan-2008  yamt sync with head
 1.12.2.4 27-Oct-2007  yamt sync with head.
 1.12.2.3 03-Sep-2007  yamt sync with head.
 1.12.2.2 30-Dec-2006  yamt sync with head.
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.16.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.10.4 11-May-2006  elad sync with head
 1.16.10.3 19-Apr-2006  elad sync with head.
 1.16.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.16.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.16.8.3 11-Aug-2006  yamt sync with head
 1.16.8.2 26-Jun-2006  yamt sync with head.
 1.16.8.1 24-May-2006  yamt sync with head.
 1.16.6.2 01-Jun-2006  kardel Sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.25.2.1 19-Jun-2006  chap Sync with head.
 1.27.6.2 10-Dec-2006  yamt sync with head.
 1.27.6.1 22-Oct-2006  yamt sync with head
 1.27.4.1 18-Nov-2006  ad Sync with head.
 1.31.8.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.31.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.31.2.1 08-Jun-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1156):
sys/dev/pci/if_ipw.c: revision 1.40
PR#34477: Don't dereference ni_chan if it points to the special
``any channel'' token IEEE80211_CHAN_ANYC
 1.32.16.3 23-Mar-2008  matt sync with HEAD
 1.32.16.2 09-Jan-2008  matt sync with HEAD
 1.32.16.1 06-Nov-2007  matt sync with HEAD
 1.32.14.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.32.14.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.32.14.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.32.14.2 05-Oct-2007  joerg Convert ipw(4) to PNP power management and use pci_disable_retry.
 1.32.14.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.32.10.1 03-Sep-2007  skrll Sync with HEAD.
 1.32.2.2 23-Oct-2007  ad Sync with head.
 1.32.2.1 09-Oct-2007  ad Sync with head.
 1.33.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.34.6.1 11-Dec-2007  yamt sync with head.
 1.34.4.1 26-Dec-2007  ad Sync with head.
 1.35.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.36.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.36.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.36.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.36.2.1 24-Mar-2008  keiichi sync with head.
 1.39.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.39.4.5 11-Aug-2010  yamt sync with head.
 1.39.4.4 11-Mar-2010  yamt sync with head
 1.39.4.3 16-Sep-2009  yamt sync with head
 1.39.4.2 16-May-2009  yamt sync with head
 1.39.4.1 04-May-2009  yamt sync with head.
 1.39.2.1 04-Jun-2008  yamt sync with head
 1.41.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.41.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.42.2.2 14-Jan-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #250):
sys/dev/pci/if_iwi.c: revision 1.78
sys/dev/pci/if_ipw.c: revision 1.45
Make the "EULA not accepted" message a bit more informative, now reads:
EULA not accepted; please see the <driver>(4) man page.
 1.42.2.1 09-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #25):
sys/dev/pci/if_ipw.c: revision 1.44
sys/dev/pci/if_ipwvar.h: revision 1.14
sys/dev/pci/if_iwi.c: revision 1.76
sys/dev/pci/if_iwn.c: revision 1.26
Match image name with upstream distfiles.
 1.45.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.2 05-Mar-2011  rmind sync with head
 1.50.4.1 30-May-2010  rmind sync with head
 1.50.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.52.12.1 18-Feb-2012  mrg merge to -current.
 1.52.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.52.8.2 30-Oct-2012  yamt sync with head
 1.52.8.1 17-Apr-2012  yamt sync with head
 1.53.10.1 18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1473):
sys/dev/pci/if_ipw.c: revision 1.65 via patch
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.53.8.1 18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1473):
sys/dev/pci/if_ipw.c: revision 1.65 via patch
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.53.6.3 03-Dec-2017  jdolecek update from HEAD
 1.53.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.53.2.1 18-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1473):
sys/dev/pci/if_ipw.c: revision 1.65 via patch
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.54.2.1 18-May-2014  rmind sync with head
 1.57.12.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/dev/pci/if_ipw.c: revision 1.65
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.57.8.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/dev/pci/if_ipw.c: revision 1.65
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.57.6.5 28-Aug-2017  skrll Sync with HEAD
 1.57.6.4 05-Feb-2017  skrll Sync with HEAD
 1.57.6.3 09-Jul-2016  skrll Sync with HEAD
 1.57.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.57.6.1 06-Apr-2015  skrll Sync with HEAD
 1.57.4.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1469):
sys/dev/pci/if_ipw.c: revision 1.65
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.60.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.60.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.61.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.64.2.2 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.64.2.1 05-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #182):
sys/dev/pci/if_ipw.c: revision 1.65
Null out sbuf->m on failure to avoid double-free later.
From Ilja Van Sprundel.
Also null out sbuf->map out of paranoia.
 1.67.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.67.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.67.2.1 02-May-2018  pgoyette Synch with HEAD
 1.69.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.69.2.1 10-Jun-2019  christos Sync with HEAD
 1.72.6.1 29-Feb-2020  ad Sync with head.
 1.73.10.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.6 25-Dec-2007  perry Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.5 20-Dec-2005  skrll branches: 1.5.46; 1.5.52; 1.5.56; 1.5.60;
Merge the FreeBSD code and adapt to NetBSD:

- add power management.
- update ioctl handling.

Fix PR 27439 as the FreeBSD code has joerg's fix for when the RX intr
routine can't allocate a new mbuf.

Fix PR 30806. Thanks to cube@ for testing and some struct ipw_soft_hdr
handling code.

XXX The state machine doesn't sync with the net80211 layer, but that's
XXX not a surprise.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 14-Sep-2004  lukem branches: 1.3.12;
Whitespace tweaks from Damien Bergamini.
Whitespace tweaks by me.
Remove vendor RCSID, since it's out of sync already (due to manual patchs).
 1.2 23-Aug-2004  lukem branches: 1.2.2;
NetBSD RCSID
 1.1 23-Aug-2004  lukem branches: 1.1.1;
Initial revision
 1.1.1.2 20-Dec-2005  skrll Import of the ipw(4) FreeBSD sources from 14-Nov-2005 (just after the
last net80211 merge) as a step towards a working driver and to make
future merging easier.
 1.1.1.1 23-Aug-2004  lukem ipw(4) - Intel PRO/Wireless 2100 driver.
Written by Damien Bergamini, from http://damien.bergamini.free.fr/ipw/
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.2.2.1 23-Aug-2004  skrll file if_ipwreg.h was added on branch ktrace-lwp on 2004-08-25 06:58:05 +0000
 1.3.12.2 21-Jan-2008  yamt sync with head
 1.3.12.1 21-Jun-2006  yamt sync with head.
 1.5.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.56.1 26-Dec-2007  ad Sync with head.
 1.5.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.46.1 09-Jan-2008  matt sync with HEAD
 1.19 05-Oct-2019  mrg remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned. codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
 1.18 02-Feb-2017  nonaka branches: 1.18.14;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.17 06-Sep-2015  dholland branches: 1.17.2; 1.17.4;
More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.16 27-Oct-2012  chs branches: 1.16.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.15 19-Jan-2010  pooka branches: 1.15.12; 1.15.22;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.14 07-Nov-2008  joerg Match image name with upstream distfiles.
 1.13 27-May-2008  dyoung branches: 1.13.4; 1.13.6; 1.13.8;
Straggler from last commit: drop unused radiotap flags field, set
the __packed attribute on the radiotap headers.
 1.12 09-Dec-2007  jmcneill branches: 1.12.10; 1.12.12; 1.12.14; 1.12.16;
Merge jmcneill-pm branch.
 1.11 17-Apr-2006  rpaulo branches: 1.11.32; 1.11.34; 1.11.44; 1.11.46;
Remove SIOCKILLFW.
 1.10 17-Apr-2006  rpaulo Oops, 16 is not enough to store the firmware filenames, use 24.
 1.9 17-Apr-2006  rpaulo Use the firmload API to retrive the firmware from the filesystem.
 1.8 20-Dec-2005  skrll branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
Merge the FreeBSD code and adapt to NetBSD:

- add power management.
- update ioctl handling.

Fix PR 27439 as the FreeBSD code has joerg's fix for when the RX intr
routine can't allocate a new mbuf.

Fix PR 30806. Thanks to cube@ for testing and some struct ipw_soft_hdr
handling code.

XXX The state machine doesn't sync with the net80211 layer, but that's
XXX not a surprise.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 22-Jun-2005  dyoung branches: 1.6.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.5 19-Jan-2005  dyoung Keep a count of free transmit/command descriptors, sc->txfree.
Make the transmit section reserve one descriptor for issuing a
command at all times. If either transmit descriptors run out, or
header/buffer software descriptors run out, set IFF_OACTIVE and
get out of ipw_start, rather than re-using a descriptor or trying
to use a NULL descriptor that comes off the front of an empty
descriptor tailqueue.

This ought to fix port-i386/27439 and kern/28683.
 1.4 14-Sep-2004  lukem branches: 1.4.4;
Add IEEE802.11 radiotap support. From Damien Bergamini.
 1.3 14-Sep-2004  lukem Whitespace tweaks from Damien Bergamini.
Whitespace tweaks by me.
Remove vendor RCSID, since it's out of sync already (due to manual patchs).
 1.2 23-Aug-2004  lukem branches: 1.2.2;
NetBSD RCSID
 1.1 23-Aug-2004  lukem branches: 1.1.1;
Initial revision
 1.1.1.2 20-Dec-2005  skrll Import of the ipw(4) FreeBSD sources from 14-Nov-2005 (just after the
last net80211 merge) as a step towards a working driver and to make
future merging easier.
 1.1.1.1 23-Aug-2004  lukem ipw(4) - Intel PRO/Wireless 2100 driver.
Written by Damien Bergamini, from http://damien.bergamini.free.fr/ipw/
 1.2.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.2.2.1 23-Aug-2004  skrll file if_ipwvar.h was added on branch ktrace-lwp on 2004-08-25 06:58:05 +0000
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.6.2.2 21-Jan-2008  yamt sync with head
 1.6.2.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.10.1 19-Apr-2006  elad sync with head.
 1.8.8.1 24-May-2006  yamt sync with head.
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.11.46.1 11-Dec-2007  yamt sync with head.
 1.11.44.1 26-Dec-2007  ad Sync with head.
 1.11.34.1 09-Jan-2008  matt sync with HEAD
 1.11.32.1 05-Oct-2007  joerg Convert ipw(4) to PNP power management and use pci_disable_retry.
 1.12.16.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.14.2 11-Mar-2010  yamt sync with head
 1.12.14.1 04-May-2009  yamt sync with head.
 1.12.12.1 04-Jun-2008  yamt sync with head
 1.12.10.2 17-Jan-2009  mjf Sync with HEAD.
 1.12.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.8.1 09-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #25):
sys/dev/pci/if_ipw.c: revision 1.44
sys/dev/pci/if_ipwvar.h: revision 1.14
sys/dev/pci/if_iwi.c: revision 1.76
sys/dev/pci/if_iwn.c: revision 1.26
Match image name with upstream distfiles.
 1.13.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.22.2 03-Dec-2017  jdolecek update from HEAD
 1.15.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.15.12.1 30-Oct-2012  yamt sync with head
 1.16.14.2 05-Feb-2017  skrll Sync with HEAD
 1.16.14.1 22-Sep-2015  skrll Sync with HEAD
 1.17.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.17.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.18.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.121 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.120 22-Aug-2022  thorpej branches: 1.120.10;
iwi_start(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success (or fatal error)".
 1.119 22-Aug-2022  thorpej We come into our if_start routine via ether_output(), therefore there is
no need to check-and-pullup to sizeof(struct ether_header). Instead, we
can simply assert it.
 1.118 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.117 09-Sep-2021  riastradh sys/dev: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.

I think the iwi(4), mcd(4), and ses(4) changes actually plug leaks;
the raidframe(4) change probably doesn't (but doesn't hurt).
 1.116 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.115 08-May-2021  thorpej Use pci_compatible_match().
 1.114 20-Mar-2020  thorpej branches: 1.114.8;
This driver sleeps during iwi_media_change(), and thus requires an
adaptive mutex for the media lock.
 1.113 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.112 10-Nov-2019  chs branches: 1.112.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.111 03-Feb-2019  mrg branches: 1.111.4;
- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.110 22-Dec-2018  maxv Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
 1.109 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.108 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.107 26-Jun-2018  msaitoh branches: 1.107.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.106 01-May-2018  maya GC private 802.11 rateset declarations, use the standard ones.

Build tested only.
 1.105 16-Jan-2018  maxv branches: 1.105.2;
Fix overflow.
 1.104 23-Oct-2017  msaitoh - If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
 1.103 23-May-2017  ozaki-r branches: 1.103.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.
 1.102 02-Feb-2017  nonaka wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.101 08-Dec-2016  ozaki-r branches: 1.101.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.100 03-Aug-2016  mlelstv be quiet about regular intermediate authentication states.
 1.99 10-Jun-2016  ozaki-r branches: 1.99.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.98 07-Jan-2015  ozaki-r Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.
 1.97 29-Mar-2014  christos branches: 1.97.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.96 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.95 26-Nov-2013  roy iwi_newstate should work along with ieee80211_new_state, not always
override it.
 1.94 21-Nov-2013  riz Wrap debug code in {} because "a label can only be part of a statement and
a declaration is not a statement." I.e., make it a statement by making
it part of a block.
 1.93 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.92 30-Mar-2013  christos branches: 1.92.4;
remove trailing whitespace
 1.91 02-Jun-2012  dsl branches: 1.91.2;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.90 21-Mar-2012  nisimura Unbreak the endian issue in firmware header decoding. Comfirmed good and
running by a powerpc machine.
 1.89 30-Jan-2012  drochner branches: 1.89.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.88 19-Nov-2011  tls branches: 1.88.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.87 23-May-2011  drochner branches: 1.87.4;
-remove references to crypto/arc4/arc4.* -- the code isn't used
anywhere afaics
(The confusion comes probably from use of arc4random() at various places,
but this lives in libkern and doesn't share code with the former.)
-g/c non-implementation of arc4 encryption in swcrypto(4)
-remove special casing of ARC4 in crypto(4) -- the point is that it
doesn't use an IV, and this fact is made explicit by the new "ivsize"
property of xforms
 1.86 31-Jan-2011  christos clear register 0x41 as FreeBSD and OpenBSD do. Update copyright to the latest.
 1.85 15-Nov-2010  uebayasi branches: 1.85.2; 1.85.4;
tsleep needs sys/proc.h.
 1.84 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.83 19-Jan-2010  pooka branches: 1.83.2; 1.83.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.82 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.81 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.80 13-Mar-2009  jym Fixes in the iwi(4) driver to better handle errors:
- bus_dmamap fixes, with checks against NULL
- move the rings' allocation code later in iwi_attach() to avoid NULL pointer
dereference if allocation fails
- avoid double free() in case of failure during attach. If an allocation fails,
do not free the ring directly, as it is handled by iwi_detach()
- only set ring->count for RX/TX rings when ring allocation is successful, or
else the for loop during detach will fail with a NULL dereference.
- call pci_intr_disestablish() if iwi_reset() fails during attach; driver is
in an incoherent state, interrupt handler should not be used.

Proposed by me on tech-net@, approved by christos@. Compiled and tested
with GENERIC and XEN3_DOM0 kernels.
 1.79 13-Feb-2009  bouyer make iwi_alloc_tx_ring() prototype match function declaration (shows up when
bus_addr_t != bus_size_t). Fix cast for 64bit paddr_t on i386.
 1.78 09-Jan-2009  jmcneill branches: 1.78.2;
Make the "EULA not accepted" message a bit more informative, now reads:

EULA not accepted; please see the <driver>(4) man page.
 1.77 10-Nov-2008  joerg Fix typo in fw name.
 1.76 07-Nov-2008  joerg Match image name with upstream distfiles.
 1.75 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.74 30-Oct-2008  joerg branches: 1.74.2;
Add glue to ship Intel firmware images. For ipw and iwi require user to
accept the EULA via sysctl as discussed with core@.
 1.73 16-Jun-2008  mlelstv branches: 1.73.2; 1.73.4;
Compute the correct number of pages spanned by the firmware.

The old code just uses the firmware size and rounds up to full
pages. However, if the firmware isn't loaded aligned to a page
boundary (which it isn't), then one more page (and thus DMA
segment) might be necessary.
 1.72 21-Mar-2008  dyoung branches: 1.72.2; 1.72.4; 1.72.6; 1.72.8;
pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.71 11-Mar-2008  dyoung Finish the job: pci_disable_retry() is now a no-op, so don't call
it any more.
 1.70 11-Mar-2008  dyoung pci_disable_retry() is now a no-op, so don't call it any more.
 1.69 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.68 09-Dec-2007  jmcneill branches: 1.68.6; 1.68.10;
Merge jmcneill-pm branch.
 1.67 22-Oct-2007  joerg branches: 1.67.4; 1.67.6;
Also convert detach function.
 1.66 22-Oct-2007  joerg Convert to device_t/softc split and aprint usage.
 1.65 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.64 01-Sep-2007  dyoung branches: 1.64.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.63 26-Aug-2007  dyoung branches: 1.63.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.62 04-Mar-2007  sketch branches: 1.62.2; 1.62.10; 1.62.14;
Put unformatted firmware version output behind IWI_DEBUG
 1.61 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.60 23-Jan-2007  skrll branches: 1.60.2;
Pass the right pointer to firmware_free.

Fixes the DIAGNOSTIC panic reported by Sverre Froyen on current-users.
 1.59 20-Dec-2006  skrll - Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
 1.58 16-Nov-2006  christos branches: 1.58.2;
__unused removal on arguments; approved by core.
 1.57 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.56 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.55 30-Aug-2006  christos branches: 1.55.2; 1.55.4;
fix initializers.
 1.54 19-Aug-2006  skrll Add some sysctl knobs to bring us closer to the FreeBSD driver.

Also sysctl enable the debug message printing (if IWI_DEBUG) is defined.
 1.53 09-Aug-2006  skrll s/printf/aprint_error/ for one message.
 1.52 09-Aug-2006  skrll Adapt iwi(4) to use firmload(9) and remove firmware loading from
iwictl(8).
 1.51 21-Jul-2006  ad - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.50 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.49 28-May-2006  blymn branches: 1.49.2;
Clean up bogus whitespace
 1.48 14-May-2006  elad branches: 1.48.2;
integrate kauth.
 1.47 11-Apr-2006  rpaulo Coverity ID 2442: check if one can dereference ifp before calling
iwi_stop() in iwi_detach().
 1.46 09-Mar-2006  jmcneill branches: 1.46.2;
Save and restore PCI configuration state on suspend/resume.
 1.45 21-Feb-2006  skrll branches: 1.45.2; 1.45.4;
Fix from Sam Leffler "correct check for whether wpa is enabled".
wpa_supplicant and static WEP doesn't crash the firmware now. YAY!
 1.44 24-Dec-2005  perry branches: 1.44.2; 1.44.4; 1.44.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.43 05-Dec-2005  skrll Finally (I hope) fix iwi_ioctl:

- handle SIOCADDMULTI/SIOCDELMULTI properly, i.e. no need to reset
anything as we don't do multicast filters (yet)
- restructure some code and use an IS_RUNNING macro

Fix iwi_init to set if_flags before the net80211 state machine is kicked
and init to IEEE80211_S_INIT.
 1.42 29-Nov-2005  rpaulo Add support for software controlled LEDs as found on some
boards. Currently, only the associated LED is being used because
that's the only LED my card has. The other two LEDs (OFDM and
activity) can later be set by someone, easily, who owns some board
with that LEDs.

Reviewed by Nick Hudson.
 1.41 26-Nov-2005  skrll Fixes from Steve Woodford:

- add some missing bus_dmamap_sync operations.
- don't process other interrupts if we get an error/radio off
interrupt.
- improve command handling - sleep against the descriptor instead
of the descriptor set.
 1.40 23-Nov-2005  skrll Fix the handling of ENETRESET in iwi_ioctl.

This fixes PR 32143
 1.39 23-Nov-2005  skrll Correct a bpf tap.
 1.38 18-Nov-2005  skrll Resolve conflicts. Changelog to follow.
 1.37 14-Nov-2005  skrll branches: 1.37.2;
Don't use DPRINTF for previous. Doh!
 1.36 14-Nov-2005  skrll Dump the error log if we get an IWI_INTR_FATAL_ERROR interrupt.
 1.35 29-Oct-2005  scw Expunge an extraneous bus_dmamap_sync() call in iwi_frame_intr(). The entire
frame has already been sync'd by iwi_rx_intr().
 1.34 29-Oct-2005  scw - Use the DMA map size when calling bus_dmamap_sync(), instead of
blindly assuming MCLBYTES will DTRT.
- Use bus_dmamap_load_mbuf() instead of bus_dmamap_load() where
appropriate.
- If we have to coalesce a Tx mbuf chain comprised of more than IWI_MAX_NSEG
segments, allocate a cluster iff the payload won't fit in the header.
 1.33 29-Oct-2005  skrll Don't byte swap unnecessarily in iwi_read_prom_word. Fix the user instead.
 1.32 29-Oct-2005  scw Support big-endian hosts:
- Always byte-swap data read from EEPROM.
- Byte-swap firmware image when host is big-endian.

In iwi_tx_start():
- Fix descriptor initialisation bogon (only problematic on big-endian hosts).
- Fix bus_dmamap_sync() 'len' parameter..
 1.31 19-Oct-2005  joerg Fix a kernel segfault when a RX interrupt can't allocate a new mbuf.
The change adopts the idea of fxp to drop the incoming packet and panic
if the old mbuf cannot be reloaded. Since the bus_dmamap is allocated
during attach, this is not supposed to happen. Since a lot of code moves
anyway, factor out the allocation of RX ring elements, which is shared
between the init path and the RX interrupt path.

XXX A better fix might be to borrow the mbuf from the logic end of the
XXX ring buffer, but that needs more involved driver changes.

Reviewed by dyoung@ and nick@
 1.30 08-Oct-2005  skrll branches: 1.30.2;
Use the new scan command for monitor mode as well.
 1.29 29-Sep-2005  skrll Improve interrupt handling:

- don't disable/enable as we're already at splnet()
- ack the interrupts early

Fixes my "lost interrupt" problem.

Thanks to dyoung and scw for the suggestions.
 1.28 25-Sep-2005  skrll Whitespace and change a comment slightly.
 1.27 25-Sep-2005  skrll Don't try to bus_dmamem_alloc everytime we want to load the firmware as
it can fail all too easily. Instead bus_dmamap_load the cached copy and
create the command blocks for the device to load it accordingly.

Thanks to scw and mrg for reviewing this.

Closes PR 29892 (I hope).
 1.26 25-Sep-2005  skrll Support hidden ESSID APs.

Use the newer scan command as this one doesn't crash the firmware when
scanning 802.11a channels.

Thanks to scw and blymn for testing.

Closes PR 31295.
 1.25 25-Sep-2005  skrll Resolve conflicts.
 1.24 17-Sep-2005  skrll KNF. That is change u_intN_t to uintN_t.
 1.23 15-Sep-2005  skrll Correct a debug message.
 1.22 12-Sep-2005  skrll Fix spello.
 1.21 12-Sep-2005  skrll Use the correct length parameter when capturing rx packets.
 1.20 04-Sep-2005  skrll Re-organise a bit to reduce diff to FreeBSD.
 1.19 30-Aug-2005  skrll Let the net80211 layer handle the transition to INIT as well.

Testing by salo and me suggests that PR 31010 is fixed.
 1.18 30-Aug-2005  skrll Disestablish the power and shutdown hooks when detaching.
 1.17 30-Aug-2005  skrll KNF (and reduced diff to FreeBSD)
 1.16 27-Aug-2005  skrll Be explicit about which cards to setup .11a rates for.

hi matt.
 1.15 19-Aug-2005  skrll Add shutdown and power hooks.
 1.14 19-Aug-2005  skrll More sync with the FreeBSD driver.
 1.13 01-Aug-2005  skrll - Match more product ids.
- Don't initialise ic_phytype twice and do initialise ic_state.
- announce available rates.
- mark interface down if firmware crashes for the radio transmitter
gets turned off.
 1.12 30-Jul-2005  christos Partially fix. Now it comes up, associates with wep, but something is wrong
with tcp since it crashes in wep encryption when I cvs update.
 1.11 07-Jul-2005  dyoung Cosmetic: use the idiom &ic->ic_nw_keys[0] instead of ic->ic_nw_keys,
just be a little more parallel to &ic->ic_nw_keys[IEEE80211_WEP_NKID]
on the same line.
 1.10 25-Jun-2005  dyoung branches: 1.10.2;
Let ieee80211_input do WEP-decapsulation.

Make iwi(4) provide a key-allocator that returns valid indices for
the four global keys. Now net80211 should let the h/w do WEP
encryption/decryption.
 1.9 22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.8 20-Jun-2005  sekiya Implement monitor mode. From OpenBSD.
 1.7 07-Jun-2005  skrll Sync with pcidevs changes.
 1.6 13-Apr-2005  mrg fix an error message: could -> could not
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 15-Jan-2005  skrll branches: 1.4.2; 1.4.4; 1.4.6;
Remove local PCI_PRODUCT defines
 1.3 11-Jan-2005  skrll Disable the debug stuff
 1.2 11-Jan-2005  skrll NetBSD RCSID
 1.1 11-Jan-2005  skrll branches: 1.1.1;
Initial revision
 1.1.1.3 18-Nov-2005  skrll Import FreeBSD's iwi(4) of 1-nov-2005
 1.1.1.2 25-Sep-2005  skrll Import of the FreeBSD sources from just after the net80211 merge. There
are no major changes, but this will make future merging easier.
 1.1.1.1 11-Jan-2005  skrll iwi(4) - Intel PRO/Wireless 2200AG/2915ABG driver.
Written by Damien Bergamini, from http://damien.bergamini.free.fr/ipw/

Ad-hoc mode and roaming are not fully implemented yet.
 1.4.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.5 11-Dec-2005  christos Sync with head.
 1.4.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.4.4.1 15-Jan-2005  skrll file if_iwi.c was added on branch ktrace-lwp on 2005-01-17 19:31:24 +0000
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.10.2.8 24-Mar-2008  yamt sync with head.
 1.10.2.7 17-Mar-2008  yamt sync with head.
 1.10.2.6 21-Jan-2008  yamt sync with head
 1.10.2.5 27-Oct-2007  yamt sync with head.
 1.10.2.4 03-Sep-2007  yamt sync with head.
 1.10.2.3 26-Feb-2007  yamt sync with head.
 1.10.2.2 30-Dec-2006  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.30.2.2 02-Nov-2005  yamt sync with head.
 1.30.2.1 26-Oct-2005  yamt sync with head
 1.37.2.3 29-Nov-2005  yamt sync with head.
 1.37.2.2 22-Nov-2005  yamt sync with head.
 1.37.2.1 14-Nov-2005  yamt file if_iwi.c was added on branch yamt-readahead on 2005-11-22 16:08:11 +0000
 1.44.6.2 01-Jun-2006  kardel Sync with head.
 1.44.6.1 22-Apr-2006  simonb Sync with head.
 1.44.4.1 09-Sep-2006  rpaulo sync with head
 1.44.2.1 01-Mar-2006  yamt sync with head.
 1.45.4.4 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.45.4.3 19-Apr-2006  elad sync with head.
 1.45.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.45.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.45.2.5 03-Sep-2006  yamt sync with head.
 1.45.2.4 11-Aug-2006  yamt sync with head
 1.45.2.3 26-Jun-2006  yamt sync with head.
 1.45.2.2 24-May-2006  yamt sync with head.
 1.45.2.1 13-Mar-2006  yamt sync with head.
 1.46.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.48.2.1 19-Jun-2006  chap Sync with head.
 1.49.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.55.4.3 21-Dec-2006  yamt sync with head.
 1.55.4.2 10-Dec-2006  yamt sync with head.
 1.55.4.1 22-Oct-2006  yamt sync with head
 1.55.2.3 01-Feb-2007  ad Sync with head.
 1.55.2.2 12-Jan-2007  ad Sync with head.
 1.55.2.1 18-Nov-2006  ad Sync with head.
 1.58.2.2 28-Jan-2007  tron Pull up following revision(s) (requested by skrll in ticket #385):
sys/dev/pci/if_iwi.c: revision 1.60
Pass the right pointer to firmware_free.
Fixes the DIAGNOSTIC panic reported by Sverre Froyen on current-users.
 1.58.2.1 29-Dec-2006  riz Pull up following revision(s) (requested by skrll in ticket #296):
sys/dev/pci/if_iwireg.h: revision 1.17
sys/dev/pci/if_iwi.c: revision 1.59
sys/dev/pci/if_iwivar.h: revision 1.13
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
 1.60.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.62.14.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.62.14.6 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.62.14.5 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.62.14.4 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.62.14.3 03-Sep-2007  jmcneill Sync with HEAD.
 1.62.14.2 23-Aug-2007  joerg Introduce pci_net_generic_power, which should be enough for most
network drivers and be a good foundation for C&P for the rest.

For iwi(4), don't reset the PCI retry register again, pci_conf_restore
should take care of that already.

For bge(4), add a NetBSD style if_stop.
 1.62.14.1 21-Aug-2007  joerg Convert iwi(4) to pnp_register/pnp_deregister and drop explicit shutdown
hooks.
 1.62.10.1 03-Sep-2007  skrll Sync with HEAD.
 1.62.2.2 23-Oct-2007  ad Sync with head.
 1.62.2.1 09-Oct-2007  ad Sync with head.
 1.63.2.3 23-Mar-2008  matt sync with HEAD
 1.63.2.2 09-Jan-2008  matt sync with HEAD
 1.63.2.1 06-Nov-2007  matt sync with HEAD
 1.64.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.67.6.1 11-Dec-2007  yamt sync with head.
 1.67.4.1 26-Dec-2007  ad Sync with head.
 1.68.10.3 17-Jan-2009  mjf Sync with HEAD.
 1.68.10.2 29-Jun-2008  mjf Sync with HEAD.
 1.68.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.68.6.1 24-Mar-2008  keiichi sync with head.
 1.72.8.1 18-Jun-2008  simonb Sync with head.
 1.72.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.72.4.5 11-Aug-2010  yamt sync with head.
 1.72.4.4 11-Mar-2010  yamt sync with head
 1.72.4.3 16-Sep-2009  yamt sync with head
 1.72.4.2 16-May-2009  yamt sync with head
 1.72.4.1 04-May-2009  yamt sync with head.
 1.72.2.1 17-Jun-2008  yamt sync with head.
 1.73.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.73.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.73.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.73.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.74.2.4 29-Sep-2009  snj Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/dev/pci/if_iwi.c: revision 1.79
make iwi_alloc_tx_ring() prototype match function declaration (shows up when
bus_addr_t != bus_size_t). Fix cast for 64bit paddr_t on i386.
 1.74.2.3 14-Jan-2009  snj branches: 1.74.2.3.4;
Pull up following revision(s) (requested by jmcneill in ticket #250):
sys/dev/pci/if_iwi.c: revision 1.78
sys/dev/pci/if_ipw.c: revision 1.45
Make the "EULA not accepted" message a bit more informative, now reads:
EULA not accepted; please see the <driver>(4) man page.
 1.74.2.2 10-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #43):
sys/dev/pci/if_iwi.c: revision 1.77
Fix typo in fw name.
 1.74.2.1 09-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #25):
sys/dev/pci/if_ipw.c: revision 1.44
sys/dev/pci/if_ipwvar.h: revision 1.14
sys/dev/pci/if_iwi.c: revision 1.76
sys/dev/pci/if_iwn.c: revision 1.26
Match image name with upstream distfiles.
 1.74.2.3.4.1 21-Apr-2010  matt sync to netbsd-5
 1.78.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.83.4.3 31-May-2011  rmind sync with head
 1.83.4.2 05-Mar-2011  rmind sync with head
 1.83.4.1 30-May-2010  rmind sync with head
 1.83.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.85.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.85.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.87.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.87.4.2 30-Oct-2012  yamt sync with head
 1.87.4.1 17-Apr-2012  yamt sync with head
 1.88.2.2 05-Apr-2012  mrg sync to latest -current.
 1.88.2.1 18-Feb-2012  mrg merge to -current.
 1.89.2.1 22-Mar-2012  riz Pull up following revision(s) (requested by nisimura in ticket #134):
sys/dev/pci/if_iwi.c: revision 1.90
Unbreak the endian issue in firmware header decoding. Comfirmed good and
running by a powerpc machine.
 1.91.2.3 03-Dec-2017  jdolecek update from HEAD
 1.91.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.91.2.1 23-Jun-2013  tls resync from head
 1.92.4.1 18-May-2014  rmind sync with head
 1.97.6.5 28-Aug-2017  skrll Sync with HEAD
 1.97.6.4 05-Feb-2017  skrll Sync with HEAD
 1.97.6.3 05-Oct-2016  skrll Sync with HEAD
 1.97.6.2 09-Jul-2016  skrll Sync with HEAD
 1.97.6.1 06-Apr-2015  skrll Sync with HEAD
 1.99.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.99.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.99.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.101.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.103.2.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1835):

sys/dev/pci/if_iwi.c: revision 1.117
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.401
sys/dev/scsipi/ses.c: revision 1.52
sys/dev/isa/mcd.c: revision 1.121
(all via patch)

sys/dev: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.

I think the iwi(4), mcd(4), and ses(4) changes actually plug leaks;
the raidframe(4) change probably doesn't (but doesn't hurt).
 1.103.2.1 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.105.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.105.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.105.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.105.2.1 02-May-2018  pgoyette Synch with HEAD
 1.107.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.107.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.107.2.1 10-Jun-2019  christos Sync with HEAD
 1.111.4.1 03-Aug-2022  martin Pull up following revision(s) (requested by riastradh in ticket #1485):

sys/dev/pci/if_iwi.c: revision 1.117
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.401
sys/dev/scsipi/ses.c: revision 1.52
sys/dev/isa/mcd.c: revision 1.121

sys/dev: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.

I think the iwi(4), mcd(4), and ses(4) changes actually plug leaks;
the raidframe(4) change probably doesn't (but doesn't hurt).
 1.112.2.1 29-Feb-2020  ad Sync with head.
 1.114.8.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.114.8.1 13-May-2021  thorpej Sync with HEAD.
 1.120.10.1 02-Aug-2025  perseant Sync with HEAD
 1.19 08-Sep-2008  gmcgarry Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.18 25-Dec-2007  perry branches: 1.18.6; 1.18.10; 1.18.12; 1.18.16;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.17 20-Dec-2006  skrll branches: 1.17.20; 1.17.26; 1.17.28; 1.17.32;
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
 1.16 09-Aug-2006  skrll branches: 1.16.2; 1.16.4; 1.16.6;
Adapt iwi(4) to use firmload(9) and remove firmware loading from
iwictl(8).
 1.15 29-Nov-2005  rpaulo branches: 1.15.4; 1.15.8;
Add support for software controlled LEDs as found on some
boards. Currently, only the associated LED is being used because
that's the only LED my card has. The other two LEDs (OFDM and
activity) can later be set by someone, easily, who owns some board
with that LEDs.

Reviewed by Nick Hudson.
 1.14 18-Nov-2005  skrll Resolve conflicts. Changelog to follow.
 1.13 14-Nov-2005  skrll branches: 1.13.2;
Dump the error log if we get an IWI_INTR_FATAL_ERROR interrupt.
 1.12 29-Oct-2005  scw Re-arrange a bitfield according to host byte-order.
 1.11 08-Oct-2005  skrll branches: 1.11.2;
Use the new scan command for monitor mode as well.
 1.10 29-Sep-2005  skrll Fix the endianness of the scan command.

All the channels get the right scan type/dwelltime now.
 1.9 25-Sep-2005  skrll Support hidden ESSID APs.

Use the newer scan command as this one doesn't crash the firmware when
scanning 802.11a channels.

Thanks to scw and blymn for testing.

Closes PR 31295.
 1.8 25-Sep-2005  skrll Resolve conflicts.
 1.7 17-Sep-2005  skrll KNF. That is change u_intN_t to uintN_t.
 1.6 12-Sep-2005  skrll Fix spello.
 1.5 19-Aug-2005  skrll More sync with the FreeBSD driver.
 1.4 30-Jul-2005  christos Partially fix. Now it comes up, associates with wep, but something is wrong
with tcp since it crashes in wep encryption when I cvs update.
 1.3 20-Jun-2005  sekiya branches: 1.3.2;
Implement monitor mode. From OpenBSD.
 1.2 11-Jan-2005  skrll branches: 1.2.4;
NetBSD RCSID
 1.1 11-Jan-2005  skrll branches: 1.1.1;
Initial revision
 1.1.1.3 18-Nov-2005  skrll Import FreeBSD's iwi(4) of 1-nov-2005
 1.1.1.2 25-Sep-2005  skrll Import of the FreeBSD sources from just after the net80211 merge. There
are no major changes, but this will make future merging easier.
 1.1.1.1 11-Jan-2005  skrll iwi(4) - Intel PRO/Wireless 2200AG/2915ABG driver.
Written by Damien Bergamini, from http://damien.bergamini.free.fr/ipw/

Ad-hoc mode and roaming are not fully implemented yet.
 1.2.4.4 11-Dec-2005  christos Sync with head.
 1.2.4.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2005  skrll file if_iwireg.h was added on branch ktrace-lwp on 2005-01-17 19:31:24 +0000
 1.3.2.3 21-Jan-2008  yamt sync with head
 1.3.2.2 30-Dec-2006  yamt sync with head.
 1.3.2.1 21-Jun-2006  yamt sync with head.
 1.11.2.1 02-Nov-2005  yamt sync with head.
 1.13.2.3 29-Nov-2005  yamt sync with head.
 1.13.2.2 22-Nov-2005  yamt sync with head.
 1.13.2.1 14-Nov-2005  yamt file if_iwireg.h was added on branch yamt-readahead on 2005-11-22 16:08:11 +0000
 1.15.8.1 11-Aug-2006  yamt sync with head
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.16.6.1 29-Dec-2006  riz Pull up following revision(s) (requested by skrll in ticket #296):
sys/dev/pci/if_iwireg.h: revision 1.17
sys/dev/pci/if_iwi.c: revision 1.59
sys/dev/pci/if_iwivar.h: revision 1.13
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
 1.16.4.1 21-Dec-2006  yamt sync with head.
 1.16.2.1 12-Jan-2007  ad Sync with head.
 1.17.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.17.28.1 26-Dec-2007  ad Sync with head.
 1.17.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.17.20.1 09-Jan-2008  matt sync with HEAD
 1.18.16.1 19-Oct-2008  haad Sync with HEAD.
 1.18.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.18.10.1 04-May-2009  yamt sync with head.
 1.18.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.20 20-Mar-2020  thorpej This driver sleeps during iwi_media_change(), and thus requires an
adaptive mutex for the media lock.
 1.19 02-Feb-2017  nonaka branches: 1.19.14;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.18 06-Sep-2015  dholland branches: 1.18.2; 1.18.4;
More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.17 07-Jan-2015  ozaki-r Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.
 1.16 19-Jan-2010  pooka branches: 1.16.22; 1.16.40;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.15 09-Dec-2007  jmcneill branches: 1.15.14;
Merge jmcneill-pm branch.
 1.14 22-Oct-2007  joerg branches: 1.14.4; 1.14.6;
Convert to device_t/softc split and aprint usage.
 1.13 20-Dec-2006  skrll branches: 1.13.18; 1.13.20; 1.13.24;
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
 1.12 19-Aug-2006  skrll branches: 1.12.2; 1.12.4; 1.12.6;
Add some sysctl knobs to bring us closer to the FreeBSD driver.

Also sysctl enable the debug message printing (if IWI_DEBUG) is defined.
 1.11 09-Aug-2006  skrll Adapt iwi(4) to use firmload(9) and remove firmware loading from
iwictl(8).
 1.10 09-Mar-2006  jmcneill Save and restore PCI configuration state on suspend/resume.
 1.9 29-Nov-2005  rpaulo branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10;
Add support for software controlled LEDs as found on some
boards. Currently, only the associated LED is being used because
that's the only LED my card has. The other two LEDs (OFDM and
activity) can later be set by someone, easily, who owns some board
with that LEDs.

Reviewed by Nick Hudson.
 1.8 18-Nov-2005  skrll Resolve conflicts. Changelog to follow.
 1.7 17-Sep-2005  skrll branches: 1.7.6;
KNF. That is change u_intN_t to uintN_t.
 1.6 19-Aug-2005  skrll Add shutdown and power hooks.
 1.5 19-Aug-2005  skrll More sync with the FreeBSD driver.
 1.4 30-Jul-2005  christos Partially fix. Now it comes up, associates with wep, but something is wrong
with tcp since it crashes in wep encryption when I cvs update.
 1.3 22-Jun-2005  dyoung branches: 1.3.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.2 11-Jan-2005  skrll branches: 1.2.4;
NetBSD RCSID
 1.1 11-Jan-2005  skrll branches: 1.1.1;
Initial revision
 1.1.1.3 18-Nov-2005  skrll Import FreeBSD's iwi(4) of 1-nov-2005
 1.1.1.2 25-Sep-2005  skrll Import of the FreeBSD sources from just after the net80211 merge. There
are no major changes, but this will make future merging easier.
 1.1.1.1 11-Jan-2005  skrll iwi(4) - Intel PRO/Wireless 2200AG/2915ABG driver.
Written by Damien Bergamini, from http://damien.bergamini.free.fr/ipw/

Ad-hoc mode and roaming are not fully implemented yet.
 1.2.4.4 11-Dec-2005  christos Sync with head.
 1.2.4.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2005  skrll file if_iwivar.h was added on branch ktrace-lwp on 2005-01-17 19:31:24 +0000
 1.3.2.4 21-Jan-2008  yamt sync with head
 1.3.2.3 27-Oct-2007  yamt sync with head.
 1.3.2.2 30-Dec-2006  yamt sync with head.
 1.3.2.1 21-Jun-2006  yamt sync with head.
 1.7.6.2 29-Nov-2005  yamt sync with head.
 1.7.6.1 22-Nov-2005  yamt sync with head.
 1.9.10.1 19-Apr-2006  elad sync with head.
 1.9.8.3 03-Sep-2006  yamt sync with head.
 1.9.8.2 11-Aug-2006  yamt sync with head
 1.9.8.1 13-Mar-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.12.6.1 29-Dec-2006  riz Pull up following revision(s) (requested by skrll in ticket #296):
sys/dev/pci/if_iwireg.h: revision 1.17
sys/dev/pci/if_iwi.c: revision 1.59
sys/dev/pci/if_iwivar.h: revision 1.13
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
- Upgrade to the latest firmware and as a result remove the error log dump.
- Mostly sync with OpenBSD
- Serialise sending commands to the firmware
- Remove redundant calls to bpfdetach.
- use bus_size_t where appropriate and not fetch iobase as it's not
used.
- improve 802.11 radiotap support (correct rx rate)
- add short preamble flag
- add short slot time support
- ignore parity errors (as per the Linux driver)
- Set Tx power for all channels.
- disable bluetooth co-existance
- Check that ni->ni_rates.rs_nrates is not greater than the maximum
handled by the firmware.
- Begin syncing with the FreeBSD driver by renaming a few things.
 1.12.4.1 21-Dec-2006  yamt sync with head.
 1.12.2.1 12-Jan-2007  ad Sync with head.
 1.13.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.20.2 09-Jan-2008  matt sync with HEAD
 1.13.20.1 06-Nov-2007  matt sync with HEAD
 1.13.18.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.18.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.13.18.1 21-Aug-2007  joerg Convert iwi(4) to pnp_register/pnp_deregister and drop explicit shutdown
hooks.
 1.14.6.1 11-Dec-2007  yamt sync with head.
 1.14.4.1 26-Dec-2007  ad Sync with head.
 1.15.14.1 11-Mar-2010  yamt sync with head
 1.16.40.3 05-Feb-2017  skrll Sync with HEAD
 1.16.40.2 22-Sep-2015  skrll Sync with HEAD
 1.16.40.1 06-Apr-2015  skrll Sync with HEAD
 1.16.22.1 03-Dec-2017  jdolecek update from HEAD
 1.18.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.18.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.19.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.90 10-Nov-2024  mlelstv Add MBUFTRACE
 1.89 09-Feb-2024  mlelstv branches: 1.89.2;
Fix DMA sync sizes.
Don't panic for inconsistent queue counter, just print an error to console.
 1.88 21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.87 24-Jun-2021  riastradh iwm(4): Disentangle attach.

Don't attach a half-baked interface and then detach it and then
reattach it after mountroot when we can read firmware; just defer
attaching the interface altogether until mountroot.

Likely fixes some panics I've seen every now and then at boot with
iwm(4).
 1.86 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.85 22-May-2020  thorpej branches: 1.85.6;
This driver sleeps during iwm_media_change(), and thus requires an
adaptive mutex for the media lock.
 1.84 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.83 26-Jun-2018  msaitoh branches: 1.83.2; 1.83.10;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.82 08-Jun-2018  knakahara iwm(4) workaround as ifp->if_hwdl can be set only once. Advised nonaka@n.o and ozaki-r@n.o, thanks.

To avoid for iwm(4) to set if_hwdl before loading firmware, use local address
as dummy. See sys/net/if.c::if_set_sadl().
 1.81 08-Jun-2018  knakahara Fix "ifconfig iwm0" failures reported by ryoon@n.o. Advised nonaka@n.o and ozaki-r@n.o, thanks.
 1.80 06-Jun-2018  maya Remove duplicate ;
 1.79 05-Jun-2018  knakahara Fix panic on boot with iwm(4). Advised by nonaka@n.o, thanks.

XXX pullup-8
 1.78 21-Jan-2018  christos branches: 1.78.2;
CID-1427736: Appease coverity using KASSERT
 1.77 10-Jan-2018  mlelstv Match Intel Dual Band Wireless AC 3168. The code already supports it.
 1.76 23-Oct-2017  msaitoh branches: 1.76.2;
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
 1.75 23-Jul-2017  para branches: 1.75.2;
kmem_intr_free kmem_intr_[z]alloced memory

the underlying pools are the same but api-wise those should match
 1.74 09-Jun-2017  nonaka fix typo.

reported by ryo@.
 1.73 01-Jun-2017  chs branches: 1.73.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.72 19-May-2017  nonaka iwm(4): match Wireless 8265 device.
 1.71 14-Mar-2017  nonaka iwm(4): update firmware to maintained core release.

firmware from https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/linux-firmware.git/tree/?id=4b9559fb0565f582a21a4070a81a3b6a7d77610b
 1.70 02-Feb-2017  nonaka wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.69 21-Jan-2017  nonaka PR/51797: initialize hardware completely when receiving a deauth frame from AP.

avoid "iwm0: fatal firmware error".
 1.68 21-Jan-2017  nonaka more block network interrupt.
 1.67 21-Jan-2017  nonaka increase command response timeout value.
 1.66 21-Jan-2017  nonaka include <sys/intr.h> for softint(9).
 1.65 19-Jan-2017  nonaka newstate should be blocked network interrupt, because it called iwm_start.
 1.64 17-Jan-2017  nonaka show NVM channel flags when AB_DEBUG is set.
 1.63 17-Jan-2017  nonaka more acknowledge interrupts from iwn(4).
 1.62 17-Jan-2017  nonaka only bus_dmamap_sync(9) once for ICT region.
 1.61 13-Jan-2017  nonaka branches: 1.61.2;
iwm(4): 3165 works fine with iwlwifi-7265D-17.ucode firmware.

firmware from http://git.kernel.org/cgit/linux/kernel/git/iwlwifi/linux-firmware.git/tree/?id=be8a6fcba2e48e00674d1f35e6def56e2268039c
 1.60 10-Jan-2017  nonaka check LAR support in NVM for 8260/4165.
 1.59 10-Jan-2017  nonaka Add apmg_wake_up_wa support from DragonFly BSD.
 1.58 10-Jan-2017  nonaka iwm(4): 8260 works now. 4165 may works too.
 1.57 10-Jan-2017  nonaka set NULL after free.
 1.56 09-Jan-2017  nonaka Apply OpenBSD if_iwm.c rev.1.148.

> While setting up the basic rate bitmask for iwm's firmware, if the AP does
> not specify basic rates for either the CCK or OFDM set, add just the most
> basic rate to that set (1 Mbit/s in case of CCK, 6 Mbit/s in case of OFDM).
> This behaviour matches what code comments seem to imply.

> The previous code would add all possible basic rates in such cases.
> So if all basic rates were CCK only, the code would add all possible OFDM basic
> rates on top. Then the firmware would send some frames at too high rates, e.g.
> RTS frames would be sent at 24Mbit/s which is a bit risky on noisy channels.
 1.55 09-Jan-2017  khorben Do not use the "flags" field uninitialized

A backport if iwm(4) (to netbsd-7) does not build without this change.

LGTM nonaka@
 1.54 09-Jan-2017  nonaka Added enum iwm_tx_pm_timeouts from FreeBSD.
 1.53 09-Jan-2017  nonaka cosmetic.
 1.52 09-Jan-2017  nonaka use correct header size.
 1.51 08-Jan-2017  nonaka fix indent
 1.50 08-Jan-2017  nonaka iwm(4): make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html
 1.49 08-Jan-2017  nonaka use pci_intr_establish_xname(9).
 1.48 08-Jan-2017  nonaka twiddle bpf related.
 1.47 08-Jan-2017  nonaka cosmetic
 1.46 04-Jan-2017  nonaka Export some 802.11 IE manipulate functions.
 1.45 18-Dec-2016  nonaka iwm(4): Sync with OpenBSD.

7265 works fine.
7260 and 3160 maybe work.
7265D, 3165 and 8260 not work yet.

if_iwm.c: r1.147.
if_iwmreg.h: r1.19 without r1.16.
if_iwmvar.h: r1.24.

firmware is taken from https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi
- iwlwifi-7260-ucode-16.242414.0.tgz
- iwlwifi-3160-ucode-16.242414.0.tgz
- iwlwifi-7265-ucode-16.242414.0.tgz
- iwlwifi-8000-ucode-16.242414.0.tgz
 1.44 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.43 23-Sep-2016  maya Fix inverted logic in iwm(4).

The PROT_REQUIRE flag in should be set for data frames above a certain
length, but we were setting it for !data frames above a certain length,
which makes no sense at all.

- taken from all other BSDs (OpenBSD, FreeBSD, DragonflyBSD...)
 1.42 10-Jun-2016  ozaki-r branches: 1.42.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.41 26-May-2016  ozaki-r Use M_GETCTX

No functional change.
 1.40 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.39 06-Nov-2015  nonaka Always use pci_intr_alloc(9)/pci_intr_release(9).
 1.38 14-Oct-2015  ozaki-r Remove leading whitespaces and kind
 1.37 24-Jul-2015  nonaka Use pci_intr_alloc().
 1.36 22-Jul-2015  nonaka iwm(4) can read the firmware image from disk when interface up.
This change is useful for full-disk encryption environment.
 1.35 22-May-2015  nonaka Limit the number of dma segments used for transmitting packets to
IWM_NUM_OF_TBS - 2. We have IWM_NUM_OF_TBS slots, but use two of those
for sending commands to the firmware.

From OpenBSD rev. 1.41.
 1.34 16-May-2015  nonaka should be able to use 5GHz wireless network.
 1.33 15-May-2015  knakahara if_iwm use unified establish API.
 1.32 29-Apr-2015  nonaka Added control debugging output via sysctl.
 1.31 28-Apr-2015  nonaka Use MSI instead of legacy INTx, if available.

should fix PR/49663.
 1.30 15-Apr-2015  nonaka Register iwm(4) with pmf(9).

Patch from Pierre Pronchery.
 1.29 26-Mar-2015  nonaka branches: 1.29.2;
Not all iwm hardware supports the 5GHz band. Make setting 11a rates
and scanning conditional on the 5GHz support bit in the nvm.

From OpenBSD rev. 1.39. Arranged by me.
 1.28 07-Mar-2015  nonaka Fix radiotap and fixed rates. Radiotap was reporting the wrong rate for
data frames and fixed rates weren't really fixed and were converted into
the wrong hardware rate.

From OpenBSD rev.1.36.
 1.27 07-Mar-2015  khorben Avoid kmem_free(NULL) in iwm_read_firmware()

This code path can be hit if the firmware failed to load, for instance
if the file is not present on the filesystem. In this case
firmware_open() fails, and fw->fw_rawdata never gets allocated in the
first place.
 1.26 04-Mar-2015  nonaka stop the calibration timeout when stopping the interface.

From OpenBSD rev.1.35.
 1.25 04-Mar-2015  nonaka Set/clear the IWM_MAC_FILTER_IN_BEACON flag under conditions that match what
Linux does.

From OpenBSD rev.1.34.
 1.24 03-Mar-2015  nonaka Fix 11a support.

From OpenBSD rev.1.33.
 1.23 03-Mar-2015  nonaka Make setting the MAC context bit for 11g protection when transmitting
OFDM frames conditional on the node via IEEE80211_F_USEPROT.

From OpenBSD rev.1.31.
 1.22 03-Mar-2015  nonaka Don't set CTS to self. Linux stopped setting this back in
dc271ee0d04d12d6bfabacbec803289a7072fbd9 as it is known
to cause problems.

From OpenBSD rev.1.30.
 1.21 03-Mar-2015  nonaka sc_fixed_ridx is initialised to 0 but tested as it it were initialised
to -1. The result of this is tx frames were always sent out at fixed
rate 0 instead of ni_txrate.

Match the iwn behaviour and test ic_fixed_rate for -1 instead.

From OpenBSD rev.1.29.
 1.20 03-Mar-2015  nonaka Correctly set lowest_present_ofdm in iwm_mvm_ack_rates().
From OpenBSD rev.1.28.
 1.19 03-Mar-2015  nonaka init error to 0 in iwm_send_cmd().
From OpenBSD rev.1.27.
 1.18 03-Mar-2015  nonaka match iwn and init txrate at lowest available bit-rate.
From OpenBSD rev.1.26.
 1.17 03-Mar-2015  nonaka workaround for interrupt coalescing bug not needed on 7265.
From OpenBSD if_iwm.c rev.1.25, if_iwmvar.h rev.1.7.
 1.16 02-Mar-2015  nonaka Correctly set lowest_present_ofdm in iwm_mvm_ack_rates().
From OpenBSD rev.1.23.
 1.15 25-Feb-2015  nonaka Display code number of unhandled packet.
 1.14 24-Feb-2015  christos Work around Coverity CIDs 127102{0,1}: Confused by the comparison
nrates > __arraycount(lq->rs_table), coverity erroneously binds nrates
to the range [0..16), whereas it is really bound to [0..15) by
ni->ni_rates.rs_nrates (IEEE80211_RATE_MAXSIZE). We add an explicit comparison
to unconfuse it that will always succeed.
 1.13 24-Feb-2015  nonaka Revert previous change.
 1.12 23-Feb-2015  nonaka CID 1271021: Overrunning array "in->in_ridx" of 15 bytes at byte offset 15 using index "i" (which evaluates to 15).

http://mail-index.netbsd.org/coverity-updates/2015/02/21/msg000115.html
 1.11 20-Feb-2015  nonaka Make the iwm(4) hardware receive filter pass multicast traffic from OpenBSD.
Fixes inet6 autoconf, for example.
 1.10 20-Feb-2015  nonaka Don't return success when hw is not ready.
 1.9 17-Feb-2015  nonaka fix compile failure with IWM_DEBUG on i386.
 1.8 16-Feb-2015  nonaka whitespace
 1.7 16-Feb-2015  nonaka Fix compile failure with clang.
Pointed out by Herbert J. Skuhra.
 1.6 14-Feb-2015  nonaka print error message when fail to load firmware.
 1.5 13-Feb-2015  nonaka iwm(4) works now, but 2.4GHz only.

> iwm0 at pci2 dev 0 function 0: Intel Dual Band Wireless AC 3160 (rev. 0x83)
> iwm0: interrupting at ioapic0 pin 18
> iwm0: hw rev: 0x160, fw ver 25.228 (API ver 9), address XX:XX:XX:XX:XX:XX
> iwm0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
> iwm0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
 1.4 13-Feb-2015  nonaka Make some functions and variables static.
 1.3 13-Feb-2015  nonaka Convert printf() to aprint_*().
 1.2 13-Feb-2015  nonaka Sync with OpenBSD if_iwm.c rev.1.18.
 1.1 07-Feb-2015  pooka Add a driver for Intel Centrino 7260 and similar wireless cards.
Supported devices should more or less match ones supported
by the Linux iwlwifi mvm driver. Sponsored by genua mbh for OpenBSD.

This is probably the world's first Canadian cross device driver: it was
created for OpenBSD by writing and porting a NetBSD driver which was
developed in a rump kernel in Linux userspace.

Note: I don't have access to the hardware anymore, so this version is
not tested and not enabled by default. While I tried to be careful in
adding the NetBSD bits back, it's probable that there's a snafu or two.
Feel free to send private email in case you have the hardware and there
are issues.
 1.29.2.11 28-Aug-2017  skrll Sync with HEAD
 1.29.2.10 05-Feb-2017  skrll Sync with HEAD
 1.29.2.9 05-Oct-2016  skrll Sync with HEAD
 1.29.2.8 09-Jul-2016  skrll Sync with HEAD
 1.29.2.7 29-May-2016  skrll Sync with HEAD
 1.29.2.6 19-Mar-2016  skrll Sync with HEAD
 1.29.2.5 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.29.2.4 22-Sep-2015  skrll Sync with HEAD
 1.29.2.3 06-Jun-2015  skrll Sync with HEAD
 1.29.2.2 06-Apr-2015  skrll Sync with HEAD
 1.29.2.1 26-Mar-2015  skrll file if_iwm.c was added on branch nick-nhusb on 2015-04-06 15:18:10 +0000
 1.42.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.42.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.42.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.61.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.73.2.3 02-Jan-2018  snj Pull up following revision(s) (requested by ozaki-r in ticket #456):
sys/arch/arm/sunxi/sunxi_emac.c: 1.9
sys/dev/ic/dwc_gmac.c: 1.43-1.44
sys/dev/pci/if_iwm.c: 1.75
sys/dev/pci/if_wm.c: 1.543
sys/dev/pci/ixgbe/ixgbe.c: 1.112
sys/dev/pci/ixgbe/ixv.c: 1.74
sys/kern/sys_socket.c: 1.75
sys/net/agr/if_agr.c: 1.43
sys/net/bpf.c: 1.219
sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
sys/net/if_etherip.c: 1.40
sys/net/if_ethersubr.c: 1.243, 1.246
sys/net/if_faith.c: 1.57
sys/net/if_gif.c: 1.132
sys/net/if_l2tp.c: 1.15, 1.17
sys/net/if_loop.c: 1.98-1.101
sys/net/if_media.c: 1.35
sys/net/if_pppoe.c: 1.131-1.132
sys/net/if_spppsubr.c: 1.176-1.177
sys/net/if_tun.c: 1.142
sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
sys/net/npf/npf_ifaddr.c: 1.3
sys/net/npf/npf_os.c: 1.8-1.9
sys/net/rtsock.c: 1.230
sys/netcan/if_canloop.c: 1.3-1.5
sys/netinet/if_arp.c: 1.255
sys/netinet/igmp.c: 1.65
sys/netinet/in.c: 1.210-1.211
sys/netinet/in_pcb.c: 1.180
sys/netinet/ip_carp.c: 1.92, 1.94
sys/netinet/ip_flow.c: 1.81
sys/netinet/ip_input.c: 1.362
sys/netinet/ip_mroute.c: 1.147
sys/netinet/ip_output.c: 1.283, 1.285, 1.287
sys/netinet6/frag6.c: 1.61
sys/netinet6/in6.c: 1.251, 1.255
sys/netinet6/in6_pcb.c: 1.162
sys/netinet6/ip6_flow.c: 1.35
sys/netinet6/ip6_input.c: 1.183
sys/netinet6/ip6_output.c: 1.196
sys/netinet6/mld6.c: 1.90
sys/netinet6/nd6.c: 1.239-1.240
sys/netinet6/nd6_nbr.c: 1.139
sys/netinet6/nd6_rtr.c: 1.136
sys/netipsec/ipsec_output.c: 1.65
sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
 1.73.2.2 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.73.2.1 10-Jun-2017  snj Pull up following revision(s) (requested by nonaka in ticket #21):
sys/dev/pci/if_iwm.c: revision 1.74
fix typo.
reported by ryo@.
 1.75.2.3 26-Jul-2017  snj Pull up following revision(s) (requested by nonaka in ticket #1459):
sys/dev/pci/if_iwm.c: revision 1.72
iwm(4): match Wireless 8265 device.
 1.75.2.2 25-Jul-2017  snj Apply patch (requested by nonaka in ticket #1413):
iwm(4): Add a driver for Intel Wireless 726x, 316x, 826x and 416x series.
Ported from OpenBSD.
 1.75.2.1 23-Jul-2017  snj file if_iwm.c was added on branch netbsd-7 on 2017-07-25 19:43:03 +0000
 1.76.2.2 03-Dec-2017  jdolecek update from HEAD
 1.76.2.1 23-Oct-2017  jdolecek file if_iwm.c was added on branch tls-maxphys on 2017-12-03 11:37:07 +0000
 1.78.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.78.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.83.10.1 29-Feb-2020  ad Sync with head.
 1.83.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.85.6.2 01-Aug-2021  thorpej Sync with HEAD.
 1.85.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.89.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 01-Sep-2023  andvar fix typos in comments, mainly s/innner/inner/.
 1.13 24-Jun-2023  msaitoh Fix typo in comment.
 1.12 05-Dec-2021  msaitoh s/coresponding/corresponding/ in comment.
 1.11 05-Dec-2021  msaitoh availabe -> available in comment.
 1.10 10-Nov-2021  msaitoh s/unoticable/unnoticeable/ in comment.
 1.9 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.8 02-Jun-2021  nia Can't left shift a signed int by 31. Found by kubsan.
 1.7 19-Apr-2018  christos branches: 1.7.8; 1.7.20;
s/static inline/static __inline/g for consistency.
 1.6 14-Mar-2017  nonaka branches: 1.6.6; 1.6.10; 1.6.14; 1.6.16;
iwm(4): update firmware to maintained core release.

firmware from https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/linux-firmware.git/tree/?id=4b9559fb0565f582a21a4070a81a3b6a7d77610b
 1.5 13-Jan-2017  nonaka branches: 1.5.2;
iwm(4): 3165 works fine with iwlwifi-7265D-17.ucode firmware.

firmware from http://git.kernel.org/cgit/linux/kernel/git/iwlwifi/linux-firmware.git/tree/?id=be8a6fcba2e48e00674d1f35e6def56e2268039c
 1.4 09-Jan-2017  nonaka Added enum iwm_tx_pm_timeouts from FreeBSD.
 1.3 18-Dec-2016  nonaka iwm(4): Sync with OpenBSD.

7265 works fine.
7260 and 3160 maybe work.
7265D, 3165 and 8260 not work yet.

if_iwm.c: r1.147.
if_iwmreg.h: r1.19 without r1.16.
if_iwmvar.h: r1.24.

firmware is taken from https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi
- iwlwifi-7260-ucode-16.242414.0.tgz
- iwlwifi-3160-ucode-16.242414.0.tgz
- iwlwifi-7265-ucode-16.242414.0.tgz
- iwlwifi-8000-ucode-16.242414.0.tgz
 1.2 16-Feb-2015  nonaka branches: 1.2.2; 1.2.4;
whitespace
 1.1 07-Feb-2015  pooka Add a driver for Intel Centrino 7260 and similar wireless cards.
Supported devices should more or less match ones supported
by the Linux iwlwifi mvm driver. Sponsored by genua mbh for OpenBSD.

This is probably the world's first Canadian cross device driver: it was
created for OpenBSD by writing and porting a NetBSD driver which was
developed in a rump kernel in Linux userspace.

Note: I don't have access to the hardware anymore, so this version is
not tested and not enabled by default. While I tried to be careful in
adding the NetBSD bits back, it's probable that there's a snafu or two.
Feel free to send private email in case you have the hardware and there
are issues.
 1.2.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.4 28-Aug-2017  skrll Sync with HEAD
 1.2.2.3 05-Feb-2017  skrll Sync with HEAD
 1.2.2.2 06-Apr-2015  skrll Sync with HEAD
 1.2.2.1 16-Feb-2015  skrll file if_iwmreg.h was added on branch nick-nhusb on 2015-04-06 15:18:10 +0000
 1.5.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.6.16.1 22-Apr-2018  pgoyette Sync with HEAD
 1.6.14.2 03-Dec-2017  jdolecek update from HEAD
 1.6.14.1 14-Mar-2017  jdolecek file if_iwmreg.h was added on branch tls-maxphys on 2017-12-03 11:37:07 +0000
 1.6.10.2 25-Jul-2017  snj Apply patch (requested by nonaka in ticket #1413):
iwm(4): Add a driver for Intel Wireless 726x, 316x, 826x and 416x series.
Ported from OpenBSD.
 1.6.10.1 14-Mar-2017  snj file if_iwmreg.h was added on branch netbsd-7 on 2017-07-25 19:43:03 +0000
 1.6.6.1 05-Jun-2021  martin Pull up following revision(s) (requested by nia in ticket #1682):

sys/dev/pci/if_iwmreg.h: revision 1.8

Can't left shift a signed int by 31. Found by kubsan.
 1.7.20.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.7.8.1 05-Jun-2021  martin Pull up following revision(s) (requested by nia in ticket #1282):

sys/dev/pci/if_iwmreg.h: revision 1.8

Can't left shift a signed int by 31. Found by kubsan.
 1.20 22-May-2020  thorpej This driver sleeps during iwm_media_change(), and thus requires an
adaptive mutex for the media lock.
 1.19 05-Oct-2019  mrg remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned. codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
 1.18 14-Mar-2017  nonaka branches: 1.18.10; 1.18.14; 1.18.18;
iwm(4): update firmware to maintained core release.

firmware from https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/linux-firmware.git/tree/?id=4b9559fb0565f582a21a4070a81a3b6a7d77610b
 1.17 02-Feb-2017  nonaka wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.16 21-Jan-2017  nonaka Remove unused iwm_softc member.
 1.15 13-Jan-2017  nonaka branches: 1.15.2;
iwm(4): 3165 works fine with iwlwifi-7265D-17.ucode firmware.

firmware from http://git.kernel.org/cgit/linux/kernel/git/iwlwifi/linux-firmware.git/tree/?id=be8a6fcba2e48e00674d1f35e6def56e2268039c
 1.14 10-Jan-2017  nonaka check LAR support in NVM for 8260/4165.
 1.13 10-Jan-2017  nonaka Add apmg_wake_up_wa support from DragonFly BSD.
 1.12 10-Jan-2017  nonaka iwm(4): 8260 works now. 4165 may works too.
 1.11 08-Jan-2017  nonaka iwm(4): make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html
 1.10 18-Dec-2016  nonaka iwm(4): Sync with OpenBSD.

7265 works fine.
7260 and 3160 maybe work.
7265D, 3165 and 8260 not work yet.

if_iwm.c: r1.147.
if_iwmreg.h: r1.19 without r1.16.
if_iwmvar.h: r1.24.

firmware is taken from https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi
- iwlwifi-7260-ucode-16.242414.0.tgz
- iwlwifi-3160-ucode-16.242414.0.tgz
- iwlwifi-7265-ucode-16.242414.0.tgz
- iwlwifi-8000-ucode-16.242414.0.tgz
 1.9 06-Nov-2015  nonaka branches: 1.9.2;
Always use pci_intr_alloc(9)/pci_intr_release(9).
 1.8 22-Jul-2015  nonaka iwm(4) can read the firmware image from disk when interface up.
This change is useful for full-disk encryption environment.
 1.7 15-May-2015  knakahara if_iwm use unified establish API.
 1.6 28-Apr-2015  nonaka Use MSI instead of legacy INTx, if available.

should fix PR/49663.
 1.5 03-Mar-2015  nonaka branches: 1.5.2;
workaround for interrupt coalescing bug not needed on 7265.
From OpenBSD if_iwm.c rev.1.25, if_iwmvar.h rev.1.7.
 1.4 16-Feb-2015  nonaka whitespace
 1.3 13-Feb-2015  nonaka iwm(4) works now, but 2.4GHz only.

> iwm0 at pci2 dev 0 function 0: Intel Dual Band Wireless AC 3160 (rev. 0x83)
> iwm0: interrupting at ioapic0 pin 18
> iwm0: hw rev: 0x160, fw ver 25.228 (API ver 9), address XX:XX:XX:XX:XX:XX
> iwm0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
> iwm0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
 1.2 13-Feb-2015  nonaka Sync with OpenBSD if_iwm.c rev.1.18.
 1.1 07-Feb-2015  pooka Add a driver for Intel Centrino 7260 and similar wireless cards.
Supported devices should more or less match ones supported
by the Linux iwlwifi mvm driver. Sponsored by genua mbh for OpenBSD.

This is probably the world's first Canadian cross device driver: it was
created for OpenBSD by writing and porting a NetBSD driver which was
developed in a rump kernel in Linux userspace.

Note: I don't have access to the hardware anymore, so this version is
not tested and not enabled by default. While I tried to be careful in
adding the NetBSD bits back, it's probable that there's a snafu or two.
Feel free to send private email in case you have the hardware and there
are issues.
 1.5.2.7 28-Aug-2017  skrll Sync with HEAD
 1.5.2.6 05-Feb-2017  skrll Sync with HEAD
 1.5.2.5 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5.2.4 22-Sep-2015  skrll Sync with HEAD
 1.5.2.3 06-Jun-2015  skrll Sync with HEAD
 1.5.2.2 06-Apr-2015  skrll Sync with HEAD
 1.5.2.1 03-Mar-2015  skrll file if_iwmvar.h was added on branch nick-nhusb on 2015-04-06 15:18:10 +0000
 1.9.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.9.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.18.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.14.2 03-Dec-2017  jdolecek update from HEAD
 1.18.14.1 14-Mar-2017  jdolecek file if_iwmvar.h was added on branch tls-maxphys on 2017-12-03 11:37:08 +0000
 1.18.10.2 25-Jul-2017  snj Apply patch (requested by nonaka in ticket #1413):
iwm(4): Add a driver for Intel Wireless 726x, 316x, 826x and 416x series.
Ported from OpenBSD.
 1.18.10.1 14-Mar-2017  snj file if_iwmvar.h was added on branch netbsd-7 on 2017-07-25 19:43:03 +0000
 1.101 10-Nov-2024  mlelstv Add MBUFTRACE
 1.100 03-Apr-2024  gutteridge branches: 1.100.2;
if_iwn.c: pick up proper firmware for Centrino Wireless-N 130

Both variants should use iwlwifi-6000g2b-6 not iwlwifi-6000g2a-6. (It
seems only two specific product variants use iwlwifi-6000g2a-6. We
could simplify by reversing the sense of the test, as OpenBSD does, but
it doesn't seem to matter much, as what we now match seems to be the
full gamut possible, so the simpler diff was chosen here.)

Addresses PR kern/58105 from wandrien.dev@gmail.com, with the
PCI_PRODUCT_INTEL_WIFI_LINK_130_1 match tested by the reporter. Code
inspection of the FreeBSD driver indicates we should safely be able to
match PCI_PRODUCT_INTEL_WIFI_LINK_130_2 also.
 1.99 25-Apr-2022  gutteridge branches: 1.99.4;
Update firmware for Intel Centrino Advanced-N 6205 WiFi cards

Use the final version of firmware provided for these cards. This has
been tested with both variants of impacted iwn(4) cards (6005_2X2_1 and
6005_2X2_2, as found in a Dell E6230 and a Lenovo T420), improvements
noted.
 1.98 31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.97 19-Sep-2021  andvar fix few more typos in comments, messages and documentation.
 1.96 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.95 08-May-2021  thorpej Use pci_compatible_match().
 1.94 20-Mar-2020  sevan branches: 1.94.8;
Apply the same change as for if_iwi.c r1.114 here, as part of kern/55090.

This driver sleeps during iwn_media_change(), and thus requires an adaptive
mutex for the media lock.
 1.93 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.92 10-Oct-2019  bad branches: 1.92.2;
magic number police. use ETHER_ADDR_LEN.
 1.91 19-Apr-2019  gutteridge branches: 1.91.4;
if_iwn.c: add a comment noting which PCI IDs are covered by an else
statement that loads a specific firmware variant. While here, also
amend the formatting of two other comments.
 1.90 26-Jun-2018  msaitoh branches: 1.90.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.89 01-May-2018  maya GC private 802.11 rateset declarations, use the standard ones.

Build tested only.
 1.88 28-Jan-2018  christos branches: 1.88.2;
add an annotation.
 1.87 16-Jan-2018  maxv Fix overflow.
 1.86 23-Oct-2017  msaitoh If if_initialize() failed in the attach function, free resources and return.
 1.85 19-Jul-2017  mlelstv Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.
 1.84 02-Feb-2017  nonaka branches: 1.84.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.83 02-Feb-2017  nonaka iwn(4): use MSI if available.
 1.82 04-Jan-2017  nonaka branches: 1.82.2;
Export some 802.11 IE manipulate functions.
 1.81 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.80 24-Nov-2016  hkenken bus_dmamap_sync() is required for ICT table read/write.
Tested by arm platform.
 1.79 03-Aug-2016  mlelstv be less noisy with concurrent scan requests.
 1.78 10-Jun-2016  ozaki-r branches: 1.78.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.77 26-May-2016  ozaki-r Use M_GETCTX

No functional change.
 1.76 22-Sep-2015  nonaka PR/50187: Don't use DS parameter set when 5GHz channel is scanning.

XXX: pullup-7
 1.75 24-Aug-2015  pooka Remove "#ifdef INET" code. Por que? Because opt_inet.h was not included
and "#ifdef INET" was just a fancy way of saying "#ifndef NetBSD".
 1.74 09-Nov-2014  nonaka branches: 1.74.2;
Use correct IWN_HW_REV_TYPE_MASK.
 1.73 09-Nov-2014  nonaka fix error messages.
 1.72 30-Oct-2014  nonaka Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.71 29-Mar-2014  christos branches: 1.71.4;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.70 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.69 14-Sep-2013  joerg Conditionalize iwn_memwrite_2 and friends under !IEEE80211_NO_HT.
 1.68 23-Aug-2013  christos PR/48150: Noriyuki Koizumi: Add support for Intel Centrino Advanced-N 6235
Wi-Fi controller
 1.67 28-Jul-2013  prlw1 Add support for Centrino Wireless-N 1030 and Centrino Advanced-N 6230
http://mail-index.netbsd.org/tech-net/2013/01/04/msg003802.html
 1.66 15-Jun-2013  christos branches: 1.66.2;
reflect the correct OpenBSD versions we are synced with.
 1.65 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.64 30-Mar-2013  christos replace function with macro
 1.63 30-Mar-2013  christos remove trailing whitespace
 1.62 30-Jan-2012  drochner branches: 1.62.2; 1.62.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.61 08-Oct-2011  elric branches: 1.61.2; 1.61.6;
Use aprint_error_dev().
 1.60 08-Oct-2011  mbalmer Make this compile again: Use the device_xname() macro to get the devic name.
 1.59 07-Oct-2011  elric Update from OpenBSD merging in 1.111 and 1.112 with log messages:

1.112 Differential gain calibration makes the 6005 firmware crap
out, so skip it for now until we figure out why. This
probably means the device won't function optimally, but
that's better than not functioning at all. Makes my "Intel
Centrinto Advanced-N 6205" work quite well.

1.111 The 6005 and 6050-based parts need DC calibration turned
on, otherwise the firmware will crap out, at least on the
6005. First step to getting my "Intel Centrino Advanced-N
6205" to work.

Both are commited by kettenis@openbsd.org.
 1.58 28-Aug-2011  elric Revert prior inadvertent checkin.
 1.57 28-Aug-2011  elric Remove crypto/dist/heimdal and its associated build infrastructure as
it has been replaced by crypto/external/bsd/heimdal.
 1.56 21-May-2011  msaitoh Add newer Wireless WiFi Link 4965 devices, Centrino Wireless-N 1030
and Centrino Advanced-N 6230
 1.55 20-May-2011  msaitoh Add support for 6050(6250 and 6150) and 6005(6205).
TODO: update iwn.4 manpage.
 1.54 18-May-2011  dyoung #include <sys/bus.h>, not <machine/bus.h>.
 1.53 15-May-2011  christos update from OpenBSD by msaitoh. Tested on amd64.
 1.52 30-Dec-2010  jruoho branches: 1.52.2;
Use "temperature" rather than "TEMP" as the sensor name. No functional change.
 1.51 30-Dec-2010  jruoho Fill out struct ifnet::if_stop, which is required for network class devices
in pmf(9). Fixes the panic reported in PR # kern/44296.
 1.50 29-Aug-2010  christos Don't try to hold the mutex if we are disabling the card because we can
be called from an interrupt context. While this is not strictly correct,
we are SoL anyway so this does not matter.
 1.49 10-Jul-2010  christos V() the mutex when firmware is initialized, duh!
 1.48 03-Jul-2010  christos Don't use spinlocks.
 1.47 02-Jul-2010  christos - Fix the recursive iwn_init() call problem properly.
- Don't print the scan request while scanning all the time. Perhaps I will
remove this completely.
 1.46 18-Jun-2010  christos Patch from Sverre Froyen to avoid panic when an ioctl happens while the
driver is initializing.
 1.45 12-May-2010  christos Use device names from the OpenBSD iwn driver, adding and modifying device
names as needed. From Sverre Froyen
 1.44 02-May-2010  christos Replace iwn_tx from rev. 1.39 with a port of the current OpenBSD version.
Remove superfluous call to bpf_detach.
Add comments regarding porting issues and add a couple of cosmetic changes
that reduce the diffs to the OpenBSD version. From Sverre Froyen
 1.43 28-Apr-2010  christos kill stray free. from Sverre Froyen.
 1.42 23-Apr-2010  christos Align usage of *free and *alloc and clean up the firmware read code.
This fixes two panics that occur for kernels compiled with DIAGNOSTIC and
DEBUG. From Sverre Froyen
 1.41 17-Apr-2010  christos add support for the 6000. From sverre froyen
 1.40 16-Apr-2010  christos Update with newer version from Sverre Froyen
 1.39 11-Apr-2010  mrg avoid rbuf starvation. when grabbing a recieve buffer, if a local
4KB buffer isn't available, try to MEXTMALLOC() one. only if both
of these fail to we abort the recieve operation.

based on a patch from Sverre Froyen <sverre@viewmark.com>, thanks!

tested by myself, sverre and jeremy reed.
 1.38 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.37 24-Feb-2010  dyoung branches: 1.37.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.36 19-Jan-2010  pooka branches: 1.36.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.35 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.34 21-Nov-2009  njoly Cleanup boot messages, use aprint functions.
 1.33 11-Sep-2009  christos Add support for the 5100 and newer firmware. Tested also with the 4900.
Thanks to everyone for helping and testing.
 1.32 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.31 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.30 07-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.29 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.28 22-Dec-2008  blymn branches: 1.28.2;
Pay more attention to the state of the RF kill switch, such as don't
bring the interface up when the RF is off.
 1.27 13-Nov-2008  blymn Actually declare the structures used in iwn_scan_hdr instead of using
pointer arithmetic to create the elements on the fly.

Other changes to scan routine taken from FreeBSD driver.
 1.26 07-Nov-2008  joerg Match image name with upstream distfiles.
 1.25 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.24 06-Nov-2008  blymn Move init of essid to the attach code.
 1.23 05-Nov-2008  blymn * Disable aborting the scan for the moment - it causes a firmware error if
a scan was never initiated which breaks WEP and open wireless connections
* Make sure the ESSID is cleared.
 1.22 20-Oct-2008  rtr branches: 1.22.2; 1.22.4;
- fix crazy condition that always evaluates to false without this
iwn_fix_channel() never gets called.
- remove hardcode to ic->ic_channels[11]

fixes a problem in associating to access points
 1.21 18-Oct-2008  blymn Make scan abort command async as newstate is called from an interrupt
context so we cannot ltsleep.
 1.20 13-Oct-2008  blymn DMA fixes thanks to rtr & skrll
Don't set tsf in auth, this stops firmware errors on WPA renegotiation
Various other tweaks that the linux driver seems to have that we did not
 1.19 20-Sep-2008  freza iwn_node_alloc(): Allocate 'iwn_node' in M_80211_NODE (which is what
ieee80211_node:node_free() expects), not M_DEVBUF. Fixes DIAGNOSTIC
crashes due to suspected double-free.
 1.18 14-Sep-2008  freza * iwn_rx_intr(): free rbuf is available if 'nb_free_entries > 0'.
This used to have '>=' resulting in kernel crash accessing NULL
rbuf under non-trivial Rx load.
 1.17 18-Aug-2008  cube - Make RX queue free list code look like in if_wpi.c, including:
- Protect RX queue free list with a mutex, as it was done in so many
network drivers now that it calls for common code, as dyoung@ points
out.

However, for now it should improve a bit iwn(4)'s stability.
 1.16 29-Jul-2008  christos fix typo.
 1.15 28-Jul-2008  christos just whitespace fixes.
 1.14 28-Jul-2008  christos fix type punned warnings.
 1.13 28-Jul-2008  christos lint wins again :-) From Anon Ymous:
- fix a mis-placed parenthesis.
- fix assignment to the wrong variable.
 1.12 26-Jul-2008  christos make sure we write little endian. From Anon Ymous
 1.11 24-Jul-2008  blymn * Add the BSS node during the auth phase so negotiation can occur
* Make the adding of a node into a function instead of duplicating code
 1.10 10-May-2008  degroote branches: 1.10.2; 1.10.4;
Fix error handling after m_pullup
 1.9 29-Mar-2008  blymn branches: 1.9.2; 1.9.4; 1.9.6;
Remove erroneous byteswap of flags - the flags are byteswapped when
assigned to the tx struct.
 1.8 29-Mar-2008  blymn Clean up trailing whitespace.
 1.7 13-Mar-2008  taca branches: 1.7.2;
Reflect change of PMF_FN_ARGS.
 1.6 11-Mar-2008  dyoung pci_disable_retry() is now a no-op, so don't call it any more.
 1.5 16-Feb-2008  ober branches: 1.5.2; 1.5.4; 1.5.8;
More cleanup. Removal of debug comments.
 1.4 10-Feb-2008  skrll branches: 1.4.2;
Use PRIu64 in a DPRINTF.
 1.3 09-Feb-2008  skrll More whitespace and RCSIds.
 1.2 09-Feb-2008  ober Clean up white space and KNF everything.
 1.1 09-Feb-2008  ober Intel PRO/Wireless LAN 4965AGN Mini-PCI Adapter Driver ported from OpenBSD
by deroote@. OK nick@ moof@
 1.4.2.4 17-Mar-2008  yamt sync with head.
 1.4.2.3 27-Feb-2008  yamt sync with head.
 1.4.2.2 11-Feb-2008  yamt sync with head.
 1.4.2.1 10-Feb-2008  yamt file if_iwn.c was added on branch yamt-lazymbuf on 2008-02-11 14:59:38 +0000
 1.5.8.4 17-Jan-2009  mjf Sync with HEAD.
 1.5.8.3 28-Sep-2008  mjf Sync with HEAD.
 1.5.8.2 02-Jun-2008  mjf Sync with HEAD.
 1.5.8.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.4.1 24-Mar-2008  keiichi sync with head.
 1.5.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.5.2.1 16-Feb-2008  mjf file if_iwn.c was added on branch mjf-devfs on 2008-02-18 21:05:57 +0000
 1.7.2.2 23-Mar-2008  matt sync with HEAD
 1.7.2.1 13-Mar-2008  matt file if_iwn.c was added on branch matt-armv6 on 2008-03-23 02:04:47 +0000
 1.9.6.4 10-Oct-2008  skrll Sync with HEAD.
 1.9.6.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.9.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.9.4.7 09-Oct-2010  yamt sync with head
 1.9.4.6 11-Aug-2010  yamt sync with head.
 1.9.4.5 11-Mar-2010  yamt sync with head
 1.9.4.4 16-Sep-2009  yamt sync with head
 1.9.4.3 16-May-2009  yamt sync with head
 1.9.4.2 04-May-2009  yamt sync with head.
 1.9.4.1 16-May-2008  yamt sync with head.
 1.9.2.1 18-May-2008  yamt sync with head.
 1.10.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.10.4.1 19-Oct-2008  haad Sync with HEAD.
 1.10.2.2 31-Jul-2008  simonb Sync with head.
 1.10.2.1 28-Jul-2008  simonb Sync with head.
 1.22.4.3 15-Nov-2008  snj Pull up following revision(s) (requested by blymn in ticket #58):
sys/dev/pci/if_iwn.c: revision 1.24
Move init of essid to the attach code.
 1.22.4.2 15-Nov-2008  snj Pull up following revision(s) (requested by blymn in ticket #58):
sys/dev/pci/if_iwn.c: revision 1.23
* Disable aborting the scan for the moment - it causes a firmware error if
a scan was never initiated which breaks WEP and open wireless
connections
* Make sure the ESSID is cleared.
 1.22.4.1 09-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #25):
sys/dev/pci/if_ipw.c: revision 1.44
sys/dev/pci/if_ipwvar.h: revision 1.14
sys/dev/pci/if_iwi.c: revision 1.76
sys/dev/pci/if_iwn.c: revision 1.26
Match image name with upstream distfiles.
 1.22.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.28.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.36.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.37.2.4 31-May-2011  rmind sync with head
 1.37.2.3 05-Mar-2011  rmind sync with head
 1.37.2.2 03-Jul-2010  rmind sync with head
 1.37.2.1 30-May-2010  rmind sync with head
 1.52.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.61.6.1 18-Feb-2012  mrg merge to -current.
 1.61.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.61.2.1 17-Apr-2012  yamt sync with head
 1.62.6.3 03-Dec-2017  jdolecek update from HEAD
 1.62.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.62.6.1 23-Jun-2013  tls resync from head
 1.62.2.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by nonaka in ticket #1330):
sys/dev/pci/if_iwnvar.h: revision 1.17
sys/dev/pci/if_iwn.c: revision 1.76
PR/50187: Don't use DS parameter set when 5GHz channel is scanning.
XXX: pullup-7
 1.66.2.2 18-May-2014  rmind sync with head
 1.66.2.1 28-Aug-2013  rmind sync with head
 1.71.4.2 06-Nov-2015  riz Pull up following revision(s) (requested by nonaka in ticket #987):
sys/dev/pci/if_iwnvar.h: revision 1.17
sys/dev/pci/if_iwn.c: revision 1.76
PR/50187: Don't use DS parameter set when 5GHz channel is scanning.
XXX: pullup-7
 1.71.4.1 28-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #467):
external/intel-fw-public/iwl2030/dist/iwlwifi-2030-6.ucode: revision 1.1
distrib/sets/lists/base/mi: revision 1.1091
share/man/man4/iwn.4: revision 1.13
external/intel-fw-public/iwl100/Makefile: revision 1.1
external/intel-fw-public/iwl2030/Makefile: revision 1.1
external/intel-fw-public/iwl135/Makefile: revision 1.1
sys/dev/pci/pcidevs: revision 1.1205
external/intel-fw-public/Makefile: revision 1.8
external/intel-fw-public/iwl135/dist/iwlwifi-135-6.ucode: revision 1.1
external/intel-fw-public/iwl2030/dist/LICENSE.iwlwifi-2030-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/LICENSE.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/LICENSE.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/iwlwifi-100-5.ucode: revision 1.1
external/intel-fw-public/iwl135/dist/LICENSE.iwlwifi-135-ucode: revision 1.1
external/intel-fw-public/iwl135/dist/README.iwlwifi-135-ucode: revision 1.1
sys/dev/pci/if_iwnvar.h: revision 1.16
external/intel-fw-public/iwl2000/dist/iwlwifi-2000-6.ucode: revision 1.1
external/intel-fw-public/iwl100/dist/README.iwlwifi-100-ucode: revision 1.1
sys/dev/pci/if_iwn.c: revision 1.72
sys/dev/pci/if_iwnreg.h: revision 1.14
external/intel-fw-public/iwl105/dist/README.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/LICENSE.iwlwifi-100-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/README.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/iwlwifi-105-6.ucode: revision 1.1
external/intel-fw-public/iwl2000/Makefile: revision 1.1
external/intel-fw-public/iwl105/Makefile: revision 1.1
external/intel-fw-public/iwl2030/dist/README.iwlwifi-2030-ucode: revision 1.1
Add some Intel Wi-Fi devices.
Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.74.2.8 28-Aug-2017  skrll Sync with HEAD
 1.74.2.7 05-Feb-2017  skrll Sync with HEAD
 1.74.2.6 05-Dec-2016  skrll Sync with HEAD
 1.74.2.5 05-Oct-2016  skrll Sync with HEAD
 1.74.2.4 09-Jul-2016  skrll Sync with HEAD
 1.74.2.3 29-May-2016  skrll Sync with HEAD
 1.74.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.74.2.1 22-Sep-2015  skrll Sync with HEAD
 1.78.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.78.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.78.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.82.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.84.6.3 17-Apr-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1953):

sys/dev/pci/if_iwn.c: revision 1.100

if_iwn.c: pick up proper firmware for Centrino Wireless-N 130

Both variants should use iwlwifi-6000g2b-6 not iwlwifi-6000g2a-6. (It
seems only two specific product variants use iwlwifi-6000g2a-6. We
could simplify by reversing the sense of the test, as OpenBSD does, but
it doesn't seem to matter much, as what we now match seems to be the
full gamut possible, so the simpler diff was chosen here.)

Addresses PR kern/58105 from wandrien.dev%gmail.com@localhost, with the
PCI_PRODUCT_INTEL_WIFI_LINK_130_1 match tested by the reporter. Code
inspection of the FreeBSD driver indicates we should safely be able to
match PCI_PRODUCT_INTEL_WIFI_LINK_130_2 also.
 1.84.6.2 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.84.6.1 25-Aug-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #218):
sys/dev/pci/if_iwn.c: revision 1.85
sys/dev/pci/if_iwnreg.h: revision 1.17
sys/dev/pci/if_iwnvar.h: revision 1.20
Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.
 1.88.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.88.2.1 02-May-2018  pgoyette Synch with HEAD
 1.90.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.90.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.90.2.1 10-Jun-2019  christos Sync with HEAD
 1.91.4.1 17-Apr-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1825):

sys/dev/pci/if_iwn.c: revision 1.100

if_iwn.c: pick up proper firmware for Centrino Wireless-N 130

Both variants should use iwlwifi-6000g2b-6 not iwlwifi-6000g2a-6. (It
seems only two specific product variants use iwlwifi-6000g2a-6. We
could simplify by reversing the sense of the test, as OpenBSD does, but
it doesn't seem to matter much, as what we now match seems to be the
full gamut possible, so the simpler diff was chosen here.)

Addresses PR kern/58105 from wandrien.dev%gmail.com@localhost, with the
PCI_PRODUCT_INTEL_WIFI_LINK_130_1 match tested by the reporter. Code
inspection of the FreeBSD driver indicates we should safely be able to
match PCI_PRODUCT_INTEL_WIFI_LINK_130_2 also.
 1.92.2.1 29-Feb-2020  ad Sync with head.
 1.94.8.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.94.8.1 13-May-2021  thorpej Sync with HEAD.
 1.99.4.1 17-Apr-2024  martin Pull up following revision(s) (requested by riastradh in ticket #653):

sys/dev/pci/if_iwn.c: revision 1.100

if_iwn.c: pick up proper firmware for Centrino Wireless-N 130

Both variants should use iwlwifi-6000g2b-6 not iwlwifi-6000g2a-6. (It
seems only two specific product variants use iwlwifi-6000g2a-6. We
could simplify by reversing the sense of the test, as OpenBSD does, but
it doesn't seem to matter much, as what we now match seems to be the
full gamut possible, so the simpler diff was chosen here.)

Addresses PR kern/58105 from wandrien.dev%gmail.com@localhost, with the
PCI_PRODUCT_INTEL_WIFI_LINK_130_1 match tested by the reporter. Code
inspection of the FreeBSD driver indicates we should safely be able to
match PCI_PRODUCT_INTEL_WIFI_LINK_130_2 also.
 1.100.2.1 02-Aug-2025  perseant Sync with HEAD
 1.18 17-Jun-2021  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.17 19-Jul-2017  mlelstv branches: 1.17.22;
Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.
 1.16 11-Mar-2017  maya branches: 1.16.6;
Add missing comma, else the strings are concatenated (and possibly the
wrong message is used). noted by coverity.

Linux iwlwifi strings seem similar.
 1.15 09-Nov-2014  nonaka branches: 1.15.2; 1.15.4; 1.15.6;
Use correct IWN_HW_REV_TYPE_MASK.
 1.14 30-Oct-2014  nonaka Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.13 28-Jul-2013  prlw1 branches: 1.13.4;
Add support for Centrino Wireless-N 1030 and Centrino Advanced-N 6230
http://mail-index.netbsd.org/tech-net/2013/01/04/msg003802.html
 1.12 15-Jun-2013  christos branches: 1.12.2;
reflect the correct OpenBSD versions we are synced with.
 1.11 30-Mar-2013  christos Use only one set of EDCA variables
 1.10 08-Oct-2011  elric branches: 1.10.2; 1.10.12;
Update from OpenBSD merging in 1.111 and 1.112 with log messages:

1.112 Differential gain calibration makes the 6005 firmware crap
out, so skip it for now until we figure out why. This
probably means the device won't function optimally, but
that's better than not functioning at all. Makes my "Intel
Centrinto Advanced-N 6205" work quite well.

1.111 The 6005 and 6050-based parts need DC calibration turned
on, otherwise the firmware will crap out, at least on the
6005. First step to getting my "Intel Centrino Advanced-N
6205" to work.

Both are commited by kettenis@openbsd.org.
 1.9 15-May-2011  christos update from OpenBSD by msaitoh. Tested on amd64.
 1.8 18-Jun-2010  christos branches: 1.8.2;
Patch from Sverre Froyen to avoid panic when an ioctl happens while the
driver is initializing.
 1.7 16-Apr-2010  christos Update with newer version from Sverre Froyen
 1.6 11-Sep-2009  christos branches: 1.6.2; 1.6.4;
Add support for the 5100 and newer firmware. Tested also with the 4900.
Thanks to everyone for helping and testing.
 1.5 13-Nov-2008  blymn Actually declare the structures used in iwn_scan_hdr instead of using
pointer arithmetic to create the elements on the fly.

Other changes to scan routine taken from FreeBSD driver.
 1.4 13-Oct-2008  blymn branches: 1.4.2;
Correct beacon structure
Add scan abort command
Add TX status codes from FreeBSD driver
 1.3 09-Feb-2008  skrll branches: 1.3.2; 1.3.4; 1.3.10; 1.3.12; 1.3.16; 1.3.22;
More whitespace and RCSIds.
 1.2 09-Feb-2008  ober Clean up white space and KNF everything.
 1.1 09-Feb-2008  ober Intel PRO/Wireless LAN 4965AGN Mini-PCI Adapter Driver ported from OpenBSD
by deroote@. OK nick@ moof@
 1.3.22.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.22.1 19-Oct-2008  haad Sync with HEAD.
 1.3.16.3 11-Aug-2010  yamt sync with head.
 1.3.16.2 16-Sep-2009  yamt sync with head
 1.3.16.1 04-May-2009  yamt sync with head.
 1.3.12.2 23-Mar-2008  matt sync with HEAD
 1.3.12.1 09-Feb-2008  matt file if_iwnreg.h was added on branch matt-armv6 on 2008-03-23 02:04:47 +0000
 1.3.10.1 17-Jan-2009  mjf Sync with HEAD.
 1.3.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.3.4.1 09-Feb-2008  mjf file if_iwnreg.h was added on branch mjf-devfs on 2008-02-18 21:05:57 +0000
 1.3.2.2 11-Feb-2008  yamt sync with head.
 1.3.2.1 09-Feb-2008  yamt file if_iwnreg.h was added on branch yamt-lazymbuf on 2008-02-11 14:59:38 +0000
 1.4.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.4.3 31-May-2011  rmind sync with head
 1.6.4.2 03-Jul-2010  rmind sync with head
 1.6.4.1 30-May-2010  rmind sync with head
 1.6.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.12.3 03-Dec-2017  jdolecek update from HEAD
 1.10.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.12.1 23-Jun-2013  tls resync from head
 1.10.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.2.1 28-Aug-2013  rmind sync with head
 1.13.4.1 28-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #467):
external/intel-fw-public/iwl2030/dist/iwlwifi-2030-6.ucode: revision 1.1
distrib/sets/lists/base/mi: revision 1.1091
share/man/man4/iwn.4: revision 1.13
external/intel-fw-public/iwl100/Makefile: revision 1.1
external/intel-fw-public/iwl2030/Makefile: revision 1.1
external/intel-fw-public/iwl135/Makefile: revision 1.1
sys/dev/pci/pcidevs: revision 1.1205
external/intel-fw-public/Makefile: revision 1.8
external/intel-fw-public/iwl135/dist/iwlwifi-135-6.ucode: revision 1.1
external/intel-fw-public/iwl2030/dist/LICENSE.iwlwifi-2030-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/LICENSE.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/LICENSE.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/iwlwifi-100-5.ucode: revision 1.1
external/intel-fw-public/iwl135/dist/LICENSE.iwlwifi-135-ucode: revision 1.1
external/intel-fw-public/iwl135/dist/README.iwlwifi-135-ucode: revision 1.1
sys/dev/pci/if_iwnvar.h: revision 1.16
external/intel-fw-public/iwl2000/dist/iwlwifi-2000-6.ucode: revision 1.1
external/intel-fw-public/iwl100/dist/README.iwlwifi-100-ucode: revision 1.1
sys/dev/pci/if_iwn.c: revision 1.72
sys/dev/pci/if_iwnreg.h: revision 1.14
external/intel-fw-public/iwl105/dist/README.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/LICENSE.iwlwifi-100-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/README.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/iwlwifi-105-6.ucode: revision 1.1
external/intel-fw-public/iwl2000/Makefile: revision 1.1
external/intel-fw-public/iwl105/Makefile: revision 1.1
external/intel-fw-public/iwl2030/dist/README.iwlwifi-2030-ucode: revision 1.1
Add some Intel Wi-Fi devices.
Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.15.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.15.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.15.2.1 28-Aug-2017  skrll Sync with HEAD
 1.16.6.1 25-Aug-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #218):
sys/dev/pci/if_iwn.c: revision 1.85
sys/dev/pci/if_iwnreg.h: revision 1.17
sys/dev/pci/if_iwnvar.h: revision 1.20
Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.
 1.17.22.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.22 20-Mar-2020  sevan Apply the same change as for if_iwi.c r1.114 here, as part of kern/55090.

This driver sleeps during iwn_media_change(), and thus requires an adaptive
mutex for the media lock.
 1.21 05-Oct-2019  mrg remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned. codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
 1.20 19-Jul-2017  mlelstv branches: 1.20.4;
Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.
 1.19 02-Feb-2017  nonaka branches: 1.19.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.18 02-Feb-2017  nonaka iwn(4): use MSI if available.
 1.17 22-Sep-2015  nonaka branches: 1.17.2; 1.17.4;
PR/50187: Don't use DS parameter set when 5GHz channel is scanning.

XXX: pullup-7
 1.16 30-Oct-2014  nonaka branches: 1.16.2;
Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.15 28-Jul-2013  prlw1 branches: 1.15.4;
Add support for Centrino Wireless-N 1030 and Centrino Advanced-N 6230
http://mail-index.netbsd.org/tech-net/2013/01/04/msg003802.html
 1.14 15-Jun-2013  christos branches: 1.14.2;
reflect the correct OpenBSD versions we are synced with.
 1.13 15-May-2011  christos branches: 1.13.4; 1.13.10; 1.13.14;
update from OpenBSD by msaitoh. Tested on amd64.
 1.12 02-Jul-2010  christos branches: 1.12.2;
- Fix the recursive iwn_init() call problem properly.
- Don't print the scan request while scanning all the time. Perhaps I will
remove this completely.
 1.11 18-Jun-2010  christos Patch from Sverre Froyen to avoid panic when an ioctl happens while the
driver is initializing.
 1.10 23-Apr-2010  christos Align usage of *free and *alloc and clean up the firmware read code.
This fixes two panics that occur for kernels compiled with DIAGNOSTIC and
DEBUG. From Sverre Froyen
 1.9 16-Apr-2010  christos Update with newer version from Sverre Froyen
 1.8 19-Jan-2010  pooka branches: 1.8.2; 1.8.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.7 17-Jan-2010  pooka Forward declare struct bpf_if and use that as the type for bpf_if
instead of "void *". Buys us oo times the type-safety for 0 times
the price.
(no functional change)
 1.6 11-Sep-2009  christos Add support for the 5100 and newer firmware. Tested also with the 4900.
Thanks to everyone for helping and testing.
 1.5 22-Dec-2008  blymn Pay more attention to the state of the RF kill switch, such as don't
bring the interface up when the RF is off.
 1.4 18-Aug-2008  cube branches: 1.4.2;
- Make RX queue free list code look like in if_wpi.c, including:
- Protect RX queue free list with a mutex, as it was done in so many
network drivers now that it calls for common code, as dyoung@ points
out.

However, for now it should improve a bit iwn(4)'s stability.
 1.3 09-Feb-2008  skrll branches: 1.3.2; 1.3.4; 1.3.10; 1.3.12; 1.3.16; 1.3.18; 1.3.22;
More whitespace and RCSIds.
 1.2 09-Feb-2008  ober Clean up white space and KNF everything.
 1.1 09-Feb-2008  ober Intel PRO/Wireless LAN 4965AGN Mini-PCI Adapter Driver ported from OpenBSD
by deroote@. OK nick@ moof@
 1.3.22.1 19-Oct-2008  haad Sync with HEAD.
 1.3.18.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.16.4 11-Aug-2010  yamt sync with head.
 1.3.16.3 11-Mar-2010  yamt sync with head
 1.3.16.2 16-Sep-2009  yamt sync with head
 1.3.16.1 04-May-2009  yamt sync with head.
 1.3.12.2 23-Mar-2008  matt sync with HEAD
 1.3.12.1 09-Feb-2008  matt file if_iwnvar.h was added on branch matt-armv6 on 2008-03-23 02:04:47 +0000
 1.3.10.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.10.1 28-Sep-2008  mjf Sync with HEAD.
 1.3.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.3.4.1 09-Feb-2008  mjf file if_iwnvar.h was added on branch mjf-devfs on 2008-02-18 21:05:57 +0000
 1.3.2.2 11-Feb-2008  yamt sync with head.
 1.3.2.1 09-Feb-2008  yamt file if_iwnvar.h was added on branch yamt-lazymbuf on 2008-02-11 14:59:38 +0000
 1.4.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.4.3 31-May-2011  rmind sync with head
 1.8.4.2 03-Jul-2010  rmind sync with head
 1.8.4.1 30-May-2010  rmind sync with head
 1.8.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.8.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.14.3 03-Dec-2017  jdolecek update from HEAD
 1.13.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.14.1 23-Jun-2013  tls resync from head
 1.13.10.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by nonaka in ticket #1330):
sys/dev/pci/if_iwnvar.h: revision 1.17
sys/dev/pci/if_iwn.c: revision 1.76
PR/50187: Don't use DS parameter set when 5GHz channel is scanning.
XXX: pullup-7
 1.13.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.1 28-Aug-2013  rmind sync with head
 1.15.4.2 06-Nov-2015  riz Pull up following revision(s) (requested by nonaka in ticket #987):
sys/dev/pci/if_iwnvar.h: revision 1.17
sys/dev/pci/if_iwn.c: revision 1.76
PR/50187: Don't use DS parameter set when 5GHz channel is scanning.
XXX: pullup-7
 1.15.4.1 28-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #467):
external/intel-fw-public/iwl2030/dist/iwlwifi-2030-6.ucode: revision 1.1
distrib/sets/lists/base/mi: revision 1.1091
share/man/man4/iwn.4: revision 1.13
external/intel-fw-public/iwl100/Makefile: revision 1.1
external/intel-fw-public/iwl2030/Makefile: revision 1.1
external/intel-fw-public/iwl135/Makefile: revision 1.1
sys/dev/pci/pcidevs: revision 1.1205
external/intel-fw-public/Makefile: revision 1.8
external/intel-fw-public/iwl135/dist/iwlwifi-135-6.ucode: revision 1.1
external/intel-fw-public/iwl2030/dist/LICENSE.iwlwifi-2030-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/LICENSE.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/LICENSE.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/iwlwifi-100-5.ucode: revision 1.1
external/intel-fw-public/iwl135/dist/LICENSE.iwlwifi-135-ucode: revision 1.1
external/intel-fw-public/iwl135/dist/README.iwlwifi-135-ucode: revision 1.1
sys/dev/pci/if_iwnvar.h: revision 1.16
external/intel-fw-public/iwl2000/dist/iwlwifi-2000-6.ucode: revision 1.1
external/intel-fw-public/iwl100/dist/README.iwlwifi-100-ucode: revision 1.1
sys/dev/pci/if_iwn.c: revision 1.72
sys/dev/pci/if_iwnreg.h: revision 1.14
external/intel-fw-public/iwl105/dist/README.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/LICENSE.iwlwifi-100-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/README.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/iwlwifi-105-6.ucode: revision 1.1
external/intel-fw-public/iwl2000/Makefile: revision 1.1
external/intel-fw-public/iwl105/Makefile: revision 1.1
external/intel-fw-public/iwl2030/dist/README.iwlwifi-2030-ucode: revision 1.1
Add some Intel Wi-Fi devices.
Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.16.2.3 28-Aug-2017  skrll Sync with HEAD
 1.16.2.2 05-Feb-2017  skrll Sync with HEAD
 1.16.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.17.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.19.6.1 25-Aug-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #218):
sys/dev/pci/if_iwn.c: revision 1.85
sys/dev/pci/if_iwnreg.h: revision 1.17
sys/dev/pci/if_iwnvar.h: revision 1.20
Pull in some hardware support from FreeBSD. Also fix 5GHz mode by
adapting the method described in: https://forums.freebsd.org/threads/53574/.
 1.20.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.20.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.100 25-Mar-2025  christos Don't return random value from interrupt. (coverity)
 1.99 29-Jun-2024  riastradh branches: 1.99.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.98 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.97 05-Feb-2024  andvar fix various typos in comments.
 1.96 20-Dec-2023  skrll Remove unnecssary #include
 1.95 13-Oct-2023  yamaguchi ixl(4): limit receive frame size upto 9600 even if ETHERCAP_VLAN_MTU is enabled
 1.94 13-Oct-2023  yamaguchi ixl(4): added ETHERCAP_VLAN_MTU support

PR kern/57652
 1.93 11-Oct-2023  rin ixl(4): Print device info on attach

Without PCIVERBOSE option:
ixl0 at pci1 dev 0 function 0: vendor 8086 product 1572 (rev. 0x01)

With PCIVERBOSE option:
ixl0 at pci1 dev 0 function 0: Intel XL710 SFP+ Ethernet (SFI) (rev. 0x01)

OK yamaguchi@
 1.92 11-Oct-2023  yamaguchi ixl(4): update link status in workqueue
 1.91 11-Oct-2023  yamaguchi ixl(4): use cv_broadcast to wakeup ioctl and workqueue context.

Commands may be issued at the same time from the both context.
 1.90 11-Oct-2023  yamaguchi ixl(4): skip getting link status if the last command is running
 1.89 26-Mar-2023  andvar fix various typos in documentation, comments and sysctl device description.
mainly aion -> ation and inlude -> include.
 1.88 16-Sep-2022  knakahara branches: 1.88.4;
Add ALWAYS_TXDEFER option to ixl(4), too.
 1.87 28-Aug-2022  skrll Empty if_watchdog functions are useless and now waste resources. Let's
remove them.
 1.86 25-Aug-2022  knakahara Tune number of Rx descriptors for ixl(4), ok'ed by yamaguchi@n.o.

In some tunneling measurement cases, that improve performance.
In other cases, that keep up performance.
 1.85 17-Jun-2022  yamaguchi ixl(4): fix typo
 1.84 17-Jun-2022  yamaguchi ixl(4), iavf(4): fix endian bug in vlan tag
 1.83 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.82 31-Mar-2022  yamaguchi call detach functions before stopping the interrupt for atq
 1.81 31-Mar-2022  yamaguchi Use xc_barrier to wait for finish of the interrupt handler

poited out by riastradh@n.o, thanks.
 1.80 31-Mar-2022  yamaguchi ixl(4): remove unnecessary lock acquirement

Running interrupt handlers is finished while accessing to
I40E_Q[TR]X_ENA register. Therefore, it is not need to acquire
locks to wait for the finish.

pointed out by riastradh@n.o, thanks.
 1.79 24-Mar-2022  yamaguchi ixl(4): Added Intel V710 for 5000BaseT support
 1.78 16-Mar-2022  yamaguchi ixl: Added support for Intel ethernet X710-T*L
 1.77 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.76 09-Feb-2021  jakllsch branches: 1.76.4;
Zero interrupt handles upon allocation.

Might prevent detach-time bugs.
 1.75 08-Sep-2020  yamaguchi branches: 1.75.2;
Added iavf(4) that is based on OpenBSD's iavf(4) implementation

reviewed by msaitoh@n.o and knakahara@n.o
 1.74 19-Aug-2020  yamaguchi Make descriptor_num in ixl(4) readonly
because ixl(4) does not support reallocating related resources

pointed out by knakahara@, thanks.
 1.73 19-Aug-2020  yamaguchi Adjust the default descriptor sizes for ixl(4)

These decreasements has no impact for throughput
while forwarding 64-1518 byte packets.
 1.72 19-Aug-2020  yamaguchi whitespace fix

From msaitoh@, thanks.
 1.71 31-Jul-2020  yamaguchi Use if_initialize() and if_register()
 1.70 31-Jul-2020  yamaguchi Added sysctl nodes for the number of descriptors in ixl(4)
 1.69 31-Jul-2020  yamaguchi Added sysctl nodes for ixl(4) Interrupt throttling(ITR)
 1.68 16-Jul-2020  yamaguchi Set PCI_COMMAND_MASTER_ENABLE and PCI_COMMAND_MEM_ENABLE
to activate the pci devices

This configuration is needed when BIOS or UEFI do not make them set.
 1.67 11-Jun-2020  thorpej Update for proplib(3) API changes.
 1.66 14-May-2020  msaitoh Remove extra semicolon.
 1.65 19-Mar-2020  yamaguchi branches: 1.65.2;
Fix panic due to aquire an adaptive mutex with spin mutex held

The panic is caused by the spin mutex held in ifmedia before
calling callbacks. ixl(4) registers the adaptive mutex used in
the callbacks at initialization to prevent the panic.
 1.64 13-Mar-2020  yamaguchi Use I40E_PFINT_ITRN registers to enable ITR for MSI-X interrupts
 1.63 13-Mar-2020  yamaguchi Fix locking against myself at ixl_link_state_update()
called by ixl_get_link_status()

Though the timing to call the function is change,
there is no order to get link status at initialization.
 1.62 12-Mar-2020  yamaguchi hold the lock for struct ixl_softc during read or write to sc->sc_media_*

OKed by knakahara@n.o
 1.61 12-Mar-2020  yamaguchi remove unnecessary code because IFM_ACTIVE is setted
in ixl_set_link_status()

OKed by knakahara@n.o
 1.60 03-Mar-2020  yamaguchi Send packets even if link state is not up

ixl(4) has not the limitation that it must not send packet when
link is down. And most of the other NIC drivers do not refer to it
when sending packets.

reviewed by knakahara@n.o, thanks.
 1.59 03-Mar-2020  yamaguchi Use ixl_atq_exec for waiting the Get link status response of ixl(4)
not to send the same command at once

reviewed by knakahara@n.o., thanks.
 1.58 03-Mar-2020  yamaguchi Added KASSERT
 1.57 03-Mar-2020  yamaguchi Fix the crash when ixl(4) sends Get link status command
and receives Get link status response in parallel

sc->sc_link_state_atq.iatq_fn is used in ixl_atq_done_locked()
with sc->sc_atq_lock, but it was cleared in ixl_get_link_status()
without the lock.
 1.56 25-Feb-2020  yamaguchi Add a comment about RSS and remove a wrong comment

pointed out and reviewed by knakahara@n.o., thanks
 1.55 25-Feb-2020  yamaguchi Use IFM_25G_ACC

pointed out and reviewed by msaitoh@n.o., thanks
 1.54 25-Feb-2020  yamaguchi Use kmem_alloc instead of malloc

pointed out and reviewed by knakahar@n.o., thanks
 1.53 25-Feb-2020  yamaguchi Change the number of retry to be the same as FreeBSD and Linux

pointed out and reviewed by knakahara@n.o., thanks.
 1.52 25-Feb-2020  yamaguchi Disable all queues before waiting for the completion
on each queue to reduce the number of delays

pointed out and reviewed by knakahara@n.o., thanks
 1.51 25-Feb-2020  yamaguchi Use callout_halt() instead of callout_stop for safety

pointed out and reviewed by knakahara@n.o., thanks
 1.50 25-Feb-2020  yamaguchi Stop callout for statistics while the interface is not running
 1.49 25-Feb-2020  yamaguchi Change position of the cpuid::ixl_hmc_txq
to be same with ixl_hmc_pack_txq[]

This has no functionality impact because the position on memory
is defined in ixl_hmc_pack_txq[].

pointed out and reviewed by knakahara@n.o., thanks
 1.48 25-Feb-2020  yamaguchi Hold per-queue locks when clearing config of queues for safety
 1.47 25-Feb-2020  yamaguchi Add defines for the max number of queue

pointed out and reviewed by knakahara@n.o., thanks
 1.46 25-Feb-2020  yamaguchi Set 0 to txr_{prod,cons} and rxr_{prod,cons} when HMC objects
are cleared

Those values should be the same as head and tail in an HMC object
 1.45 25-Feb-2020  yamaguchi Use workqueue API directly, without the wrapper in ixl(4)
to improve performace by removing atomic_ops(3)

pointed out and reviewed by knakahara@n.o., thanks
 1.44 25-Feb-2020  yamaguchi Remove WQ_PERCPU flag for the workqueue that does configurations
such as link up and down

And added kpreempt_disable and kpreempt_enable around
workqueue_enqueue to call it in non-WQ_PERCPU thread context.

pointed out and reviewed by knakahara@n.o., thanks.
 1.43 25-Feb-2020  yamaguchi Added __KERNEL_RCSID
 1.42 12-Feb-2020  yamaguchi Remove wrong KASSERTs because mutex_owned for a spin lock doesn't check
that a lock is held in the current context.
 1.41 12-Feb-2020  yamaguchi Use Set RSS key command and Set LUT command to enable RSS on X722
 1.40 12-Feb-2020  yamaguchi xl(4) should use the aq command to access RX control registers
if the device is X722 or others whose API version is upper than 1.5
 1.39 12-Feb-2020  yamaguchi Fix a wrong comment in ixl(4)
 1.38 12-Feb-2020  yamaguchi Change the command sequence and timing to prevent EIO
in "Get PHY Abilities" command

The error has been appeared on X722 attaching an SFP module
without link up.
 1.37 07-Feb-2020  yamaguchi Use if_link_state_change() even if ixl(4) is attaching
 1.36 04-Feb-2020  thorpej Use ifmedia_fini().
 1.35 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.34 31-Jan-2020  yamaguchi Revert r1.32 because some documents say that the device supports SFP+ SX/LX

I referred the document #332191-024 "Intel Ethernet Controller
X710/XXV710/XL710 Feature Support Matrix"

pointed out by msaitoh@, thanks.
 1.33 31-Jan-2020  yamaguchi Fix missing kpreempt_disabe()
 1.32 31-Jan-2020  yamaguchi Remove unsupported media on ixl(4)
 1.31 31-Jan-2020  yamaguchi Add media and flow changes support for ixl(4)
 1.30 31-Jan-2020  yamaguchi Fix a wrong return code from ixl_get_phy_types()
 1.29 30-Jan-2020  yamaguchi Add SIOCSIFMTU support for ixl(4)
 1.28 27-Jan-2020  yamaguchi Add TX checksum offload supports for ixl(4)
 1.27 27-Jan-2020  yamaguchi Fix missing PCI_INTR_MPSAFE settings in ixl(4)
 1.26 17-Jan-2020  yamaguchi Print nvm version of ixl(4) when attaching

reviewed by msaitoh
 1.25 17-Jan-2020  yamaguchi Use flags instead of bool that changes behavior related to
adminq command of ixl(4)
 1.24 17-Jan-2020  yamaguchi Fix the wrong expression in ixl(4)

Closes PR/54860.
 1.23 16-Jan-2020  yamaguchi Fix wrong usage of PCI_PRODUCT(), ixl(4)
 1.22 16-Jan-2020  yamaguchi Fix ixl(4) not to assign interrupts to cpu #0
if ncpu > queue pairs
 1.21 16-Jan-2020  yamaguchi Use def{flag,param} for parameters in ixl(4)
 1.20 15-Jan-2020  yamaguchi Fix typo (s/txr_opackets/txr_obytes/)

pointed out by ryo@n.o, thanks.
 1.19 09-Jan-2020  yamaguchi Make some parametes in ixl(4) be able to change when loading
for debugging

- nomsix(boolean)
- disable msix support
- stats_interval(signed integer)
- change interval for collecting statistic counters
- nqps_limit(signed integer)
- limitation for the number of queue pairs
- {tx,rx}_ndescs(unsigned integer)
- the number of discriptors in txqueue or rxqueue
 1.18 09-Jan-2020  yamaguchi ixl(4) supports in-chip statistic counters per VSI
 1.17 09-Jan-2020  yamaguchi ixl(4) supports in-chip statistic counters per port
 1.16 08-Jan-2020  yamaguchi branches: 1.16.2;
Not stop kpreempt if unnecessary, ixl(4)
 1.15 26-Dec-2019  yamaguchi Fix lack of of sysctl_teardown() in ixl(4)
 1.14 26-Dec-2019  yamaguchi ixl(4) supports IFCAP_CSUM_*_Rx

OKed by msaitoh@n.o.
 1.13 26-Dec-2019  yamaguchi Improve DDPRINTF for ixl(4)
 1.12 20-Dec-2019  yamaguchi ixl(4) supports ETHERCAP_VLAN_HWFILTER
the feature is disable by default.

reviewed by msaitoh and knakahara
 1.11 20-Dec-2019  yamaguchi ixl(4) supports ETHERCAP_VLAN_HWTAGGING
It is enabled by defualt

The features is realized by the following operations:
- internal switch
- use "0b00: Show VLAN, DEI and UP in descriptor" mode
- TX
- set VLAN tag and IL2TAG1 flag to each descriptor
- RX
- use 32byte descriptor to use SHOWIV and L2SEL flag
included in RX queue configuration
- VLAN tags are not stored in descriptor without these config.
- get VLAN tags from L2TAG1 field included in RX descriptor
and set them to mbuf

reviewed by msaitoh and knakahara
 1.10 20-Dec-2019  yamaguchi enable other interrupt even if ixl(4) is down
 1.9 20-Dec-2019  yamaguchi Do IXL_AQ_OP_SET_VSI_PROMISC in ixl_ifflags_cb() for
applying IFF_PROMISC
 1.8 20-Dec-2019  yamaguchi Fix ixl(4) to set ENETRESET when IFF_ALLMULTI is changed
 1.7 20-Dec-2019  yamaguchi Fix ixl_{add|remove}_macvlan() to return errno
instead of command status
 1.6 20-Dec-2019  yamaguchi Fix softint leak in ixl(4) when detaching
 1.5 20-Dec-2019  yamaguchi Use name of variable instead of that of data structure
 1.4 11-Dec-2019  yamaguchi Fix to detect link state down

Link status event that is used to update link status sometimes
is not notified when link down. So, use Get Link Status response
that has the same information with the event.
The handling of the event is needed to detect link state
up because the response sometimes does not notify link up.
 1.3 11-Dec-2019  yamaguchi Fix build error related to ixl(4) on i386
 1.2 11-Dec-2019  yamaguchi Not use _LP64 but sizeof(bus_addr_t) for getting size of address
It makes ixl(4) be able to work on ILP32

pointed out by thorpej@. thanks.
 1.1 10-Dec-2019  yamaguchi Ported driver for Intel Ethernet 700 series

reviewed by msaitoh and knakahara
 1.16.2.2 29-Feb-2020  ad Sync with head.
 1.16.2.1 17-Jan-2020  ad Sync with head.
 1.65.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.65.2.1 19-Mar-2020  martin file if_ixl.c was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.75.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.76.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.88.4.2 18-Oct-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #417):

sys/dev/pci/if_ixl.c: revision 1.94
sys/dev/pci/if_ixl.c: revision 1.95

ixl(4): added ETHERCAP_VLAN_MTU support
PR kern/57652

ixl(4): limit receive frame size upto 9600 even if ETHERCAP_VLAN_MTU is enabled
 1.88.4.1 14-Oct-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #409):

sys/dev/pci/if_ixl.c: revision 1.90
sys/dev/pci/if_ixl.c: revision 1.91
sys/dev/pci/if_ixl.c: revision 1.92
sys/dev/pci/if_ixl.c: revision 1.93
sys/arch/evbarm/conf/GENERIC64: revision 1.214

ixl(4): skip getting link status if the last command is running

ixl(4): use cv_broadcast to wakeup ioctl and workqueue context.
Commands may be issued at the same time from the both context.

ixl(4): update link status in workqueue

ixl(4): Print device info on attach
Without PCIVERBOSE option:
ixl0 at pci1 dev 0 function 0: vendor 8086 product 1572 (rev. 0x01)
With PCIVERBOSE option:
ixl0 at pci1 dev 0 function 0: Intel XL710 SFP+ Ethernet (SFI) (rev. 0x01)
OK yamaguchi@

aarch64/GENERIC64: Add ixl(4)
Works just fine for little-endian on LX2K with UEFI firmware.
Not tested for big-endian yet; attach fails on ROCKPro64 due to
host controller problem.
OK yamaguchi@
 1.99.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 17-Jun-2022  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.1 10-Dec-2019  yamaguchi branches: 1.1.6;
Ported driver for Intel Ethernet 700 series

reviewed by msaitoh and knakahara
 1.1.6.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.6.1 10-Dec-2019  martin file if_ixlreg.h was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.8 16-Mar-2022  yamaguchi ixl: Added support for Intel ethernet X710-T*L
 1.7 08-Sep-2020  yamaguchi Added iavf(4) that is based on OpenBSD's iavf(4) implementation

reviewed by msaitoh@n.o and knakahara@n.o
 1.6 12-Feb-2020  yamaguchi branches: 1.6.4;
Use Set RSS key command and Set LUT command to enable RSS on X722
 1.5 31-Jan-2020  yamaguchi Add media and flow changes support for ixl(4)
 1.4 17-Jan-2020  yamaguchi Print nvm version of ixl(4) when attaching

reviewed by msaitoh
 1.3 26-Dec-2019  yamaguchi branches: 1.3.2;
ixl(4) supports IFCAP_CSUM_*_Rx

OKed by msaitoh@n.o.
 1.2 20-Dec-2019  yamaguchi ixl(4) supports ETHERCAP_VLAN_HWTAGGING
It is enabled by defualt

The features is realized by the following operations:
- internal switch
- use "0b00: Show VLAN, DEI and UP in descriptor" mode
- TX
- set VLAN tag and IL2TAG1 flag to each descriptor
- RX
- use 32byte descriptor to use SHOWIV and L2SEL flag
included in RX queue configuration
- VLAN tags are not stored in descriptor without these config.
- get VLAN tags from L2TAG1 field included in RX descriptor
and set them to mbuf

reviewed by msaitoh and knakahara
 1.1 10-Dec-2019  yamaguchi Ported driver for Intel Ethernet 700 series

reviewed by msaitoh and knakahara
 1.3.2.2 29-Feb-2020  ad Sync with head.
 1.3.2.1 17-Jan-2020  ad Sync with head.
 1.6.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.4.1 12-Feb-2020  martin file if_ixlvar.h was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.57 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.56 20-Dec-2023  thorpej branches: 1.56.2;
Remove unnecessary <sys/malloc.h>.
 1.55 02-Sep-2022  thorpej Remove unnecessary inclusion of <net/netisr.h>.
 1.54 21-Aug-2022  thorpej jme_ifstart(): Replace "IFQ_DEQUEUE() -> IF_PREPEND() on failure" with
"IFQ_POLL() -> IFQ_DEQUEUE() on success (and fatal-to-packet errors)".
 1.53 21-Aug-2022  thorpej Don't allow jme_encap() to modify the head-of-mbuf-chain pointer. Instead,
act on fatal packet errors in jme_ifstart().
 1.52 21-Aug-2022  thorpej jme_encap(): Fix up some botched formatting, and don't use (*m_head)
all over the place (just assign m = *m_head earlier). NFCI.
 1.51 16-Mar-2022  andvar s/watchog/watchdog in comment and log message, one wording fix in comment.
 1.50 08-May-2021  thorpej Use pci_compatible_match().
 1.49 08-Feb-2020  maxv branches: 1.49.10;
localify
 1.48 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.47 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.46 23-Sep-2019  maxv branches: 1.46.2;
A * is missing here. This could cause a use-after-free.

Found by the lgtm bot.
 1.45 07-Aug-2019  msaitoh Avoid undefined behavior in jme_mii_write(). Found by kUBSan.
 1.44 09-Jul-2019  msaitoh branches: 1.44.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.43 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.42 28-May-2019  msaitoh Fix typos. From OpenBSD r1.52.
 1.41 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.40 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.39 22-Apr-2019  msaitoh Remove extra SIOCSIFMEDIA check.
 1.38 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.37 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.36 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.35 26-Jun-2018  msaitoh branches: 1.35.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.34 22-Jun-2018  msaitoh It's not required to include net/bpfdesc.h. Remove it.
 1.33 01-Jun-2018  maxv Rename

M_CSUM_DATA_IPv6_HL -> M_CSUM_DATA_IPv6_IPHL
M_CSUM_DATA_IPv6_HL_SET -> M_CSUM_DATA_IPv6_SET

Reduces the diff against IPv4. Also, clarify the definitions.
 1.32 26-Sep-2017  knakahara branches: 1.32.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.31 15-Dec-2016  ozaki-r branches: 1.31.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.30 10-Jun-2016  ozaki-r branches: 1.30.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.29 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.28 12-Sep-2015  christos missing splx() found by brainy
 1.27 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.26 10-Aug-2014  tls branches: 1.26.4;
Merge tls-earlyentropy branch into HEAD.
 1.25 29-Mar-2014  christos branches: 1.25.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.24 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.23 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.22 30-Mar-2013  christos branches: 1.22.4;
remove trailing whitespace
 1.21 22-Jul-2012  matt branches: 1.21.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.20 02-Jun-2012  dsl Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.19 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.18 19-Nov-2011  tls branches: 1.18.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.17 30-Mar-2011  bouyer branches: 1.17.4;
Some bus_dma(9)-related and memory allocation fixes:
- always bus_dmamap_unload() before recycling a receive descriptor
- make sure to not sleep from interrupt context: call bus_dmamap_load with
M_NOWAIT, and create dma maps BUS_DMA_ALLOCNOW.
- if a receive descriptor has a NULL mbuf try to allocate a new one, don't
try to receive it.
 1.16 09-Jan-2011  kochi branches: 1.16.2;
Try reading MAC addr from register if it fails to read from EEPROM.
Copied from FreeBSD driver.

Without this my JMC261 doesn't get MAC address properly.

OK'ed by bouyer@
 1.15 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.14 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.13 19-Jan-2010  pooka branches: 1.13.2; 1.13.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.12 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.11 27-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only.
 1.10 26-Jun-2009  dyoung A lot of good it does, but let this build with 'no options INET'.
 1.9 18-Apr-2009  tsutsui branches: 1.9.2;
Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.8 18-Mar-2009  cegger bcopy -> memcpy
 1.7 18-Mar-2009  cegger bzero -> memset
 1.6 31-Jan-2009  bouyer branches: 1.6.2;
Under some circunstance, the JMC250A2 (and maybe others) can enter a state
where INTA is asserted while no enabled interrupts are pending, which
cause a continous strean if interrupts with no way to clear it.
Clearing/resetting the enabled interrupt mask in the interrupt handler seems
to workaround this issue (this is what the FreeBSD driver does).
While there properly return 0 if the interrupt was not for us, and explicitely
disable JME_TMCSR in addition to TIMER1 and TIMER2.
 1.5 16-Jan-2009  bouyer branches: 1.5.2;
According to the latest datasheet I have (1.09), the transmitter and ckecksum
offload clocks needs to be programmed according to the negociated speed;
make it so. This makes the sample JME260 I have work.
 1.4 16-Oct-2008  abs branches: 1.4.2; 1.4.4; 1.4.6;
Fix compilation if !INET6
 1.3 13-Oct-2008  bouyer Add support for jumbo frames.
Some performances tweaks (including better defaults for interrupt mitigation)
 1.2 12-Oct-2008  bouyer Fix reading MAC address from eeprom: don't forget to read the last
descriptor.
While there, white space fixes.
 1.1 11-Oct-2008  bouyer jme(4), a driver for JMicron Technologies JME250 Gigabit Ethernet and
JME260 Fast Ethernet PCI Express controllers.
Written with a lot of cut-n-paste from the FreeBSD jme(4) driver.
No support for jumbo ethernet frames yet (but should come soon).
Thanks to JMicron Technologies for providing me sample boards and
documentation for this work.
 1.4.6.4 05-Apr-2011  riz Pull up following revision(s) (requested by bouyer in ticket #1588):
sys/dev/pci/if_jme.c: revision 1.17
Some bus_dma(9)-related and memory allocation fixes:
- always bus_dmamap_unload() before recycling a receive descriptor
- make sure to not sleep from interrupt context: call bus_dmamap_load with
M_NOWAIT, and create dma maps BUS_DMA_ALLOCNOW.
- if a receive descriptor has a NULL mbuf try to allocate a new one, don't
try to receive it.
 1.4.6.3 16-Jan-2011  bouyer Pull up following revision(s) (requested by kochi in ticket #1525):
sys/dev/pci/if_jme.c: revision 1.16
Try reading MAC addr from register if it fails to read from EEPROM.
Copied from FreeBSD driver.
Without this my JMC261 doesn't get MAC address properly.
OK'ed by bouyer@
 1.4.6.2 02-Feb-2009  snj Pull up following revision(s) (requested by bouyer in ticket #388):
sys/dev/pci/if_jme.c: revision 1.6
Under some circunstance, the JMC250A2 (and maybe others) can enter a state
where INTA is asserted while no enabled interrupts are pending, which
cause a continous strean if interrupts with no way to clear it.
Clearing/resetting the enabled interrupt mask in the interrupt handler seems
to workaround this issue (this is what the FreeBSD driver does).
While there properly return 0 if the interrupt was not for us, and explicitely
disable JME_TMCSR in addition to TIMER1 and TIMER2.
 1.4.6.1 17-Jan-2009  snj Pull up following revision(s) (requested by bouyer in ticket #278):
sys/dev/pci/if_jme.c: revision 1.5
sys/dev/pci/if_jmereg.h: revision 1.3
According to the latest datasheet I have (1.09), the transmitter and
ckecksum offload clocks needs to be programmed according to the negociated
speed; make it so. This makes the sample JME260 I have work.
 1.4.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.4.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.4.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.2.2 19-Oct-2008  haad Sync with HEAD.
 1.4.2.1 16-Oct-2008  haad file if_jme.c was added on branch haad-dm on 2008-10-19 22:16:39 +0000
 1.5.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.5.2.1 16-Jan-2009  mjf file if_jme.c was added on branch mjf-devfs2 on 2009-01-17 13:29:00 +0000
 1.6.2.2 23-Jul-2009  jym Sync with HEAD.
 1.6.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.2.5 11-Aug-2010  yamt sync with head.
 1.9.2.4 11-Mar-2010  yamt sync with head
 1.9.2.3 18-Jul-2009  yamt sync with head.
 1.9.2.2 04-May-2009  yamt sync with head.
 1.9.2.1 18-Apr-2009  yamt file if_jme.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:57 +0000
 1.13.4.3 21-Apr-2011  rmind sync with head
 1.13.4.2 05-Mar-2011  rmind sync with head
 1.13.4.1 30-May-2010  rmind sync with head
 1.13.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.4.2 30-Oct-2012  yamt sync with head
 1.17.4.1 17-Apr-2012  yamt sync with head
 1.18.2.1 18-Feb-2012  mrg merge to -current.
 1.21.2.3 03-Dec-2017  jdolecek update from HEAD
 1.21.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 23-Jun-2013  tls resync from head
 1.22.4.1 18-May-2014  rmind sync with head
 1.25.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.26.4.5 05-Feb-2017  skrll Sync with HEAD
 1.26.4.4 09-Jul-2016  skrll Sync with HEAD
 1.26.4.3 19-Mar-2016  skrll Sync with HEAD
 1.26.4.2 22-Sep-2015  skrll Sync with HEAD
 1.26.4.1 06-Jun-2015  skrll Sync with HEAD
 1.30.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.31.8.3 10-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1430):

sys/dev/pci/if_jme.c: revision 1.46

A * is missing here. This could cause a use-after-free.
Found by the lgtm bot.
 1.31.8.2 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.31.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.32.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.32.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.32.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.32.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.35.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.35.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.2.1 10-Jun-2019  christos Sync with HEAD
 1.44.2.2 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #672):

sys/dev/ic/tulip.c: revision 1.198
sys/dev/pci/if_jme.c: revision 1.45
sys/dev/pci/agp.c: revision 1.86
sys/dev/pci/if_lii.c: revision 1.27
sys/dev/acpi/thinkpad_acpi.c: revision 1.47
sys/dev/scsipi/scsipi_base.c: revision 1.183
sys/dev/ic/aic6915reg.h: revision 1.6

Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.

Use unsigned when initialize the transmit completion ring to avoid undefined
behavior. Found by kUBSan.

Avoid undefined behavior when setting multicast address. found by kUBSan.

Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.

Avoid undefined behavior in jme_mii_write(). Found by kUBSan.

Use unsigned to avoid undefined behavior in lii_setmulti().

Use unsigned to avoid undefined behavior in scsipi_{get,put}_tag().

Found by kUBSan.
 1.44.2.1 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #376):

sys/dev/pci/if_jme.c: revision 1.46

A * is missing here. This could cause a use-after-free.
Found by the lgtm bot.
 1.46.2.1 29-Feb-2020  ad Sync with head.
 1.49.10.1 13-May-2021  thorpej Sync with HEAD.
 1.56.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.7 05-Dec-2021  msaitoh as/aggresive/aggressive/ in comment.
 1.6 26-Aug-2021  andvar Add missing RCSID in header files and one __KERNEL_RCSID().
 1.5 14-Nov-2019  msaitoh Revert previous. Sorry.
 1.4 14-Nov-2019  msaitoh Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.
 1.3 16-Jan-2009  bouyer branches: 1.3.2; 1.3.6;
According to the latest datasheet I have (1.09), the transmitter and ckecksum
offload clocks needs to be programmed according to the negociated speed;
make it so. This makes the sample JME260 I have work.
 1.2 13-Oct-2008  bouyer branches: 1.2.2; 1.2.4; 1.2.6;
Add support for jumbo frames.
Some performances tweaks (including better defaults for interrupt mitigation)
 1.1 11-Oct-2008  bouyer jme(4), a driver for JMicron Technologies JME250 Gigabit Ethernet and
JME260 Fast Ethernet PCI Express controllers.
Written with a lot of cut-n-paste from the FreeBSD jme(4) driver.
No support for jumbo ethernet frames yet (but should come soon).
Thanks to JMicron Technologies for providing me sample boards and
documentation for this work.
 1.2.6.1 17-Jan-2009  snj Pull up following revision(s) (requested by bouyer in ticket #278):
sys/dev/pci/if_jme.c: revision 1.5
sys/dev/pci/if_jmereg.h: revision 1.3
According to the latest datasheet I have (1.09), the transmitter and
ckecksum offload clocks needs to be programmed according to the negociated
speed; make it so. This makes the sample JME260 I have work.
 1.2.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.2.2.2 19-Oct-2008  haad Sync with HEAD.
 1.2.2.1 13-Oct-2008  haad file if_jmereg.h was added on branch haad-dm on 2008-10-19 22:16:39 +0000
 1.3.6.2 04-May-2009  yamt sync with head.
 1.3.6.1 16-Jan-2009  yamt file if_jmereg.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:57 +0000
 1.3.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.1 16-Jan-2009  mjf file if_jmereg.h was added on branch mjf-devfs2 on 2009-01-17 13:29:00 +0000
 1.59 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.58 31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.57 08-May-2021  thorpej Use pci_compatible_match().
 1.56 20-Sep-2020  nisimura branches: 1.56.6;

- rectify nonsense and bugs around statistics counter managment.
- scoop up counter values in one second interval comsolidating with phy_tick.
- reformat register definitions for ease to see.
 1.55 20-Sep-2020  nisimura guard statistics gathering callout with #ifdef
 1.54 20-Sep-2020  nisimura be more cautious about error exit path. nuke unused variables
 1.53 01-Apr-2020  nisimura insert missing ETHER_UNLOCK()
 1.52 01-Apr-2020  nisimura switch to use ETHER_F_ALLMULTI flag
 1.51 24-Mar-2020  nisimura nuke <sys/queue.h> and reorder #include
 1.50 02-Mar-2020  nisimura minor knits in mcast handling.
 1.49 17-Feb-2020  nisimura comment mods and code tiddy ups
 1.48 04-Feb-2020  skrll Adopt <net/if_stats.h>
 1.47 06-Jan-2020  nisimura branches: 1.47.2;
correct bogus comparison. pointed by msaitoh@
 1.46 14-Dec-2019  nisimura use FC enable bit for 8842 host port
 1.45 12-Dec-2019  nisimura use additional MAC addresses to accept mcast
 1.44 03-Dec-2019  nisimura streamline receive filter logic, work-in-progress.
 1.43 29-Nov-2019  nisimura switch to deferred if_start framework.
 1.42 26-Nov-2019  nisimura - use mii(4) layer to control KSZ8841 builtin PHY.
- handle PAUSE flow control properly according to ifconfig(8) mediaopt
selection.
- some style knits; use aprint(9) and modernise callout(9).
 1.41 07-Nov-2019  nisimura comment touchup
 1.40 07-Nov-2019  nisimura clarify 8842 MAC behaves 100FDX only has no alternative media selection
possible.
 1.39 06-Nov-2019  nisimura major rework to fix link control breakage
 1.38 29-May-2019  msaitoh branches: 1.38.2;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.37 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.36 23-May-2019  msaitoh -No functional change:
- Simplify struct ethercom's pointer near ETHER_FIRST_MULTI().
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.35 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.34 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.33 18-Jul-2018  sevan Be consistent among ethernet drivers on the convention for printing ethernet
addresses.

NFC
 1.32 26-Jun-2018  msaitoh branches: 1.32.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.31 15-Dec-2016  ozaki-r branches: 1.31.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.30 10-Jun-2016  ozaki-r branches: 1.30.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.29 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.28 16-Jun-2014  msaitoh branches: 1.28.4;
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.27 29-Mar-2014  christos branches: 1.27.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.26 25-Mar-2014  christos kill sprintf
 1.25 08-Nov-2013  nisimura move EVCNT only variable inside #ifdef
 1.24 30-Mar-2013  christos branches: 1.24.4;
remove trailing whitespace
 1.23 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.22 05-Apr-2010  joerg branches: 1.22.8; 1.22.14; 1.22.18;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.21 19-Jan-2010  pooka branches: 1.21.2; 1.21.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.20 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.19 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.18 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.17 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.16 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.15 26-May-2008  nisimura branches: 1.15.6; 1.15.12;
- assign 2 clause TNF license to the files cited as my ownership.
- abandon and remove my copyright notice from the three files were
copied in order to adapt HW I don't have; pvr.c, pm.c and stic.c
 1.14 10-Apr-2008  cegger branches: 1.14.2; 1.14.4; 1.14.6;
use aprint_*_dev and device_xname
 1.13 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.12 07-Feb-2008  dyoung branches: 1.12.2; 1.12.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.11 16-Nov-2007  nisimura reduce Tx/Rx maximum number of words (as PDF says) in one DMA
transaction to 8. value 32 triggers occational watchdog() Tx
timeout when higher system load. This symptom is observed in
ipforwarding across two PCI devices case so far, and it remains
unidentified what really happens for Tx DMA activity. 16 seems
ok, 8 is conservative and heuristic value. may need more adjustment
work in other parts.
 1.10 19-Oct-2007  ad branches: 1.10.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.9 19-Oct-2007  nisimura - fix an error when retriving two 16bit halves of 29bit stat value.
- port3 counters are found exist and in fact working as 0x102/0x105.
 1.8 19-Oct-2007  nisimura - add multicast Rx hash table feature.
- distinguish 8842 from 8841. 8842 now keeps media selection "auto"
and indicates "up 100baseTX-FDX flow" when either of two ports has
a valid link. There is no provision to see and control the two this
moment and their media selections remain in "auto" all the time. This
arrangement is considered acceptable since 8842's external ports are
connected with the internal EMAC via managed 3 port Ethernet switch.
- 8841 behaves a plain stanadrd 10/100 EMAC with standard media
selection feature.
- gather MIB statistics counter values with evcnt(8) framework.
- increase Tx/Rx DMA DMA burst transfer size from 16 to 32.
 1.7 14-Oct-2007  nisimura branches: 1.7.2;
fix typos about a pair of multicast hash table registers.
 1.6 14-Oct-2007  nisimura add multicast filter support; either to use HW hash table lookup
filter or to accept any mcast frames.
 1.5 07-Oct-2007  nisimura A typo fix in one of comments and some adjustments of register field names.
No functionality change intented.

IHAE "IP Header Alignment Enable" feature of RXC register;
- careful cross referencing at KSZ8692P/8841P/8842P PDFs indicates IHEA
bit works as follows; When the feature is turned on, Rx DMA engine
will populate Rx frame data in the Rx memory with +2 or +3 byte swifted
to make its IP head field 32bit aligned. The shift amount is recorded
inside RDES0 to tell 0, 2 or 3. The automatic alignment is done only
when IHAE is enabled _and_ the Rx frame was IP frame. In other cases,
RDES0 swift amount field keeps 0.
- KSZ8841P document mentions the IHAE bit but its reference link is broken
to tell the new RDES0 field. KSZ8842P lacks both. The bit usage of
RDES0 23:20 seems different from KSZ8692P, which brings me a vague
suspiction of documentation error.
 1.4 09-Jul-2007  ad branches: 1.4.6; 1.4.8; 1.4.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.3 04-Mar-2007  christos branches: 1.3.2; 1.3.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 29-Sep-2006  tsutsui branches: 1.2.4; 1.2.6;
- trim CRC off rather than setting M_HASFCS
- use appropriate types instead of `unsigned'
 1.1 30-Jun-2006  nisimura branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Add kse(4) driver for Micrel KSZ8842/8841 Ethernet controller.
 1.1.12.1 22-Oct-2006  yamt sync with head
 1.1.10.2 09-Sep-2006  rpaulo sync with head
 1.1.10.1 30-Jun-2006  rpaulo file if_kse.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:17 +0000
 1.1.8.1 18-Nov-2006  ad Sync with head.
 1.1.6.2 11-Aug-2006  yamt sync with head
 1.1.6.1 30-Jun-2006  yamt file if_kse.c was added on branch yamt-pdpolicy on 2006-08-11 15:44:25 +0000
 1.1.2.2 13-Jul-2006  gdamore Merge from HEAD.
 1.1.2.1 30-Jun-2006  gdamore file if_kse.c was added on branch gdamore-uart on 2006-07-13 17:49:27 +0000
 1.2.6.1 12-Mar-2007  rmind Sync with HEAD.
 1.2.4.7 17-Mar-2008  yamt sync with head.
 1.2.4.6 11-Feb-2008  yamt sync with head.
 1.2.4.5 07-Dec-2007  yamt sync with head
 1.2.4.4 27-Oct-2007  yamt sync with head.
 1.2.4.3 03-Sep-2007  yamt sync with head.
 1.2.4.2 30-Dec-2006  yamt sync with head.
 1.2.4.1 29-Sep-2006  yamt file if_kse.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:44 +0000
 1.3.4.1 11-Jul-2007  mjf Sync with head.
 1.3.2.3 23-Oct-2007  ad Sync with head.
 1.3.2.2 09-Oct-2007  ad Sync with head.
 1.3.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.4.10.2 18-Oct-2007  yamt sync with head.
 1.4.10.1 14-Oct-2007  yamt sync with head.
 1.4.8.3 23-Mar-2008  matt sync with HEAD
 1.4.8.2 09-Jan-2008  matt sync with HEAD
 1.4.8.1 06-Nov-2007  matt sync with HEAD
 1.4.6.3 21-Nov-2007  joerg Sync with HEAD.
 1.4.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.4.6.1 07-Oct-2007  joerg Sync with HEAD.
 1.7.2.2 18-Nov-2007  bouyer Sync with HEAD
 1.7.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.10.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.12.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.2.1 24-Mar-2008  keiichi sync with head.
 1.14.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.4.4 11-Aug-2010  yamt sync with head.
 1.14.4.3 11-Mar-2010  yamt sync with head
 1.14.4.2 16-May-2009  yamt sync with head
 1.14.4.1 04-May-2009  yamt sync with head.
 1.14.2.1 04-Jun-2008  yamt sync with head
 1.15.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.21.4.1 30-May-2010  rmind sync with head
 1.21.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.22.18.4 03-Dec-2017  jdolecek update from HEAD
 1.22.18.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.18.2 23-Jun-2013  tls resync from head
 1.22.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.22.14.1 09-Nov-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #1189):
sys/dev/pci/if_wm.c: revision 1.270
sys/dev/mii/inphy.c: revision 1.53
sys/dev/mii/glxtphy.c: revision 1.24
sys/dev/mii/tlphy.c: revision 1.62
sys/dev/mii/iophy.c: revision 1.37
sys/dev/mii/brgphy.c: revision 1.70
sys/dev/mii/ihphy.c: revision 1.8
sys/dev/mii/bmtphy.c: revision 1.31
sys/dev/mii/urlphy.c: revision 1.30
sys/dev/mii/makphy.c: revision 1.40
sys/dev/mii/qsphy.c: revision 1.48
sys/dev/mii/igphy.c: revision 1.23
sys/dev/mii/nsphy.c: revision 1.58
sys/dev/mii/mvphy.c: revision 1.10
sys/dev/pci/if_txp.c: revision 1.41
sys/dev/mii/nsphy.c: revision 1.59
sys/dev/mii/rlphy.c: revision 1.28
sys/dev/mii/icsphy.c: revision 1.49
sys/dev/mii/rlphy.c: revision 1.29
sys/dev/mii/lxtphy.c: revision 1.49
sys/dev/mii/ciphyreg.h: revision 1.5
sys/dev/mii/nsphyter.c: revision 1.38
sys/dev/mii/sqphy.c: revision 1.50
sys/dev/mii/gentbi.c: revision 1.26
sys/dev/mii/gentbi.c: revision 1.27
sys/dev/mii/tqphy.c: revision 1.39
sys/dev/mii/ikphy.c: revision 1.10
sys/dev/mii/dmphy.c: revision 1.35
sys/dev/mii/amhphy.c: revision 1.20
sys/dev/mii/acphy.c: revision 1.24
sys/dev/mii/ciphy.c: revision 1.25
sys/dev/mii/brgphyreg.h: revision 1.8
sys/dev/mii/ukphy_subr.c: revision 1.12
sys/dev/ic/rtl80x9.c: revision 1.16
sys/arch/mips/adm5120/dev/if_admsw.c: revision 1.12
sys/dev/pci/if_kse.c: revision 1.28
sys/dev/mii/ukphy_subr.c: revision 1.13
sys/dev/mii/mii.h: revision 1.18
sys/dev/mii/gphyter.c: revision 1.29
No functional change:
- Fix typo.
- Remove trailing white spaces.
- Capitalize comments.
- Tabify.
- KNF.
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.22.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.22.8.1 30-Oct-2012  yamt sync with head
 1.24.4.1 18-May-2014  rmind sync with head
 1.27.2.1 10-Aug-2014  tls Rebase.
 1.28.4.3 05-Feb-2017  skrll Sync with HEAD
 1.28.4.2 09-Jul-2016  skrll Sync with HEAD
 1.28.4.1 19-Mar-2016  skrll Sync with HEAD
 1.30.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.31.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.31.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.32.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.32.2.1 10-Jun-2019  christos Sync with HEAD
 1.38.2.1 10-Nov-2019  martin Pull up following revision(s) (requested by nisimura in ticket #406):

sys/dev/pci/if_kse.c: revision 1.40
sys/dev/pci/if_kse.c: revision 1.41
sys/dev/pci/if_kse.c: revision 1.39

comment touchup

-

clarify 8842 MAC behaves 100FDX only has no alternative media selection
possible.

-

major rework to fix link control breakage
 1.47.2.1 29-Feb-2020  ad Sync with head.
 1.56.6.1 13-May-2021  thorpej Sync with HEAD.
 1.55 25-Jan-2020  thorpej Retire the le@pci attachment. It has been superseded (and matched at a
higher priority) by the pcn(4) driver since NetBSD 1.6.
 1.54 25-Apr-2019  msaitoh branches: 1.54.4;
No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.53 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.52 29-Mar-2014  christos branches: 1.52.28; 1.52.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.51 26-Jul-2011  dyoung branches: 1.51.2; 1.51.12; 1.51.16;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.50 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.49 28-Apr-2008  martin branches: 1.49.22;
Remove clause 3 and 4 from TNF licenses
 1.48 04-Apr-2008  tsutsui branches: 1.48.2; 1.48.4;
Split device_t/softc for le(4) and variants and misc cosmetic changes.
 1.47 19-Oct-2007  ad branches: 1.47.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.46 04-Mar-2007  christos branches: 1.46.2; 1.46.14; 1.46.16; 1.46.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.45 16-Nov-2006  christos branches: 1.45.4;
__unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 11-Dec-2005  christos branches: 1.43.20; 1.43.22;
merge ktrace-lwp.
 1.42 27-Feb-2005  perry branches: 1.42.4;
nuke trailing whitespace
 1.41 21-Aug-2004  thorpej branches: 1.41.4; 1.41.6;
Use ANSI function decls and make use of static.
 1.40 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.39 02-Oct-2002  thorpej branches: 1.39.6;
Add trailing ; to CFATTACH_DECL.
 1.38 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.37 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.36 21-Nov-2001  wiz Explicitly write explicitly without a second e.
 1.35 13-Nov-2001  lukem add RCSID
 1.34 08-Jul-2001  thorpej branches: 1.34.2;
Remove unnecessary include files. From Onno van der Linden.
 1.33 18-Jun-2001  jdolecek Convert to use ether_ioctl() for SIOCSIFADDR and SIOCSIFFLAGS.
 1.32 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.31 30-May-2001  mrg use _KERNEL_OPT
 1.30 28-Dec-2000  sommerfeld branches: 1.30.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.29 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.28 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.27 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.26 02-Oct-1998  fvdl branches: 1.26.12;
Add missing field to le_softc structure, missed in previous commit. Name
it consistently with the other fields.
 1.25 01-Oct-1998  drochner support media selection / full duplex
 1.24 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.23 21-Jul-1998  drochner adapt to LANCE driver split; let PCNET/PCI use the 32-bit mode
 1.22 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.21 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.20 04-Feb-1998  thorpej Add dm_mapsize to bus_dmamap_t and rename BUS_DMAMEM_NOSYNC to
BUS_DMA_COHERENT.
 1.19 06-Jun-1997  thorpej Pull thorpej-bus-dma branch into mainline.
 1.18 13-Apr-1997  cgd branches: 1.18.2;
rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.17 13-Apr-1997  cgd use pci_map_register().
 1.16 17-Mar-1997  thorpej #include <net/if_media.h>
 1.15 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.14 05-Dec-1996  cgd branches: 1.14.4;
update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.13 25-Oct-1996  cgd update alpha_XXX_dmamap() invocations to match prototype.
 1.12 23-Oct-1996  cgd update drivers to use the new NetBSD/alpha DMA mapping hack, since
the old one is not workable with the new bus.h.
 1.11 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.10 13-Oct-1996  christos backout kprintf changes
 1.9 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 15-Jul-1996  cgd before #defining the vtophys() hack for the alpha, #undef vtophys since
it may be a macro.
 1.7 03-Jun-1996  cgd convert alpha vtophys() #defines to use __alpha_bus_XXX_dmamap(), to
get rid of the nasty (vtophys(va) | 0x40000000) expressions, and to make
the code more correct.
 1.6 14-May-1996  thorpej branches: 1.6.4;
Don't include <machine/intr.h> twice on the Alpha.
 1.5 13-May-1996  mycroft Use intr.h.
 1.4 12-May-1996  thorpej Squish a straggling inb(), and tweak so that this compiles on the Alpha.
 1.3 12-May-1996  thorpej Fix a think-o (my fault) that caused LANCE register offsets to be wrong.
While I'm here, convert driver to use <machine/bus.h> and the new PCI
I/O space interface (the new PCI interrupt interface was already in-use).
Also, correct a "corrected" printf.
 1.2 07-May-1996  christos - Add an XXX declaration to kvtop
- Add a missing argument to printf
 1.1 07-May-1996  thorpej Make the MI LANCE driver standalone, and use cfattach to resolve
naming conflicts between bus attachments on ports that can have
multiple instances of the LANCE.

Add a real PCI front-end for PCnet-PCI Ethernet cards.

Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
 1.6.4.1 03-Jun-1996  cgd pull up from trunk:
>convert alpha vtophys() #defines to use __alpha_bus_XXX_dmamap(), to
>get rid of the nasty (vtophys(va) | 0x40000000) expressions, and to make
>the code more correct.
 1.14.4.2 09-Mar-1997  is netinet/if_ether.h -> netinet/if_inarp.h
 1.14.4.1 21-Feb-1997  is Transform to the new world order.
 1.18.2.2 17-May-1997  thorpej Update for bus_dmamem_alloc() changes.
 1.18.2.1 13-May-1997  thorpej Convert to use bus dma.
 1.26.12.3 05-Jan-2001  bouyer Sync with HEAD
 1.26.12.2 22-Nov-2000  bouyer Sync with HEAD.
 1.26.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.30.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.30.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.30.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.30.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.30.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.34.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.34.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.39.6.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.39.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.39.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.39.6.2 25-Aug-2004  skrll Sync with HEAD.
 1.39.6.1 03-Aug-2004  skrll Sync with HEAD
 1.41.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.41.4.1 29-Apr-2005  kent sync with -current
 1.42.4.3 27-Oct-2007  yamt sync with head.
 1.42.4.2 03-Sep-2007  yamt sync with head.
 1.42.4.1 30-Dec-2006  yamt sync with head.
 1.43.22.2 10-Dec-2006  yamt sync with head.
 1.43.22.1 22-Oct-2006  yamt sync with head
 1.43.20.1 18-Nov-2006  ad Sync with head.
 1.45.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.46.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.46.16.1 06-Nov-2007  matt sync with HEAD
 1.46.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.2.1 23-Oct-2007  ad Sync with head.
 1.47.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.48.4.1 16-May-2008  yamt sync with head.
 1.48.2.1 18-May-2008  yamt sync with head.
 1.49.22.1 05-Mar-2011  rmind sync with head
 1.51.16.1 18-May-2014  rmind sync with head
 1.51.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.51.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.52.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.52.30.1 10-Jun-2019  christos Sync with HEAD
 1.52.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.54.4.1 25-Jan-2020  ad Sync with head.
 1.10 25-Jan-2020  thorpej Retire the le@pci attachment. It has been superseded (and matched at a
higher priority) by the pcn(4) driver since NetBSD 1.6.
 1.9 28-Apr-2008  martin branches: 1.9.88; 1.9.96;
Remove clause 3 and 4 from TNF licenses
 1.8 02-Oct-1998  fvdl branches: 1.8.144; 1.8.146; 1.8.148;
Add missing field to le_softc structure, missed in previous commit. Name
it consistently with the other fields.
 1.7 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.6 21-Jul-1998  drochner adapt to LANCE driver split; let PCNET/PCI use the 32-bit mode
 1.5 06-Jun-1997  thorpej Pull thorpej-bus-dma branch into mainline.
 1.4 15-Mar-1997  is branches: 1.4.2;
New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.3 21-Oct-1996  thorpej branches: 1.3.4;
New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.2 12-May-1996  thorpej Fix a think-o (my fault) that caused LANCE register offsets to be wrong.
While I'm here, convert driver to use <machine/bus.h> and the new PCI
I/O space interface (the new PCI interrupt interface was already in-use).
Also, correct a "corrected" printf.
 1.1 07-May-1996  thorpej Make the MI LANCE driver standalone, and use cfattach to resolve
naming conflicts between bus attachments on ports that can have
multiple instances of the LANCE.

Add a real PCI front-end for PCnet-PCI Ethernet cards.

Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_reset)()
to take a struct ifnet *, rather than a unit number.
 1.3.4.1 27-Feb-1997  is Removed #include <route.h> and #include <netisr.h>. They're not needed, and
the latter will go away soon.
 1.4.2.1 13-May-1997  thorpej Convert to use bus dma.
 1.8.148.1 16-May-2008  yamt sync with head.
 1.8.146.1 18-May-2008  yamt sync with head.
 1.8.144.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.96.1 25-Jan-2020  ad Sync with head.
 1.9.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.30 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.29 16-Sep-2022  andvar s/Paket/Packet/
 1.28 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.27 18-Sep-2019  msaitoh branches: 1.27.2;
Use unsigned to avoid undefined behavior in lii_setmulti().
 1.26 30-May-2019  msaitoh branches: 1.26.2;
Simplify MII structure initialization and reference. No functional change.
 1.25 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.24 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.23 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.22 22-Apr-2019  msaitoh On drivers which use MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.
 1.21 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.20 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.19 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.18 26-Jun-2018  msaitoh branches: 1.18.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.17 15-Dec-2016  ozaki-r branches: 1.17.8; 1.17.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.16 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.15 10-Jun-2016  ozaki-r branches: 1.15.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.14 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.13 29-Mar-2014  christos branches: 1.13.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.12 30-Mar-2013  christos branches: 1.12.4;
remove trailing whitespace
 1.11 22-Jul-2012  matt branches: 1.11.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.10 20-Apr-2011  christos branches: 1.10.4;
PR/41258: Elias Benali: Try to get the ethernet address from the BIOS before
failing.
 1.9 05-Apr-2010  joerg branches: 1.9.2;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.8 19-Jan-2010  pooka branches: 1.8.2; 1.8.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.7 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.6 26-Apr-2009  cegger fix error handling in lii_attach()
ok jmcneill@
 1.5 08-Jul-2008  sborrill branches: 1.5.2; 1.5.4; 1.5.8;
Fix multicast (multicast hash table were calculated incorrectly).
 1.4 29-Apr-2008  martin branches: 1.4.2; 1.4.4; 1.4.6; 1.4.8;
Convert to new 2 clause license
 1.3 06-Apr-2008  mjf branches: 1.3.2; 1.3.4; 1.3.6;
Prevent packet header from being placed outside the TXD buffer. This
should stop the "mismatched status and packet" error messages that have
been plaguing the EeePC.

Fix provided by Joel Sing, thanks!
 1.2 31-Mar-2008  mjf branches: 1.2.2;
Register pmf handler.
 1.1 29-Mar-2008  cube Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.

The linux driver was used as documentation.

Many thanks to all the people who helped or at least supported me while I
was fighting that bug that made the EeePC freeze. At the top of that list,
Matt J. Fleming (mjf@) and David Gwynne (from the OpenBSD fame).
 1.2.2.4 28-Sep-2008  mjf Sync with HEAD.
 1.2.2.3 02-Jun-2008  mjf Sync with HEAD.
 1.2.2.2 03-Apr-2008  mjf Sync with HEAD.
 1.2.2.1 31-Mar-2008  mjf file if_lii.c was added on branch mjf-devfs2 on 2008-04-03 12:42:50 +0000
 1.3.6.5 11-Aug-2010  yamt sync with head.
 1.3.6.4 11-Mar-2010  yamt sync with head
 1.3.6.3 16-Sep-2009  yamt sync with head
 1.3.6.2 04-May-2009  yamt sync with head.
 1.3.6.1 16-May-2008  yamt sync with head.
 1.3.4.3 20-Aug-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1164):
sys/dev/pci/if_lii.c: revision 1.5
Fix multicast (multicast hash table were calculated incorrectly).
 1.3.4.2 19-Apr-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1128):
sys/dev/pci/if_lii.c: revisions 1.1, 1.3 via patch
sys/arch/i386/conf/ALL: revision 1.161 via patch
share/man/man4/lii.4: revision 1.1 via patch
sys/dev/pci/files.pci: revision 1.303 via patch
sys/dev/DEVNAMES: revision 1.238 via patch
sys/arch/i386/conf/GENERIC: revision 1.885 via patch
distrib/sets/lists/man/mi: revisions 1.1062, 1.1063 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.43 via patch
share/man/man4/Makefile: revision 1.460 via patch
sys/arch/i386/conf/INSTALL: revision 1.323 via patch
sys/dev/pci/if_liireg.h: revision 1.1 via patch
Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.
 1.3.4.1 06-Apr-2008  bouyer file if_lii.c was added on branch netbsd-4 on 2008-04-19 15:57:56 +0000
 1.3.2.1 18-May-2008  yamt sync with head.
 1.4.8.1 19-Oct-2008  haad Sync with HEAD.
 1.4.6.1 18-Jul-2008  simonb Sync with head.
 1.4.4.3 04-Sep-2008  skrll Sync with netbsd-4.
 1.4.4.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.4.4.1 29-Apr-2008  skrll file if_lii.c was added on branch wrstuden-fixsa on 2008-06-03 20:47:24 +0000
 1.4.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.4.1 20-May-2011  bouyer Pull up following revision(s) (requested by dholland in ticket #1612):
sys/dev/pci/if_lii.c: revision 1.10
PR/41258: Elias Benali: Try to get the ethernet address from the BIOS before
failing.
 1.5.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.4.2 21-Apr-2011  rmind sync with head
 1.8.4.1 30-May-2010  rmind sync with head
 1.8.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.4.1 30-Oct-2012  yamt sync with head
 1.11.2.3 03-Dec-2017  jdolecek update from HEAD
 1.11.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.1 23-Jun-2013  tls resync from head
 1.12.4.1 18-May-2014  rmind sync with head
 1.13.6.3 05-Feb-2017  skrll Sync with HEAD
 1.13.6.2 09-Jul-2016  skrll Sync with HEAD
 1.13.6.1 19-Mar-2016  skrll Sync with HEAD
 1.15.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17.14.3 26-Jan-2019  pgoyette Sync with HEAD
 1.17.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.17.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.17.8.1 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.18.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.18.2.1 10-Jun-2019  christos Sync with HEAD
 1.26.2.1 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #672):

sys/dev/ic/tulip.c: revision 1.198
sys/dev/pci/if_jme.c: revision 1.45
sys/dev/pci/agp.c: revision 1.86
sys/dev/pci/if_lii.c: revision 1.27
sys/dev/acpi/thinkpad_acpi.c: revision 1.47
sys/dev/scsipi/scsipi_base.c: revision 1.183
sys/dev/ic/aic6915reg.h: revision 1.6

Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.

Use unsigned when initialize the transmit completion ring to avoid undefined
behavior. Found by kUBSan.

Avoid undefined behavior when setting multicast address. found by kUBSan.

Use unsigned to avoid undefined behavior in agpattach(). Found by kUBSan.

Avoid undefined behavior in jme_mii_write(). Found by kUBSan.

Use unsigned to avoid undefined behavior in lii_setmulti().

Use unsigned to avoid undefined behavior in scsipi_{get,put}_tag().

Found by kUBSan.
 1.27.2.1 29-Feb-2020  ad Sync with head.
 1.2 29-Apr-2008  martin branches: 1.2.4;
Convert to new 2 clause license
 1.1 29-Mar-2008  cube branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.

The linux driver was used as documentation.

Many thanks to all the people who helped or at least supported me while I
was fighting that bug that made the EeePC freeze. At the top of that list,
Matt J. Fleming (mjf@) and David Gwynne (from the OpenBSD fame).
 1.1.8.1 16-May-2008  yamt sync with head.
 1.1.6.2 19-Apr-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1128):
sys/dev/pci/if_lii.c: revisions 1.1, 1.3 via patch
sys/arch/i386/conf/ALL: revision 1.161 via patch
share/man/man4/lii.4: revision 1.1 via patch
sys/dev/pci/files.pci: revision 1.303 via patch
sys/dev/DEVNAMES: revision 1.238 via patch
sys/arch/i386/conf/GENERIC: revision 1.885 via patch
distrib/sets/lists/man/mi: revisions 1.1062, 1.1063 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.43 via patch
share/man/man4/Makefile: revision 1.460 via patch
sys/arch/i386/conf/INSTALL: revision 1.323 via patch
sys/dev/pci/if_liireg.h: revision 1.1 via patch
Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.
 1.1.6.1 29-Mar-2008  bouyer file if_liireg.h was added on branch netbsd-4 on 2008-04-19 15:57:56 +0000
 1.1.4.1 18-May-2008  yamt sync with head.
 1.1.2.3 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.2 03-Apr-2008  mjf Sync with HEAD.
 1.1.2.1 29-Mar-2008  mjf file if_liireg.h was added on branch mjf-devfs2 on 2008-04-03 12:42:50 +0000
 1.2.4.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.2.4.1 29-Apr-2008  skrll file if_liireg.h was added on branch wrstuden-fixsa on 2008-06-03 20:47:24 +0000
 1.69 12-Dec-2018  maxv Retire the LMC driver, and its associated lmcconfig tool. LMC has been
mentioned repeatedly as a non-MP-safe driver that is hard to maintain,
and no one is taking care of it.

LMC was removed from OpenBSD three years ago, and from FreeBSD a few
months ago.
 1.68 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.67 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.66 26-Jun-2018  msaitoh branches: 1.66.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.65 25-Jun-2018  msaitoh Move txintr_setup() stuff from lmc_interrupt() and do it in ifnet_start().
Now we can use bpf_mtap() in the TX path. Not tested.
 1.64 07-Feb-2018  mrg branches: 1.64.2;
avoid an indentation issue by adding "if (1)".
 1.63 24-Jan-2017  ozaki-r branches: 1.63.6;
Defer bpf_mtap in Rx interrupt context to softint

bpf_mtap of some drivers is still called in hardware interrupt context.
We want to run them in softint as well as bpf_mtap of most drivers
(see if_percpuq_softint and if_input).

To this end, bpf_mtap_softint mechanism is implemented; it defers
bpf_mtap processing to a dedicated softint for a target driver.
By using the machanism, we can move bpf_mtap processing to softint
without changing target drivers much while it adds some overhead
on CPU and memory. Once target drivers are changed to softint-based,
we should return to normal bpf_mtap.

Proposed on tech-kern and tech-net
 1.62 15-Dec-2016  ozaki-r branches: 1.62.2;
Annotate bpf_mtap still running in Rx hardware interrupt with "XXX not in softint"
 1.61 10-Jun-2016  ozaki-r branches: 1.61.2;
Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.
 1.60 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.59 28-Apr-2016  ozaki-r Constify rtentry of if_output

We no longer need to change rtentry below if_output.

The change makes it clear where rtentries are changed (or not)
and helps forthcoming locking (os psrefing) rtentries.
 1.58 20-Apr-2016  knakahara IFQ_ENQUEUE refactor (3/3) : eliminate pktattr argument from IFQ_ENQUEUE caller
 1.57 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.56 28-Nov-2014  ozaki-r branches: 1.56.2;
Don't call if_free_sadl in ifnet_detach

It'll be called in if_detach below.
 1.55 05-Jun-2014  rmind - Implement pktqueue interface for lockless IP input queue.
- Replace ipintrq and ip6intrq with the pktqueue mechanism.
- Eliminate kernel-lock from ipintr() and ip6intr().
- Some preparation work to push softnet_lock out of ipintr().

Discussed on tech-net.
 1.54 29-Mar-2014  christos branches: 1.54.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.53 30-Mar-2013  christos branches: 1.53.4;
remove trailing whitespace
 1.52 29-Oct-2012  chs fix device/softc split errors.
 1.51 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.50 13-Nov-2010  uebayasi branches: 1.50.8; 1.50.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.49 19-Jan-2010  pooka branches: 1.49.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.48 16-Sep-2009  dyoung Pass lmc(4) through 'unifdef -U__FreeBSD__ -U__bsdi__ -U__OpenBSD__
-U__linux__ -D__NetBSD__ -UNETGRAPH' to shorten this driver by
>2500 lines. objdump -D does not reveal any differences in the
compiled code.
 1.47 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.46 02-Feb-2009  tsutsui branches: 1.46.2;
Remove obsolete #if defined(LKM) block. PR kern/40513
 1.45 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.44 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.43 27-Jun-2008  gmcgarry branches: 1.43.2; 1.43.4;
Convert lmc(4) to mutexes, removing ({ }) gcc extension along the way.
 1.42 12-Jun-2008  cegger use device_lookup_private to get softc
 1.41 10-Apr-2008  cegger branches: 1.41.2; 1.41.4; 1.41.6; 1.41.8;
use aprint_*_dev and device_xname
 1.40 07-Feb-2008  dyoung branches: 1.40.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.39 10-Jan-2008  dyoung Straggler: change generic ifmedia_X names to lmc_ifmedia_X.
 1.38 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.37 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.36 19-Oct-2007  ad branches: 1.36.2; 1.36.4; 1.36.6; 1.36.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.35 09-Jul-2007  ad branches: 1.35.6; 1.35.8; 1.35.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.34 04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 17-Feb-2007  dyoung KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.

Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.

Constify:

1 Introduce const accessor for route->ro_dst, rtcache_getdst().

2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.

3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.

4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
 1.32 16-Nov-2006  christos branches: 1.32.4;
__unused removal on arguments; approved by core.
 1.31 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.30 30-Aug-2006  christos branches: 1.30.2; 1.30.4;
complete initializers.
 1.29 14-May-2006  elad integrate kauth.
 1.28 20-Apr-2006  christos New version from David Boggs.
 1.27 14-Apr-2006  christos Coverity CID 1122: Add KASSERT to clarify this NULL deref can't happen.
 1.26 10-Mar-2006  christos branches: 1.26.2;
PR/33049: OKANO Takayoshi: Fix the spelling of NetBSD RCS tags.
 1.25 13-Feb-2006  martin branches: 1.25.2; 1.25.4;
Protect parts inside #ifdef _LKM that are only supposed to be there
when building an LKM.
 1.24 11-Feb-2006  christos new version from David Boggs.
 1.23 06-Dec-2005  christos branches: 1.23.2; 1.23.4; 1.23.6;
New lmc driver from David Boggs
 1.22 30-May-2005  christos branches: 1.22.2;
- const poisoning
- avoid variable shadowing.
 1.21 27-Feb-2005  perry nuke trailing whitespace
 1.20 03-May-2003  wiz branches: 1.20.2; 1.20.10; 1.20.12;
DMA, not dma nor Dma.
 1.19 20-Jan-2003  simonb Remove variable that is only assigned too but not referenced.
 1.18 04-Jan-2002  martin Move net/if_sppp.h to net/if_spppvar.h, create a new net/if_sppp.h
containing the userland visible thinks (i.e. ioctl definitions).

Remove all (both) old ioctls, as they had a brain dead API and made keeping
binary compatibility more or less impossible.

Replace by several new ioctls. While there, remove any arbitrary limits
(resulting from the old, broken ioctls) and allow any length of names
and passwords.
 1.17 13-Nov-2001  lukem add RCSID
 1.16 27-Aug-2001  eeh Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.15 19-Jul-2001  itojun it seems that pp_{up,down} code does not really help, since (1) sppp_ioctl
calls lcp.{Up,Down} by itself, and (2) as lmc driver uses interrupt to
get the card initialization callback lcp calls from sppp_ioctl
does not really work. for chdlc pp_{up,down} are not really necessary so
don't bother (#if 0'ed).
 1.14 19-Jul-2001  itojun do not call pp_{up,down} on cisco HDLC mode, it seems that
sys/net/if_spppsubr.c does not like it.
XXX api clarification needed...
 1.13 19-Jul-2001  itojun - on IFF_UP change, inform sys/net/if_spppsubr.c of the change so that
we can run LCP and subsequent PPP negotiation.
- suppress too noisy printf() for about AIS event (if you remove the cable,
it will bark forever).
- sppp_dequeue() can return NULL even when sppp_isempty() is false, so check
it and do not deref NULL pointer.
- sppp_flush() on LMC interface shutdown.
- prepare to change BPF type on the fly (bpf_change_type).
 1.12 07-Jul-2001  thorpej branches: 1.12.2;
bzero -> memset
 1.11 07-Jul-2001  thorpej bcopy -> memcpy
 1.10 13-Jun-2001  wiz withough -> without
 1.9 12-Jun-2001  wiz receive, not recieve
 1.8 12-Apr-2001  itojun support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.7 09-Apr-2001  martin Specify the size of the framing added to packets, so if_sppsubr.c can
calculate correct statistics.
 1.6 14-Nov-2000  thorpej branches: 1.6.2;
NBPG -> PAGE_SIZE
 1.5 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.3 03-May-2000  thorpej `typedef void ifnet_ret_t;' isn't valid C -- use #define, instead. Also,
don't abuse the C preprocessor.
 1.2 04-Dec-1999  ragge CL* discarding.
 1.1 25-Mar-1999  explorer branches: 1.1.8; 1.1.14;
Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.1.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.8.3 21-Apr-2001  bouyer Sync with HEAD
 1.1.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.6.2.5 11-Jan-2002  nathanw More catchup.
 1.6.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.6.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.12.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.12.2.1 03-Aug-2001  lukem update to -current
 1.20.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.10.1 29-Apr-2005  kent sync with -current
 1.20.2.3 11-Dec-2005  christos Sync with head.
 1.20.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.22.2.7 11-Feb-2008  yamt sync with head.
 1.22.2.6 21-Jan-2008  yamt sync with head
 1.22.2.5 27-Oct-2007  yamt sync with head.
 1.22.2.4 03-Sep-2007  yamt sync with head.
 1.22.2.3 26-Feb-2007  yamt sync with head.
 1.22.2.2 30-Dec-2006  yamt sync with head.
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.23.6.2 01-Jun-2006  kardel Sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.23.2.1 18-Feb-2006  yamt sync with head.
 1.25.4.3 11-May-2006  elad sync with head
 1.25.4.2 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.25.4.1 19-Apr-2006  elad sync with head.
 1.25.2.3 03-Sep-2006  yamt sync with head.
 1.25.2.2 24-May-2006  yamt sync with head.
 1.25.2.1 13-Mar-2006  yamt sync with head.
 1.26.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.30.4.2 10-Dec-2006  yamt sync with head.
 1.30.4.1 22-Oct-2006  yamt sync with head
 1.30.2.1 18-Nov-2006  ad Sync with head.
 1.32.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.32.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.2 23-Oct-2007  ad Sync with head.
 1.34.2.1 05-Apr-2007  ad Compile fixes.
 1.35.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.35.8.3 23-Mar-2008  matt sync with HEAD
 1.35.8.2 09-Jan-2008  matt sync with HEAD
 1.35.8.1 06-Nov-2007  matt sync with HEAD
 1.35.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.36.8.3 10-Jan-2008  bouyer Sync with HEAD
 1.36.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.36.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.36.6.1 11-Dec-2007  yamt sync with head.
 1.36.4.1 26-Dec-2007  ad Sync with head.
 1.36.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.40.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.40.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.40.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.8.2 27-Jun-2008  simonb Sync with head.
 1.41.8.1 18-Jun-2008  simonb Sync with head.
 1.41.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.41.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.41.4.3 11-Mar-2010  yamt sync with head
 1.41.4.2 16-May-2009  yamt sync with head
 1.41.4.1 04-May-2009  yamt sync with head.
 1.41.2.1 17-Jun-2008  yamt sync with head.
 1.43.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.43.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.43.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.46.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.49.4.1 05-Mar-2011  rmind sync with head
 1.50.18.4 03-Dec-2017  jdolecek update from HEAD
 1.50.18.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.18.2 23-Jun-2013  tls resync from head
 1.50.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.50.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.50.8.1 30-Oct-2012  yamt sync with head
 1.53.4.1 18-May-2014  rmind sync with head
 1.54.2.1 10-Aug-2014  tls Rebase.
 1.56.2.4 09-Jul-2016  skrll Sync with HEAD
 1.56.2.3 29-May-2016  skrll Sync with HEAD
 1.56.2.2 22-Apr-2016  skrll Sync with HEAD
 1.56.2.1 19-Mar-2016  skrll Sync with HEAD
 1.61.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.61.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.62.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.63.6.1 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #950):

sys/dev/pci/if_lmc.h: revision 1.25
sys/dev/pci/if_lmc.c: revision 1.65
doc/TODO.smpnet: revision 1.20

Move txintr_setup() stuff from lmc_interrupt() and do it in ifnet_start().
Now we can use bpf_mtap() in the TX path. Not tested.
 1.64.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.64.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.64.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.66.2.1 10-Jun-2019  christos Sync with HEAD
 1.27 12-Dec-2018  maxv Retire the LMC driver, and its associated lmcconfig tool. LMC has been
mentioned repeatedly as a non-MP-safe driver that is hard to maintain,
and no one is taking care of it.

LMC was removed from OpenBSD three years ago, and from FreeBSD a few
months ago.
 1.26 16-Sep-2018  skrll interrupt has two 'r's

fix another typo while I'm here (flsah)
 1.25 25-Jun-2018  msaitoh branches: 1.25.2;
Move txintr_setup() stuff from lmc_interrupt() and do it in ifnet_start().
Now we can use bpf_mtap() in the TX path. Not tested.
 1.24 24-Jan-2017  ozaki-r branches: 1.24.6; 1.24.12;
Defer bpf_mtap in Rx interrupt context to softint

bpf_mtap of some drivers is still called in hardware interrupt context.
We want to run them in softint as well as bpf_mtap of most drivers
(see if_percpuq_softint and if_input).

To this end, bpf_mtap_softint mechanism is implemented; it defers
bpf_mtap processing to a dedicated softint for a target driver.
By using the machanism, we can move bpf_mtap processing to softint
without changing target drivers much while it adds some overhead
on CPU and memory. Once target drivers are changed to softint-based,
we should return to normal bpf_mtap.

Proposed on tech-kern and tech-net
 1.23 28-Apr-2016  ozaki-r branches: 1.23.2; 1.23.4;
Constify rtentry of if_output

We no longer need to change rtentry below if_output.

The change makes it clear where rtentries are changed (or not)
and helps forthcoming locking (os psrefing) rtentries.
 1.22 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.21 27-Oct-2012  chs branches: 1.21.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.20 13-Mar-2012  elad branches: 1.20.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.19 05-Apr-2010  joerg branches: 1.19.8; 1.19.12;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.18 19-Jan-2010  pooka branches: 1.18.2; 1.18.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.17 16-Sep-2009  dyoung Pass lmc(4) through 'unifdef -U__FreeBSD__ -U__bsdi__ -U__OpenBSD__
-U__linux__ -D__NetBSD__ -UNETGRAPH' to shorten this driver by
>2500 lines. objdump -D does not reveal any differences in the
compiled code.
 1.16 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.15 12-Nov-2008  ad branches: 1.15.4;
Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.14 08-Sep-2008  gmcgarry branches: 1.14.2;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.13 27-Jun-2008  gmcgarry branches: 1.13.2;
Convert lmc(4) to mutexes, removing ({ }) gcc extension along the way.
 1.12 12-Jun-2008  cegger use device_lookup_private to get softc
 1.11 10-Apr-2008  cegger branches: 1.11.2; 1.11.4; 1.11.6; 1.11.8;
use aprint_*_dev and device_xname
 1.10 10-Jan-2008  dyoung branches: 1.10.6;
Straggler: change generic ifmedia_X names to lmc_ifmedia_X.
 1.9 04-Mar-2007  christos branches: 1.9.16; 1.9.22; 1.9.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.8 17-Feb-2007  dyoung KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.

Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.

Constify:

1 Introduce const accessor for route->ro_dst, rtcache_getdst().

2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.

3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.

4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
 1.7 04-Jan-2007  elad branches: 1.7.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.6 27-Aug-2006  christos branches: 1.6.2;
Grr. Don't define _KERNEL! Most of the kernel files do #ifdef _KERNEL
 1.5 21-Jul-2006  ad - Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.4 14-May-2006  elad branches: 1.4.6;
integrate kauth.
 1.3 20-Apr-2006  christos New version from David Boggs.
 1.2 11-Feb-2006  christos branches: 1.2.2; 1.2.4; 1.2.6;
new version from David Boggs.
 1.1 06-Dec-2005  christos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
New lmc driver from David Boggs
 1.1.8.2 01-Jun-2006  kardel Sync with head.
 1.1.8.1 22-Apr-2006  simonb Sync with head.
 1.1.6.1 09-Sep-2006  rpaulo sync with head
 1.1.4.1 18-Feb-2006  yamt sync with head.
 1.1.2.2 11-Dec-2005  christos Sync with head.
 1.1.2.1 06-Dec-2005  christos file if_lmc.h was added on branch ktrace-lwp on 2005-12-11 10:28:58 +0000
 1.2.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.4.3 11-May-2006  elad sync with head
 1.2.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.2.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.2.2.3 03-Sep-2006  yamt sync with head.
 1.2.2.2 11-Aug-2006  yamt sync with head
 1.2.2.1 24-May-2006  yamt sync with head.
 1.4.6.6 21-Jan-2008  yamt sync with head
 1.4.6.5 03-Sep-2007  yamt sync with head.
 1.4.6.4 26-Feb-2007  yamt sync with head.
 1.4.6.3 30-Dec-2006  yamt sync with head.
 1.4.6.2 21-Jun-2006  yamt sync with head.
 1.4.6.1 14-May-2006  yamt file if_lmc.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:04 +0000
 1.6.2.1 12-Jan-2007  ad Sync with head.
 1.7.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.7.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.9.28.1 10-Jan-2008  bouyer Sync with HEAD
 1.9.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.16.1 23-Mar-2008  matt sync with HEAD
 1.10.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.10.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.10.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.10.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.8.2 27-Jun-2008  simonb Sync with head.
 1.11.8.1 18-Jun-2008  simonb Sync with head.
 1.11.6.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.11.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.4.4 11-Aug-2010  yamt sync with head.
 1.11.4.3 11-Mar-2010  yamt sync with head
 1.11.4.2 16-May-2009  yamt sync with head
 1.11.4.1 04-May-2009  yamt sync with head.
 1.11.2.1 17-Jun-2008  yamt sync with head.
 1.13.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.2.1 19-Oct-2008  haad Sync with HEAD.
 1.14.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 30-May-2010  rmind sync with head
 1.18.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.12.1 05-Apr-2012  mrg sync to latest -current.
 1.19.8.2 30-Oct-2012  yamt sync with head
 1.19.8.1 17-Apr-2012  yamt sync with head
 1.20.2.2 03-Dec-2017  jdolecek update from HEAD
 1.20.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.14.3 05-Feb-2017  skrll Sync with HEAD
 1.21.14.2 29-May-2016  skrll Sync with HEAD
 1.21.14.1 22-Sep-2015  skrll Sync with HEAD
 1.23.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.23.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.24.12.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.24.12.2 30-Sep-2018  pgoyette Ssync with HEAD
 1.24.12.1 28-Jul-2018  pgoyette Sync with HEAD
 1.24.6.1 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #950):

sys/dev/pci/if_lmc.h: revision 1.25
sys/dev/pci/if_lmc.c: revision 1.65
doc/TODO.smpnet: revision 1.20

Move txintr_setup() stuff from lmc_interrupt() and do it in ifnet_start().
Now we can use bpf_mtap() in the TX path. Not tested.
 1.25.2.1 10-Jun-2019  christos Sync with HEAD
 1.11 06-Dec-2005  christos New lmc driver from David Boggs
 1.10 27-Feb-2005  perry branches: 1.10.4;
nuke trailing whitespace
 1.9 04-Jan-2002  martin branches: 1.9.16; 1.9.24; 1.9.26;
Move net/if_sppp.h to net/if_spppvar.h, create a new net/if_sppp.h
containing the userland visible thinks (i.e. ioctl definitions).

Remove all (both) old ioctls, as they had a brain dead API and made keeping
binary compatibility more or less impossible.

Replace by several new ioctls. While there, remove any arbitrary limits
(resulting from the old, broken ioctls) and allow any length of names
and passwords.
 1.8 13-Nov-2001  lukem add RCSID
 1.7 27-Aug-2001  eeh Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.6 13-Jun-2001  wiz branches: 1.6.2;
withough -> without
 1.5 12-Apr-2001  itojun support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.4 28-Jun-2000  mrg branches: 1.4.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.2 03-May-2000  thorpej `typedef void ifnet_ret_t;' isn't valid C -- use #define, instead. Also,
don't abuse the C preprocessor.
 1.1 25-Mar-1999  explorer branches: 1.1.8;
Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.1.8.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.4 11-Jan-2002  nathanw More catchup.
 1.4.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.9.26.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.24.1 29-Apr-2005  kent sync with -current
 1.9.16.2 11-Dec-2005  christos Sync with head.
 1.9.16.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.4.1 21-Jun-2006  yamt sync with head.
 1.18 06-Dec-2005  christos New lmc driver from David Boggs
 1.17 30-May-2005  christos branches: 1.17.2;
- const poisoning
- avoid variable shadowing.
 1.16 27-Feb-2005  perry nuke trailing whitespace
 1.15 22-Feb-2003  tsutsui branches: 1.15.2; 1.15.10; 1.15.12;
hz -> Hz
 1.14 25-Nov-2002  thorpej Fix a strict-alias problem uncovered by GCC 3.3.
 1.13 04-Jan-2002  martin Move net/if_sppp.h to net/if_spppvar.h, create a new net/if_sppp.h
containing the userland visible thinks (i.e. ioctl definitions).

Remove all (both) old ioctls, as they had a brain dead API and made keeping
binary compatibility more or less impossible.

Replace by several new ioctls. While there, remove any arbitrary limits
(resulting from the old, broken ioctls) and allow any length of names
and passwords.
 1.12 13-Nov-2001  lukem add RCSID
 1.11 01-Nov-2001  uch missing NBPFILTER > 0
 1.10 27-Aug-2001  eeh branches: 1.10.4;
Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.9 19-Jul-2001  itojun sync with latest Linux driver, avoid framing error on LMC1200 (T1/E1).
from hal@vailsys.com
 1.8 19-Jul-2001  itojun readability changes (s/0/LMC_LINK_DOWN/, whitespace)
 1.7 19-Jul-2001  itojun - on IFF_UP change, inform sys/net/if_spppsubr.c of the change so that
we can run LCP and subsequent PPP negotiation.
- suppress too noisy printf() for about AIS event (if you remove the cable,
it will bark forever).
- sppp_dequeue() can return NULL even when sppp_isempty() is false, so check
it and do not deref NULL pointer.
- sppp_flush() on LMC interface shutdown.
- prepare to change BPF type on the fly (bpf_change_type).
 1.6 12-Jun-2001  wiz branches: 1.6.2;
receive, not recieve
 1.5 12-Apr-2001  itojun support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.4 28-Jun-2000  mrg branches: 1.4.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.2 03-May-2000  thorpej `typedef void ifnet_ret_t;' isn't valid C -- use #define, instead. Also,
don't abuse the C preprocessor.
 1.1 25-Mar-1999  explorer branches: 1.1.8;
Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.1.8.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.4.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.5 11-Jan-2002  nathanw More catchup.
 1.4.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.4.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.6.2.1 03-Aug-2001  lukem update to -current
 1.10.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.15.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.10.1 29-Apr-2005  kent sync with -current
 1.15.2.3 11-Dec-2005  christos Sync with head.
 1.15.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.23 06-Dec-2005  christos New lmc driver from David Boggs
 1.22 27-Feb-2005  perry branches: 1.22.4;
nuke trailing whitespace
 1.21 01-Apr-2003  thorpej branches: 1.21.2; 1.21.10; 1.21.12;
Use PAGE_SIZE rather than NBPG.
 1.20 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.19 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.18 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.17 09-May-2002  matt Print out interrupt we attached to.
 1.16 04-Jan-2002  martin Move net/if_sppp.h to net/if_spppvar.h, create a new net/if_sppp.h
containing the userland visible thinks (i.e. ioctl definitions).

Remove all (both) old ioctls, as they had a brain dead API and made keeping
binary compatibility more or less impossible.

Replace by several new ioctls. While there, remove any arbitrary limits
(resulting from the old, broken ioctls) and allow any length of names
and passwords.
 1.15 13-Nov-2001  lukem add RCSID
 1.14 27-Aug-2001  eeh Get rid of debug printf.
 1.13 27-Aug-2001  augustss Make it compile.
 1.12 27-Aug-2001  eeh Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.11 19-Jul-2001  itojun - on IFF_UP change, inform sys/net/if_spppsubr.c of the change so that
we can run LCP and subsequent PPP negotiation.
- suppress too noisy printf() for about AIS event (if you remove the cable,
it will bark forever).
- sppp_dequeue() can return NULL even when sppp_isempty() is false, so check
it and do not deref NULL pointer.
- sppp_flush() on LMC interface shutdown.
- prepare to change BPF type on the fly (bpf_change_type).
 1.10 07-Jul-2001  thorpej branches: 1.10.2;
bcopy -> strcpy
 1.9 13-Jun-2001  wiz withough -> without
 1.8 12-Apr-2001  itojun support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.7 12-Jan-2001  itojun branches: 1.7.2;
match T1 card. from freebsd driver, it should just work.
i'll test it as soon as i get the card handy.
 1.6 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.5 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.3 03-May-2000  thorpej `typedef void ifnet_ret_t;' isn't valid C -- use #define, instead. Also,
don't abuse the C preprocessor.
 1.2 12-May-1999  explorer branches: 1.2.2;
just say no to __BROKEN_INDIRECT_CONFIG
 1.1 25-Mar-1999  explorer branches: 1.1.4;
Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.1.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.2.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.2.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.7 20-Jun-2002  nathanw Catch up to -current.
 1.7.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.7.2.5 11-Jan-2002  nathanw More catchup.
 1.7.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.7.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.10.2.1 03-Aug-2001  lukem update to -current
 1.21.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.10.1 29-Apr-2005  kent sync with -current
 1.21.2.2 11-Dec-2005  christos Sync with head.
 1.21.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.22.4.1 21-Jun-2006  yamt sync with head.
 1.6 06-Dec-2005  christos New lmc driver from David Boggs
 1.5 09-May-2002  matt branches: 1.5.10; 1.5.26;
LMC_CTL_LEN1 and LMC_CTL_LEN2 extracted each other's fields. Stop doing
that.
 1.4 27-Aug-2001  eeh Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.3 12-Apr-2001  itojun branches: 1.3.2;
support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.2 25-Mar-1999  explorer branches: 1.2.8; 1.2.20;
wrap kernel bits in shared kernel/userland files
 1.1 25-Mar-1999  explorer Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.2.20.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.20.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.20.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.8.1 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.5.26.1 21-Jun-2006  yamt sync with head.
 1.5.10.1 11-Dec-2005  christos Sync with head.
 1.6 06-Dec-2005  christos New lmc driver from David Boggs
 1.5 08-Jul-2003  itojun branches: 1.5.16;
function prototype must not have variable name
 1.4 27-Aug-2001  eeh branches: 1.4.20;
Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.3 12-Apr-2001  itojun branches: 1.3.2;
support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.2 25-Mar-1999  explorer branches: 1.2.8; 1.2.20;
wrap kernel bits in shared kernel/userland files
 1.1 25-Mar-1999  explorer Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.2.20.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.20.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.8.1 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.4.20.4 11-Dec-2005  christos Sync with head.
 1.4.20.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.20.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.20.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.13 06-Dec-2005  christos New lmc driver from David Boggs
 1.12 27-Feb-2005  perry branches: 1.12.4;
nuke trailing whitespace
 1.11 01-Oct-2002  thorpej branches: 1.11.6; 1.11.14; 1.11.16;
Remove uneecessary extern decl of de_ca.
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 31-May-2002  thorpej * Add __unused___ to lmc_system_errors, since it is not used by
everything which includes if_lmcvar.h.
* #if 0 lmc_status_bits, since it's not used by anything.
 1.8 27-Aug-2001  eeh branches: 1.8.12;
Make the LMC driver bus_dma and endian clean (big-endian mode does not appear
to work on LMC cards).
 1.7 13-Jun-2001  wiz branches: 1.7.2;
withough -> without
 1.6 12-Apr-2001  itojun support T1 card (LMC1200) properly. PR 12331 (patch from openbsd).

change DLT type to cisco HDLC, as lmc driver is hardwired to cisco HDLC
on driver attach. XXX we may need to revisit this, as if_spppsubr may want
to alter this later.
 1.5 12-Dec-2000  thorpej branches: 1.5.2;
Adapt to bpfattach() changes, and further centralize the bpfattach()
and bpfdetach() calls into link-type subroutines where possible.
 1.4 06-Sep-2000  thorpej Cast the argument to vtophys() to vaddr_t.
 1.3 03-May-2000  thorpej `typedef void ifnet_ret_t;' isn't valid C -- use #define, instead. Also,
don't abuse the C preprocessor.
 1.2 11-May-1999  thorpej branches: 1.2.2;
Set the data link type to DLT_PPP_SERIAL so that tcpdump can do
something useful with our captured frames.
 1.1 25-Mar-1999  explorer branches: 1.1.4;
Commit files for the LAN Media Corporation high speed serial/HSSI/DS3 driver
 1.1.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.2.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.5.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.5.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.5.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.12.1 20-Jun-2002  gehenna catch up with -current.
 1.11.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.14.1 29-Apr-2005  kent sync with -current
 1.11.6.2 11-Dec-2005  christos Sync with head.
 1.11.6.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.4.1 21-Jun-2006  yamt sync with head.
 1.9 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.8 08-May-2021  thorpej Use pci_compatible_match().
 1.7 09-Dec-2018  jdolecek branches: 1.7.16;
use pci_intr_establish_xname() everywhere
 1.6 02-Feb-2017  nonaka branches: 1.6.12; 1.6.14;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.5 29-Mar-2014  christos branches: 1.5.6; 1.5.10; 1.5.14;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.4 30-Mar-2013  christos branches: 1.4.4;
remove trailing whitespace
 1.3 05-Aug-2012  degroote branches: 1.3.2; 1.3.4;
Add pmf(9) handler to malo(4) wireless driver
 1.2 30-Jul-2012  degroote Add missing $NetBSD$ tags and __KERNEL_RCSID().
 1.1 30-Jul-2012  degroote Add malo(4)@pci driver for Marvell Libertas wireless adaptor

Ported from OpenBSD
Known issues :
- contrary to OpenBSD one, only support pci at the moment, because I don't
have the necessary hardware to test PCMCIA / CARDUS Marvell Card
- not connected to pmf(9) (unable to test it)
 1.3.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.4.2 30-Oct-2012  yamt sync with head
 1.3.4.1 05-Aug-2012  yamt file if_malo_pci.c was added on branch yamt-pagecache on 2012-10-30 17:21:30 +0000
 1.3.2.3 03-Dec-2017  jdolecek update from HEAD
 1.3.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.2.1 23-Jun-2013  tls resync from head
 1.4.4.1 18-May-2014  rmind sync with head
 1.5.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.5.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5.6.1 05-Feb-2017  skrll Sync with HEAD
 1.6.14.1 10-Jun-2019  christos Sync with HEAD
 1.6.12.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7.16.1 13-May-2021  thorpej Sync with HEAD.
 1.29 07-Jul-2024  msaitoh mcx(4): Match on ConnectX-6 virtual functions, too. From OpenBSD.
 1.28 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.27 11-Apr-2024  andvar branches: 1.27.2;
mcx(4): enforce full-duplex mark in mcx_media_status(), when link is up.

LACP protocol requires full-duplex to be enabled for lagg(4) to work,
however mcx(4) was not setting this capability making it to fail.

Fixes PR kern/58124. OK'd by msaitoh@
 1.26 26-Oct-2023  msaitoh mcx(4): Add Mellanox ConnectX-6 Lx from OpenBSD.
 1.25 28-Aug-2022  skrll branches: 1.25.4;
Empty if_watchdog functions are useless and now waste resources. Let's
remove them.
 1.24 07-Jul-2022  skrll Trailing whitespace
 1.23 05-Nov-2021  andvar mcx(4): ensure that RQT size is always a power of two.
Fixes PR kern/56484.
Thanks riastradh for the power of two patch :). OK: mrg, jmcneill, riastradh.
 1.22 26-Sep-2021  jmcneill Enable checksum offload features by default.
 1.21 26-Sep-2021  jmcneill We are not mapping registers prefetchable so no need for explicit bs
barriers.
 1.20 25-Sep-2021  jmcneill Sync with OpenBSD r1.101:

When processing a received packet, only sync the amount of bytes
mcx(4) told us has arrived. The DMA map's mapsize on RX packets
is the length of the allocated buffer. For mcx(4), this can be
more than around 9000 bytes, as each buffer will be at least as
big as the maximum supported MTU. There's no need to sync the
whole buffer, if it's only a small packet.
 1.19 20-Sep-2021  jmcneill Use coherent DMA mappings when possible.
 1.18 24-Jul-2021  andvar s/structres/structures + s/whenver/whenever
 1.17 20-Feb-2021  jmcneill branches: 1.17.4;
Sync with OpenBSD r1.99:

move the rearming of the cq after the refill of the rq.

this is the only real diff we have left outstanding on a box that
experienced rx lockups. since adding this change it's been happy
for the last 4 weeks and counting so far.
 1.16 05-Feb-2021  jmcneill mcx: Add if_transmit callback to enable more than one tx queue
 1.15 30-Jan-2021  jmcneill Sync with OpenBSD r1.98. Lots of improvements including checksum offload,
hardware vlan tagging, and support for multiple receive queues.
 1.14 25-May-2020  jmcneill branches: 1.14.2;
Add __KERNEL_RCSID
 1.13 24-Apr-2020  jmcneill mcx: sync with OpenBSD sys/dev/pci/if_mcx.c r1.44

1.44:
Fix typo which could lead into a double free

1.43:
Commands that create objects return a 24 bit object ID, so mask off the
high 8 bits of the value we extract, in case the firmware leaves junk there.
Hrvoje Popovski has seen this with newer firmware on a ConnectX 5 card,
which now works properly.

1.42:
Increase the completion queue size to prevent overflow. Under reasonably
unlikely circumstances - lots of single-fragment packets being sent, a
significant number of packets being received, while the interrupt handler
was unable to process the completion queue - the completion queue could
overflow, which would result in the interface locking up.

1.41:
Check if we've reached the end of the current mailbox before writing past
the end of it, rather than after. Now we can actually allocate queues
big enough to need multiple mailboxes.

1.40:
Don't call mcx_intr() from mcx_cmdq_poll(); this was a leftover from early
development that I forgot about, but turns out to be a potential race with
the actual interrupt handler.

1.39:
fix previous: use the correct offset for sq/rq creation, and don't
reset the mbox counter to 0 after calculating it.

1.38:
Add a helper function for writing physical addresses for queues into
command queue mailboxes, and use this for all queue setup commands.
Previously we just assumed the addresses would fit in the first mailbox,
which is currently true but may not be for much longer.

1.37:
(skipped)

1.36:
The event queue consumer counter also needs to be unsigned like the others.

1.35:
try to make if_baudrate look plausible.
this updates the eth proto capability map so it records the baudrate
against the different link types and their media, and then reads
it when the link state changes.

1.34:
(skipped)
 1.12 15-Mar-2020  thorpej branches: 1.12.2; 1.12.4;
Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.11 29-Feb-2020  thorpej Use the 64-bit PCI DMA tag if available. Otherwise, we are needlessly
allocating (and using) bounce buffers on sytems with >4GB of RAM.

XXX pullup-9
 1.10 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.9 29-Nov-2019  msaitoh branches: 1.9.2;
Set if_baudrate.
 1.8 28-Nov-2019  msaitoh - Change IFM_10G_T(10GBase-T) entry to IFM_10G_CR1(10GBASE-CR1)
- Add the following entries:

20GBASE-KR2
56GBASE-R4
100GBASE-LR4
100BaseTX
1000baseT
10GBase-T
 1.7 26-Nov-2019  jmcneill Fix IFF_ALLMULTI handling.
 1.6 18-Nov-2019  nonaka Fixed incorrect m_defrag return value check.
 1.5 17-Oct-2019  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.4 28-Sep-2019  tnn len -> m_len
 1.3 28-Sep-2019  tnn mcx(4): fix rx mbuf DMA overrun

pullup-9
 1.2 24-Sep-2019  msaitoh Use IFM_50G_SR2.
 1.1 21-Sep-2019  jmcneill branches: 1.1.2;
Add support for Mellanox 5th generation ethernet devices. This driver
supports the ConnectX-4 Lx EN, ConnectX-4 EN, ConnectX-5 EN, and
ConnectX-6 EN adapters.

Driver ported from OpenBSD.
 1.1.2.10 28-Apr-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #858):

sys/dev/pci/if_mcx.c: revision 1.13

mcx: sync with OpenBSD sys/dev/pci/if_mcx.c r1.44

1.44:
Fix typo which could lead into a double free

1.43:
Commands that create objects return a 24 bit object ID, so mask off the
high 8 bits of the value we extract, in case the firmware leaves junk there.
Hrvoje Popovski has seen this with newer firmware on a ConnectX 5 card,
which now works properly.

1.42:
Increase the completion queue size to prevent overflow. Under reasonably
unlikely circumstances - lots of single-fragment packets being sent, a
significant number of packets being received, while the interrupt handler
was unable to process the completion queue - the completion queue could
overflow, which would result in the interface locking up.

1.41:
Check if we've reached the end of the current mailbox before writing past
the end of it, rather than after. Now we can actually allocate queues
big enough to need multiple mailboxes.

1.40:
Don't call mcx_intr() from mcx_cmdq_poll(); this was a leftover from early
development that I forgot about, but turns out to be a potential race with
the actual interrupt handler.

1.39:
fix previous: use the correct offset for sq/rq creation, and don't
reset the mbox counter to 0 after calculating it.

1.38:
Add a helper function for writing physical addresses for queues into
command queue mailboxes, and use this for all queue setup commands.
Previously we just assumed the addresses would fit in the first mailbox,
which is currently true but may not be for much longer.

1.37:
(skipped)

1.36:
The event queue consumer counter also needs to be unsigned like the others.

1.35:
try to make if_baudrate look plausible.
this updates the eth proto capability map so it records the baudrate
against the different link types and their media, and then reads
it when the link state changes.

1.34:
(skipped)
 1.1.2.9 01-Mar-2020  martin Pull up following revision(s) (requested by thorpej in ticket #747):

sys/dev/pci/if_mcx.c: revision 1.11

Use the 64-bit PCI DMA tag if available. Otherwise, we are needlessly
allocating (and using) bounce buffers on sytems with >4GB of RAM.

XXX pullup-9
 1.1.2.8 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.1.2.7 26-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #651):

sys/dev/pci/if_mcx.c: revision 1.8
sys/dev/pci/if_mcx.c: revision 1.9

- Change IFM_10G_T(10GBase-T) entry to IFM_10G_CR1(10GBASE-CR1)
- Add the following entries:
20GBASE-KR2
56GBASE-R4
100GBASE-LR4
100BaseTX
1000baseT
10GBase-T
Set if_baudrate.
 1.1.2.6 26-Nov-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #486):

sys/dev/pci/if_mcx.c: revision 1.7

Fix IFF_ALLMULTI handling.
 1.1.2.5 18-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #441):

sys/dev/hyperv/if_hvn.c: revision 1.7
sys/dev/pci/if_mcx.c: revision 1.6

Fixed incorrect m_defrag return value check.
 1.1.2.4 29-Sep-2019  martin Pull up following revision(s) (requested by tnn in ticket #266):

sys/dev/pci/if_mcx.c: revision 1.3
sys/dev/pci/if_mcx.c: revision 1.4

mcx(4): fix rx mbuf DMA overrun
pullup-9

-

len -> m_len
 1.1.2.3 26-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #247):

sys/dev/pci/if_mcx.c: revision 1.2

Use IFM_50G_SR2.
 1.1.2.2 23-Sep-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #230):

sys/dev/pci/files.pci: revision 1.415
distrib/sets/lists/man/mi: revision 1.1655
sys/dev/pci/if_mcx.c: revision 1.1
share/man/man4/Makefile: revision 1.683
share/man/man4/mcx.4: revision 1.1
sys/arch/evbarm/conf/GENERIC64: revision 1.107
sys/dev/pci/files.pci: revision 1.414

Add support for Mellanox 5th generation ethernet devices. This driver
supports the ConnectX-4 Lx EN, ConnectX-4 EN, ConnectX-5 EN, and
ConnectX-6 EN adapters.

Driver ported from OpenBSD.

add mcx attachment.

Correct mcx comment, drop mii dependency
 1.1.2.1 21-Sep-2019  martin file if_mcx.c was added on branch netbsd-9 on 2019-09-23 07:04:40 +0000
 1.9.2.1 29-Feb-2020  ad Sync with head.
 1.12.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12.4.1 15-Mar-2020  martin file if_mcx.c was added on branch phil-wifi on 2020-04-13 08:04:26 +0000
 1.12.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.14.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.17.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.25.4.2 18-Apr-2024  martin Pull up following revision(s) (requested by andvar in ticket #661):

sys/dev/pci/if_mcx.c: revision 1.27

mcx(4): enforce full-duplex mark in mcx_media_status(), when link is up.

LACP protocol requires full-duplex to be enabled for lagg(4) to work,
however mcx(4) was not setting this capability making it to fail.

Fixes PR kern/58124. OK'd by msaitoh@
 1.25.4.1 03-Nov-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #447):

sys/dev/pci/pcidevs: revision 1.1498
sys/dev/pci/if_mcx.c: revision 1.26
share/man/man4/mcx.4: revision 1.3

pcidevs: Add Mellanox ConnectX-6 Lx.

mcx(4): Add Mellanox ConnectX-6 Lx from OpenBSD.
 1.27.2.1 02-Aug-2025  perseant Sync with HEAD
 1.119 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.118 20-Sep-2021  jmcneill Use coherent DMA mappings when possible.
 1.117 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.116 08-May-2021  thorpej branches: 1.116.6;
Use pci_compatible_match().
 1.115 24-Apr-2021  thorpej branches: 1.115.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.114 04-Oct-2020  jakllsch branches: 1.114.4;
device_printf() instead of aprint_error_dev() where appropriate
 1.113 11-May-2020  jakllsch msk(4): ack Status BMU IRQ only if we're (apparently) caught up with it

Possibility for acking an unprocessed Status BMU IRQ still exists, and
remains handled by the watchdog. Nevertheless this should reduce the
likelyhood that path is taken.
 1.112 11-May-2020  jakllsch msk(4): simplify interrupt return value creation

This also corrects a problem where we would not claim we handled an
interrupt that was ours.
 1.111 11-May-2020  jakllsch msk(4): moderate no interrupts globally

The global interrupt moderator on mskc(4) is mostly redundant with the Status Unit's tx and rx interrupt coalescing for our purpouses

Revisits interrupt moderation change in 1.108.
 1.110 08-May-2020  jakllsch Use sysctl_teardown() upon detach of mskc(4).
 1.109 08-May-2020  jakllsch msk(4): Simplify setting the first List Element owner-bit last.

We don't actually need to do this, as the BMU won't proceed to the new
descriptor until we advance the ring-end pointer on the chip, but perhaps
it has value as paranoia.
 1.108 30-Apr-2020  jakllsch msk(4): actually moderate interrupts from the Yukon 2 Status BMU

Previously the interrupt moderation enable register was being programmed
with sk(4)-style enable bits, none of which matched the significant
interrupt sources of the Yukon 2 we enable.
 1.107 30-Apr-2020  jakllsch msk(4): during attach print intrstr only once
 1.106 30-Apr-2020  jakllsch msk(4): rework rx descriptor loading to support multiple segments

This paves the way to replace the driver-internal jumbo frame rx buffer
with other recieve buffers (for example MCLGET/MEXTMALLOC) in the future.
 1.105 29-Apr-2020  jakllsch msk(4): Simply keep a ring of (tx) dmamaps, rather than a linked list
 1.104 29-Apr-2020  jakllsch msk(4): don't keep array of pointers to each ring descriptor

With 512 descriptors each in 2 rings this saves 4KiB (LP32) or 8KiB (LP64)
per interface.
 1.103 28-Apr-2020  jakllsch Use correct-semantic byteorder(9) functions to provide letoh*() in msk(4)
 1.102 28-Apr-2020  jakllsch Remove unused cargo cult include of <dev/mii/brgphyreg.h> in if_msk.c.
 1.101 26-Apr-2020  jakllsch Remove written-only sk_next member of struct (m)sk_chain.
 1.100 22-Apr-2020  jdolecek show the 'interrupting at ...' info on boot
 1.99 18-Apr-2020  jakllsch msk(4): Avoid bus_dmamap_destroy() in msk_stop()

bus_dmamap_destroy() can not be executed in soft interrupt context,
and msk_stop() can be called in soft interrupt context.

As such, move creation and destruction of tx dmamaps to attach() and
detach() functions.
 1.98 04-Feb-2020  thorpej branches: 1.98.4;
Use ifmedia_fini().
 1.97 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.96 01-Dec-2019  maxv branches: 1.96.2;
minor adjustments, to avoid warnings on debug builds
 1.95 28-Nov-2019  maxv localify
 1.94 15-Nov-2019  msaitoh Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.
 1.93 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.92 17-Oct-2019  msaitoh Fix order of m_freem(). Found by kASan. OK'd by jdolecek and mrg.
 1.91 03-Jun-2019  msaitoh branches: 1.91.2;
I think it's not required to call msk_init_yukon() in msk_attach().
Fixes PR kern/54261 reported by David shao.
 1.90 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.89 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.88 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.87 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.86 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.85 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.84 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.83 08-Jan-2019  msaitoh KNF. No functional change.
 1.82 27-Dec-2018  mrg - initialise sk_rx_hiaddr and sk_tx_hiaddr
- use MSK_ADDR_LO() and MSK_ADDR_HI()
- expand a debug message
- remove unused softc members
 1.81 08-Dec-2018  bouyer Don't try to handle interrupts for a detached device. Should fix
panic on shutdown reported by Stefan Hertenberger on current-users.
 1.80 13-Nov-2018  jdolecek whitespace fix, NFC
 1.79 21-Oct-2018  jmcneill Enable MSI support where available.
 1.78 14-Sep-2018  jakllsch msk(4): add 64-bit DMA support

portions of this change set provided by mrg@
 1.77 12-Sep-2018  jakllsch if_msk: detach/reattach fixes

- Fill in sc->sk_bsize upon pci_mapreg_map() so that we'll correctly
bus_space_unmap() on detach.
- Clear sc->sk_intrhand after interrupt disestablish, to prevent
disestablishing unestablished interrupt.
 1.76 23-Aug-2018  maxv Fix buffer overflow, detected by kASan.

[ 1.044878] kASan: Unauthorized Access In 0xffffffff804ec7e2: Addr 0xffffffff818a51e4 [2 bytes, read]
[ 1.044878] #0 0xffffffff804ec7e2 in mskc_probe <netbsd>
[ 1.044878] #1 0xffffffff80e92a77 in mapply <netbsd>
[ 1.044878] #2 0xffffffff80e92e5f in config_search_loc <netbsd>
[ 1.044878] #3 0xffffffff80e93fb5 in config_found_sm_loc <netbsd>
[ 1.044878] #4 0xffffffff802ca9ea in pci_probe_device <netbsd>
[ 1.044878] #5 0xffffffff802cad97 in pci_enumerate_bus <netbsd>
[ 1.044878] #6 0xffffffff802caf00 in pcirescan <netbsd>
[ 1.044878] #7 0xffffffff802cb1ee in pciattach <netbsd>
[ 1.044878] #8 0xffffffff80e93e5b in config_attach_loc <netbsd>
[ 1.044878] #9 0xffffffff80e93fce in config_found_sm_loc <netbsd>
[ 1.044878] #10 0xffffffff80271212 in mp_pci_scan <netbsd>
[ 1.044878] #11 0xffffffff8022d9ee in mainbus_attach <netbsd>
[ 1.044878] #12 0xffffffff80e93e5b in config_attach_loc <netbsd>
[ 1.044878] #13 0xffffffff8021e38b in cpu_configure <netbsd>
[ 1.044878] #14 0xffffffff814a7068 in main <netbsd>
 1.75 10-Jul-2018  jdolecek replace code using SK_WA_4109 workaround flag by explicit conditional
on affected type ids and revisions, so it's properly applied whenever
new types are added; taken with FreeBSD

contrary to FreeBSD, keep the IWM workaround for all XL revs - my XL rev. A3
seems to consistently have slightly (~2%) better Rx performance with the 0x04
value
 1.74 10-Jul-2018  jdolecek minor fix for earlier sync with OpenBSD if_msk.c; remove duplicit
COMA handling, add also workaround code for Yukon EC Ultra and EX, and
remove a write-only assignment
 1.73 10-Jul-2018  jdolecek fix comment typo
 1.72 10-Jul-2018  jdolecek add callout for re-filling RX ring - it's invoked when the RX refill
code can't get enough buffers; fixes possible stall when the RXSTAT
interrupt arrives while no buffers are available

idea from OpenBSD if_msk.c rev. 1.131

as part of this remove the confusingly commented re-fill code from
msk_jfree() and instead just invoke the callout if needed; also
refill in msk_intr() only when running low instead of every RX intr;
this simplifies the code, and gives small RX performance boost on
my hardware (6%: ~38 MB/s -> ~40 MB/s)

tested on SK-9E22 (Yukon-2 XL rev. A3) by me, and 88E8071 (Yukon-2
Extreme rev. B0) by Jogn Halfpenny; unfortunately still doesn't
resolve the PR kern/53301 stall
 1.71 04-Jul-2018  jdolecek use pci_intr_establish_xname()
 1.70 03-Jul-2018  jdolecek fix detach code and do it on shutdown
 1.69 03-Jul-2018  jdolecek attach the rnd source only once even with dual-port adapters
 1.68 02-Jul-2018  jdolecek sync OpenBSD if_msk.c revs 1.66-1.79 skipping framework changes and already
present changes:
- Make Yukon-2 FE+ (88E8040, 88E8042) work
- 88E8057 is a Yukon 2 Ultra 2, and this might make it work on a little
shiny green box in Japan
- Prevent null pointer dereference that could happen when we process an RX
interrupt that was queued while stopping the interface.
- Remove holdover XMAC II writes/reads inherited from sk as
they aren't required and cause problems like the 88E8072
hard locking a system when enabling macsec bypass.
- Bypass macsec on extreme/supreme based chips.
Makes my 88E8072 work.
- Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order.

towards resolution of PR kern/53301 but will need more work

tested by John Halfpenny on another 8040/Yukon-2 FE+ and reported
improving behaviour (system hang to stall) so committing as stopgap; also
tested on my SK-9E22 (Yukon-2 XL), there works without any issues both before
and after
 1.67 26-Jun-2018  msaitoh branches: 1.67.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.66 21-Jun-2018  msaitoh Simplify & white space fix. No functional change.
 1.65 14-Jun-2018  msaitoh Remove extra tabs. No functional change.
 1.64 13-Jun-2018  jdolecek fix device name in printf when not matched
 1.63 13-Jun-2018  jdolecek sync and adapt with OpenBSD if_msk.c rev. 1.43-1.65 (modulo some
cosmetics, stuff we already had, or stuff which does not apply due
to different frameworks):

- Add support for fiber on 88E8021/22
- Avoid unnecessary resets. This should make fiber 88E8021/22 work completely
- Only probe phy's at address 0; gets rid of bogus phy's on the
Marvell Yukon 88E8036
- Remove an unused function msk_setfilt() which was copied from sk(4)
- Make msk(4) detachable
- Simplify the combination use of pci_mapreg_type()/pci_mapreg_map()
 1.62 13-Jun-2018  jdolecek revert rev. 1.29 'Only tick mii if the phy had a status change', as neither
OpenBSD nor FreeBSD drivers have this conditional
 1.61 12-Jun-2018  jdolecek move SK_HASH_BITS to if_skreg.h and reuse in if_msk.c (from OpenBSD)
 1.60 12-Jun-2018  jdolecek match three more variants - DGE550T_B1, 8040T, 8042

sync more sk_type conditionals from OpenBSD
 1.59 12-Jun-2018  jdolecek fix whitespace
 1.58 11-Jun-2018  jdolecek Factual correction: actually old code also used number of octents, but set
sc_if->sk_tx_ramend to invalid value, and assumed 128k buffer when
SK_EPROM0 read returned zero

(no code change)
 1.57 11-Jun-2018  jdolecek adopt tx/rx buffer size computation from OpenBSD rev. 1.51 to fix
"random" msk failures

the crucial fix is that the start/end adresses are computed and
written to hw registers in number of octets (i.e. size /
sizeof(u_int64_t)), as that is actually what the hardware expects

fixes PR kern/36454 (which had fix which highlighted the trouble),
and seems likely to also fix kern/35711 and port-i386/42514
 1.56 09-Jun-2018  jdolecek port basic match support for several more Yukon variants from OpenBSD, together
with some basic conditionals I've found in that driver; only compile-tested, so
very likely needs further work to actually work

adresses also PR kern/43507
 1.55 20-Oct-2017  christos branches: 1.55.2;
update entry for Marvel Yukon 8058, and fix URL for pci ids (Rocky Hotas)
 1.54 15-Dec-2016  ozaki-r branches: 1.54.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.53 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.52 06-Nov-2016  christos msk_init is too heavyweight and loses link. Provide a specialized way to
enter and exit promiscuous mode so that we don't lose seconds of traffic
each time we run tcpdump.
 1.51 10-Jun-2016  ozaki-r branches: 1.51.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.50 01-Jun-2016  pgoyette Commit patch from t-hash in PR kern/48309
 1.49 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.48 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.47 10-Oct-2014  christos branches: 1.47.2;
PR/49270: Hauke Fath: Samsung NC10 Marvell Yukon ethernet not supported
 1.46 10-Aug-2014  tls Merge tls-earlyentropy branch into HEAD.
 1.45 29-Mar-2014  christos branches: 1.45.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.44 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.43 30-Mar-2013  christos branches: 1.43.4;
remove trailing whitespace
 1.42 04-Aug-2012  riastradh branches: 1.42.2;
Fix null pointer dereference in msk_rxeof.

This triggers when processing an RX interrupt that was queued while
stopping the interface, which caused my machine to panic last night.
In this case, just drop the packet.

From OpenBSD's if_msk.c rev. 1.71.
 1.41 22-Jul-2012  matt Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.40 02-Jun-2012  dsl Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.39 02-Feb-2012  tls branches: 1.39.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.38 24-Apr-2011  plunky branches: 1.38.4; 1.38.8;
use static inline for msk_rxvalid(), it is not referenced elsewhere

(avoids C99 vs GNU semantics for external inline functions)
 1.37 16-Apr-2011  jakllsch Make previous compile.
 1.36 16-Apr-2011  jakllsch Ensure PCI_COMMAND_MASTER_ENABLE.
 1.35 05-Apr-2010  joerg branches: 1.35.2;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.34 30-Mar-2010  tnn yinterrupt -> interrupt
 1.33 24-Feb-2010  dyoung branches: 1.33.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.32 19-Jan-2010  pooka branches: 1.32.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.31 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.30 24-Dec-2009  christos - split the sk_dev
- don't program the interrupt mitigation to 0, only to set it to 1000 later.
- don't be verbose when setting the interrupt mitigation during reset, it
messes up the attach line and does not convey useful information.
 1.29 14-Dec-2009  matt Only tick mii if the phy had a status change.
 1.28 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.27 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.26 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.25 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.24 18-Mar-2009  cegger bzero -> memset
 1.23 18-Mar-2009  cegger bcmp -> memcmp
 1.22 18-Nov-2008  chris branches: 1.22.4;
Fix Yukon EC Ultra cold power up issue.

For the EC Ultra it is necessary to update some extra registers during
reset. Without doing so causes the system to hang at boot. The only
workaround I found was to PXE boot before booting into NetBSD.

This change is based on the code from FreeBSD's if_msk.c. Specifically the
msk_phy_power function.

Also add an splnet/splx across mii_tick. This matches most other network
drivers.

Change posted for review on 3rd Oct 2008 to tech-net. No feedback
received.
 1.21 20-Jun-2008  cube branches: 1.21.2; 1.21.4; 1.21.6;
Apply a similar patch as what was just applied to sk(4):

> Use a mutex instead of splvm() to protect the list of jubo-ready mbufs, as
> done with nfe(4) a while ago.
>
> Issue reported by Gary Duzan, who kindly fixed the patch I had sent him.

Lars Nordlund noted that such a change made things a lot better with his
msk(4).
 1.20 28-May-2008  joerg branches: 1.20.2;
Add PMF hooks. Fixes PR 38675.
 1.19 27-May-2008  dyoung For all controllers but type SK_YUKON_FE, set the jumbo frames
capability, ETHERCAP_JUMBO_MTU. Rely on ether_ioctl() to enforce
the MTU range implied by the ethernet capabilities. Should fix
kern/38748.

While I'm here, use some standard ethernet constants instead of
msk-specific constants.
 1.18 10-Apr-2008  cegger branches: 1.18.2; 1.18.4; 1.18.6;
use aprint_*_dev and device_xname
 1.17 28-Mar-2008  kiyohara The status buffer must synchronize. If your CPU is cache writeback,
synchronous processing is necessary. However, the size of a status
buffer will overwrite the memory while synchronously processing it
because it is very small. We clear the flag SK_Y2_STOPC_OWN at more
late.
 1.16 07-Feb-2008  dyoung branches: 1.16.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.15 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.14 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.13 15-Nov-2007  manu branches: 1.13.2; 1.13.4; 1.13.6;
It's 88C055, not 88CO55.
 1.12 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.11 22-Oct-2007  manu branches: 1.11.2;
Add support for Marvell 88CO55. Newer iMacs come with that chip.
 1.10 19-Jul-2007  dsl branches: 1.10.4; 1.10.6; 1.10.10; 1.10.12;
include sys/cdefs.h
 1.9 09-Jul-2007  ad branches: 1.9.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.8 04-Mar-2007  christos branches: 1.8.2; 1.8.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 31-Jan-2007  msaitoh branches: 1.7.2;
Apply OpenBSD's rev. 1.14 via patch:
> remove another Yukon Lite workaround.
 1.6 30-Jan-2007  msaitoh apply some patches from FreeBSD

o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs
 1.5 30-Jan-2007  msaitoh sync with OpenBSD-current (many bugfixes, add some devices)

if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41
 1.4 05-Jan-2007  msaitoh Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"

Original commit message:
> In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> continuing when busy flag set.
 1.3 16-Nov-2006  christos branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
__unused removal on arguments; approved by core.
 1.2 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.1 09-Sep-2006  riz branches: 1.1.2; 1.1.4; 1.1.6;
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:

- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.

Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.1.6.2 10-Dec-2006  yamt sync with head.
 1.1.6.1 22-Oct-2006  yamt sync with head
 1.1.4.1 15-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #153):
sys/dev/pci/if_skreg.h: revision 1.8
sys/dev/pci/if_msk.c: revision 1.1
sys/dev/pci/files.pci: revision 1.268
sys/dev/pci/if_mskvar.h: revision 1.1
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:
- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.
Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.1.2.2 14-Sep-2006  yamt sync with head.
 1.1.2.1 09-Sep-2006  yamt file if_msk.c was added on branch yamt-pdpolicy on 2006-09-14 12:31:33 +0000
 1.3.8.2 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.3.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.3.6.8 11-Feb-2008  yamt sync with head.
 1.3.6.7 21-Jan-2008  yamt sync with head
 1.3.6.6 15-Nov-2007  yamt sync with head.
 1.3.6.5 27-Oct-2007  yamt sync with head.
 1.3.6.4 03-Sep-2007  yamt sync with head.
 1.3.6.3 26-Feb-2007  yamt sync with head.
 1.3.6.2 30-Dec-2006  yamt sync with head.
 1.3.6.1 16-Nov-2006  yamt file if_msk.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:45 +0000
 1.3.4.4 15-Nov-2007  pavel Backout accidental commit to the release branch.
 1.3.4.3 15-Nov-2007  manu It's not 88CO55, it's 88C055
 1.3.4.2 04-Nov-2007  xtraeme Pull up following revision(s) (requested by manu in ticket #954):
sys/dev/pci/pcidevs_data.h: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/if_msk.c: revision 1.11
sys/dev/pci/pcidevs: revision 1.907

Add support for Marvell 88CO55. Newer iMacs come with that chip.
 1.3.4.1 26-Aug-2007  liamjfoy Pull up following revision(s) (requested by riz in ticket #816):
sys/dev/pci/if_skreg.h: revision 1.10
sys/dev/pci/if_skreg.h: revision 1.11
sys/dev/pci/pcidevs: revision 1.866
sys/dev/pci/if_skreg.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.36
sys/dev/pci/if_msk.c: revision 1.4
sys/dev/pci/if_msk.c: revision 1.5
sys/dev/pci/if_msk.c: revision 1.6
sys/dev/pci/if_msk.c: revision 1.7
sys/dev/pci/if_mskvar.h: revision 1.2
sys/dev/pci/if_mskvar.h: revision 1.3
Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
Original commit message:
> In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> continuing when busy flag set.

add some msk devices

sync with OpenBSD-current (many bugfixes, add some devices)
if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41

sync with if_skreg.h rev. 1.41
need more work?

apply some patches from FreeBSD
o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs

fix bit definitions for the RX FIFO Flush mode

Apply OpenBSD's rev. 1.14 via patch:
> remove another Yukon Lite workaround.
 1.3.2.4 01-Feb-2007  ad Sync with head.
 1.3.2.3 12-Jan-2007  ad Sync with head.
 1.3.2.2 18-Nov-2006  ad Sync with head.
 1.3.2.1 16-Nov-2006  ad file if_msk.c was added on branch newlock2 on 2006-11-18 21:34:30 +0000
 1.7.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.4.1 11-Jul-2007  mjf Sync with head.
 1.8.2.3 01-Sep-2007  ad Update for pool_cache API changes.
 1.8.2.2 20-Aug-2007  ad Sync with HEAD.
 1.8.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.9.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.10.12.2 19-Jul-2007  dsl include sys/cdefs.h
 1.10.12.1 19-Jul-2007  dsl file if_msk.c was added on branch matt-mips64 on 2007-07-19 22:04:23 +0000
 1.10.10.3 18-Nov-2007  bouyer Sync with HEAD
 1.10.10.2 13-Nov-2007  bouyer Sync with HEAD
 1.10.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.6.4 23-Mar-2008  matt sync with HEAD
 1.10.6.3 09-Jan-2008  matt sync with HEAD
 1.10.6.2 08-Nov-2007  matt sync with -HEAD
 1.10.6.1 06-Nov-2007  matt sync with HEAD
 1.10.4.3 21-Nov-2007  joerg Sync with HEAD.
 1.10.4.2 11-Nov-2007  joerg Sync with HEAD.
 1.10.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.11.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.11.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.13.6.2 20-Jan-2008  bouyer Sync with HEAD
 1.13.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.13.4.1 11-Dec-2007  yamt sync with head.
 1.13.2.1 26-Dec-2007  ad Sync with head.
 1.16.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.16.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.16.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.16.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.18.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.4.5 11-Aug-2010  yamt sync with head.
 1.18.4.4 11-Mar-2010  yamt sync with head
 1.18.4.3 16-Sep-2009  yamt sync with head
 1.18.4.2 16-May-2009  yamt sync with head
 1.18.4.1 04-May-2009  yamt sync with head.
 1.18.2.1 04-Jun-2008  yamt sync with head
 1.20.2.1 27-Jun-2008  simonb Sync with head.
 1.21.6.1 20-Nov-2008  snj branches: 1.21.6.1.4;
Pull up following revision(s) (requested by chris in ticket #84):
sys/dev/pci/if_skreg.h: revision 1.13
sys/dev/pci/if_msk.c: revision 1.22
Fix Yukon EC Ultra cold power up issue.
For the EC Ultra it is necessary to update some extra registers during
reset. Without doing so causes the system to hang at boot. The only
workaround I found was to PXE boot before booting into NetBSD.
This change is based on the code from FreeBSD's if_msk.c. Specifically the
msk_phy_power function.
Also add an splnet/splx across mii_tick. This matches most other network
drivers.
Change posted for review on 3rd Oct 2008 to tech-net. No feedback
received.
 1.21.6.1.4.1 09-Nov-2009  cliff - in msk_tick, only call mii_tick() if status has changed
 1.21.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.21.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.22.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.33.2.3 31-May-2011  rmind sync with head
 1.33.2.2 21-Apr-2011  rmind sync with head
 1.33.2.1 30-May-2010  rmind sync with head
 1.35.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.38.8.1 18-Feb-2012  mrg merge to -current.
 1.38.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.4.2 30-Oct-2012  yamt sync with head
 1.38.4.1 17-Apr-2012  yamt sync with head
 1.39.2.1 12-Aug-2012  martin Pull up following revision(s) (requested by riastradh in ticket #480):
sys/dev/pci/if_msk.c: revision 1.42
Fix null pointer dereference in msk_rxeof.
This triggers when processing an RX interrupt that was queued while
stopping the interface, which caused my machine to panic last night.
In this case, just drop the packet.
From OpenBSD's if_msk.c rev. 1.71.
 1.42.2.3 03-Dec-2017  jdolecek update from HEAD
 1.42.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.2.1 23-Jun-2013  tls resync from head
 1.43.4.1 18-May-2014  rmind sync with head
 1.45.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.47.2.5 05-Feb-2017  skrll Sync with HEAD
 1.47.2.4 05-Dec-2016  skrll Sync with HEAD
 1.47.2.3 09-Jul-2016  skrll Sync with HEAD
 1.47.2.2 19-Mar-2016  skrll Sync with HEAD
 1.47.2.1 06-Jun-2015  skrll Sync with HEAD
 1.51.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.54.8.2 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.54.8.1 08-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #616):
sys/dev/pci/if_msk.c: revision 1.55
sys/dev/pci/pcidevs: revision 1.1299
update entry for Marvel Yukon 8058, and fix URL for pci ids (Rocky Hotas)
 1.55.2.8 26-Jan-2019  pgoyette Sync with HEAD
 1.55.2.7 18-Jan-2019  pgoyette Synch with HEAD
 1.55.2.6 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.55.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.55.2.4 30-Sep-2018  pgoyette Ssync with HEAD
 1.55.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.55.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.55.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.67.2.4 21-Apr-2020  martin Sync with HEAD
 1.67.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.67.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.67.2.1 10-Jun-2019  christos Sync with HEAD
 1.91.2.2 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #450):

sys/dev/pci/if_msk.c: revision 1.94
sys/dev/pci/if_skreg.h: revision 1.27

Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.
 1.91.2.1 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #374):

sys/dev/pci/if_msk.c: revision 1.92

Fix order of m_freem(). Found by kASan. OK'd by jdolecek and mrg.
 1.96.2.1 29-Feb-2020  ad Sync with head.
 1.98.4.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.98.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.114.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.115.2.1 13-May-2021  thorpej Sync with HEAD.
 1.116.6.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.25 29-Apr-2020  jakllsch msk(4): Simply keep a ring of (tx) dmamaps, rather than a linked list
 1.24 29-Apr-2020  jakllsch msk(4): don't keep array of pointers to each ring descriptor

With 512 descriptors each in 2 rings this saves 4KiB (LP32) or 8KiB (LP64)
per interface.
 1.23 26-Apr-2020  jakllsch Remove written-only sk_next member of struct (m)sk_chain.
 1.22 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.21 27-Dec-2018  mrg - initialise sk_rx_hiaddr and sk_tx_hiaddr
- use MSK_ADDR_LO() and MSK_ADDR_HI()
- expand a debug message
- remove unused softc members
 1.20 21-Oct-2018  jmcneill Enable MSI support where available.
 1.19 14-Sep-2018  jakllsch msk(4): add 64-bit DMA support

portions of this change set provided by mrg@
 1.18 10-Jul-2018  jdolecek add the RX refill callout (forgot to commit with if_msk.c change)
 1.17 03-Jul-2018  jdolecek fix detach code and do it on shutdown
 1.16 03-Jul-2018  jdolecek attach the rnd source only once even with dual-port adapters
 1.15 02-Jul-2018  jdolecek sync OpenBSD if_msk.c revs 1.66-1.79 skipping framework changes and already
present changes:
- Make Yukon-2 FE+ (88E8040, 88E8042) work
- 88E8057 is a Yukon 2 Ultra 2, and this might make it work on a little
shiny green box in Japan
- Prevent null pointer dereference that could happen when we process an RX
interrupt that was queued while stopping the interface.
- Remove holdover XMAC II writes/reads inherited from sk as
they aren't required and cause problems like the 88E8072
hard locking a system when enabling macsec bypass.
- Bypass macsec on extreme/supreme based chips.
Makes my 88E8072 work.
- Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order.

towards resolution of PR kern/53301 but will need more work

tested by John Halfpenny on another 8040/Yukon-2 FE+ and reported
improving behaviour (system hang to stall) so committing as stopgap; also
tested on my SK-9E22 (Yukon-2 XL), there works without any issues both before
and after
 1.14 13-Jun-2018  jdolecek branches: 1.14.2;
sync and adapt with OpenBSD if_msk.c rev. 1.43-1.65 (modulo some
cosmetics, stuff we already had, or stuff which does not apply due
to different frameworks):

- Add support for fiber on 88E8021/22
- Avoid unnecessary resets. This should make fiber 88E8021/22 work completely
- Only probe phy's at address 0; gets rid of bogus phy's on the
Marvell Yukon 88E8036
- Remove an unused function msk_setfilt() which was copied from sk(4)
- Make msk(4) detachable
- Simplify the combination use of pci_mapreg_type()/pci_mapreg_map()
 1.13 11-Jun-2018  jdolecek adopt tx/rx buffer size computation from OpenBSD rev. 1.51 to fix
"random" msk failures

the crucial fix is that the start/end adresses are computed and
written to hw registers in number of octets (i.e. size /
sizeof(u_int64_t)), as that is actually what the hardware expects

fixes PR kern/36454 (which had fix which highlighted the trouble),
and seems likely to also fix kern/35711 and port-i386/42514
 1.12 13-Apr-2015  riastradh branches: 1.12.16;
Convert sys/dev to use <sys/rndsource.h>.
 1.11 14-Oct-2012  msaitoh branches: 1.11.14;
struct device * -> device_t change.
 1.10 02-Feb-2012  tls branches: 1.10.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.9 19-Nov-2011  tls branches: 1.9.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.8 24-Dec-2009  christos branches: 1.8.12;
- split the sk_dev
- don't program the interrupt mitigation to 0, only to set it to 1000 later.
- don't be verbose when setting the interrupt mitigation during reset, it
messes up the attach line and does not convey useful information.
 1.7 20-Jun-2008  cube Apply a similar patch as what was just applied to sk(4):

> Use a mutex instead of splvm() to protect the list of jubo-ready mbufs, as
> done with nfe(4) a while ago.
>
> Issue reported by Gary Duzan, who kindly fixed the patch I had sent him.

Lars Nordlund noted that such a change made things a lot better with his
msk(4).
 1.6 28-Apr-2008  martin branches: 1.6.2; 1.6.4;
Remove clause 3 and 4 from TNF licenses
 1.5 28-Mar-2008  kiyohara branches: 1.5.2; 1.5.4;
The status buffer must synchronize. If your CPU is cache writeback,
synchronous processing is necessary. However, the size of a status
buffer will overwrite the memory while synchronously processing it
because it is very small. We clear the flag SK_Y2_STOPC_OWN at more
late.
 1.4 04-Mar-2007  christos branches: 1.4.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 30-Jan-2007  msaitoh branches: 1.3.2;
apply some patches from FreeBSD

o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs
 1.2 30-Jan-2007  msaitoh sync with OpenBSD-current (many bugfixes, add some devices)

if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41
 1.1 09-Sep-2006  riz branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.12; 1.1.14;
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:

- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.

Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.1.14.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.12.4 03-Sep-2007  yamt sync with head.
 1.1.12.3 26-Feb-2007  yamt sync with head.
 1.1.12.2 30-Dec-2006  yamt sync with head.
 1.1.12.1 09-Sep-2006  yamt file if_mskvar.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:45 +0000
 1.1.10.1 26-Aug-2007  liamjfoy Pull up following revision(s) (requested by riz in ticket #816):
sys/dev/pci/if_skreg.h: revision 1.10
sys/dev/pci/if_skreg.h: revision 1.11
sys/dev/pci/pcidevs: revision 1.866
sys/dev/pci/if_skreg.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.36
sys/dev/pci/if_msk.c: revision 1.4
sys/dev/pci/if_msk.c: revision 1.5
sys/dev/pci/if_msk.c: revision 1.6
sys/dev/pci/if_msk.c: revision 1.7
sys/dev/pci/if_mskvar.h: revision 1.2
sys/dev/pci/if_mskvar.h: revision 1.3
Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
Original commit message:
> In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> continuing when busy flag set.

add some msk devices

sync with OpenBSD-current (many bugfixes, add some devices)
if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41

sync with if_skreg.h rev. 1.41
need more work?

apply some patches from FreeBSD
o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs

fix bit definitions for the RX FIFO Flush mode

Apply OpenBSD's rev. 1.14 via patch:
> remove another Yukon Lite workaround.
 1.1.8.2 01-Feb-2007  ad Sync with head.
 1.1.8.1 18-Nov-2006  ad Sync with head.
 1.1.4.1 15-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #153):
sys/dev/pci/if_skreg.h: revision 1.8
sys/dev/pci/if_msk.c: revision 1.1
sys/dev/pci/files.pci: revision 1.268
sys/dev/pci/if_mskvar.h: revision 1.1
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:
- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.
Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.1.2.2 14-Sep-2006  yamt sync with head.
 1.1.2.1 09-Sep-2006  yamt file if_mskvar.h was added on branch yamt-pdpolicy on 2006-09-14 12:31:33 +0000
 1.3.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.36.3 29-Jun-2008  mjf Sync with HEAD.
 1.4.36.2 02-Jun-2008  mjf Sync with HEAD.
 1.4.36.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.4.3 11-Mar-2010  yamt sync with head
 1.5.4.2 04-May-2009  yamt sync with head.
 1.5.4.1 16-May-2008  yamt sync with head.
 1.5.2.1 18-May-2008  yamt sync with head.
 1.6.4.1 27-Jun-2008  simonb Sync with head.
 1.6.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.12.2 30-Oct-2012  yamt sync with head
 1.8.12.1 17-Apr-2012  yamt sync with head
 1.9.2.1 18-Feb-2012  mrg merge to -current.
 1.10.6.2 03-Dec-2017  jdolecek update from HEAD
 1.10.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.14.1 06-Jun-2015  skrll Sync with HEAD
 1.12.16.5 18-Jan-2019  pgoyette Synch with HEAD
 1.12.16.4 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.12.16.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.12.16.2 28-Jul-2018  pgoyette Sync with HEAD
 1.12.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.14.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.2.1 10-Jun-2019  christos Sync with HEAD
 1.22 08-May-2021  thorpej Use pci_compatible_match().
 1.21 09-Dec-2018  jdolecek branches: 1.21.16;
use pci_intr_establish_xname() everywhere
 1.20 07-Jul-2016  msaitoh branches: 1.20.16; 1.20.18;
KNF. Remove extra spaces. No functional change.
 1.19 29-Mar-2014  christos branches: 1.19.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.18 27-Oct-2012  chs branches: 1.18.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.17 30-Jan-2012  drochner branches: 1.17.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.16 26-Jul-2011  dyoung branches: 1.16.2; 1.16.6;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.15 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.14 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.13 28-Apr-2008  martin branches: 1.13.14;
Remove clause 3 and 4 from TNF licenses
 1.12 10-Apr-2008  cegger branches: 1.12.2; 1.12.4;
use aprint_*_dev and device_xname
 1.11 12-Mar-2008  dyoung Use device_t and accessors.
 1.10 19-Oct-2007  ad branches: 1.10.12; 1.10.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.9 16-Nov-2006  christos branches: 1.9.8; 1.9.22; 1.9.24; 1.9.28;
__unused removal on arguments; approved by core.
 1.8 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.7 11-Dec-2005  christos branches: 1.7.20; 1.7.22;
merge ktrace-lwp.
 1.6 27-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 21-Aug-2004  thorpej branches: 1.5.4; 1.5.6;
Use ANSI function decls and make use of static.
 1.4 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.3 15-Oct-2003  simonb Fix obvious typos in a call to pci_mapreg_map().
 1.2 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.1 07-Nov-2002  martin branches: 1.1.2; 1.1.8;
Add a driver for the Myson Technology MTD803 3-in-1 Fast Ethernet Controller,
provided by Peter Bex in PR 18675.
 1.1.8.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.8.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.2 25-Aug-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 07-Nov-2002  nathanw file if_mtd_pci.c was added on branch nathanw_sa on 2002-11-11 22:11:06 +0000
 1.5.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.4.1 29-Apr-2005  kent sync with -current
 1.6.4.3 17-Mar-2008  yamt sync with head.
 1.6.4.2 27-Oct-2007  yamt sync with head.
 1.6.4.1 30-Dec-2006  yamt sync with head.
 1.7.22.2 10-Dec-2006  yamt sync with head.
 1.7.22.1 22-Oct-2006  yamt sync with head
 1.7.20.1 18-Nov-2006  ad Sync with head.
 1.9.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.9.24.2 23-Mar-2008  matt sync with HEAD
 1.9.24.1 06-Nov-2007  matt sync with HEAD
 1.9.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.9.8.1 23-Oct-2007  ad Sync with head.
 1.10.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.10.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.12.1 24-Mar-2008  keiichi sync with head.
 1.12.4.3 11-Mar-2010  yamt sync with head
 1.12.4.2 16-May-2009  yamt sync with head
 1.12.4.1 16-May-2008  yamt sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.13.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.6.1 18-Feb-2012  mrg merge to -current.
 1.16.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.2.2 30-Oct-2012  yamt sync with head
 1.16.2.1 17-Apr-2012  yamt sync with head
 1.17.6.3 03-Dec-2017  jdolecek update from HEAD
 1.17.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.2.1 18-May-2014  rmind sync with head
 1.19.6.1 09-Jul-2016  skrll Sync with HEAD
 1.20.18.1 10-Jun-2019  christos Sync with HEAD
 1.20.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.21.16.1 13-May-2021  thorpej Sync with HEAD.
 1.40 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.39 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.38 15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.37 29-Mar-2014  christos branches: 1.37.28; 1.37.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.36 26-Jul-2011  dyoung branches: 1.36.2; 1.36.12; 1.36.16;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.35 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.34 06-May-2009  cegger branches: 1.34.4; 1.34.6;
struct device * -> device_t, no functional changes intended.
 1.33 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32 28-Apr-2008  martin branches: 1.32.14;
Remove clause 3 and 4 from TNF licenses
 1.31 12-Mar-2008  cube branches: 1.31.2; 1.31.4;
Split device_t and softc for the NE2000 Ethernet chip and all its variants
and attachments. Use device_t accessors, correct types, and ANSIfy when
appropriate.
 1.30 19-Oct-2007  ad branches: 1.30.12; 1.30.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.29 16-Nov-2006  christos branches: 1.29.8; 1.29.22; 1.29.24; 1.29.28;
__unused removal on arguments; approved by core.
 1.28 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.27 11-Dec-2005  christos branches: 1.27.20; 1.27.22;
merge ktrace-lwp.
 1.26 21-Aug-2004  thorpej branches: 1.26.12;
Use ANSI function decls and make use of static.
 1.25 13-Feb-2004  wiz RealTek -> Realtek.
 1.24 02-Oct-2002  thorpej branches: 1.24.6;
Add trailing ; to CFATTACH_DECL.
 1.23 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.22 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.21 13-Nov-2001  lukem add RCSID
 1.20 08-Jul-2001  thorpej branches: 1.20.2;
Remove unnecessary include files. From Onno van der Linden.
 1.19 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.18 12-Feb-2001  thorpej branches: 1.18.2;
Adjust the way that media is initialized on DP8390-compatible
chips. The dp8390_softc now has media_init and media_fini
function pointers that do the work.
 1.17 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.16 22-Mar-2000  ws Make IPKDB working again.
Add support for i386 debugging and pci-based ne2000 boards.
 1.15 06-Mar-2000  mark Support the W89C940F alternative ID.
 1.14 09-Nov-1998  thorpej branches: 1.14.10;
Const poisoning.
 1.13 31-Oct-1998  thorpej Use the rtl80x9 common code for media selection.
 1.12 31-Oct-1998  thorpej Move the RTL8029 register definitions to <dev/ic/rtl80x9reg.h>, and add
the registers/bits present in the RTL8019 (ISA version).
 1.11 28-Oct-1998  thorpej Add support for media selection to the PCI front-end of the NE2000
driver. Currently supports:

RealTek 8029: 10base2, 10baseT, 10baseT-FDX, auto detect (but not FDX).
 1.10 27-Oct-1998  thorpej Add register definitions for PCI NE2000-compatible extenstions, allowing
control over e.g. full-duplex mode, media, etc.

Currently, only extensions for the RealTek 8029 are defined.
 1.9 27-Oct-1998  thorpej Cosmetic changes in product lookup, to match other drivers.
 1.8 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.7 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.6 05-May-1998  thorpej Add 5 more NE-2000 compatible PCI Ethernet interfaces. XXX Note that some
of these may need revision in pcidevs.
 1.5 10-Apr-1998  thorpej Add support for the VIA Technologies VT86C926, from Kazuki Sakamoto,
PR #5256.
 1.4 27-Oct-1997  thorpej Oops, missed one in previous.
 1.3 27-Oct-1997  thorpej Update for new pcidevs entry for Winbond NE2000-compatible Ethernet ASIC.
 1.2 14-Oct-1997  thorpej branches: 1.2.2;
Pulldown from marc-pcmcia branch: PCI front-end for the "ne" driver.
 1.1 14-Oct-1997  thorpej branches: 1.1.2;
file if_ne_pci.c was initially added on branch marc-pcmcia.
 1.1.2.2 14-Oct-1997  thorpej Mark this interface as enabled right from the get-go.
 1.1.2.1 14-Oct-1997  thorpej Split off NE2000 support from the ISA "ed" driver, and create a new "ne"
driver that deals with NE2000s and compatibles on ISA, PCI, and PCMCIA
busses.

This driver uses the generic DP8390 core chipset back-end.
 1.2.2.1 27-Oct-1997  thorpej Update from trunk: Update for new Winbond NE2000-compatible Ethernet ASIC
description.
 1.14.10.3 12-Mar-2001  bouyer Sync with HEAD.
 1.14.10.2 05-Jan-2001  bouyer Sync with HEAD
 1.14.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.18.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.18.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.18.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.20.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.20.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.24.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.24.6.2 25-Aug-2004  skrll Sync with HEAD.
 1.24.6.1 03-Aug-2004  skrll Sync with HEAD
 1.26.12.3 17-Mar-2008  yamt sync with head.
 1.26.12.2 27-Oct-2007  yamt sync with head.
 1.26.12.1 30-Dec-2006  yamt sync with head.
 1.27.22.2 10-Dec-2006  yamt sync with head.
 1.27.22.1 22-Oct-2006  yamt sync with head
 1.27.20.1 18-Nov-2006  ad Sync with head.
 1.29.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.29.24.2 23-Mar-2008  matt sync with HEAD
 1.29.24.1 06-Nov-2007  matt sync with HEAD
 1.29.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.29.8.1 23-Oct-2007  ad Sync with head.
 1.30.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.30.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.30.12.1 24-Mar-2008  keiichi sync with head.
 1.31.4.2 16-May-2009  yamt sync with head
 1.31.4.1 16-May-2008  yamt sync with head.
 1.31.2.1 18-May-2008  yamt sync with head.
 1.32.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.34.4.1 31-May-2011  rmind sync with head
 1.36.16.1 18-May-2014  rmind sync with head
 1.36.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.30.1 10-Jun-2019  christos Sync with HEAD
 1.37.28.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.37.28.1 28-Jul-2018  pgoyette Sync with HEAD
 1.2 31-Oct-1998  thorpej Move the RTL8029 register definitions to <dev/ic/rtl80x9reg.h>, and add
the registers/bits present in the RTL8019 (ISA version).
 1.1 27-Oct-1998  thorpej Add register definitions for PCI NE2000-compatible extenstions, allowing
control over e.g. full-duplex mode, media, etc.

Currently, only extensions for the RealTek 8029 are defined.
 1.81 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.80 22-Jan-2022  martin branches: 1.80.10;
Explicitly cast a __MASK(40) to bus_addr_t (for 32bit bus_addr_t archs)
 1.79 22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.78 13-Mar-2020  msaitoh Improve error check:

- We check PHY register read error correctly (timeout and NFE_PHY_ERROR), so
don't check NFE_PHY_DATA register's value with 0xffffffff or 0. At least,
some registers may have 0.
- Check NFE_PHY_ERROR bit in nfe_miibus_writereg().
- Improve debug printf
 1.77 08-Mar-2020  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.76 01-Mar-2020  thorpej Add explicit casts in bus_dmatag_subregion() calls to avoid overflow /
truncation warnings on 32-bit platforms.
 1.75 01-Mar-2020  thorpej - Range-limit our DMA tag to 40-bit.
- Eliminate __LP64__ ifdefs.
 1.74 04-Feb-2020  thorpej Use ifmedia_fini().
 1.73 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.72 13-Sep-2019  msaitoh branches: 1.72.2;
if_flags is neither int nor short. It's unsigned short.
 1.71 09-Jul-2019  msaitoh branches: 1.71.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.70 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.69 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.68 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.67 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.66 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.65 26-Jun-2018  msaitoh branches: 1.65.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.64 26-Sep-2017  knakahara branches: 1.64.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.63 15-Dec-2016  ozaki-r branches: 1.63.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.62 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.61 10-Jun-2016  ozaki-r branches: 1.61.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.60 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.59 29-Mar-2014  christos branches: 1.59.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.58 30-Mar-2013  christos branches: 1.58.4;
remove trailing whitespace
 1.57 23-Sep-2012  chs use 64-bit DMA where possible.
 1.56 22-Jul-2012  matt branches: 1.56.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.55 30-Jan-2012  drochner branches: 1.55.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.54 23-Jan-2011  tsutsui branches: 1.54.4; 1.54.8;
Pull the following fix from OpenBSD:
http://www.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/if_nfe.c#rev1.97
>> Some nfe(4)/rlphy(4) combos don't work, because the PHY responds to all
>> addresses on the mii bus. As a countereasure, only attach the first PHY we
>> encounter. It is very unlikely we're going to ever see nfe(4) with multiple
>> PHYs. The same is probably true for any modern NIC.

Should suppress bogus ukphy30 noted in PR kern/42950.
No bad side effect on my nfe(4) which didn't get ghosts:
---
nfe0 at pci0 dev 5 function 0: NVIDIA nForce3 Ethernet #4 (rev. 0xa2)
:
rlphy0 at nfe0 phy 1: RTL8201L 10/100 media interface, rev. 1
rlphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
 1.53 03-Nov-2010  jakllsch branches: 1.53.2; 1.53.4;
Make nfe(4) detachable.
 1.52 02-Nov-2010  jakllsch Explicitly set PCI_COMMAND_MASTER_ENABLE.
 1.51 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.50 24-Feb-2010  dyoung branches: 1.50.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.49 19-Jan-2010  pooka branches: 1.49.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.48 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.47 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.46 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.45 14-Jun-2009  cegger use __arraycount
 1.44 18-Mar-2009  cegger bcmp -> memcmp
 1.43 01-Mar-2009  cegger bzero -> memset per request from martin@
bcopy -> memcpy

XXX Would changing bcmp to memcpy be a functional change regarding its return value?
 1.42 01-Mar-2009  cegger when nfe_attach() fails, free all resources including
interrupt map, interrupt handler and dma maps.
Also prevent call to bus_dmamap_destroy() when bus_dmamap_create() failed.
The nfe_free_* routines assume, the map pointers are NULL but they
are actually undefined. Make the assumption true by making them NULL
in the error path of bus_dmamap_create().

All together, this fixes crashes when nfe_attach() fails.
ok martin@
 1.41 01-Mar-2009  cegger MCP79 supports JUMBO frames.
Information from Linux driver.
Patch presented on current-users@ http://mail-index.netbsd.org/current-users/2009/02/11/msg008037.html
 1.40 12-Feb-2009  cegger flow-control support for MCP65 chip.
XXX other chips may also have flow-control, but only on MCP65 tested.
ok cube@
 1.39 18-Jan-2009  cegger branches: 1.39.2;
Bracket IRQ masking around nfe_intr() in nfe_init() rather inside nfe_intr().
Proposed by dyoung@ in PR 40345. Should fix PR 40345.
 1.38 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.37 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.36 17-Jun-2008  cube branches: 1.36.2; 1.36.4; 1.36.6;
Use MUTEX_DEFAULT to initialise the mutex, per martin@'s input.
 1.35 25-May-2008  jmcneill branches: 1.35.2;
Based on changes to nfe_attach in r1.27, wake newer chips from powerdown
mode on resume as well as at attach time.
 1.34 20-Apr-2008  cube branches: 1.34.2; 1.34.4;
Restore jumbo frame support and protect access to the DMA space for
received frames with a mutex.

Tested by Paul Goyette, Martin Husemann and myself.
 1.33 17-Apr-2008  christos branches: 1.33.2;
join line for symmetry.
 1.32 17-Apr-2008  xtraeme Make this build again... HI XTOS.
 1.31 17-Apr-2008  christos sync with openbsd; fixes observed corruption issues.
 1.30 26-Mar-2008  cube Split device_t and softc, and related cosmetic changes.
 1.29 24-Feb-2008  isaki Minor style fix.
 1.28 07-Feb-2008  dyoung branches: 1.28.2; 1.28.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.27 26-Jan-2008  tsutsui Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.

Tested by wiz@ in PR kern/37868.
 1.26 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.25 17-Dec-2007  tsutsui Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
 1.24 09-Dec-2007  jmcneill branches: 1.24.2;
Merge jmcneill-pm branch.
 1.23 14-Nov-2007  xtraeme branches: 1.23.2; 1.23.4;
Add the MCP{67,73} products on nfe_attach().
 1.22 14-Nov-2007  xtraeme Attach to NVIDIA MCP67/73 Ethernet controllers.
 1.21 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.20 19-Oct-2007  ad branches: 1.20.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.19 24-Sep-2007  cube branches: 1.19.2;
- If the chip doesn't support jumbo frames, don't use bus_dmamap_load_mbuf
which expects a properly filled mbuf chain, but bus_dmamap_load for the
mbuf storage space instead.

- If the chip supports jumbo frames
+ keep track of which RX descriptor uses which jumbo mbuf buffer, so
that we can rewrite the physaddr field of the descriptor later, as it
might be partially overwritten by the hw
+ when we're out of jumbo mbufs, and if the packet is small enough,
copy it into a cluster mbuf

Those changes make my nfe(4) stable in both cases (defining NFE_NO_JUMBO
for the first one).
 1.18 24-Sep-2007  cube From OpenBSD, rev 1.72:

In nfe_start() do a fast return if IFF_OACTIVE is set, in
this case we need a Tx interrupt to clean up the DMA ring
before if_start can be properly called.
 1.17 01-Sep-2007  dyoung branches: 1.17.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.16 09-Jul-2007  ad branches: 1.16.2; 1.16.6; 1.16.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.15 04-Mar-2007  christos branches: 1.15.2; 1.15.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 28-Feb-2007  tsutsui Apply patches which may fix RX stall problem on nfe(4):
- make DMA descriptors volatile to avoid possible unintended reordering
which might cause some race conditions
- process interrupts until all NFE_IRQ_WANTED bits are handled

and also put misc fixes:
- return 1 and call nfe_start() in nfe_intr() only if any own interrupts
are actually handled
- use bus_dmamap_load_mbuf(9) for RX mbufs rather than bus_dmamap_load(9)
with mtod(9) and MCLBYTES
- check sc->txq.queued to see if TX descriptors are queued or handled
in nfe_start() and nfe_txeof()
- use proper BUS_DMASYNC_{PRE,POST} ops
- prepare and use NFE_[RT]X_NEXTDESC() macro
- rename NFE_TX_TCP_CSUM to NFE_TX_TCP_UDP_CSUM since it also enables
hardware udp4csum-tx for UDP4 packets
- some minor optimization
- misc KNF

Tested and confirmed by matthew green by
"to send >25MB/sec to nfe0 for over one hour,"
and also tested by me (with light TRX load on 100baseTX though)
for a month.
 1.13 09-Jan-2007  tsutsui branches: 1.13.2;
Enable hardware checksum support by hardware info taken from FreeBSD.
Tested on nForce3 250 and nForce4 by Chuck Silvers, Cesar Catrian Carreno,
and me.
 1.12 05-Jan-2007  jmcneill A few changes to make this work on the Microsoft Xbox. Should also help
with other users who have been experiencing watchdog timeouts:
* Mask all interrupts while servicing a tx or rx interrupt.
* On init, clear IRQ status registers (workaround for buggy netbooters).
 1.11 01-Jan-2007  tsutsui Pull a TX timeout fix from OpenBSD:
> Defer setting of the valid bit in the first TX descriptor after
> all descriptors have been setup. Otherwise, hardware may start
> processing descriptors faster than us and crap out.
> Fixes "watchdog timeout" errors.
>
> Original idea from Matthew Dillon @DragonFly.
 1.10 01-Jan-2007  tsutsui Minor style fixes in nfe_attach:
- print PCI device name and revision
- print interrupt and Ethernet address like other devices

Before:
---
nfe0 at pci0 dev 5 function 0LKLN: Picked IRQ 20 with weight 1
: ioapic0 pin 20 (irq 9), address xx:xx:xx:xx:xx:xx

After:
---
nfe0 at pci0 dev 5 function 0: NVIDIA nForce3 ethernet #4 (rev. 0xa2)
LKLN: Picked IRQ 20 with weight 1
nfe0: interrupting at ioapic0 pin 20 (irq 9)
nfe0: Ethernet address xx:xx:xx:xx:xx:xx

(note "Picked IRQ" message is logged by aprint_verbose(9) in acpi(4))
 1.9 27-Dec-2006  alc remove the KASSERT() introduced in last commit and use VLAN_OUTPUT_TAG() macro.

tested by martin@
pointed out and ok by pavel@, also ok from christos@
 1.8 25-Dec-2006  alc CID-3667: check if 'mtag != NULL' before dereferencing it
 1.7 16-Nov-2006  christos branches: 1.7.2;
__unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.4 03-Sep-2006  xtraeme branches: 1.4.2; 1.4.4; 1.4.6;
Add support for MCP61/65 controllers... from obsd.
 1.3 26-Mar-2006  chs branches: 1.3.2; 1.3.4; 1.3.6; 1.3.12; 1.3.14;
work around another mbuf leak, the hardware doesn't seem
to work quite the way that the driver expects.
 1.2 16-Mar-2006  chs branches: 1.2.2;
handle another difference between the BSDs:
free the original mbuf in the jumbo-free callback too.
 1.1 12-Mar-2006  chs branches: 1.1.2;
add nfe driver and manpage from OpenBSD.
 1.1.2.4 03-Sep-2006  yamt sync with head.
 1.1.2.3 01-Apr-2006  yamt sync with head.
 1.1.2.2 13-Mar-2006  yamt sync with head.
 1.1.2.1 12-Mar-2006  yamt file if_nfe.c was added on branch yamt-pdpolicy on 2006-03-13 09:07:26 +0000
 1.2.2.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.3.14.1 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #112):
sys/dev/pci/if_nfe.c: revision 1.4
sys/dev/pci/pcidevs: revision 1.824
- Add nForce MCP61/65 LAN controllers... from obsd.
- Improve description in some nForce controllers as well.
Add support for MCP61/65 controllers... from obsd.
 1.3.12.11 27-Feb-2008  yamt sync with head.
 1.3.12.10 11-Feb-2008  yamt sync with head.
 1.3.12.9 04-Feb-2008  yamt sync with head.
 1.3.12.8 21-Jan-2008  yamt sync with head
 1.3.12.7 15-Nov-2007  yamt sync with head.
 1.3.12.6 27-Oct-2007  yamt sync with head.
 1.3.12.5 03-Sep-2007  yamt sync with head.
 1.3.12.4 26-Feb-2007  yamt sync with head.
 1.3.12.3 30-Dec-2006  yamt sync with head.
 1.3.12.2 21-Jun-2006  yamt sync with head.
 1.3.12.1 26-Mar-2006  yamt file if_nfe.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:04 +0000
 1.3.6.2 22-Apr-2006  simonb Sync with head.
 1.3.6.1 26-Mar-2006  simonb file if_nfe.c was added on branch simonb-timecounters on 2006-04-22 11:39:14 +0000
 1.3.4.4 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
sys/dev/pci/if_nfe.c: revision 1.3
work around another mbuf leak, the hardware doesn't seem
to work quite the way that the driver expects.
 1.3.4.3 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
sys/dev/pci/if_nfe.c: revision 1.2
handle another difference between the BSDs:
free the original mbuf in the jumbo-free callback too.
 1.3.4.2 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
share/man/man4/Makefile: revision 1.377
sys/dev/pci/if_nfe.c: revision 1.1
sys/dev/pci/if_nfereg.h: revision 1.1
share/man/man4/nfe.4: revision 1.1
sys/dev/pci/if_nfevar.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.863
add nfe driver and manpage from OpenBSD.
 1.3.4.1 26-Mar-2006  snj file if_nfe.c was added on branch netbsd-3 on 2006-04-20 03:11:14 +0000
 1.3.2.2 19-Apr-2006  elad sync with head.
 1.3.2.1 26-Mar-2006  elad file if_nfe.c was added on branch elad-kernelauth on 2006-04-19 03:25:35 +0000
 1.4.6.2 10-Dec-2006  yamt sync with head.
 1.4.6.1 22-Oct-2006  yamt sync with head
 1.4.4.2 09-Sep-2006  rpaulo sync with head
 1.4.4.1 03-Sep-2006  rpaulo file if_nfe.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:17 +0000
 1.4.2.2 12-Jan-2007  ad Sync with head.
 1.4.2.1 18-Nov-2006  ad Sync with head.
 1.7.2.3 23-Feb-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1061):
sys/dev/pci/if_nfe.c: revision 1.22, 1.23, 1.25, 1.27
sys/dev/pci/pcidevs: revision 1.914
sys/dev/pci/if_nfereg.h: revision 1.5, 1.6
share/man/man4/nfe.4: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.5, 1.6
Add NVIDIA MCP7[37] devices, from OpenBSD.
Attach to NVIDIA MCP67/73 Ethernet controllers.
Add the MCP{67,73} products on nfe_attach().
Sync with reality.
Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.
Tested by wiz@ in PR kern/37868.
 1.7.2.2 07-Oct-2007  pavel Pull up following revisions (requested by cube in ticket #920):
sys/dev/pci/if_nfe.c: revision 1.14, 1.18-1.19
sys/dev/pci/if_nfereg.h: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.3
Apply patches which may fix RX stall problem on nfe(4):
- make DMA descriptors volatile to avoid possible unintended reordering
which might cause some race conditions
- process interrupts until all NFE_IRQ_WANTED bits are handled
and also put misc fixes:
- return 1 and call nfe_start() in nfe_intr() only if any own interrupts
are actually handled
- use bus_dmamap_load_mbuf(9) for RX mbufs rather than bus_dmamap_load(9)
with mtod(9) and MCLBYTES
- check sc->txq.queued to see if TX descriptors are queued or handled
in nfe_start() and nfe_txeof()
- use proper BUS_DMASYNC_{PRE,POST} ops
- prepare and use NFE_[RT]X_NEXTDESC() macro
- rename NFE_TX_TCP_CSUM to NFE_TX_TCP_UDP_CSUM since it also enables
hardware udp4csum-tx for UDP4 packets
- some minor optimization
- misc KNF
Tested and confirmed by matthew green by
"to send >25MB/sec to nfe0 for over one hour,"
and also tested by me (with light TRX load on 100baseTX though)
for a month.


From OpenBSD, rev 1.72:
In nfe_start() do a fast return if IFF_OACTIVE is set, in
this case we need a Tx interrupt to clean up the DMA ring
before if_start can be properly called.


- If the chip doesn't support jumbo frames, don't use bus_dmamap_load_mbuf
which expects a properly filled mbuf chain, but bus_dmamap_load for the
mbuf storage space instead.
- If the chip supports jumbo frames
+ keep track of which RX descriptor uses which jumbo mbuf buffer, so
that we can rewrite the physaddr field of the descriptor later, as it
might be partially overwritten by the hw
+ when we're out of jumbo mbufs, and if the packet is small enough,
copy it into a cluster mbuf
Those changes make my nfe(4) stable in both cases (defining NFE_NO_JUMBO
for the first one).
 1.7.2.1 19-Jan-2007  bouyer branches: 1.7.2.1.2;
Pull up following revision(s) (requested by tsutsui in ticket #370):
sys/dev/pci/if_nfe.c: revision 1.8 - 1.13
sys/dev/pci/if_nfereg.h: revision 1.2 - 1.3
several bug fixes and hardware checksum support for nfs(4).
 1.7.2.1.2.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.7.2.1.2.1 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.13.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.4 23-Oct-2007  ad Sync with head.
 1.15.2.3 09-Oct-2007  ad Sync with head.
 1.15.2.2 01-Sep-2007  ad Update for pool_cache API changes.
 1.15.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.16.8.4 23-Mar-2008  matt sync with HEAD
 1.16.8.3 09-Jan-2008  matt sync with HEAD
 1.16.8.2 08-Nov-2007  matt sync with -HEAD
 1.16.8.1 06-Nov-2007  matt sync with HEAD
 1.16.6.8 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.16.6.7 14-Nov-2007  joerg Sync with HEAD.
 1.16.6.6 11-Nov-2007  joerg Sync with HEAD.
 1.16.6.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.16.6.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.6.3 05-Oct-2007  joerg Convert nfe(4) to PNP power management.
 1.16.6.2 02-Oct-2007  joerg Sync with HEAD.
 1.16.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.16.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.17.2.1 06-Oct-2007  yamt sync with head.
 1.19.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.19.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.19.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.20.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.20.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.23.4.1 11-Dec-2007  yamt sync with head.
 1.23.2.1 26-Dec-2007  ad Sync with head.
 1.24.2.2 20-Jan-2008  bouyer Sync with HEAD
 1.24.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.28.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.28.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.28.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.28.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.28.2.1 24-Mar-2008  keiichi sync with head.
 1.33.2.2 04-Jun-2008  yamt sync with head
 1.33.2.1 18-May-2008  yamt sync with head.
 1.34.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.34.2.5 11-Aug-2010  yamt sync with head.
 1.34.2.4 11-Mar-2010  yamt sync with head
 1.34.2.3 16-Sep-2009  yamt sync with head
 1.34.2.2 20-Jun-2009  yamt sync with head
 1.34.2.1 04-May-2009  yamt sync with head.
 1.35.2.1 18-Jun-2008  simonb Sync with head.
 1.36.6.1 02-Mar-2009  snj Pull up following revision(s) (requested by cegger in ticket #540):
sys/dev/pci/if_nfe.c: revision 1.42
when nfe_attach() fails, free all resources including
interrupt map, interrupt handler and dma maps.
Also prevent call to bus_dmamap_destroy() when bus_dmamap_create() failed.
The nfe_free_* routines assume, the map pointers are NULL but they
are actually undefined. Make the assumption true by making them NULL
in the error path of bus_dmamap_create().
All together, this fixes crashes when nfe_attach() fails.
ok martin@
 1.36.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.36.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.36.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.36.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.39.2.2 23-Jul-2009  jym Sync with HEAD.
 1.39.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.49.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.49.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.50.2.2 05-Mar-2011  rmind sync with head
 1.50.2.1 30-May-2010  rmind sync with head
 1.53.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.53.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.54.8.1 18-Feb-2012  mrg merge to -current.
 1.54.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.54.4.2 30-Oct-2012  yamt sync with head
 1.54.4.1 17-Apr-2012  yamt sync with head
 1.55.2.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #685):
sys/dev/pci/if_nfe.c: revision 1.57
use 64-bit DMA where possible.
 1.56.2.4 03-Dec-2017  jdolecek update from HEAD
 1.56.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56.2.2 23-Jun-2013  tls resync from head
 1.56.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.58.4.1 18-May-2014  rmind sync with head
 1.59.6.3 05-Feb-2017  skrll Sync with HEAD
 1.59.6.2 09-Jul-2016  skrll Sync with HEAD
 1.59.6.1 19-Mar-2016  skrll Sync with HEAD
 1.61.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.63.8.2 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.63.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.64.2.3 26-Jan-2019  pgoyette Sync with HEAD
 1.64.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.64.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.65.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.65.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.65.2.1 10-Jun-2019  christos Sync with HEAD
 1.71.2.1 19-Mar-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #786):

sys/dev/pci/if_nfe.c: revision 1.77
sys/dev/pci/if_nfe.c: revision 1.78
sys/dev/mii/atphy.c: revision 1.28
sys/dev/mii/atphy.c: revision 1.29
sys/dev/mii/miidevs: revision 1.166

Use unsigned to avoid undefined behavior. Found by kUBSan.
0x001374 is non-bitreversed value of Attansic OUI(0x00c82e).
Attansic/Atheros correctly uses ID1 and ID2 register, so delete all 0x001374
related entries.

Improve error check:
- We check PHY register read error correctly (timeout and NFE_PHY_ERROR), so
don't check NFE_PHY_DATA register's value with 0xffffffff or 0. At least,
some registers may have 0.
- Check NFE_PHY_ERROR bit in nfe_miibus_writereg().
- Improve debug printf

Fix a bug that atphy(4) doesn't work with Attansic L2 rev. 1.
Reported by Rocky Hotas.

- On ASUS M2N-MX SE Plus (NVIDIA MCP61 with Attansic L2 rev. 1), changing
debug port 0x29's value makes the next PHY read fail with error. Read any
register to ignore this problem if the PHY is Attansic L2 revision 1.
I don't know if this problem is from L2 rev. 1 itself or from the
combination because I have only one machine which has L2 rev. "1".
At least, ASUS eee pc 900 (Attansic L2 rev. "2") has no this problem.
- Add comment. AR8021 document has no description about the power saving
control register(debug port 0x29).
- Add comment. AR8031 document says the lower 14 bits are reserved and the
default value is 0x36d0. Shouldn't we clear those bits?
- I have no document neither L1(F1) nor L2(F2), so I don't know whether the
debug port access is correct or not.
Tested with the following machines:
- ASUS P5B SE, L1 rev. 5, age(4)
- ASUS K50IJ, L1 rev. 9, ale(4)
- ASUS eee pc 900, L2 rev. 2, lii(4)
- ASUS M2N-MX SE Plus, L2 rev. 1, nfe(4)
- Intel DP55WB, 82578(AR8021 rev. 2), wm(4)
- Dell inspiron 14z, AR0835 rev. 9, alc(4)
 1.72.2.1 29-Feb-2020  ad Sync with head.
 1.80.10.1 02-Aug-2025  perseant Sync with HEAD
 1.8 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.7 17-Apr-2008  christos branches: 1.7.92;
sync with openbsd; fixes observed corruption issues.
 1.6 26-Jan-2008  tsutsui branches: 1.6.6;
Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.

Tested by wiz@ in PR kern/37868.
 1.5 17-Dec-2007  tsutsui Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
 1.4 28-Feb-2007  tsutsui branches: 1.4.16; 1.4.22; 1.4.24; 1.4.28;
Apply patches which may fix RX stall problem on nfe(4):
- make DMA descriptors volatile to avoid possible unintended reordering
which might cause some race conditions
- process interrupts until all NFE_IRQ_WANTED bits are handled

and also put misc fixes:
- return 1 and call nfe_start() in nfe_intr() only if any own interrupts
are actually handled
- use bus_dmamap_load_mbuf(9) for RX mbufs rather than bus_dmamap_load(9)
with mtod(9) and MCLBYTES
- check sc->txq.queued to see if TX descriptors are queued or handled
in nfe_start() and nfe_txeof()
- use proper BUS_DMASYNC_{PRE,POST} ops
- prepare and use NFE_[RT]X_NEXTDESC() macro
- rename NFE_TX_TCP_CSUM to NFE_TX_TCP_UDP_CSUM since it also enables
hardware udp4csum-tx for UDP4 packets
- some minor optimization
- misc KNF

Tested and confirmed by matthew green by
"to send >25MB/sec to nfe0 for over one hour,"
and also tested by me (with light TRX load on 100baseTX though)
for a month.
 1.3 09-Jan-2007  tsutsui branches: 1.3.2;
Enable hardware checksum support by hardware info taken from FreeBSD.
Tested on nForce3 250 and nForce4 by Chuck Silvers, Cesar Catrian Carreno,
and me.
 1.2 05-Jan-2007  jmcneill Fix incorrect definition of wake-on-LAN magic number, from FreeBSD.
 1.1 12-Mar-2006  chs branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10; 1.1.16; 1.1.20; 1.1.22; 1.1.26;
add nfe driver and manpage from OpenBSD.
 1.1.26.3 23-Feb-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1061):
sys/dev/pci/if_nfe.c: revision 1.22, 1.23, 1.25, 1.27
sys/dev/pci/pcidevs: revision 1.914
sys/dev/pci/if_nfereg.h: revision 1.5, 1.6
share/man/man4/nfe.4: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.5, 1.6
Add NVIDIA MCP7[37] devices, from OpenBSD.
Attach to NVIDIA MCP67/73 Ethernet controllers.
Add the MCP{67,73} products on nfe_attach().
Sync with reality.
Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.
Tested by wiz@ in PR kern/37868.
 1.1.26.2 07-Oct-2007  pavel Pull up following revisions (requested by cube in ticket #920):
sys/dev/pci/if_nfe.c: revision 1.14, 1.18-1.19
sys/dev/pci/if_nfereg.h: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.3
Apply patches which may fix RX stall problem on nfe(4):
- make DMA descriptors volatile to avoid possible unintended reordering
which might cause some race conditions
- process interrupts until all NFE_IRQ_WANTED bits are handled
and also put misc fixes:
- return 1 and call nfe_start() in nfe_intr() only if any own interrupts
are actually handled
- use bus_dmamap_load_mbuf(9) for RX mbufs rather than bus_dmamap_load(9)
with mtod(9) and MCLBYTES
- check sc->txq.queued to see if TX descriptors are queued or handled
in nfe_start() and nfe_txeof()
- use proper BUS_DMASYNC_{PRE,POST} ops
- prepare and use NFE_[RT]X_NEXTDESC() macro
- rename NFE_TX_TCP_CSUM to NFE_TX_TCP_UDP_CSUM since it also enables
hardware udp4csum-tx for UDP4 packets
- some minor optimization
- misc KNF
Tested and confirmed by matthew green by
"to send >25MB/sec to nfe0 for over one hour,"
and also tested by me (with light TRX load on 100baseTX though)
for a month.


From OpenBSD, rev 1.72:
In nfe_start() do a fast return if IFF_OACTIVE is set, in
this case we need a Tx interrupt to clean up the DMA ring
before if_start can be properly called.


- If the chip doesn't support jumbo frames, don't use bus_dmamap_load_mbuf
which expects a properly filled mbuf chain, but bus_dmamap_load for the
mbuf storage space instead.
- If the chip supports jumbo frames
+ keep track of which RX descriptor uses which jumbo mbuf buffer, so
that we can rewrite the physaddr field of the descriptor later, as it
might be partially overwritten by the hw
+ when we're out of jumbo mbufs, and if the packet is small enough,
copy it into a cluster mbuf
Those changes make my nfe(4) stable in both cases (defining NFE_NO_JUMBO
for the first one).
 1.1.26.1 19-Jan-2007  bouyer branches: 1.1.26.1.2;
Pull up following revision(s) (requested by tsutsui in ticket #370):
sys/dev/pci/if_nfe.c: revision 1.8 - 1.13
sys/dev/pci/if_nfereg.h: revision 1.2 - 1.3
several bug fixes and hardware checksum support for nfs(4).
 1.1.26.1.2.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.1.26.1.2.1 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 12-Mar-2006  rpaulo file if_nfereg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:17 +0000
 1.1.20.1 12-Jan-2007  ad Sync with head.
 1.1.16.6 04-Feb-2008  yamt sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 26-Feb-2007  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 12-Mar-2006  yamt file if_nfereg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:04 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 12-Mar-2006  simonb file if_nfereg.h was added on branch simonb-timecounters on 2006-04-22 11:39:14 +0000
 1.1.8.2 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
share/man/man4/Makefile: revision 1.377
sys/dev/pci/if_nfe.c: revision 1.1
sys/dev/pci/if_nfereg.h: revision 1.1
share/man/man4/nfe.4: revision 1.1
sys/dev/pci/if_nfevar.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.863
add nfe driver and manpage from OpenBSD.
 1.1.8.1 12-Mar-2006  snj file if_nfereg.h was added on branch netbsd-3 on 2006-04-20 03:11:14 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 12-Mar-2006  elad file if_nfereg.h was added on branch elad-kernelauth on 2006-04-19 03:25:35 +0000
 1.1.2.2 13-Mar-2006  yamt sync with head.
 1.1.2.1 12-Mar-2006  yamt file if_nfereg.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:26 +0000
 1.3.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.24.1 26-Dec-2007  ad Sync with head.
 1.4.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.16.2 23-Mar-2008  matt sync with HEAD
 1.4.16.1 09-Jan-2008  matt sync with HEAD
 1.6.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.92.1 10-Jun-2019  christos Sync with HEAD
 1.12 01-Mar-2020  thorpej - Range-limit our DMA tag to 40-bit.
- Eliminate __LP64__ ifdefs.
 1.11 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.10 03-Nov-2010  jakllsch branches: 1.10.60;
Make nfe(4) detachable.
 1.9 20-Apr-2008  cube branches: 1.9.22; 1.9.24;
Restore jumbo frame support and protect access to the DMA space for
received frames with a mutex.

Tested by Paul Goyette, Martin Husemann and myself.
 1.8 17-Apr-2008  christos branches: 1.8.2;
sync with openbsd; fixes observed corruption issues.
 1.7 26-Mar-2008  cube Split device_t and softc, and related cosmetic changes.
 1.6 26-Jan-2008  tsutsui branches: 1.6.6;
Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.

Tested by wiz@ in PR kern/37868.
 1.5 17-Dec-2007  tsutsui Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
 1.4 09-Dec-2007  jmcneill branches: 1.4.2;
Merge jmcneill-pm branch.
 1.3 24-Sep-2007  cube branches: 1.3.4; 1.3.6; 1.3.8;
- If the chip doesn't support jumbo frames, don't use bus_dmamap_load_mbuf
which expects a properly filled mbuf chain, but bus_dmamap_load for the
mbuf storage space instead.

- If the chip supports jumbo frames
+ keep track of which RX descriptor uses which jumbo mbuf buffer, so
that we can rewrite the physaddr field of the descriptor later, as it
might be partially overwritten by the hw
+ when we're out of jumbo mbufs, and if the packet is small enough,
copy it into a cluster mbuf

Those changes make my nfe(4) stable in both cases (defining NFE_NO_JUMBO
for the first one).
 1.2 04-Mar-2007  christos branches: 1.2.2; 1.2.14; 1.2.16; 1.2.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.1 12-Mar-2006  chs branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10; 1.1.16; 1.1.22; 1.1.26; 1.1.28; 1.1.32;
add nfe driver and manpage from OpenBSD.
 1.1.32.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.1.32.1 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.1.28.1 12-Mar-2007  rmind Sync with HEAD.
 1.1.26.2 23-Feb-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1061):
sys/dev/pci/if_nfe.c: revision 1.22, 1.23, 1.25, 1.27
sys/dev/pci/pcidevs: revision 1.914
sys/dev/pci/if_nfereg.h: revision 1.5, 1.6
share/man/man4/nfe.4: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.5, 1.6
Add NVIDIA MCP7[37] devices, from OpenBSD.
Attach to NVIDIA MCP67/73 Ethernet controllers.
Add the MCP{67,73} products on nfe_attach().
Sync with reality.
Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.
Tested by wiz@ in PR kern/37868.
 1.1.26.1 07-Oct-2007  pavel Pull up following revisions (requested by cube in ticket #920):
sys/dev/pci/if_nfe.c: revision 1.14, 1.18-1.19
sys/dev/pci/if_nfereg.h: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.3
Apply patches which may fix RX stall problem on nfe(4):
- make DMA descriptors volatile to avoid possible unintended reordering
which might cause some race conditions
- process interrupts until all NFE_IRQ_WANTED bits are handled
and also put misc fixes:
- return 1 and call nfe_start() in nfe_intr() only if any own interrupts
are actually handled
- use bus_dmamap_load_mbuf(9) for RX mbufs rather than bus_dmamap_load(9)
with mtod(9) and MCLBYTES
- check sc->txq.queued to see if TX descriptors are queued or handled
in nfe_start() and nfe_txeof()
- use proper BUS_DMASYNC_{PRE,POST} ops
- prepare and use NFE_[RT]X_NEXTDESC() macro
- rename NFE_TX_TCP_CSUM to NFE_TX_TCP_UDP_CSUM since it also enables
hardware udp4csum-tx for UDP4 packets
- some minor optimization
- misc KNF
Tested and confirmed by matthew green by
"to send >25MB/sec to nfe0 for over one hour,"
and also tested by me (with light TRX load on 100baseTX though)
for a month.


From OpenBSD, rev 1.72:
In nfe_start() do a fast return if IFF_OACTIVE is set, in
this case we need a Tx interrupt to clean up the DMA ring
before if_start can be properly called.


- If the chip doesn't support jumbo frames, don't use bus_dmamap_load_mbuf
which expects a properly filled mbuf chain, but bus_dmamap_load for the
mbuf storage space instead.
- If the chip supports jumbo frames
+ keep track of which RX descriptor uses which jumbo mbuf buffer, so
that we can rewrite the physaddr field of the descriptor later, as it
might be partially overwritten by the hw
+ when we're out of jumbo mbufs, and if the packet is small enough,
copy it into a cluster mbuf
Those changes make my nfe(4) stable in both cases (defining NFE_NO_JUMBO
for the first one).
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 12-Mar-2006  rpaulo file if_nfevar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:17 +0000
 1.1.16.6 04-Feb-2008  yamt sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 27-Oct-2007  yamt sync with head.
 1.1.16.3 03-Sep-2007  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 12-Mar-2006  yamt file if_nfevar.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:04 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 12-Mar-2006  simonb file if_nfevar.h was added on branch simonb-timecounters on 2006-04-22 11:39:14 +0000
 1.1.8.2 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
share/man/man4/Makefile: revision 1.377
sys/dev/pci/if_nfe.c: revision 1.1
sys/dev/pci/if_nfereg.h: revision 1.1
share/man/man4/nfe.4: revision 1.1
sys/dev/pci/if_nfevar.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.863
add nfe driver and manpage from OpenBSD.
 1.1.8.1 12-Mar-2006  snj file if_nfevar.h was added on branch netbsd-3 on 2006-04-20 03:11:14 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 12-Mar-2006  elad file if_nfevar.h was added on branch elad-kernelauth on 2006-04-19 03:25:35 +0000
 1.1.2.2 13-Mar-2006  yamt sync with head.
 1.1.2.1 12-Mar-2006  yamt file if_nfevar.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:26 +0000
 1.2.18.1 06-Oct-2007  yamt sync with head.
 1.2.16.3 23-Mar-2008  matt sync with HEAD
 1.2.16.2 09-Jan-2008  matt sync with HEAD
 1.2.16.1 06-Nov-2007  matt sync with HEAD
 1.2.14.2 05-Oct-2007  joerg Convert nfe(4) to PNP power management.
 1.2.14.1 02-Oct-2007  joerg Sync with HEAD.
 1.2.2.1 09-Oct-2007  ad Sync with head.
 1.3.8.1 11-Dec-2007  yamt sync with head.
 1.3.6.1 26-Dec-2007  ad Sync with head.
 1.3.4.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.6.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.2.1 18-May-2008  yamt sync with head.
 1.9.24.1 05-Mar-2011  rmind sync with head
 1.9.22.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.10.60.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.10.60.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.33 01-Aug-2023  andvar s/diable/disable/ in comments.
 1.32 24-May-2022  andvar fix various typos in comments, docs and log messages.
 1.31 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.30 14-Jul-2016  msaitoh branches: 1.30.16; 1.30.18;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.29 29-Mar-2014  christos branches: 1.29.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.28 27-Oct-2012  chs branches: 1.28.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.27 26-Jul-2011  dyoung branches: 1.27.2; 1.27.12;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.26 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.25 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.24 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.23 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.22 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.21 10-Apr-2008  cegger branches: 1.21.4; 1.21.12; 1.21.18;
use aprint_*_dev and device_xname
 1.20 19-Oct-2007  ad branches: 1.20.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.19 16-Nov-2006  christos branches: 1.19.8; 1.19.22; 1.19.24; 1.19.28;
__unused removal on arguments; approved by core.
 1.18 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.17 29-Mar-2006  thorpej branches: 1.17.8; 1.17.10;
Use device_cfdata().
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
merge ktrace-lwp.
 1.15 30-May-2005  christos branches: 1.15.2;
- const poisoning
- avoid variable shadowing.
 1.14 04-Feb-2005  perry de-__P
 1.13 02-Nov-2003  wiz branches: 1.13.8; 1.13.10;
boundary, not boundry. Inspired by Tom Cosgrove.
 1.12 03-May-2003  wiz branches: 1.12.2;
DMA, not dma nor Dma.
 1.11 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.10 06-Jan-2003  wiz interrupt with two rs.
 1.9 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.8 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.7 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.6 13-Nov-2001  lukem add RCSID
 1.5 14-Aug-2001  mrg add (u_long) casts for sparc64.
 1.4 28-Dec-2000  sommerfeld branches: 1.4.2; 1.4.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.3 04-Jan-2000  chopps Add support for setting the clock and adapt the code to the new more
generic ic/hd56470.c core which now supports the isa version of the
same card.
 1.2 15-Feb-1999  hubertf branches: 1.2.8;
RCS ID police
 1.1 26-Jul-1998  explorer add ntwo* at pci? function ?, a T1 network driver.
 1.2.8.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.4.2.4 07-Jan-2003  thorpej Sync with HEAD.
 1.4.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.4.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.12.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.10.1 12-Feb-2005  yamt sync with head.
 1.13.8.1 29-Apr-2005  kent sync with -current
 1.15.2.3 27-Oct-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.16.10.1 19-Apr-2006  elad sync with head.
 1.16.8.1 01-Apr-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.17.10.2 10-Dec-2006  yamt sync with head.
 1.17.10.1 22-Oct-2006  yamt sync with head
 1.17.8.1 18-Nov-2006  ad Sync with head.
 1.19.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.19.24.1 06-Nov-2007  matt sync with HEAD
 1.19.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.19.8.1 23-Oct-2007  ad Sync with head.
 1.20.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.21.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.21.4.3 11-Mar-2010  yamt sync with head
 1.21.4.2 16-May-2009  yamt sync with head
 1.21.4.1 04-May-2009  yamt sync with head.
 1.27.12.3 03-Dec-2017  jdolecek update from HEAD
 1.27.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.27.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.2.1 30-Oct-2012  yamt sync with head
 1.28.2.1 18-May-2014  rmind sync with head
 1.29.6.1 05-Oct-2016  skrll Sync with HEAD
 1.30.18.1 10-Jun-2019  christos Sync with HEAD
 1.30.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.6 06-Jul-2024  andvar Fix various typos in comments:
s/defininitions/definitions/
s/ininitialise/initialise/
s/collasped/collapsed/
s/optionaly/optionally/
 1.5 11-Dec-2005  christos branches: 1.5.202;
merge ktrace-lwp.
 1.4 27-Feb-2005  perry nuke trailing whitespace
 1.3 04-Jan-2000  chopps branches: 1.3.28; 1.3.36; 1.3.38;
Add support for setting the clock and adapt the code to the new more
generic ic/hd56470.c core which now supports the isa version of the
same card.
 1.2 15-Feb-1999  hubertf branches: 1.2.8;
RCS ID police
 1.1 26-Jul-1998  explorer add ntwo* at pci? function ?, a T1 network driver.
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.38.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.36.1 29-Apr-2005  kent sync with -current
 1.3.28.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.202.1 02-Aug-2025  perseant Sync with HEAD
 1.81 04-Oct-2025  thorpej Use device_getprop_bool().
 1.80 10-Nov-2024  mlelstv Add MBUFTRACE
 1.79 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.78 10-Feb-2024  andvar branches: 1.78.2;
s/alloted/allotted/ in comments.
 1.77 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.76 16-Mar-2020  thorpej Do the "have transmit resources available" check before checking that
there is a packet in the send queue.
 1.75 15-Mar-2020  thorpej Don't bother with IFF_OACTIVE.
 1.74 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.73 29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.72 11-Oct-2019  msaitoh branches: 1.72.2;
Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.71 28-May-2019  msaitoh branches: 1.71.2;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.70 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.69 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.68 22-Apr-2019  msaitoh In drivers which use MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.
 1.67 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.66 02-Dec-2018  jdolecek use pci_intr_establish_xname()
 1.65 26-Jun-2018  msaitoh branches: 1.65.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.64 15-Dec-2016  ozaki-r branches: 1.64.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.63 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.62 10-Jun-2016  ozaki-r branches: 1.62.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.61 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.60 27-Apr-2015  christos fix mbuf leak on failure (Brainy)
 1.59 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.58 10-Aug-2014  tls branches: 1.58.2; 1.58.4;
Merge tls-earlyentropy branch into HEAD.
 1.57 29-Mar-2014  christos branches: 1.57.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.56 30-Mar-2013  christos branches: 1.56.4;
remove trailing whitespace
 1.55 22-Jul-2012  matt branches: 1.55.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.54 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.53 19-Nov-2011  tls branches: 1.53.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.52 13-Nov-2010  uebayasi branches: 1.52.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.51 30-Apr-2010  hubertf silence "boot -z"
 1.50 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.49 19-Jan-2010  pooka branches: 1.49.2; 1.49.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.48 06-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested Am79c973 PCnet-FAST III.
 1.47 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.46 04-Apr-2008  tsutsui branches: 1.46.4; 1.46.14; 1.46.18;
Split device_t/softc with misc related changes.
 1.45 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.44 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.43 20-Jan-2008  jmmv branches: 1.43.2; 1.43.6;
Now that the driver goes through the mii_ifmedia_change indirection
instead of directly calling the pcn_79c970_mediachange function, we
must initialize sc->sc_mii.mii_ifp so that this last function is
passed a valid parameter.

Fixes a panic in pcn_79c970_mediachange that arose immediately when
trying to use this interface due to a NULL pointer dereference.
Hi dyoung@!
 1.42 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.41 19-Oct-2007  ad branches: 1.41.2; 1.41.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.40 29-Aug-2007  dyoung branches: 1.40.4;
Constify: LLADDR() -> CLLADDR().
 1.39 09-Jul-2007  ad branches: 1.39.2; 1.39.6; 1.39.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.38 04-Mar-2007  christos branches: 1.38.2; 1.38.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.37 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.36 16-Nov-2006  christos branches: 1.36.4;
__unused removal on arguments; approved by core.
 1.35 15-Nov-2006  jdarrow Fix typo (enaddr[3] should be enaddr[2]), and add note to comment,
both in VMware bug-workaround section.
 1.34 01-Nov-2006  thorpej Detect if we're talking to a VMware virtual interface, and, if so,
limit the number of Tx segments to 8 to work around a VMware bug.
 1.33 31-Oct-2006  thorpej In the pcn driver:
- Remove the PCN_NO_PROM option. Instead, query the am79c970-no-eeprom
property, and read the MAC address from the CSRs if that property is TRUE.

In the ibmnws port:
- Implement device_register().
- In device_register(), set the am79c970-no-eeprom property for the
built-in Ethernet.
 1.32 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.31 17-Jun-2006  christos branches: 1.31.4; 1.31.6;
re-factor the pci powestate api. reviewed by gimpy
 1.30 14-Jun-2006  tsutsui branches: 1.30.2;
Call pcn_reset() in pcn_shutdown() so that my 7248 (prep) firmware
can netboot even after reboot without powercycle.
 1.29 22-Feb-2006  garbled branches: 1.29.2; 1.29.8;
IBM makes a pcn card that shows up as:
Trident Microsystems 4DWAVE DX (ethernet network, revision 0x25)
Unfortunately, this is an autri sound card. Special case the match routines
for both drivers so if_pcn properly picks it up, and autri doesn't.
 1.28 24-Dec-2005  perry branches: 1.28.2; 1.28.4; 1.28.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.27 11-Dec-2005  christos merge ktrace-lwp.
 1.26 07-May-2005  is branches: 1.26.2;
As discussed on tech-net: don't suppress any PHYs to enable multiple
external PHYs. The internal PHY at MII (nr 31) will be the last instance,
so it won't be the default instance when external PHYs are present.
 1.25 27-Feb-2005  perry branches: 1.25.2;
nuke trailing whitespace
 1.24 30-Oct-2004  thorpej branches: 1.24.4; 1.24.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.23 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.22 25-Oct-2003  christos branches: 1.22.4;
Fix uninitialized variable warnings
 1.21 19-Oct-2003  matt Add PCN_NO_PROM flag. (read the macaddr from the chip assuming the "BIOS"
has properly written it). From John Gordon.
 1.20 21-Jul-2003  jdolecek add rnd hooks
 1.19 30-Mar-2003  jdolecek branches: 1.19.2;
sprinkle some const qualifiers
 1.18 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.17 23-Oct-2002  perry fix lint warnings about things being stringified under cpp -traditional
 1.16 22-Oct-2002  thorpej Fix typos in media configuration register init. From patch posted
to tech-kern by Erik Anggard <erik.anggard@packetfront.com>.

May address PR 16346.
 1.15 21-Oct-2002  fair Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.
 1.14 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.13 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 04-Sep-2002  thorpej Add support for memory-mapped PCnet-PCI chips.
 1.10 02-Aug-2002  thorpej Fix a typo which caused the wrong register to be updated when
the media is not full-duplex.
 1.9 03-May-2002  thorpej branches: 1.9.2; 1.9.4;
Bump the number of Tx DMA segments from 8 to 16 (the zero-copy socket
code sometimes sees more than 8).
 1.8 29-Jan-2002  nisimura DANAS (disable autonegotiation) bit of BCR32 takes its effect when
set, not cleared.
 1.7 29-Nov-2001  thorpej Fix typo in copyright notice.
 1.6 27-Nov-2001  onoe Set ONES (must be ones) bits in tmd1 of tx descriptors.
This fix avoids VMware 3.0/WinXP to crash.
 1.5 13-Nov-2001  lukem add RCSID
 1.4 02-Sep-2001  enami branches: 1.4.4; 1.4.6;
Fix an obvious typo found while reading the source.
 1.3 28-Aug-2001  thorpej - Swap the bytes OR'd into init_ladrf[], for big-endian machines.
- Make sure to sync the init block.

Pointed out by Izumi Tsutsui.
 1.2 28-Aug-2001  thorpej Print "auto-FDX" for the second "autoselect" instance. Pointed out
by Izumi Tsutsui.
 1.1 27-Aug-2001  thorpej New driver for the AMD PCnet-PCI family of Ethernet chips. This
driver uses direct DMA to mbufs (like other PCI network drivers,
and unlike the old "le at pci" driver), and also supports communication
with the MII-connected PHYs on the 10/100 boards.
 1.4.6.12 29-Dec-2002  thorpej Sync with HEAD.
 1.4.6.11 11-Nov-2002  nathanw Catch up to -current
 1.4.6.10 22-Oct-2002  thorpej Sync with HEAD.
 1.4.6.9 18-Oct-2002  nathanw Catch up to -current.
 1.4.6.8 17-Sep-2002  nathanw Catch up to -current.
 1.4.6.7 13-Aug-2002  nathanw Catch up to -current.
 1.4.6.6 20-Jun-2002  nathanw Catch up to -current.
 1.4.6.5 28-Feb-2002  nathanw Catch up to -current.
 1.4.6.4 08-Jan-2002  nathanw Catch up to -current.
 1.4.6.3 14-Nov-2001  nathanw Catch up to -current.
 1.4.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.4.6.1 02-Sep-2001  nathanw file if_pcn.c was added on branch nathanw_sa on 2001-09-21 22:35:56 +0000
 1.4.4.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.4.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.4.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.4.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.4.4.1 02-Sep-2001  thorpej file if_pcn.c was added on branch kqueue on 2001-09-13 01:15:55 +0000
 1.9.4.3 30-Nov-2002  he Pull up revision 1.11 (requested by thorpej in ticket #767):
Add support for memory-mapped PCnet-PCI chips.
 1.9.4.2 23-Oct-2002  lukem Pull up revision 1.16 (requested by thorpej in ticket #940):
Fix typos in media configuration register init. From patch posted
to tech-kern by Erik Anggard <erik.anggard@packetfront.com>.
May address PR 16346.
 1.9.4.1 02-Aug-2002  lukem Pull up revision 1.10 (requested by thorpej in ticket #605):
Fix a typo which caused the wrong register to be updated when
the media is not full-duplex.
 1.9.2.1 29-Aug-2002  gehenna catch up with -current.
 1.19.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.19.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.4.1 24-Jan-2005  he Pull up revision 1.24 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.24.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.24.4.1 29-Apr-2005  kent sync with -current
 1.25.2.2 15-Nov-2006  bouyer Pull up following revision(s) (requested by thorpej in ticket #1586):
sys/dev/pci/if_pcn.c: revision 1.35
Fix typo (enaddr[3] should be enaddr[2]), and add note to comment,
both in VMware bug-workaround section.
 1.25.2.1 11-Nov-2006  bouyer Pull up following revision(s) (requested by thorpej in ticket #1577):
sys/dev/pci/if_pcn.c: revision 1.34
Detect if we're talking to a VMware virtual interface, and, if so,
limit the number of Tx segments to 8 to work around a VMware bug.
 1.26.2.8 24-Mar-2008  yamt sync with head.
 1.26.2.7 17-Mar-2008  yamt sync with head.
 1.26.2.6 21-Jan-2008  yamt sync with head
 1.26.2.5 27-Oct-2007  yamt sync with head.
 1.26.2.4 03-Sep-2007  yamt sync with head.
 1.26.2.3 26-Feb-2007  yamt sync with head.
 1.26.2.2 30-Dec-2006  yamt sync with head.
 1.26.2.1 21-Jun-2006  yamt sync with head.
 1.28.6.1 22-Apr-2006  simonb Sync with head.
 1.28.4.1 09-Sep-2006  rpaulo sync with head
 1.28.2.1 01-Mar-2006  yamt sync with head.
 1.29.8.1 19-Jun-2006  chap Sync with head.
 1.29.2.1 26-Jun-2006  yamt sync with head.
 1.30.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.31.6.2 10-Dec-2006  yamt sync with head.
 1.31.6.1 22-Oct-2006  yamt sync with head
 1.31.4.1 18-Nov-2006  ad Sync with head.
 1.36.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.36.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.38.4.1 11-Jul-2007  mjf Sync with head.
 1.38.2.3 23-Oct-2007  ad Sync with head.
 1.38.2.2 09-Oct-2007  ad Sync with head.
 1.38.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.39.8.2 23-Mar-2008  matt sync with HEAD
 1.39.8.1 06-Nov-2007  matt sync with HEAD
 1.39.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.39.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.39.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.40.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.41.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.41.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.43.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.43.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.43.2.1 24-Mar-2008  keiichi sync with head.
 1.46.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.46.14.1 20-Nov-2010  riz Pull up following revision(s) (requested by hubertf in ticket #1385):
sys/dev/pci/if_pcn.c: revision 1.51
silence "boot -z"
 1.46.4.4 11-Aug-2010  yamt sync with head.
 1.46.4.3 11-Mar-2010  yamt sync with head
 1.46.4.2 16-Sep-2009  yamt sync with head
 1.46.4.1 16-May-2009  yamt sync with head
 1.49.4.2 05-Mar-2011  rmind sync with head
 1.49.4.1 30-May-2010  rmind sync with head
 1.49.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.49.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.52.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.52.8.2 30-Oct-2012  yamt sync with head
 1.52.8.1 17-Apr-2012  yamt sync with head
 1.53.2.1 18-Feb-2012  mrg merge to -current.
 1.55.2.3 03-Dec-2017  jdolecek update from HEAD
 1.55.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.2.1 23-Jun-2013  tls resync from head
 1.56.4.1 18-May-2014  rmind sync with head
 1.57.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.58.4.4 05-Feb-2017  skrll Sync with HEAD
 1.58.4.3 09-Jul-2016  skrll Sync with HEAD
 1.58.4.2 19-Mar-2016  skrll Sync with HEAD
 1.58.4.1 06-Jun-2015  skrll Sync with HEAD
 1.58.2.1 30-Jul-2015  martin Pull up following revision(s) (requested by maxv in ticket #889):
sys/dev/pci/if_bge.c: revision 1.283
sys/dev/pci/if_pcn.c: revision 1.60
Fix mbuf leaks in error branches (found by the Brainy code scanner)
 1.62.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.64.14.3 26-Jan-2019  pgoyette Sync with HEAD
 1.64.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.64.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.65.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.65.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.65.2.1 10-Jun-2019  christos Sync with HEAD
 1.71.2.1 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.72.2.1 29-Feb-2020  ad Sync with head.
 1.78.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 04-Sep-2002  thorpej Add support for memory-mapped PCnet-PCI chips.
 1.2 29-Nov-2001  thorpej branches: 1.2.10;
Fix typo in copyright notice.
 1.1 27-Aug-2001  thorpej branches: 1.1.4; 1.1.6;
New driver for the AMD PCnet-PCI family of Ethernet chips. This
driver uses direct DMA to mbufs (like other PCI network drivers,
and unlike the old "le at pci" driver), and also supports communication
with the MII-connected PHYs on the 10/100 boards.
 1.1.6.4 17-Sep-2002  nathanw Catch up to -current.
 1.1.6.3 08-Jan-2002  nathanw Catch up to -current.
 1.1.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.6.1 27-Aug-2001  nathanw file if_pcnreg.h was added on branch nathanw_sa on 2001-09-21 22:35:57 +0000
 1.1.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.4.1 27-Aug-2001  thorpej file if_pcnreg.h was added on branch kqueue on 2001-09-13 01:15:55 +0000
 1.2.10.1 30-Nov-2002  he Pull up revision 1.3 (requested by thorpej in ticket #767):
Add support for memory-mapped PCnet-PCI chips.
 1.26 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.25 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.24 25-Jul-2017  maya branches: 1.24.2; 1.24.4;
enable rt2860 power management code

adjust to fit netbsd:
make suspend,resume functions match desired pmf* prototypes
remove wakeup/activate wrapper functions

avoid jumping to NULL on resume by initializing if_stop

the problem machine has other issues on resume, so there might be further
issues, but it's an improvement over a jump to NULL.

tested by Riccardo Mottola
 1.23 06-Jul-2016  christos branches: 1.23.10;
more cards, sort.
 1.22 27-Apr-2016  christos Sync with OpenBSD (add rt2860). Handle 32/64 memory bars,
some power management, more device matches.
 1.21 29-Mar-2014  christos branches: 1.21.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.20 18-Feb-2012  drochner branches: 1.20.2; 1.20.4;
split device_t/softc
 1.19 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.18 26-Jul-2011  dyoung branches: 1.18.2; 1.18.6;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.17 10-May-2011  dyoung Constify pci_attach_args.
 1.16 10-May-2011  dyoung Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.15 19-Jan-2010  pooka branches: 1.15.4; 1.15.6;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.14 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.13 08-Aug-2009  matt If we've had to enable MEM access, make sure our flags reflect that so that
pci_mapreg_map won't fail because it didn't know we did it.
 1.12 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.11 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.10 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.9 29-Apr-2008  scw branches: 1.9.14;
Pull in some more changes from OpenBSD:

- replace rssadapt(9) with amrr for automatic rate control.
- don't blindly IFQ_DEQUEUE() then drop a Tx packet if there are no
available Tx resources.
- move default MAC/BBP/RF settings from rt2661.c to rt2661reg.h.
- enable packet bursting when operating as a STA.
- implement new ic_updateslot() callback.
- in hostap mode, we defer update of the slot time until all associated
STAs are notified with updated beacons.
- 802.11a uses a 16 microseconds short interframe space.
- Fix rt2661_set_macaddr() so that we don't override the "unicast to me"
flag in RT2661_MAC_CSR3 when setting the MAC address.
- fix index of ERP information element in beacons.

Add a couple of tweaks of my own:

- The RX/TX BUSY flag should be the last thing written to a descriptor.
- Check and service any additional h/w interrupts before returning
from the isr.

Tested in STA, AP, and Monitor modes. Tested with WEP, WPA, and WPA2 crypto.

Additional testing by xtraeme@
 1.8 10-Apr-2008  cegger branches: 1.8.2; 1.8.4;
use aprint_*_dev and device_xname
 1.7 19-Oct-2007  ad branches: 1.7.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 16-Nov-2006  christos branches: 1.6.8; 1.6.22; 1.6.24; 1.6.28;
__unused removal on arguments; approved by core.
 1.5 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.4 06-Jun-2006  rpaulo branches: 1.4.6; 1.4.8;
Attachment framework for the rt2561.c and rt2661.c drivers.

From OpenBSD.
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.14;
merge ktrace-lwp.
 1.2 04-Jul-2005  drochner branches: 1.2.2; 1.2.8;
update PCI/Cardbus ral wlan driver, and adapt to new FreeBSD/NetBSD
80211 framework, from FUKAUMI Naoki per mail to tech-net
 1.1 01-Jul-2005  drochner add drivers for Ralink RT2500-based wireless adapters, written by
Damien Bergamini, ported and submitted by FUKAUMI Naoki per PR kern/30449
I've modified the USB "ural" driver for recent changes to the NetBSD
ieee80211 framework, possibly not completely, but with an ASUS wireless
adapter I'm getting some signs of life.
Didn't care about pci/cardbus for now, hopefully someone with hardware
will do it.
 1.2.8.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.8.1 04-Jul-2005  skrll file if_ral_pci.c was added on branch ktrace-lwp on 2005-11-10 14:06:01 +0000
 1.2.2.3 27-Oct-2007  yamt sync with head.
 1.2.2.2 30-Dec-2006  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.14.1 19-Jun-2006  chap Sync with head.
 1.3.8.1 26-Jun-2006  yamt sync with head.
 1.3.6.1 07-Jun-2006  kardel Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.8.2 10-Dec-2006  yamt sync with head.
 1.4.8.1 22-Oct-2006  yamt sync with head
 1.4.6.1 18-Nov-2006  ad Sync with head.
 1.6.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.24.1 06-Nov-2007  matt sync with HEAD
 1.6.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.8.1 23-Oct-2007  ad Sync with head.
 1.7.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.4.4 11-Mar-2010  yamt sync with head
 1.8.4.3 19-Aug-2009  yamt sync with head.
 1.8.4.2 16-May-2009  yamt sync with head
 1.8.4.1 16-May-2008  yamt sync with head.
 1.8.2.1 18-May-2008  yamt sync with head.
 1.9.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.4.1 31-May-2011  rmind sync with head
 1.18.6.2 24-Feb-2012  mrg sync to -current.
 1.18.6.1 18-Feb-2012  mrg merge to -current.
 1.18.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.2.1 17-Apr-2012  yamt sync with head
 1.20.4.1 18-May-2014  rmind sync with head
 1.20.2.2 03-Dec-2017  jdolecek update from HEAD
 1.20.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.6.3 28-Aug-2017  skrll Sync with HEAD
 1.21.6.2 09-Jul-2016  skrll Sync with HEAD
 1.21.6.1 29-May-2016  skrll Sync with HEAD
 1.23.10.1 01-Aug-2017  snj Pull up following revision(s) (requested by maya in ticket #162):
sys/dev/pci/if_ral_pci.c: revision 1.24
sys/dev/ic/rt2860.c: revision 1.28
sys/dev/ic/rt2860var.h: revision 1.5
enable rt2860 power management code
adjust to fit netbsd:
make suspend,resume functions match desired pmf* prototypes
remove wakeup/activate wrapper functions
avoid jumping to NULL on resume by initializing if_stop
the problem machine has other issues on resume, so there might be further
issues, but it's an improvement over a jump to NULL.
tested by Riccardo Mottola
 1.24.4.1 10-Jun-2019  christos Sync with HEAD
 1.24.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7 21-Jan-2005  yamt - switch to dev/rtl8169.c from pci/if_re.c.
- enable re@cardbus.
both of re@pci and re@cardbus seem to work for me.
 1.6 30-Oct-2004  thorpej branches: 1.6.4;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.5 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.4 01-Jun-2004  mrg branches: 1.4.2; 1.4.4;
#include <sys/device.h>
call ether_ifdetach() and if_detach() if attaching fails...
 1.3 30-May-2004  toshii rcsid
 1.2 30-May-2004  toshii Fix brokenness I introduced while debugging.
- initialize rxlenmask when 8139C+
- remove meaningless memsets.
 1.1 28-May-2004  toshii Add re(4) RealTek 8139C+/8169/8169S/8110S PCI ethernet adapter driver,
from FreeBSD.
I haven't tested this code very well, but it seems to work fairly well
for me.
 1.4.4.7 24-Jan-2005  skrll Sync with HEAD.
 1.4.4.6 02-Nov-2004  skrll Sync with HEAD.
 1.4.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.4.4.2 03-Aug-2004  skrll Sync with HEAD
 1.4.4.1 01-Jun-2004  skrll file if_re.c was added on branch ktrace-lwp on 2004-08-03 10:49:08 +0000
 1.4.2.5 21-Jun-2004  tron branches: 1.4.2.5.2;
Pull up revision 1.4 (requested by toshii in ticket #517):
call ether_ifdetach() and if_detach() if attaching fails...
 1.4.2.4 21-Jun-2004  tron Pull up revision 1.2 (requested by toshii in ticket #517):
Fix brokenness I introduced while debugging.
- initialize rxlenmask when 8139C+
- remove meaningless memsets.
 1.4.2.3 21-Jun-2004  tron Pull up revision 1.3 (requested by toshii in ticket #517):
rcsid
 1.4.2.2 21-Jun-2004  tron Pull up revision 1.1 (requested by toshii in ticket #517):
Add re(4) RealTek 8139C+/8169/8169S/8110S PCI ethernet adapter driver,
from FreeBSD.
I haven't tested this code very well, but it seems to work fairly well
for me.
 1.4.2.1 01-Jun-2004  tron file if_re.c was added on branch netbsd-2-0 on 2004-06-21 16:41:45 +0000
 1.4.2.5.2.2 01-Dec-2005  tron Apply patch (requested by riz in ticket #10160):
Match two candidates. From Francois Romieu in private mail.
 1.4.2.5.2.1 01-Dec-2005  tron Pull up following revision(s) (requested by riz in ticket #10156):
sys/dev/pci/if_sk.c: revision 1.18 via patch
sys/dev/pci/if_re.c: patch
Special-case the Linksys EG1032 cards using PCI subsystem ID; rev. 2 uses
the sk(4) driver, while rev. 3 needs re(4).
Mostly from brad@openbsd.
 1.6.4.1 29-Apr-2005  kent sync with -current
 1.53 28-Feb-2024  jakllsch Add Killer E2600, adapted from PR 57969
 1.52 18-Feb-2020  msaitoh branches: 1.52.24;
Whitespace fix. No functional change.
 1.51 30-Jan-2020  jmcneill Prefer memory space register mapping over IO space. Make an exception for
RTL8169SC, as the FreeBSD driver says memory mapped IO doesn't work there.
 1.50 14-Nov-2019  msaitoh branches: 1.50.2;
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.
 1.49 13-Nov-2018  jdolecek branches: 1.49.4;
use pci_intr_establish_xname()
 1.48 18-May-2017  jakllsch branches: 1.48.2; 1.48.8; 1.48.10;
Re-enable RTKQ_IM_HW. Timeout issues appear to be fixed since
src/sys/dev/ic/rtl8169.c r1.151
 1.47 01-May-2017  jakllsch Disable interrupt moderation, as it is it causes watchdog timeouts on
some chips/systems.
 1.46 19-Apr-2017  jmcneill branches: 1.46.2;
Performance improvements for PCIe and 8168 based devices:
- When using the countdown timer for interrupt moderation on PCIe devices,
use a timer rate value based on a 125MHz PCIe reference clock instead of
33 MHz.
- For 8168 based devices, ditch the countdown timer and instead use the
(undocumented) hardware interrupt moderation feature.
- Support TSOv4 on 8168D and later devices.
 1.45 14-Dec-2015  jakllsch branches: 1.45.2; 1.45.4;
Switch PCI re(4) attachment from pci_intr_map() to
pci_intr_alloc()/pci_intr_release().

This enables MSI where available.
 1.44 03-May-2015  matt Deal with 64-bit BARs
 1.43 29-Mar-2014  christos branches: 1.43.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.42 30-Mar-2013  christos branches: 1.42.4;
remove trailing whitespace
 1.41 30-Jan-2012  drochner branches: 1.41.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.40 27-Jul-2010  jakllsch branches: 1.40.8; 1.40.12;
Use 64-bit DMA tag (if available) on PCI-E re(4) NICs.
 1.39 27-Jul-2010  jakllsch Make the Realtek PCI network interfaces detachable.
Use __arraycount to avoid null table entries.
Miscellaneous other touch-ups in bus front-ends.
 1.38 02-Sep-2009  tsutsui branches: 1.38.2; 1.38.4;
Move pmf(9) calls to MI re_attach() and re_detach() from each backend.
 1.37 29-Aug-2009  tsutsui Remove unnecessary #includes.
 1.36 25-Apr-2009  tsutsui Remove suffix "B" from rtk_name of PCI_PRODUCT_REALTEK_RT8168 devices.
All 8168/8111 variants (8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP)
have the same PCI device ID.
 1.35 23-Aug-2008  tnn branches: 1.35.2; 1.35.4; 1.35.8; 1.35.12;
Add support for the Realtek 8102E/8102EL PCIe 10/100 Ethernet devices.
From FreeBSD.
 1.34 25-Apr-2008  tsutsui branches: 1.34.2; 1.34.4; 1.34.8;
Split device_t/softc for re(4) and rtk(4).
 1.33 10-Apr-2008  cegger branches: 1.33.2;
use aprint_*_dev and device_xname
 1.32 11-Dec-2007  lukem branches: 1.32.8;
use __KERNEL_RCSID()
 1.31 09-Dec-2007  jmcneill branches: 1.31.2;
Merge jmcneill-pm branch.
 1.30 19-Oct-2007  ad branches: 1.30.4; 1.30.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.29 07-Aug-2007  simonb branches: 1.29.2; 1.29.6;
Fix a tyop.
 1.28 19-Jul-2007  dsl branches: 1.28.4; 1.28.6;
include sys/cdefs.h
 1.27 21-Mar-2007  tsutsui branches: 1.27.4;
Cleanup handling of quikrs on each RealTek chip:
- replace rtk_type member in rtk_softc which has chip types
with new rtk_quirk that represents quirks on each chip:
- RTKQ_8129 doesn't have internal MII (used in rtk(4))
- RTKQ_8139CPLUS has different register layout (for re(4))
- RTKQ_8169NONS (original 8169) requires some settings on init
- RTKQ_PCIE requires different settings in setmulti
so that we don't have to check each hwrev values or types everywhere
and newer variants will also work without changes if they don't
have other quirks
(sc_rev is unchenged for now for reference to the Realtek's driver)
- don't check hwrev register in re_pci_match() but check
only PCI_VENDER(), PCI_PRODUCT() and PCI_REVISION()
so that we no longer have to map pci space there
- add a new HWREV value for another 8168 variant
- try to map PCI mem space more properly
- remove (probably unneeded) ifp->if_baudrate initialization

Tested on a newer 8168 variant by Dennis den Brok on tech-kern,
and also tested on 8139 and 8169C on macppc, and 8139C+ on landisk
by me.
 1.26 05-Mar-2007  tsutsui branches: 1.26.2; 1.26.4; 1.26.6;
Also check both I/O and memory space on unmap. Pointer out by yamt.
 1.25 03-Mar-2007  tsutsui Add an entry to match hwrev RTK_HWREV_8100E_SPIN2 too.

XXX: should we use PCI_REVISION() rather than hwrev
for 8139C+ as OpenBSD does?
 1.24 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.23 04-Feb-2007  tsutsui branches: 1.23.2;
Add an 8169SC variant to re_devs. From Darrin B.Jewell.
 1.22 04-Feb-2007  tsutsui Try to map both PCI I/O and memory space.
 1.21 24-Nov-2006  christos branches: 1.21.2;
fix capitalization of NetBSD; from Zapher
 1.20 18-Nov-2006  tsutsui Rename re_pci_probe() -> re_pci_match().
 1.19 18-Nov-2006  tsutsui - sync HWREV definitions with FreeBSD
- recognize 8169SC/8100E/8101E (untested, but won't hurt working devices)
XXX: 8100E/8101E don't support 1000M; need some flag to set if_baudrate
 1.18 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.17 03-Nov-2006  tsutsui Pull another 8139C+ fix from FreeBSD if_re.c rev 1.68:
Perform hardware diagnostic only on the original RTL8169,
which was the only device that really needed it.
(i.e. a possible hardware bug when the NIC was put on a 64bit PCI slot)

Tested with on-board 8139C+ by Brian A. Seklecki.

Note this change might also fix PR kern/34952
(because re_diag() is no longer called on 8169S/8110S),
but I'm not sure if the re(4) chip was properly initialized in such case.
 1.16 28-Oct-2006  christos PR/34933: Sami Kantoluoto: RealTek 8168B found from Asus P5B motherboard
is not recognized
 1.15 27-Oct-2006  tsutsui Use common macro rather than local one.
 1.14 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.13 18-Jun-2006  christos branches: 1.13.4; 1.13.6;
PR/33761: dieter roelants: NetBSD doesn't recognize a RealTek 8168B nic
 1.12 25-Dec-2005  rpaulo branches: 1.12.4; 1.12.8; 1.12.14; 1.12.16;
PR/32386: Dawid Szymanski (arhea). Add support for the 8169SB chipset.
 1.11 23-Nov-2005  riz Special-case the Linksys EG1032 cards using PCI subsystem ID; rev. 2 uses
the sk(4) driver, while rev. 3 needs re(4).

Mostly from brad@openbsd.
 1.10 15-Jun-2005  cube branches: 1.10.2; 1.10.8;
Match two candidates. From Francois Romieu in private mail.
 1.9 09-May-2005  martin Add support for Corega CG-LAPCIGT Gigabit Ethernet.
From PR kern/30173.
 1.8 27-Feb-2005  perry branches: 1.8.2;
nuke trailing whitespace
 1.7 23-Feb-2005  yamt re_pci_probe: don't use i/o space unless RE_USEIOSPACE.
 1.6 13-Feb-2005  jdolecek constify
 1.5 22-Jan-2005  briggs branches: 1.5.2;
Put the headers in a more standard order with machine-specific and
dev/bus-specific headers after the sys and net headers. This allows
it to actually compile on macppc, among other things.
 1.4 18-Jan-2005  yamt - add rcsid.
- restore Bill Paul's copyright notice.
 1.3 15-Jan-2005  kanaoka branches: 1.3.2; 1.3.4;
- Make sure D0 state if device has Power Managmet capability.
- Use aprint_*.
- Change some cosmetic.

XXX not tested.
 1.2 13-Jan-2005  kanaoka - Move re_diag() from bus independend code to PCI attachment code.

XXX: I tested cardbus device,but not PCI device.
 1.1 23-Dec-2004  jonathan Snapshot of incomplete-but-working split of re(4) driver into a
bus-independent backend, with PCI and CardBus attachment code.
The committed code has two serious bugs:

1. The driver makes no attempt to recover resources when a (Cardbus)
instance is removed; bus resources are leaked.

2. In testing with a NetGear GA-511, the Cardbus card never responded
to a reset/wakeup if the card is powered down after attachment.
So for now, leave cardbus instances powered up at attachment
(insertion, or at boot if a card is already present).

That aside, it acutally works on my GA-511. Committed as-is despite
the bugs, after repeated requests to make the code available for
further testing. Also requires sys/dev/mii/miidevs rev 1.54 -> 1.55,
and consequent regen of miidevs{,_data}.h.
 1.3.4.7 11-Dec-2005  christos Sync with head.
 1.3.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.4.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.4.4 15-Feb-2005  skrll Sync with HEAD.
 1.3.4.3 24-Jan-2005  skrll Sync with HEAD.
 1.3.4.2 17-Jan-2005  skrll Sync with HEAD.
 1.3.4.1 15-Jan-2005  skrll file if_re_pci.c was added on branch ktrace-lwp on 2005-01-17 19:31:24 +0000
 1.3.2.1 29-Apr-2005  kent sync with -current
 1.5.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.2.7 04-Oct-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1852):
sys/dev/ic/rtl81x9var.h: revision 1.39
sys/dev/cardbus/if_re_cardbus.c: revision 1.13
sys/dev/pci/if_re_pci.c: revision 1.27 via patch
sys/dev/pci/if_rtk_pci.c: revision 1.32
sys/dev/cardbus/if_rtk_cardbus.c: revision 1.32
sys/dev/ic/rtl8169.c: revision 1.84, 1.85
sys/dev/ic/rtl81x9reg.h: revision 1.27
sys/dev/ic/rtl81x9.c: revision 1.72
Cleanup handling of quikrs on each RealTek chip:
Pull a fix for PCIe variants from FreeBSD
 1.8.2.6 10-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1680):
sys/dev/pci/if_re_pci.c: revision 1.25-1.26
Add an entry to match hwrev RTK_HWREV_8100E_SPIN2 too.
Also check both I/O and memory space on unmap. Pointer out by yamt.
 1.8.2.5 03-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1673):
distrib/sets/lists/man/mi 1.844, 1.871
share/man/man4/Makefile 1.372, 1.379 via patch
share/man/man4/re.4 1.8, 1.9, 1.11, 1.12
share/man/man4/rgephy.4 1.1
share/man/man4/rlphy.4 1.1, 1.2
sys/arch/amd64/conf/GENERIC 1.79, 1.89
sys/arch/amd64/conf/INSTALL 1.45, 1.49
sys/arch/i386/conf/GENERIC 1.717, 1.747
sys/arch/i386/conf/GENERIC_LAPTOP 1.164
sys/arch/i386/conf/INSTALL 1.277, 1.283
sys/arch/i386/conf/INSTALL_LAPTOP 1.96, 1.98
sys/arch/i386/conf/XEN2_DOM0 1.22 via patch
sys/arch/macppc/conf/GENERIC 1.220, 1.246
sys/arch/macppc/conf/INSTALL 1.96, 1.100
sys/dev/cardbus/if_re_cardbus.c 1.10
sys/dev/cardbus/if_rtk_cardbus.c 1.29-1.31
sys/dev/ic/rtl8169.c 1.14, 1.20, 1.24, 1.25, 1.28-1.61, 1.63, 1.64-1.81 via patch
sys/dev/ic/rtl81x9.c 1.52, 1.54-1.63, 1.65, 1.67-1.70
sys/dev/ic/rtl81x9reg.h 1.15-1.26
sys/dev/ic/rtl81x9var.h 1.19, 1.21-1.37
sys/dev/mii/files.mii 1.38
sys/dev/mii/miidevs 1.62, 1.64
sys/dev/mii/rgephy.c 1.10, 1.13-1.16
sys/dev/mii/rlphy.c 1.1, 1.6, 1.7, 1.11 via patch
sys/dev/pci/if_re_pci.c 1.13, 1.15-1.17, 1.19-1.23
sys/dev/pci/if_rtk_pci.c 1.25, 1.28, 1.29, 1.31
sys/dev/pci/pcidevs 1.851, 1.852

on re(4):
- improve stability (I believe ;-)
- add a workaround for hardware ip4csum-tx bug
- support newer chips (8169SB/SC, PCIe based 8168 etc.)
- fix 8139C+ support
- enable hardware VLAN
- misc bus_dma(9) fix (which makes re(4) work on mips ports)

on rtk(4):
- fix kern/31348
- fix possible panic on dreamcast
 1.8.2.4 29-Dec-2005  riz Pull up following revision(s) (requested by rpaulo in ticket #1070):
sys/dev/pci/if_re_pci.c: revision 1.12
sys/dev/ic/rtl81x9reg.h: revision 1.14
PR/32386: Dawid Szymanski (arhea). Add support for the 8169SB chipset.
From FreeBSD.
 1.8.2.3 24-Nov-2005  tron Pull up following revision(s) (requested by riz in ticket #993):
sys/dev/pci/if_sk.c: revision 1.18
sys/dev/pci/if_re_pci.c: revision 1.11
Special-case the Linksys EG1032 cards using PCI subsystem ID; rev. 2 uses
the sk(4) driver, while rev. 3 needs re(4).
Mostly from brad@openbsd.
 1.8.2.2 24-Nov-2005  tron Pull up following revision(s) (requested by riz in ticket #995):
sys/dev/pci/if_re_pci.c: revision 1.10
Match two candidates. From Francois Romieu in private mail.
 1.8.2.1 10-May-2005  tron Pull up revision 1.9 (requested by martin in ticket #273):
Add support for Corega CG-LAPCIGT Gigabit Ethernet.
From PR kern/30173.
 1.10.8.1 29-Nov-2005  yamt sync with head.
 1.10.2.6 21-Jan-2008  yamt sync with head
 1.10.2.5 27-Oct-2007  yamt sync with head.
 1.10.2.4 03-Sep-2007  yamt sync with head.
 1.10.2.3 26-Feb-2007  yamt sync with head.
 1.10.2.2 30-Dec-2006  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.12.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.12.14.1 22-Jun-2006  chap Complete a sync sys/ with head.
 1.12.8.3 15-Sep-2006  yamt revert unrelated changes erroneously slipped in.
 1.12.8.2 26-Jun-2006  yamt sync with head.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.6.2 10-Dec-2006  yamt sync with head.
 1.13.6.1 22-Oct-2006  yamt sync with head
 1.13.4.3 09-Feb-2007  ad Sync with HEAD.
 1.13.4.2 12-Jan-2007  ad Sync with head.
 1.13.4.1 18-Nov-2006  ad Sync with head.
 1.21.2.6 18-Aug-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1339):
sys/dev/ic/rtl8169.c: revisions 1.107, 1.114, 1.115, 1.116,
1.117 (via patch), 1.118 (via patch),
1.119, 1.121
sys/dev/ic/rtl81x9reg.h: revisions 1.36, 1.37, 1.38, 1.39
sys/dev/ic/rtl81x9var.h: revision 1.47
sys/dev/mii/rgephy.c: revisions 1.16, 1.18, 1.19, 1.27 (via patch)
sys/dev/mii/rgephyreg.h: revision 1.3
sys/dev/pci/if_re_pci.c: revision 1.36
- add support for RTL8211B(L) to rgephy(4)
- add a wakeup instruction for rgephy(4) on newer re(4) chips
- detect RTL8169CP, RTL8168D/8111D, and RTL8103E variants
- fix rgephy(4) problem on RTL8111D reported on current-users:
http://mail-index.NetBSD.org/current-users/2009/04/12/msg008977.html
http://mail-index.NetBSD.org/current-users/2009/04/19/msg009096.html
- pull more quirk handling from FreeBSD
- fix RX hwcksum for DESCV2 chips for PR kern/40605
- remove "B" suffix from RTL8168 device names in attach message
 1.21.2.5 31-Mar-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1297):
src/sys/dev/ic/rtl8169.c 1.104 (via patch), 1.105 (via patch),
1.106 (via patch), 1.108, 1.109 (via patch),
1.110, 1.111, 1.112, 1.113
sys/dev/ic/rtl81x9reg.h: revision 1.30 - 1.35
sys/dev/ic/rtl81x9var.h: revision 1.42 - 1.45
sys/dev/pci/if_re_pci.c: revision 1.35
Add support for 8168C/8111C/8102E chips.
Fix MAC reset issue (PR kern/41009)
Add/fix HW checksum support (PR kern/40955)
 1.21.2.4 16-May-2007  jdc Pull up revision 1.27 via patch (requested by tsutsui in ticket #640).

Cleanup handling of quikrs on each RealTek chip:
- replace rtk_type member in rtk_softc which has chip types
with new rtk_quirk that represents quirks on each chip:
- RTKQ_8129 doesn't have internal MII (used in rtk(4))
- RTKQ_8139CPLUS has different register layout (for re(4))
- RTKQ_8169NONS (original 8169) requires some settings on init
- RTKQ_PCIE requires different settings in setmulti
so that we don't have to check each hwrev values or types everywhere
and newer variants will also work without changes if they don't
have other quirks
(sc_rev is unchenged for now for reference to the Realtek's driver)
- don't check hwrev register in re_pci_match() but check
only PCI_VENDER(), PCI_PRODUCT() and PCI_REVISION()
so that we no longer have to map pci space there
- add a new HWREV value for another 8168 variant
- try to map PCI mem space more properly
- remove (probably unneeded) ifp->if_baudrate initialization

Tested on a newer 8168 variant by Dennis den Brok on tech-kern,
and also tested on 8139 and 8169C on macppc, and 8139C+ on landisk
by me.
 1.21.2.3 10-Mar-2007  bouyer branches: 1.21.2.3.2;
Pull up following revision(s) (requested by tsutsui in ticket #502):
sys/dev/pci/if_re_pci.c: revision 1.25-1.26
Add an entry to match hwrev RTK_HWREV_8100E_SPIN2 too.
Also check both I/O and memory space on unmap. Pointer out by yamt.
 1.21.2.2 10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/pci/if_re_pci.c: revision 1.23
Add an 8169SC variant to re_devs. From Darrin B.Jewell.
 1.21.2.1 10-Feb-2007  tron Pull up following revision(s) (requested by tsutsui in ticket #437):
sys/dev/pci/if_re_pci.c: revision 1.22
Try to map both PCI I/O and memory space.
 1.21.2.3.2.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.23.2.3 24-Mar-2007  yamt sync with head.
 1.23.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.23.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.26.6.1 29-Mar-2007  reinoud Pullup to -current
 1.26.4.1 11-Jul-2007  mjf Sync with head.
 1.26.2.3 23-Oct-2007  ad Sync with head.
 1.26.2.2 20-Aug-2007  ad Sync with HEAD.
 1.26.2.1 10-Apr-2007  ad Sync with head.
 1.27.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.28.6.2 19-Jul-2007  dsl include sys/cdefs.h
 1.28.6.1 19-Jul-2007  dsl file if_re_pci.c was added on branch matt-mips64 on 2007-07-19 22:04:23 +0000
 1.28.4.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.28.4.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.28.4.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.28.4.2 05-Oct-2007  joerg Remove the power management nonsense in the PCI versions of
rtk(4) and re(4). It is not really likely to work anyway.
Use PNP power management for the cardbus attachment as well and
remove the power management handlers from the chipset code.
 1.28.4.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.29.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.29.2.2 09-Jan-2008  matt sync with HEAD
 1.29.2.1 06-Nov-2007  matt sync with HEAD
 1.30.6.1 11-Dec-2007  yamt sync with head.
 1.30.4.1 26-Dec-2007  ad Sync with head.
 1.31.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.32.8.2 28-Sep-2008  mjf Sync with HEAD.
 1.32.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.2.1 18-May-2008  yamt sync with head.
 1.34.8.1 19-Oct-2008  haad Sync with HEAD.
 1.34.4.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.34.2.3 11-Aug-2010  yamt sync with head.
 1.34.2.2 16-Sep-2009  yamt sync with head
 1.34.2.1 04-May-2009  yamt sync with head.
 1.35.12.1 21-Apr-2010  matt sync to netbsd-5
 1.35.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.35.4.1 19-Jun-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #821):
sys/dev/ic/rtl8169.c: revisions 1.107, 1.114-1.119, 1.121
sys/dev/ic/rtl81x9reg.h: revisions 1.36-1.39
sys/dev/ic/rtl81x9var.h: revision 1.47
sys/dev/mii/rgephy.c: revision 1.27 via patch
sys/dev/pci/if_re_pci.c: revision 1.36
remove extra semicolons.
--
Add HWREV values of RTL8168CP and RTL8168D. From FreeBSD.

XXX: needs more quirk handling after wakeup for newer chips.
--
Add HWREV of RTL8102EL variant. From FUKAUMI Naoki.
--
Assume an unknown HWREV chip has the same features with the latest one.
--
Remove suffix "B" from rtk_name of PCI_PRODUCT_REALTEK_RT8168 devices.
All 8168/8111 variants (8168/8168B/8168C/8168CP/8168D/8111B/8111C/8111CP)
have the same PCI device ID.
--
Remove magic reset sequence except wakeup for rev 2 chips which breaks 8111D.
Problem reported and fix confirmed by Thomas Bieg on current-users.

Also tested on 8111C (no bad side effect) by several users privately.
--
Pull some changes for newer chips from FreeBSD:
- pull MACSTAT and CMDSTOP quirks for 8168/8111 chips
- always set CPLUSCMD_PCI_MRW on reset
- set VLANSTRIP and RXCSUM_ENB bits on CPLUS register per if_capenable

Tested on 8111C and 8111D by several users, and
no bad side effect on my old 8169S.
--
Remove unused sc_rev settings (all quirks are handled by sc_quirk)
and merge HWREV cases which have the same quirks.
--
- rename RTK_HWREV_8102EL_SPIN2 -> RTK_HWREV_8103E
- add a HWREV value for 8168DP
Per Realtek's Linux drivers.
--
Two fixes for RX hwcsum on DESCV2 chips:
* On checking TCPv4/UDPv4 RX checksum on DESCV2 chips, also check
RE_RDESC_VLANCTL_IPV4 bit because those DESCV2 chips may also recognize
IPv6 packets and set RE_PROTOID_TCPIP or RE_PROTOID_UDPIP bits for
TCPv6/UDPv6 packets. This may fix PR kern/40605.
* According to Realtek's Linux driver, DESCV2 chips don't set RE_PROTOID_IP
for non-TCP/UDP IP packets (set only RE_RDESC_VLANCTL_IPV[46]) so
remove PROTOID check for IPv4 RX cheksum on DESCV2 chips.
 1.35.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.38.4.1 05-Mar-2011  rmind sync with head
 1.38.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.40.12.1 18-Feb-2012  mrg merge to -current.
 1.40.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.40.8.1 17-Apr-2012  yamt sync with head
 1.41.6.3 03-Dec-2017  jdolecek update from HEAD
 1.41.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.6.1 23-Jun-2013  tls resync from head
 1.42.4.1 18-May-2014  rmind sync with head
 1.43.6.3 28-Aug-2017  skrll Sync with HEAD
 1.43.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.43.6.1 06-Jun-2015  skrll Sync with HEAD
 1.45.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.45.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.46.2.2 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.46.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.48.10.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.48.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48.10.1 10-Jun-2019  christos Sync with HEAD
 1.48.8.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.48.2.1 19-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1449:

sys/dev/pci/if_re_pci.c 1.50
share/man/man4/re.4 1.17-1.18

Add D-Link DGE-530T Rev. C,D and TP-Link TG-3468 v2,v3.
Add note about UDP checksum offload feature to the document.
 1.49.4.1 19-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #451:

sys/dev/pci/if_re_pci.c 1.50 (patch)
share/man/man4/re.4 1.17-1.18 (patch)

Add D-Link DGE-530T Rev. C,D and TP-Link TG-3468 v2,v3.
Add note about UDP checksum offload feature to the document.
 1.50.2.1 29-Feb-2020  ad Sync with head.
 1.52.24.1 24-Aug-2024  martin Pull up following revision(s) (requested by jakllsch in ticket #805):

sys/dev/pci/pcidevs: revision 1.1503
sys/dev/pci/if_re_pci.c: revision 1.53

Add (Realtek/)Killer E2600 Ethernet
Add Killer E2600, adapted from PR 57969
 1.42 29-Oct-2025  pgoyette One more attempt to revert
 1.41 29-Oct-2025  pgoyette Undo recent changes since they seem to have broken something.

Will reexamine moving forward from last time we synched with
OpenBSD - January 20, 2021
 1.40 28-Oct-2025  pgoyette Update microcode, initialization and reset behavior. From
OpenBSD, if_rge.c rev 1.23 and if_rgereg.h rev 1.10.

XXX In the same commit, two chip variants were de-supported,
with an expectation that those two variants were never
shipped in any product. It's not clear that this is
true, so I did NOT remove support for them.
 1.39 27-Oct-2025  pgoyette Update RTL8125 microcode.

From openbsd, if_rge.c rev 1.13, if_rgereg.h rev 1.7
 1.38 26-Oct-2025  pgoyette We only suppoprt the MAC_CFG2_8126 (hwrev 0x649000000). Disable the
others.

Based on driver code from Realtek, all three of these are "8126A"
models ...
 1.37 25-Oct-2025  pgoyette Clean up interrupt handling and add rge_detach().

Disable recognition of 8126-B until we know more about how
to drive it.
 1.36 23-Oct-2025  pgoyette Recognize the RT8126 Rev B.

XXX Assume for now that it works the same as Rev A. Neither
XXX Free- nor OpenBSD give any clues on Rev B details.
 1.35 21-Oct-2025  pgoyette Add MODULE glue
 1.34 04-Feb-2025  jmcneill rge(4): Add support for RTL8126

Patch from FUKAUMI Naoki in PR# 59044
 1.33 10-Nov-2024  mlelstv Add MBUFTRACE
 1.32 29-Jun-2024  riastradh branches: 1.32.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.31 18-Jan-2024  msaitoh rge(4): Print HW revision.
 1.30 21-Dec-2023  skrll G/C sc_task and #include "opt_net_mpsafe.h"
 1.29 16-Dec-2023  mlelstv - handle stuck transmitter (descriptor still owned)
- restart send queue after transmit
- count output packets
- use deferred start

Should fix PR 57694
 1.28 19-Oct-2023  mrg rge: properly handle mbuf allocation failures in rx interrupts

several changes that should fix crashes seen after an mbuf
allocation failure:

- create RX ring dma maps with BUS_DMA_ALLOCNOW, so that any
future bus_dmamap_load*() call will succeed. this avoids one
error case in rge_newbuf(), that similar cases in eg wm(4)
actually call panic for now (i think this idea can be copied
into wm(4) as well.)

- extract the RX descriptor set into a common function that
both rge_newbuf() and rge_rxeof() can both use. it's almost
identical to the old rge_discard_rxbuf() except it also sets
the rge_addr (this is needed for the newbuf case.)

- move the bus_dmamap_unload() into rge_newbuf(), so that the
existing mbuf will remain mapped until a new mbuf is allocated.
(this part is what should fix crashes seen by wiz and Chavdar,
as the unload follow by sync is what triggers the assert in
x86 bus_dma. without the assert, it will would have shortly
triggered a page fault.) remove the assignment to NULL for
the rxq mbuf pointer, it is required for reload.

- add a couple of missing if_statinc() calls.


tested on amd64 and arm64.
 1.27 09-Oct-2023  riastradh rge(4): callout_stop can't be right here; just do callout_halt.

XXX pullup-10
 1.26 05-Oct-2023  mrg rge(4): check for all errors in rx buffer allocation

should fix a crash seen by by Chavdar Ivanov reported on current-users.

move the rx and tx list clean up into their own functions, and call the
rx clean up function from the init function if something fails. this
should fix a potential leak in this case, and generally frees up memory
that won't be used without a successful init phase again.

slight application of 'static', much more could be done.
 1.25 21-Dec-2022  nonaka Update the Rx descriptor based on the vendor driver for Linux.

This fixes a panic on RTL8125.
Patch from OpenBSD if_rge.c r1.20, if_rgereg.h r1.8.

Tested by msaitoh@n.o.
 1.24 24-Sep-2022  thorpej branches: 1.24.4;
Remove unnecessary include of <sys/malloc.h>.
 1.23 07-Jul-2022  skrll Trailing whitespace
 1.22 11-Oct-2021  msaitoh Avoid unaligned access in rge_get_macaddr(). Found by kUBSan.
 1.21 11-Oct-2021  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.20 11-Oct-2021  msaitoh Add pmf_device_register().
 1.19 08-May-2021  thorpej Use pci_compatible_match().
 1.18 02-Mar-2021  knakahara branches: 1.18.4;
Fix build failure for options NET_MPSAFE.
 1.17 01-Mar-2021  jakllsch Update rge(4) from older OpenBSD, finish porting.

Should consider merging this all into re(4) and rgephy(4) someday.

Some cleanup tasks remain here.
 1.16 27-Jan-2021  jakllsch if_rge.c: avoid aprint_error*() abuse
 1.15 20-Jan-2021  jakllsch Sync with OpenBSD if_rge.c r1.4

"""
Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.
"""
 1.14 30-May-2020  sevan branches: 1.14.2;
Use device_xname() to access dv_xname
 1.13 30-May-2020  sevan Switch from printf to aprintf_error/normal
 1.12 30-May-2020  sevan Initialise sc->sc_dev, otherwise unnamed interfaces show up and things go
downhill from there.
 1.11 20-May-2020  sevan use device_private() instead of casting self as it doesn't work here.
Bump rcs tag which was missed in r1.9
 1.10 30-Apr-2020  sevan Sync with r1.3 from OpenBSD

"Use correct bit mask to promptly exit rge_set_phy_power() and
rge_exit_oob() timeout loops.

Spotted by CID 1491296 and 1491309."
 1.9 29-Feb-2020  thorpej branches: 1.9.4;
Use the 64-bit PCI tag, if available.
 1.8 27-Feb-2020  sevan Cast to make up for the difference in type between our bus_dma_map(9) and
theirs. Where we expect kvap to be of void **, they expect caddr_t (typedef char *).
 1.7 27-Feb-2020  sevan Add an implementation of MCLGETI.
Borrowed from sys/dev/pci/if_bwfm_pci.c
 1.6 13-Feb-2020  sevan redundant include
 1.5 04-Feb-2020  skrll Trailing whitespace
 1.4 04-Feb-2020  skrll Adopt <net/if_stats.h>
 1.3 12-Jan-2020  sevan branches: 1.3.2;
Start to switch from OpenBSD timeout(9) API to callout(9) and workqueue(9)
Replace functions with NetBSD counterparts.
 1.2 11-Jan-2020  sevan Start porting to NetBSD. (WIP, incomplete)
 1.1 11-Jan-2020  sevan Import rge(4) from OpenBSD for Realtek's RTL8125 based 2.5GbE network cards.
 1.3.2.3 29-Feb-2020  ad Sync with head.
 1.3.2.2 17-Jan-2020  ad Sync with head.
 1.3.2.1 12-Jan-2020  ad file if_rge.c was added on branch ad-namecache on 2020-01-17 21:47:31 +0000
 1.9.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.9.4.1 29-Feb-2020  martin file if_rge.c was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.14.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.18.4.1 13-May-2021  thorpej Sync with HEAD.
 1.24.4.6 02-Jun-2025  martin ticket #1124: minor fix to make it compile on this branch
 1.24.4.5 01-Jun-2025  martin Pull up following revision(s) (requested by jmcneill in ticket #1124):

sys/dev/pci/if_rge.c: revision 1.34
sys/dev/pci/if_rgereg.h: revision 1.9
share/man/man4/rge.4: revision 1.5

rge(4): Add support for RTL8126

Patch from FUKAUMI Naoki in PR# 59044
 1.24.4.4 22-Aug-2024  martin Pull up following revision(s) (requested by mrg in ticket #782):

sys/dev/pci/if_rge.c: revision 1.29

- handle stuck transmitter (descriptor still owned)
- restart send queue after transmit
- count output packets
- use deferred start

Should fix PR 57694
 1.24.4.3 22-Oct-2023  martin Pull up following revision(s) (requested by mrg in ticket #434):

sys/dev/pci/if_rge.c: revision 1.26
sys/dev/pci/if_rge.c: revision 1.28

rge(4): check for all errors in rx buffer allocation
should fix a crash seen by by Chavdar Ivanov reported on current-users.
move the rx and tx list clean up into their own functions, and call the
rx clean up function from the init function if something fails. this
should fix a potential leak in this case, and generally frees up memory
that won't be used without a successful init phase again.
slight application of 'static', much more could be done.

rge: properly handle mbuf allocation failures in rx interrupts
several changes that should fix crashes seen after an mbuf
allocation failure:
- create RX ring dma maps with BUS_DMA_ALLOCNOW, so that any
future bus_dmamap_load*() call will succeed. this avoids one
error case in rge_newbuf(), that similar cases in eg wm(4)
actually call panic for now (i think this idea can be copied
into wm(4) as well.)
- extract the RX descriptor set into a common function that
both rge_newbuf() and rge_rxeof() can both use. it's almost
identical to the old rge_discard_rxbuf() except it also sets
the rge_addr (this is needed for the newbuf case.)
- move the bus_dmamap_unload() into rge_newbuf(), so that the
existing mbuf will remain mapped until a new mbuf is allocated.
(this part is what should fix crashes seen by wiz and Chavdar,
as the unload follow by sync is what triggers the assert in
x86 bus_dma. without the assert, it will would have shortly
triggered a page fault.) remove the assignment to NULL for
the rxq mbuf pointer, it is required for reload.
- add a couple of missing if_statinc() calls.

tested on amd64 and arm64.
 1.24.4.2 14-Oct-2023  martin Pull up following revision(s) (requested by riastradh in ticket #414):

sys/dev/pci/if_rge.c: revision 1.27

rge(4): callout_stop can't be right here; just do callout_halt.
 1.24.4.1 21-Dec-2022  martin Pull up following revision(s) (requested by nonaka in ticket #14):

sys/dev/pci/if_rge.c: revision 1.25
sys/dev/pci/if_rgereg.h: revision 1.7

Update the Rx descriptor based on the vendor driver for Linux.

This fixes a panic on RTL8125.

Patch from OpenBSD if_rge.c r1.20, if_rgereg.h r1.8.

Tested by msaitoh@n.o.
 1.32.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 29-Oct-2025  pgoyette One more attempt to revert
 1.13 29-Oct-2025  pgoyette Undo recent changes since they seem to have broken something.

Will reexamine moving forward from last time we synched with
OpenBSD - January 20, 2021
 1.12 28-Oct-2025  pgoyette Update microcode, initialization and reset behavior. From
OpenBSD, if_rge.c rev 1.23 and if_rgereg.h rev 1.10.

XXX In the same commit, two chip variants were de-supported,
with an expectation that those two variants were never
shipped in any product. It's not clear that this is
true, so I did NOT remove support for them.
 1.11 27-Oct-2025  pgoyette Update RTL8125 microcode.

From openbsd, if_rge.c rev 1.13, if_rgereg.h rev 1.7
 1.10 25-Oct-2025  pgoyette Clean up interrupt handling and add rge_detach().

Disable recognition of 8126-B until we know more about how
to drive it.
 1.9 04-Feb-2025  jmcneill rge(4): Add support for RTL8126

Patch from FUKAUMI Naoki in PR# 59044
 1.8 21-Dec-2023  skrll branches: 1.8.2;
G/C sc_task and #include "opt_net_mpsafe.h"
 1.7 21-Dec-2022  nonaka Update the Rx descriptor based on the vendor driver for Linux.

This fixes a panic on RTL8125.
Patch from OpenBSD if_rge.c r1.20, if_rgereg.h r1.8.

Tested by msaitoh@n.o.
 1.6 28-Aug-2022  skrll branches: 1.6.4;
Trailing whitespace
 1.5 01-Mar-2021  jakllsch Update rge(4) from older OpenBSD, finish porting.

Should consider merging this all into re(4) and rgephy(4) someday.

Some cleanup tasks remain here.
 1.4 30-May-2020  sevan branches: 1.4.2;
Use device_t for sc_dev
 1.3 12-Jan-2020  sevan branches: 1.3.2; 1.3.6;
Start to switch from OpenBSD timeout(9) API to callout(9) and workqueue(9)
Replace functions with NetBSD counterparts.
 1.2 11-Jan-2020  sevan Start porting to NetBSD. (WIP, incomplete)
 1.1 11-Jan-2020  sevan Import rge(4) from OpenBSD for Realtek's RTL8125 based 2.5GbE network cards.
 1.3.6.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.6.1 12-Jan-2020  martin file if_rgereg.h was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.3.2.2 17-Jan-2020  ad Sync with head.
 1.3.2.1 12-Jan-2020  ad file if_rgereg.h was added on branch ad-namecache on 2020-01-17 21:47:31 +0000
 1.4.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6.4.2 01-Jun-2025  martin Pull up following revision(s) (requested by jmcneill in ticket #1124):

sys/dev/pci/if_rge.c: revision 1.34
sys/dev/pci/if_rgereg.h: revision 1.9
share/man/man4/rge.4: revision 1.5

rge(4): Add support for RTL8126

Patch from FUKAUMI Naoki in PR# 59044
 1.6.4.1 21-Dec-2022  martin Pull up following revision(s) (requested by nonaka in ticket #14):

sys/dev/pci/if_rge.c: revision 1.25
sys/dev/pci/if_rgereg.h: revision 1.7

Update the Rx descriptor based on the vendor driver for Linux.

This fixes a panic on RTL8125.

Patch from OpenBSD if_rge.c r1.20, if_rgereg.h r1.8.

Tested by msaitoh@n.o.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 10-May-2000  thorpej These are no longer used.
 1.10 30-Mar-2000  augustss Remove register declarations.
 1.9 23-Mar-2000  mycroft Rather than guessing at the location of the PMCSR, use the pointer returned by
pci_get_capability(). (This is, after all, a standardized interface...)
 1.8 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.7 06-Mar-2000  thorpej No longer necessary to futz with ifp->if_baudrate here.
 1.6 02-Feb-2000  thorpej Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().
 1.5 02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.4 12-Nov-1999  thorpej Call mii_down() as appropriate.
 1.3 04-Nov-1999  thorpej Adapt to mii_phy_probe() change.
 1.2 20-Aug-1999  sommerfeld branches: 1.2.2; 1.2.4; 1.2.6; 1.2.10;
clean up attach messages slightly.
 1.1 27-Jun-1999  drochner branches: 1.1.2;
add driver for realtek 8129/8139, from freebsd, with mii stuff kicked out
 1.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.2.1 27-Jun-1999  thorpej file if_rl.c was added on branch chs-ubc2 on 1999-07-01 23:34:07 +0000
 1.2.10.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.6.2 20-Oct-1999  he Pull up revisions 1.1-1.2 + patch (requested by bouyer):
Back-port of the Realtek ethernet driver.
 1.2.6.1 20-Aug-1999  he file if_rl.c was added on branch netbsd-1-4 on 1999-10-20 23:39:22 +0000
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck, and commit Makefile which
I forgot in the batch of commits.
 1.8 10-May-2000  haya Move if_rl_pci.c:1.7 to if_rtk_pci.c.
 1.7 01-May-2000  tsutsui - Move some initialization into MI rl_attach() from each bus attachment.
- Use proper CARDBUS_* macro in if_rl_cardbus.c
- Use product ID read from PCI configuration space rather than from EEPROM
in if_rl_pci.c.

Patch sent from Masanori Kanaoka <kanaoka@ann.hi-ho.ne.jp> and
some cosmetic changes by me.
 1.6 30-Apr-2000  tsutsui Modify EEPROM read functions and handle also 9356 EEPROM.
Fixes kern/9861.
 1.5 26-Apr-2000  tsutsui - Allocate mbuf dynamically on Tx and use bus_dmamap_load_mbuf(9).
- Call bus_dmamap_sync(9) as appropriate.
- Leave only register declarations in rtl81x9reg.h and
split other stuff into rtl81x9var.h.

bus_dma(9) code mostly taken from thorpej's if_rtp.c.
 1.4 25-Apr-2000  tsutsui Fix two endian problems. rtk now works on macppc.

- Use le32toh() on reading rxstat from the Rx DMA buffer.
- rl_read_eeprom() should return EEPROM values in little endian
when caller requires byte-stream data.

bus_dma(9) fixes are still on-going.

XXX rtk on macppc seems to make tons of CRC errors...
XXX Does it work fine on i386 or others?
 1.3 24-Apr-2000  tsutsui Merge changes of sys/pci/if_rl.c rev. 1.8->1.10. (from kern/9870)
Also remove unused pbase, vbase and PCI_CAP_PWRMGMT declarations.
 1.2 19-Apr-2000  haya Changes the name of RealTek driver. The new name is `rtk'. This used
to be called `rl' and it conflict with RL vax disks, canonical and
historical unix driver name.

This changes are minimal: it only changes the name of RealTek driver.
The filename of source code and a lot of the letter `rl' in source
files should be changed shortly.
 1.1 10-Apr-2000  haya Incorporate the changes of RL81x9 driver provided by M. Kanaoka
<kanaoka@ann.hi-ho.ne.jp>. He separated the driver into IC specific
portion and bus attachment portion and added cardbus attachent.
 1.3 10-May-2000  thorpej These are no longer used.
 1.2 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.1 27-Jun-1999  drochner branches: 1.1.2; 1.1.4; 1.1.8;
add driver for realtek 8129/8139, from freebsd, with mii stuff kicked out
 1.1.8.2 20-Oct-1999  he Pull up revision 1.1 (requested by boyuer):
Back-port of the Realtek ethernet driver.
 1.1.8.1 27-Jun-1999  he file if_rlreg.h was added on branch netbsd-1-4 on 1999-10-20 23:44:52 +0000
 1.1.4.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck, and commit Makefile which
I forgot in the batch of commits.
 1.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.2.1 27-Jun-1999  thorpej file if_rlreg.h was added on branch chs-ubc2 on 1999-07-01 23:34:08 +0000
 1.48 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.47 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.46 09-May-2015  christos branches: 1.46.16; 1.46.18;
PR/49889: Maxim Tsyplakov: support for D-Link DFE520TX
 1.45 29-Mar-2014  christos branches: 1.45.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.44 30-Mar-2013  christos branches: 1.44.4;
remove trailing whitespace
 1.43 30-Jan-2012  drochner branches: 1.43.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.42 02-Nov-2010  jakllsch branches: 1.42.8; 1.42.12;
Explicitly set PCI_COMMAND_MASTER_ENABLE, in case the platform firmware didn't.
 1.41 27-Jul-2010  jakllsch Make the Realtek PCI network interfaces detachable.
Use __arraycount to avoid null table entries.
Miscellaneous other touch-ups in bus front-ends.
 1.40 26-Nov-2009  njoly branches: 1.40.2; 1.40.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.39 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.38 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.37 23-Aug-2008  tsutsui branches: 1.37.8;
Also match Realtek 8138, 8139D, and 8100.
 1.36 25-Apr-2008  tsutsui branches: 1.36.2; 1.36.4; 1.36.8;
Split device_t/softc for re(4) and rtk(4).
 1.35 09-Dec-2007  jmcneill branches: 1.35.10; 1.35.12;
Merge jmcneill-pm branch.
 1.34 06-Nov-2007  uwe branches: 1.34.2; 1.34.4;
Use device_t and device_private(). Convert attach to use aprint_*.
 1.33 19-Oct-2007  ad branches: 1.33.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.32 21-Mar-2007  tsutsui branches: 1.32.8; 1.32.10; 1.32.14;
Cleanup handling of quikrs on each RealTek chip:
- replace rtk_type member in rtk_softc which has chip types
with new rtk_quirk that represents quirks on each chip:
- RTKQ_8129 doesn't have internal MII (used in rtk(4))
- RTKQ_8139CPLUS has different register layout (for re(4))
- RTKQ_8169NONS (original 8169) requires some settings on init
- RTKQ_PCIE requires different settings in setmulti
so that we don't have to check each hwrev values or types everywhere
and newer variants will also work without changes if they don't
have other quirks
(sc_rev is unchenged for now for reference to the Realtek's driver)
- don't check hwrev register in re_pci_match() but check
only PCI_VENDER(), PCI_PRODUCT() and PCI_REVISION()
so that we no longer have to map pci space there
- add a new HWREV value for another 8168 variant
- try to map PCI mem space more properly
- remove (probably unneeded) ifp->if_baudrate initialization

Tested on a newer 8168 variant by Dennis den Brok on tech-kern,
and also tested on 8139 and 8169C on macppc, and 8139C+ on landisk
by me.
 1.31 25-Feb-2007  tsutsui branches: 1.31.4; 1.31.6; 1.31.8;
Try to map both PCI I/O and memory space and remove #ifdef RTK_USEIOSPACE.

Tested on dreamcast, landisk, and macppc with 8139C on PCI slot.
 1.30 16-Nov-2006  christos branches: 1.30.2; 1.30.4; 1.30.6;
__unused removal on arguments; approved by core.
 1.29 09-Nov-2006  tsutsui Print device revision on attach.
 1.28 27-Oct-2006  tsutsui Use common macro rather than local one.
 1.27 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.26 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.25 01-Sep-2006  uwe branches: 1.25.2; 1.25.4;
s/dreamcast/sh3/ to cover landisk.
 1.24 09-Mar-2006  he Add recognition of Nortel Baystack 21 as an rtk8139 variant.
Rest of information submitted in PR#33044.
 1.23 11-Dec-2005  christos branches: 1.23.4; 1.23.6; 1.23.8; 1.23.10;
merge ktrace-lwp.
 1.22 27-Jan-2005  jmcneill branches: 1.22.4; 1.22.6;
Add rtk_pci powerhook, from Kentaro A. Kurahone
 1.21 21-Aug-2004  thorpej branches: 1.21.4; 1.21.6;
Use ANSI function decls and make use of static.
 1.20 13-Feb-2004  wiz branches: 1.20.4;
RealTek -> Realtek.
 1.19 25-Oct-2003  fvdl Add definitions for 8139C+ and 8169 chips. Not used yet. From FreeBSD.
 1.18 29-Jan-2003  kanaoka branches: 1.18.2;
Set RTK_ENABLE flag when it attached. This fixed multicast problem.
Found by FUKAUMI Naoki <naoki@fukaumi.org>.
 1.17 23-Dec-2002  tsutsui Don't use PCI_PRODUCT_DELTA_8139 (0x1360) for args of pci_conf_read() and
pci_conf_write(); use PCI_INTERRUPT_REG (0x3c) instead. (How does it work?)
 1.16 23-Dec-2002  tsutsui Fix typo in printf message.
 1.15 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.14 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.13 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.12 06-Feb-2002  tsutsui branches: 1.12.10;
TAB/space cosmetics
 1.11 04-Feb-2002  tsutsui Remove chip description which is also mentioned in dev/ic/rtl81x9.c.
 1.10 13-Nov-2001  lukem add RCSID
 1.9 18-Jul-2001  thorpej Costmetic change.
 1.8 08-Jul-2001  thorpej branches: 1.8.2;
Remove unnecessary include files. From Onno van der Linden.
 1.7 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.6 11-Jun-2001  tron Add support for the D-Link DFE-530TX+. Patch supplied by
Gabriel Rosenkoetter in PR kern/13161.
 1.5 31-Jan-2001  thorpej branches: 1.5.2;
Match the SEGA Dreamcast Broadband Adapter, and use PCI memory
space on that device (XXX should be done differently than it is).
 1.4 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.3 19-May-2000  tsutsui branches: 1.3.4; 1.3.6;
- Change RL_* -> RTK_*
- Free bus_dma resources if attach fails
- Add detach and power management code

Patch from Masanori Kanaoka <kanaoka@ann.hi-ho.ne.jp> in kern/10156.
 1.2 15-May-2000  thorpej Symbol namespace cleanup: rl_ -> rtk_
 1.1 10-May-2000  haya Move if_rl_pci.c:1.7 to if_rtk_pci.c.
 1.3.6.4 11-Feb-2001  bouyer Sync with HEAD.
 1.3.6.3 05-Jan-2001  bouyer Sync with HEAD
 1.3.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 19-May-2000  bouyer file if_rtk_pci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:23 +0000
 1.3.4.1 11-Jun-2001  he Pull up revision 1.6 (requested by tron):
Support the D-Link DFE-530TX+. Fixes PR#13161.
 1.5.2.6 29-Dec-2002  thorpej Sync with HEAD.
 1.5.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.5.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.5.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.5.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.5.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.8.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.1 03-Aug-2001  lukem update to -current
 1.12.10.1 28-Apr-2003  tron Pull up revision 1.18 (requested by kanaoka in ticket #1134):
Set RTK_ENABLE flag when it attached. This fixed multicast problem.
Found by FUKAUMI Naoki <naoki@fukaumi.org>.
 1.18.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.18.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.4.1 17-Mar-2006  riz Pull up following revision(s) (requested by hw in ticket #10364):
sys/dev/pci/if_rtk_pci.c: revision 1.24
Add recognition of Nortel Baystack 21 as an rtk8139 variant.
Rest of information submitted in PR#33044.
 1.21.6.1 12-Feb-2005  yamt sync with head.
 1.21.4.1 29-Apr-2005  kent sync with -current
 1.22.6.7 21-Jan-2008  yamt sync with head
 1.22.6.6 15-Nov-2007  yamt sync with head.
 1.22.6.5 27-Oct-2007  yamt sync with head.
 1.22.6.4 03-Sep-2007  yamt sync with head.
 1.22.6.3 26-Feb-2007  yamt sync with head.
 1.22.6.2 30-Dec-2006  yamt sync with head.
 1.22.6.1 21-Jun-2006  yamt sync with head.
 1.22.4.3 04-Oct-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1852):
sys/dev/ic/rtl81x9var.h: revision 1.39
sys/dev/cardbus/if_re_cardbus.c: revision 1.13
sys/dev/pci/if_re_pci.c: revision 1.27 via patch
sys/dev/pci/if_rtk_pci.c: revision 1.32
sys/dev/cardbus/if_rtk_cardbus.c: revision 1.32
sys/dev/ic/rtl8169.c: revision 1.84, 1.85
sys/dev/ic/rtl81x9reg.h: revision 1.27
sys/dev/ic/rtl81x9.c: revision 1.72
Cleanup handling of quikrs on each RealTek chip:
Pull a fix for PCIe variants from FreeBSD
 1.22.4.2 03-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1673):
distrib/sets/lists/man/mi 1.844, 1.871
share/man/man4/Makefile 1.372, 1.379 via patch
share/man/man4/re.4 1.8, 1.9, 1.11, 1.12
share/man/man4/rgephy.4 1.1
share/man/man4/rlphy.4 1.1, 1.2
sys/arch/amd64/conf/GENERIC 1.79, 1.89
sys/arch/amd64/conf/INSTALL 1.45, 1.49
sys/arch/i386/conf/GENERIC 1.717, 1.747
sys/arch/i386/conf/GENERIC_LAPTOP 1.164
sys/arch/i386/conf/INSTALL 1.277, 1.283
sys/arch/i386/conf/INSTALL_LAPTOP 1.96, 1.98
sys/arch/i386/conf/XEN2_DOM0 1.22 via patch
sys/arch/macppc/conf/GENERIC 1.220, 1.246
sys/arch/macppc/conf/INSTALL 1.96, 1.100
sys/dev/cardbus/if_re_cardbus.c 1.10
sys/dev/cardbus/if_rtk_cardbus.c 1.29-1.31
sys/dev/ic/rtl8169.c 1.14, 1.20, 1.24, 1.25, 1.28-1.61, 1.63, 1.64-1.81 via patch
sys/dev/ic/rtl81x9.c 1.52, 1.54-1.63, 1.65, 1.67-1.70
sys/dev/ic/rtl81x9reg.h 1.15-1.26
sys/dev/ic/rtl81x9var.h 1.19, 1.21-1.37
sys/dev/mii/files.mii 1.38
sys/dev/mii/miidevs 1.62, 1.64
sys/dev/mii/rgephy.c 1.10, 1.13-1.16
sys/dev/mii/rlphy.c 1.1, 1.6, 1.7, 1.11 via patch
sys/dev/pci/if_re_pci.c 1.13, 1.15-1.17, 1.19-1.23
sys/dev/pci/if_rtk_pci.c 1.25, 1.28, 1.29, 1.31
sys/dev/pci/pcidevs 1.851, 1.852

on re(4):
- improve stability (I believe ;-)
- add a workaround for hardware ip4csum-tx bug
- support newer chips (8169SB/SC, PCIe based 8168 etc.)
- fix 8139C+ support
- enable hardware VLAN
- misc bus_dma(9) fix (which makes re(4) work on mips ports)

on rtk(4):
- fix kern/31348
- fix possible panic on dreamcast
 1.22.4.1 17-Mar-2006  tron Pull up following revision(s) (requested by he in ticket #1203):
sys/dev/pci/if_rtk_pci.c: revision 1.24
Add recognition of Nortel Baystack 21 as an rtk8139 variant.
Rest of information submitted in PR#33044.
 1.23.10.1 19-Apr-2006  elad sync with head.
 1.23.8.2 03-Sep-2006  yamt sync with head.
 1.23.8.1 13-Mar-2006  yamt sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.25.4.2 10-Dec-2006  yamt sync with head.
 1.25.4.1 22-Oct-2006  yamt sync with head
 1.25.2.1 18-Nov-2006  ad Sync with head.
 1.30.6.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.30.4.2 24-Mar-2007  yamt sync with head.
 1.30.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.30.2.1 16-May-2007  jdc Pull up revision 1.32 (requested by tsutsui in ticket #640).

Cleanup handling of quikrs on each RealTek chip:
- replace rtk_type member in rtk_softc which has chip types
with new rtk_quirk that represents quirks on each chip:
- RTKQ_8129 doesn't have internal MII (used in rtk(4))
- RTKQ_8139CPLUS has different register layout (for re(4))
- RTKQ_8169NONS (original 8169) requires some settings on init
- RTKQ_PCIE requires different settings in setmulti
so that we don't have to check each hwrev values or types everywhere
and newer variants will also work without changes if they don't
have other quirks
(sc_rev is unchenged for now for reference to the Realtek's driver)
- don't check hwrev register in re_pci_match() but check
only PCI_VENDER(), PCI_PRODUCT() and PCI_REVISION()
so that we no longer have to map pci space there
- add a new HWREV value for another 8168 variant
- try to map PCI mem space more properly
- remove (probably unneeded) ifp->if_baudrate initialization

Tested on a newer 8168 variant by Dennis den Brok on tech-kern,
and also tested on 8139 and 8169C on macppc, and 8139C+ on landisk
by me.
 1.31.8.1 29-Mar-2007  reinoud Pullup to -current
 1.31.6.1 11-Jul-2007  mjf Sync with head.
 1.31.4.2 23-Oct-2007  ad Sync with head.
 1.31.4.1 10-Apr-2007  ad Sync with head.
 1.32.14.2 13-Nov-2007  bouyer Sync with HEAD
 1.32.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.32.10.2 09-Jan-2008  matt sync with HEAD
 1.32.10.1 06-Nov-2007  matt sync with HEAD
 1.32.8.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.32.8.5 06-Nov-2007  joerg Sync with HEAD.
 1.32.8.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.32.8.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.32.8.2 05-Oct-2007  joerg Remove the power management nonsense in the PCI versions of
rtk(4) and re(4). It is not really likely to work anyway.
Use PNP power management for the cardbus attachment as well and
remove the power management handlers from the chipset code.
 1.32.8.1 05-Oct-2007  joerg Convert rtk/pci to PNP power management.
 1.33.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.33.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.34.4.1 11-Dec-2007  yamt sync with head.
 1.34.2.1 26-Dec-2007  ad Sync with head.
 1.35.12.1 18-May-2008  yamt sync with head.
 1.35.10.2 28-Sep-2008  mjf Sync with HEAD.
 1.35.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.36.8.1 19-Oct-2008  haad Sync with HEAD.
 1.36.4.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.2.5 11-Aug-2010  yamt sync with head.
 1.36.2.4 11-Mar-2010  yamt sync with head
 1.36.2.3 16-Sep-2009  yamt sync with head
 1.36.2.2 16-May-2009  yamt sync with head
 1.36.2.1 04-May-2009  yamt sync with head.
 1.37.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.40.4.1 05-Mar-2011  rmind sync with head
 1.40.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.40.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.42.12.1 18-Feb-2012  mrg merge to -current.
 1.42.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.8.1 17-Apr-2012  yamt sync with head
 1.43.6.3 03-Dec-2017  jdolecek update from HEAD
 1.43.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.6.1 23-Jun-2013  tls resync from head
 1.44.4.1 18-May-2014  rmind sync with head
 1.45.6.1 06-Jun-2015  skrll Sync with HEAD
 1.46.18.1 10-Jun-2019  christos Sync with HEAD
 1.46.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.25 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.24 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.23 29-Mar-2014  christos branches: 1.23.28; 1.23.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.22 30-Sep-2012  dsl branches: 1.22.2;
Fix debug build
 1.21 23-Sep-2012  chs reformat product array to match openbsd.
 1.20 26-Jul-2011  dyoung branches: 1.20.2; 1.20.12;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.19 26-Jan-2011  dyoung Make oodles of mainly cosmetic changes that make rtw(4)'s PCI attachment
resemble its CardBus attachment very, very closely: slightly more than
24 lines are different. Alas, I cannot commit the CardBus part of this
change, yet, because I have to finish my overhaul of CardBus resource
handling, first.
 1.18 04-Mar-2010  dyoung branches: 1.18.2; 1.18.4; 1.18.6;
Make cosmetic changes in order to reduce differences with
sys/dev/cardbus/if_rtw_cardbus.c: remove an unnecessary #include.
Change a few cut & paste instances of ADM8211 to RTL8180. Make the
suspend & resume functions static, add declarations for them at the top
of the file, and move the functions themselves to the bottom.
 1.17 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.16 08-Jan-2010  dyoung branches: 1.16.2;
Expand PMF_FN_* macros.
 1.15 16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.14 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.13 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.12 28-Apr-2008  martin branches: 1.12.14;
Remove clause 3 and 4 from TNF licenses
 1.11 21-Mar-2008  dyoung branches: 1.11.2; 1.11.4;
pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.10 12-Mar-2008  dyoung Use device_t and its accessors throughout. Use aprint_*_dev().

Improve PMF-ability.

Add a 'flags' argument to suspend/resume handlers and
callers such as pmf_system_suspend().

Define a flag, PMF_F_SELF, which indicates to PMF that a
device is suspending/resuming itself. Add helper routines,
pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
that call pmf_device_suspend(dev, PMF_F_SELF) and
pmf_device_resume(dev, PMF_F_SELF), respectively. Use
PMF_F_SELF to suspend/resume self in ath(4), audio(4),
rtw(4), and sip(4).

In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
callbacks, provided by the bus front-end, with
self-suspension/resumption. Also, clean up the bus
front-ends. Make sure that the interrupt handler is
disestablished during suspension. Get rid of driver-private
flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
device_is_active()/device_has_power() calls, instead.

In the network-class suspend handler, call if_stop(, 0)
instead of if_stop(, 1), because the latter is superfluous
(bus- and driver-suspension hooks will 'disable' the NIC),
and it may cause recursion.

In the network-class resume handler, prevent infinite
recursion through if_init() by getting out early if we are
self-suspending (PMF_F_SELF).

rtw(4) improvements:

Destroy rtw(4) callouts when we detach it. Make rtw at
pci detachable. Print some more information with the "rx
frame too long" warning.

Remove activate() methods:

Get rid of rtw_activate() and ath_activate(). The device
activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

Introduce a boolean device property, "pmf-powerdown". If
pmf-powerdown is present and false, it indicates that a
bus back-end should not remove power from a device.

Honor this property in cardbus_child_suspend().

Set this property to 'false' in ath_attach(), since removing
power from an ath at cardbus seems to lobotomize the WPA
crypto engine. XXX Should the pmf-powerdown property
propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

Warn if ath(4) tries to write crypto keys to suspended
hardware.

Reduce differences between FreeBSD and NetBSD in ath(4)
multicast filter setup.

Make ath_printrxbuf() print an rx descriptor's status &
key index, to help debug crypto errors.

Shorten a staircase in ath_ioctl(). Don't check for
ieee80211_ioctl() return code ERESTART, it never happens.
 1.9 21-Dec-2007  dyoung branches: 1.9.2; 1.9.6;
Do not embed a struct device in rtw_softc any longer. Register
both pci and cardbus attachments with CFATTACH_DECL_NEW(). Access
the softc through the device_t using device_private().

While I'm here, change a couple of KASSERT()s about the Rx buffer
length to a warning.
 1.8 19-Oct-2007  ad branches: 1.8.4; 1.8.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.7 01-Sep-2006  dyoung branches: 1.7.12; 1.7.26; 1.7.28; 1.7.32;
Remove the declaration of an unused local variable 'reg'.
 1.6 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.5 28-Apr-2006  rpaulo branches: 1.5.2; 1.5.4;
Use aprint family of functions.
 1.4 04-Dec-2005  christos branches: 1.4.4; 1.4.6; 1.4.8; 1.4.10; 1.4.12;
PR/32181: Matthias-Christian Ott: Add support for the Belkin F5D6001 pci device
 1.3 22-Jun-2005  dyoung branches: 1.3.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 26-Sep-2004  dyoung branches: 1.1.2; 1.1.6; 1.1.8;
Add Cardbus, PCI bus front-ends for RTL8180 802.11b MAC/baseband.
 1.1.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 29-Apr-2005  kent sync with -current
 1.1.2.5 11-Dec-2005  christos Sync with head.
 1.1.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 19-Oct-2004  skrll Sync with HEAD
 1.1.2.1 26-Sep-2004  skrll file if_rtw_pci.c was added on branch ktrace-lwp on 2004-10-19 15:56:59 +0000
 1.3.2.6 24-Mar-2008  yamt sync with head.
 1.3.2.5 17-Mar-2008  yamt sync with head.
 1.3.2.4 21-Jan-2008  yamt sync with head
 1.3.2.3 27-Oct-2007  yamt sync with head.
 1.3.2.2 30-Dec-2006  yamt sync with head.
 1.3.2.1 21-Jun-2006  yamt sync with head.
 1.4.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.4.10.1 11-May-2006  elad sync with head
 1.4.8.3 03-Sep-2006  yamt sync with head.
 1.4.8.2 26-Jun-2006  yamt sync with head.
 1.4.8.1 24-May-2006  yamt sync with head.
 1.4.6.1 01-Jun-2006  kardel Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.2.1 19-Jun-2006  chap Sync with head.
 1.7.32.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.28.3 23-Mar-2008  matt sync with HEAD
 1.7.28.2 09-Jan-2008  matt sync with HEAD
 1.7.28.1 06-Nov-2007  matt sync with HEAD
 1.7.26.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.12.1 23-Oct-2007  ad Sync with head.
 1.8.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.4.1 26-Dec-2007  ad Sync with head.
 1.9.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.2.1 24-Mar-2008  keiichi sync with head.
 1.11.4.4 11-Mar-2010  yamt sync with head
 1.11.4.3 16-Sep-2009  yamt sync with head
 1.11.4.2 16-May-2009  yamt sync with head
 1.11.4.1 16-May-2008  yamt sync with head.
 1.11.2.1 18-May-2008  yamt sync with head.
 1.12.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.18.6.1 08-Feb-2011  bouyer Sync with HEAD
 1.18.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.2.1 05-Mar-2011  rmind sync with head
 1.20.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.20.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.2.1 30-Oct-2012  yamt sync with head
 1.22.2.1 18-May-2014  rmind sync with head
 1.23.30.1 10-Jun-2019  christos Sync with HEAD
 1.23.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.21 01-Aug-2023  mrg fix simple mis-matched function prototype and definitions.

most of these are like, eg

void foo(int[2]);

with either of these

void foo(int*) { ... }
void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
 1.20 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.19 30-Jan-2020  thorpej branches: 1.19.10;
Adopt <net/if_stats.h>.
 1.18 09-Dec-2018  jdolecek branches: 1.18.6;
use pci_intr_establish_xname() everywhere
 1.17 29-Jun-2018  thorpej - Unify the "rtwn" and "urtwn" register definitions and initialization
tables into common header files shared by both drivers.
- Fix some register and bit definitions, from OpenBSD and verified against
the vendor driver.
- Add some additional register / descriptor defnitions, from OpenBSD.
 1.16 26-Jun-2018  msaitoh branches: 1.16.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.15 06-Apr-2018  macallan in rtwn_attach(): return; before unconditionally running into fail:
 1.14 08-Feb-2018  dholland branches: 1.14.2;
Typos.
 1.13 23-Oct-2017  msaitoh branches: 1.13.2;
If if_initialize() failed in the attach function, free resources and return.
 1.12 18-May-2017  nonaka branches: 1.12.2;
Fixed m is not freed if m_defrag() fails.
 1.11 02-Feb-2017  nonaka branches: 1.11.4;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.10 24-Jan-2017  nonaka rtwn(4): increase the number of tx queue required to clear the full mask.
 1.9 08-Dec-2016  ozaki-r branches: 1.9.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.8 10-Jun-2016  ozaki-r branches: 1.8.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.7 26-May-2016  ozaki-r Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.
 1.6 26-May-2016  ozaki-r Use M_GETCTX

No functional change.
 1.5 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.4 06-Feb-2016  riastradh Missed a spot.
 1.3 06-Feb-2016  riastradh Avoid shadowing global `max' from libkern.
 1.2 06-Nov-2015  nonaka Always use pci_intr_alloc(9)/pci_intr_release(9).
 1.1 27-Aug-2015  nonaka branches: 1.1.2;
Added rtwn(4) for Realtek RTL8188CE/RTL8192CE PCIe 802.11b/g/n wireless network
devices. Ported from OpenBSD.
 1.1.2.8 28-Aug-2017  skrll Sync with HEAD
 1.1.2.7 05-Feb-2017  skrll Sync with HEAD
 1.1.2.6 09-Jul-2016  skrll Sync with HEAD
 1.1.2.5 29-May-2016  skrll Sync with HEAD
 1.1.2.4 19-Mar-2016  skrll Sync with HEAD
 1.1.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 27-Aug-2015  skrll file if_rtwn.c was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.8.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.8.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.4.1 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.12.2.2 09-Apr-2018  bouyer Pull up following revision(s) (requested by msaitoh in ticket #719):
sys/dev/pci/if_rtwn.c: revision 1.15
in rtwn_attach(): return; before unconditionally running into fail:
 1.12.2.1 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.13.2.2 03-Dec-2017  jdolecek update from HEAD
 1.13.2.1 23-Oct-2017  jdolecek file if_rtwn.c was added on branch tls-maxphys on 2017-12-03 11:37:08 +0000
 1.14.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.14.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.14.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.16.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.16.2.1 10-Jun-2019  christos Sync with HEAD
 1.18.6.1 29-Feb-2020  ad Sync with head.
 1.19.10.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.6 05-Oct-2019  mrg remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned. codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
 1.5 29-Jun-2018  thorpej - Unify the "rtwn" and "urtwn" register definitions and initialization
tables into common header files shared by both drivers.
- Fix some register and bit definitions, from OpenBSD and verified against
the vendor driver.
- Add some additional register / descriptor defnitions, from OpenBSD.
 1.4 02-Feb-2017  nonaka branches: 1.4.12; 1.4.14; 1.4.16;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.3 24-Jan-2017  nonaka rtwn(4): increase the number of tx queue required to clear the full mask.
 1.2 06-Nov-2015  nonaka branches: 1.2.2; 1.2.4;
Always use pci_intr_alloc(9)/pci_intr_release(9).
 1.1 27-Aug-2015  nonaka branches: 1.1.2;
Added rtwn(4) for Realtek RTL8188CE/RTL8192CE PCIe 802.11b/g/n wireless network
devices. Ported from OpenBSD.
 1.1.2.4 05-Feb-2017  skrll Sync with HEAD
 1.1.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 27-Aug-2015  skrll file if_rtwnreg.h was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.2.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.16.1 10-Jun-2019  christos Sync with HEAD
 1.4.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.4.12.2 03-Dec-2017  jdolecek update from HEAD
 1.4.12.1 02-Feb-2017  jdolecek file if_rtwnreg.h was added on branch tls-maxphys on 2017-12-03 11:37:08 +0000
 1.23 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.22 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.21 07-Jul-2016  msaitoh branches: 1.21.16; 1.21.18;
KNF. Remove extra spaces. No functional change.
 1.20 29-Mar-2014  christos branches: 1.20.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.19 27-Oct-2012  chs branches: 1.19.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.18 26-Nov-2009  njoly branches: 1.18.12; 1.18.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.17 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.16 28-Apr-2008  martin branches: 1.16.14;
Remove clause 3 and 4 from TNF licenses
 1.15 10-Apr-2008  cegger branches: 1.15.2; 1.15.4;
use aprint_*_dev and device_xname
 1.14 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.13 19-Oct-2007  ad branches: 1.13.12; 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 17-Jun-2006  christos branches: 1.10.4; 1.10.6;
re-factor the pci powestate api. reviewed by gimpy
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.8; 1.9.14; 1.9.16;
merge ktrace-lwp.
 1.8 21-Aug-2004  thorpej branches: 1.8.12;
Use ANSI function decls and make use of static.
 1.7 23-Dec-2002  tsutsui branches: 1.7.2;
Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 08-Jul-2001  thorpej branches: 1.2.2;
Remove unnecessary include files. From Onno van der Linden.
 1.1 18-Jun-2001  thorpej branches: 1.1.2;
Add support for the Adaptec AIC-6915 10/100 Ethernet. This is
a 64-bit PCI chip, available in 1, 2, and 4 port models.
 1.1.2.6 29-Dec-2002  thorpej Sync with HEAD.
 1.1.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.1.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.1 18-Jun-2001  nathanw file if_sf_pci.c was added on branch nathanw_sa on 2001-06-21 20:04:49 +0000
 1.2.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.8.12.4 24-Mar-2008  yamt sync with head.
 1.8.12.3 27-Oct-2007  yamt sync with head.
 1.8.12.2 30-Dec-2006  yamt sync with head.
 1.8.12.1 21-Jun-2006  yamt sync with head.
 1.9.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.9.14.1 19-Jun-2006  chap Sync with head.
 1.9.8.1 26-Jun-2006  yamt sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.6.2 10-Dec-2006  yamt sync with head.
 1.10.6.1 22-Oct-2006  yamt sync with head
 1.10.4.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.2 23-Mar-2008  matt sync with HEAD
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.12.1 24-Mar-2008  keiichi sync with head.
 1.15.4.3 11-Mar-2010  yamt sync with head
 1.15.4.2 16-May-2009  yamt sync with head
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.22.3 03-Dec-2017  jdolecek update from HEAD
 1.18.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.12.1 30-Oct-2012  yamt sync with head
 1.19.2.1 18-May-2014  rmind sync with head
 1.20.6.1 09-Jul-2016  skrll Sync with HEAD
 1.21.18.1 10-Jun-2019  christos Sync with HEAD
 1.21.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.193 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.192 29-Jun-2024  riastradh branches: 1.192.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.191 10-Feb-2024  andvar s/alloted/allotted/ in comments.
 1.190 02-Jun-2023  andvar follow the steps of Andrew Doran (ad) commit and fix more s/loose/lose/ typos.
also s/beyound/beyond/ and few others along the way, mainly in comments.
 1.189 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.188 11-Sep-2022  ryo Packets larger than 1518 bytes (1522 bytes if VLAN tag is included) are no longer received.
Previously, those packets were received as truncated (incomplete) packets.
 1.187 06-Aug-2022  riastradh sip(4): Tidy up DMA syncs.

- No membar_producer in sip_init_rxdesc -- use bus_dmamap_sync with
BUS_DMASYNC_PREWRITE to order updates to the DMA descriptors.

- Omit needless membar_producer in sip_init_txdesc -- the hardware
will not look at any of these descriptors until we set CMDSTS_OWN
on the first one in the sequence, which is done later in the
caller, sipcom_start.

- In gsip_rxintr, make sure to read cmdsts _before_ extsts, by
separating them with BUS_DMASYNC_PREREAD. Otherwise, the CPU might
reorder the loads and read a stale extsts first before witnessing
an updated cmdsts with the CMDSTS_OWN bit that transfers ownership
of the rx packet to us.
 1.186 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.185 16-Feb-2022  andvar fix various typos, mainly in comments.
 1.184 31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.183 21-Oct-2021  andvar fix various typos, mainly in comments, but also in man pages and log messages.
 1.182 16-Mar-2020  thorpej Do the "have transmit resources available" check before checking that
there is a packet in the send queue.
 1.181 15-Mar-2020  thorpej Don't bother with IFF_OACTIVE.
 1.180 13-Mar-2020  thorpej Adjust the logic for enabling the 64-bit data path when a 64-bit slot
is detected:
- If DATA64_EN isn't set in CFG after a reset, don't use 64-bit data path
at all (it's been disabled by an EEPROM setting).
- Provide a hook for force-disabling the 64-bit data path.
- Otherwise, perform the "known 64-bit cards" check as done previously
(because dodgy-vendor-EEPROM-settings still applies).
 1.179 08-Mar-2020  thorpej Support 64-bit DMA addressing on the DP83820, used only when a 64-bit
DMA tag is available.
 1.178 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.177 04-Feb-2020  thorpej Use ifmedia_fini().
 1.176 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.175 13-Sep-2019  msaitoh branches: 1.175.2;
if_flags is neither int nor short. It's unsigned short.
 1.174 09-Jul-2019  msaitoh Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.173 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.172 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.171 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.170 26-Apr-2019  msaitoh Fix a bug that read value of MII_EXTSR register on TBI mode always fails.
This bug was added in rev. 1.169.
 1.169 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.168 26-Jun-2018  msaitoh branches: 1.168.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.167 26-Sep-2017  knakahara branches: 1.167.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.166 10-May-2017  msaitoh branches: 1.166.2;
Use pci_intr_establish_xname().
 1.165 15-Dec-2016  ozaki-r branches: 1.165.6;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.164 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.163 14-Jul-2016  msaitoh branches: 1.163.2;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.162 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.161 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.160 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.159 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.158 10-Aug-2014  tls branches: 1.158.4;
Merge tls-earlyentropy branch into HEAD.
 1.157 29-Mar-2014  christos branches: 1.157.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.156 30-Mar-2013  christos branches: 1.156.4;
remove trailing whitespace
 1.155 23-Sep-2012  chs match some more devices.
 1.154 22-Jul-2012  matt branches: 1.154.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.153 02-Feb-2012  tls branches: 1.153.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.152 12-Dec-2011  jakllsch Using BUS_DMA_NOCACHE for bus_dmamem_map() causes issues on (at least) sparc64.
 1.151 19-Nov-2011  tls branches: 1.151.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.150 15-Oct-2011  dholland branches: 1.150.2;
"return f();" where both f and the enclosing function return void is
sometimes convenient. But, it's not standard, so don't do it.
 1.149 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.148 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.147 24-Feb-2010  dyoung branches: 1.147.2;
Use device_suspensor_t.
 1.146 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.145 19-Jan-2010  pooka branches: 1.145.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.144 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.143 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.142 16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.141 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.140 05-May-2009  dyoung Change struct cfdata * to cfdata_t. No functional change intended.
 1.139 05-May-2009  cegger device_t/softc split
tested by and ok dyoung@
 1.138 02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.137 27-Mar-2009  dyoung If a sip(4) is powered down, then so is its PHY, so don't try to read
media status from the PHY.
 1.136 07-Mar-2009  dyoung Don't try to write the registers of the NIC to stop it if it is
already powered down. This change prevents PCI bus exceptions
(indicated by NMI) when, for example, I detach the whole device
tree on a Soekris net4521:

com1: detached
NMI ... going to debugger
Stopped in pid 0.1 (system) at netbsd:sipcom_stop+0x4d: pushl $0
db{0}> continue
NMI ... going to debugger
Stopped in pid 0.1 (system) at netbsd:sipcom_stop+0x149: addl $0x10,%e
sp
db{0}> continue
sip0: detached

(On the AMD Elan SC520, the NMI occurs at the instruction after
the write or, if the write was posted, at either that instruction
or some later one.)
 1.135 07-Nov-2008  dyoung branches: 1.135.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.134 05-May-2008  dyoung branches: 1.134.6; 1.134.8;
Make PCI power re-activation DTRT: pass pci_activate_null instead
of NULL to pci_activate()

Call the variable where we store the PCI Command & Status Register
'csr' instead of 'pmreg'.

In sipcom_intr(), get out if the device is inactive. Otherwise
sip(4) may inadvertently try to handle a shared interrupt before
the driver state is completely set up.
 1.133 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.132 10-Apr-2008  cegger branches: 1.132.2; 1.132.4;
use aprint_*_dev and device_xname
 1.131 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.130 12-Mar-2008  dyoung Use device_t and its accessors throughout. Use aprint_*_dev().

Improve PMF-ability.

Add a 'flags' argument to suspend/resume handlers and
callers such as pmf_system_suspend().

Define a flag, PMF_F_SELF, which indicates to PMF that a
device is suspending/resuming itself. Add helper routines,
pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
that call pmf_device_suspend(dev, PMF_F_SELF) and
pmf_device_resume(dev, PMF_F_SELF), respectively. Use
PMF_F_SELF to suspend/resume self in ath(4), audio(4),
rtw(4), and sip(4).

In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
callbacks, provided by the bus front-end, with
self-suspension/resumption. Also, clean up the bus
front-ends. Make sure that the interrupt handler is
disestablished during suspension. Get rid of driver-private
flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
device_is_active()/device_has_power() calls, instead.

In the network-class suspend handler, call if_stop(, 0)
instead of if_stop(, 1), because the latter is superfluous
(bus- and driver-suspension hooks will 'disable' the NIC),
and it may cause recursion.

In the network-class resume handler, prevent infinite
recursion through if_init() by getting out early if we are
self-suspending (PMF_F_SELF).

rtw(4) improvements:

Destroy rtw(4) callouts when we detach it. Make rtw at
pci detachable. Print some more information with the "rx
frame too long" warning.

Remove activate() methods:

Get rid of rtw_activate() and ath_activate(). The device
activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

Introduce a boolean device property, "pmf-powerdown". If
pmf-powerdown is present and false, it indicates that a
bus back-end should not remove power from a device.

Honor this property in cardbus_child_suspend().

Set this property to 'false' in ath_attach(), since removing
power from an ath at cardbus seems to lobotomize the WPA
crypto engine. XXX Should the pmf-powerdown property
propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

Warn if ath(4) tries to write crypto keys to suspended
hardware.

Reduce differences between FreeBSD and NetBSD in ath(4)
multicast filter setup.

Make ath_printrxbuf() print an rx descriptor's status &
key index, to help debug crypto errors.

Shorten a staircase in ath_ioctl(). Don't check for
ieee80211_ioctl() return code ERESTART, it never happens.
 1.129 11-Mar-2008  dyoung Use device_t and accessors.
 1.128 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.127 07-Feb-2008  dyoung branches: 1.127.2; 1.127.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.126 19-Jan-2008  dyoung Let ether_ioctl() handle default SIOCSIFMEDIA/SIOCGIFMEDIA actions.
 1.125 10-Jan-2008  dyoung Re-use ether_mediachange(), ether_mediastatus(). Stop using
shutdownhook_establish(9).
 1.124 16-Dec-2007  dyoung Convert many macros to inline subroutines. Some of the subroutines
probably should not be inline.
 1.123 15-Dec-2007  dyoung sip_copy_small and gsip_copy_small should not be static any longer.
Make it so.
 1.122 15-Dec-2007  he Only declare sip_copy_small under __NO_STRICT_ALIGNMENT, to afoid
a "defined but not used" warning turned into error by compiler options.
 1.121 15-Dec-2007  dyoung Take care to release all resources. Now I can 'drvctl -d sip0;
drvctl -r pci0' to to detach / re-attach a sip0.
 1.120 15-Dec-2007  dyoung Finish making the sip(4) and gsip(4) drivers share compiled code.
 1.119 15-Dec-2007  dyoung Attach sip to 10/100 variants, gsip to gigabit variants. Thanks
Izumi Tsutsui for the bug report.
 1.118 14-Dec-2007  dogcow fix KDASSERTs by defining ifp
 1.117 14-Dec-2007  dyoung Simplify suspend/resume using device_has_power().
 1.116 14-Dec-2007  dyoung Take a step toward sharing compiled code between sip(4) and gsip(4):
get rid of SIP_DECL() and reduce #ifdef DP83820 code. Next step
is to move a bunch of shared code to a new file (if_sipcom.c, say)
and compile it *once*.

While I am here, add suspend/resume handling to sip(4) and to
gsip(4).

Tested with the NatSemi sip(4) on the Soekris net4521. I don't
have any gsip(4) to test with, and it seems that the few holders
of gsip(4) in the world keep them in their attic, anyway.
 1.115 19-Oct-2007  ad branches: 1.115.2; 1.115.4; 1.115.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.114 29-Aug-2007  dyoung branches: 1.114.4;
Constify: LLADDR() -> CLLADDR().
 1.113 09-Jul-2007  ad branches: 1.113.2; 1.113.6; 1.113.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.112 04-Mar-2007  yamt branches: 1.112.2; 1.112.4;
fix fallout from caddr_t changes.
 1.111 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.110 16-Nov-2006  christos branches: 1.110.4;
__unused removal on arguments; approved by core.
 1.109 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.108 17-Jun-2006  christos branches: 1.108.4; 1.108.6;
re-factor the pci powestate api. reviewed by gimpy
 1.107 18-Apr-2006  pavel branches: 1.107.2; 1.107.4;
VLAN tags were sent byte-swapped by the gsip driver, because the driver
forgets to convert them from the host to the network byte order. Use
bswap16 to convert them. (Not htons, because on a big-endian machine, they
are in the correct byte order initially, but then, they are byte-swapped
by a htole32 call when written to the transmit descriptor. So
byte-swapping is needed in this case too, to compensate for this htole32
call.)

For a similar reason, tags were seen byte-swapped when received on a
big-endian machine. Replace ntohs by bswap16 in the input path too.
(Again, it is needed to compensate for a le32toh call when the receive
descriptor is read.)

Fixes PR 32644.

Tested on 3.0/i386, 3.0/sgimips and current/alpha.

OK by martin@.
 1.106 10-Apr-2006  pavel In rev. 1.98, the ioctl method of the (g)sip drivers was optimized for
SIOCSIFFLAGS: it compares the new flags with the old flags and avoids
reset if there are only certain changes. This was done to fix PR 29126.

It does not take into account, though, that there is other state which
can change and SIOCSIFFLAGS is called to inform about it. Namely,
if_capenable, ec_capenable and ec_nvlans. For all three, the _init
method must program the hardware specially. Not doing it resulted in:
- VLAN frames getting truncated
- hw checksumming not working
- outgoing VLAN frames not being tagged when they should
- incoming VLAN frames being treated as untagged.

Fix by keeping all the old state in the softc and initializing the
hardware if any of it changes.

Tested on gsip. Also tested by Nino Dehne and Martin J. Laubach
on sip, thanks.

Fixes PRs 32900 and 33216.

Approved by martin@ .
 1.105 27-Mar-2006  bouyer MCLAIM() mbufs allocated here.
 1.104 07-Feb-2006  thorpej branches: 1.104.2; 1.104.4; 1.104.6;
In the receive interrupt handler, compute the packet length before resetting
m to point to the first buffer in the packet. The bug would cause the
length of jumbo frames to be incorrect.
 1.103 11-Dec-2005  christos branches: 1.103.2; 1.103.4; 1.103.6;
merge ktrace-lwp.
 1.102 02-May-2005  yamt branches: 1.102.2;
split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.101 27-Feb-2005  perry branches: 1.101.2;
nuke trailing whitespace
 1.100 20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition
 1.99 06-Feb-2005  cube Initialize 'error' in all cases in ioctl handler, otherwise it doesn't
compile (and of course might return garbage). [hi kim!]
 1.98 06-Feb-2005  kim If the interface is up and running, only modify the receive filter
when setting promiscuous or debug mode. This avoids resetting the
chip unnecessarily.

Fixes PR kern/29126.
 1.97 30-Jan-2005  thorpej - Fix some logic errors in multi-descriptor packet reception case for
DP83820.
- Eliminate use of M_HASFCS.
 1.96 30-Oct-2004  thorpej branches: 1.96.4; 1.96.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.95 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.94 15-May-2004  thorpej Add PAUSE-related event counters for sip(4) and gsip(4), slightly modified
from a patch supplied by HITOSHI Osada.
 1.93 15-May-2004  thorpej Patch from HITOSHI Osada:
* On the DP83820, don't set PCR_PS_DA if the PAUSE packet address is
not registered in the multicast filter.
 1.92 15-May-2004  thorpej Patch from HITOSHI Osada:
* SiS900 chips require the address of the PAUSE packet to be registered
in the multicast filter.
 1.91 09-May-2004  fair Two changes:
1. ifdef out the restriction that the SiS 900 has only one PHY
This is demonstrably false; the SiS 960 super south bridge in
PR 18590 has a SiS 900 rev 1 core in it.

2. bitbang the MII for all versions of the SiS 900; this is the
only way that the PHYs on this system answer.

Also, I suspect that SIS900_REV_960 constant in if_sipreg.h is
incorrectly labelled - there were later revisions of the super
south bridge (e.g. the 961, 962, and 963), and I suspect the
SiS 900 revision code there refers to one of those.
 1.90 22-Apr-2004  enami If defined(DP83820), (always) drop IFF_OACTIVE if we got txintr.
Otherwise, the driver simply stuck once we face tx resource shortage.
 1.89 11-Apr-2004  thorpej Flow control support for DP83820 and SiS900. From HITOSHI Osada.
 1.88 11-Apr-2004  thorpej Improvements to DP83820 support, from HITOSHI Osada:
- Fix jumbo frame support.
- Disable interrupts at the chip in sip_intr().
- Disable checksum offloading if MTU > 8109 - the hardware is broken
in this case.
- Use the interrupt hold-off timer.
- Correct the Tx FIFO size.
- Add Pause Control/Status register definitions.
 1.87 11-Jan-2004  cube branches: 1.87.2;
The limitation for TX/RX DMA of rev. 900B and 635 os the SiS chips also
applies to rev. 0x91 for 96x chipsets. Needed to fix PR 24043, but more
stressing testing has to be performed before closing it.
 1.86 05-Dec-2003  cube Remove bitbang code that was taken from FreeBSD to support recent SiS
chipsets and use mii_bitbang interface instead. Reflect sip dependency in
the config file.

Support for SiS96x needs broader testing.
 1.85 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.84 03-Dec-2003  cube o Add support for accessing the PHY through MDIO for recent SiS chips
o Add support for the recent SiS96x chipsets that have a new revision.
That includes a new bit of code to access the EEPROM, since it is
shared with the ieee1394 controller on those chipsets.

Mostly taken from FreeBSD (rev. 1.62 and 1.64 of sys/pci/if_sip.c). I
tried to make the code look less ugly, but couldn't invent documentation.

Fix PR #23481. Thanks to Stephane ENGEL <sengel AT melshake DOT com> for
the report and the cheerful testing.
 1.83 29-Oct-2003  mycroft Fix the real cause of the uninitialized warning -- we were looking for the VLAN
tag in the wrong place!
 1.82 25-Oct-2003  christos Fix uninitialized variable warnings
 1.81 30-Sep-2003  martin Fix typo (DP83020 -> DP83820) from HITOSHI Osada in PR kern/23023.
 1.80 25-Aug-2003  itojun KNF
 1.79 15-Aug-2003  itojun accept 1518-byte frames (needed for vlan). Valtteri Vuorikoski
 1.78 23-Mar-2003  thorpej branches: 1.78.2;
Add a work-around for the "short cable problem" that some DP83815
revisions have, as discussed on the soekris-tech mailing list a
while ago, whereby one can experience excessive recieve erros when
using < 30m cables. The patch detects overflow in a DSP filter
parameter, and corrects it by writing a known good value.
 1.77 13-Mar-2003  briggs Detect SMC EZ Card as 64-bit. Patch from Pavel Cahyna in kern/20680.
 1.76 17-Jan-2003  itojun switch from kame-based m_aux mbuf auxiliary data, to openbsd m_tag
implementation. it will simplify porting across *bsd (such as kame/altq),
and make us more synchronized. from Joel Wilsson
 1.75 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.74 24-Nov-2002  scw Fix uninitialised variable warnings.
 1.73 17-Oct-2002  fair Change the "dontcare" bits argument of ifmedia_init() to IFM_IMASK,
so that PHY instance is not siginificant in ifmedia_match(). This
is done to support multiple PHYs on the MII. Without this change,
ifmedia_set() would panic the system when no PHYs were matched.

I ran into this on an AMD EasyNow PC, which is built around SiS
system chips with an embedded SiS 900 core, and an external AMD
Am79c901 PHY, which presents two PHYs on the MII: one for HomePNA,
and one for standard 10base-T. The 10base-T PHY ends up with instance
number 1...
 1.72 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.71 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.70 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.69 26-Aug-2002  thorpej * The Netgear GA-621 is a 64-bit card, so add it to the 64-bit
quirk table.
* We want to hardwire BMSR_EXTSTAT, not BMSR_EXTCAP, when reading
the TBI BMSR.
* Fetch the GPIO bits from the GPIOR register after an auto-load,
rather than reading from the EEPROM directly.
 1.68 26-Aug-2002  itojun need to set wantinit variable
 1.67 26-Aug-2002  itojun suppress some of debugging output (IFF_DEBUG will re-enable it). PR 18069
 1.66 21-Aug-2002  itojun use RND_ENABLED() to avoid unneeded function call. should help if_gsip case.
 1.65 20-Aug-2002  itojun attach random number source.
 1.64 16-Aug-2002  thorpej * Hard-code EXTSR_1000XFDX|EXTSR_1000XHDX for reads of the MII_EXTSR
in the TBI case.
* Force BMSR_ANEG | BMSR_EXTCAP to be returned for reads of the MII_BMSR
in the TBI case.
 1.63 10-Aug-2002  thorpej Preliminary support for the ten-bit interface on the DP83820. This
code needs more testing, and more bug fixing.
 1.62 10-Aug-2002  thorpej Don't treat the "reset complete" interrupts as errors. Doing so
causes us to go into a reset/interrupt/reset/... loop.
 1.61 11-Jul-2002  thorpej Add 64-bit quirk for the Accton EN1407-T/Planex GN-1000TE. IDs provided
by SAITOH Masanobu <msaitoh@netbsd.org>.
 1.60 30-Jun-2002  thorpej Add a table of known-64-bit DP83820-based cards. Use this table
to enable 64-bit data transfers on 64-bit cards when plugged into
a 64-bit slot. Right know the Asante GigaNIX is listed in that
table.

Sigh, there is an EEPROM bit that can be used to detect 64-bit vs
32-bit cards. Unfortunately, at least 2 vendors of 32-bit cards
fail to clear the "DATA64_EN" bit in the EEPROM, which causes the
card to lose badly, because it still manages to detect that it's
plugged into a 64-bit PCI slot. Yay, stupid hardware vendors.
 1.59 30-Jun-2002  thorpej Load configuration data from the EEPROM on the DP83820 differently: rather
than grovel the EEPROM directly, initiate an "EEPROM load" in the PCI
test register, and fetch the values from the CFG register.
 1.58 30-Jun-2002  thorpej Update the TODO list: We have some Tx interrupt mitigation now, so
we need to do Rx interrupt mitigation next.
 1.57 30-Jun-2002  thorpej Be more aggressive in giving descriptors to the chip in the transmit
path: Instead of waiting for the if_snd queue to be drained before
giving ownership of the frist descriptor to the chip, do it after
sync'ing all the descriptors for a single packet.
 1.56 30-Jun-2002  thorpej Implement a sliding interrupt delay window for Tx interrupts.
 1.55 30-Jun-2002  thorpej * Give symbolic names to the CFG bits in the EEPROM.
* Get CFG_M64ADDR, CFG_T64ADDR, and CFG_DATA64_EN from the EEPROM.
Note, we still disable CFG_M64ADDR and CFG_T64ADDR later (XXX need
PCI bus capability flags for these).
* Print a message if we're in a 64-bit slot and 64-bit data is
disabled in the EEPROM. Make sure CFG_DATA64_EN is disabled if
we're not in a 64-bit slot.
 1.54 01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.53 28-May-2002  tron Set initial transmit drain threshold to 1504 to avoid the problem
described in PR kern/16070. Change approved by Jason Thorpe.

XXX We'll should try to find a better adaptive scheme for the next
NetBSD release.
 1.52 03-May-2002  thorpej branches: 1.52.2; 1.52.4;
Bump the number of Tx DMA segments from 8 to 16 (the zero-copy socket
code sometimes sees more than 8).
 1.51 27-Mar-2002  briggs Erf. Actually use the symbolic name for the 630ET instead of a constant.
 1.50 27-Mar-2002  briggs Print the chip revision in the attach function.
Treat revision 0x84 of the SiS like other SIS630 variants.
Call revision 0x84 the 630ET (name from OpenBSD).
 1.49 24-Mar-2002  is use the right endian ether_crc32 function in the multicast hash table computation
 1.48 28-Feb-2002  thorpej If the upper layer says Write/Invalidate is okay, then make sure
it's enabled in the PCI CSR.
 1.47 28-Feb-2002  thorpej Change the default Rx FIFO drain threshold to 128 bytes; this
reduces the likelihood of Rx FIFO overruns on machines with wimpy
PCI busses, while still allowing the interface to burst with a
reasonable size.
 1.46 28-Feb-2002  thorpej * On the DP83820, make sure to make the Tx DMA map large enough for
jumbo frames.
* Work around broken PXE firmware on some boards, which leave the ROM
BAR enabled even after the PXE stack has been unloaded.
* Set up the initial values for sc_tx_fill_thresh, sc_tx_drain_thresh, and
sc_rx_drain_thresh in sip_attach(), rather than in sip_init().
 1.45 09-Feb-2002  thorpej Fix problems associated with the SiS 635/735 on-board Ethernet,
from Stephen Degler <sdegler@degler.net>, port-i386/15261.
 1.44 20-Dec-2001  thorpej Fetch the MAC address from the NVRAM on the SiS 630 built-in Ethernet.

Based on PR 14665, Stephen Borrill <netbsd@precedence.co.uk>.
 1.43 13-Nov-2001  lukem add RCSID
 1.42 23-Jul-2001  thorpej Make sure to initialize the all Rx descriptors properly in *_init()
even if mbufs for them are already allocated.
 1.41 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.40 08-Jul-2001  thorpej branches: 1.40.2;
Some cosmetic shuffling.
 1.39 08-Jul-2001  thorpej Fix a very, very dumb mistake that broke multicast on the dp83815
and dp83820.
 1.38 07-Jul-2001  thorpej Change the structure of dp83815_set_filter ever so slightly.
 1.37 07-Jul-2001  thorpej bcmp -> memcmp
 1.36 07-Jul-2001  thorpej Add support for jumbo Ethernet frames on the DP83820.
 1.35 30-Jun-2001  thorpej Split the receive interrupt handler into two versions, one for the
SiS900/DP83815, one for the DP83820. In preparation for changes
to the DP83820 version for handling jumbo Ethernet frames.
 1.34 18-Jun-2001  simonb Make error checking/reporting a little more correct.
 1.33 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.32 03-Jun-2001  thorpej Clarify a historical comment.
 1.31 02-Jun-2001  thorpej Implement support for IP/TCP/UDP checksum offloading provided by
network interfaces. This works by pre-computing the pseudo-header
checksum and caching it, delaying the actual checksum to ip_output()
if the hardware cannot perform the sum for us. In-bound checksums
can either be fully-checked by hardware, or summed up for final
verification by software. This method was modeled after how this
is done in FreeBSD, although the code is significantly different in
most places.

We don't delay checksums for IPv6/TCP, but we do take advantage of the
cached pseudo-header checksum.

Note: hardware-assisted checksumming defaults to "off". It is
enabled with ifconfig(8). See the manual page for details.

Implement hardware-assisted checksumming on the DP83820 Gigabit Ethernet,
3c90xB/3c90xC 10/100 Ethernet, and Alteon Tigon/Tigon2 Gigabit Ethernet.
 1.30 18-May-2001  thorpej - Add some instrumentation which can be enabled by defining
SIP_EVENT_COUNTERS.
- Decrease SIP_NTXSEGS to 8 and increase SIP_TXQUEUELEN to 256.
This gives us 256 transmit jobs with only twice the descriptor
memory footprint. This prevents stalling transmissions due to
lack of transmit jobs under heavy load.
- Increase SIP_NRXDESC to 128 so we don't run out of receive descriptors
under extreme load.
- As recommended by the manual, leave one descriptor in the transmit ring
with OWN clear to prevent wrap-around.
- Even though the manual claims that driver software must initialize
TXDP if there are no pending transmissions when a new transmission
is to be initialized, doing so causes serious performance degredation
on the DP83820 under heavy load. Not initializing TXDP also increases
performance on the DP83815.

All of this gets us up to ~90Mb/s on both the DP83820 and DP83815 when
connected to a 100base network.
 1.29 18-May-2001  thorpej Add a driver for the National Semiconductor DP83820 Gigabit Ethernet
chip. This is found on the NetGear GA-622 and Asante FriendlyNet
GigaNIX.
 1.28 15-May-2001  thorpej Encapsulate name declarations in macros in preparation for adding
conditionally-compiled code for the DP83820.
 1.27 24-Mar-2001  briggs There is no need to accept all ARP packets (regardless of destination
address) on the DP83815. Noted by Shiva Shenoy <shiva@riverstonenet.com>
in private correspondence.
 1.26 09-Mar-2001  briggs More fixes for the DP83815...
- Set the destination address register properly for "perfect match" mode
in the receive filter setup.
- Do not enable multicast receipt unless we are configured for some multicast.
- Use the "recommended settings" (which set undocumented registers and
documented-as-reserved fields) for the silicon revision 302h (not 203h,
as documented in one of the two places in the manual) because the
documentation is unclear and because those settings fix the card's
behavior in "perfect match" mode. Without those settings, the card
was generating random CRC/invalid symbol errors and generally not
working unless it was set to be promiscuous.

With these changes, this week's version of the Netgear FA311 works for me.
 1.25 09-Mar-2001  briggs Add a variant hook to read the ethernet MAC address from EEPROM differently
for the SiS 900 and the DP83815. Also add some configuration suggested by
the DP83815 documentation for one model of the DP83815.
 1.24 06-Feb-2001  thorpej branches: 1.24.2;
Gack, fix a stupid bug in the DP83815 multicast setup code.
 1.23 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.22 19-Dec-2000  thorpej Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.
 1.21 14-Dec-2000  thorpej ALTQ'ify.
 1.20 15-Nov-2000  thorpej Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.19 28-Oct-2000  tsutsui Increase initial Tx drain threshold to 512 bytes.
My macppc complains about transmit FIFO underrun every time.
 1.18 15-Oct-2000  thorpej Don't trim off the FCS, pass it up.
 1.17 11-Oct-2000  thorpej Use ether_ioctl().
 1.16 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.15 20-Sep-2000  thorpej Preliminary support for the National Semiconductor DP83815 10/100
Ethernet chip, which is based on the SiS 900 core, but with differences
in the PHY and filter programming interface, and different WoL and
802.3x flow control programming.

This chip appears on new NetGear FA-312TX cards. Thank goodness
they're finally ditching the LiteOn chips.
 1.14 12-Aug-2000  tsutsui - Check CR_RST rather than ISR_TXRCMP and ISR_RXRCMP in sip_reset()
- Add more delay after reset
- "Big endian mode" on SiS 900 seems broken so don't enable it;
use htole32()/le32toh() instead
- Don't cast u_int16_t array to u_int8_t pointer
- Add some delay() to FILTER_EMIT macro in sip_set_filter()

Now SiS 900 works on my macppc.
 1.13 04-Aug-2000  tsutsui Add one more delay() to sip_read_eeprom().
 1.12 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.11 12-May-2000  thorpej branches: 1.11.4;
Use ether_crc32_le().
 1.10 23-Mar-2000  mycroft Rather than guessing at the location of the PMCSR, use the pointer returned by
pci_get_capability(). (This is, after all, a standardized interface...)
 1.9 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.8 06-Mar-2000  thorpej No longer necessary to futz with ifp->if_baudrate here.
 1.7 02-Feb-2000  thorpej Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().
 1.6 02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.5 31-Jan-2000  thorpej Add support for the SiS 7016.
 1.4 12-Nov-1999  thorpej Call mii_down() as appropriate.
 1.3 04-Nov-1999  thorpej Adapt to mii_phy_probe() change.
 1.2 03-Aug-1999  thorpej branches: 1.2.2; 1.2.4; 1.2.8;
Be a little nicer about memory usage:
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() it changed to handle compressing clusters.
 1.1 01-Jun-1999  thorpej branches: 1.1.2;
Device driver for the Silicon Integrated Systems SiS900 10/100 Ethernet
chip, found on the IBM Netstation.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.6 27-Mar-2001  bouyer Sync with HEAD.
 1.2.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.4.9 08-Sep-2003  msaitoh Pull up revision 1.79 via patch (requested by itojun in ticket #69):
Accept 1518-byte frames (needed for vlan). Valtteri Vuorikoski
 1.11.4.8 27-Mar-2002  he Pull up revision 1.49 (via patch, requested by is):
Fix multicast reception on DP83815. Fixes PR#15998.
 1.11.4.7 09-Mar-2002  he Apply patch (requested by bouyer):
Fix an uninitialized pointer in sip_start(), which might eventually
lead to a crash, especially if bpf is used.
 1.11.4.6 27-Oct-2001  he Apply patch (requested by briggs):
Adjust receive and transmit descriptor list structures,
sip_start(), and sip_txintr() to be more similar to the current
development version. Fixes periodic device timeouts.
Tested by briggs with a Netgear FA311TX on i386.
 1.11.4.5 13-Mar-2001  he Pull up revisions 1.25-1.26 (requested by briggs):
Fix support for the DP83815 so that it works properly with the
current crop of Netgear FA311 10/100 cards.
 1.11.4.4 26-Feb-2001  he Pull up revision 1.24 (requested by thorpej):
Fix a bug in the DP83815 multicast setup code.
 1.11.4.3 30-Oct-2000  tv Pullup 1.19 [thorpej/tsutsui]:
Increase initial Tx drain threshold to 512 bytes.
My macppc complains about transmit FIFO underrun every time.
 1.11.4.2 28-Sep-2000  thorpej Sync with trunk: Add support for the DP83815 10/100 Ethernet,
found on new NetGear cards.
 1.11.4.1 12-Aug-2000  tsutsui Pull up rev 1.13 and 1.14 (approved by thorpej):

revision 1.13:
- Add one more delay() to sip_read_eeprom()

revision 1.14:
- Check CR_RST rather than ISR_TXRCMP and ISR_RXRCMP in sip_reset()
- Add more delay after reset
- "Big endian mode" on SiS 900 seems broken so don't enable it;
use htole32()/le32toh() instead
- Don't cast u_int16_t array to u_int8_t pointer
- Add some delay() to FILTER_EMIT macro in sip_set_filter()
 1.24.2.16 17-Jan-2003  thorpej Sync with HEAD.
 1.24.2.15 29-Dec-2002  thorpej Sync with HEAD.
 1.24.2.14 11-Dec-2002  thorpej Sync with HEAD.
 1.24.2.13 11-Nov-2002  nathanw Catch up to -current
 1.24.2.12 18-Oct-2002  nathanw Catch up to -current.
 1.24.2.11 27-Aug-2002  nathanw Catch up to -current.
 1.24.2.10 13-Aug-2002  nathanw Catch up to -current.
 1.24.2.9 01-Aug-2002  nathanw Catch up to -current.
 1.24.2.8 20-Jun-2002  nathanw Catch up to -current.
 1.24.2.7 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.24.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.24.2.5 08-Jan-2002  nathanw Catch up to -current.
 1.24.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.24.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.24.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.24.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.40.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.40.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.40.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.40.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.40.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.40.2.1 03-Aug-2001  lukem update to -current
 1.52.4.10 02-Oct-2003  tron Pull up revision 1.81 (requested by martin in ticket #1490):
Fix typo (DP83020 -> DP83820) from HITOSHI Osada in PR kern/23023.
 1.52.4.9 15-Aug-2003  tron Pull up revision 1.79 (requested by itojun in ticket #1413):
accept 1518-byte frames (needed for vlan). Valtteri Vuorikoski
 1.52.4.8 15-Jun-2003  tron Pull up revision 1.78 (requested by thorpej in ticket #1228):
Add a work-around for the "short cable problem" that some DP83815
revisions have, as discussed on the soekris-tech mailing list a
while ago, whereby one can experience excessive recieve erros when
using < 30m cables. The patch detects overflow in a DSP filter
parameter, and corrects it by writing a known good value.
 1.52.4.7 21-Nov-2002  he Pull up revision 1.62 (requested by tls in ticket #1007):
Do not treat the ``reset complete'' interrupts as errors.
Doing so causes us to go into a reset/interrupt/reset loop.
 1.52.4.6 01-Nov-2002  tron Pull up revision 1.60 (requested by thorpej in ticket #415):
Add a table of known-64-bit DP83820-based cards. Use this table
to enable 64-bit data transfers on 64-bit cards when plugged into
a 64-bit slot. Right know the Asante GigaNIX is listed in that
table.
Sigh, there is an EEPROM bit that can be used to detect 64-bit vs
32-bit cards. Unfortunately, at least 2 vendors of 32-bit cards
fail to clear the "DATA64_EN" bit in the EEPROM, which causes the
card to lose badly, because it still manages to detect that it's
plugged into a 64-bit PCI slot. Yay, stupid hardware vendors.
 1.52.4.5 01-Nov-2002  tron Pull up revision 1.59 (requested by thorpej in ticket #414):
Load configuration data from the EEPROM on the DP83820 differently: rather
than grovel the EEPROM directly, initiate an "EEPROM load" in the PCI
test register, and fetch the values from the CFG register.
 1.52.4.4 01-Nov-2002  tron Pull up revision 1.58 (requested by thorpej in ticket #413):
Update the TODO list: We have some Tx interrupt mitigation now, so
we need to do Rx interrupt mitigation next.
 1.52.4.3 01-Nov-2002  tron Pull up revision 1.56 (requested by thorpej in ticket #412):
Implement a sliding interrupt delay window for Tx interrupts.
 1.52.4.2 01-Nov-2002  tron Pull up revision 1.55 (requested by thorpej in ticket #411):
* Give symbolic names to the CFG bits in the EEPROM.
* Get CFG_M64ADDR, CFG_T64ADDR, and CFG_DATA64_EN from the EEPROM.
Note, we still disable CFG_M64ADDR and CFG_T64ADDR later (XXX need
PCI bus capability flags for these).
* Print a message if we're in a 64-bit slot and 64-bit data is
disabled in the EEPROM. Make sure CFG_DATA64_EN is disabled if
we're not in a 64-bit slot.
 1.52.4.1 28-May-2002  tv Pull up revision 1.53 (requested by tron in ticket #50):
Set initial transmit drain threshold to 1504 to avoid the problem
described in PR kern/16070. Change approved by Jason Thorpe.
XXX We'll should try to find a better adaptive scheme for the next
NetBSD release.
 1.52.2.4 29-Aug-2002  gehenna catch up with -current.
 1.52.2.3 15-Jul-2002  gehenna catch up with -current.
 1.52.2.2 20-Jun-2002  gehenna catch up with -current.
 1.52.2.1 30-May-2002  gehenna Catch up with -current.
 1.78.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.78.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.78.2.8 06-Feb-2005  skrll Sync with HEAD.
 1.78.2.7 06-Feb-2005  skrll Sync with HEAD.
 1.78.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.78.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.78.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.78.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.78.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.78.2.1 03-Aug-2004  skrll Sync with HEAD
 1.87.2.1 28-May-2004  tron branches: 1.87.2.1.2;
Pull up revision 1.91 (requested by fair in ticket #296):
Two changes:
1. ifdef out the restriction that the SiS 900 has only one PHY
This is demonstrably false; the SiS 960 super south bridge in
PR 18590 has a SiS 900 rev 1 core in it.
2. bitbang the MII for all versions of the SiS 900; this is the
only way that the PHYs on this system answer.
Also, I suspect that SIS900_REV_960 constant in if_sipreg.h is
incorrectly labelled - there were later revisions of the super
south bridge (e.g. the 961, 962, and 963), and I suspect the
SiS 900 revision code there refers to one of those.
 1.87.2.1.2.1 24-Jan-2005  he Pull up revision 1.96 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.96.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.96.6.1 12-Feb-2005  yamt sync with head.
 1.96.4.1 29-Apr-2005  kent sync with -current
 1.101.2.3 21-Apr-2006  tron Pull up following revision(s) (requested by pavel in ticket #1280):
sys/dev/pci/if_sip.c: revision 1.106
In rev. 1.98, the ioctl method of the (g)sip drivers was optimized for
SIOCSIFFLAGS: it compares the new flags with the old flags and avoids
reset if there are only certain changes. This was done to fix PR 29126.
It does not take into account, though, that there is other state which
can change and SIOCSIFFLAGS is called to inform about it. Namely,
if_capenable, ec_capenable and ec_nvlans. For all three, the _init
method must program the hardware specially. Not doing it resulted in:
- VLAN frames getting truncated
- hw checksumming not working
- outgoing VLAN frames not being tagged when they should
- incoming VLAN frames being treated as untagged.
Fix by keeping all the old state in the softc and initializing the
hardware if any of it changes.
Tested on gsip. Also tested by Nino Dehne and Martin J. Laubach
on sip, thanks.
Fixes PRs 32900 and 33216.
Approved by martin@ .
 1.101.2.2 21-Apr-2006  tron Pull up following revision(s) (requested by pavel in ticket #1279):
sys/dev/pci/if_sip.c: revision 1.107
VLAN tags were sent byte-swapped by the gsip driver, because the driver
forgets to convert them from the host to the network byte order. Use
bswap16 to convert them. (Not htons, because on a big-endian machine, they
are in the correct byte order initially, but then, they are byte-swapped
by a htole32 call when written to the transmit descriptor. So
byte-swapping is needed in this case too, to compensate for this htole32
call.)
For a similar reason, tags were seen byte-swapped when received on a
big-endian machine. Replace ntohs by bswap16 in the input path too.
(Again, it is needed to compensate for a le32toh call when the receive
descriptor is read.)
Fixes PR 32644.
Tested on 3.0/i386, 3.0/sgimips and current/alpha.
OK by martin@.
 1.101.2.1 08-Feb-2006  tron Pull up following revision(s) (requested by thorpej in ticket #1161):
sys/dev/pci/if_wm.c: revision 1.111
sys/dev/pci/if_sip.c: revision 1.104
In the receive interrupt handler, compute the packet length before
resetting
m to point to the first buffer in the packet. The bug would cause the
length of jumbo frames to be incorrect.
 1.102.2.8 24-Mar-2008  yamt sync with head.
 1.102.2.7 17-Mar-2008  yamt sync with head.
 1.102.2.6 11-Feb-2008  yamt sync with head.
 1.102.2.5 21-Jan-2008  yamt sync with head
 1.102.2.4 27-Oct-2007  yamt sync with head.
 1.102.2.3 03-Sep-2007  yamt sync with head.
 1.102.2.2 30-Dec-2006  yamt sync with head.
 1.102.2.1 21-Jun-2006  yamt sync with head.
 1.103.6.1 22-Apr-2006  simonb Sync with head.
 1.103.4.1 09-Sep-2006  rpaulo sync with head
 1.103.2.1 18-Feb-2006  yamt sync with head.
 1.104.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.104.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.104.4.1 19-Apr-2006  elad sync with head.
 1.104.2.4 26-Jun-2006  yamt sync with head.
 1.104.2.3 24-May-2006  yamt sync with head.
 1.104.2.2 11-Apr-2006  yamt sync with head
 1.104.2.1 01-Apr-2006  yamt sync with head.
 1.107.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.107.2.1 19-Jun-2006  chap Sync with head.
 1.108.6.2 10-Dec-2006  yamt sync with head.
 1.108.6.1 22-Oct-2006  yamt sync with head
 1.108.4.1 18-Nov-2006  ad Sync with head.
 1.110.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.112.4.1 11-Jul-2007  mjf Sync with head.
 1.112.2.3 23-Oct-2007  ad Sync with head.
 1.112.2.2 09-Oct-2007  ad Sync with head.
 1.112.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.113.8.3 23-Mar-2008  matt sync with HEAD
 1.113.8.2 09-Jan-2008  matt sync with HEAD
 1.113.8.1 06-Nov-2007  matt sync with HEAD
 1.113.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.113.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.113.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.114.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.115.8.3 20-Jan-2008  bouyer Sync with HEAD
 1.115.8.2 10-Jan-2008  bouyer Sync with HEAD
 1.115.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.115.4.1 26-Dec-2007  ad Sync with head.
 1.115.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.127.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.127.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.127.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.127.2.1 24-Mar-2008  keiichi sync with head.
 1.132.4.6 11-Aug-2010  yamt sync with head.
 1.132.4.5 11-Mar-2010  yamt sync with head
 1.132.4.4 16-Sep-2009  yamt sync with head
 1.132.4.3 16-May-2009  yamt sync with head
 1.132.4.2 04-May-2009  yamt sync with head.
 1.132.4.1 16-May-2008  yamt sync with head.
 1.132.2.1 18-May-2008  yamt sync with head.
 1.134.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.134.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.134.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.135.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.145.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.147.2.2 05-Mar-2011  rmind sync with head
 1.147.2.1 30-May-2010  rmind sync with head
 1.150.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.150.2.2 30-Oct-2012  yamt sync with head
 1.150.2.1 17-Apr-2012  yamt sync with head
 1.151.2.1 18-Feb-2012  mrg merge to -current.
 1.153.2.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #691):
sys/dev/pci/aac_pci.c: revision 1.34
sys/dev/pci/if_sip.c: revision 1.155
sys/dev/pci/if_tlp_pci.c: revision 1.122
sys/dev/pci/if_an_pci.c: revision 1.34
match some more devices.
 1.154.2.4 03-Dec-2017  jdolecek update from HEAD
 1.154.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.154.2.2 23-Jun-2013  tls resync from head
 1.154.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.156.4.1 18-May-2014  rmind sync with head
 1.157.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.158.4.6 28-Aug-2017  skrll Sync with HEAD
 1.158.4.5 05-Feb-2017  skrll Sync with HEAD
 1.158.4.4 05-Oct-2016  skrll Sync with HEAD
 1.158.4.3 09-Jul-2016  skrll Sync with HEAD
 1.158.4.2 19-Mar-2016  skrll Sync with HEAD
 1.158.4.1 06-Jun-2015  skrll Sync with HEAD
 1.163.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.165.6.1 11-May-2017  pgoyette Sync with HEAD
 1.166.2.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.167.2.2 26-Jan-2019  pgoyette Sync with HEAD
 1.167.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.168.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.168.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.168.2.1 10-Jun-2019  christos Sync with HEAD
 1.175.2.1 29-Feb-2020  ad Sync with head.
 1.192.2.1 02-Aug-2025  perseant Sync with HEAD
 1.22 02-Feb-2024  andvar fix various typos in comments.
 1.21 08-Mar-2020  thorpej Support 64-bit DMA addressing on the DP83820, used only when a 64-bit
DMA tag is available.
 1.20 08-Feb-2018  dholland branches: 1.20.4;
Typos.
 1.19 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.18 15-Dec-2007  dyoung branches: 1.18.6; 1.18.8; 1.18.10;
Finish making the sip(4) and gsip(4) drivers share compiled code.
 1.17 15-Dec-2007  dyoung Convert some #ifdef DP83820 to comments /* DP83820 only */ where
that will neither make a functional difference nor cause a name
collision.
 1.16 14-Dec-2007  dyoung Take a step toward sharing compiled code between sip(4) and gsip(4):
get rid of SIP_DECL() and reduce #ifdef DP83820 code. Next step
is to move a bunch of shared code to a new file (if_sipcom.c, say)
and compile it *once*.

While I am here, add suspend/resume handling to sip(4) and to
gsip(4).

Tested with the NatSemi sip(4) on the Soekris net4521. I don't
have any gsip(4) to test with, and it seems that the few holders
of gsip(4) in the world keep them in their attic, anyway.
 1.15 11-Dec-2005  christos branches: 1.15.46; 1.15.56; 1.15.60;
merge ktrace-lwp.
 1.14 11-Apr-2004  thorpej branches: 1.14.12;
Improvements to DP83820 support, from HITOSHI Osada:
- Fix jumbo frame support.
- Disable interrupts at the chip in sip_intr().
- Disable checksum offloading if MTU > 8109 - the hardware is broken
in this case.
- Use the interrupt hold-off timer.
- Correct the Tx FIFO size.
- Add Pause Control/Status register definitions.
 1.13 03-Dec-2003  cube o Add support for accessing the PHY through MDIO for recent SiS chips
o Add support for the recent SiS96x chipsets that have a new revision.
That includes a new bit of code to access the EEPROM, since it is
shared with the ieee1394 controller on those chipsets.

Mostly taken from FreeBSD (rev. 1.62 and 1.64 of sys/pci/if_sip.c). I
tried to make the code look less ugly, but couldn't invent documentation.

Fix PR #23481. Thanks to Stephane ENGEL <sengel AT melshake DOT com> for
the report and the cheerful testing.
 1.12 15-Aug-2003  itojun accept 1518-byte frames (needed for vlan). Valtteri Vuorikoski
 1.11 30-Jun-2002  thorpej branches: 1.11.6;
* Give symbolic names to the CFG bits in the EEPROM.
* Get CFG_M64ADDR, CFG_T64ADDR, and CFG_DATA64_EN from the EEPROM.
Note, we still disable CFG_M64ADDR and CFG_T64ADDR later (XXX need
PCI bus capability flags for these).
* Print a message if we're in a 64-bit slot and 64-bit data is
disabled in the EEPROM. Make sure CFG_DATA64_EN is disabled if
we're not in a 64-bit slot.
 1.10 27-Mar-2002  briggs branches: 1.10.2; 1.10.4;
Print the chip revision in the attach function.
Treat revision 0x84 of the SiS like other SIS630 variants.
Call revision 0x84 the 630ET (name from OpenBSD).
 1.9 09-Feb-2002  thorpej Fix problems associated with the SiS 635/735 on-board Ethernet,
from Stephen Degler <sdegler@degler.net>, port-i386/15261.
 1.8 20-Dec-2001  thorpej Fetch the MAC address from the NVRAM on the SiS 630 built-in Ethernet.

Based on PR 14665, Stephen Borrill <netbsd@precedence.co.uk>.
 1.7 18-May-2001  thorpej branches: 1.7.2;
Add a driver for the National Semiconductor DP83820 Gigabit Ethernet
chip. This is found on the NetGear GA-622 and Asante FriendlyNet
GigaNIX.
 1.6 15-May-2001  thorpej Define the register/descriptor differences between the DP83815 and the
DP83820. The DP83820 definitions are wrapped in #ifdef DP83820, since
there are enough differences that a single binary object would not be
able to efficiently drive both the DP83815 and DP83820.
 1.5 09-Mar-2001  briggs Goes along with rev. 1.25/1.26 of if_sip.c -- forgot to commit.
 1.4 21-Sep-2000  thorpej branches: 1.4.2;
Some more register definitions for the DP83815.
 1.3 20-Sep-2000  thorpej Add additional register defintions for the National Semiconductor
DP83815, which is based on the SiS900 core.
 1.2 31-Jan-2000  thorpej branches: 1.2.4;
Add support for the SiS 7016.
 1.1 01-Jun-1999  thorpej branches: 1.1.2; 1.1.4;
Device driver for the Silicon Integrated Systems SiS900 10/100 Ethernet
chip, found on the IBM Netstation.
 1.1.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.4.3 08-Sep-2003  msaitoh Pull up revision 1.12 via patch (requested by itojun in ticket #69):
Accept 1518-byte frames (needed for vlan). Valtteri Vuorikoski
 1.2.4.2 13-Mar-2001  he Pull up revision 1.5 (requested by briggs):
Fix support for the DP83815 so that it works properly with the
current crop of Netgear FA311 10/100 cards.
 1.2.4.1 28-Sep-2000  thorpej Sync with trunk: Add support for the DP83815 10/100 Ethernet,
found on new NetGear cards.
 1.4.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.4.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.4.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.7.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.4.2 15-Aug-2003  tron Pull up revision 1.12 (requested by itojun in ticket #1413):
accept 1518-byte frames (needed for vlan). Valtteri Vuorikoski
 1.10.4.1 01-Nov-2002  tron Pull up revision 1.11 (requested by thorpej in ticket #411):
* Give symbolic names to the CFG bits in the EEPROM.
* Get CFG_M64ADDR, CFG_T64ADDR, and CFG_DATA64_EN from the EEPROM.
Note, we still disable CFG_M64ADDR and CFG_T64ADDR later (XXX need
PCI bus capability flags for these).
* Print a message if we're in a 64-bit slot and 64-bit data is
disabled in the EEPROM. Make sure CFG_DATA64_EN is disabled if
we're not in a 64-bit slot.
 1.10.2.1 15-Jul-2002  gehenna catch up with -current.
 1.11.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.12.1 21-Jan-2008  yamt sync with head
 1.15.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.56.1 26-Dec-2007  ad Sync with head.
 1.15.46.1 09-Jan-2008  matt sync with HEAD
 1.18.10.1 16-May-2008  yamt sync with head.
 1.18.8.1 18-May-2008  yamt sync with head.
 1.18.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.20.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.114 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.113 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.112 23-May-2024  andvar branches: 1.112.2;
s/separare/separate/ and s/separete/separate/ in comments.
 1.111 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.110 03-May-2022  andvar fix various typos, mainly s/trasfering/transferring/ and s/theese/these/.
 1.109 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.108 08-May-2021  thorpej branches: 1.108.6;
Use pci_compatible_match().
 1.107 24-Apr-2021  thorpej branches: 1.107.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.106 02-Jul-2020  msaitoh branches: 1.106.4;
prop_data_data_nocopy -> prop_data_value
 1.105 24-Feb-2020  rin 0x%p --> %p for non-external codes.
 1.104 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.103 27-Dec-2019  msaitoh branches: 1.103.2;
s/is is/is/ in comment.
 1.102 28-Nov-2019  maxv localify
 1.101 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.100 03-Jun-2019  msaitoh KNF. No functional change.
 1.99 03-Jun-2019  msaitoh Make new sk_unreset_{xmac,yukon}() and use them in sk_attach().
Fixes PR kern/54267 reported by martin.
 1.98 30-May-2019  msaitoh Simplify MII structure initialization and reference. No functional change.
 1.97 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.96 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.95 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.94 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.93 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.92 08-Jan-2019  msaitoh Whitespace fix. No functional change.
 1.91 08-Jan-2019  msaitoh u_int{8,16,32,64}_t -> uint{8,16,32,64}_t. No functional change.
 1.90 15-Nov-2018  maxv Remove the 'copy' argument from m_devget(), unused. While here rename
off0->off.
 1.89 04-Jul-2018  jdolecek use pci_intr_establish_xname()
 1.88 03-Jul-2018  jdolecek attach the rnd source only once even with dual-port adapters
 1.87 26-Jun-2018  msaitoh branches: 1.87.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.86 12-Jun-2018  jdolecek move SK_HASH_BITS to if_skreg.h and reuse in if_msk.c (from OpenBSD)
 1.85 15-Dec-2016  ozaki-r branches: 1.85.8; 1.85.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.84 14-Dec-2016  christos Tidy up and make it look like the other drivers.
 1.83 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.82 10-Jun-2016  ozaki-r branches: 1.82.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.81 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.80 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.79 10-Dec-2014  christos don't give up on mii tick before the interface is marked up.
 1.78 10-Aug-2014  tls branches: 1.78.4;
Merge tls-earlyentropy branch into HEAD.
 1.77 29-Mar-2014  christos branches: 1.77.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.76 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.75 13-Sep-2013  martin #ifdef a variable like their use
 1.74 11-Jun-2013  msaitoh branches: 1.74.2;
Remove an extra mii_pollstat() call. The PHY status should be updated
by adjacent mii_tick() call. I suspect that this mii_pollstat() call was
added to do workaround for broken MII_TICK code. A lot of MII PHY drivers
had bugs in MII_TICK and those bugs were fixed.
 1.73 30-Mar-2013  christos remove trailing whitespace
 1.72 22-Jul-2012  matt branches: 1.72.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.71 02-Jun-2012  dsl Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.70 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.69 29-May-2011  phx branches: 1.69.4; 1.69.8;
The Genesis interface provides a register in the device specific config space
to automatically revert the byte order in all descriptors.
Make sure this feature is inactive. Otherwise the driver is unable to
receive or transmit any frame.
 1.68 26-Jul-2010  jym branches: 1.68.2;
Add PAE to ALL kernel, so that most paddr_t format string errors get caught
during compilation.

While here, fix the compilation for ALL.
 1.67 16-May-2010  phx Make netboot generate a BTINFO_NET bootinfo node for the Synology sk(4) NIC.
It will pass the MAC address, which is read from Flash ROM, into the kernel.
The kernel creates a "mac-address" device-property, which is used by sk(4),
when given, before reading the MAC from its EEPROM.
 1.66 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.65 24-Feb-2010  dyoung branches: 1.65.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.64 19-Jan-2010  pooka branches: 1.64.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.63 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.62 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.61 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.60 23-Apr-2009  kefren Add pmf hooks. Proposed two days ago on tech-kern@, no objections.
Tested on amd64 with Asus P5Q-E mainboard with onboard Yukon Lite
 1.59 18-Mar-2009  cegger bzero -> memset
 1.58 18-Mar-2009  cegger bcmp -> memcmp
 1.57 13-Feb-2009  bouyer More printf format fixes.
 1.56 12-Feb-2009  cegger Yukon chips support flow-control. Tested on Yukon Lite chip.
ok cube@
 1.55 07-Nov-2008  dyoung branches: 1.55.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.54 09-Sep-2008  cegger branches: 1.54.2; 1.54.4; 1.54.6;
make an i386/ALL kernel build
 1.53 08-Sep-2008  christos more device_private, pointed by cube.
 1.52 08-Sep-2008  christos avoid using casts by referencing the proper struct members.
 1.51 08-Sep-2008  christos cf_attach_decl_new
 1.50 20-Jun-2008  cube branches: 1.50.2;
Use a mutex instead of splvm() to protect the list of jubo-ready mbufs, as
done with nfe(4) a while ago.

Issue reported by Gary Duzan, who kindly fixed the patch I had sent him.
 1.49 28-Apr-2008  martin branches: 1.49.2; 1.49.4;
Remove clause 3 and 4 from TNF licenses
 1.48 10-Apr-2008  cegger branches: 1.48.2; 1.48.4;
use aprint_*_dev and device_xname
 1.47 07-Feb-2008  dyoung branches: 1.47.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.46 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.45 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.44 01-Dec-2007  jmcneill branches: 1.44.2; 1.44.4; 1.44.6;
aprintify, on behalf of xtraeme
 1.43 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.42 19-Jul-2007  dsl branches: 1.42.4; 1.42.6; 1.42.10; 1.42.12; 1.42.14;
include sys/cdefs.h
 1.41 09-Jul-2007  ad branches: 1.41.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.40 06-Jul-2007  briggs Print an error and fail the sk_attach() if we have an unknown chip type
(instead of panicing).
Also check to see if we have a Yukon2 type, and if we do, complain about
that explicitly earlier (and still fail the attach, but refer to msk(4)).
It would be better if we didn't have Yukon2 devices match in the sk(4)
device table, but in case people change the hardware without changing
device IDs, we might as well catch it.
 1.39 06-Jul-2007  briggs Remove DLink DGE560T as it (in at least some versions) uses a Yukon EC
chipset, which is not handled by this driver, but is handled by the msk(4)
driver. The DGE560T_2 entry is left alone for now--it might also need to
go to msk(4).
 1.38 13-Mar-2007  msaitoh Apply if_msk.c rev. 1.4 to if_sk.c:

> Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
>
> Original commit message:
> > In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> > continuing when busy flag set.
 1.37 04-Mar-2007  christos branches: 1.37.2; 1.37.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.36 30-Jan-2007  msaitoh branches: 1.36.2;
sync with if_skreg.h rev. 1.41

need more work?
 1.35 16-Nov-2006  christos branches: 1.35.2;
__unused removal on arguments; approved by core.
 1.34 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.33 10-Sep-2006  riz branches: 1.33.2;
g/c unused SK_{SET,CLR}BIT macros
 1.32 25-Aug-2006  riz branches: 1.32.2;
In sk_watchdog(), attempt to reclaim pending TX descriptors before
resetting the hardware. Should fix occasional watchdog timeouts
seen with this driver.

From FreeBSD, via OpenBSD.
 1.31 25-Aug-2006  riz Cleanup, with no functional changes:

- remove unused code
- KNF
- ANSI function declarations
- replace printf() with aprint_error() except in debug functions
- a few minor indentation/whitespace changes
 1.30 22-Aug-2006  riz Vendor GALILEO is now MARVELL.
 1.29 22-Aug-2006  riz Add byteswapping where appropriate, to allow things to work on
(at least some) bigendian systems - I tested on macppc.

From brad@openbsd .
 1.28 20-Aug-2006  riz Some cleanup in skc_attach():

- does not need splnet()
- disestablish the interrupt and unmap bus space on failures.
 1.27 20-Aug-2006  riz Make this driver compile when SK_USEIOSPACE is defined - I have no
evidence that this is actually needed except for the existence of the
code itself, but if it's going to be here, it should compile. Tested
briefly on my ASUS motherboard with built-in sk interface.
 1.26 31-May-2006  riz branches: 1.26.4;
Add support for the DLink DGE-530T revision B1 (Tested by Tillman
Hodgson) and the DGE-560T (untested).
 1.25 17-Apr-2006  christos branches: 1.25.2;
Fix typo. Pointed out by brad.
 1.24 14-Apr-2006  christos Coviery CID 1108: Avoid NULL pointer deref.
 1.23 14-Apr-2006  christos Coverity CID 1105: Avoid NULL deref.
 1.22 28-Mar-2006  riz Add jumbo frames support, from OpenBSD (mcbride). As seen on tech-net
for the last N months.
 1.21 25-Feb-2006  wiz branches: 1.21.2; 1.21.4; 1.21.6;
Fix some typos.
 1.20 14-Feb-2006  riz Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.

Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.

Discussed on tech-net beginning in November 2005.
 1.19 11-Feb-2006  rpaulo PR 31304: Contribute to the random pool. From Rhialto.
 1.18 23-Nov-2005  riz branches: 1.18.2; 1.18.4; 1.18.6;
Special-case the Linksys EG1032 cards using PCI subsystem ID; rev. 2 uses
the sk(4) driver, while rev. 3 needs re(4).

Mostly from brad@openbsd.
 1.17 19-Nov-2005  riz From FreeBSD (appropriate pieces of revs 1.90 and 1.92):

Only clear the IFF_OACTIVE flag when we have a chance of being able
to queue a packet to the hardware, instead of when the hardware queue
is empty, and fix up handling and prodding of the tx.

These fixes clear up an occasional "sk0: watchdog timeout" from the
on-board ethernet on my Asus A8V motherboard.

OK christos@
 1.16 11-Sep-2005  xtraeme branches: 1.16.6;
Fix from OpenBSD:

rev 1.56:

Don't initialize the card (and start an autonegotiation!) every time
the IP address changes. Makes 'dhclient sk0' invocations way faster
and more consistant. i.e. one DHCPREQUEST elicts the DHCPACK.

Fix from FreeBSD:

rev 1.109:

Solve "No PHY found" problem for more Yukon Lite variants.

These changes fixed the problem on my sk(4) trying to get an IP
via dhclient(8).
 1.15 30-May-2005  christos branches: 1.15.2;
- const poisoning
- avoid variable shadowing.
 1.14 27-Feb-2005  perry branches: 1.14.2;
nuke trailing whitespace
 1.13 23-Jan-2005  fredb branches: 1.13.2;
Recognize Belkin Gigabit Desktop Network PCI card.
 1.12 30-Oct-2004  thorpej branches: 1.12.4;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.11 26-Sep-2004  skd Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.10 24-May-2004  kleink branches: 1.10.2;
Fix a glitch in the initial import: The XMAC hash function is actually
based on CRC32-_LE_.

From Christian Weisgerber in private mail.
 1.9 24-May-2004  kleink In sk_init_yukon(), don't open-code clearing the multicast filter but
go via the normal filter setup path instead. The old behaviour only
worked ok as long as the init function was exclusively called at attach
time, when there was no configuration to be lost.

From Christian Weisgerber in private mail.
 1.8 07-May-2004  kleink Add an additional multicast hash function for Yukon.
 1.7 28-Jan-2004  chs branches: 1.7.2;
also match the version of this that's built into my Asus
A7N8X-E Deluxe motherboard.
 1.6 17-Dec-2003  tls Add support for some more Marvell-based adapters to the sk driver:

D-Link DGE-530T
Linksys EG1032v2
Linksys EG1064v2

The Linux driver treats all of these the same. Tested with a DGE-530T;
it works, though performance on at least one of my systems is atrocious.

Fix setting of ethernet capabilities into interface capabilites word in
attach routine.

Manual page: note that jumbo support doesn't work and checksum support
doesn't exist.
 1.5 30-Oct-2003  briggs Make sure we can transmit larger packets correctly.
Don't initialize extra fields of the ifp.
Use strcpy() instead of bcopy() for copying the device name.
Handle if_timer a bit better.
 1.4 25-Oct-2003  chs NULL -> 0
 1.3 15-Oct-2003  briggs Make sure descriptors get bus_dmamap_sync()ed.
Restructure a little to make this a little easier.
Also try to avoid allocating things at reset time.
 1.2 08-Sep-2003  thorpej Fix a printf format.
 1.1 26-Aug-2003  jdolecek Add driver for SysKonnect SK-9821 and 3COM 3C940 gigabit ethernet boards
From FreeBSD via OpenBSD, port to NetBSD done by Stephen Degler

Changes relative to submitted version:
* yukonreg.h and xmaciireg.h merged into if_skreg.h
* bhack[] constified + other small editing changes
* use 'Ethernet address' rather than 'address' in attach message

XXX completely untested by me, needs further cleanup

Driver provided in PR kern/22511 by Stephen Degler
 1.7.2.4 07-Jan-2005  jdc Pull up revision 1.11 (requested by abs in ticket #973).

Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.7.2.3 25-May-2004  jmc branches: 1.7.2.3.2;
Pullup rev 1.10 (requested by kleink in ticket #384)

Fix a glitch in the initial import: The XMAC hash function is actually
based on CRC32-_LE_.
 1.7.2.2 25-May-2004  jmc Pullup rev 1.9 (requested by kleink in ticket #382)

In sk_init_yukon(), don't open-code clearing the multicast filter but
go via the normal filter setup path instead. The old behaviour only
worked ok as long as the init function was exclusively called at attach
time, when there was no configuration to be lost.
 1.7.2.1 11-May-2004  tron Pull up revision 1.8 (requested by kleink in ticket #286):
Add an additional multicast hash function for Yukon.
 1.7.2.3.2.11 11-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #10693):
sys/arch/cobalt/pci/pchb.c: revision 1.9 via patch
sys/dev/pci/if_sk.c: revision 1.30 via patch
sys/arch/evbmips/malta/pci/pchb.c: revision 1.9 via patch
Vendor GALILEO is now MARVELL.
 1.7.2.3.2.10 07-Sep-2006  rpaulo Pull up following revision(s) (requested by riz in ticket #10680):
sys/dev/pci/if_skvar.h: revision 1.10
share/man/man4/sk.4: revision 1.9
sys/dev/pci/if_sk.c: revision 1.22
Add jumbo frames support, from OpenBSD (mcbride). As seen on tech-net
for the last N months.
Jumbo frames now work under NetBSD, so note it.
 1.7.2.3.2.9 04-Jun-2006  tron Pull up following revision(s) (requested by riz in ticket #10636):
sys/dev/pci/if_skreg.h: revision 1.7
sys/dev/pci/if_sk.c: revision 1.26
Add support for the DLink DGE-530T revision B1 (Tested by Tillman
Hodgson) and the DGE-560T (untested).
 1.7.2.3.2.8 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #10403):
sys/dev/pci/if_skreg.h: revision 1.6
sys/dev/pci/if_skvar.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.20 via patch
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.
Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.
Discussed on tech-net beginning in November 2005.
 1.7.2.3.2.7 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #10402):
sys/dev/pci/if_sk.c: revision 1.19
sys/dev/pci/if_skvar.h: revision 1.8
PR 31304: Contribute to the random pool. From Rhialto.
 1.7.2.3.2.6 01-Dec-2005  tron Pull up following revision(s) (requested by riz in ticket #10156):
sys/dev/pci/if_sk.c: revision 1.18 via patch
sys/dev/pci/if_re.c: patch
Special-case the Linksys EG1032 cards using PCI subsystem ID; rev. 2 uses
the sk(4) driver, while rev. 3 needs re(4).
Mostly from brad@openbsd.
 1.7.2.3.2.5 01-Dec-2005  tron Pull up following revision(s) (requested by riz in ticket #10154):
sys/dev/pci/if_sk.c: revision 1.17
From FreeBSD (appropriate pieces of revs 1.90 and 1.92):
Only clear the IFF_OACTIVE flag when we have a chance of being able
to queue a packet to the hardware, instead of when the hardware queue
is empty, and fix up handling and prodding of the tx.
These fixes clear up an occasional "sk0: watchdog timeout" from the
on-board ethernet on my Asus A8V motherboard.
OK christos@
 1.7.2.3.2.4 13-Sep-2005  riz Pull up following revision(s) (requested by xtraeme in ticket #5841):
sys/dev/pci/if_sk.c: revision 1.16
Fix from OpenBSD:
rev 1.56:
Don't initialize the card (and start an autonegotiation!) every time
the IP address changes. Makes 'dhclient sk0' invocations way faster
and more consistant. i.e. one DHCPREQUEST elicts the DHCPACK.
Fix from FreeBSD:
rev 1.109:
Solve "No PHY found" problem for more Yukon Lite variants.
These changes fixed the problem on my sk(4) trying to get an IP
via dhclient(8).
 1.7.2.3.2.3 17-Apr-2005  tron Pull up revision 1.13 (requested by fredb in ticket #1120):
Recognize Belkin Gigabit Desktop Network PCI card.
 1.7.2.3.2.2 24-Jan-2005  he Pull up revision 1.12 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.7.2.3.2.1 07-Jan-2005  jdc Pull up revision 1.11 (requested by abs in ticket #973).

Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.10.2.10 11-Dec-2005  christos Sync with head.
 1.10.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.7 24-Jan-2005  skrll Sync with HEAD.
 1.10.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.10.2.5 19-Oct-2004  skrll Sync with HEAD
 1.10.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.2 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 24-May-2004  skrll file if_sk.c was added on branch ktrace-lwp on 2004-08-03 10:49:09 +0000
 1.12.4.1 29-Apr-2005  kent sync with -current
 1.13.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.2.7 03-Nov-2006  tron Pull up following revision(s) (requested by riz in ticket #1480):
sys/dev/pci/if_skvar.h: revision 1.10
sys/dev/pci/if_sk.c: revision 1.22
Add jumbo frames support, from OpenBSD (mcbride). As seen on tech-net
for the last N months.
 1.14.2.6 04-Jun-2006  tron Pull up following revision(s) (requested by riz in ticket #1350):
sys/dev/pci/if_skreg.h: revision 1.7
sys/dev/pci/if_sk.c: revision 1.26
Add support for the DLink DGE-530T revision B1 (Tested by Tillman
Hodgson) and the DGE-560T (untested).
 1.14.2.5 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #1230):
sys/dev/pci/if_skreg.h: revision 1.6
sys/dev/pci/if_skvar.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.20 via patch
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.
Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.
Discussed on tech-net beginning in November 2005.
 1.14.2.4 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #1229):
sys/dev/pci/if_sk.c: revision 1.19
sys/dev/pci/if_skvar.h: revision 1.8
PR 31304: Contribute to the random pool. From Rhialto.
 1.14.2.3 24-Nov-2005  tron Pull up following revision(s) (requested by riz in ticket #993):
sys/dev/pci/if_sk.c: revision 1.18
sys/dev/pci/if_re_pci.c: revision 1.11
Special-case the Linksys EG1032 cards using PCI subsystem ID; rev. 2 uses
the sk(4) driver, while rev. 3 needs re(4).
Mostly from brad@openbsd.
 1.14.2.2 21-Nov-2005  tron Pull up following revision(s) (requested by riz in ticket #979):
sys/dev/pci/if_sk.c: revision 1.17
From FreeBSD (appropriate pieces of revs 1.90 and 1.92):
Only clear the IFF_OACTIVE flag when we have a chance of being able
to queue a packet to the hardware, instead of when the hardware queue
is empty, and fix up handling and prodding of the tx.
These fixes clear up an occasional "sk0: watchdog timeout" from the
on-board ethernet on my Asus A8V motherboard.
OK christos@
 1.14.2.1 13-Sep-2005  tron Pull up following revision(s) (requested by xtraeme in ticket #765):
sys/dev/pci/if_sk.c: revision 1.16
Fix from OpenBSD:
rev 1.56:
Don't initialize the card (and start an autonegotiation!) every time
the IP address changes. Makes 'dhclient sk0' invocations way faster
and more consistant. i.e. one DHCPREQUEST elicts the DHCPACK.
Fix from FreeBSD:
rev 1.109:
Solve "No PHY found" problem for more Yukon Lite variants.
These changes fixed the problem on my sk(4) trying to get an IP
via dhclient(8).
 1.15.2.8 11-Feb-2008  yamt sync with head.
 1.15.2.7 21-Jan-2008  yamt sync with head
 1.15.2.6 07-Dec-2007  yamt sync with head
 1.15.2.5 15-Nov-2007  yamt sync with head.
 1.15.2.4 03-Sep-2007  yamt sync with head.
 1.15.2.3 26-Feb-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.6.2 29-Nov-2005  yamt sync with head.
 1.16.6.1 22-Nov-2005  yamt sync with head.
 1.18.6.2 01-Jun-2006  kardel Sync with head.
 1.18.6.1 22-Apr-2006  simonb Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.18.2.2 01-Mar-2006  yamt sync with head.
 1.18.2.1 18-Feb-2006  yamt sync with head.
 1.21.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.21.4.1 19-Apr-2006  elad sync with head.
 1.21.2.5 14-Sep-2006  yamt sync with head.
 1.21.2.4 03-Sep-2006  yamt sync with head.
 1.21.2.3 26-Jun-2006  yamt sync with head.
 1.21.2.2 24-May-2006  yamt sync with head.
 1.21.2.1 01-Apr-2006  yamt sync with head.
 1.25.2.1 19-Jun-2006  chap Sync with head.
 1.26.4.2 08-Sep-2006  rpaulo Pull up following revision(s) (requested by riz in ticket #140):
sys/dev/pci/if_sk.c: revision 1.31
sys/dev/pci/if_sk.c: revision 1.32
sys/dev/pci/if_sk.c: revision 1.27
sys/dev/pci/if_sk.c: revision 1.28
sys/dev/pci/if_sk.c: revision 1.29
Make this driver compile when SK_USEIOSPACE is defined - I have no
evidence that this is actually needed except for the existence of the
code itself, but if it's going to be here, it should compile. Tested
briefly on my ASUS motherboard with built-in sk interface.
Some cleanup in skc_attach():
- does not need splnet()
- disestablish the interrupt and unmap bus space on failures.
Add byteswapping where appropriate, to allow things to work on
(at least some) bigendian systems - I tested on macppc.
From brad@openbsd .
Cleanup, with no functional changes:
- remove unused code
- KNF
- ANSI function declarations
- replace printf() with aprint_error() except in debug functions
- a few minor indentation/whitespace changes
In sk_watchdog(), attempt to reclaim pending TX descriptors before
resetting the hardware. Should fix occasional watchdog timeouts
seen with this driver.
From FreeBSD, via OpenBSD.
 1.26.4.1 08-Sep-2006  rpaulo Pull up following revision(s) (requested by riz in ticket #139):
sys/arch/cobalt/pci/pchb.c: revision 1.9
sys/dev/pci/if_sk.c: revision 1.30
sys/arch/cobalt/pci/pci_machdep.c: revision 1.24
sys/dev/pci/pcidevs: revision 1.820
sys/arch/evbmips/malta/pci/pchb.c: revision 1.9
Rename vendor GALILEO -> vendor MARVELL . Marvell bought Galileo years
ago, we have little existing stuff in the tree, and this will make it
easier to keep certain network drivers in sync with other OSes.
OK matt@, uwe@
Vendor GALILEO is now MARVELL.
 1.32.2.2 01-Feb-2007  ad Sync with head.
 1.32.2.1 18-Nov-2006  ad Sync with head.
 1.33.2.2 10-Dec-2006  yamt sync with head.
 1.33.2.1 22-Oct-2006  yamt sync with head
 1.35.2.2 26-Aug-2007  liamjfoy Pull up following revision(s) (requested by riz in ticket #816):
sys/dev/pci/if_skreg.h: revision 1.10
sys/dev/pci/if_skreg.h: revision 1.11
sys/dev/pci/pcidevs: revision 1.866
sys/dev/pci/if_skreg.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.36
sys/dev/pci/if_msk.c: revision 1.4
sys/dev/pci/if_msk.c: revision 1.5
sys/dev/pci/if_msk.c: revision 1.6
sys/dev/pci/if_msk.c: revision 1.7
sys/dev/pci/if_mskvar.h: revision 1.2
sys/dev/pci/if_mskvar.h: revision 1.3
Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
Original commit message:
> In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> continuing when busy flag set.

add some msk devices

sync with OpenBSD-current (many bugfixes, add some devices)
if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41

sync with if_skreg.h rev. 1.41
need more work?

apply some patches from FreeBSD
o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs

fix bit definitions for the RX FIFO Flush mode

Apply OpenBSD's rev. 1.14 via patch:
> remove another Yukon Lite workaround.
 1.35.2.1 26-Mar-2007  jdc branches: 1.35.2.1.2;
Pull up revision 1.38 (requested by msaitoh in ticket #519).

Apply if_msk.c rev. 1.4 to if_sk.c:

> Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
>
> Original commit message:
> > In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> > continuing when busy flag set.
 1.35.2.1.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.36.2.2 24-Mar-2007  yamt sync with head.
 1.36.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.4.1 11-Jul-2007  mjf Sync with head.
 1.37.2.5 01-Sep-2007  ad Update for pool_cache API changes.
 1.37.2.4 20-Aug-2007  ad Sync with HEAD.
 1.37.2.3 15-Jul-2007  ad Sync with head.
 1.37.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.37.2.1 13-Mar-2007  ad Sync with head.
 1.41.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.42.14.2 19-Jul-2007  dsl include sys/cdefs.h
 1.42.14.1 19-Jul-2007  dsl file if_sk.c was added on branch matt-mips64 on 2007-07-19 22:04:24 +0000
 1.42.12.4 18-Feb-2008  mjf Sync with HEAD.
 1.42.12.3 27-Dec-2007  mjf Sync with HEAD.
 1.42.12.2 08-Dec-2007  mjf Sync with HEAD.
 1.42.12.1 19-Nov-2007  mjf Sync with HEAD.
 1.42.10.1 13-Nov-2007  bouyer Sync with HEAD
 1.42.6.3 23-Mar-2008  matt sync with HEAD
 1.42.6.2 09-Jan-2008  matt sync with HEAD
 1.42.6.1 08-Nov-2007  matt sync with -HEAD
 1.42.4.2 03-Dec-2007  joerg Sync with HEAD.
 1.42.4.1 11-Nov-2007  joerg Sync with HEAD.
 1.44.6.2 20-Jan-2008  bouyer Sync with HEAD
 1.44.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.44.4.1 11-Dec-2007  yamt sync with head.
 1.44.2.1 26-Dec-2007  ad Sync with head.
 1.47.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.47.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.47.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.47.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.48.4.5 11-Aug-2010  yamt sync with head.
 1.48.4.4 11-Mar-2010  yamt sync with head
 1.48.4.3 16-Sep-2009  yamt sync with head
 1.48.4.2 04-May-2009  yamt sync with head.
 1.48.4.1 16-May-2008  yamt sync with head.
 1.48.2.1 18-May-2008  yamt sync with head.
 1.49.4.1 27-Jun-2008  simonb Sync with head.
 1.49.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.49.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.50.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.50.2.1 19-Oct-2008  haad Sync with HEAD.
 1.54.6.1 26-Jul-2009  snj branches: 1.54.6.1.2;
Pull up following revision(s) (requested by dholland in ticket #874):
sys/dev/ic/ciss.c: revision 1.15
sys/dev/isa/isadma.c: revision 1.59
sys/dev/usb/ulpt.c: revision 1.82
sys/dev/ic/tcic2.c: revision 1.31
sys/dev/isa/if_ntwoc_isa.c: revision 1.18
sys/dev/pci/if_sk.c: revision 1.57
sys/dev/pcmcia/if_cnw.c: revision 1.46
More printf format fixes.
 1.54.6.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.54.4.1 26-Jul-2009  snj Pull up following revision(s) (requested by dholland in ticket #874):
sys/dev/ic/ciss.c: revision 1.15
sys/dev/isa/isadma.c: revision 1.59
sys/dev/usb/ulpt.c: revision 1.82
sys/dev/ic/tcic2.c: revision 1.31
sys/dev/isa/if_ntwoc_isa.c: revision 1.18
sys/dev/pci/if_sk.c: revision 1.57
sys/dev/pcmcia/if_cnw.c: revision 1.46
More printf format fixes.
 1.54.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.54.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.54.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.55.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.64.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.64.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.65.2.3 31-May-2011  rmind sync with head
 1.65.2.2 05-Mar-2011  rmind sync with head
 1.65.2.1 30-May-2010  rmind sync with head
 1.68.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.69.8.1 18-Feb-2012  mrg merge to -current.
 1.69.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.69.4.2 30-Oct-2012  yamt sync with head
 1.69.4.1 17-Apr-2012  yamt sync with head
 1.72.2.3 03-Dec-2017  jdolecek update from HEAD
 1.72.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.72.2.1 23-Jun-2013  tls resync from head
 1.74.2.1 18-May-2014  rmind sync with head
 1.77.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.78.4.5 05-Feb-2017  skrll Sync with HEAD
 1.78.4.4 09-Jul-2016  skrll Sync with HEAD
 1.78.4.3 19-Mar-2016  skrll Sync with HEAD
 1.78.4.2 06-Jun-2015  skrll Sync with HEAD
 1.78.4.1 06-Apr-2015  skrll Sync with HEAD
 1.82.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.85.14.5 26-Jan-2019  pgoyette Sync with HEAD
 1.85.14.4 18-Jan-2019  pgoyette Synch with HEAD
 1.85.14.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.85.14.2 28-Jul-2018  pgoyette Sync with HEAD
 1.85.14.1 25-Jun-2018  pgoyette Sync with HEAD
 1.85.8.1 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.87.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.87.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.87.2.1 10-Jun-2019  christos Sync with HEAD
 1.103.2.1 29-Feb-2020  ad Sync with head.
 1.106.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.107.2.1 13-May-2021  thorpej Sync with HEAD.
 1.108.6.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.112.2.1 02-Aug-2025  perseant Sync with HEAD
 1.34 16-Feb-2025  jakllsch Add additional Yukon2 definitions relating to hardware VLAN tagging and
queue interrupt information
 1.33 09-Feb-2024  andvar branches: 1.33.2;
fix spelling mistakes, mainly in comments and log messages.
 1.32 02-Feb-2024  andvar fix various typos in comments.
 1.31 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.30 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.29 08-May-2020  jakllsch if_skreg.h: remove duplicate or triplicate identical #defines
 1.28 26-Apr-2020  jakllsch Use __aligned(8) with naturally-aligned-yet-__packed msk(4) descriptors.

Allows compiler to generate more efficent struct member accesses.
 1.27 15-Nov-2019  msaitoh Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.
 1.26 05-Mar-2019  msaitoh branches: 1.26.4;
Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.25 14-Sep-2018  jakllsch msk(4): add 64-bit DMA support

portions of this change set provided by mrg@
 1.24 11-Jul-2018  kre Build fix: Supply missing symbol definition.
Value taken from OpenBSD (and confirmed with FreeBSD)
(Feel free to fix/reformat as appropriate...)
 1.23 10-Jul-2018  kre Whitespace fixes. NFC.
 1.22 04-Jul-2018  jdolecek sync SK_IMTIMER_TICKS_YUKON value with OpenBSD (likely pasto)
 1.21 14-Jun-2018  msaitoh branches: 1.21.2;
s/regisrer/register/. No functional change.
 1.20 14-Jun-2018  msaitoh The revision number of Yukon FE A2 is not 0x3 but 0x2. Same as other OSes.
 1.19 13-Jun-2018  jdolecek actually recognize the Yukon 2 variants up to SK_YUKON_OPTIMA2 as such
 1.18 12-Jun-2018  jdolecek move SK_HASH_BITS to if_skreg.h and reuse in if_msk.c (from OpenBSD)
 1.17 12-Jun-2018  jdolecek match three more variants - DGE550T_B1, 8040T, 8042

sync more sk_type conditionals from OpenBSD
 1.16 09-Jun-2018  jdolecek port basic match support for several more Yukon variants from OpenBSD, together
with some basic conditionals I've found in that driver; only compile-tested, so
very likely needs further work to actually work

adresses also PR kern/43507
 1.15 10-Oct-2014  christos branches: 1.15.18;
PR/49270: Hauke Fath: Samsung NC10 Marvell Yukon ethernet not supported
 1.14 29-May-2011  phx branches: 1.14.14;
The Genesis interface provides a register in the device specific config space
to automatically revert the byte order in all descriptors.
Make sure this feature is inactive. Otherwise the driver is unable to
receive or transmit any frame.
 1.13 18-Nov-2008  chris branches: 1.13.8; 1.13.10;
Fix Yukon EC Ultra cold power up issue.

For the EC Ultra it is necessary to update some extra registers during
reset. Without doing so causes the system to hang at boot. The only
workaround I found was to PXE boot before booting into NetBSD.

This change is based on the code from FreeBSD's if_msk.c. Specifically the
msk_phy_power function.

Also add an splnet/splx across mii_tick. This matches most other network
drivers.

Change posted for review on 3rd Oct 2008 to tech-net. No feedback
received.
 1.12 28-Apr-2008  martin branches: 1.12.6; 1.12.8; 1.12.10;
Remove clause 3 and 4 from TNF licenses
 1.11 31-Jan-2007  msaitoh branches: 1.11.40; 1.11.42; 1.11.44;
fix bit definitions for the RX FIFO Flush mode
 1.10 30-Jan-2007  msaitoh apply some patches from FreeBSD

o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs
 1.9 30-Jan-2007  msaitoh sync with OpenBSD-current (many bugfixes, add some devices)

if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41
 1.8 09-Sep-2006  riz branches: 1.8.4; 1.8.6;
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:

- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.

Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.7 31-May-2006  riz branches: 1.7.4; 1.7.6;
Add support for the DLink DGE-530T revision B1 (Tested by Tillman
Hodgson) and the DGE-560T (untested).
 1.6 14-Feb-2006  riz branches: 1.6.2; 1.6.8;
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.

Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.

Discussed on tech-net beginning in November 2005.
 1.5 11-Dec-2005  christos branches: 1.5.2; 1.5.4; 1.5.6;
merge ktrace-lwp.
 1.4 30-May-2005  christos branches: 1.4.2;
- const poisoning
- avoid variable shadowing.
 1.3 26-Sep-2004  skd branches: 1.3.10;
Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.2 26-Aug-2003  jdolecek branches: 1.2.2; 1.2.4; 1.2.6;
retain the FreeBSD RCS Id for xmaciireg.h for reference
 1.1 26-Aug-2003  jdolecek Add driver for SysKonnect SK-9821 and 3COM 3C940 gigabit ethernet boards
From FreeBSD via OpenBSD, port to NetBSD done by Stephen Degler

Changes relative to submitted version:
* yukonreg.h and xmaciireg.h merged into if_skreg.h
* bhack[] constified + other small editing changes
* use 'Ethernet address' rather than 'address' in attach message

XXX completely untested by me, needs further cleanup

Driver provided in PR kern/22511 by Stephen Degler
 1.2.6.3 04-Jun-2006  tron Pull up following revision(s) (requested by riz in ticket #10636):
sys/dev/pci/if_skreg.h: revision 1.7
sys/dev/pci/if_sk.c: revision 1.26
Add support for the DLink DGE-530T revision B1 (Tested by Tillman
Hodgson) and the DGE-560T (untested).
 1.2.6.2 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #10403):
sys/dev/pci/if_skreg.h: revision 1.6
sys/dev/pci/if_skvar.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.20 via patch
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.
Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.
Discussed on tech-net beginning in November 2005.
 1.2.6.1 07-Jan-2005  jdc Pull up revision 1.3 (requested by abs in ticket #973).

Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.2.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.4.5 19-Oct-2004  skrll Sync with HEAD
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 26-Aug-2003  skrll file if_skreg.h was added on branch ktrace-lwp on 2004-08-03 10:49:09 +0000
 1.2.2.1 07-Jan-2005  jdc Pull up revision 1.3 (requested by abs in ticket #973).

Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.3.10.2 04-Jun-2006  tron Pull up following revision(s) (requested by riz in ticket #1350):
sys/dev/pci/if_skreg.h: revision 1.7
sys/dev/pci/if_sk.c: revision 1.26
Add support for the DLink DGE-530T revision B1 (Tested by Tillman
Hodgson) and the DGE-560T (untested).
 1.3.10.1 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #1230):
sys/dev/pci/if_skreg.h: revision 1.6
sys/dev/pci/if_skvar.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.20 via patch
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.
Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.
Discussed on tech-net beginning in November 2005.
 1.4.2.3 26-Feb-2007  yamt sync with head.
 1.4.2.2 30-Dec-2006  yamt sync with head.
 1.4.2.1 21-Jun-2006  yamt sync with head.
 1.5.6.2 01-Jun-2006  kardel Sync with head.
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.5.2.1 18-Feb-2006  yamt sync with head.
 1.6.8.1 19-Jun-2006  chap Sync with head.
 1.6.2.2 14-Sep-2006  yamt sync with head.
 1.6.2.1 26-Jun-2006  yamt sync with head.
 1.7.6.2 01-Feb-2007  ad Sync with head.
 1.7.6.1 18-Nov-2006  ad Sync with head.
 1.7.4.1 15-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #153):
sys/dev/pci/if_skreg.h: revision 1.8
sys/dev/pci/if_msk.c: revision 1.1
sys/dev/pci/files.pci: revision 1.268
sys/dev/pci/if_mskvar.h: revision 1.1
Add msk(4), a driver for Marvell Yukon 2 gigabit ethernet chips,
from Mark Kettenis of OpenBSD. There are still some outstanding
issues with this driver, namely:
- Checksum offload is unsupported
- There is a significant amount of code duplication from sk(4)
- There remain some 'magic numbers'
- Performance is not heavily tested, and likely to be lower than
the chip is capable of in some cases. Syncing some of the
aforementioned 'magic numbers' with the Marvell FreeBSD driver
should help here.
Tested on a motherboard with Marvell 88E8053 ethernet, under NetBSD/i386
and NetBSD/amd64.
 1.8.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.8.4.1 26-Aug-2007  liamjfoy Pull up following revision(s) (requested by riz in ticket #816):
sys/dev/pci/if_skreg.h: revision 1.10
sys/dev/pci/if_skreg.h: revision 1.11
sys/dev/pci/pcidevs: revision 1.866
sys/dev/pci/if_skreg.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.36
sys/dev/pci/if_msk.c: revision 1.4
sys/dev/pci/if_msk.c: revision 1.5
sys/dev/pci/if_msk.c: revision 1.6
sys/dev/pci/if_msk.c: revision 1.7
sys/dev/pci/if_mskvar.h: revision 1.2
sys/dev/pci/if_mskvar.h: revision 1.3
Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
Original commit message:
> In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> continuing when busy flag set.

add some msk devices

sync with OpenBSD-current (many bugfixes, add some devices)
if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41

sync with if_skreg.h rev. 1.41
need more work?

apply some patches from FreeBSD
o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs

fix bit definitions for the RX FIFO Flush mode

Apply OpenBSD's rev. 1.14 via patch:
> remove another Yukon Lite workaround.
 1.11.44.2 04-May-2009  yamt sync with head.
 1.11.44.1 16-May-2008  yamt sync with head.
 1.11.42.1 18-May-2008  yamt sync with head.
 1.11.40.2 17-Jan-2009  mjf Sync with HEAD.
 1.11.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 20-Nov-2008  snj Pull up following revision(s) (requested by chris in ticket #84):
sys/dev/pci/if_skreg.h: revision 1.13
sys/dev/pci/if_msk.c: revision 1.22
Fix Yukon EC Ultra cold power up issue.
For the EC Ultra it is necessary to update some extra registers during
reset. Without doing so causes the system to hang at boot. The only
workaround I found was to PXE boot before booting into NetBSD.
This change is based on the code from FreeBSD's if_msk.c. Specifically the
msk_phy_power function.
Also add an splnet/splx across mii_tick. This matches most other network
drivers.
Change posted for review on 3rd Oct 2008 to tech-net. No feedback
received.
 1.12.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.8.1 31-May-2011  rmind sync with head
 1.14.14.1 03-Dec-2017  jdolecek update from HEAD
 1.15.18.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.15.18.2 28-Jul-2018  pgoyette Sync with HEAD
 1.15.18.1 25-Jun-2018  pgoyette Sync with HEAD
 1.21.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.21.2.1 10-Jun-2019  christos Sync with HEAD
 1.26.4.1 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #450):

sys/dev/pci/if_msk.c: revision 1.94
sys/dev/pci/if_skreg.h: revision 1.27

Make Yukon EX, FE+, SUPR stable. The code is mainly taken from FreeBSD.

At least, this change made my own Yukon EX machine (HP ProBook 4501s) much
stable than before.
 1.33.2.1 02-Aug-2025  perseant Sync with HEAD
 1.20 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.19 03-Jul-2018  jdolecek attach the rnd source only once even with dual-port adapters
 1.18 13-Apr-2015  riastradh branches: 1.18.16; 1.18.18;
Convert sys/dev to use <sys/rndsource.h>.
 1.17 02-Feb-2012  tls branches: 1.17.6; 1.17.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.16 19-Nov-2011  tls branches: 1.16.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.15 08-Sep-2008  christos branches: 1.15.28;
cf_attach_decl_new
 1.14 20-Jun-2008  cube branches: 1.14.2;
Use a mutex instead of splvm() to protect the list of jubo-ready mbufs, as
done with nfe(4) a while ago.

Issue reported by Gary Duzan, who kindly fixed the patch I had sent him.
 1.13 28-Apr-2008  martin branches: 1.13.2; 1.13.4;
Remove clause 3 and 4 from TNF licenses
 1.12 04-Mar-2007  christos branches: 1.12.36; 1.12.38; 1.12.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 04-Sep-2006  riz branches: 1.11.8;
Remove unused members of sk_softc.
 1.10 28-Mar-2006  riz Add jumbo frames support, from OpenBSD (mcbride). As seen on tech-net
for the last N months.
 1.9 14-Feb-2006  riz branches: 1.9.2; 1.9.4; 1.9.6;
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.

Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.

Discussed on tech-net beginning in November 2005.
 1.8 11-Feb-2006  rpaulo PR 31304: Contribute to the random pool. From Rhialto.
 1.7 11-Dec-2005  christos branches: 1.7.2; 1.7.4; 1.7.6;
merge ktrace-lwp.
 1.6 30-May-2005  christos branches: 1.6.2;
- const poisoning
- avoid variable shadowing.
 1.5 27-Feb-2005  perry branches: 1.5.2;
nuke trailing whitespace
 1.4 26-Sep-2004  skd branches: 1.4.4; 1.4.6;
Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.3 02-Nov-2003  wiz branches: 1.3.2; 1.3.4; 1.3.6;
boundary, not boundry. Inspired by Tom Cosgrove.
 1.2 15-Oct-2003  briggs Make sure descriptors get bus_dmamap_sync()ed.
Restructure a little to make this a little easier.
Also try to avoid allocating things at reset time.
 1.1 26-Aug-2003  jdolecek Add driver for SysKonnect SK-9821 and 3COM 3C940 gigabit ethernet boards
From FreeBSD via OpenBSD, port to NetBSD done by Stephen Degler

Changes relative to submitted version:
* yukonreg.h and xmaciireg.h merged into if_skreg.h
* bhack[] constified + other small editing changes
* use 'Ethernet address' rather than 'address' in attach message

XXX completely untested by me, needs further cleanup

Driver provided in PR kern/22511 by Stephen Degler
 1.3.6.4 07-Sep-2006  rpaulo Pull up following revision(s) (requested by riz in ticket #10680):
sys/dev/pci/if_skvar.h: revision 1.10
share/man/man4/sk.4: revision 1.9
sys/dev/pci/if_sk.c: revision 1.22
Add jumbo frames support, from OpenBSD (mcbride). As seen on tech-net
for the last N months.
Jumbo frames now work under NetBSD, so note it.
 1.3.6.3 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #10403):
sys/dev/pci/if_skreg.h: revision 1.6
sys/dev/pci/if_skvar.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.20 via patch
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.
Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.
Discussed on tech-net beginning in November 2005.
 1.3.6.2 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #10402):
sys/dev/pci/if_sk.c: revision 1.19
sys/dev/pci/if_skvar.h: revision 1.8
PR 31304: Contribute to the random pool. From Rhialto.
 1.3.6.1 07-Jan-2005  jdc Pull up revision 1.4 (requested by abs in ticket #973).

Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.3.4.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.4.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.4.5 19-Oct-2004  skrll Sync with HEAD
 1.3.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 02-Nov-2003  skrll file if_skvar.h was added on branch ktrace-lwp on 2004-08-03 10:49:09 +0000
 1.3.2.1 07-Jan-2005  jdc Pull up revision 1.4 (requested by abs in ticket #973).

Fix Yukon ram sizing.
Fix tx queue (slist can be corrupted when tx interrupts hit within tx_encap.
Lower interrupt moderation timer to (improves performance).
Improve chip identification. (from linux sk98lin driver).
Keep tx queue running by kicking the tx bmu repeatedly.
 1.4.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.5.2.3 03-Nov-2006  tron Pull up following revision(s) (requested by riz in ticket #1480):
sys/dev/pci/if_skvar.h: revision 1.10
sys/dev/pci/if_sk.c: revision 1.22
Add jumbo frames support, from OpenBSD (mcbride). As seen on tech-net
for the last N months.
 1.5.2.2 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #1230):
sys/dev/pci/if_skreg.h: revision 1.6
sys/dev/pci/if_skvar.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.20 via patch
Not all chips supported by this driver use the same interrupt moderation
timer frequency; Take this into account. Information gathered from
the sk98lin driver for Linux, from Marvell.
Also add sysctl support for changing the interrupt moderation timer at
runtime; each board is controlled independently.
Discussed on tech-net beginning in November 2005.
 1.5.2.1 29-Mar-2006  tron Pull up following revision(s) (requested by riz in ticket #1229):
sys/dev/pci/if_sk.c: revision 1.19
sys/dev/pci/if_skvar.h: revision 1.8
PR 31304: Contribute to the random pool. From Rhialto.
 1.6.2.3 03-Sep-2007  yamt sync with head.
 1.6.2.2 30-Dec-2006  yamt sync with head.
 1.6.2.1 21-Jun-2006  yamt sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.7.2.1 18-Feb-2006  yamt sync with head.
 1.9.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.9.4.1 19-Apr-2006  elad sync with head.
 1.9.2.2 14-Sep-2006  yamt sync with head.
 1.9.2.1 01-Apr-2006  yamt sync with head.
 1.11.8.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.40.2 04-May-2009  yamt sync with head.
 1.12.40.1 16-May-2008  yamt sync with head.
 1.12.38.1 18-May-2008  yamt sync with head.
 1.12.36.3 28-Sep-2008  mjf Sync with HEAD.
 1.12.36.2 29-Jun-2008  mjf Sync with HEAD.
 1.12.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.4.1 27-Jun-2008  simonb Sync with head.
 1.13.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.13.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.2.1 19-Oct-2008  haad Sync with HEAD.
 1.15.28.1 17-Apr-2012  yamt sync with head
 1.16.2.1 18-Feb-2012  mrg merge to -current.
 1.17.24.1 06-Jun-2015  skrll Sync with HEAD
 1.17.6.1 03-Dec-2017  jdolecek update from HEAD
 1.18.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.18.1 10-Jun-2019  christos Sync with HEAD
 1.18.16.1 28-Jul-2018  pgoyette Sync with HEAD
 1.66 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.65 10-Feb-2024  andvar s/alloted/allotted/ in comments.
 1.64 21-Sep-2022  thorpej No need to include <sys/malloc.h>
 1.63 21-Sep-2022  thorpej Fix a memory leak in an extremely uncommon error path in ste_start().
 1.62 15-Mar-2020  thorpej Don't bother with IFF_OACTIVE.
 1.61 13-Mar-2020  thorpej - Add the D-Link products, identified by subsystem ID.
- On some variations, the internal PHY is ghosted at #0 and #1. Work
around this by ignoring PHY #0 accesses unless we don't find one, and
then look for one there as a fall-back if we don't detect anything else.
- Fix access width when setting the TxDMAUrgentThresh register.
- Support MBUFTRACE.
 1.60 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.59 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.58 02-Nov-2019  tnn branches: 1.58.2;
cast away unused return value
 1.57 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.56 28-May-2019  msaitoh branches: 1.56.2;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.55 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.54 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.53 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.52 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.51 26-Jun-2018  msaitoh branches: 1.51.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.50 15-Dec-2016  ozaki-r branches: 1.50.8; 1.50.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.49 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.48 07-Jul-2016  msaitoh branches: 1.48.2;
KNF. Remove extra spaces. No functional change.
 1.47 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.46 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.45 29-Mar-2014  christos branches: 1.45.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.44 27-Oct-2012  chs branches: 1.44.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.43 22-Jul-2012  matt branches: 1.43.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.42 13-Nov-2010  uebayasi branches: 1.42.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.41 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.40 19-Jan-2010  pooka branches: 1.40.2; 1.40.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.39 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.38 27-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only.
 1.37 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.36 28-Apr-2008  martin branches: 1.36.14;
Remove clause 3 and 4 from TNF licenses
 1.35 10-Apr-2008  cegger branches: 1.35.2; 1.35.4;
use aprint_*_dev and device_xname
 1.34 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.33 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.32 19-Jan-2008  dyoung branches: 1.32.2; 1.32.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.31 19-Oct-2007  ad branches: 1.31.2; 1.31.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.30 14-Oct-2007  xtraeme branches: 1.30.2;
IC Plus Corp IP100A support for ste(4), submitted by
Pedro Alejandro Lopez-Valencia in PR kern/36605.
 1.29 26-Aug-2007  dyoung branches: 1.29.2; 1.29.4;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.28 09-Jul-2007  ad branches: 1.28.2; 1.28.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.27 04-Mar-2007  christos branches: 1.27.2; 1.27.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.26 07-Jan-2007  mlelstv branches: 1.26.2;
Make watchdog poll interrupts before re-initializing the chip.
Fixes kern/34834.
 1.25 16-Nov-2006  christos branches: 1.25.2;
__unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 17-Jun-2006  christos branches: 1.23.4; 1.23.6;
re-factor the pci powestate api. reviewed by gimpy
 1.22 11-Dec-2005  christos branches: 1.22.4; 1.22.8; 1.22.14; 1.22.16;
merge ktrace-lwp.
 1.21 27-Feb-2005  perry branches: 1.21.4;
nuke trailing whitespace
 1.20 30-Oct-2004  thorpej branches: 1.20.4; 1.20.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.19 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.18 08-Jul-2004  mycroft Program the "MaxFrameSize" register so that it's correct for VLAN
encapsulation, per PR 20195.
 1.17 05-Jun-2003  tsutsui branches: 1.17.2; 1.17.4;
Add a missed htole32() for DMA txdescs.
Problem reported by Todd Mortimer on port-macppc.
 1.16 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.15 21-Oct-2002  fair Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.
 1.14 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.13 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 05-Jun-2002  bouyer STE_CarrierSenseErrors is 8bit wide, not 16bit.
Reenable statistics interrupts, reading it as 16bit caused it to not be cleared,and thus the eventual interrupt to not be cleared (and this caused an
infinite loop in interrupt routine).
While I'm there count STE_CarrierSenseErrors as oerror (this is incremented
each time we try to send a packet and the link is down).
 1.10 05-Jun-2002  bouyer Rework transmit underrun logic:
- when a transmit underrun occurs, only reset the transmit logic. This prevents
the link from going down at the MII level (the same logic can probably
be used for other transmit errors)
- set the urgent threshold to half the start threshold. From experiments
this helps a bit decreasing the number of underruns

Now that underruns don't cause the interface to stop for several seconds,
make back out the default transmit threshold to 128.
 1.9 01-Jun-2002  bouyer When the chip gets a transmit underrun, the driver resets the chip, which
cause the link to go down for several seconds on my Dlink DFE580-TX (quad-port
DL1002). This behavior is unacceptable, especially as the driver usually
gets several underrun at once, causing the link to be almost unaviable
for several 10s of seconds.
Bump the default transmit threshold to 1504 bytes to avoid transmit underrun.
 1.8 01-Jun-2002  bouyer On a Dlink DFE580-TX (DL-1002), attempting to transmit packets while the link
is down cause the chip to create an IE_UpdateStats condition which can't be
cleared, causing the driver to enter an interrupt loop.
Workaround: mask IE_UpdateStats
 1.7 13-Nov-2001  lukem branches: 1.7.8; 1.7.10;
add RCSID
 1.6 23-Jul-2001  thorpej branches: 1.6.2;
Make sure to initialize the all Rx descriptors properly in *_init()
even if mbufs for them are already allocated.
 1.5 23-Jul-2001  thorpej Adjust some reset delays.
 1.4 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.3 30-Jun-2001  thorpej branches: 1.3.2;
Update for D-Link ST201 change.
 1.2 29-Jun-2001  thorpej In the `copy small' path, make sure to align the payload.
 1.1 19-Jun-2001  thorpej Device driver for the Sundance Tech. ST-201 10/100 Ethernet. This
chip is found on the D-Link DFE-550TX.
 1.3.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 03-Aug-2001  lukem update to -current
 1.6.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.6.2.6 11-Nov-2002  nathanw Catch up to -current
 1.6.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.6.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.6.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.6.2.1 23-Jul-2001  nathanw file if_ste.c was added on branch nathanw_sa on 2001-08-24 00:10:07 +0000
 1.7.10.2 17-Jun-2003  msaitoh Pull up revisions 1.17 (requested by tsutsui in ticket #1315):
Add a missed htole32() for DMA txdescs.
 1.7.10.1 10-Jun-2002  tv Pull up revision 1.8 (requested by 128 in ticket #0):
- mask IE_UpdateStats interrupt: the driver fails to clear the interrupt
and enter an interrupt loop (it may be a chip bug, I didn't have the time
to investigate yet) if it attemps to transmit some packets while the link
is down (like unplug/replug the cable, ifconfig down/ifconfig up or after a
transmit underrun condition, see below)
- bump the default transmit threshold to 1504 to avoid transmit underruns.
The driver resets the chip after a transmit underrun condition, which
makes the link go down for several seconds, which is unacceptable for
a server usage (after bootup you'll get 10s of underruns before the
threshold is high enouth and things stabilize, which means the link is
almost unusable for minutes)
- update documentation to mention the quad-port DFE580TX, and mention the
driver in notes.
 1.7.8.1 20-Jun-2002  gehenna catch up with -current.
 1.17.4.1 23-Jul-2004  he branches: 1.17.4.1.2;
Pull up revision 1.18 (requested by mycroft in ticket #698):
Program the "MaxFrameSize" register so that it is correct
for VLAN encapsulation. Fixes PR#20195.
 1.17.4.1.2.1 24-Jan-2005  he Pull up revision 1.20 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.17.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.17.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.17.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.17.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.4.1 29-Apr-2005  kent sync with -current
 1.21.4.7 24-Mar-2008  yamt sync with head.
 1.21.4.6 17-Mar-2008  yamt sync with head.
 1.21.4.5 21-Jan-2008  yamt sync with head
 1.21.4.4 27-Oct-2007  yamt sync with head.
 1.21.4.3 03-Sep-2007  yamt sync with head.
 1.21.4.2 26-Feb-2007  yamt sync with head.
 1.21.4.1 21-Jun-2006  yamt sync with head.
 1.22.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.22.14.1 19-Jun-2006  chap Sync with head.
 1.22.8.1 26-Jun-2006  yamt sync with head.
 1.22.4.1 09-Sep-2006  rpaulo sync with head
 1.23.6.2 10-Dec-2006  yamt sync with head.
 1.23.6.1 22-Oct-2006  yamt sync with head
 1.23.4.2 12-Jan-2007  ad Sync with head.
 1.23.4.1 18-Nov-2006  ad Sync with head.
 1.25.2.2 22-Oct-2007  pavel Pull up following revisions (requested by xtraeme in ticket #931):
sys/dev/pci/pcidevs: revision 1.905
sys/dev/pci/if_ste.c: revision 1.30
IC Plus Corp IP100A support for ste(4), submitted by
Pedro Alejandro Lopez-Valencia in PR kern/36605.
 1.25.2.1 01-Apr-2007  bouyer branches: 1.25.2.1.2;
Pull up following revision(s) (requested by mlelstv in ticket #552):
sys/dev/pci/if_ste.c: revision 1.26
Make watchdog poll interrupts before re-initializing the chip.
Fixes kern/34834.
 1.25.2.1.2.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.26.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.27.4.1 11-Jul-2007  mjf Sync with head.
 1.27.2.3 23-Oct-2007  ad Sync with head.
 1.27.2.2 09-Oct-2007  ad Sync with head.
 1.27.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.28.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.28.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.28.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.29.4.1 14-Oct-2007  yamt sync with head.
 1.29.2.2 23-Mar-2008  matt sync with HEAD
 1.29.2.1 06-Nov-2007  matt sync with HEAD
 1.30.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.31.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.31.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.32.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.32.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.2.1 24-Mar-2008  keiichi sync with head.
 1.35.4.4 11-Aug-2010  yamt sync with head.
 1.35.4.3 11-Mar-2010  yamt sync with head
 1.35.4.2 16-May-2009  yamt sync with head
 1.35.4.1 16-May-2008  yamt sync with head.
 1.35.2.1 18-May-2008  yamt sync with head.
 1.36.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.40.4.2 05-Mar-2011  rmind sync with head
 1.40.4.1 30-May-2010  rmind sync with head
 1.40.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.8.1 30-Oct-2012  yamt sync with head
 1.43.2.3 03-Dec-2017  jdolecek update from HEAD
 1.43.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.44.2.1 18-May-2014  rmind sync with head
 1.45.6.3 05-Feb-2017  skrll Sync with HEAD
 1.45.6.2 09-Jul-2016  skrll Sync with HEAD
 1.45.6.1 19-Mar-2016  skrll Sync with HEAD
 1.48.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.50.14.3 26-Jan-2019  pgoyette Sync with HEAD
 1.50.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.50.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.50.8.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.51.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.51.2.1 10-Jun-2019  christos Sync with HEAD
 1.56.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.58.2.1 29-Feb-2020  ad Sync with head.
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 25-Dec-2007  perry branches: 1.4.6; 1.4.8; 1.4.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.3 24-Jun-2002  bouyer branches: 1.3.22; 1.3.80; 1.3.86; 1.3.90; 1.3.94;
Typo fix
 1.2 03-May-2002  thorpej branches: 1.2.2;
Bump the number of Tx DMA segments from 8 to 16 (the zero-copy socket
code sometimes sees more than 8).
 1.1 19-Jun-2001  thorpej branches: 1.1.2; 1.1.4;
Device driver for the Sundance Tech. ST-201 10/100 Ethernet. This
chip is found on the D-Link DFE-550TX.
 1.1.4.4 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 19-Jun-2001  nathanw file if_stereg.h was added on branch nathanw_sa on 2001-08-24 00:10:07 +0000
 1.1.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 15-Jul-2002  gehenna catch up with -current.
 1.3.94.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.90.1 26-Dec-2007  ad Sync with head.
 1.3.86.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.80.1 09-Jan-2008  matt sync with HEAD
 1.3.22.1 21-Jan-2008  yamt sync with head
 1.4.10.1 16-May-2008  yamt sync with head.
 1.4.8.1 18-May-2008  yamt sync with head.
 1.4.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.94 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.93 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.92 29-Jun-2024  riastradh branches: 1.92.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.91 10-Feb-2024  andvar s/alloted/allotted/ in comments.
 1.90 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.89 22-Jan-2022  martin Explicitly cast a __MASK(40) to bus_addr_t (for 32bit bus_addr_t archs)
 1.88 22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.87 02-Jul-2020  msaitoh prop_data_data_nocopy -> prop_data_value
 1.86 15-Mar-2020  thorpej Don't bother with IFF_OACTIVE.
 1.85 13-Mar-2020  thorpej Support MBUFTRACE.
 1.84 07-Mar-2020  thorpej If bus_dmatag_subregion(), actually fall back on the base 64-bit
DMA tag.
 1.83 02-Mar-2020  thorpej Duh, acctually use all 64-bits when giving the rings to the chip.
 1.82 01-Mar-2020  thorpej Add explicit casts in bus_dmatag_subregion() calls to avoid overflow /
truncation warnings on 32-bit platforms.
 1.81 01-Mar-2020  thorpej Harmonize bus_dmatag_subregion() handling with other drivers.
 1.80 29-Feb-2020  thorpej Use the 64-bit PCI DMA tag if it's available, but range-limit to
40-bit because that's what the hardware can do.
 1.79 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.78 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.77 14-Jan-2020  msaitoh No functional change:

- Move some definitions from if_stgereg.h to if_stge.c again because those are
not chip (registers or descriptors) definitions.
- Use proplib to pass information that loading DSP code is required when
PHY reset.
 1.76 09-Jan-2020  msaitoh Reduce diff against OpenBSD. No functional change.

- USE CSR_{READ,WRITE}_*() macro.
- Move some macros from if_stge.c to if_stgereg.h
 1.75 26-Dec-2019  msaitoh branches: 1.75.2;
Improve flow control.
 1.74 26-Dec-2019  msaitoh Apply OpenBSD rev. 1.34:

> Set Rx early threshold and Tx DMA thesholds.
>
> From Linux via FreeBSD
 1.73 10-Nov-2019  msaitoh Add missing initialization of sc_dev.
 1.72 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.71 07-Oct-2019  msaitoh Add support IC Plus IP1000* PHYs. PR/kern 42314 first reported by
Tomokazu HARADA and patch provided by Andrius V.
 1.70 09-Jul-2019  msaitoh branches: 1.70.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.69 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.68 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.67 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.66 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.65 26-Jun-2018  msaitoh branches: 1.65.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.64 28-Sep-2017  christos branches: 1.64.2;
only get vtag when we have vtag like the other drivers.
 1.63 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.62 15-Dec-2016  ozaki-r branches: 1.62.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.61 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.60 07-Jul-2016  msaitoh branches: 1.60.2;
KNF. Remove extra spaces. No functional change.
 1.59 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.58 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.57 29-Mar-2014  christos branches: 1.57.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.56 30-Mar-2013  christos branches: 1.56.4;
remove trailing whitespace
 1.55 22-Jul-2012  matt branches: 1.55.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.54 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.53 12-Mar-2011  phx branches: 1.53.4; 1.53.8;
When shutting down the network interface it is not enough to stop it. Some
boards also need to reset the chip, otherwise bad things can happen.
 1.52 08-Mar-2011  phx On the ST1023 (and compatible, like IP1000A), the mac-address can also be
passed via device properties, when the serial EEPROM is missing or empty.
 1.51 13-Nov-2010  uebayasi branches: 1.51.2;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.50 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.49 19-Jan-2010  pooka branches: 1.49.2; 1.49.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.48 14-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested on D-Link DL-4000.
 1.47 17-May-2009  tsutsui Split device_t/softc. Tested on D-Link DL-4000.
 1.46 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.45 28-Apr-2008  martin branches: 1.45.14;
Remove clause 3 and 4 from TNF licenses
 1.44 10-Apr-2008  cegger branches: 1.44.2; 1.44.4;
use aprint_*_dev and device_xname
 1.43 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.42 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.41 07-Feb-2008  dyoung branches: 1.41.2; 1.41.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.40 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.39 19-Oct-2007  ad branches: 1.39.2; 1.39.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.38 26-Aug-2007  dyoung branches: 1.38.2; 1.38.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.37 09-Jul-2007  ad branches: 1.37.2; 1.37.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.36 04-Mar-2007  christos branches: 1.36.2; 1.36.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 16-Nov-2006  christos branches: 1.35.4;
__unused removal on arguments; approved by core.
 1.34 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.33 17-Jun-2006  christos branches: 1.33.4; 1.33.6;
re-factor the pci powestate api. reviewed by gimpy
 1.32 11-Dec-2005  christos branches: 1.32.4; 1.32.8; 1.32.14; 1.32.16;
merge ktrace-lwp.
 1.31 28-Jul-2005  christos Don't use a global variable to indicate that we are stge1023. Use an sc member.
Pointed out by thorpej.
 1.30 25-Jul-2005  kleink Add missing brace to previous.
 1.29 25-Jul-2005  christos PR/29925: Mihai CHELARU: Fix for stge 1023.
 1.28 25-Jun-2005  bouyer branches: 1.28.2;
Write the station address using 8-bits writes instead of 16-bits.
This is what the linux driver does, and makes the DGE-550T work without the
STGE_CU_BUG hack. So remove the STGE_CU_BUG hack.
Set bit 0x0020 in STGE_DebugCtrl too, the linux driver does it (the comments
note this as a workaround, without more details. This doesn't seem to make
things worse).
Also initialize STGE_RxDMABurstThresh and STGE_RxDMAUrgentThresh, using
values from the linux driver.

Approved by Jason Thorpe.
 1.27 16-May-2005  bouyer Fix some big-endian issues. stge(4) now works on sparc64 with hardware
checksums.
 1.26 13-May-2005  wiz Fix typo reported by Brad at comstyle com.
 1.25 02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.24 27-Feb-2005  perry branches: 1.24.2;
nuke trailing whitespace
 1.23 20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition
 1.22 30-Oct-2004  thorpej branches: 1.22.4; 1.22.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.21 02-Oct-2004  wiz Fix typo reported by Alexander Yurchenko in private mail.
 1.20 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.19 01-Mar-2003  mjacob branches: 1.19.2; 1.19.6;
Argh. Commited the wrong file.
 1.18 01-Mar-2003  mjacob Fix RFD_TCI macro.
 1.17 10-Feb-2003  christos Centralize the interrupt bits for the 3 registers where they are being used.
 1.16 10-Feb-2003  christos make this compile again.
 1.15 10-Feb-2003  mjacob Add in h/w VLAN tag support.

Put in code that, if enabled, makes *my* copper Sundance TI cards work-
promiscuous mode is needed for this for now. The default is to have this
off until I or somebody figures out what is broken- I think it's stuff
with the Marvell PHY.
 1.14 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.13 21-Oct-2002  fair Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 13-Nov-2001  lukem add RCSID
 1.8 10-Oct-2001  mjacob The flow control registers are 16 bits wide, not 32.
 1.7 06-Oct-2001  thorpej Create the Tx DMA maps with a size large enough for a jumbo Ethernet
frame.
 1.6 30-Jul-2001  thorpej branches: 1.6.2; 1.6.4; 1.6.6;
Oops, make Rx interrupt deferral actually work.
 1.5 27-Jul-2001  thorpej Tell the MII layer to advertise PAUSE capability, and configure
the chip's PAUSE threshold.
 1.4 25-Jul-2001  thorpej Jumbo frames do not currently work (chip goes catatonic -- silicon bug?),
so don't set the capability.
 1.3 25-Jul-2001  thorpej Match the Antares Gigabit Ethernet.
 1.2 25-Jul-2001  thorpej Remove a debugging #define.
 1.1 25-Jul-2001  thorpej Driver for the Sundance Tech./Tamarack TC9021 Gigabit Ethernet
controller.
 1.6.6.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.6.4.7 29-Dec-2002  thorpej Sync with HEAD.
 1.6.4.6 11-Nov-2002  nathanw Catch up to -current
 1.6.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.6.4.4 14-Nov-2001  nathanw Catch up to -current.
 1.6.4.3 22-Oct-2001  nathanw Catch up to -current.
 1.6.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.6.4.1 30-Jul-2001  nathanw file if_stge.c was added on branch nathanw_sa on 2001-08-24 00:10:08 +0000
 1.6.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.2 03-Aug-2001  lukem update to -current
 1.6.2.1 30-Jul-2001  lukem file if_stge.c was added on branch kqueue on 2001-08-03 04:13:16 +0000
 1.19.6.3 05-Jul-2005  riz Pull up revision 1.28 (requested by bouyer in ticket #2062):
Write the station address using 8-bits writes instead of 16-bits.
This is what the linux driver does, and makes the DGE-550T work without the
STGE_CU_BUG hack. So remove the STGE_CU_BUG hack.
Set bit 0x0020 in STGE_DebugCtrl too, the linux driver does it (the comments
note this as a workaround, without more details. This doesn't seem to make
things worse).
Also initialize STGE_RxDMABurstThresh and STGE_RxDMAUrgentThresh, using
values from the linux driver.
Approved by Jason Thorpe.
 1.19.6.2 21-Jun-2005  riz Pull up revision 1.27 (requested by bouyer in ticket #2009):
Fix some big-endian issues. stge(4) now works on sparc64 with hardware
checksums.
 1.19.6.1 24-Jan-2005  he Pull up revision 1.22 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.19.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.19.2.4 19-Oct-2004  skrll Sync with HEAD
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.22.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.4.1 29-Apr-2005  kent sync with -current
 1.24.2.2 05-Jul-2005  tron Pull up revision 1.28 (requested by bouyer in ticket #548):
Write the station address using 8-bits writes instead of 16-bits.
This is what the linux driver does, and makes the DGE-550T work without the
STGE_CU_BUG hack. So remove the STGE_CU_BUG hack.
Set bit 0x0020 in STGE_DebugCtrl too, the linux driver does it (the comments
note this as a workaround, without more details. This doesn't seem to make
things worse).
Also initialize STGE_RxDMABurstThresh and STGE_RxDMAUrgentThresh, using
values from the linux driver.
Approved by Jason Thorpe.
 1.24.2.1 22-Jun-2005  tron Pull up revision 1.27 (requested by bouyer in ticket #477):
Fix some big-endian issues. stge(4) now works on sparc64 with hardware
checksums.
 1.28.2.8 24-Mar-2008  yamt sync with head.
 1.28.2.7 17-Mar-2008  yamt sync with head.
 1.28.2.6 11-Feb-2008  yamt sync with head.
 1.28.2.5 21-Jan-2008  yamt sync with head
 1.28.2.4 27-Oct-2007  yamt sync with head.
 1.28.2.3 03-Sep-2007  yamt sync with head.
 1.28.2.2 30-Dec-2006  yamt sync with head.
 1.28.2.1 21-Jun-2006  yamt sync with head.
 1.32.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.32.14.1 19-Jun-2006  chap Sync with head.
 1.32.8.1 26-Jun-2006  yamt sync with head.
 1.32.4.1 09-Sep-2006  rpaulo sync with head
 1.33.6.2 10-Dec-2006  yamt sync with head.
 1.33.6.1 22-Oct-2006  yamt sync with head
 1.33.4.1 18-Nov-2006  ad Sync with head.
 1.35.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.4.1 11-Jul-2007  mjf Sync with head.
 1.36.2.3 23-Oct-2007  ad Sync with head.
 1.36.2.2 09-Oct-2007  ad Sync with head.
 1.36.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.37.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.37.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.37.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.38.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.38.2.2 23-Mar-2008  matt sync with HEAD
 1.38.2.1 06-Nov-2007  matt sync with HEAD
 1.39.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.39.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.41.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.41.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.41.2.1 24-Mar-2008  keiichi sync with head.
 1.44.4.6 11-Aug-2010  yamt sync with head.
 1.44.4.5 11-Mar-2010  yamt sync with head
 1.44.4.4 16-Sep-2009  yamt sync with head
 1.44.4.3 20-Jun-2009  yamt sync with head
 1.44.4.2 16-May-2009  yamt sync with head
 1.44.4.1 16-May-2008  yamt sync with head.
 1.44.2.1 18-May-2008  yamt sync with head.
 1.45.14.2 23-Jul-2009  jym Sync with HEAD.
 1.45.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.49.4.3 21-Apr-2011  rmind sync with head
 1.49.4.2 05-Mar-2011  rmind sync with head
 1.49.4.1 30-May-2010  rmind sync with head
 1.49.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.53.8.1 18-Feb-2012  mrg merge to -current.
 1.53.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.53.4.2 30-Oct-2012  yamt sync with head
 1.53.4.1 17-Apr-2012  yamt sync with head
 1.55.2.3 03-Dec-2017  jdolecek update from HEAD
 1.55.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.2.1 23-Jun-2013  tls resync from head
 1.56.4.1 18-May-2014  rmind sync with head
 1.57.6.3 05-Feb-2017  skrll Sync with HEAD
 1.57.6.2 09-Jul-2016  skrll Sync with HEAD
 1.57.6.1 19-Mar-2016  skrll Sync with HEAD
 1.60.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.62.8.3 14-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1439):

sys/dev/sbus/sio16.c: revision 1.25
sys/dev/gpib/mt.c: revision 1.33
sys/arch/mvme68k/dev/wdsc.c: revision 1.33
sys/dev/gpib/ct.c: revision 1.31
sys/dev/isa/mcd.c: revision 1.119
sys/dev/pci/if_stge.c: revision 1.73
sys/dev/gpib/ppi.c: revision 1.25
sys/dev/pcmcia/if_tr_pcmcia.c: revision 1.29
sys/arch/amiga/dev/zssc.c: revision 1.46
sys/arch/mac68k/obio/iwm_fd.c: revision 1.57
sys/arch/amiga/dev/if_qn.c: revision 1.48
sys/dev/isa/tcic2_isa.c: revision 1.28
sys/dev/isa/uha_isa.c: revision 1.42
sys/dev/pci/neo.c: revision 1.55
sys/arch/next68k/dev/nextdisplay.c: revision 1.22
sys/dev/isa/if_iy.c: revision 1.111

Add missing initialization of sc_dev.


Initialize sc_dev correctly to avoid null pointer dereference when
bus_space_map() failed.


Add missing initialization of sc_dev.
 1.62.8.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.62.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.64.2.3 26-Jan-2019  pgoyette Sync with HEAD
 1.64.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.64.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.65.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.65.2.1 10-Jun-2019  christos Sync with HEAD
 1.70.2.3 25-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #476):

sys/dev/pci/if_stgereg.h: revision 1.6
sys/arch/amd64/conf/ALL: revision 1.124
sys/dev/mii/files.mii: revision 1.51
share/man/man4/vge.4: revision 1.8
share/man/man4/vge.4: revision 1.9
distrib/sets/lists/man/mi: revision 1.1656
sys/arch/i386/conf/ALL: revision 1.471
share/man/man4/mii.4: revision 1.28
sys/dev/pci/if_stge.c: revision 1.71
sys/dev/mii/ipgphy.c: revision 1.1
sys/dev/mii/ipgphy.c: revision 1.2
share/man/man4/Makefile: revision 1.684
sys/dev/mii/ipgphy.c: revision 1.3
sys/dev/mii/ipgphyreg.h: revision 1.1
sys/dev/mii/ipgphy.c: revision 1.4
sys/dev/mii/ipgphyreg.h: revision 1.2
sys/dev/mii/ipgphy.c: revision 1.5
sys/dev/mii/ipgphyreg.h: revision 1.3
sys/dev/DEVNAMES: revision 1.322
sys/arch/i386/conf/GENERIC: revision 1.1211
sys/arch/amd64/conf/GENERIC: revision 1.537
share/man/man4/ipgphy.4: revision 1.1
share/man/man4/ipgphy.4: revision 1.2

Add support IC Plus IP1000* PHYs. PR/kern 42314 first reported by

Tomokazu HARADA and patch provided by Andrius V.

New sentence, new line.
Fix date. Add RCS Id.

KNF. No functional change.

STGE_PhyCtrl is not PHY register but MAC register, so use ukphy_status()
for IP1000A device.

- Use auto-negotiation when forcing 1000BASE-T.
- Add XXX comment for strange pause setting code. I suspect this is wrong.
- On my environments, 1000BASE-T half duplex doesn't work, so we might remove
IFM_1000T_HDX from this device in future.
- Define IPGPHY_SCR's address.
- Whitespace fix.

Add missing NetBSD RCS Id. Reported by Andrius V.
 1.70.2.2 14-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #425):

sys/dev/sbus/sio16.c: revision 1.25
sys/dev/gpib/mt.c: revision 1.33
sys/arch/mvme68k/dev/wdsc.c: revision 1.33
sys/dev/gpib/ct.c: revision 1.31
sys/dev/isa/mcd.c: revision 1.119
sys/dev/pci/if_stge.c: revision 1.73
sys/dev/gpib/ppi.c: revision 1.25
sys/dev/pcmcia/if_tr_pcmcia.c: revision 1.29
sys/arch/amiga/dev/zssc.c: revision 1.46
sys/arch/mac68k/obio/iwm_fd.c: revision 1.57
sys/arch/amiga/dev/if_qn.c: revision 1.48
sys/dev/isa/tcic2_isa.c: revision 1.28
sys/dev/isa/uha_isa.c: revision 1.42
sys/dev/pci/neo.c: revision 1.55
sys/arch/next68k/dev/nextdisplay.c: revision 1.22
sys/dev/isa/if_iy.c: revision 1.111

Add missing initialization of sc_dev.

Initialize sc_dev correctly to avoid null pointer dereference when
bus_space_map() failed.

Add missing initialization of sc_dev.
 1.70.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.75.2.2 29-Feb-2020  ad Sync with head.
 1.75.2.1 17-Jan-2020  ad Sync with head.
 1.92.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 14-Jan-2020  msaitoh No functional change:

- Move some definitions from if_stgereg.h to if_stge.c again because those are
not chip (registers or descriptors) definitions.
- Use proplib to pass information that loading DSP code is required when
PHY reset.
 1.8 09-Jan-2020  msaitoh Reduce diff against OpenBSD. No functional change.

- USE CSR_{READ,WRITE}_*() macro.
- Move some macros from if_stge.c to if_stgereg.h
 1.7 26-Dec-2019  msaitoh branches: 1.7.2;
Fix address of STGE_MaxFrameSize. Same as other OSes.
 1.6 07-Oct-2019  msaitoh Add support IC Plus IP1000* PHYs. PR/kern 42314 first reported by
Tomokazu HARADA and patch provided by Andrius V.
 1.5 28-Apr-2008  martin branches: 1.5.80; 1.5.88; 1.5.94;
Remove clause 3 and 4 from TNF licenses
 1.4 25-Dec-2007  perry branches: 1.4.6; 1.4.8; 1.4.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.3 10-Feb-2003  christos branches: 1.3.18; 1.3.76; 1.3.82; 1.3.86; 1.3.90;
Centralize the interrupt bits for the 3 registers where they are being used.
 1.2 08-Nov-2002  enami s/than than/than/.
 1.1 25-Jul-2001  thorpej branches: 1.1.2; 1.1.4;
Driver for the Sundance Tech./Tamarack TC9021 Gigabit Ethernet
controller.
 1.1.4.3 11-Nov-2002  nathanw Catch up to -current
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 25-Jul-2001  nathanw file if_stgereg.h was added on branch nathanw_sa on 2001-08-24 00:10:08 +0000
 1.1.2.2 03-Aug-2001  lukem update to -current
 1.1.2.1 25-Jul-2001  lukem file if_stgereg.h was added on branch kqueue on 2001-08-03 04:13:16 +0000
 1.3.90.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.86.1 26-Dec-2007  ad Sync with head.
 1.3.82.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.76.1 09-Jan-2008  matt sync with HEAD
 1.3.18.1 21-Jan-2008  yamt sync with head
 1.4.10.1 16-May-2008  yamt sync with head.
 1.4.8.1 18-May-2008  yamt sync with head.
 1.4.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.94.2 21-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #627):

sys/dev/pci/if_stgereg.h: revision 1.7

Fix address of STGE_MaxFrameSize. Same as other OSes.
 1.5.94.1 25-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #476):

sys/dev/pci/if_stgereg.h: revision 1.6
sys/arch/amd64/conf/ALL: revision 1.124
sys/dev/mii/files.mii: revision 1.51
share/man/man4/vge.4: revision 1.8
share/man/man4/vge.4: revision 1.9
distrib/sets/lists/man/mi: revision 1.1656
sys/arch/i386/conf/ALL: revision 1.471
share/man/man4/mii.4: revision 1.28
sys/dev/pci/if_stge.c: revision 1.71
sys/dev/mii/ipgphy.c: revision 1.1
sys/dev/mii/ipgphy.c: revision 1.2
share/man/man4/Makefile: revision 1.684
sys/dev/mii/ipgphy.c: revision 1.3
sys/dev/mii/ipgphyreg.h: revision 1.1
sys/dev/mii/ipgphy.c: revision 1.4
sys/dev/mii/ipgphyreg.h: revision 1.2
sys/dev/mii/ipgphy.c: revision 1.5
sys/dev/mii/ipgphyreg.h: revision 1.3
sys/dev/DEVNAMES: revision 1.322
sys/arch/i386/conf/GENERIC: revision 1.1211
sys/arch/amd64/conf/GENERIC: revision 1.537
share/man/man4/ipgphy.4: revision 1.1
share/man/man4/ipgphy.4: revision 1.2

Add support IC Plus IP1000* PHYs. PR/kern 42314 first reported by

Tomokazu HARADA and patch provided by Andrius V.

New sentence, new line.
Fix date. Add RCS Id.

KNF. No functional change.

STGE_PhyCtrl is not PHY register but MAC register, so use ukphy_status()
for IP1000A device.

- Use auto-negotiation when forcing 1000BASE-T.
- Add XXX comment for strange pause setting code. I suspect this is wrong.
- On my environments, 1000BASE-T half duplex doesn't work, so we might remove
IFM_1000T_HDX from this device in future.
- Define IPGPHY_SCR's address.
- Whitespace fix.

Add missing NetBSD RCS Id. Reported by Andrius V.
 1.5.88.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.80.1 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1496):

sys/dev/pci/if_stgereg.h: revision 1.7

Fix address of STGE_MaxFrameSize. Same as other OSes.
 1.7.2.1 17-Jan-2020  ad Sync with head.
 1.125 05-Nov-2024  andvar s/UCP/UDP/ in comments.
 1.124 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.123 23-May-2022  rin branches: 1.123.10;
Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.122 10-Nov-2021  msaitoh s/desciptor/descriptor/ in comment.
 1.121 05-Jun-2021  thorpej Back out the following changes:

http://mail-index.netbsd.org/source-changes/2020/02/29/msg114581.html
http://mail-index.netbsd.org/source-changes/2020/02/29/msg114583.html

They have reportedly caused some issues with link detection, and will
be revisited later.
 1.120 05-Mar-2020  msaitoh branches: 1.120.8; 1.120.12;
Add support for Farallon PN9000SX from FreeBSD.
 1.119 05-Mar-2020  msaitoh No functional change:

- Remove extra semicolon
- Remove extra whitespace
 1.118 05-Mar-2020  msaitoh No functional change:

- Fix typo in comment.
- Whitespace
 1.117 05-Mar-2020  msaitoh s/Intialize/Initialize/ in comment.
 1.116 03-Mar-2020  msaitoh Don't clear CFI and priority bit to pass them to the upper layer.
 1.115 29-Feb-2020  thorpej - Change the definition and usage of TI_HOSTADDR() to allow for 64-bit
DMA addresses. Modeled after similar usage in the bge(4) driver (the
chips supported by bge(4) are descendants of those supported by ti(4)).
- Use the 64-bit PCI DMA tag if available, otherwise we're allocating (and
using) bounce buffers needlessly.
 1.114 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.113 10-Nov-2019  chs branches: 1.113.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.112 09-Jul-2019  msaitoh branches: 1.112.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.111 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.110 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.109 23-May-2019  msaitoh -No functional change:
- Simplify struct ethercom's pointer near ETHER_FIRST_MULTI().
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.108 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.107 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.106 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.105 18-Jul-2018  sevan Be consistent among ethernet drivers on the convention for printing ethernet
addresses.

NFC
 1.104 26-Jun-2018  msaitoh branches: 1.104.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.103 08-Feb-2018  dholland branches: 1.103.2;
Typos.
 1.102 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.101 15-Dec-2016  ozaki-r branches: 1.101.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.100 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.99 14-Jul-2016  msaitoh branches: 1.99.2;
- Use aprint_normal_dev() instead of aprint_error_dev() when printing
Ethernet address.
- Use aprint() more.
- KNF.
 1.98 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.97 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.96 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.95 25-Jul-2015  maxv Memory leak. Same as r1.93. I don't know why Brainy didn't detect it
earlier; or perhaps I forgot to report it.

Found by Brainy.
 1.94 27-Apr-2015  christos fix mbuf leak on failure (Brainy)
 1.93 29-Mar-2014  christos branches: 1.93.4; 1.93.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.92 27-Feb-2014  joerg Remove impossible checks.
 1.91 27-Oct-2012  chs branches: 1.91.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.90 13-Nov-2010  uebayasi branches: 1.90.8; 1.90.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.89 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.88 19-Jan-2010  pooka branches: 1.88.2; 1.88.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.87 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.86 27-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only.
 1.85 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.84 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.83 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.82 07-Nov-2008  dyoung branches: 1.82.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.81 10-Apr-2008  cegger branches: 1.81.4; 1.81.10; 1.81.12;
use aprint_*_dev and device_xname
 1.80 07-Feb-2008  dyoung branches: 1.80.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.79 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.78 19-Oct-2007  ad branches: 1.78.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.77 07-Sep-2007  tnn branches: 1.77.4;
First part of ti(4) overhaul:
- Sanitise macros
- Apply KNF
Should have no functional changes.
 1.76 01-Sep-2007  dyoung Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.75 29-Aug-2007  dyoung Constify: LLADDR() -> CLLADDR().
 1.74 04-Mar-2007  christos branches: 1.74.2; 1.74.10; 1.74.14; 1.74.16;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.73 16-Nov-2006  christos branches: 1.73.4;
__unused removal on arguments; approved by core.
 1.72 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.71 07-Sep-2006  dogcow branches: 1.71.2; 1.71.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.70 28-Mar-2006  thorpej Use device_unit().
 1.69 11-Dec-2005  christos branches: 1.69.4; 1.69.6; 1.69.8; 1.69.10; 1.69.12;
merge ktrace-lwp.
 1.68 30-May-2005  christos branches: 1.68.2;
- const poisoning
- avoid variable shadowing.
 1.67 02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.66 27-Feb-2005  perry nuke trailing whitespace
 1.65 20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition

also restructure and simplify input VLAN ID code handling somewhat, to not use
local have_vlan/vlan_tag variables, and use the appropriate cur_rx condition
on the one place where it's needed
 1.64 04-Feb-2005  perry de-__P
 1.63 29-Sep-2004  yamt branches: 1.63.4; 1.63.6;
- mbuf external storage is of (caddr_t), not (caddr_t *).
- remove a needless cast.
 1.62 21-Sep-2004  yamt introduce M_EXT_RW to allow mbuf external storage R/W.
discussed on tech-net@.
 1.61 27-Jul-2004  he Make the SSLOTS, MSLOTS and JSLOTS tunable (redefineable).
Bump the default values for these to the values used by FreeBSD,
and also adjust ti_init_rx_ring_jumbo() to use the same constant
that FreeBSD uses. Yes, this consumes more kernel memory.

The effect of this is that you can use jumbo frames in a back-to-back
setup with TCP windows up to about 250KB and get ~930Mbit/s throughput,
while we were earlier limited to around 3-400Mbit/s, and trying to push
above that mark by widening the TCP window caused
ti0: jumbo buffer allocation failed
messages to be logged and a corresponding stall in the traffic.
 1.60 18-Mar-2004  bouyer branches: 1.60.2;
Use the bus_space_*_stream_* methods to access the chip's registers.
As we turn the chip to big-endian mode on big-endian systems, we should
never byte-swap the data read/written from/to registers. Tested on sparc64.
Finally fix kern/13341 by Jason R. Thorpe (really, the hard work of putting
bus_dmamap_sync() calls at the right places has been done my Jason mid-2001 :)
 1.59 18-Mar-2004  bouyer cur_rx->ti_vlan_tag holds the 802.1q VLAN tag and the 802.1p priority.
Trimm the priority, as the upper layers won't do it and will drop the packet
if priority is not 0.
While there, print the revision in the "unsupported chip revision" printf.
 1.58 24-Feb-2004  wiz becuase -> because. From Peter Postma.
 1.57 09-Feb-2003  mjacob branches: 1.57.2;
Add missing binding of VLAN tag to received packet.
 1.56 31-Jan-2003  thorpej Change ext_size to a size_t, and update the signature of ext_free.
 1.55 21-Jan-2003  itojun vlan tagging mistake during m_tag transition
 1.54 20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.53 17-Jan-2003  itojun switch from kame-based m_aux mbuf auxiliary data, to openbsd m_tag
implementation. it will simplify porting across *bsd (such as kame/altq),
and make us more synchronized. from Joel Wilsson
 1.52 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.51 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.50 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.49 16-Jul-2002  bouyer Add missing BUS_DMA_NOWAIT to bus_dmamap_load_mbuf() calls. Should fix
port-alpha/17615.
 1.48 01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.47 02-May-2002  thorpej branches: 1.47.2; 1.47.4;
Change the semantics of mbuf external storage "ext_free" routines
so that they're more useful for arbitrary types of external storage:

* Add an "mbuf *" argument to (*ext_free)(). If non-NULL, (*ext_free)()
is expected to free the mbuf itself. This allows (*ext_free)() to use
the mbuf for bookkeeping (e.g. deferring the work to a helper thread).
If the "mbuf *" argument is NULL, we are assumed to be in a context
which is safe for performing the destructor operation *now*.
* Adjust MEXTREMOVE() and MFREE() routines for above change.
* Update "ade" and "ti" drivers for new semantics.
 1.46 28-Apr-2002  thorpej Use MEXTADD() rather than open-coding it.
 1.45 20-Mar-2002  eeh Use bus_space_vaddr() correctly. (Why use bus_space_vaddr() at all?)
 1.44 26-Nov-2001  itojun make it compile without INET
 1.43 13-Nov-2001  lukem add RCSID
 1.42 20-Aug-2001  wiz precede, not preceed.
 1.41 14-Aug-2001  mrg add (u_long) casts for sparc64.
 1.40 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.39 07-Jul-2001  thorpej branches: 1.39.2;
bzero -> memset
 1.38 07-Jul-2001  thorpej bcopy -> memcpy, strcpy
 1.37 05-Jul-2001  thorpej For product names that include the media in the name, don't bother
saying "Gigabit".
 1.36 30-Jun-2001  bjh21 IFM_1000_TX -> IFM_1000_T, as (breifly) discussed on tech-net.
 1.35 30-Jun-2001  thorpej Sync the Tx descriptors pre- and post- on the Tigon 2.
 1.34 30-Jun-2001  thorpej When we're done setting up the General Information Block, sync it.
Sync the NIC-maintained stats structure as appropriate, as well.
 1.33 30-Jun-2001  thorpej Use macros (like those in every other network driver I have written)
to compute the offset of a structure in the DMA'd control data, and
the DMA address of that structure.
 1.32 30-Jun-2001  thorpej Split the tx-end-of-frame routine into Tigon 1 and Tigon 2 verions,
for the same reason we split the tx encap routine.
 1.31 30-Jun-2001  thorpej Split the transmit encap routine into two versions: one for the Tigon 1
and another for the Tigon 2. This eliminates a conditional in the
loop around the DMA segments, and will make further cleanup easier.
 1.30 30-Jun-2001  thorpej Move the `ti_tx_ring_nic' pointer out of the ring-data structure
and into the softc. Garbage-collect the `ti_cmd_ring' pointer,
since bus_space is properly used to access the command ring.
 1.29 30-Jun-2001  thorpej When a transmit is complete, sync (and unload!!) the DMA map used
for the packet. When setting up a packet for transmit, sync the
DMA map being used.
 1.28 30-Jun-2001  thorpej Move the Tigon/Tigon2 firmware, version 12.4.13+wpaul, to a
more appropriate location.
 1.27 29-Jun-2001  thorpej Correct spelling of media in the product names.
 1.26 27-Jun-2001  bouyer When setting/changing an address, no need to call ti_init() if the interface
is already up.
Especially this allow netatalk to start properly on a ti interface.
 1.25 12-Jun-2001  wiz receive, not recieve
 1.24 07-Jun-2001  bouyer Set TI_OPMODE_1_DMA_ACTIVE only if hardware assisted checksum isn't used
(FreeBSD does it this way). My Tigon II works with hardware assisted checksum
now.
 1.23 03-Jun-2001  thorpej In ti_init2(), use a simpler, more obvious, and correct MTU
calculation to give the firmware.
 1.22 03-Jun-2001  thorpej Replace a bunch of home-grown Ethernet related constants with
ones defined in <net/if_ether.h>
 1.21 02-Jun-2001  thorpej Implement support for IP/TCP/UDP checksum offloading provided by
network interfaces. This works by pre-computing the pseudo-header
checksum and caching it, delaying the actual checksum to ip_output()
if the hardware cannot perform the sum for us. In-bound checksums
can either be fully-checked by hardware, or summed up for final
verification by software. This method was modeled after how this
is done in FreeBSD, although the code is significantly different in
most places.

We don't delay checksums for IPv6/TCP, but we do take advantage of the
cached pseudo-header checksum.

Note: hardware-assisted checksumming defaults to "off". It is
enabled with ifconfig(8). See the manual page for details.

Implement hardware-assisted checksumming on the DP83820 Gigabit Ethernet,
3c90xB/3c90xC 10/100 Ethernet, and Alteon Tigon/Tigon2 Gigabit Ethernet.
 1.20 29-Jan-2001  enami branches: 1.20.2;
Handle allmulti case correctly as a NetBSD network driver;
if we are requested range of multicast address or too many multicast address,
program multicast filter to receive all multicast address. And set/clear
IFF_ALLMULTI flag properly.
 1.19 18-Jan-2001  jdolecek constify
 1.18 14-Jan-2001  thorpej Use splnet() to block network interrupts, not splimp().
 1.17 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.16 14-Dec-2000  thorpej ALTQ'ify.
 1.15 17-Nov-2000  bouyer Pull up FreeBSD changes:
1.39:
Have if_ti stop "hiding" the softc pointer in the buffer region. Rather,
use the available void * passed to the free routine and pass the softc
pointer through there.
1.33:
Add support for the Netgear GA620T copper gigabit card.
1.32:
Tweak probe message so that 1000baseSX and 1000baseT cards are
explicitly identified.
1.31:
Update the Tigon driver to support 1000baseTX gigE over copper AceNIC
cards. This basically involves switching to the 12.4.13 firmware, plus
a couple of minor tweaks to the driver.

NetBSD changes:
get rid of ti_inuse, the mbuf ref counting code should call ti_free() when
needed.
Use hardware 802.1q support.
 1.14 15-Nov-2000  thorpej Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.13 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.12 12-Nov-2000  bouyer - use jumbo rx if mtu is too big to fit in one mbuf, not when larger than
ETHERMTU.
- add support for ETHERCAP_VLAN_MTU.
 1.11 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.10 24-Sep-2000  martin Add calls to ether_addmulti and ether_delmulti. This code looks a bit
different than other drivers due to the way ti_setmulti manages the
filters. Patch from Keijiro Ehara.
 1.9 24-Sep-2000  jdolecek use new generic bootverbose instead of local definition
 1.8 30-Mar-2000  augustss branches: 1.8.4;
Remove register declarations.
 1.7 17-Mar-2000  bouyer Fix botched merge in previous.
 1.6 17-Mar-2000  bouyer - remove leftovers of FreeBSD code in #if 0/#endif
- fix a bug in ti_encap() where a NULL pointer could be used if we run out
of tx descriptors (return ENOMEM instead, and let the caller assert OACTIVE)
- sync boot messages with NetBSD's pci standart (print ti_name and irq
line)
- add a shutdown hook to stop the board, so that the board will not DMA at
random places while we're rebooting
- convert all but TIGON 1 transmit descriptors to use bus_space
(this last one isn't trivial to get rigth and I don't have the hardware to
test)
- If we can't map the mem space linar, retry to map it nolinear. Punt if
we couldn't map the mem space linear and we found a Tigon 1 chip.

With these changes a Tigon 2 board (netgear BA620 at last) can be used in
my DS20.
 1.5 06-Mar-2000  thorpej Set ifp->if_baudrate as appropriate.
 1.4 25-Jan-2000  thorpej "i/o" -> "memory"
 1.3 25-Jan-2000  thorpej IFM_1000_FX -> IFM_1000_SX
 1.2 06-Oct-1999  drochner branches: 1.2.2;
1. include headers for NS support
2. pull in a fix from FreeBSD:
revision 1.18
date: 1999/09/17 18:04:14; author: wpaul; state: Exp; lines: +3 -3
Remember to account for ETHER_ALIGN when setting the maxmimum packet
length for mini receive ring. The max length was MHLEN, however the mbufs
are actually shortened to MHLEN - ETHER_ALIGN to force payload alignment.
 1.1 01-Sep-1999  drochner branches: 1.1.2; 1.1.4;
quick 'n dirty port of FreeBSD's Alteon Gigabit Ethernet driver.
todo:
-IPv6
-clean up jumbo buffer allocation - NetBSD provides an opaque argument
to the free function, thus doesn't need the hack done here
-deal correctly with the mapping of the shared memory
 1.1.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.6 06-Jul-2000  he Pull up revision 1.3 (requested by he):
Make the ti(4) driver compile again after the wi(4) related
pullups of if_media.h changed IFM_1000_FX to IFM_1000_SX.
 1.1.2.5 01-Jun-2000  he Apply patch (requested by bouyer):
Fix compile error.
 1.1.2.4 30-Apr-2000  he Pull up revisions 1.6-1.7 (via patch, requested by bouyer):
Fix bug which could result in a panic. Add a shutdown hook to
stop the board to avoid memory corruption on reboot. Use bus_space
for TIGON 2 chips, so that they will work even if we can't map
the memory space linearly (e.g. on alpha).
 1.1.2.3 06-Oct-1999  he Pull up revision 1.2 (requested by drochner):
Make it compile in GENERIC by including NS headers.
Pull in fix from FreeBSD.
 1.1.2.2 05-Oct-1999  he Pull up revision 1.1+patch (new, requested by drochner):
Back-port of driver for Alteon Gigabit Ethernet driver, originally
from FreeBSD.
 1.1.2.1 01-Sep-1999  he file if_ti.c was added on branch netbsd-1-4 on 1999-10-05 22:08:51 +0000
 1.2.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.4 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.4.4 13-Nov-2001  he Pull up revision 1.26 (requested by bouyer):
When setting/changing an address, do not call ti_init() if the
interface is already up. This allows netatalk to start when
using this interface.
 1.8.4.3 13-Mar-2001  he Pull up revision 1.20 (requested by tsutsui):
Handle allmulti case correctly as a NetBSD network driver;
if we are requested range of multicast address or too many
multicast address, program multicast filter to receive all
multicast address. And set/clear IFF_ALLMULTI flag properly.
 1.8.4.2 31-Dec-2000  jhawk Pull up revision 1.12, 1.15 via patch (requested by bouyer):
For the ti driver, add hardware 802.1Q support, update firmware
to 12.4.13+wpaul, and support the Netgear GA620T copper gigabit card,
and the Alteon ACEnic 100baseSX and 1000baseT gigabit cards. Various
small changes from FreeBSD.
 1.8.4.1 26-Sep-2000  martin Pullup revision 1.10 (approved by thorpej).

Fix multicast filters. Patch from Keijiro Ehara.
 1.20.2.9 17-Jan-2003  thorpej Sync with HEAD.
 1.20.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.20.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.20.2.6 20-Jun-2002  nathanw Catch up to -current.
 1.20.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.20.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.20.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.20.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.20.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.39.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.39.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.39.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.39.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.39.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.39.2.1 03-Aug-2001  lukem update to -current
 1.47.4.3 26-May-2004  tron Pull up revision 1.60 (requested by bouyer in ticket #1698):
Use the bus_space_*_stream_* methods to access the chip's registers.
As we turn the chip to big-endian mode on big-endian systems, we should
never byte-swap the data read/written from/to registers. Tested on sparc64.
Finally fix kern/13341 by Jason R. Thorpe (really, the hard work of putting
bus_dmamap_sync() calls at the right places has been done my Jason mid-2001 :)
 1.47.4.2 26-May-2004  tron Pull up revision 1.59 (requested by bouyer in ticket #1697):
cur_rx->ti_vlan_tag holds the 802.1q VLAN tag and the 802.1p priority.
Trimm the priority, as the upper layers won't do it and will drop the packet
if priority is not 0.
While there, print the revision in the "unsupported chip revision" printf.
 1.47.4.1 18-Jul-2002  lukem Pull up revision 1.49 (requested by thorpej in ticket #513):
Add missing BUS_DMA_NOWAIT to bus_dmamap_load_mbuf() calls. Should fix
port-alpha/17615.
 1.47.2.2 20-Jul-2002  gehenna catch up with -current.
 1.47.2.1 20-Jun-2002  gehenna catch up with -current.
 1.57.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.57.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.57.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.57.2.5 19-Oct-2004  skrll Sync with HEAD
 1.57.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.57.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.57.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.57.2.1 03-Aug-2004  skrll Sync with HEAD
 1.60.2.1 28-Jul-2004  tron Pull up revision 1.61 (requested by he in ticket #719):
Make the SSLOTS, MSLOTS and JSLOTS tunable (redefineable).
Bump the default values for these to the values used by FreeBSD,
and also adjust ti_init_rx_ring_jumbo() to use the same constant
that FreeBSD uses. Yes, this consumes more kernel memory.
The effect of this is that you can use jumbo frames in a back-to-back
setup with TCP windows up to about 250KB and get ~930Mbit/s throughput,
while we were earlier limited to around 3-400Mbit/s, and trying to push
above that mark by widening the TCP window caused
ti0: jumbo buffer allocation failed
messages to be logged and a corresponding stall in the traffic.
 1.63.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.63.6.1 12-Feb-2005  yamt sync with head.
 1.63.4.1 29-Apr-2005  kent sync with -current
 1.68.2.6 11-Feb-2008  yamt sync with head.
 1.68.2.5 15-Nov-2007  yamt sync with head.
 1.68.2.4 27-Oct-2007  yamt sync with head.
 1.68.2.3 03-Sep-2007  yamt sync with head.
 1.68.2.2 30-Dec-2006  yamt sync with head.
 1.68.2.1 21-Jun-2006  yamt sync with head.
 1.69.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.69.10.1 19-Apr-2006  elad sync with head.
 1.69.8.2 14-Sep-2006  yamt sync with head.
 1.69.8.1 01-Apr-2006  yamt sync with head.
 1.69.6.1 22-Apr-2006  simonb Sync with head.
 1.69.4.1 09-Sep-2006  rpaulo sync with head
 1.71.4.2 10-Dec-2006  yamt sync with head.
 1.71.4.1 22-Oct-2006  yamt sync with head
 1.71.2.1 18-Nov-2006  ad Sync with head.
 1.73.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.74.16.3 23-Mar-2008  matt sync with HEAD
 1.74.16.2 08-Nov-2007  matt sync with -HEAD
 1.74.16.1 06-Nov-2007  matt sync with HEAD
 1.74.14.4 11-Nov-2007  joerg Sync with HEAD.
 1.74.14.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.74.14.2 02-Oct-2007  joerg Sync with HEAD.
 1.74.14.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.74.10.2 10-Sep-2007  skrll Sync with HEAD.
 1.74.10.1 03-Sep-2007  skrll Sync with HEAD.
 1.74.2.3 23-Oct-2007  ad Sync with head.
 1.74.2.2 09-Oct-2007  ad Sync with head.
 1.74.2.1 01-Sep-2007  ad Update for pool_cache API changes.
 1.77.4.2 13-Nov-2007  bouyer Sync with HEAD
 1.77.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.78.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.78.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.80.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.80.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.81.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.81.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.81.4.4 11-Aug-2010  yamt sync with head.
 1.81.4.3 11-Mar-2010  yamt sync with head
 1.81.4.2 16-May-2009  yamt sync with head
 1.81.4.1 04-May-2009  yamt sync with head.
 1.82.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.88.4.2 05-Mar-2011  rmind sync with head
 1.88.4.1 30-May-2010  rmind sync with head
 1.88.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.90.18.3 03-Dec-2017  jdolecek update from HEAD
 1.90.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.90.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.90.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.90.8.1 30-Oct-2012  yamt sync with head
 1.91.2.1 18-May-2014  rmind sync with head
 1.93.6.6 05-Feb-2017  skrll Sync with HEAD
 1.93.6.5 05-Oct-2016  skrll Sync with HEAD
 1.93.6.4 09-Jul-2016  skrll Sync with HEAD
 1.93.6.3 19-Mar-2016  skrll Sync with HEAD
 1.93.6.2 22-Sep-2015  skrll Sync with HEAD
 1.93.6.1 06-Jun-2015  skrll Sync with HEAD
 1.93.4.1 04-Aug-2015  snj Pull up following revision(s) (requested by maxv in ticket #913):
sys/dev/pci/if_ti.c: revisions 1.94, 1.95
fix mbuf leak on failure (Brainy)
--
Memory leak. Same as r1.93. I don't know why Brainy didn't detect it
earlier; or perhaps I forgot to report it.
Found by Brainy.
 1.99.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.101.8.3 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1590:

sys/dev/pci/if_ti.c 1.103, 1.106, 1.108,
1.116-1.120 via patch
sys/dev/pci/if_tireg.h 1.26

- Use pci_intr_establish_xname()
- Don't clear CFI and priority bit to pass them to the upper layer.
- Add support for Farallon PN9000SX from FreeBSD.
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- Fix typo in comment.
- Style fix.
 1.101.8.2 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.101.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.103.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.103.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.104.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.104.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.104.2.1 10-Jun-2019  christos Sync with HEAD
 1.112.2.1 15-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1014:

sys/dev/pci/if_ti.c 1.116-1.120 via patch
sys/dev/pci/if_tireg.h 1.26

- Don't clear CFI and priority bit to pass them to the upper layer.
- Add support for Farallon PN9000SX from FreeBSD.
- Fix typo in comment.
- Style fix.
 1.113.2.1 29-Feb-2020  ad Sync with head.
 1.120.12.1 06-Jun-2021  cjep sync with head
 1.120.8.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.123.10.1 02-Aug-2025  perseant Sync with HEAD
 1.32 21-Feb-2023  andvar s/jumo/jumbo/ in comments.
 1.31 05-Jun-2021  thorpej Back out the following changes:

http://mail-index.netbsd.org/source-changes/2020/02/29/msg114581.html
http://mail-index.netbsd.org/source-changes/2020/02/29/msg114583.html

They have reportedly caused some issues with link detection, and will
be revisited later.
 1.30 02-Apr-2020  msaitoh branches: 1.30.8; 1.30.12;
No functional change:
- s/u_int64_t/uint64_t/
- s/alignes/aligns/
- indent, tabify
 1.29 02-Apr-2020  msaitoh s/impliment/implement/ in comment.
 1.28 05-Mar-2020  msaitoh u_int*_t -> unit*_t. No funcitonal change.
 1.27 05-Mar-2020  msaitoh miscelaneous -> miscellaneous in comment.
 1.26 05-Mar-2020  msaitoh No functional change:

- Fix typo in comment.
- Whitespace
 1.25 29-Feb-2020  thorpej G/C the never-used version of ti_hostaddr that can't possibly be correct.
 1.24 29-Feb-2020  thorpej - Change the definition and usage of TI_HOSTADDR() to allow for 64-bit
DMA addresses. Modeled after similar usage in the bge(4) driver (the
chips supported by bge(4) are descendants of those supported by ti(4)).
- Use the 64-bit PCI DMA tag if available, otherwise we're allocating (and
using) bounce buffers needlessly.
 1.23 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.22 13-Sep-2019  msaitoh branches: 1.22.2;
if_flags is neither int nor short. It's unsigned short.
 1.21 05-Mar-2019  msaitoh branches: 1.21.4;
Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.20 27-Oct-2012  chs branches: 1.20.30; 1.20.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.19 07-Sep-2007  tnn branches: 1.19.58; 1.19.68;
First part of ti(4) overhaul:
- Sanitise macros
- Apply KNF
Should have no functional changes.
 1.18 04-Mar-2007  christos branches: 1.18.2; 1.18.10; 1.18.14; 1.18.16;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 11-Dec-2005  christos branches: 1.17.26;
merge ktrace-lwp.
 1.16 30-May-2005  christos branches: 1.16.2;
- const poisoning
- avoid variable shadowing.
 1.15 27-Feb-2005  perry nuke trailing whitespace
 1.14 27-Jul-2004  he branches: 1.14.4; 1.14.6;
Make the SSLOTS, MSLOTS and JSLOTS tunable (redefineable).
Bump the default values for these to the values used by FreeBSD,
and also adjust ti_init_rx_ring_jumbo() to use the same constant
that FreeBSD uses. Yes, this consumes more kernel memory.

The effect of this is that you can use jumbo frames in a back-to-back
setup with TCP windows up to about 250KB and get ~930Mbit/s throughput,
while we were earlier limited to around 3-400Mbit/s, and trying to push
above that mark by widening the TCP window caused
ti0: jumbo buffer allocation failed
messages to be logged and a corresponding stall in the traffic.
 1.13 18-Mar-2004  bouyer branches: 1.13.2;
Use the bus_space_*_stream_* methods to access the chip's registers.
As we turn the chip to big-endian mode on big-endian systems, we should
never byte-swap the data read/written from/to registers. Tested on sparc64.
Finally fix kern/13341 by Jason R. Thorpe (really, the hard work of putting
bus_dmamap_sync() calls at the right places has been done my Jason mid-2001 :)
 1.12 14-May-2003  wiz branches: 1.12.2;
coaless -> coalesce.
 1.11 30-Jun-2001  bjh21 branches: 1.11.16;
IFM_1000_TX -> IFM_1000_T, as (breifly) discussed on tech-net.
 1.10 30-Jun-2001  thorpej Add macros to sync the various bits of the DMA'd control data.
 1.9 30-Jun-2001  thorpej Use macros (like those in every other network driver I have written)
to compute the offset of a structure in the DMA'd control data, and
the DMA address of that structure.
 1.8 30-Jun-2001  thorpej Split the tx-end-of-frame routine into Tigon 1 and Tigon 2 verions,
for the same reason we split the tx encap routine.
 1.7 30-Jun-2001  thorpej Split the transmit encap routine into two versions: one for the Tigon 1
and another for the Tigon 2. This eliminates a conditional in the
loop around the DMA segments, and will make further cleanup easier.
 1.6 30-Jun-2001  thorpej Move the `ti_tx_ring_nic' pointer out of the ring-data structure
and into the softc. Garbage-collect the `ti_cmd_ring' pointer,
since bus_space is properly used to access the command ring.
 1.5 03-Jun-2001  thorpej Replace a bunch of home-grown Ethernet related constants with
ones defined in <net/if_ether.h>
 1.4 15-May-2001  lukem delint: () protect some macro args
 1.3 17-Nov-2000  bouyer branches: 1.3.2;
Pull up FreeBSD changes:
1.39:
Have if_ti stop "hiding" the softc pointer in the buffer region. Rather,
use the available void * passed to the free routine and pass the softc
pointer through there.
1.33:
Add support for the Netgear GA620T copper gigabit card.
1.32:
Tweak probe message so that 1000baseSX and 1000baseT cards are
explicitly identified.
1.31:
Update the Tigon driver to support 1000baseTX gigE over copper AceNIC
cards. This basically involves switching to the 12.4.13 firmware, plus
a couple of minor tweaks to the driver.

NetBSD changes:
get rid of ti_inuse, the mbuf ref counting code should call ti_free() when
needed.
Use hardware 802.1q support.
 1.2 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.1 01-Sep-1999  drochner branches: 1.1.2; 1.1.4; 1.1.14;
quick 'n dirty port of FreeBSD's Alteon Gigabit Ethernet driver.
todo:
-IPv6
-clean up jumbo buffer allocation - NetBSD provides an opaque argument
to the free function, thus doesn't need the hack done here
-deal correctly with the mapping of the shared memory
 1.1.14.1 31-Dec-2000  jhawk Pull up revision 1.3 (requested by bouyer):
For the ti driver, add hardware 802.1Q support, update firmware
to 12.4.13+wpaul, and support the Netgear GA620T copper gigabit card,
and the Alteon ACEnic 100baseSX and 1000baseT gigabit cards. Various
small changes from FreeBSD.
 1.1.4.1 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.2 05-Oct-1999  he Pull up revision 1.1 (new, requested by drochner):
Back-port of driver for Alteon Gigabit Ethernet driver, originally
from FreeBSD.
 1.1.2.1 01-Sep-1999  he file if_tireg.h was added on branch netbsd-1-4 on 1999-10-05 22:06:48 +0000
 1.3.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.16.1 26-May-2004  tron Pull up revision 1.13 (requested by bouyer in ticket #1698):
Use the bus_space_*_stream_* methods to access the chip's registers.
As we turn the chip to big-endian mode on big-endian systems, we should
never byte-swap the data read/written from/to registers. Tested on sparc64.
Finally fix kern/13341 by Jason R. Thorpe (really, the hard work of putting
bus_dmamap_sync() calls at the right places has been done my Jason mid-2001 :)
 1.12.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.2.1 28-Jul-2004  tron Pull up revision 1.14 (requested by he in ticket #719):
Make the SSLOTS, MSLOTS and JSLOTS tunable (redefineable).
Bump the default values for these to the values used by FreeBSD,
and also adjust ti_init_rx_ring_jumbo() to use the same constant
that FreeBSD uses. Yes, this consumes more kernel memory.
The effect of this is that you can use jumbo frames in a back-to-back
setup with TCP windows up to about 250KB and get ~930Mbit/s throughput,
while we were earlier limited to around 3-400Mbit/s, and trying to push
above that mark by widening the TCP window caused
ti0: jumbo buffer allocation failed
messages to be logged and a corresponding stall in the traffic.
 1.14.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.4.1 29-Apr-2005  kent sync with -current
 1.16.2.2 27-Oct-2007  yamt sync with head.
 1.16.2.1 03-Sep-2007  yamt sync with head.
 1.17.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.16.1 06-Nov-2007  matt sync with HEAD
 1.18.14.1 02-Oct-2007  joerg Sync with HEAD.
 1.18.10.1 10-Sep-2007  skrll Sync with HEAD.
 1.18.2.1 09-Oct-2007  ad Sync with head.
 1.19.68.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.58.1 30-Oct-2012  yamt sync with head
 1.20.38.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.20.38.1 10-Jun-2019  christos Sync with HEAD
 1.20.30.1 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1590:

sys/dev/pci/if_ti.c 1.103, 1.106, 1.108,
1.116-1.120 via patch
sys/dev/pci/if_tireg.h 1.26

- Use pci_intr_establish_xname()
- Don't clear CFI and priority bit to pass them to the upper layer.
- Add support for Farallon PN9000SX from FreeBSD.
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- Fix typo in comment.
- Style fix.
 1.21.4.1 15-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1014:

sys/dev/pci/if_ti.c 1.116-1.120 via patch
sys/dev/pci/if_tireg.h 1.26

- Don't clear CFI and priority bit to pass them to the upper layer.
- Add support for Farallon PN9000SX from FreeBSD.
- Fix typo in comment.
- Style fix.
 1.22.2.1 29-Feb-2020  ad Sync with head.
 1.30.12.1 06-Jun-2021  cjep sync with head
 1.30.8.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.126 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.125 02-Sep-2022  thorpej Remove unnecessary inclusion of <net/netisr.h>.
 1.124 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.123 06-Sep-2021  andvar fix typos in word "segment" and two additional typos in if_tl.c.
 1.122 07-Jul-2020  msaitoh No functional change:

- u_int32_t -> uint32_t
- KNF.
 1.121 11-Jun-2020  thorpej Update for proplib(3) API changes.
 1.120 28-Feb-2020  msaitoh When a media change is requested, don't just all (*if_init)(). That's
needlessly disruptive and incompatible with future locking changes.
We can use ether_mediachange() instead.
 1.119 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.118 22-Dec-2019  thorpej branches: 1.118.2;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.117 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.116 28-May-2019  msaitoh branches: 1.116.2;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.115 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.114 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.113 24-Apr-2019  msaitoh Remove extra test of SIOCSIFMEDIA.
 1.112 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.111 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.110 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.109 26-Jun-2018  msaitoh branches: 1.109.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.108 22-Jun-2018  msaitoh It's not required to include net/bpfdesc.h. Remove it.
 1.107 23-May-2017  ozaki-r branches: 1.107.2; 1.107.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.
 1.106 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.105 07-Jul-2016  msaitoh branches: 1.105.2;
KNF. Remove extra spaces. No functional change.
 1.104 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.103 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.102 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.101 10-Aug-2014  tls branches: 1.101.4;
Merge tls-earlyentropy branch into HEAD.
 1.100 29-Mar-2014  christos branches: 1.100.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.99 30-Mar-2013  christos branches: 1.99.4;
remove trailing whitespace
 1.98 22-Jul-2012  matt branches: 1.98.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.97 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.96 13-Nov-2010  uebayasi branches: 1.96.8; 1.96.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.95 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.94 19-Jan-2010  pooka branches: 1.94.2; 1.94.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.93 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.92 05-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested Compaq Netelligent 10/100 TX.
 1.91 16-Nov-2008  tsutsui Fix tyop in #ifdef TLDEBUG part.
 1.90 04-Oct-2008  bouyer branches: 1.90.2;
Add missing splx(). Funny that it didn't cause issues ...
 1.89 01-Jun-2008  tsutsui branches: 1.89.4;
Split device_t/softc, with misc cosmetic changes.
 1.88 31-May-2008  tsutsui My Compaq Netelligent 10/100 TX has 24C02 (2kbit) serial EEPROM,
so pass 256 (bytes) rather than 512 to seeprom_bootstrap_read().
 1.87 22-May-2008  dyoung KNF.
 1.86 10-Apr-2008  cegger branches: 1.86.2; 1.86.4; 1.86.6;
use aprint_*_dev and device_xname
 1.85 19-Jan-2008  dyoung branches: 1.85.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.84 19-Oct-2007  ad branches: 1.84.2; 1.84.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.83 09-Jul-2007  ad branches: 1.83.6; 1.83.8; 1.83.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.82 04-Mar-2007  christos branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.81 25-Dec-2006  wiz branches: 1.81.2;
Spell "schedule" correctly. From Zafer Aydogan.
 1.80 24-Dec-2006  rumble Make this compile again when KASSERT is enabled.
 1.79 24-Dec-2006  rumble Revert the previous change and specify the appropriate page boundary to
bus_dmamap_create(9) via a proplib number entry.

Recommended by Izumi Tsutsui.
 1.78 23-Dec-2006  rumble The Set Engineering GIO board for sgimips (IP22) sits behind a special
bridge that precludes the ThunderLAN's DMA engine from performing segment
transfers across page boundaries. Add logic under #ifdef TL_SETENG_GFE to
split up these segment transfers appropriately.

It's unknown whether this issue could also affect the RX path, though no
problems have been observed yet.
 1.77 16-Nov-2006  christos branches: 1.77.2;
__unused removal on arguments; approved by core.
 1.76 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.75 07-Sep-2006  dogcow branches: 1.75.2; 1.75.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.74 07-Sep-2006  rumble Avoid a panic on adapter check interrupts: the 'tl_restart' callout expects
a pointer to struct ifnet, not tl_softc.
 1.73 30-Aug-2006  rumble Make this compile again when TLDEBUG is defined.
 1.72 24-Dec-2005  perry branches: 1.72.4; 1.72.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.71 11-Dec-2005  christos merge ktrace-lwp.
 1.70 30-May-2005  christos branches: 1.70.2;
- const poisoning
- avoid variable shadowing.
 1.69 20-Apr-2005  bouyer Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.68 04-Feb-2005  perry branches: 1.68.4;
de-__P
 1.67 23-Jan-2005  dan branches: 1.67.2;
attach tl(4) as an event source to rnd(4)
patches from Sean Davis in PR/28556
(slightly modified to actually catch our own interrupts)
 1.66 30-Oct-2004  thorpej branches: 1.66.4;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.65 15-Jun-2004  bouyer Apply patch from kern/25936 by Michael Blake: Add support for the
Netelligent 10/100 TX variant found on the Compaq Proliant Professional
Workstation 5100.
 1.64 10-Nov-2003  wiz branches: 1.64.2;
Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.63 02-Nov-2003  wiz deferred, not deffered. Inspired by Tom Cosgrove.
 1.62 05-Oct-2003  tsutsui Increase number of transmit/receive buffers from 10 to 32 to avoid
RX buffer overrun.
 1.61 05-Oct-2003  tsutsui Pass proper dma mapsize of TX/RX mbufs to bus_dmamap_sync().
Now tl(4) works on sgimips.
 1.60 05-Oct-2003  tsutsui Oops, more white space nit.
 1.59 05-Oct-2003  tsutsui TAB/space nits.
 1.58 30-Sep-2003  thorpej New generic I2C framework. Supports bit-bang and "intelligent" I2C
interface controllers (of varying intelligence levels).

Contributed by Wasabi Systems, Inc. Primarily written by Steve Woodford,
with some modification by me.
 1.57 19-Mar-2003  bouyer branches: 1.57.2;
tl(4) supports ETHERCAP_VLAN_MTU.
 1.56 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.55 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.54 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.53 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.52 17-Apr-2002  wiz branches: 1.52.4;
Fix two typos in comments. kern/16386 by Sean Davis.
 1.51 07-Mar-2002  christos stupid void pointers... tl_init() needs struct ifnet *...
 1.50 05-Mar-2002  itojun bring in latest ALTQ from kjc. ALTQify some of the drivers.
 1.49 28-Feb-2002  christos PR/15754: Sean Davis: Initialize if_softc before calling the mii init
routines to avoid NULL pointer de-referencing in the callbacks.
 1.48 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.47 13-Nov-2001  lukem add RCSID
 1.46 20-Sep-2001  bouyer - Allocate control structures at attach time rather than at init time.
Avoids using bus_dmamem_alloc/bus_dmamem_map at interrupt time.
Should fix PRs kern/13924 and kern/13979 from dive@endersgame.net
- while I'm there convert to use ether_ioctl.
 1.45 07-Aug-2001  bouyer branches: 1.45.2;
Properly set/clear IFF_OACTIVE.
 1.44 06-Aug-2001  bouyer Improvement: allocate one page of dmamem for Rx, Tx and nullbuff instead of
3 different ones.
Also pass the rigth seg/nseg to bus_dmamem_free().
Correct types in debug printf's
 1.43 03-Aug-2001  bouyer - kill the carrier detect code. It's not usefull any more and can give
false informations on a loaded ethernet segement.
- convert to bus_dma(9) (better late than never :)
- add proper le32toh/htole32 so that it works on big-endian system (tested
on macppc).
Close PR kern/10327.
 1.42 07-Jul-2001  thorpej branches: 1.42.2;
bzero -> memset
 1.41 07-Jul-2001  thorpej bcopy -> memcpy, strcpy
 1.40 21-Jun-2001  bouyer Proper media support for Compaq Deskpro 4000. PR kern/13244 from
Andrew Gillham.
 1.39 28-Dec-2000  sommerfeld branches: 1.39.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.38 14-Dec-2000  thorpej ALTQ'ify.
 1.37 15-Nov-2000  thorpej Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.36 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.35 05-Sep-2000  thorpej Cast arg to vtophys() to vaddr_t.
 1.34 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.33 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.32 23-Mar-2000  thorpej branches: 1.32.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.31 06-Mar-2000  thorpej No longer necessary to futz with ifp->if_baudrate here.
 1.30 02-Feb-2000  thorpej Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().
 1.29 02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.28 12-Dec-1999  tron As suggested by Jason Thorpe back out revision 1.27 because it broke
PHY probing for the ThunderLan driver.
 1.27 19-Nov-1999  thorpej Make the ThunderLAN and VIA Rhine drivers use the common MII bit-bang module.
 1.26 12-Nov-1999  thorpej Call mii_down() as appropriate.
 1.25 04-Nov-1999  thorpej Adapt to mii_phy_probe() change.
 1.24 18-May-1999  thorpej branches: 1.24.2; 1.24.4; 1.24.8;
Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.23 25-Mar-1999  bouyer branches: 1.23.4; 1.23.6;
First pass at support of Compaq NetFlex 3/P PCI: this one has
IO and Mem base address register inverted.
Still need some MII hack to get it fully fonctionnal.
 1.22 11-Jan-1999  tron Because memory mapped access doesn't fail only with the docking station
for the TI TravelMate 5000 but also with at least one Compaq NIC we
prefer I/O mapped access again. Fixes PR kern/6690.
 1.21 30-Oct-1998  thorpej branches: 1.21.4;
Manuel confirms that defaulting to AUTO is ok, to Do It.
 1.20 18-Aug-1998  thorpej vm_offset_t -> vaddr_t
 1.19 15-Aug-1998  thorpej Oops, don't forget to tick the MII once a second.
 1.18 15-Aug-1998  bouyer Fix typos in last commit.
 1.17 15-Aug-1998  bouyer correct indent.
 1.16 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.15 11-Aug-1998  thorpej Adapt to the new MII code. This required splitting some structures into
if_tlvar.h, since the ThunderLAN PHY driver needs to know some things
about it's parent (and since it can only attach to a ThunderLAN chip,
this is the easiest way).
 1.14 08-Aug-1998  mycroft Use splnet, not splimp.
 1.13 05-Jul-1998  jonathan branches: 1.13.2;
defopt NS, NSIP.
 1.12 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.11 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.10 05-May-1998  thorpej Slighly less brutal hack to deal with broken memory-mapped access of
the ThunderLAN on the TI TravelMate 5000 docking station: single it out,
and allow memory-mapped access on the Compaq products.
 1.9 11-Feb-1998  bouyer Correct a bogosity in the adapter->mii attach code pointed out by cgd:
in pci/if_tl.c, call config_found() with a print function, instead of
printing ourself a message in if_tl.c if no miibus was found. The print
function is in mii/mii.c (mii_adapter_print()) so that it can be used by any
adapter (idea from the scsi system).
 1.8 12-Jan-1998  thorpej Update for config changes.
 1.7 30-Nov-1997  drochner make it compile without "__BROKEN_INDIRECT_CONFIG"
 1.6 18-Nov-1997  bouyer Fix for systems with multiple tl interfaces:
nullbuf (used to pad packets < ETHER_MIN_SIZE) is used for all tl
interfaces. Allocates only once, and never deallocate it (as we can't say
if another instance of the driver is interface is using it).
 1.5 17-Nov-1997  thorpej Sigh, now that we've fixed a bug in PCI space management (the bug caused
i/o-mapped space to always be used), we discover that at least one
ThunderLAN interface can't read the EEPROM properly if memory-mapped
access is used. Kludge around this for now by "prefering" i/o space.
 1.4 17-Nov-1997  thorpej Fix a couple of bugs/annoyances in match/attach:
- Do PCI space configuration like the other drivers. In particular,
don't _disable_ the space we're not using because some lame firmware
implementations might not reenable it on warm boot. Also, prefer
memory space always.
- Make match and info-gathering in attach table-driven.
- Rearrange things a bit to be a bit more visually pleasing during boot.

Also, fixup some #include problems.
 1.3 16-Nov-1997  christos PR/4510: William Coldwell: Add TI thunderlan support.
 1.2 21-Oct-1997  bouyer Correct 'ThunderLAN' spelling
 1.1 17-Oct-1997  bouyer branches: 1.1.2;
Driver for Texas Instruments' thunderland network controller (present in some
Compaq products).
 1.1.2.5 10-Nov-1998  cgd patch from bouyer to address sysinst and media selection issues:
set the default media to UTP, and don't include 'none' in the media
list, so that sysinst will be able to set media properly. Done
differently in -current, because there the code uses MII. (bouyer)
 1.1.2.4 18-Nov-1997  mellon Pull rev 1.6 up from trunk (bouyer)
 1.1.2.3 17-Nov-1997  thorpej Sync w/ trunk.
 1.1.2.2 17-Nov-1997  thorpej Sync w/ trunk.
 1.1.2.1 21-Oct-1997  mrg pull up from trunk: Correct ThunderLAN spelling
 1.13.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.21.4.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.23.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.23.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.24.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.24.4.1 15-Nov-1999  fvdl Sync with -current
 1.24.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.24.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.24.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.32.4.3 11-Mar-2002  he Revert pull-up of revision 1.51 (requested by christos):
tl_init() changed interface between the netbsd-1-5 branch and -current.
Therefore, application of 1.51 is wrong, so undo it here.
 1.32.4.2 09-Mar-2002  he Pull up revisions 1.49,1.51 (via patch, requested by christos):
Make sure ifp->sc_softc is initialized before we set the media
callbacks, and correct argument error in invocation of tl_init().
 1.32.4.1 13-Nov-2001  he Pull up revision 1.40 (requested by bouyer):
Fix media support for Compaq Deskpro 4000. Fixes PR#13244.
 1.39.2.7 18-Oct-2002  nathanw Catch up to -current.
 1.39.2.6 20-Jun-2002  nathanw Catch up to -current.
 1.39.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.39.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.39.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.39.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.39.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.42.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.42.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.42.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.42.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.42.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.42.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.45.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.52.4.3 01-May-2005  tron Pull up revision 1.69 (requested by bouyer in ticket #5756):
Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.52.4.2 22-Jun-2004  tron Pull up revision 1.65 (requested by bouyer in ticket #1718):
Apply patch from kern/25936 by Michael Blake: Add support for the
Netelligent 10/100 TX variant found on the Compaq Proliant Professional
Workstation 5100.
 1.52.4.1 30-Jun-2003  grant Pull up revision 1.57 (requested by bouyer in ticket #1350):

tl(4) supports ETHERCAP_VLAN_MTU.
 1.57.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.57.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.57.2.5 24-Jan-2005  skrll Sync with HEAD.
 1.57.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.57.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.57.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.57.2.1 03-Aug-2004  skrll Sync with HEAD
 1.64.2.1 22-Jun-2004  tron branches: 1.64.2.1.2;
Pull up revision 1.65 (requested by bouyer in ticket #537):
Apply patch from kern/25936 by Michael Blake: Add support for the
Netelligent 10/100 TX variant found on the Compaq Proliant Professional
Workstation 5100.
 1.64.2.1.2.3 01-May-2005  tron Pull up revision 1.69 (requested by bouyer in ticket #1438):
Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.64.2.1.2.2 16-Apr-2005  tron Pull up revision 1.67 (requested by dan in ticket #1117):
attach tl(4) as an event source to rnd(4)
patches from Sean Davis in PR/28556
(slightly modified to actually catch our own interrupts)
 1.64.2.1.2.1 24-Jan-2005  he Pull up revision 1.66 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.66.4.1 29-Apr-2005  kent sync with -current
 1.67.2.1 12-Feb-2005  yamt sync with head.
 1.68.4.1 21-Apr-2005  tron Pull up revision 1.69 (requested by bouyer in ticket #180):
Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.70.2.5 21-Jan-2008  yamt sync with head
 1.70.2.4 27-Oct-2007  yamt sync with head.
 1.70.2.3 03-Sep-2007  yamt sync with head.
 1.70.2.2 30-Dec-2006  yamt sync with head.
 1.70.2.1 21-Jun-2006  yamt sync with head.
 1.72.8.2 14-Sep-2006  yamt sync with head.
 1.72.8.1 03-Sep-2006  yamt sync with head.
 1.72.4.1 09-Sep-2006  rpaulo sync with head
 1.75.4.2 10-Dec-2006  yamt sync with head.
 1.75.4.1 22-Oct-2006  yamt sync with head
 1.75.2.2 12-Jan-2007  ad Sync with head.
 1.75.2.1 18-Nov-2006  ad Sync with head.
 1.77.2.1 04-Mar-2007  bouyer Pull up following revision(s) (requested by rumble in ticket #478):
sys/dev/pci/if_tl.c: revision 1.78 - 1.80
sys/dev/ic/tulip.c: revision 1.148
Make the ThunderLAN part of the Set Engineering GIO board for sgimips (IP22)
work.
Extract mac addresses on Phobos G100 boards.
 1.81.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.82.4.1 11-Jul-2007  mjf Sync with head.
 1.82.2.2 23-Oct-2007  ad Sync with head.
 1.82.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.83.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.83.8.2 23-Mar-2008  matt sync with HEAD
 1.83.8.1 06-Nov-2007  matt sync with HEAD
 1.83.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.84.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.84.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.85.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.85.6.2 05-Oct-2008  mjf Sync with HEAD.
 1.85.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.86.6.2 10-Oct-2008  skrll Sync with HEAD.
 1.86.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.86.4.4 11-Aug-2010  yamt sync with head.
 1.86.4.3 11-Mar-2010  yamt sync with head
 1.86.4.2 16-Sep-2009  yamt sync with head
 1.86.4.1 04-May-2009  yamt sync with head.
 1.86.2.1 04-Jun-2008  yamt sync with head
 1.89.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.89.4.1 19-Oct-2008  haad Sync with HEAD.
 1.90.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.94.4.2 05-Mar-2011  rmind sync with head
 1.94.4.1 30-May-2010  rmind sync with head
 1.94.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.96.12.1 18-Feb-2012  mrg merge to -current.
 1.96.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.96.8.2 30-Oct-2012  yamt sync with head
 1.96.8.1 17-Apr-2012  yamt sync with head
 1.98.2.3 03-Dec-2017  jdolecek update from HEAD
 1.98.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.98.2.1 23-Jun-2013  tls resync from head
 1.99.4.1 18-May-2014  rmind sync with head
 1.100.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.101.4.5 28-Aug-2017  skrll Sync with HEAD
 1.101.4.4 05-Feb-2017  skrll Sync with HEAD
 1.101.4.3 09-Jul-2016  skrll Sync with HEAD
 1.101.4.2 19-Mar-2016  skrll Sync with HEAD
 1.101.4.1 06-Jun-2015  skrll Sync with HEAD
 1.105.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.107.8.4 26-Jan-2019  pgoyette Sync with HEAD
 1.107.8.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.107.8.2 28-Jul-2018  pgoyette Sync with HEAD
 1.107.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.107.2.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.107.2.1 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.109.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.109.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.109.2.1 10-Jun-2019  christos Sync with HEAD
 1.116.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.118.2.1 29-Feb-2020  ad Sync with head.
 1.131 20-Dec-2023  thorpej malloc(9) -> kmem(9), and plug a memory leak on detach while I'm here.
 1.130 08-May-2021  thorpej Use pci_compatible_match().
 1.129 07-Jul-2020  msaitoh branches: 1.129.6;
No functional change:

- u_int32_t -> uint32_t
- KNF.
 1.128 02-Jul-2020  msaitoh prop_data_data_nocopy -> prop_data_value
 1.127 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.126 29-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- KNF
 1.125 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.124 07-Jul-2016  msaitoh branches: 1.124.16; 1.124.18;
KNF. Remove extra spaces. No functional change.
 1.123 29-Mar-2014  christos branches: 1.123.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.122 23-Sep-2012  chs branches: 1.122.2;
match some more devices.
 1.121 11-Nov-2011  jakllsch branches: 1.121.6; 1.121.10;
Use GPP_GPC in the last place it isn't already used.
 1.120 11-Nov-2011  jakllsch Improve punctuation and consistency in some comments.
 1.119 10-Nov-2011  jakllsch When applying the board-specific bits for the SMC 9332,
the mediasw has already been set to non-NULL, don't require it to be NULL.
 1.118 26-Jul-2011  dyoung branches: 1.118.2;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.117 09-Jul-2011  christos - add a routine to get the name of the card.
 1.116 21-Jan-2010  martin Remove sparc specific code, rely on device properties instead
 1.115 01-Sep-2009  jmcneill aprint-ify
 1.114 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.113 17-Apr-2009  cegger backout rev. 1.112. I was misleaded by the wrong pci(9) manpage.
 1.112 17-Apr-2009  cegger pci_activate() wants a softc and not a device
 1.111 17-Apr-2009  cegger check return code of tlp_attach()
 1.110 17-Apr-2009  cegger Free resources in error path.
While here, fix copy&paste error I introduced in rev. 1.108.
 1.109 17-Apr-2009  cegger use aprint_*
 1.108 17-Apr-2009  cegger Detach tlp(4) during shutdown.
Free unused resources on attachment.
 1.107 17-Apr-2009  cegger device_t/softc split. Tested with tlp at pci
 1.106 08-Jun-2008  tsutsui branches: 1.106.6; 1.106.12;
Use device_lookup_private() rather than using cd_devs[] directly to get softc.

XXX maybe we should change a type of cd_devs[] in struct cfdriver
from (void *) to device_t.
 1.105 28-Apr-2008  martin branches: 1.105.2;
Remove clause 3 and 4 from TNF licenses
 1.104 10-Apr-2008  cegger branches: 1.104.2; 1.104.4;
use aprint_*_dev and device_xname
 1.103 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.102 19-Oct-2007  ad branches: 1.102.12; 1.102.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.101 18-Feb-2007  tsutsui branches: 1.101.4; 1.101.16; 1.101.18; 1.101.22;
- KNF, ANSIfy, TAB/space cleanup
- unwrap some lines
- u_intNN_t -> uintNN_t
 1.100 10-Feb-2007  dsl branches: 1.100.2;
Remove some ancient debugging leftovers left in by Michael Lorenz.
 1.99 09-Feb-2007  macallan add a quirks entry for the DEC21140 found on UMAX E100 cards
 1.98 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.97 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.96 30-Aug-2006  rumble branches: 1.96.2; 1.96.4;
Add quirks for the Phobos GIO Fast Ethernet boards.
 1.95 26-Jul-2006  itohy branches: 1.95.2;
Remove ADM9511's "signature".
I don't think it is used anywhere.
 1.94 21-Jul-2006  gdamore Update ADMtek pci device ids to match data sheets. While here, add the 9513
device (although I've never seen one, I have a datasheet for it. :-)
 1.93 18-Jul-2006  itohy Make new device (vendor 0x1317, product 0x9511) work as AN983.
 1.92 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.91 20-May-2006  rpaulo branches: 1.91.2;
The check for LMC cards should return NULL, not 0.
No functional change.
 1.90 05-May-2006  thorpej branches: 1.90.2;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.89 20-Apr-2006  christos Put back the code that avoids matching the lmc card. As pointed out by David
Boggs, it does not matter if the lmc driver routine returns 100 for the match,
because if the lmc driver is loaded via an LKM after boot, the other drivers
would have claimed the card already.
 1.88 25-Mar-2006  rpaulo Add support for the Conexant RS7112. From Frank Wille <frank@phoenix.owl.de>.
 1.87 25-Mar-2006  thorpej Use device_parent().
 1.86 18-Feb-2006  thorpej branches: 1.86.2; 1.86.4; 1.86.6;
- Don't expose dev_propdb directly -- provide devprop_*() wrappers instead.
- Rework the ARMADILLO / epe device properties interaction so that it actually
associates the MAC address property with the epe device instance.
 1.85 16-Feb-2006  thorpej Remove the ugly algor_get_ethaddr() hack. We have a properties infrastructure
now, so use that to provide the Ethernet address of the built-in Ethernet.
XXX Still a little ugly in the tlp driver, but fixing that would require
XXX reworking the SROM usage in a broader sense.

While here, do the P4032 DMA window hack in device_register() as well.
 1.84 06-Dec-2005  christos branches: 1.84.2; 1.84.4; 1.84.6;
Remove the "don't match lmc cards" test, because the lmc driver returns a
match of 100 which will supersede the de and tlp match if present. If not
present, then these two drivers will fail to match an mii. Thanks to thorpej
for the explanation.
 1.83 06-Dec-2005  thorpej Don't use magic constants in previous. (Not that we should be doing this
here in the first place...)
 1.82 06-Dec-2005  christos Don't match lmc cards by accident.
 1.81 17-Jul-2005  rpaulo If the DEC board name is not known, remove the leading whitespace in
sc_name.
This closes PR#30458.

ok'ed Jason Thorpe.
 1.80 23-Jun-2005  rpaulo branches: 1.80.2;
Add support for ASIX AX88140A/AX88141 chipsets using only
the 10/100 MII with inspiration from FreeBSD dc(4) driver.

Tested on i386 and macppc.

Reviewed by Jason Thorpe and ok'ed by Hubert Feyrer.
 1.79 13-Jun-2005  tron Also use prom_getether() under NetBSD-sparc(64) if the MAC address
retrieved from the PROM starts with ff:ff:ff. The driver now works with
the onboard interface in the Tadpole SPARCle.
 1.78 27-Feb-2005  perry branches: 1.78.2;
nuke trailing whitespace
 1.77 21-Aug-2004  thorpej branches: 1.77.4; 1.77.6;
Use ANSI function decls and make use of static.
 1.76 17-Mar-2004  martin branches: 1.76.4;
For sparc*: myetheraddr is no more
 1.75 28-Nov-2003  cube Add support for the 3com OfficeConnect 10/100B card, which has an ADMtek
AN985 controller, handled by tlp(4).

From Mike M. Volokhov <mishka AT terabyte DOT com DOT ua> in
current-users.
 1.74 03-Nov-2003  ichiro Fix uninitialized variable warnings
 1.73 27-Jun-2003  itohy branches: 1.73.2;
Properly reset PHY on ZNYX boards which are composed of
21143 and Quality Semiconductor QS6611 PHY.

QS6611 requires explicit reset on some hardware configuration. See
``Using the Intel 21143 with the Quality Semiconductor QS6611 Revision D4''
<http://www.intel.com/design/network/applnots/278239.htm> for details.

Models which should be supported by this change are
ZX345Q, ZX346Q, ZX348Q, (non-Q versions use different PHYs)
ZX414, ZX412, ZX444,
ZX442, ZX212, ZX214,
ZX374, ZX372, ZX244,
ZX424, ZX422.

Tested on ZX346Q.

Some information is from the ZNYX driver source code available from
the ZNYX web site <http://www.znyx.com/>.
 1.72 10-Mar-2003  thorpej Fix an error message.
 1.71 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.70 09-Oct-2002  jdolecek tlp_pci_vpc_21140_quirks(): make agnostic to signed/unsigned char; fixes
compile on cats
 1.69 08-Oct-2002  minoura Add quirk for Connectix VirtualPC emulated 21140, just to print the name
from the SROM.
 1.68 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.67 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.66 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.65 17-Apr-2002  mycroft Remove TLP_MATCH_* options.
 1.64 04-Apr-2002  chs add support for Cogent EM100 (aka Adaptec ANA-6910) TX and FX.
 1.63 03-Apr-2002  thorpej Add support for the Netwinder on-board 21143 (but don't try using it
yet; there are still some problems).
 1.62 26-Mar-2002  chs add support for SMC 9332DST.
 1.61 16-Mar-2002  chs decode the sub-system IDs on adaptec cards so we can differentiate between
multi-port cards (which need the shared-rom/intr stuff) and single-port cards
(which must not have it). previously we enabled sharing for all adaptec cards,
which caused problems if you had multiple single-port cards on the same PCI bus.
 1.60 13-Mar-2002  chs support the 4-port boards with the Cogent OUI as well.
 1.59 13-Mar-2002  chs support ANA-6944A boards (in addition to ANA-6922).
 1.58 14-Feb-2002  chs add support for Adaptec ANA-69xx multi-port cards.
 1.57 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.56 07-Dec-2001  matt Fix sense of if to grab address from alternation if srom is not in isv
format on Davicom chips. Add sparc specific case in this case to call
myetheraddr if oui is all 0s (for Netra X1).
 1.55 13-Nov-2001  lukem add RCSID
 1.54 08-Jul-2001  thorpej branches: 1.54.2;
Remove unnecessary include files. From Onno van der Linden.
 1.53 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.52 27-May-2001  thorpej Add quirks for the Algorithmics P-5064 on-board 21143, and a way to
get the Ethernet address from it (they don't have an SROM).

XXX The latter should be replaced with devprops when they exist.
 1.51 24-Feb-2001  cgd branches: 1.51.2;
C requires that labels be followed by statements.
 1.50 08-Jan-2001  thorpej Add Accton EN2242 10/100 MiniPCI Ethernet.
 1.49 08-Jan-2001  thorpej Use the AN985 media switch on the AN985.
 1.48 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.47 03-Oct-2000  thorpej Add support for the ADMtek AN983 and AN985.
 1.46 03-Aug-2000  castor Support some differences in the Macronix 98715AEC-C and E chips from the other
98715* series.

The MX98715AEC-[C,E] use a different location in the serial eerom for
LED control, and programming it with the original location's values
caused unpredictable behavior.

Also, start integrating fixes where media changes on an adapter
under load may fail. There's more work to be done here, but I need
to sort out our internal changes a little more carefully.
 1.45 17-Jul-2000  tron Don't make assumptions of the actual value of PCI_PMCSR_STATE_D0.
Problem noted by John Hawkinson.
 1.44 17-Jul-2000  tron Don't clobber bits from 2 to 31 when trying to change the power state.
Problem noted by John Hawkinson.
 1.43 16-Jul-2000  tron If card is in power state D3 put it into power state D0 so that it will
at least work after the next reboot.
 1.42 15-Jul-2000  tron Avoid printing duplicate colon when card is waked up.
 1.41 15-Jul-2000  tron Improve kernel message when card is in power state D3. Instead of...

epic0 at pci0 dev 11 function 0 epic0: unable to wake up from ...

... print this:

epic0 at pci0 dev 11 function 0: unable to wake up from power state D3
 1.40 25-Jun-2000  sommerfeld Defopt TLP_MATCH_*
 1.39 27-May-2000  thorpej branches: 1.39.2;
While DM9102A boards tend to have ISV-format SROMs (likely to describe
the HomePNA PHY typically connected to the external MII interface),
DM9102 implementations (often found on motherboards) do not. Handle
this.
 1.38 26-May-2000  thorpej branches: 1.38.2;
Add support for the Davicom DM9102 and DM9102A 10/100 Ethernet chips.

Partially based on diffs submitted by Matthew Orgass <darkstar@pgh.net>
and IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>.
 1.37 04-Apr-2000  thorpej - if_tlp_cardbus.c: Use the `pmreg' pointer passed by by
cardbus_get_capability() [mirror change already made to if_tlp_pci.c]
- if_tlp_cardbus.c: If we don't find an ISV SROM, try to grab the
Ethernet address from the CIS.
- if_tlp_cardbus.c: set CardBus cards to store-and-forward mode from
the get-go.
- Put the TxThresh tables in tulipvar.h, and use them in the CardBus
and PCI front-ends to go to store-and-forward mode.
- Document the Xircom X3201-3 clone a little more.
 1.36 26-Mar-2000  soren For Cobalt Networks 21143's, always use store-and-forward and toggle
a GPIO line to fully reset the PHY.
 1.35 23-Mar-2000  mycroft Rather than guessing at the location of the PMCSR, use the pointer returned by
pci_get_capability(). (This is, after all, a standardized interface...)
 1.34 15-Mar-2000  thorpej Add power management support to the `tlp' driver. The battery on my
laptop lasts a whole lot longer now.
 1.33 07-Mar-2000  mycroft Determine the size of the SROM by probing the chip using the standard Microwire
protocol. Eliminates the need for srom_quirks and some other trash.
 1.32 26-Jan-2000  thorpej Give the ISV filter a chance to verify 21143 pass 4.1 SROMs before running
them through the quirk table.
 1.31 26-Jan-2000  thorpej Additional hackery for the Cobalt interfaces. Even though these are
pass 4.1 21143s, they have a 128-byte SROM, and thus use a different
SROM address size than all other pass 4.1 21143s.

A plea to hardware designers -- *please* read application notes for
the components you're using before putting your hardware together. Thanks.
 1.30 25-Jan-2000  thorpej Clean up the SROM addrbits code a little.
 1.29 25-Jan-2000  thorpej Add a chip type for the Xircom X3201-3, and centralize the declaration
of the chip names array.
 1.28 25-Jan-2000  thorpej Handle Cobalt Networks interfaces, which are 21143 pass 4.1 devices
with a simple (MAC address only) SROM format.

From Soren S. Jorvang <soren@wheel.dk>
 1.27 11-Dec-1999  thorpej - Don't try to run the chip in big-endian mode. Not all chips support
this consistently, and it doesn't always work even when the chip
supports it.
- Make sure things DMA'd to the chip that the chip interprets are in
little-endian mode.
 1.26 07-Dec-1999  thorpej After reading the 21143 manual again, make sure SNOOZE is cleared in
the CFDA register, too.
 1.25 07-Dec-1999  thorpej Add the PMCSR offset for the 21143, and make sure to bring the 21142
and 21143 out of sleep mode. From Masanori Kanaoka.
 1.24 07-Dec-1999  thorpej If, on the 21143, we find that we don't have an ISV SROM, try reading
it again, with 8 address bits. 21143 Pass 4.1 has a larger SROM,
for storing the CIS when used in a CardBus application.
 1.23 19-Nov-1999  thorpej - Use the common MII bit-bang module.
- Add support other than 128-byte SROMs.
- Add support for the 21142/21143 MII.
 1.22 04-Nov-1999  thorpej Use Memory Read Line and Memory Read Multiple on the 21140, 21140A,
21142, and 21143, if the PCI bus says its okay.
 1.21 28-Oct-1999  thorpej Add some 21142/21143 goo.
 1.20 30-Sep-1999  thorpej branches: 1.20.2; 1.20.4; 1.20.6;
Changes to get the Lite-On/Macronix 82C115 working:
- 82C115 has a 128-bit multicast hash table, not 512-bit.
- Correct the way the MAC address is read from the SROM, after re-reading
the MX98715A Application Note.

Other semi-related changes:
- Differentiate between MX98715 and MX98715A.
- Improve the Macronix link-up/link-down detection.
 1.19 29-Sep-1999  thorpej - Get a little closer on the Macronix chips. Still some more work to do.
- Add some basic support for the ADMtek AL981 clone (which, unfortunately,
I can't test until my sample boards arrive).
 1.18 28-Sep-1999  thorpej Add code to take a device out of Power-Down state if it's in such a state,
and attempt to attach Macronix chips.
 1.17 26-Sep-1999  thorpej Add a quirk entry for the Asante 21140[A] boards that don't use the
ISV SROM format. For these boards, we provide the GPIO pin direction
info, a separate reset hook, and hard-wire them to MII-on-SIO.

Based on a patch submitted by Luoqi Chen <luoqi@chekov.watermarkgroup.com>.
 1.16 26-Sep-1999  thorpej Some 21140[A] boards don't use the ISV SROM format (e.g. Asante boards),
but instead use the older DEC Address ROM format.

From a patch supplied by Luoqi Chen <luoqi@chekov.watermarkgroup.com>.
 1.15 26-Sep-1999  thorpej Add quirk entry support for the 21041 and 21140 chips. Initial quirks
for these: extract the spiffy DEC board names (e.g. DE500-AA).
 1.14 26-Sep-1999  thorpej Make tlp_read_srom() work on big-endian systems.

From a patch supplied by Luoqi Chen <luoqi@chekov.watermarkgroup.com>.
 1.13 25-Sep-1999  thorpej Add support for the DECchip 21140[A]. This currently only works with
boards which use MII for media attachment.

ISV SROM format information lifted from Matt Thomas's `de' driver.

Thanks to Dave Sainty for experimenting w/ his 21140A MII boards, and
for supplying a fix to the MII bit-bang code (PR #8382).
 1.12 20-Sep-1999  thorpej Add support for the DECchip 21041. This also adds some preliminary
support for the ISV SROM format used in the 2114{1,1A,2,3}. Note, like
the 21040, auto-sense is not yet supported for the 21041.

Add a "pre-init" hook, which will be used for the 2114x and PNIC (currently)
which allows chip-specific code to set up and write OPMODE before the
chip is reset. This is necessary in order for the chip's internal
pathways to get initialized properly for MII/SYM/PCS/SIA media attachments.

Thanks to Dave Sainty for the hint from the `de' driver that inspired the
pre-init hook.
 1.11 17-Sep-1999  thorpej Fix a few buglets in the multi-port 21040 code. ZNYX ZX314 confirmed
working now.
 1.10 14-Sep-1999  thorpej Make sure 21040 chips are at least pass 2.0 and that 21140 chips are at
least pass 1.1.
 1.9 14-Sep-1999  thorpej Move the PCI device number to the base Tulip softc; it will be needed to
decode the SROM on 21041 and 2114x multi-port boards.
 1.8 14-Sep-1999  thorpej First crack at shared ROM/shared interrupts on 21040 multi-port boards,
plus quirk identification for non-multiple-port boards.
 1.7 14-Sep-1999  thorpej Oops, fix Winbond regshift.
 1.6 14-Sep-1999  thorpej Change the semantics of `sc_regshift'; it is now the shift required to
make a CSR index number into a CSR offset. Introduce a couple of macros
to handle CSR name -> offset conversion.
 1.5 14-Sep-1999  thorpej - More PNIC NWAY stuff. Still more work to do, here.
- Fix the SROM checksum routine.
- Add code to parse the old DEC Address ROM SROM format.
- Rearrange the statchg routines a bit, to make them consistent with one
another.
- Add support for the DECchip 21040. XXX No support for media autosense
yet, and no support for any of the multi-port boards yet.
 1.4 08-Sep-1999  thorpej Add chip types for several more Tulip clones (ASIX, ADMtex, PNIC II, Davicom),
and match the Compex RL100-ATX; it uses the Winbond 89C840F (RL100-TX is
a Macronix 98713).
 1.3 08-Sep-1999  thorpej Update for Lite-On product ID change.
 1.2 03-Sep-1999  thorpej Byte swap the EEPROM words on the PNIC. From Stephen Ma.
 1.1 01-Sep-1999  thorpej This is the long-awaited "new Tulip driver", a complete, from-scratch
rewrite of the driver for the DECchip 21x4x Ethernet chips, and a variety
of clones.

Currently, the driver supports the Winbond 89C840F (this works pretty
well), and the Lite-On PNIC (e.g. NetGear PCI boards), however Lite-On
support may be broken [I may simply have a busted test board].

Eventually, support for the Macronix and ASIX chips will filter into
this driver, and then, slowly, support for the genuine DEC chips,
and maybe even the DE-425 EISA model.
 1.20.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.20.4.1 15-Nov-1999  fvdl Sync with -current
 1.20.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.20.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.20.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.20.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.38.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.39.2.7 24-Apr-2001  he Apply patch (requested by he):
Fix typo in last patch, so that this compiles again.
 1.39.2.6 23-Apr-2001  he Pull up revisions 1.47-1.50 (via patch, requested by hubertf):
Support Accton EN2242 and other AmdTek AN985 compatible cards
with the tlp(4) driver.
 1.39.2.5 09-Aug-2000  castor Pulling up
ic/tulipvar.h diffs between 1.36 and 1.37
ic/tulipreg.h diffs between 1.21 and 1.20
ic/ tulip.c diffs between 1.70 and 1.71
pci/if_tlp_pci.c diffs between 1.43 and 1.46

requested by tls and thorpej, approved by thorpej

> date: 2000/08/03 03:07:31; author: castor; state: Exp;
lines: +5 -1 Support some differences in the Macronix
98715AEC-C and E chips from the other 98715* series.

The MX98715AEC-[C,E] use a different location in the serial eerom for
LED control, and programming it with the original location's values
caused unpredictable behavior.

Also, start integrating fixes where media changes on an adapter
under load may fail. There's more work to be done here, but I need
to sort out our internal changes a little more carefully.
 1.39.2.4 16-Jul-2000  tron Sync with NetBSD-current (pull up approved by thorpej):

syssrc/sys/dev/pci/if_epic_pci.c, 1.12
syssrc/sys/dev/pci/if_tlp_pci.c, 1.43

If card is in power state D3 put it into power state D0 so that it will
at least work after the next reboot.
 1.39.2.3 15-Jul-2000  tron Sync with NetBSD-current (pull up approved by thorpej):

syssrc/sys/dev/pci/if_epic_pci.c, 1.11
syssrc/sys/dev/pci/if_tlp_pci.c, 1.42

Avoid printing duplicate colon when card is waked up.
 1.39.2.2 15-Jul-2000  tron Sync with NetBSD-current (pull up approved by thorpej):

syssrc/sys/dev/pci/if_epic_pci.c, 1.9
syssrc/sys/dev/pci/if_tlp_pci.c, 1.41

Improve kernel message when card is in power state D3. Instead of...

epic0 at pci0 dev 11 function 0 epic0: unable to wake up from ...

... print this:

epic0 at pci0 dev 11 function 0: unable to wake up from power state D3
 1.39.2.1 25-Jun-2000  sommerfeld defopt TLP_MATCH_*. pullup approved by thorpej
 1.51.2.10 29-Dec-2002  thorpej Sync with HEAD.
 1.51.2.9 18-Oct-2002  nathanw Catch up to -current.
 1.51.2.8 20-Jun-2002  nathanw Catch up to -current.
 1.51.2.7 17-Apr-2002  nathanw Catch up to -current.
 1.51.2.6 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.51.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.51.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.51.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.51.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.51.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.54.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.54.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.54.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.54.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.54.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.73.2.7 11-Dec-2005  christos Sync with head.
 1.73.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.73.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.73.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.73.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.73.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.73.2.1 03-Aug-2004  skrll Sync with HEAD
 1.76.4.1 24-Jul-2005  riz Pull up revision 1.81 (requested by rpaulo in ticket #5506):
If the DEC board name is not known, remove the leading whitespace in
sc_name.
This closes PR#30458.
ok'ed Jason Thorpe.
 1.77.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.77.4.1 29-Apr-2005  kent sync with -current
 1.78.2.3 19-Jul-2005  riz Pull up revision 1.81 (requested by rpaulo in ticket #600):
If the DEC board name is not known, remove the leading whitespace in
sc_name.
This closes PR#30458.
ok'ed Jason Thorpe.
 1.78.2.2 01-Jul-2005  tron Pull up revision 1.80 (requested by rpaulo in ticket #493):
Add support for ASIX AX88140A/AX88141 chipsets using only
the 10/100 MII with inspiration from FreeBSD dc(4) driver.
Tested on i386 and macppc.
Reviewed by Jason Thorpe and ok'ed by Hubert Feyrer.
 1.78.2.1 18-Jun-2005  riz Pull up revision 1.79 (requested by tron in ticket #451):
Also use prom_getether() under NetBSD-sparc(64) if the MAC address
retrieved from the PROM starts with ff:ff:ff. The driver now works with
the onboard interface in the Tadpole SPARCle.
 1.80.2.5 24-Mar-2008  yamt sync with head.
 1.80.2.4 27-Oct-2007  yamt sync with head.
 1.80.2.3 26-Feb-2007  yamt sync with head.
 1.80.2.2 30-Dec-2006  yamt sync with head.
 1.80.2.1 21-Jun-2006  yamt sync with head.
 1.84.6.2 01-Jun-2006  kardel Sync with head.
 1.84.6.1 22-Apr-2006  simonb Sync with head.
 1.84.4.1 09-Sep-2006  rpaulo sync with head
 1.84.2.1 18-Feb-2006  yamt sync with head.
 1.86.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.86.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.86.4.2 11-May-2006  elad sync with head
 1.86.4.1 19-Apr-2006  elad sync with head.
 1.86.2.5 03-Sep-2006  yamt sync with head.
 1.86.2.4 11-Aug-2006  yamt sync with head
 1.86.2.3 26-Jun-2006  yamt sync with head.
 1.86.2.2 24-May-2006  yamt sync with head.
 1.86.2.1 01-Apr-2006  yamt sync with head.
 1.90.2.1 19-Jun-2006  chap Sync with head.
 1.91.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.95.2.1 10-Sep-2006  tron Pull up following revision(s) (requested by rumble in ticket #137):
sys/dev/pci/if_tlp_pci.c: revision 1.96
Add quirks for the Phobos GIO Fast Ethernet boards.
 1.96.4.2 10-Dec-2006  yamt sync with head.
 1.96.4.1 22-Oct-2006  yamt sync with head
 1.96.2.1 18-Nov-2006  ad Sync with head.
 1.100.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.101.22.1 25-Oct-2007  bouyer Sync with HEAD.
 1.101.18.2 23-Mar-2008  matt sync with HEAD
 1.101.18.1 06-Nov-2007  matt sync with HEAD
 1.101.16.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.101.4.1 23-Oct-2007  ad Sync with head.
 1.102.16.3 29-Jun-2008  mjf Sync with HEAD.
 1.102.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.102.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.102.12.1 24-Mar-2008  keiichi sync with head.
 1.104.4.5 11-Mar-2010  yamt sync with head
 1.104.4.4 16-Sep-2009  yamt sync with head
 1.104.4.3 16-May-2009  yamt sync with head
 1.104.4.2 04-May-2009  yamt sync with head.
 1.104.4.1 16-May-2008  yamt sync with head.
 1.104.2.2 17-Jun-2008  yamt sync with head.
 1.104.2.1 18-May-2008  yamt sync with head.
 1.105.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.106.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.106.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.118.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.118.2.2 30-Oct-2012  yamt sync with head
 1.118.2.1 17-Apr-2012  yamt sync with head
 1.121.10.3 03-Dec-2017  jdolecek update from HEAD
 1.121.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.121.10.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.121.6.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #691):
sys/dev/pci/aac_pci.c: revision 1.34
sys/dev/pci/if_sip.c: revision 1.155
sys/dev/pci/if_tlp_pci.c: revision 1.122
sys/dev/pci/if_an_pci.c: revision 1.34
match some more devices.
 1.122.2.1 18-May-2014  rmind sync with head
 1.123.6.1 09-Jul-2016  skrll Sync with HEAD
 1.124.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.124.18.1 10-Jun-2019  christos Sync with HEAD
 1.124.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.129.6.1 13-May-2021  thorpej Sync with HEAD.
 1.13 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.12 07-Jul-2020  msaitoh No functional change:

- u_int32_t -> uint32_t
- KNF.
 1.11 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.10 19-Oct-2009  bouyer branches: 1.10.22;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.9 25-Dec-2007  perry branches: 1.9.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.8 11-Dec-2005  christos branches: 1.8.46; 1.8.52; 1.8.56; 1.8.60;
merge ktrace-lwp.
 1.7 27-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 06-Aug-2001  bouyer branches: 1.6.20; 1.6.28; 1.6.30;
Improvement: allocate one page of dmamem for Rx, Tx and nullbuff instead of
3 different ones.
Also pass the rigth seg/nseg to bus_dmamem_free().
Correct types in debug printf's
 1.5 03-Aug-2001  bouyer - kill the carrier detect code. It's not usefull any more and can give
false informations on a loaded ethernet segement.
- convert to bus_dma(9) (better late than never :)
- add proper le32toh/htole32 so that it works on big-endian system (tested
on macppc).
Close PR kern/10327.
 1.4 15-Aug-1998  bouyer branches: 1.4.24; 1.4.26;
Fix typos in last commit.
 1.3 15-Aug-1998  bouyer correct indent.
 1.2 17-Nov-1997  thorpej Cosmetic change.
 1.1 17-Oct-1997  bouyer branches: 1.1.2;
Driver for Texas Instruments' thunderland network controller (present in some
Compaq products).
 1.1.2.1 17-Nov-1997  thorpej Sync w/ trunk.
 1.4.26.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.4.24.1 24-Aug-2001  nathanw Catch up with -current.
 1.6.30.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.28.1 29-Apr-2005  kent sync with -current
 1.6.20.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.4.1 21-Jan-2008  yamt sync with head
 1.8.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.56.1 26-Dec-2007  ad Sync with head.
 1.8.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.46.1 09-Jan-2008  matt sync with HEAD
 1.9.10.1 11-Mar-2010  yamt sync with head
 1.10.22.1 03-Dec-2017  jdolecek update from HEAD
 1.18 07-Jul-2020  msaitoh No functional change:

- u_int32_t -> uint32_t
- KNF.
 1.17 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.16 02-Feb-2012  tls branches: 1.16.6; 1.16.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.15 19-Nov-2011  tls branches: 1.15.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.14 19-Oct-2009  bouyer branches: 1.14.12;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.13 01-Jun-2008  tsutsui Split device_t/softc, with misc cosmetic changes.
 1.12 11-Dec-2005  christos branches: 1.12.70; 1.12.72; 1.12.74; 1.12.76;
merge ktrace-lwp.
 1.11 23-Jan-2005  dan attach tl(4) as an event source to rnd(4)
patches from Sean Davis in PR/28556
(slightly modified to actually catch our own interrupts)
 1.10 10-Nov-2003  wiz branches: 1.10.6; 1.10.8;
Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.9 02-Nov-2003  wiz deferred, not deffered. Inspired by Tom Cosgrove.
 1.8 30-Sep-2003  thorpej New generic I2C framework. Supports bit-bang and "intelligent" I2C
interface controllers (of varying intelligence levels).

Contributed by Wasabi Systems, Inc. Primarily written by Steve Woodford,
with some modification by me.
 1.7 20-Sep-2001  bouyer branches: 1.7.18;
- Allocate control structures at attach time rather than at init time.
Avoids using bus_dmamem_alloc/bus_dmamem_map at interrupt time.
Should fix PRs kern/13924 and kern/13979 from dive@endersgame.net
- while I'm there convert to use ether_ioctl.
 1.6 06-Aug-2001  bouyer branches: 1.6.2;
Improvement: allocate one page of dmamem for Rx, Tx and nullbuff instead of
3 different ones.
Also pass the rigth seg/nseg to bus_dmamem_free().
Correct types in debug printf's
 1.5 03-Aug-2001  bouyer - kill the carrier detect code. It's not usefull any more and can give
false informations on a loaded ethernet segement.
- convert to bus_dma(9) (better late than never :)
- add proper le32toh/htole32 so that it works on big-endian system (tested
on macppc).
Close PR kern/10327.
 1.4 23-Mar-2000  thorpej branches: 1.4.6; 1.4.8;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.3 11-Jan-1999  tron branches: 1.3.8;
Because memory mapped access doesn't fail only with the docking station
for the TI TravelMate 5000 but also with at least one Compaq NIC we
prefer I/O mapped access again. Fixes PR kern/6690.
 1.2 15-Aug-1998  bouyer branches: 1.2.4;
correct indent.
 1.1 11-Aug-1998  thorpej Adapt to the new MII code. This required splitting some structures into
if_tlvar.h, since the ThunderLAN PHY driver needs to know some things
about it's parent (and since it can only attach to a ThunderLAN chip,
this is the easiest way).
 1.2.4.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.8.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.4.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.4.6.1 24-Aug-2001  nathanw Catch up with -current.
 1.6.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.7.18.4 24-Jan-2005  skrll Sync with HEAD.
 1.7.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.18.1 03-Aug-2004  skrll Sync with HEAD
 1.10.8.1 29-Apr-2005  kent sync with -current
 1.10.6.1 16-Apr-2005  tron Pull up revision 1.11 (requested by dan in ticket #1117):
attach tl(4) as an event source to rnd(4)
patches from Sean Davis in PR/28556
(slightly modified to actually catch our own interrupts)
 1.12.76.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.74.2 11-Mar-2010  yamt sync with head
 1.12.74.1 04-May-2009  yamt sync with head.
 1.12.72.1 04-Jun-2008  yamt sync with head
 1.12.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.12.1 17-Apr-2012  yamt sync with head
 1.15.2.1 18-Feb-2012  mrg merge to -current.
 1.16.24.1 06-Jun-2015  skrll Sync with HEAD
 1.16.6.1 03-Dec-2017  jdolecek update from HEAD
 1.76 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.75 10-Feb-2024  andvar s/alloted/allotted/ in comments.
 1.74 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.73 10-Mar-2020  thorpej On NetBSD it's spelled "__NO_STRICT_ALIGNMENT". Adjust txp_rx_reclaim()
accordingly and structure it like other NetBSD drivers so as to re-use
the original Rx buffer rather than doing a needless free/alloc cycle.

Note this happened to work previously on my Qube2 because IP, TCP, etc.
perform their own alignment checks and react accordingly. However, it's
not clear that ALL protocols do this yet, so it's better to just do the
safe thing for now.
 1.72 10-Mar-2020  thorpej - Add support for MBUFTRACE.
- Fix an mbuf leak I introduced in rev 1.68 (failed to increment "cnt"
variable in txp_start(), which subsequently caused txp_tx_reclaim()
to never run).
- Use the context address pointer in the Tx descriptor to stash the
pointer to the Tx job software state in a manner like that which
is used for Rx software state.
 1.71 09-Mar-2020  thorpej Add an assertion.
 1.70 09-Mar-2020  thorpej Now that we're allocating rx software state from a fixed pool, we
don't have to round-trip pointers in a sketchy way -- we can round-
trip indices.
 1.69 09-Mar-2020  thorpej Allocate a static set of receive software state descriptors at attach
time, and create a simple allocator for them for use by the rx reclaim
handlers. Don't create and destroy DMA maps for receoive buffers
in the interrupt handlers -- just use the maps that are created at
attach time.
 1.68 08-Mar-2020  thorpej Give each Tx DMA map 16 DMA segments rather than the previous absurdly large
number, and structure the loop in txp_start() similarly to other drivers
(e.g. ste_start() in the ste(4) driver). Similar in spirit to OpenBSD's
rev 1.126, but implemented a bit differently.
 1.67 08-Mar-2020  thorpej Upgrade to newer firmware needed by some txp(4) variants.
From FreeBSD via OpenBSD.
 1.66 08-Mar-2020  thorpej Follow the example of the MII code and don't register the half-duplex
versions of each media type.
 1.65 08-Mar-2020  thorpej - Use BUS_ADDR_{LO,HI}32(), and rather than forcing the descriptor
DMA addresses into a 64-bit value (and thus using 64-bit shifts
when unnecessary), just reference the address from the DMA map
directly.
- Add some missing byte-swaps.
 1.64 29-Feb-2020  thorpej Use the 64-bit PCI DMA tag, if available.
 1.63 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.62 06-Dec-2019  maxv branches: 1.62.2;
localify
 1.61 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.60 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.59 09-Jul-2019  msaitoh branches: 1.59.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.58 20-Jun-2019  msaitoh Fix panic on attach. This bug was added in rev. 1.56. I think it's not
required to call txp_set_filter() in the attach function.
 1.57 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.56 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.55 23-May-2019  msaitoh No functional change:
- Change ac(was arpcom) to ec(ethercom)
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.54 07-May-2019  msaitoh - Use bus_dmamem_unmap() correctly in txp_dma_free() to prevent panic.
The code was wrong since rev. 1.1. This panic was found by adding KASSERT
in uvm_map.c rev. 1.351. This bug may be related to PR kern/26204.
- Use aprint_normal() for non-error message.
 1.53 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.52 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.51 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.50 25-Jul-2018  msaitoh Initialize some members in a mbuf which is on stack.
 1.49 26-Jun-2018  msaitoh branches: 1.49.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.48 26-Sep-2017  knakahara branches: 1.48.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.47 15-Dec-2016  ozaki-r branches: 1.47.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.46 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.45 14-Jul-2016  msaitoh branches: 1.45.2;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.44 14-Jul-2016  msaitoh - Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.43 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.42 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.41 16-Jun-2014  msaitoh branches: 1.41.4;
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.40 29-Mar-2014  christos branches: 1.40.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.39 27-Oct-2012  chs branches: 1.39.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.38 13-Nov-2010  uebayasi branches: 1.38.8; 1.38.14; 1.38.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.37 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.36 19-Jan-2010  pooka branches: 1.36.2; 1.36.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.35 27-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only.
 1.34 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.33 18-Mar-2009  cegger bcopy -> memcpy
 1.32 18-Mar-2009  cegger bzero -> memset
 1.31 18-Mar-2009  cegger bcmp -> memcmp
 1.30 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.29 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.28 16-Feb-2009  cegger fix media priorities:

IEEE 802.3 Annex 28B.3 specifies the following relative
priorities of the technologies supported by
802.3 Selector Field value:

1000BASE-T full duplex
1000BASE-T
100BASE-T2 full duplex
100BASE-TX full duplex
100BASE-T2
100BASE-T4
100BASE-TX
10BASE-T full duplex
10BAST-T

Our drivers give 100BASE-T4 a higher priority than
100BASE-TX full duplex.
Fix this. This patch is based on changes in FreeBSD and OpenBSD.

Patch presented on tech-kern and tech-net:
http://mail-index.netbsd.org/tech-kern/2009/02/15/msg004397.html
http://mail-index.netbsd.org/tech-net/2009/02/15/msg001064.html

got no comments, no objections.
 1.27 07-Nov-2008  dyoung branches: 1.27.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.26 10-Apr-2008  cegger branches: 1.26.4; 1.26.10; 1.26.12; 1.26.14; 1.26.18;
use aprint_*_dev and device_xname
 1.25 09-Apr-2008  dyoung Use device_t and accessors. Use cfdata_t and __arraycount().
Miscellaneous cosmetic changes.
 1.24 09-Apr-2008  dyoung s/pcimatch/match/ to avoid conflict with a global name.
 1.23 07-Feb-2008  dyoung branches: 1.23.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.22 19-Oct-2007  ad branches: 1.22.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.21 01-Sep-2007  dyoung branches: 1.21.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.20 09-Jul-2007  ad branches: 1.20.2; 1.20.6; 1.20.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.19 04-Mar-2007  christos branches: 1.19.2; 1.19.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18 16-Nov-2006  christos branches: 1.18.4;
__unused removal on arguments; approved by core.
 1.17 04-Nov-2006  tsutsui Remove vtophys (in comment).
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 14-Apr-2006  christos branches: 1.15.8; 1.15.10;
Coverity CID 2314: Free memory if we fail to allocate rings.
 1.14 28-Dec-2005  christos branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
We don't have access to in_cksum() if no INET.
 1.13 11-Dec-2005  christos merge ktrace-lwp.
 1.12 18-Jun-2005  chs branches: 1.12.2;
adapt to const/volatile changes.
 1.11 02-May-2005  yamt split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.10 27-Feb-2005  perry branches: 1.10.2;
nuke trailing whitespace
 1.9 20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition
 1.8 30-Oct-2004  thorpej branches: 1.8.4; 1.8.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.7 01-Jul-2004  is disestablish the interupt if we fail to (among other things) download
the firmware successfully. This prevents the kernel from crashing later
at interupt enable time, if firmware download fails like with my 3c990B
card.
 1.6 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.5 27-Oct-2003  thorpej branches: 1.5.2;
- Change callout_setfunc() to require that the callout handle is already
initialized. Update the txp(4) to compensate.
- Statically initialize the TCP timer callout handles in the tcpcb
template. We still use callout_setfunc(), but that call is now much
less expensive. Add a comment that the compiler is likely to unroll
the loop (so don't sweat that it's there).
 1.4 20-Aug-2003  drochner make the vlan stuff work
 1.3 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.2 07-Jul-2003  drochner some cleanup/fixes:
-get boot messages to NetBSD's standards (ie at least 3 lines)
-get some card information from PCI ID and subsystem ID
-fix media handling and link reporting for fiber cards
-port cksum offloading to NetBSD and enable as far as appropriate
(TCP/UDP transmit offloading still disabled, as in OpenBSD)
 1.1 01-Jul-2003  drochner branches: 1.1.2;
VERY quick and VERY dirty port of the OpenBSD "txp" driver for
3Com 3C(R)990 cards. No TCP/UDP nor IPSEC offloading for now.
The ifmedia part needs some work, but I only have a 100-FX card;
hopefully someone will clean this up.
 1.1.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.2.1 10-Jul-2004  tron branches: 1.5.2.1.2;
Pull up revision 1.7 (requested by is in ticket #626):
disestablish the interupt if we fail to (among other things) download
the firmware successfully. This prevents the kernel from crashing later
at interupt enable time, if firmware download fails like with my 3c990B
card.
 1.5.2.1.2.1 24-Jan-2005  he Pull up revision 1.8 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.8.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.2.1 28-Oct-2005  jmc Pullup (requested by chs in ticket #912)
Fix txp cards so this compiles and enable in GENERIC.
 1.12.2.5 11-Feb-2008  yamt sync with head.
 1.12.2.4 27-Oct-2007  yamt sync with head.
 1.12.2.3 03-Sep-2007  yamt sync with head.
 1.12.2.2 30-Dec-2006  yamt sync with head.
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.14.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.10.1 19-Apr-2006  elad sync with head.
 1.14.8.1 24-May-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.10.2 10-Dec-2006  yamt sync with head.
 1.15.10.1 22-Oct-2006  yamt sync with head
 1.15.8.1 18-Nov-2006  ad Sync with head.
 1.18.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.4.1 11-Jul-2007  mjf Sync with head.
 1.19.2.3 23-Oct-2007  ad Sync with head.
 1.19.2.2 09-Oct-2007  ad Sync with head.
 1.19.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.20.8.2 23-Mar-2008  matt sync with HEAD
 1.20.8.1 06-Nov-2007  matt sync with HEAD
 1.20.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.20.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.20.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.21.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.23.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.23.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.26.18.1 21-Apr-2010  matt sync to netbsd-5
 1.26.14.1 01-May-2009  snj Pull up following revision(s) (requested by cegger in ticket #474):
sys/dev/mii/inphy.c: revision 1.51
sys/dev/mii/iophy.c: revision 1.35
sys/dev/mii/nsphy.c: revision 1.56
sys/dev/mii/rlphy.c: revision 1.25
sys/dev/mii/ukphy_subr.c: revision 1.11
sys/dev/pci/if_txp.c: revision 1.28
fix media priorities:
IEEE 802.3 Annex 28B.3 specifies the following relative
priorities of the technologies supported by
802.3 Selector Field value:
1000BASE-T full duplex
1000BASE-T
100BASE-T2 full duplex
100BASE-TX full duplex
100BASE-T2
100BASE-T4
100BASE-TX
10BASE-T full duplex
10BAST-T
Our drivers give 100BASE-T4 a higher priority than
100BASE-TX full duplex.
Fix this. This patch is based on changes in FreeBSD and OpenBSD.
Patch presented on tech-kern and tech-net:
http://mail-index.netbsd.org/tech-kern/2009/02/15/msg004397.html
http://mail-index.netbsd.org/tech-net/2009/02/15/msg001064.html
got no comments, no objections.
 1.26.12.3 28-Apr-2009  skrll Sync with HEAD.
 1.26.12.2 03-Mar-2009  skrll Sync with HEAD.
 1.26.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.26.4.3 11-Aug-2010  yamt sync with head.
 1.26.4.2 11-Mar-2010  yamt sync with head
 1.26.4.1 04-May-2009  yamt sync with head.
 1.27.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.4.2 05-Mar-2011  rmind sync with head
 1.36.4.1 30-May-2010  rmind sync with head
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.38.18.3 03-Dec-2017  jdolecek update from HEAD
 1.38.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.38.14.1 09-Nov-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #1189):
sys/dev/pci/if_wm.c: revision 1.270
sys/dev/mii/inphy.c: revision 1.53
sys/dev/mii/glxtphy.c: revision 1.24
sys/dev/mii/tlphy.c: revision 1.62
sys/dev/mii/iophy.c: revision 1.37
sys/dev/mii/brgphy.c: revision 1.70
sys/dev/mii/ihphy.c: revision 1.8
sys/dev/mii/bmtphy.c: revision 1.31
sys/dev/mii/urlphy.c: revision 1.30
sys/dev/mii/makphy.c: revision 1.40
sys/dev/mii/qsphy.c: revision 1.48
sys/dev/mii/igphy.c: revision 1.23
sys/dev/mii/nsphy.c: revision 1.58
sys/dev/mii/mvphy.c: revision 1.10
sys/dev/pci/if_txp.c: revision 1.41
sys/dev/mii/nsphy.c: revision 1.59
sys/dev/mii/rlphy.c: revision 1.28
sys/dev/mii/icsphy.c: revision 1.49
sys/dev/mii/rlphy.c: revision 1.29
sys/dev/mii/lxtphy.c: revision 1.49
sys/dev/mii/ciphyreg.h: revision 1.5
sys/dev/mii/nsphyter.c: revision 1.38
sys/dev/mii/sqphy.c: revision 1.50
sys/dev/mii/gentbi.c: revision 1.26
sys/dev/mii/gentbi.c: revision 1.27
sys/dev/mii/tqphy.c: revision 1.39
sys/dev/mii/ikphy.c: revision 1.10
sys/dev/mii/dmphy.c: revision 1.35
sys/dev/mii/amhphy.c: revision 1.20
sys/dev/mii/acphy.c: revision 1.24
sys/dev/mii/ciphy.c: revision 1.25
sys/dev/mii/brgphyreg.h: revision 1.8
sys/dev/mii/ukphy_subr.c: revision 1.12
sys/dev/ic/rtl80x9.c: revision 1.16
sys/arch/mips/adm5120/dev/if_admsw.c: revision 1.12
sys/dev/pci/if_kse.c: revision 1.28
sys/dev/mii/ukphy_subr.c: revision 1.13
sys/dev/mii/mii.h: revision 1.18
sys/dev/mii/gphyter.c: revision 1.29
No functional change:
- Fix typo.
- Remove trailing white spaces.
- Capitalize comments.
- Tabify.
- KNF.
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.38.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.8.1 30-Oct-2012  yamt sync with head
 1.39.2.1 18-May-2014  rmind sync with head
 1.40.2.1 10-Aug-2014  tls Rebase.
 1.41.4.4 05-Feb-2017  skrll Sync with HEAD
 1.41.4.3 05-Oct-2016  skrll Sync with HEAD
 1.41.4.2 09-Jul-2016  skrll Sync with HEAD
 1.41.4.1 19-Mar-2016  skrll Sync with HEAD
 1.45.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.47.8.3 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.47.8.2 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.47.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.48.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.48.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.49.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.49.2.1 10-Jun-2019  christos Sync with HEAD
 1.59.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.62.2.1 29-Feb-2020  ad Sync with head.
 1.11 10-Mar-2020  thorpej Protect against multiple inclusion.
 1.10 09-Mar-2020  thorpej Allocate a static set of receive software state descriptors at attach
time, and create a simple allocator for them for use by the rx reclaim
handlers. Don't create and destroy DMA maps for receoive buffers
in the interrupt handlers -- just use the maps that are created at
attach time.
 1.9 08-Mar-2020  thorpej Give each Tx DMA map 16 DMA segments rather than the previous absurdly large
number, and structure the loop in txp_start() similarly to other drivers
(e.g. ste_start() in the ste(4) driver). Similar in spirit to OpenBSD's
rev 1.126, but implemented a bit differently.
 1.8 08-Mar-2020  thorpej Upgrade to newer firmware needed by some txp(4) variants.
From FreeBSD via OpenBSD.
 1.7 08-Mar-2020  thorpej - Use BUS_ADDR_{LO,HI}32(), and rather than forcing the descriptor
DMA addresses into a 64-bit value (and thus using 64-bit shifts
when unnecessary), just reference the address from the DMA map
directly.
- Add some missing byte-swaps.
 1.6 27-Oct-2012  chs branches: 1.6.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.5 10-Apr-2008  cegger branches: 1.5.38; 1.5.48;
use aprint_*_dev and device_xname
 1.4 04-Mar-2007  christos branches: 1.4.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 11-Dec-2005  christos branches: 1.3.26;
merge ktrace-lwp.
 1.2 07-Jul-2003  drochner branches: 1.2.16;
some cleanup/fixes:
-get boot messages to NetBSD's standards (ie at least 3 lines)
-get some card information from PCI ID and subsystem ID
-fix media handling and link reporting for fiber cards
-port cksum offloading to NetBSD and enable as far as appropriate
(TCP/UDP transmit offloading still disabled, as in OpenBSD)
 1.1 01-Jul-2003  drochner branches: 1.1.2;
VERY quick and VERY dirty port of the OpenBSD "txp" driver for
3Com 3C(R)990 cards. No TCP/UDP nor IPSEC offloading for now.
The ifmedia part needs some work, but I only have a 100-FX card;
hopefully someone will clean this up.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.2.16.1 03-Sep-2007  yamt sync with head.
 1.3.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.48.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.38.1 30-Oct-2012  yamt sync with head
 1.6.38.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.89 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.88 29-Jun-2024  riastradh branches: 1.88.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.87 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.86 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.85 17-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.84 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.83 22-Jan-2022  martin Explicitly cast a __MASK(48) to bus_addr_t (for 32bit bus_addr_t archs)
 1.82 22-Jan-2022  skrll Ensure bus_dmatag_subregion is called with an inclusive max_addr
everywhere.
 1.81 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.80 21-Mar-2020  thorpej branches: 1.80.8;
Use the 64-bit DMA tag, if available, with some constraints:
- The data buffers can come from anywhere in the 64-bit region, but
the upper 16 bits of the data buffer address is stored in a single
register, so just treat that as 0 and create a 48-bit restricted
DMA tag.
- The descriptor address registers share a single register for the
upper 32-bits, so enforce a 4G boundary when allocating memory
for the descriptors.
 1.79 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.78 27-Dec-2019  msaitoh branches: 1.78.2;
s/opration/operation/
 1.77 21-Nov-2019  msaitoh - Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
the current active link status.
 1.76 19-Nov-2019  msaitoh Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.
 1.75 08-Oct-2019  msaitoh Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.74 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.73 09-Jul-2019  msaitoh branches: 1.73.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.72 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.71 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.70 23-May-2019  msaitoh -No functional change:
- Simplify struct ethercom's pointer near ETHER_FIRST_MULTI().
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.69 11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.68 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.67 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.66 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.65 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.64 18-Jul-2018  sevan Be consistent among ethernet drivers on the convention for printing ethernet
addresses.

NFC
 1.63 26-Jun-2018  msaitoh branches: 1.63.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.62 14-Jan-2018  maxv branches: 1.62.2;
Dedup. m_defrag is already a common function, no need to reimplement it
there. Meanwhile this should fix two bugs (that I couldn't investigate
more than that since I don't have this hardware): the mbuf passed to
vge_m_defrag was leaked, and the tags were not copied in the returned
mbuf.
 1.61 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.60 15-Dec-2016  ozaki-r branches: 1.60.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.59 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.58 10-Jun-2016  ozaki-r branches: 1.58.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.57 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.56 29-Mar-2014  christos branches: 1.56.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.55 13-Sep-2013  martin Remove unused variable
 1.54 30-Mar-2013  christos branches: 1.54.4;
remove trailing whitespace
 1.53 22-Jul-2012  matt branches: 1.53.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.52 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.51 05-Apr-2010  joerg branches: 1.51.8; 1.51.12;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.50 19-Jan-2010  pooka branches: 1.50.2; 1.50.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.49 07-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested on VT6122.
 1.48 16-May-2009  tsutsui Split device_t/softc split, tested on VT6212L.
 1.47 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.46 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.45 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.44 09-Feb-2009  nonaka fix comment.
 1.43 26-Nov-2008  joerg branches: 1.43.4;
- ifconfig down support
- ALTQ support
 1.42 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.41 10-Apr-2008  cegger branches: 1.41.4; 1.41.10; 1.41.12; 1.41.14;
use aprint_*_dev and device_xname
 1.40 07-Feb-2008  dyoung branches: 1.40.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.39 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.38 19-Oct-2007  ad branches: 1.38.2; 1.38.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.37 01-Sep-2007  dyoung branches: 1.37.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.36 09-Jul-2007  ad branches: 1.36.2; 1.36.6; 1.36.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.35 12-Jun-2007  tsutsui Fix one more bug I introduced in rev 1.21:
Clear sc->sc_rx_consumed before allocating RX mbufs by vge_newbuf()
in vge_intr() otherwise vge_newbuf() might get KASSERT() failure
on DIAGNOSTIC kernel when the interface is reinitialized during RX.
 1.34 04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 01-Dec-2006  tsutsui branches: 1.33.2; 1.33.4; 1.33.8;
Free resouces on failure in vge_allocmem().
 1.32 01-Dec-2006  tsutsui - vge_probe() -> vge_match()
- KNF, unwrap lines
 1.31 26-Nov-2006  tsutsui Fix stupid bugs found on sparc64:
- checking if dmamap != NULL is not valid because dmamap is not cleared
in bus_dmamap_unload(9)
- no need check RX mbufs and call m_freem() and bus_dmamap_unload()
in vge_init() since it's done in prior vge_stop()

Now vge(4) works fine on Ultra5.
 1.30 26-Nov-2006  tsutsui Include <sys/device.h> for struct device.
 1.29 26-Nov-2006  tsutsui - prepare inline functions to set 48 bit DMA address which avoid 64 bit
arithmetic on ILP32 (sizeof(bus_addr_t) == 4, exactly) hosts
- prepare and use VGE_PREV_TXDESC() macro
- use VGE_[TR]XDESCSYNC() calls more efficiently
- wrap a sanity check against VGE_RDSTS_OWN in vge_newbuf()
with #ifdef DIAGNOSTIC since it should not happen
- use sc->sc_tx_free (number of free TX descs) to check if TX packets are
queued or sent
- call vge_start() only if the interupt is actually handled by this driver
- some misc cosmetics
 1.28 26-Nov-2006  tsutsui Introduce a new VGE_RX_BUFSIZE macro which represent default RX mbuf
length and define VGE_RX_PAD (which is 4 bytes) for ETHER_ALIGN (2 bytes)
padding only in !__NO_STRICT_ALIGNMENT case to avoid confusion.
As per comments from Murata Shuuichirou in PR kern/31323.
Tested on i386 and macppc.
 1.27 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.26 04-Nov-2006  tsutsui Rather than copying m_pkthdr.csum_flags in m_defrag() (which was
committed in rev 1.22), save it before calling m_defrag().

I haven't confirmed whether the m_pkthdr.csum_flags is preserved during
m_defrag(), but the previous way sometimes makes vge(4) chip mad...
 1.25 04-Nov-2006  tsutsui Return a proper error from vge_encap() if m_defrag() fails.
 1.24 01-Nov-2006  tsutsui Fix another botch in rev 1.14:
vge_encap() should bail out if there is not enough free
TX descriptor _OR_ TX descriptor is still owned by the chip.

Anyway, we already check if the TX descriptor already has an mbuf
to be sent in vge_start() so no need to bother to check sc_tx_free
and VGE_TDSTS_OWN in the descriptor in normal case, then make it use
KASSERT(9) or wrap with #ifdef DIAGNOSTIC.

XXX1: I don't know why original FreeBSD driver checks
if a number of free TX descriptors is more than two, not zero.
XXX2: Is it better to check a number of free descriptors in vge_start()
like other our drivers rather than mbuf chain for each descriptor?
 1.23 01-Nov-2006  tsutsui Remove a debug statement which was slipped in rev 1.21.
 1.22 01-Nov-2006  tsutsui Also copy csum_flags and csum_data in vge_m_defrag().
Fix checksum error problem on sending fragmented large packets,
which was introduced in rev 1.14.

BTW, should we have m_defrag() in MI for other drivers?
 1.21 31-Oct-2006  tsutsui Make vge(4) look a NetBSD native driver like pcn(4) or epic(4) etc:
- merge if_vgevar.h into if_vge.c since no other file refers it
- rename some macro (VGE_TX_DESC_CNT -> VGE_NTXDESC etc.) and structs
- change prefixes of structure members to represent parents
- put TX and RX descriptors into single struct vge_control_data and
allocate DMA memory at once
- no need to specify BUS_DMA_ALLOCNOW
- define appropriate macro for offsets and addresses of DMA descriptors
- define struct vge_txsoft and vge_rxsoft, and put common data for
each descriptor into them
- remove struct vge_list_data and move its members into struct vge_softc
- remove #ifdef DEVICE_POLLING code we don't support
- merge vge_[tr]x_list_init() functions into vge_init()
- use aprint_error() to print errors
- put splnet(9) where appropriate and remove unused VGE_{LOCK,UNLOCK}() macro
- clear TX timeout only if there is no pending descriptor
- check dm_nsegs properly otherwise padding short packets could fail
- prepare zero'ed DMA memory to pad short packets rather than putting
random data
- fix a wrong VGE_TXDESCSYNC() usage which should be VGE_TXFRAGSYNC()

Tested on my i386 which is my development machine.
(more bus_dmamap_sync(9) cleanup will be done later)
 1.20 21-Oct-2006  tsutsui Fix hardware VLAN tagging support on vge(4):

- On TX, vge(4) seems to assume that tags are written in little endian.
We already use htole32() to write values into descriptors,
so extra byteswap by htons() is not needed there.

- On RX, vge(4) seems to store tags in network byteorder.
We have to swap byteorder regardless of host's byteorder
(i.e. we have to use bswap16() rather than ntohs())
because we already use le32toh() to read values from descriptors.

Anyway, no need to use htons()/ntohs() because there is no stream data.

Tested on both i386 and macppc, and OK'ed by Pavel Cahyna.
 1.19 17-Oct-2006  tsutsui Fix a typo in comment.
 1.18 15-Oct-2006  tsutsui In vge_newbuf(), don't adjust packet length twice by m_adj(9)
in case of __NO_STRICT_ALIGNMENT. We can adjust m_data directly
since it's allocated by MCLGET(9) just above.
(though the length is not used anyway)
 1.17 15-Oct-2006  tsutsui Umm, remove a DELAY() added in previous. It seems to cause another problem.
 1.16 15-Oct-2006  tsutsui On sgimips (R5000 O2), it seems that the first EEPROM read data
right after vge_reset() could be corrupted. For workaround, add a
dummy EEPROM read in vge_reset() so that MAC address is properly
set on the machine.
While here, add a DELAY() in busy loop in vge_read_eeprom().
 1.15 14-Oct-2006  tsutsui - use MGETHDR() and MCLGET() rather than m_gethdr() and m_clget()
- KNF, ANSIfy, remove register decls
- some more cosmetics
 1.14 14-Oct-2006  tsutsui - call bus_dmamap_sync() properly (sigh)
- merge vge_dma_map_rx_desc() and vge_dma_map_tx_desc() into callers
- declare DMA descs volatile
- remove unused macro/declarations
- bzero -> memset
- some more cosmetics
 1.13 14-Oct-2006  tsutsui - use correct dmamap size for TX/RX DMA descriptors
- use __NO_STRICT_ALIGNMENT directly rather than local VGE_FIXUP_RX
- no need to use BUS_DMA_ALLOCNOW
- remove unneeded members from softc

XXX: Is vge_fixup_rx() really more efficient than memmove(9),
XXX: or allocating a new buffer and memcpy(9) into it?
XXX: Anyway, vge(4) is not recommended for non-x86 hosts at all
XXX: because it requires copying buffers by CPU on RX.
 1.12 14-Oct-2006  tsutsui Umm, set Ethernet address into softc properly.
 1.11 14-Oct-2006  tsutsui - fix eeprom read function so that MAC address can be read correctly
on big endian machines
- add some missed byteswap functions for DMA descriptors
 1.10 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9 08-Mar-2006  lukem branches: 1.9.10; 1.9.12;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.8 24-Dec-2005  perry branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 21-Nov-2005  martin This driver does only access the bus_space_tag via bus_space_* functions,
so there is no need to map it linear. From Garrett D'Amore in
PR kern/32137.
 1.6 08-Sep-2005  christos branches: 1.6.6;
PR/31130: FUKAUMI Naoki: Fix vge(4) SIOC{ADD,DEL}MULTI handling
 1.5 02-May-2005  yamt branches: 1.5.2;
split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.4 05-Mar-2005  jdolecek branches: 1.4.2; 1.4.4; 1.4.6;
g/c debugging printf
 1.3 05-Mar-2005  jdolecek modify vge_m_defrag() to support > MCLBYTES chains, by allocating appropriate
number of mbuf clusters; also don't free the original mbuf chain

simplify vge_encap() and make error reporting more consistent

normalize vge_start() (including use of IFQ_* macros), and handle the case
when the input mbuf chain is defragmented

JUMBO packets seem to work fine now
 1.2 27-Feb-2005  perry branches: 1.2.2;
nuke trailing whitespace
 1.1 20-Feb-2005  jdolecek Add device driver support for the VIA Networking Technologies VT6122
gigabit ethernet chip and integrated 10/100/1000 copper PHY.

Obtained from: FreeBSD
 1.2.2.5 11-Dec-2005  christos Sync with head.
 1.2.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.3 08-Mar-2005  skrll Sync with HEAD.
 1.2.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.1 27-Feb-2005  skrll file if_vge.c was added on branch ktrace-lwp on 2005-03-04 16:45:19 +0000
 1.4.6.2 29-Apr-2005  kent sync with -current
 1.4.6.1 05-Mar-2005  kent file if_vge.c was added on branch kent-audio2 on 2005-04-29 11:29:06 +0000
 1.4.4.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1 05-Mar-2005  yamt file if_vge.c was added on branch yamt-km on 2005-03-19 08:35:11 +0000
 1.4.2.1 11-Sep-2005  tron Pull up following revision(s) (requested by christos in ticket #756):
sys/dev/pci/if_vge.c: revision 1.6
PR/31130: FUKAUMI Naoki: Fix vge(4) SIOC{ADD,DEL}MULTI handling
 1.5.2.6 11-Feb-2008  yamt sync with head.
 1.5.2.5 21-Jan-2008  yamt sync with head
 1.5.2.4 27-Oct-2007  yamt sync with head.
 1.5.2.3 03-Sep-2007  yamt sync with head.
 1.5.2.2 30-Dec-2006  yamt sync with head.
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Nov-2005  yamt sync with head.
 1.8.10.1 19-Apr-2006  elad sync with head.
 1.8.8.1 13-Mar-2006  yamt sync with head.
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.12.2 10-Dec-2006  yamt sync with head.
 1.9.12.1 22-Oct-2006  yamt sync with head
 1.9.10.2 12-Jan-2007  ad Sync with head.
 1.9.10.1 18-Nov-2006  ad Sync with head.
 1.33.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.33.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.33.2.1 18-Jun-2007  liamjfoy Pull up following revision(s) (requested by tsutsui in ticket #731):
sys/dev/pci/if_vge.c: revision 1.35
Fix one more bug I introduced in rev 1.21:
Clear sc->sc_rx_consumed before allocating RX mbufs by vge_newbuf()
in vge_intr() otherwise vge_newbuf() might get KASSERT() failure
on DIAGNOSTIC kernel when the interface is reinitialized during RX.
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.4 23-Oct-2007  ad Sync with head.
 1.34.2.3 09-Oct-2007  ad Sync with head.
 1.34.2.2 15-Jul-2007  ad Sync with head.
 1.34.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.36.8.2 23-Mar-2008  matt sync with HEAD
 1.36.8.1 06-Nov-2007  matt sync with HEAD
 1.36.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.36.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.36.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.37.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.38.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.38.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.40.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.40.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.14.4 07-Dec-2008  bouyer Pull up following revision(s) (requested by joerg in ticket #143):
sys/dev/pci/if_vge.c: revision 1.43 via patch
- ifconfig down support
- ALTQ support
 1.41.14.3 30-Nov-2008  bouyer Back out ticket 143, it doesn't build.
 1.41.14.2 30-Nov-2008  bouyer Apply patch, requested by joerg in ticket 143:
Fix build failure, vge_stop() needs 2 arguments in netbsd-5.
 1.41.14.1 29-Nov-2008  bouyer Pull up following revision(s) (requested by joerg in ticket #143):
sys/dev/pci/if_vge.c: revision 1.43
- ifconfig down support
- ALTQ support
 1.41.12.2 03-Mar-2009  skrll Sync with HEAD.
 1.41.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.41.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.41.4.5 11-Aug-2010  yamt sync with head.
 1.41.4.4 11-Mar-2010  yamt sync with head
 1.41.4.3 16-Sep-2009  yamt sync with head
 1.41.4.2 16-May-2009  yamt sync with head
 1.41.4.1 04-May-2009  yamt sync with head.
 1.43.4.2 23-Jul-2009  jym Sync with HEAD.
 1.43.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.1 30-May-2010  rmind sync with head
 1.50.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.12.1 18-Feb-2012  mrg merge to -current.
 1.51.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.51.8.2 30-Oct-2012  yamt sync with head
 1.51.8.1 17-Apr-2012  yamt sync with head
 1.53.2.3 03-Dec-2017  jdolecek update from HEAD
 1.53.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.2.1 23-Jun-2013  tls resync from head
 1.54.4.1 18-May-2014  rmind sync with head
 1.56.6.3 05-Feb-2017  skrll Sync with HEAD
 1.56.6.2 09-Jul-2016  skrll Sync with HEAD
 1.56.6.1 19-Mar-2016  skrll Sync with HEAD
 1.58.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.60.8.3 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1406):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.60.8.2 13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.60.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.62.2.4 26-Jan-2019  pgoyette Sync with HEAD
 1.62.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.62.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.62.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.63.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.63.2.1 10-Jun-2019  christos Sync with HEAD
 1.73.2.2 25-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #477):

sys/dev/pci/if_vge.c: revision 1.76
sys/dev/pci/if_vge.c: revision 1.77

Fixes a bug that "ifmedia vge0 media 1000baseT-FDX" causes device timeout.

If the interface's media is NOT in the "best" mode (i.e. other than IFM_AUTO),
control VGE_DIAGCTL_GMII bit.

- Set duplex correctly when user setting is not IFM_AUTO.
- When the link is up, set VGE_DIAGCTL not from user media setting but from
the current active link status.
 1.73.2.1 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #345):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.78.2.1 29-Feb-2020  ad Sync with head.
 1.80.8.1 01-Aug-2021  thorpej Sync with HEAD.
 1.88.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.7 26-Aug-2021  andvar Add missing RCSID in header files and one __KERNEL_RCSID().
 1.6 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.5 08-Oct-2019  msaitoh branches: 1.5.12;
Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.4 11-Jul-2019  msaitoh branches: 1.4.2;
Fix typo (s/supress/suppress/).
 1.3 31-Oct-2006  tsutsui branches: 1.3.134; 1.3.142;
Make vge(4) look a NetBSD native driver like pcn(4) or epic(4) etc:
- merge if_vgevar.h into if_vge.c since no other file refers it
- rename some macro (VGE_TX_DESC_CNT -> VGE_NTXDESC etc.) and structs
- change prefixes of structure members to represent parents
- put TX and RX descriptors into single struct vge_control_data and
allocate DMA memory at once
- no need to specify BUS_DMA_ALLOCNOW
- define appropriate macro for offsets and addresses of DMA descriptors
- define struct vge_txsoft and vge_rxsoft, and put common data for
each descriptor into them
- remove struct vge_list_data and move its members into struct vge_softc
- remove #ifdef DEVICE_POLLING code we don't support
- merge vge_[tr]x_list_init() functions into vge_init()
- use aprint_error() to print errors
- put splnet(9) where appropriate and remove unused VGE_{LOCK,UNLOCK}() macro
- clear TX timeout only if there is no pending descriptor
- check dm_nsegs properly otherwise padding short packets could fail
- prepare zero'ed DMA memory to pad short packets rather than putting
random data
- fix a wrong VGE_TXDESCSYNC() usage which should be VGE_TXFRAGSYNC()

Tested on my i386 which is my development machine.
(more bus_dmamap_sync(9) cleanup will be done later)
 1.2 14-Oct-2006  tsutsui - call bus_dmamap_sync() properly (sigh)
- merge vge_dma_map_rx_desc() and vge_dma_map_tx_desc() into callers
- declare DMA descs volatile
- remove unused macro/declarations
- bzero -> memset
- some more cosmetics
 1.1 20-Feb-2005  jdolecek branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10; 1.1.38; 1.1.40;
Add device driver support for the VIA Networking Technologies VT6122
gigabit ethernet chip and integrated 10/100/1000 copper PHY.

Obtained from: FreeBSD
 1.1.40.2 10-Dec-2006  yamt sync with head.
 1.1.40.1 22-Oct-2006  yamt sync with head
 1.1.38.1 18-Nov-2006  ad Sync with head.
 1.1.10.1 30-Dec-2006  yamt sync with head.
 1.1.8.2 29-Apr-2005  kent sync with -current
 1.1.8.1 20-Feb-2005  kent file if_vgereg.h was added on branch kent-audio2 on 2005-04-29 11:29:06 +0000
 1.1.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 20-Feb-2005  yamt file if_vgereg.h was added on branch yamt-km on 2005-03-19 08:35:11 +0000
 1.1.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.1 20-Feb-2005  skrll file if_vgereg.h was added on branch ktrace-lwp on 2005-03-04 16:45:19 +0000
 1.3.142.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.134.1 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1406):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.4.2.1 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #345):

sys/dev/pci/if_vgereg.h: revision 1.5
sys/dev/pci/if_vge.c: revision 1.75

Copy vge_clrwol() from FreeBSD and call it in vge_attach() to recover from
powerdown mode. Fixes PR kern/41525 reported by Aran Clauson.
 1.5.12.1 01-Aug-2021  thorpej Sync with HEAD.
 1.7 31-Oct-2006  tsutsui This has been megered into if_vge.c.
 1.6 15-Oct-2006  tsutsui Oops, use correct dmamap to sync DMA descriptors.
Found by DIAGNOSTIC code in sgimips/bus.c:_bus_dmamap_sync_mips3().
 1.5 14-Oct-2006  tsutsui - use MGETHDR() and MCLGET() rather than m_gethdr() and m_clget()
- KNF, ANSIfy, remove register decls
- some more cosmetics
 1.4 14-Oct-2006  tsutsui - call bus_dmamap_sync() properly (sigh)
- merge vge_dma_map_rx_desc() and vge_dma_map_tx_desc() into callers
- declare DMA descs volatile
- remove unused macro/declarations
- bzero -> memset
- some more cosmetics
 1.3 14-Oct-2006  tsutsui - use correct dmamap size for TX/RX DMA descriptors
- use __NO_STRICT_ALIGNMENT directly rather than local VGE_FIXUP_RX
- no need to use BUS_DMA_ALLOCNOW
- remove unneeded members from softc

XXX: Is vge_fixup_rx() really more efficient than memmove(9),
XXX: or allocating a new buffer and memcpy(9) into it?
XXX: Anyway, vge(4) is not recommended for non-x86 hosts at all
XXX: because it requires copying buffers by CPU on RX.
 1.2 01-Oct-2005  jdolecek branches: 1.2.26; 1.2.28;
VGE_FIXUP_RX is not needed on amd64, disable it for all non-strict
alignment architectures

fix ETHER_ALIGN to 2 (same value as on FreeBSD) - appears VGE_FIXUP_RX
code cuts part of packet otherwise; also add comment about it's purpose

PR: 31323 by Murata Shuuichirou
 1.1 20-Feb-2005  jdolecek branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
Add device driver support for the VIA Networking Technologies VT6122
gigabit ethernet chip and integrated 10/100/1000 copper PHY.

Obtained from: FreeBSD
 1.1.10.2 30-Dec-2006  yamt sync with head.
 1.1.10.1 21-Jun-2006  yamt sync with head.
 1.1.8.2 29-Apr-2005  kent sync with -current
 1.1.8.1 20-Feb-2005  kent file if_vgevar.h was added on branch kent-audio2 on 2005-04-29 11:29:06 +0000
 1.1.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 20-Feb-2005  yamt file if_vgevar.h was added on branch yamt-km on 2005-03-19 08:35:11 +0000
 1.1.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.1 20-Feb-2005  skrll file if_vgevar.h was added on branch ktrace-lwp on 2005-03-04 16:45:19 +0000
 1.2.28.2 10-Dec-2006  yamt sync with head.
 1.2.28.1 22-Oct-2006  yamt sync with head
 1.2.26.1 18-Nov-2006  ad Sync with head.
 1.115 15-Jul-2025  ozaki-r vioif: count tx pcq full
 1.114 14-Feb-2025  joe use right byte size of data resource to be freed instead of sizeof pointer

use of sizeof pointer frees only 8 bytes of the large vioif_tx_context struct
which leaks the rest of the memory
 1.113 10-Nov-2024  mlelstv Add MBUFTRACE
 1.112 29-Jun-2024  riastradh branches: 1.112.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.111 21-Mar-2024  isaki Ensure that the number of bus_dma segments doesn't exceed VirtIO queue size.
This fixes reproducible panics when the host's VirtIO queue size is too small,
less than or equal to VIRTIO_NET_TX_MAXNSEGS(=16).
PR kern/58049.
 1.110 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.109 13-May-2023  andvar fix typos in comments.
 1.108 11-May-2023  yamaguchi Fix missing check for netq->netq_stopping in vioif_rx_intr()

Reported-by: syzbot+5120b7a1f97a3f5ca052@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=243cf4115808e49774a49294f63200770399660b
 1.107 27-Mar-2023  nakayama Use PRIuBUSSIZE to print bus_size_t variables.
 1.106 24-Mar-2023  yamaguchi vioif(4): fix wrong memory allocation size
 1.105 23-Mar-2023  yamaguchi vioif(4): clear flags when configure is failed
 1.104 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.103 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.102 23-Mar-2023  yamaguchi vioif(4): divide IFF_OACTIVE into per-queue
 1.101 23-Mar-2023  yamaguchi vioif(4): reorganize functions

iThis change is move of function and rename,
and this is no functional change.
 1.100 23-Mar-2023  yamaguchi vioif(4): rename sc_hdr_segs to sc_segs
 1.99 23-Mar-2023  yamaguchi vioif(4): added functions to manipulate network queues
 1.98 23-Mar-2023  yamaguchi vioif(4): added new data structure for network queues

and moved the same parameters in vioif_txqueue and
vioif_rxqueue into the new structure
 1.97 23-Mar-2023  yamaguchi vioif(4): added __predct_false to error check
 1.96 23-Mar-2023  yamaguchi vioif(4): prepare slot before dequeuing
 1.95 23-Mar-2023  yamaguchi vioif(4): added a structure to manage variables for packet processings
 1.94 23-Mar-2023  yamaguchi vioif(4): increase output error counter
 1.93 23-Mar-2023  yamaguchi vioif(4): merge drain into clear of queue
 1.92 23-Mar-2023  yamaguchi vioif(4): divide interrupt handler for receiving
into dequeuing and preparing of buffers
 1.91 23-Mar-2023  yamaguchi vioif(4): drain receive buffer on stopping the device
to remove branch in vioif_populate_rx_mbufs_locked()
 1.90 23-Mar-2023  yamaguchi vioif(4): fix missing virtio_enqueue_abort for error handling
 1.89 23-Mar-2023  yamaguchi vioif(4): added event counters related to receive processing
 1.88 23-Mar-2023  yamaguchi vioif(4): adjust receive buffer to ETHER_ALIGN
 1.87 23-Mar-2023  yamaguchi vioif(4): stop interrupt before schedule handler
 1.86 23-Mar-2023  yamaguchi vioif(4): rename {txq,rxq}_active to {txq,rxq}_running_handle
 1.85 23-Mar-2023  yamaguchi vioif(4): use device reset to stop interrupt completely
 1.84 23-Mar-2023  yamaguchi vioif(4): access to txq_active and rxq_active with lock held
 1.83 23-Mar-2023  yamaguchi vioif(4): remove unnecessary lock release

if_percpuq_enqueue() can call with rxq->rxq_lock held because of per-cpu.
 1.82 12-Sep-2022  knakahara branches: 1.82.4;
Uniform vioif's link status to if_link_state. Implemented by yamaguchi@n.o.

Let vioif(4) know LINK_STATE_UNKNOWN.
 1.81 04-May-2022  simonb White space KNF nits.
 1.80 16-Apr-2022  andvar fix various typos in comments and log messages.
 1.79 13-Apr-2022  uwe virtio: use the new syntax for snprintb(3) format strings.

The old syntax is limited to 32 bits only (and has 1-based bit numbers
which is rather incovenient too).
 1.78 13-Apr-2022  yamaguchi vioif(4): issue VIRTIO_NET_CTRL_MAC_ADDR_SET command only when
VIRTIO_NET_F_CTRL_MAC_ADDR is negotiated
 1.77 31-Mar-2022  yamaguchi vioif(4): remove unnecessary lock acquirement

The lock was hold to wait for completion of interrupt handlers.
But, they are already stopped by rxq_stopping and txq_stopping
flags.

pointed out by riastradh@n.o, thanks.
 1.76 29-Mar-2022  yamaguchi vioif(4): Added a comment about stopping packet processing
 1.75 24-Mar-2022  yamaguchi vioif(4): adopt ether_set_ifflags_cb
 1.74 24-Mar-2022  yamaguchi vioif(4): register MAC address to a device
 1.73 24-Mar-2022  yamaguchi vioif(4): fix missing error handling
 1.72 24-Mar-2022  yamaguchi vioif(4): do not schedule packet processing while stopping the device
 1.71 28-Oct-2021  yamaguchi virtio: stop reinit for safety when a device resetting is failed
 1.70 08-Feb-2021  skrll Trailing whitespace
 1.69 03-Feb-2021  reinoud Oops, made a mistake in my last commit
 1.68 03-Feb-2021  reinoud Allocate enough space for the bus_dmamap_t arrays for rxq_hdr_dmamaps[] and
txq_hdr_maps[]
 1.67 31-Jan-2021  reinoud Although the header structure can be smaller, the headers *are* indexed as if
they are full sized so allocate enough memory so the indexing works as
expected and we are not scribbling outside bounds.
 1.66 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.65 28-May-2020  riastradh branches: 1.65.2;
Allocate proper storage for the event counter group names.

Can't use a stack buffer for these because the evcnt remembers the
pointer!
 1.64 25-May-2020  yamaguchi Stop all processing related to rx before that related to tx for safety
 1.63 25-May-2020  yamaguchi Use evcnt(9) to record error status in vioif(4)
 1.62 25-May-2020  yamaguchi Introduce the lock for vioif_softc to avoid a race condition
in vioif_update_link_status()

The function is called in both vioif_init() and softint.
 1.61 25-May-2020  yamaguchi Populate mbufs in the packet receiving process, not in a softint
 1.60 25-May-2020  yamaguchi Always hold tx lock in deferred transmit to send all packets

There may be packets that enqueued before another transmission
releases the lock after finish of its transmission.
When using mutex_try_enter(), vioif_deferred_transmit() can not
sends them.

pointed out by knakahara@n.o
 1.59 25-May-2020  yamaguchi Remove redundant checks.
There is the same check in vioif_send_common_locked()
 1.58 25-May-2020  yamaguchi Replace macros with static functions for refactoring
 1.57 25-May-2020  yamaguchi Fix typo in comments
 1.56 25-May-2020  yamaguchi Fix the wrong segment size in vioif(4)
 1.55 25-May-2020  yamaguchi Introduce packet handling in softint or kthread for vioif(4)
 1.54 25-May-2020  yamaguchi Set handlers implemented in child device of virtio(4) to virtqueue
instead of the commonized function
 1.53 25-May-2020  yamaguchi Obsolete VIOIF_SOFTINT_INTR

The kernel option is introduced to realize softint-based if_input.
Since the same scheme has been implemented in if_percpuq_enqueue(),
the option is no longer needed.

pointed out by ozaki-r@n.o.
 1.52 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.51 01-Oct-2019  chs branches: 1.51.2;
in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.50 14-Sep-2019  christos - KNF
- fix typo in error message
- use aprint* everywhere
- use loops to initialize mac
- remove unused variables
 1.49 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.48 23-May-2019  msaitoh -No functional change:
- Simplify struct ethercom's pointer near ETHER_FIRST_MULTI().
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.47 04-Feb-2019  yamaguchi Do not call virtio_start_vq_intr() for ctrlq
unless the iface has a control queue
 1.46 14-Jan-2019  yamaguchi Add multiqueue support, vioif(4)
 1.45 14-Jan-2019  yamaguchi Set IFEF_MPSAFE flag
 1.44 14-Jan-2019  yamaguchi Functionize the same code related to ctrl vq in vioif(4)
 1.43 14-Jan-2019  yamaguchi Divide some elements of vioif_softc into txq, rxq, and ctrlq
 1.42 14-Jan-2019  yamaguchi Make macros not depend on vioif_softc
 1.41 26-Jun-2018  msaitoh branches: 1.41.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.40 10-Jun-2018  jakllsch remove irrelevant pci(9) #includes from virtio child drivers
 1.39 08-Feb-2018  dholland branches: 1.39.2;
Typos.
 1.38 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.37 17-May-2017  jdolecek more precise m_freem() on error paths, and update m after the m_defrag() call
 1.36 17-May-2017  jdolecek simplify vioif_start() - remove the delivery attempts on failure and retries,
leave that for the dedicated thread

if dma map load fails, retry after m_defrag(), but continue processing
other queue items regardless

set interface queue length according to the length of virtio queue, so that
higher layer won't queue more than interface can manage to keep in flight

use the mutexes always, not just with NET_MPSAFE, so they continue
being exercised and hence working; they also enforce proper IPL level

inspired by discussion around PR kern/52211, thanks to Masanobu SAITOH
for the m_defrag() idea and code
 1.35 17-May-2017  jdolecek do not set IFF_OACTIVE if dma map load or the virtio reserve fails;
this causes interface to ignore any further TX requests if this happens
when there are no other TX requests in progress

fixes kern/52211 by Juergen Hannken-Illjes
 1.34 28-Mar-2017  ozaki-r branches: 1.34.4;
Handle config change interrupts to inhibit sending packets while link down

PR kern/52103 by s-yamaguchi@IIJ
 1.33 28-Mar-2017  ozaki-r Don't write to read-only VIRTIO_NET_S_LINK_UP bit

The bit is defined as read-only in the Virtio PCI Card Specification.
The fix is inspired by FreeBSD.

PR kern/52103 by s-yamaguchi@IIJ
 1.32 25-Mar-2017  jdolecek reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.31 17-Jan-2017  ozaki-r Fix unlocking in vioif_rx_filter
 1.30 28-Dec-2016  ozaki-r branches: 1.30.2;
Protect ec_multi* with mutex

The data can be accessed from sysctl, ioctl, interface watchdog
(if_slowtimo) and interrupt handlers. We need to protect the data against
parallel accesses from them.

Currently the mutex is applied to some drivers, we need to apply it to all
drivers in the future.

Note that the mutex is adaptive one for ease of implementation but some
drivers access the data in interrupt context so we cannot apply the mutex
to every drivers as is. We have two options: one is to replace the mutex
with a spin one, which requires some additional works (see
ether_multicast_sysctl), and the other is to modify the drivers to access
the data not in interrupt context somehow.
 1.29 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.28 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.27 29-Nov-2016  uwe vioif_start() - do not call virtio_enqueue_abort() after error from
virtio_enqueue_reserve(), as it's already done by the latter, so we
ended up with a kind of "double free" that messed up out free list of
vq_entry's.

This is even documented in a "typical usage" comment in virtio.c (and
those quotes are not intended to be sarcastic).

PR 51132 - virtio net device stuck for UDP burst transmission
 1.26 27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.25 29-Aug-2016  ozaki-r Fix initializing wrong queues

Pointed out by Mike Larkin.

PR kern/51448
 1.24 10-Jun-2016  ozaki-r branches: 1.24.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.23 17-May-2016  pooka Try to get more packets going if the transmit interrupt indicates
some were sent. Doing so avoids a situation where vioif_start never
gets called in case the sendqueue fills up and therefore the interface
perpetually drops all packets due to the queue being full.
(not sure why all drivers need to do this themselves; just keeping
up with the joneses)

Problem reported and patch tested by jmmlmendes and yasukata at
repo.rumpkernel.org/rumprun
 1.22 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.21 10-Jan-2016  christos PR/50636: Ryo ONODERA: Reduce memory use
 1.20 29-Oct-2015  christos simplify
 1.19 29-Oct-2015  ozaki-r Name virtqueue index
 1.18 27-Oct-2015  christos - Print the negotiated feature bits.
- Use aprint_error_dev on error, instead of printf
- Add missing abort call.
 1.17 26-Oct-2015  ozaki-r Support MSI-X in virtio

Currently only vioif(4) uses the feature.

knakahara@ helped to migrate to pci_intr_alloc(9). Thanks!
 1.16 05-May-2015  ozaki-r Use NULL for initialization of sc_config_change
 1.15 16-Jan-2015  ozaki-r Introduce defflag for NET_MPSAFE
 1.14 25-Dec-2014  ozaki-r Reuse mbuf when retrying in vioif_start

Otherwise, the old mbuf will leak.
 1.13 24-Dec-2014  ozaki-r Take TX/RX locks when sc_stopping = true in if_stop

Taking the locks is needed to ensure ongoing TX/RX operations finish.
Otherwise, if_stop may run during TX/RX operations.
 1.12 19-Dec-2014  ozaki-r Implement softint-based interrupt handling in if_vioif

Softint-based interrupt handling is considered as a future direction
of the (network) device driver architecture in NetBSD. pq3etsec of
ppc is already implemented based on the architecture (unlike pq3etsec,
this change doesn't include softint-based if_start). In this
architecture, a hardware interrupt handler just schedules a softint
and the softint performs actual interrupt processing. It reduces
processing in hardware interrupt context and allows Layer 2 network
stack (e.g., bridge, vlan and even bpf) run in softint context,
which makes it easy to implement fine-grain locking in the layer.

This is an experimental implementation of the architecture in if_viof.

virtio introduces a new flag VIRTIO_F_PCI_INTR_SOFTINT. If a driver
of virtio sets it to sc_flags of virtio_softc, virtio calls
softint_schedule in virtio_intr instead of directly calling the
interrupt handler of the driver.

When VIOIF_SOFTINT_INTR is on, vioif doesn't use the existing softint
(vioif_rx_softint) that is called from vioif_rx_vq_done. Because
vioif_rx_softint already runs in softint context and another softint
isn't needed. This change actually improves performance in some cases.

The feature is disabled by default and enabled when SOFTINT_INTR is
set somewhere (normally in a kernel configuration).
 1.11 09-Oct-2014  ozaki-r branches: 1.11.2;
Add ETHERCAP_VLAN_MTU capability to vioif
 1.10 08-Oct-2014  ozaki-r Add missing semicolon
 1.9 08-Oct-2014  ozaki-r Don't turn promisc off in vioif_deferred_init if already configured as promisc
 1.8 13-Aug-2014  pooka Don't use config_deferred_interrupts() for vioif_deferred_init(),
just run it once as part of if_init(). The problem with the former
is that it will execute the deferred init routine in-place when !cold,
and since vioif_deferred_init() finishing depends on virtio interrupts
which are established only after config_deferred_interrupts() is called,
the vioif attach method would deadlock when !cold.
 1.7 22-Jul-2014  ozaki-r branches: 1.7.2;
Make if_vioif MPSAFE

- Introduce VIOIF_MPSAFE
- It's enabled only when NET_MPSAFE is defined in if.h or the kernel config
- Add tx and rx mutex locks
- Locking them is performance sensitive, so it's not used when !VIOIF_MPSAFE
- Set SOFTINT_MPSAFE to vioif_rx_softint only when VIOIF_MPSAFE
 1.6 22-Jul-2014  ozaki-r Introduce VIRTIO_F_PCI_INTR_MPSAFE for virtio

It is set by a child driver, e.g., if_vioif. If set, virtio sets
PCI_INTR_MPSAFE for pci_intr_establish.
 1.5 18-Jul-2014  ozaki-r Don't set SOFTINT_MPSAFE to vioif_rx_softint

vioif_rx_softint calls vioif_populate_rx_mbufs that is not MPSAFE.
vioif_populate_rx_mbufs is also called via vioif_ioctl and so can
be called by two LWPs simultaneously, resulting in kernel panic.

PR kern/49007
 1.4 09-May-2013  minoura branches: 1.4.6;
Fix a typo, and remove an unused member.
This should fix the problem that recent Qemu dies during configuring a vioif.
 1.3 30-Mar-2013  christos remove trailing whitespace
 1.2 19-Nov-2011  jmcneill branches: 1.2.6; 1.2.8; 1.2.12; 1.2.14;
fix build when ALTQ is defined
 1.1 30-Oct-2011  hannken branches: 1.1.2;
Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.1.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.2.14.3 24-Sep-2016  bouyer Pull up following revision(s) (requested by ozaki-r in ticket #1401):
sys/dev/pci/if_vioif.c: revision 1.25
Fix initializing wrong queues
Pointed out by Mike Larkin.
PR kern/51448
 1.2.14.2 07-Aug-2014  msaitoh Pull up following revision(s) (requested by ozaki-r in ticket #1102):
sys/dev/pci/if_vioif.c: revision 1.5
Don't set SOFTINT_MPSAFE to vioif_rx_softint
vioif_rx_softint calls vioif_populate_rx_mbufs that is not MPSAFE.
vioif_populate_rx_mbufs is also called via vioif_ioctl and so can
be called by two LWPs simultaneously, resulting in kernel panic.
PR kern/49007
 1.2.14.1 12-May-2013  riz Pull up following revision(s) (requested by minoura in ticket #890):
sys/dev/pci/if_vioif.c: revision 1.4
Fix a typo, and remove an unused member.
This should fix the problem that recent Qemu dies during configuring a vioif.
 1.2.12.3 03-Dec-2017  jdolecek update from HEAD
 1.2.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.12.1 23-Jun-2013  tls resync from head
 1.2.8.3 24-Sep-2016  bouyer Pull up following revision(s) (requested by ozaki-r in ticket #1401):
sys/dev/pci/if_vioif.c: revision 1.25
Fix initializing wrong queues
Pointed out by Mike Larkin.
PR kern/51448
 1.2.8.2 07-Aug-2014  msaitoh Pull up following revision(s) (requested by ozaki-r in ticket #1102):
sys/dev/pci/if_vioif.c: revision 1.5
Don't set SOFTINT_MPSAFE to vioif_rx_softint
vioif_rx_softint calls vioif_populate_rx_mbufs that is not MPSAFE.
vioif_populate_rx_mbufs is also called via vioif_ioctl and so can
be called by two LWPs simultaneously, resulting in kernel panic.
PR kern/49007
 1.2.8.1 12-May-2013  riz branches: 1.2.8.1.2;
Pull up following revision(s) (requested by minoura in ticket #890):
sys/dev/pci/if_vioif.c: revision 1.4
Fix a typo, and remove an unused member.
This should fix the problem that recent Qemu dies during configuring a vioif.
 1.2.8.1.2.2 24-Sep-2016  bouyer Pull up following revision(s) (requested by ozaki-r in ticket #1401):
sys/dev/pci/if_vioif.c: revision 1.25
Fix initializing wrong queues
Pointed out by Mike Larkin.
PR kern/51448
 1.2.8.1.2.1 07-Aug-2014  msaitoh Pull up following revision(s) (requested by ozaki-r in ticket #1102):
sys/dev/pci/if_vioif.c: revision 1.5
Don't set SOFTINT_MPSAFE to vioif_rx_softint
vioif_rx_softint calls vioif_populate_rx_mbufs that is not MPSAFE.
vioif_populate_rx_mbufs is also called via vioif_ioctl and so can
be called by two LWPs simultaneously, resulting in kernel panic.
PR kern/49007
 1.2.6.3 09-Jun-2013  msaitoh Pull up following revision(s) (requested by minoura in ticket #1861):
sys/dev/pci/if_vioif.c: revision 1.4
Fix a typo, and remove an unused member.
This should fix the problem that recent Qemu dies during configuring a vioif.
Fixes PR#47780.
 1.2.6.2 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.2.6.1 19-Nov-2011  riz file if_vioif.c was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.4.6.1 10-Aug-2014  tls Rebase.
 1.7.2.3 23-Dec-2016  snj Pull up following revision(s) (requested by bsiegert in ticket #1337):
sys/dev/pci/if_vioif.c: revision 1.21
sys/dev/pci/virtio.c: revision 1.14
PR/50636: Ryo ONODERA: Fix incorrect kmem_free()
--
PR/50636: Ryo ONODERA: Reduce memory use
 1.7.2.2 18-Sep-2016  snj Pull up following revision(s) (requested by ozaki-r in ticket #1244):
sys/dev/pci/if_vioif.c: revision 1.25
Fix initializing wrong queues
Pointed out by Mike Larkin.
PR kern/51448
 1.7.2.1 29-Dec-2014  martin branches: 1.7.2.1.2; 1.7.2.1.4;
Pull up following revision(s) (requested by ozaki-r in ticket #354):
sys/dev/pci/if_vioif.c: revision 1.14
Reuse mbuf when retrying in vioif_start
Otherwise, the old mbuf will leak.
 1.7.2.1.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.7.2.1.2.1 18-Sep-2016  snj Pull up following revision(s) (requested by ozaki-r in ticket #1244):
sys/dev/pci/if_vioif.c: revision 1.25
Fix initializing wrong queues
Pointed out by Mike Larkin.
PR kern/51448
 1.11.2.10 28-Aug-2017  skrll Sync with HEAD
 1.11.2.9 05-Feb-2017  skrll Sync with HEAD
 1.11.2.8 05-Dec-2016  skrll Sync with HEAD
 1.11.2.7 05-Oct-2016  skrll Sync with HEAD
 1.11.2.6 09-Jul-2016  skrll Sync with HEAD
 1.11.2.5 29-May-2016  skrll Sync with HEAD
 1.11.2.4 19-Mar-2016  skrll Sync with HEAD
 1.11.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.11.2.2 06-Jun-2015  skrll Sync with HEAD
 1.11.2.1 06-Apr-2015  skrll Sync with HEAD
 1.24.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.24.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.24.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.30.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.34.4.1 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.39.2.3 18-Jan-2019  pgoyette Synch with HEAD
 1.39.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.39.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.41.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.41.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.41.2.1 10-Jun-2019  christos Sync with HEAD
 1.51.2.1 29-Feb-2020  ad Sync with head.
 1.65.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.82.4.6 22-Feb-2025  martin Pull up following revision(s) (requested by joe in ticket #1055):

sys/dev/pci/if_vioif.c: revision 1.114

PR kern/59086:
use right byte size of data resource to be freed instead of sizeof pointer
use of sizeof pointer frees only 8 bytes of the large vioif_tx_context struct
which leaks the rest of the memory
 1.82.4.5 07-Aug-2024  martin Pull up following revision(s) (requested by isaki in ticket #772):

sys/dev/pci/if_vioif.c: revision 1.111

Ensure that the number of bus_dma segments doesn't exceed VirtIO queue size.

This fixes reproducible panics when the host's VirtIO queue size is too small,
less than or equal to VIRTIO_NET_TX_MAXNSEGS(=16).

PR kern/58049.
 1.82.4.4 07-Aug-2024  martin Pull up following revision(s) (requested by rin in ticket #770):

sys/dev/pci/if_vioif.c: revision 1.108

Fix missing check for netq->netq_stopping in vioif_rx_intr()
 1.82.4.3 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.82.4.2 01-Apr-2023  martin Additionally pull up the following for ticket #128 to fix the build:

sys/dev/pci/if_vioif.c: revision 1.107
sys/dev/pci/virtio.c: revision 1.71

Use PRIuBUSSIZE to print bus_size_t variables.
 1.82.4.1 30-Mar-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #128):

sys/dev/pci/if_vioif.c: revision 1.83-1.102,1.105,1.106

vioif(4): remove unnecessary lock release
if_percpuq_enqueue() can call with rxq->rxq_lock held because of per-cpu.

vioif(4): access to txq_active and rxq_active with lock held

vioif(4): use device reset to stop interrupt completely

vioif(4): rename {txq,rxq}_active to {txq,rxq}_running_handle

vioif(4): stop interrupt before schedule handler

vioif(4): adjust receive buffer to ETHER_ALIGN

vioif(4): added event counters related to receive processing

vioif(4): fix missing virtio_enqueue_abort for error handling

vioif(4): drain receive buffer on stopping the device
to remove branch in vioif_populate_rx_mbufs_locked()

vioif(4): divide interrupt handler for receiving
into dequeuing and preparing of buffers

vioif(4): merge drain into clear of queue

vioif(4): increase output error counter

vioif(4): added a structure to manage variables for packet processings

vioif(4): prepare slot before dequeuing

vioif(4): added __predct_false to error check

vioif(4): added new data structure for network queues
and moved the same parameters in vioif_txqueue and
vioif_rxqueue into the new structure

vioif(4): added functions to manipulate network queues

vioif(4): rename sc_hdr_segs to sc_segs

vioif(4): reorganize functions
This change is move of function and rename,
and this is no functional change.

vioif(4): divide IFF_OACTIVE into per-queue

vioif(4): clear flags when configure is failed

vioif(4): fix wrong memory allocation size
 1.112.2.1 02-Aug-2025  perseant Sync with HEAD
 1.17 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.16 29-Jun-2024  riastradh branches: 1.16.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.15 06-Mar-2024  andvar Fix few typos in comments.
 1.14 09-Feb-2024  andvar s/incompatiable/incompatible/ in error messages.
 1.13 28-Aug-2023  msaitoh Set IFM_FDX flag if the link is up.
 1.12 10-Aug-2023  riastradh vmxnet(4): Fix various MP bugs.

- Defer reset to workqueue.
=> vmxnet3_stop_locked is forbidden in softint.
=> XXX Problem: We still take the core lock in softint, and we
still take the core lock around vmxnet3_stop_locked. TBD.
- Touch if_flags only under IFNET_LOCK.
=> Cache ifp->if_flags & IFF_PROMISC in vmxnet3_ifflags_cb.
=> Don't call vmxnet3_set_rxfilter unless up and running; cache
this as vmx_mcastactive. Use ENETRESET in vmxnet3_ifflags_cb
instead of calling vmxnet3_set_rxfilter directly.
. (The cache is currently serialized by the core lock, but it
might reasonably be serialized by an independent lock like in
usbnet(9).)
- Fix vmxnet3_stop_rendezvous so it actually does something.
=> New vxtxq_stopping, vxrxq_stopping variables synchronize with
Rx/Tx interrupt handlers.
- Sprinkle IFNET_LOCK and core lock assertions.
 1.11 16-Sep-2022  knakahara branches: 1.11.4;
It is correct to update ifp statistics per packet, just remove commented out old statistics code.

The code is commented out by if_vmx.c:r1.57.
 1.10 16-Sep-2022  knakahara Add ALWAYS_TXDEFER option to vmx(4), too.
 1.9 06-Jul-2022  msaitoh Call txeof first, then rxeof for the consistency.

There are three functions where the txeof and rxeof are called. The MSI-X
interrupt function and the workqueue function call rxeof first, then rxeof.
For legacy interrupt. rxeof is called first. Modify it to match with other
two.
 1.8 24-May-2022  msaitoh Reduce diff among vmxnet3_{legacy_intr,txrxq_intr,handle_que}(). NFCI.
 1.7 30-Mar-2022  knakahara vmxnet3_stop_rendezvous() requires workqueue_wait() to wait workqueue not scheduled yet.
 1.6 13-Feb-2022  riastradh vmx(4): Omit needless membar_sync wrapper.

Nothing uses this, and it is unlikely that any part of this driver
will need store-before-load ordering to synchronize with the host.
 1.5 13-Oct-2021  knakahara Fix vmx(4) receive workqueue problem on qemu, reported by ozaki-r@n.o, thanks.

ESXi stops interrupt by vmxnet3_disable_intr() immediately. In contrast, qemu
does not stop interrupt soon. Hmm, qemu's behavior seems not to be correct,
however, there is no explicit specification of vmxnet3. So, we have to accept
that behavior.
 1.4 15-Oct-2020  ryo Reduces useless "vmxnet3_read_cmd(sc, VMXNET3_CMD_GET_LINK)" calls
 1.3 15-Oct-2020  ryo Fixed a bug where 'ifconfig vmx0 down up' caused a failure to send.
This procedure was leaving sc->vmx_link_active = 0.

ok nakahara@
 1.2 14-Oct-2020  ryo modularize, and fix build error
 1.1 14-Oct-2020  ryo vmx(4) should be MI. moved to sys/dev/pci from sys/arch/x86/pci
 1.11.4.2 21-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #904):

sys/dev/pci/if_vmx.c: revision 1.12

vmxnet(4): Fix various MP bugs.
- Defer reset to workqueue.
=> vmxnet3_stop_locked is forbidden in softint.
=> XXX Problem: We still take the core lock in softint, and we
still take the core lock around vmxnet3_stop_locked. TBD.
- Touch if_flags only under IFNET_LOCK.
=> Cache ifp->if_flags & IFF_PROMISC in vmxnet3_ifflags_cb.
=> Don't call vmxnet3_set_rxfilter unless up and running; cache
this as vmx_mcastactive. Use ENETRESET in vmxnet3_ifflags_cb
instead of calling vmxnet3_set_rxfilter directly.
. (The cache is currently serialized by the core lock, but it
might reasonably be serialized by an independent lock like in
usbnet(9).)
- Fix vmxnet3_stop_rendezvous so it actually does something.
=> New vxtxq_stopping, vxrxq_stopping variables synchronize with
Rx/Tx interrupt handlers.
- Sprinkle IFNET_LOCK and core lock assertions.
 1.11.4.1 11-May-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #687):

sys/dev/pci/if_vmx.c: revision 1.13

Set IFM_FDX flag if the link is up.
 1.16.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 14-Oct-2020  ryo vmx(4) should be MI. moved to sys/dev/pci from sys/arch/x86/pci
 1.138 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.137 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.136 17-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.135 24-Jul-2021  andvar s/structres/structures + s/whenver/whenever
 1.134 08-May-2021  thorpej Use pci_compatible_match().
 1.133 07-Feb-2020  thorpej branches: 1.133.10;
Use callout_setfunc() / callout_schedule().
 1.132 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.131 13-Sep-2019  msaitoh branches: 1.131.2;
if_flags is neither int nor short. It's unsigned short.
 1.130 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.129 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.128 23-May-2019  msaitoh -No functional change:
- Simplify struct ethercom's pointer near ETHER_FIRST_MULTI().
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.127 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.126 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.125 18-Jul-2018  sevan Be consistent among ethernet drivers on the convention for printing ethernet
addresses.

NFC
 1.124 26-Jun-2018  msaitoh branches: 1.124.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.123 28-Feb-2018  flxd branches: 1.123.2;
Cosmetic printf/aprint changes.
Add missing return statement after failed pci_intr_establish().
 1.122 28-Feb-2018  flxd Cosmetic fix for the Physical Address Registers PAR0 to PAR5.
 1.121 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.120 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.119 14-Jul-2016  msaitoh branches: 1.119.2;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.118 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.117 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.116 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.115 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.114 10-Aug-2014  tls branches: 1.114.4;
Merge tls-earlyentropy branch into HEAD.
 1.113 29-Mar-2014  christos branches: 1.113.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.112 27-Dec-2012  jmcneill branches: 1.112.2;
- reset the chip if the tx engine gets stuck after a link state change,
from OpenBSD
- no need to do a full reset of the chip when enabling or disabling
promiscuous mode
 1.111 22-Jul-2012  matt branches: 1.111.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.110 02-Feb-2012  tls branches: 1.110.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.109 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.108 19-Nov-2011  tls branches: 1.108.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.107 16-Dec-2010  jakllsch branches: 1.107.8;
Enable ETHERCAP_VLAN_MTU in vr(4). Tested on VT6105M and VT8237R+.
May or may not work on earlier chips, for now just assume it will.
Provoked by PR#44243.
 1.106 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.105 28-Apr-2010  hubertf Silence for boot -z
 1.104 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.103 24-Feb-2010  dyoung branches: 1.103.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.102 19-Jan-2010  pooka branches: 1.102.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.101 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.100 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.99 26-Sep-2009  jmcneill add suspend/resume support
 1.98 06-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested VIA VT86C100A (which is probed as VT3043).
 1.97 23-Aug-2009  jmcneill Don't maintain a list of descriptions for each supported device, that's
what PCIVERBOSE is for; use pci_devinfo instead.
 1.96 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.95 09-Jul-2008  joerg branches: 1.95.4; 1.95.8; 1.95.12;
- device/softc split
 1.94 09-Jul-2008  joerg Constify device table.
 1.93 28-Apr-2008  martin branches: 1.93.2; 1.93.4; 1.93.6;
Remove clause 3 and 4 from TNF licenses
 1.92 10-Apr-2008  cegger branches: 1.92.2; 1.92.4;
use aprint_*_dev and device_xname
 1.91 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.90 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.89 19-Jan-2008  dyoung branches: 1.89.2; 1.89.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.88 19-Oct-2007  ad branches: 1.88.2; 1.88.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.87 09-Jul-2007  ad branches: 1.87.6; 1.87.8; 1.87.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.86 15-Jun-2007  jmcneill Add VT6105M (Rhine III) to the list of supported devices, as found in the
Soekris net5501.
 1.85 04-Mar-2007  christos branches: 1.85.2; 1.85.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.84 16-Nov-2006  christos branches: 1.84.2; 1.84.4; 1.84.8;
__unused removal on arguments; approved by core.
 1.83 05-Nov-2006  tsutsui Use uintNN_t.
 1.82 03-Nov-2006  tsutsui Pull several fixes which improve TX error handling
from FreeBSD's if_vr.c rev 1.52:
- check more error status in TX descriptor and restart TX module
appropriately in vr_txeof()
- check more error interrupt status in vr_intr()

I can't confirm whether these changes actually fix TX stalls because
I can't reproduce the problem I had about seven years ago (I guess
it might be caused by excessive collisions on a dumb hub), but at least
they don't seem to have bad side effects on normal operations on my macppc.
 1.81 02-Nov-2006  tsutsui Don't touch the VR_STICKHW register on VT3043.

The commit log in FreeBSD's if_vr.c rev 1.43 says
"This is really only for the VT6102, but it doesn't hurt the older chips,"
but at least it hurts my VT86C100A (which returns a product ID of VT3043)
on macppc and causes kernel MCHK trap while the same board on i386
and VT6102 on macppc have no problem with it.
 1.80 02-Nov-2006  tsutsui Pull some RX fixes from FreeBSD's if_vr.c rev 1.59:
- in vr_rxeoc() (i.e. on RX error interrupts), disable RX before
calling vr_rxeof() and check it actually stopped
- no recovery is needed for VR_ISR_DROPPED, so just account ierrors
- also account ierrors in vr_rxeoc()
 1.79 02-Nov-2006  tsutsui - make DMA descriptor members volatile
- set VR_RXSTAT_OWN after all other descriptor data is set

With these changes, vr_init() seems to initialize
the vr chip stuck on RX properly.
 1.78 20-Oct-2006  scw Force a reload of the EEPROM if the MAC address is all zeroes.
Fixes PR kern/34812.
 1.77 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.76 17-Jun-2006  christos branches: 1.76.4; 1.76.6;
re-factor the pci powestate api. reviewed by gimpy
 1.75 11-Dec-2005  christos branches: 1.75.4; 1.75.8; 1.75.14; 1.75.16;
merge ktrace-lwp.
 1.74 30-Jan-2005  thorpej branches: 1.74.6;
Eliminate use of M_HASFCS.
 1.73 27-Jan-2005  scw In vr_start(), don't forget to free the new mbuf if the second
bus_dmamap_load_mbuf() fails.
 1.72 25-Jan-2005  jmmv Capture incomplete packets coming from the card, as this driver doesn't
support this feature. This avoids multiple crashes that I've had in the
past. Also ensure that packets are not empty when DIAGNOSTIC is set.

However, this is just another sanity check of the received packets, but
does not address the real problem. The issue seems to be the following:
if the card receives data while doing a reset (vr_init), it later finds
a bunch of empty packets in the receive ring.

This explains the crashes I've hit: running a program which needs
promiscuous mode (dhclient) while the card was already running in
that mode (tcpdump). In this situation, it's easy that the second
reset receives stuff from the network.

Unfortunately, I don't know why the card is producing these packets...

While here, fix a typo in a comment.
 1.71 13-Jan-2005  jmmv branches: 1.71.2; 1.71.4;
Fix two typos.
 1.70 30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.69 21-Aug-2004  thorpej Use ANSI function decls and make use of static.
 1.68 15-Feb-2004  jdolecek branches: 1.68.4;
add rnd hooks
 1.67 14-Nov-2003  jmcneill Don't set VR_EECSR_LOAD before reading the MAC address on the VT6102 either.
 1.66 13-Nov-2003  scw On Rhine III, don't set VR_EECSR_LOAD before reading the MAC address.
This reloads the entire EEPROM, not just the MAC address, which can
cause problems for the host PCI bus under certain circumstances. The
chip already loads the EEPROM at powerup/reset anyway.

XXX: This probably applies to the other Rhine variants too, but I don't
have a data sheet to confirm this behaviour.
 1.65 17-Oct-2003  tsutsui - No need to set VR_TXCTL_TLINK in vr_start() because all TX buffers have
only single segment.
- No need to set VR_CMD_TX_ON in vr_start().
- Initialize BCR0 and BCR1 registers.
- Change RX DMA threshold 128bytes.

Mostly from FreeBSD via OpenBSD.
 1.64 17-Oct-2003  tsutsui Misc cosmetics.
 1.63 17-Oct-2003  tsutsui Use common PCI macro/functions for PWRMGMT.
 1.62 23-Aug-2003  dogcow add VT6105 support to vr(4)
 1.61 10-Apr-2003  christos branches: 1.61.2;
Add MIIF_FORCEANEG from Martin Husemann
 1.60 15-Jan-2003  bouyer Zero out the buffer when padding packet to ETHER_MIN_LEN-ETHER_CRC_LEN
 1.59 03-Jan-2003  lha From freebsd if_vr.c:1.43,1.56 and if_vrreg.h:1.11,1.14

- Windows put the chip in suspended mode, make sure we unsuspend
it. 1.43, by Takefumi SAYO <stake@po.shiojiri.ne.jp>

- Detect the revision of the Rhine chip we're using, and force reset
when the chip supports it. 1.65, by silby@freebsd.org
 1.58 21-Oct-2002  fair Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.
 1.57 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.56 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.55 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.54 28-Jul-2002  christos my card prints transmit aborted and then hangs. Let's try to reset it.
 1.53 13-Nov-2001  lukem branches: 1.53.8; 1.53.10;
add RCSID
 1.52 14-Aug-2001  mrg mtod() with uintptr_t, not bus_addr_t.
 1.51 23-Jul-2001  thorpej Make sure to initialize the all Rx descriptors properly in *_init()
even if mbufs for them are already allocated.
 1.50 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.49 07-Jul-2001  thorpej branches: 1.49.2;
bcopy -> memcpy, strcpy
 1.48 12-Jun-2001  thorpej Don't need INET or NS includes here.
 1.47 12-Jun-2001  wiz receive, not recieve
 1.46 29-Jan-2001  tsutsui branches: 1.46.2;
Use ether_crc32_be() for multicast hash calculation.
 1.45 29-Jan-2001  enami Handle allmulti case correctly as a NetBSD network driver;
if we are requested range of multicast address or too many multicast address,
program multicast filter to receive all multicast address. And set/clear
IFF_ALLMULTI flag properly.
 1.44 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.43 19-Dec-2000  thorpej Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.
 1.42 14-Dec-2000  thorpej ALTQ'ify.
 1.41 15-Nov-2000  thorpej Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.40 15-Oct-2000  thorpej Don't trim off the FCS, pass it up.
 1.39 11-Oct-2000  thorpej Use ether_ioctl().
 1.38 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.37 13-Sep-2000  tron Use correct product id for VIA VT6102 chip. Problem pointed out by
Jaromir Doleeek in private e-mail.
 1.36 13-Sep-2000  tron Add support VIA VT6102 chip found e.g on the D-Link DFE530TX NIC.
Fixes PR kern/11001 by Petter Lindquist.
 1.35 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.34 23-Mar-2000  thorpej branches: 1.34.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.33 06-Mar-2000  thorpej No longer necessary to futz with ifp->if_baudrate here.
 1.32 02-Feb-2000  thorpej Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().
 1.31 02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.30 12-Dec-1999  thorpej Use htole32() and le32toh().
 1.29 19-Nov-1999  thorpej Make the ThunderLAN and VIA Rhine drivers use the common MII bit-bang module.
 1.28 12-Nov-1999  thorpej Call mii_down() as appropriate.
 1.27 04-Nov-1999  thorpej Adapt to mii_phy_probe() change.
 1.26 20-Sep-1999  thorpej branches: 1.26.2; 1.26.4; 1.26.8;
Fix packet reception in promiscuous mode: compare the Ethernet destination
address against our station address if it's not a multicast packet. Either
the Rhine manual lies about the phys/broadcast/multicast rxstatus bits,
or the Rhine chip is just broken.

Fixes a redirect storm problem reported by Laine Stump on current-users.
 1.25 14-Aug-1999  hwr Initialize error variable. Should fix spurious init errors.
From Dave Huang in PR 8205.
 1.24 14-Aug-1999  hwr Remove dulicate "Ethernet" output. From Dave Huang in PR 8206
 1.23 03-Aug-1999  thorpej Be a little nicer about memory usage:
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() it changed to handle compressing clusters.
 1.22 18-May-1999  thorpej Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.21 26-Apr-1999  thorpej Make the VIA Rhine driver work on big-endian systems. From Izumi Tsutsui,
PR #7305.
 1.20 24-Apr-1999  thorpej Fix an mbuf leak in the strict alignment case of packet reception.
 1.19 24-Mar-1999  thorpej branches: 1.19.2;
Don't enable I/O or memory access here! These bits in the PCI CSR are
set up by the firmware, and indicate which mapping types the system
supports.
 1.18 12-Feb-1999  thorpej Major overhaul of the Rhine/Rhine-II driver, structuring it a little more
like the SMC83C100 EPIC/100 driver:
* Rather than using pointers to the head and tail of the transmit and
receive rings, use wrapping indexes into arrays. This is a little more
obvious when reading the code.
* More cleanly separate the hardware descriptor from the software descriptor.
* bus_dma it everywhere.
* Implement interrupt pacing and avoid a potential race in the transmit
loop.

Now this looks more or less like the Rhine driver I was working on when
this driver was committed :-) Update copyright notice to reflect that.
 1.17 05-Feb-1999  thorpej Make this driver work on the Alpha. Apparently the receive DMA mechanism
has the same 4-byte alignment requirement that the transmit side does. This
causes the packet payload to be misaligned. So, on systems which require
strict alignment, we must copy the incoming frame to a new packet buffer,
suitably aligned.
 1.16 05-Feb-1999  thorpej Fix the interrupt handler to actually acknowledge the interupt to the
dispatch code (!!!). How did this work even on the i386 before?
 1.15 05-Feb-1999  thorpej Fix some formatting nits.
 1.14 05-Feb-1999  thorpej Remove some duplicate softc members, and comment some of the softc
fields.
 1.13 05-Feb-1999  thorpej Remove some unnecessary splnet's.
 1.12 05-Feb-1999  thorpej splimp -> splnet
 1.11 05-Feb-1999  thorpej Use the generic MII support code, not our own.
 1.10 05-Feb-1999  thorpej Use MII command opcodes from <sys/dev/mii.h>
 1.9 05-Feb-1999  thorpej Rename VR_MIICMD_DATAIN and VR_MIICMD_DATAOUT to actually match what the
data sheet says. (The names and their usage were exactly reversed in the
code.)
 1.8 02-Feb-1999  thorpej Use pcidevs.h to get vendor and product IDs.
 1.7 02-Feb-1999  thorpej Take software-only structure definitions out of the register description
header.
 1.6 02-Feb-1999  thorpej Remove support for FreeBSD from the driver; so many changes are going
to be required to make it properly portable to all of NetBSD's platforms,
that it just wouldn't be worth the effort.
 1.5 01-Feb-1999  thorpej Minimal changes to make this compile on the Alpha. Much more work is
needed to make this a truly portable driver.
 1.4 26-Jan-1999  sakamoto NetBSD RCS id.
 1.3 22-Jan-1999  sakamoto Change bootverbose 1 to 0.
Add vr_lookup.
 1.2 21-Jan-1999  sakamoto Add NetBSD autoconfiguration support.
KNF.
 1.1 21-Jan-1999  sakamoto branches: 1.1.1;
Initial revision
 1.1.1.1 21-Jan-1999  sakamoto Import FreeBSD's VIA Rhine fast ethernet PCI NIC driver
written by Bill Paul <wpaul@ctr.columbia.edu>.
 1.19.2.3 22-Sep-1999  cgd pull up rev 1.26 from trunk (requested by thorpej):
Fix packet reception in promiscuous mode: compare the Ethernet
destination address against our station address if it's not a
multicast packet. Fixes a redirect storm problem.
 1.19.2.2 26-Apr-1999  perry branches: 1.19.2.2.2; 1.19.2.2.4;
pullup 1.20->1.21 (thorpej): make the driver work on big-endian systems
 1.19.2.1 26-Apr-1999  perry pullup 1.19->1.20 (thorpej): fix an mbuf leak
 1.19.2.2.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.19.2.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.26.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.26.4.1 15-Nov-1999  fvdl Sync with -current
 1.26.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.26.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.26.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.26.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.34.4.2 13-Mar-2001  he Pull up revision 1.45 (requested by tsutsui):
Handle allmulti case correctly as a NetBSD network driver;
if we are requested range of multicast address or too many
multicast address, program multicast filter to receive all
multicast address. And set/clear IFF_ALLMULTI flag properly.
 1.34.4.1 13-Sep-2000  tron Pull up from current (approved by thorpej):

Add support VIA VT6102 chip found e.g on the D-Link DFE530TX NIC.

syssrc/sys/dev/pci/if_vr.c 1.36-1.37
syssrc/sys/dev/pci/pcidevs 1.256-1.258
 1.46.2.8 17-Jan-2003  thorpej Sync with HEAD.
 1.46.2.7 07-Jan-2003  thorpej Sync with HEAD.
 1.46.2.6 11-Nov-2002  nathanw Catch up to -current
 1.46.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.46.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.46.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.46.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.46.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.49.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.49.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.49.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.49.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.49.2.1 03-Aug-2001  lukem update to -current
 1.53.10.1 27-Jan-2003  jmc Pullup revisions 1.59-1.60 (requested by bouyer in ticket #1092)
Zero out the buffer when padding packet to ETHER_MIN_LEN-ETHER_CRC_LEN
 1.53.8.1 29-Aug-2002  gehenna catch up with -current.
 1.61.2.7 04-Feb-2005  skrll Sync with HEAD.
 1.61.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.61.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.61.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.61.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.61.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.61.2.1 03-Aug-2004  skrll Sync with HEAD
 1.68.4.1 24-Jan-2005  he Pull up revision 1.70 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.71.4.1 12-Feb-2005  yamt sync with head.
 1.71.2.1 29-Apr-2005  kent sync with -current
 1.74.6.7 24-Mar-2008  yamt sync with head.
 1.74.6.6 17-Mar-2008  yamt sync with head.
 1.74.6.5 21-Jan-2008  yamt sync with head
 1.74.6.4 27-Oct-2007  yamt sync with head.
 1.74.6.3 03-Sep-2007  yamt sync with head.
 1.74.6.2 30-Dec-2006  yamt sync with head.
 1.74.6.1 21-Jun-2006  yamt sync with head.
 1.75.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.75.14.1 19-Jun-2006  chap Sync with head.
 1.75.8.1 26-Jun-2006  yamt sync with head.
 1.75.4.1 09-Sep-2006  rpaulo sync with head
 1.76.6.2 10-Dec-2006  yamt sync with head.
 1.76.6.1 22-Oct-2006  yamt sync with head
 1.76.4.1 18-Nov-2006  ad Sync with head.
 1.84.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.84.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.84.2.1 17-Jun-2007  riz Pull up following revision(s) (requested by jmcneill in ticket #725):
sys/dev/pci/if_vr.c: revision 1.86
Add VT6105M (Rhine III) to the list of supported devices, as found
in the
Soekris net5501.
 1.85.4.1 11-Jul-2007  mjf Sync with head.
 1.85.2.3 23-Oct-2007  ad Sync with head.
 1.85.2.2 15-Jul-2007  ad Sync with head.
 1.85.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.87.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.87.8.2 23-Mar-2008  matt sync with HEAD
 1.87.8.1 06-Nov-2007  matt sync with HEAD
 1.87.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.88.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.88.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.89.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.89.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.89.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.89.2.1 24-Mar-2008  keiichi sync with head.
 1.92.4.6 11-Aug-2010  yamt sync with head.
 1.92.4.5 11-Mar-2010  yamt sync with head
 1.92.4.4 16-Sep-2009  yamt sync with head
 1.92.4.3 16-May-2009  yamt sync with head
 1.92.4.2 04-May-2009  yamt sync with head.
 1.92.4.1 16-May-2008  yamt sync with head.
 1.92.2.1 18-May-2008  yamt sync with head.
 1.93.6.1 19-Oct-2008  haad Sync with HEAD.
 1.93.4.1 18-Jul-2008  simonb Sync with head.
 1.93.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.95.12.1 21-Apr-2010  matt sync to netbsd-5
 1.95.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.95.4.2 03-Oct-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #1022):
sys/dev/pci/if_vr.c: revision 1.99
add suspend/resume support
 1.95.4.1 03-Oct-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #1022):
sys/dev/pci/if_vr.c: revision 1.98
Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested VIA VT86C100A (which is probed as VT3043).
 1.102.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.103.2.2 05-Mar-2011  rmind sync with head
 1.103.2.1 30-May-2010  rmind sync with head
 1.107.8.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.107.8.3 23-Jan-2013  yamt sync with head
 1.107.8.2 30-Oct-2012  yamt sync with head
 1.107.8.1 17-Apr-2012  yamt sync with head
 1.108.2.1 18-Feb-2012  mrg merge to -current.
 1.110.2.1 08-Feb-2013  riz Pull up following revision(s) (requested by taca in ticket #783):
sys/dev/pci/if_vr.c: revision 1.112
- reset the chip if the tx engine gets stuck after a link state change,
from OpenBSD
- no need to do a full reset of the chip when enabling or disabling
promiscuous mode
 1.111.2.3 03-Dec-2017  jdolecek update from HEAD
 1.111.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.111.2.1 25-Feb-2013  tls resync with head
 1.112.2.1 18-May-2014  rmind sync with head
 1.113.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.114.4.5 05-Feb-2017  skrll Sync with HEAD
 1.114.4.4 05-Oct-2016  skrll Sync with HEAD
 1.114.4.3 09-Jul-2016  skrll Sync with HEAD
 1.114.4.2 19-Mar-2016  skrll Sync with HEAD
 1.114.4.1 06-Jun-2015  skrll Sync with HEAD
 1.119.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.123.2.3 26-Jan-2019  pgoyette Sync with HEAD
 1.123.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.123.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.124.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.124.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.124.2.1 10-Jun-2019  christos Sync with HEAD
 1.131.2.1 29-Feb-2020  ad Sync with head.
 1.133.10.2 01-Aug-2021  thorpej Sync with HEAD.
 1.133.10.1 13-May-2021  thorpej Sync with HEAD.
 1.17 28-Feb-2018  flxd Cosmetic fix for the Physical Address Registers PAR0 to PAR5.
 1.16 05-Nov-2006  tsutsui Use uintNN_t.
 1.15 03-Nov-2006  tsutsui Pull several fixes which improve TX error handling
from FreeBSD's if_vr.c rev 1.52:
- check more error status in TX descriptor and restart TX module
appropriately in vr_txeof()
- check more error interrupt status in vr_intr()

I can't confirm whether these changes actually fix TX stalls because
I can't reproduce the problem I had about seven years ago (I guess
it might be caused by excessive collisions on a dumb hub), but at least
they don't seem to have bad side effects on normal operations on my macppc.
 1.14 02-Nov-2006  tsutsui - make DMA descriptor members volatile
- set VR_RXSTAT_OWN after all other descriptor data is set

With these changes, vr_init() seems to initialize
the vr chip stuck on RX properly.
 1.13 11-Dec-2005  christos branches: 1.13.20; 1.13.22;
merge ktrace-lwp.
 1.12 17-Oct-2003  tsutsui branches: 1.12.16;
- No need to set VR_TXCTL_TLINK in vr_start() because all TX buffers have
only single segment.
- No need to set VR_CMD_TX_ON in vr_start().
- Initialize BCR0 and BCR1 registers.
- Change RX DMA threshold 128bytes.

Mostly from FreeBSD via OpenBSD.
 1.11 17-Oct-2003  tsutsui Use common PCI macro/functions for PWRMGMT.
 1.10 03-Jan-2003  lha branches: 1.10.2;
From freebsd if_vr.c:1.43,1.56 and if_vrreg.h:1.11,1.14

- Windows put the chip in suspended mode, make sure we unsuspend
it. 1.43, by Takefumi SAYO <stake@po.shiojiri.ne.jp>

- Detect the revision of the Rhine chip we're using, and force reset
when the chip supports it. 1.65, by silby@freebsd.org
 1.9 12-Feb-1999  thorpej branches: 1.9.20;
Garbage-collect some unneeded definitions.
 1.8 05-Feb-1999  thorpej Rename VR_MIICMD_DATAIN and VR_MIICMD_DATAOUT to actually match what the
data sheet says. (The names and their usage were exactly reversed in the
code.)
 1.7 02-Feb-1999  thorpej Use pcidevs.h to get vendor and product IDs.
 1.6 02-Feb-1999  thorpej Take software-only structure definitions out of the register description
header.
 1.5 02-Feb-1999  thorpej Remove support for FreeBSD from the driver; so many changes are going
to be required to make it properly portable to all of NetBSD's platforms,
that it just wouldn't be worth the effort.
 1.4 26-Jan-1999  sakamoto NetBSD RCS id.
 1.3 22-Jan-1999  sakamoto Change bootverbose 1 to 0.
Add vr_lookup.
 1.2 21-Jan-1999  sakamoto Add NetBSD autoconfiguration support.
KNF.
 1.1 21-Jan-1999  sakamoto branches: 1.1.1;
Initial revision
 1.1.1.1 21-Jan-1999  sakamoto Import FreeBSD's VIA Rhine fast ethernet PCI NIC driver
written by Bill Paul <wpaul@ctr.columbia.edu>.
 1.9.20.1 07-Jan-2003  thorpej Sync with HEAD.
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.16.1 30-Dec-2006  yamt sync with head.
 1.13.22.1 10-Dec-2006  yamt sync with head.
 1.13.20.1 18-Nov-2006  ad Sync with head.
 1.39 24-Feb-2025  andvar fix various typos in comments.
 1.38 05-Sep-2024  andvar s/vte_rxoef/vte_rxeof/ in debug message.
 1.37 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.36 29-Jun-2024  riastradh branches: 1.36.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.35 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.34 17-Sep-2022  thorpej vte_ifstart(): Make the condition if the transmit loop the number of
free descriptors, not "are there packets in the queue"; the latter is
redundant with the IFQ_POLL() that happens within the loop after the
number of available descriptors is checked. Eliminate use of IFF_OACTIVE.
 1.33 03-Sep-2022  thorpej Garbage-collect the remaining vestiges of netisr.
 1.32 30-Aug-2021  andvar Restore original MDC speed control register value after MAC reset, if it wasn't default. Fixes PR port-i386/53494.
ok riastradh
 1.31 07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.30 04-Feb-2020  thorpej Use ifmedia_fini().
 1.29 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.28 12-Nov-2019  maya branches: 1.28.2;
Fix whitespace. From vezhlys
 1.27 30-Oct-2019  msaitoh if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.26 28-May-2019  msaitoh branches: 1.26.2;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.25 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.24 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.23 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.22 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.21 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.20 26-Jun-2018  msaitoh branches: 1.20.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.19 22-Jun-2018  msaitoh It's not required to include net/bpfdesc.h. Remove it.
 1.18 26-Jun-2017  christos branches: 1.18.4;
PR/52333: Jia-Ju Bai: explicitly pass BUS_DMA_NOWAIT to bus_dmamap_load_mbuf()
called from an interrupt context. It should not matter since the maps are
constructed with BUS_DMA_ALLOCNOW, but :-)
 1.17 23-May-2017  ozaki-r branches: 1.17.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.
 1.16 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.15 11-Jul-2016  msaitoh branches: 1.15.2;
KNF. No functional change.
 1.14 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.13 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.12 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.11 10-Aug-2014  tls branches: 1.11.4;
Merge tls-earlyentropy branch into HEAD.
 1.10 29-Mar-2014  christos branches: 1.10.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.9 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.8 30-Mar-2013  christos branches: 1.8.4;
remove trailing whitespace
 1.7 22-Jul-2012  matt branches: 1.7.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.6 02-Jun-2012  dsl Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.5 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.4 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.3 28-Apr-2011  bouyer branches: 1.3.4; 1.3.6; 1.3.10;
- Properly count collisions
- call vte_rxfilter() after starting transmit/receive; this seems to
fix some IPv6-related multicast issues for me
- when the MCR0_BROADCAST bit is set broadcast receive is disabled.
Rename it to MCR0_BROADCAST_DIS to reflect its function, and fix usage.
- Fix loop over multicast addresses to not set the same address in the
3 perfect filter slots.
 1.2 02-Apr-2011  mbalmer Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.
 1.1 26-Jan-2011  bouyer branches: 1.1.2; 1.1.4;
Add a driver for the RDC Semiconductor RDC R6040 10/100 Ethernet controller,
as found in the vortex86 SoCs (http://www.vortex86dx.com).
Ported from freebsd.
Not added to amd64's GENERIC because this CPU is 32bit only.

thanks to DM&P Electronics, Inc for providing documentation and sample
devices for this work.
 1.1.4.4 31-May-2011  rmind sync with head
 1.1.4.3 21-Apr-2011  rmind sync with head
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 26-Jan-2011  rmind file if_vte.c was added on branch rmind-uvmplock on 2011-03-05 20:53:45 +0000
 1.1.2.2 08-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 26-Jan-2011  bouyer file if_vte.c was added on branch bouyer-quota2 on 2011-02-08 16:19:50 +0000
 1.3.10.1 18-Feb-2012  mrg merge to -current.
 1.3.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.6.2 30-Oct-2012  yamt sync with head
 1.3.6.1 17-Apr-2012  yamt sync with head
 1.3.4.2 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 28-Apr-2011  jruoho file if_vte.c was added on branch jruoho-x86intr on 2011-06-06 09:08:15 +0000
 1.7.2.3 03-Dec-2017  jdolecek update from HEAD
 1.7.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.2.1 23-Jun-2013  tls resync from head
 1.8.4.1 18-May-2014  rmind sync with head
 1.10.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.11.4.6 28-Aug-2017  skrll Sync with HEAD
 1.11.4.5 05-Feb-2017  skrll Sync with HEAD
 1.11.4.4 05-Oct-2016  skrll Sync with HEAD
 1.11.4.3 09-Jul-2016  skrll Sync with HEAD
 1.11.4.2 19-Mar-2016  skrll Sync with HEAD
 1.11.4.1 06-Jun-2015  skrll Sync with HEAD
 1.15.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17.2.3 03-Sep-2021  martin Pull up following revision(s) (requested by andvar in ticket #1693):

sys/dev/pci/if_vte.c: revision 1.32

Restore original MDC speed control register value after MAC reset, if
it wasn't default. Fixes PR port-i386/53494.

ok riastradh
 1.17.2.2 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.17.2.1 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.18.4.4 26-Jan-2019  pgoyette Sync with HEAD
 1.18.4.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.18.4.2 28-Jul-2018  pgoyette Sync with HEAD
 1.18.4.1 25-Jun-2018  pgoyette Sync with HEAD
 1.20.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.20.2.1 10-Jun-2019  christos Sync with HEAD
 1.26.2.2 03-Sep-2021  martin Pull up following revision(s) (requested by andvar in ticket #1339):

sys/dev/pci/if_vte.c: revision 1.32

Restore original MDC speed control register value after MAC reset, if
it wasn't default. Fixes PR port-i386/53494.

ok riastradh
 1.26.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.28.2.1 29-Feb-2020  ad Sync with head.
 1.36.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 28-Apr-2011  bouyer branches: 1.2.4;
- Properly count collisions
- call vte_rxfilter() after starting transmit/receive; this seems to
fix some IPv6-related multicast issues for me
- when the MCR0_BROADCAST bit is set broadcast receive is disabled.
Rename it to MCR0_BROADCAST_DIS to reflect its function, and fix usage.
- Fix loop over multicast addresses to not set the same address in the
3 perfect filter slots.
 1.1 26-Jan-2011  bouyer branches: 1.1.2; 1.1.4;
Add a driver for the RDC Semiconductor RDC R6040 10/100 Ethernet controller,
as found in the vortex86 SoCs (http://www.vortex86dx.com).
Ported from freebsd.
Not added to amd64's GENERIC because this CPU is 32bit only.

thanks to DM&P Electronics, Inc for providing documentation and sample
devices for this work.
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 26-Jan-2011  rmind file if_vtereg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:45 +0000
 1.1.2.2 08-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 26-Jan-2011  bouyer file if_vtereg.h was added on branch bouyer-quota2 on 2011-02-08 16:19:50 +0000
 1.2.4.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.1 28-Apr-2011  jruoho file if_vtereg.h was added on branch jruoho-x86intr on 2011-06-06 09:08:15 +0000
 1.5 01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.4 14-Apr-2015  riastradh branches: 1.4.18; 1.4.26;
Include <sys/rndsource.h> where it is actually used.

I had removed <sys/rnd.h> from files that didn't mention anything of
the rnd(9) API. But they included other files which assumed
<sys/rnd.h> had already been included.
 1.3 02-Feb-2012  tls branches: 1.3.6; 1.3.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.2 19-Nov-2011  tls branches: 1.2.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.1 26-Jan-2011  bouyer branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
Add a driver for the RDC Semiconductor RDC R6040 10/100 Ethernet controller,
as found in the vortex86 SoCs (http://www.vortex86dx.com).
Ported from freebsd.
Not added to amd64's GENERIC because this CPU is 32bit only.

thanks to DM&P Electronics, Inc for providing documentation and sample
devices for this work.
 1.1.10.1 17-Apr-2012  yamt sync with head
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 26-Jan-2011  jruoho file if_vtevar.h was added on branch jruoho-x86intr on 2011-06-06 09:08:15 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 26-Jan-2011  rmind file if_vtevar.h was added on branch rmind-uvmplock on 2011-03-05 20:53:45 +0000
 1.1.2.2 08-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 26-Jan-2011  bouyer file if_vtevar.h was added on branch bouyer-quota2 on 2011-02-08 16:19:50 +0000
 1.2.2.1 18-Feb-2012  mrg merge to -current.
 1.3.24.1 06-Jun-2015  skrll Sync with HEAD
 1.3.6.1 03-Dec-2017  jdolecek update from HEAD
 1.4.26.1 29-Feb-2020  ad Sync with head.
 1.4.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.57 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.56 14-Jul-2016  msaitoh branches: 1.56.16; 1.56.18;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.55 29-Mar-2014  christos branches: 1.55.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.54 30-Jan-2012  drochner branches: 1.54.6; 1.54.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.53 26-Jul-2011  dyoung branches: 1.53.2; 1.53.6;
Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.52 23-Nov-2010  christos fix typos
 1.51 23-Nov-2010  christos split if_wi
 1.50 26-Nov-2009  njoly branches: 1.50.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.49 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.

XXX: should these pmf(9) calls be moved into MI attach functions
XXX: using function pointers for suspend and resume passed via softc?
 1.48 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.47 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.46 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.45 28-Apr-2008  martin branches: 1.45.14;
Remove clause 3 and 4 from TNF licenses
 1.44 10-Apr-2008  cegger branches: 1.44.2; 1.44.4;
use aprint_*_dev and device_xname
 1.43 09-Dec-2007  jmcneill branches: 1.43.10;
Merge jmcneill-pm branch.
 1.42 19-Oct-2007  ad branches: 1.42.4; 1.42.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.41 16-Nov-2006  christos branches: 1.41.8; 1.41.22; 1.41.24; 1.41.28;
__unused removal on arguments; approved by core.
 1.40 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.39 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.38 11-Dec-2005  christos branches: 1.38.20; 1.38.22;
merge ktrace-lwp.
 1.37 22-Jun-2005  dyoung branches: 1.37.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.36 27-Feb-2005  perry nuke trailing whitespace
 1.35 21-Aug-2004  thorpej branches: 1.35.4; 1.35.6;
Use ANSI function decls and make use of static.
 1.34 07-Aug-2004  mycroft Don't pass a MAC address to wi_attach() -- yet.
 1.33 17-Jul-2004  mycroft Remove special-casing of Intersil product name.
 1.32 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.31 28-Mar-2004  nakayama Avoid use of wi_pci_reset when it uses other chip like PLX bridge chip.
This solves PCI bus error on sparc64 with Eumitcom WL11000P.
 1.30 14-Dec-2003  dyoung PR 23428: support National Datacomm Corporation NCP130A2 board.
Thanks T. M. Pederson for sending the patches.
 1.29 07-Dec-2003  dyoung Enable RSSI-based rate-adaptation for wi(4). This enables wi(4)-based
APs to run at "full speed" where before they ran at just 1 or 2Mb/s.
The AP will adapt the data rate for each client based on packet
losses and the received signal strength.

I have also enabled rate adaptation for STA mode and for IBSS mode,
but the hardware gives us less control over the data rate in those
modes.
 1.28 16-Nov-2003  dyoung Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
 1.27 13-Oct-2003  dyoung Switch wi(4) to the new 802.11 layer.
 1.26 29-Sep-2003  scw Copy our pci_chipset_tag_t into wi_pci_softc instead of a pointer
to pci_attach_args. The latter is allocated on the stack during auto-
configuration and so will not be valid after that time.

It's amazing how the old code worked for so long. I guess pci_attach_args
is allocated deep in pid#0's kernel stack on most platforms.
 1.25 29-Jun-2003  fvdl branches: 1.25.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.24 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.23 12-Apr-2003  christos PR/21108: Christopher SEKIYA: if_wi_pci.c rev 1.21 is incorrect for PLX-9052
 1.22 29-Mar-2003  jdc Add support for USRobotics Wireless Access PCI adapter (model 132415).
From Sergio Jimenez in PR kern/20642.
 1.21 29-Mar-2003  dyoung Support so-called "PLX" bridge for wi(4). From FreeBSD via Simon
Burge. Simon writes,

"Here's the patch that Grant and I have been using on a combinations of
architectures and both NetBSD 1.6 and -current.

"This is based on FreeBSD - look for
/* We have to do a magic PLX poke to enable interrupts */
in
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/wi/if_wi_pci.c
 1.20 28-Mar-2003  perry Fix PR/20903 for real.
Identical patches supplied by:
Masuda Hideo <h-masuda@ootani.nagata.kobe.jp>
Christopher SEKIYA <wileyc@rezrov.net>
 1.19 27-Mar-2003  perry ifdef out something dependent on PCI_VENDOR_COREGA for now.
 1.18 27-Mar-2003  perry Tell driver to accept the Corega CGWLPCIA11.
Submitted by h-masuda@ootani.nagata.kobe.jp in PR #20903
 1.17 27-Mar-2003  dyoung Introduced sc_reset to wi_softc. The bus-specific front-end gets
to fill this.
 1.16 02-Jan-2003  dyoung Since the I/O and memory enable bits are written to the PCI CSR by
the PCI bus code, and because wi(4) does not use bus-mastering, we
may entirely skip writing the PCI CSR.
 1.15 01-Jan-2003  dyoung For confidence's sake, enable I/O and memory accesses (which were
previously NOT enabled), but do not enable bus-mastering (which
was previously enabled, but which neither Lucent nor Prism support).
 1.14 31-Dec-2002  dyoung Per discussion in PR 18794, fix PCI resets. Alas, this does not
seem to fix PR 18794.
 1.13 21-Oct-2002  soren WI_PCI_CBMA belongs in dev/pci.
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.10 30-Sep-2002  onoe Nuke unneeded member sc_ifp and use #define sc_if instead,
to prepare jumbo commit for wi.c
 1.9 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.8 23-Sep-2002  thorpej Make the PCI reset more robust. From David Young <dyoung@ojctech.com>.
 1.7 04-Apr-2002  jdolecek branches: 1.7.4;
move wi_pci_reset() from ic/wi.c to pci/if_wi_pci.c, where is belongs
 1.6 04-Apr-2002  jdolecek fix sligh confusion on whether or not to supply dv_xname to printf() in
error cases of attach
Noticed in kern/16197 by George E Sollish.
 1.5 15-Jan-2002  augustss Note to self: set variable before using it.
 1.4 13-Jan-2002  augustss Cosmetic error message fix.
 1.3 13-Jan-2002  augustss Add code to handle PCMCIA cards placed on a PCI card with the PLX chip.
From OpenBSD and FreeBSD.
 1.2 13-Nov-2001  lukem branches: 1.2.2;
add RCSID
 1.1 13-Oct-2001  ichiro branches: 1.1.2;
Add Intersil Prism2.5 Mini-PCI wavelan.
 1.1.2.10 03-Jan-2003  thorpej Sync with HEAD.
 1.1.2.9 11-Nov-2002  nathanw Catch up to -current
 1.1.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.7 05-Oct-2002  gmcgarry Remove CVS conflicts.
 1.1.2.6 23-Sep-2002  thorpej Sync with HEAD.
 1.1.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.1.2.1 13-Oct-2001  nathanw file if_wi_pci.c was added on branch nathanw_sa on 2001-10-22 20:41:24 +0000
 1.2.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 13-Nov-2001  thorpej file if_wi_pci.c was added on branch kqueue on 2002-01-10 19:56:47 +0000
 1.7.4.1 28-Jul-2003  he Pull up revisions 1.21,1.23 (via patch, requested by grant in ticket #1281):
Support the so-called ``PLX'' bridge for wi(4).
 1.25.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.25.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.4 25-Aug-2004  skrll Sync with HEAD.
 1.25.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.25.2.2 03-Aug-2004  skrll Sync with HEAD
 1.25.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.35.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.35.4.1 29-Apr-2005  kent sync with -current
 1.37.2.3 21-Jan-2008  yamt sync with head
 1.37.2.2 27-Oct-2007  yamt sync with head.
 1.37.2.1 30-Dec-2006  yamt sync with head.
 1.38.22.2 10-Dec-2006  yamt sync with head.
 1.38.22.1 22-Oct-2006  yamt sync with head
 1.38.20.1 18-Nov-2006  ad Sync with head.
 1.41.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.41.24.2 09-Jan-2008  matt sync with HEAD
 1.41.24.1 06-Nov-2007  matt sync with HEAD
 1.41.22.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.41.22.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.41.22.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.41.22.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.41.22.1 04-Sep-2007  joerg Convert wi(4) to jmcneill-pm style power management.
 1.41.8.1 23-Oct-2007  ad Sync with head.
 1.42.6.1 11-Dec-2007  yamt sync with head.
 1.42.4.1 26-Dec-2007  ad Sync with head.
 1.43.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.44.4.4 11-Mar-2010  yamt sync with head
 1.44.4.3 16-Sep-2009  yamt sync with head
 1.44.4.2 16-May-2009  yamt sync with head
 1.44.4.1 16-May-2008  yamt sync with head.
 1.44.2.1 18-May-2008  yamt sync with head.
 1.45.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.1 05-Mar-2011  rmind sync with head
 1.53.6.1 18-Feb-2012  mrg merge to -current.
 1.53.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.53.2.1 17-Apr-2012  yamt sync with head
 1.54.10.1 18-May-2014  rmind sync with head
 1.54.6.2 03-Dec-2017  jdolecek update from HEAD
 1.54.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.6.1 05-Oct-2016  skrll Sync with HEAD
 1.56.18.1 10-Jun-2019  christos Sync with HEAD
 1.56.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.801 10-Nov-2024  mlelstv Add MBUFTRACE
 1.800 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.799 29-Jun-2024  riastradh branches: 1.799.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.798 21-Feb-2024  msaitoh wm(4): Fix upper 16bit of Image Unique ID(EtrackID).

Don't override uid1 variable while reading option ROM version
to print Image Unique ID correctly.
 1.797 29-Jan-2024  msaitoh wm(4): Fix compile error without WM_EVENT_COUNTERS.
 1.796 29-Jan-2024  msaitoh wm(4): Drop frames if the RX descriptor ring has no room on multiqueue system.

Drop frames if the RX descriptor ring has no room. This is enabled only on
multiqueue system to avoid bad influence to other queues. The drop count
can be seen by the RQDPC counter (wmN rxqXXdrop evcnt).
 1.795 29-Jan-2024  msaitoh wm(4): Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.

The iqdrops counter should include not only MPC(Missed Packet Count)
but also RQDPC(Receive Queue Drop Packet Count). Same as ixgbe(4) and igc(4).

Note that the RQDPC is not currently counted because SRRCTL_DROP_EN
is not set.
 1.794 26-Jan-2024  msaitoh wm(4): Print RX packet buffer size.
 1.793 18-Jan-2024  msaitoh Add Intel I219-{LM,V}(20,21) support.
 1.792 21-Nov-2023  gutteridge if_wm.c: fix spelling and grammar in a comment
 1.791 11-Oct-2023  msaitoh wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.790 11-Oct-2023  msaitoh wm(4): Add a new workaround for Tiger Lake and newer.

- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.
 1.789 25-Sep-2023  rin wm(4): Replace /* nothing */ to __nothing for evcnt macros

Prevent empty if bodies for !WM_EVENT_COUNTERS.
 1.788 25-Sep-2023  msaitoh wm(4): Modify descriptions of flow control related event counters.
 1.787 25-Sep-2023  msaitoh wm(4): the IAC(Interrupt Assertion Count) register is for 82571 and newer.
 1.786 25-Sep-2023  msaitoh wm(4): Add some info to some event counters.

- The difference between the RUC(Rx Undersize) and RFC(Rx Fragment) is whether
the CRC is valid or not.
- The difference between the ROC(Rx Oversize) and RJC(Rx Jabber) is whether
the CRC is valid or not.
- LENERRS(Length Errors) is for the length/type field <= 1500.
 1.785 25-Sep-2023  msaitoh wm(4): Use SCVPC and HRMPC for 82575 and newer.

The SCVPC(SerDes/SGMII Code Violation Packet Count) register and the HRMPC
(Header Redirection Missed Packet Count) register were added in if_wm.c
rev. 1.776 but the location in the code were incorrect. Fix them.
 1.784 25-Aug-2023  msaitoh Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.783 25-Aug-2023  msaitoh Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.
 1.782 23-Jun-2023  msaitoh Add missing read to count Circuit Breaker Rx Dropped Packet correctly.
 1.781 11-May-2023  msaitoh Fix typo. s/ictxact/ictxatc/. No functional change.
 1.780 11-May-2023  msaitoh Use WM_IS_ICHPCH(). No functional change.
 1.779 11-May-2023  msaitoh Fix prc511's comment and description.
 1.778 11-May-2023  msaitoh Add SOICZIFDATA (ifconfig -z) support for evcnt(9).

First update the statistics data, then clear the event counters,
and finally copy and clear if_data via ether_ioctl().
 1.777 11-May-2023  msaitoh Move statistics updating code from wm_tick() to new wm_update_stats().

- To reuse.
- No functional change.
 1.776 11-May-2023  msaitoh Add some new event counters.

Add the following counters for 82575 and newer except 80003, ICHs and PCHs:
- Only 82576 document describes about the circuit breaker,
so the following two might be only for 82575:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- 82575's document doesn't describe the following two, but we can see
the same value as GO{T,R}C have:
- Host Good Octets RX
- Host Good Octets TX
- 82575's document doesn't describe the LENERRS (Length Errors) counter.
I don't know if it has.
- Perhaps Non-SerDes/SGMII devices don't have SCVPC
(SerDes/SGMII Code Violation Packet) register. We don't care if
it's SerDes/SGMII or not for now.
- HRMPC (Header Redirection Missed Packet) appears only once
in 8257[56]'s datasheet. FreeBSD's igb counts it, so we do, too.
- Count the following two for I350 and newer. I don't know if PCHs have:
- EEE TX LPI
- EEE RX LPI
 1.775 11-May-2023  msaitoh Some statistics registers were replaced with new counters.

- 0x403c was CEXTERR(Carrier Extension Error). 82575 and newer except 80003,
ICHs and PCHs have HTDPMC(Host Tx Discarded Packets by MAC). I don't really
know for 82575. The 82575 datasheet say nothing about it.
- The following two are changed for circuit breaker. Only 82576's datasheet
describes abut it, so the registers might be only for 82576.
Use those registers for 82575 and newer except 80003, ICHs and PCHs just in
case.
- 0x40fc was TSCTFC(TCP Segmentation Context Tx Fail). It was replaced by
the CBRMPC(Circuit Breaker Rx Manageability Packet) register.
- 0x4124 was ICRXOC(Interrupt Cause Receiver Overrun). It was replaced by
the HTCBDPC(Host Tx Circuit Breaker Dropped Packet) register.
- From 0x4104 to 0x4124:
- For 0x4124, 82575's datasheet says it's not changed(ICRXOC).
I don't know if it's correct. We use new HTCBDPC register for 82575.
- 82576 and newer changed the meaning.
- I don't know for 80003, ICHs and PCHs. Don't count those registers.
At least, those registers in PCH2 and PCH_CNP are all zero.
 1.774 11-May-2023  msaitoh Don't add "Count" for event counter's description.
 1.773 11-May-2023  msaitoh Fix a bug that the transmit underrun counter is incorrectly counted.

The transmit underrun bit in the transmit status filed is only for 82544
(and older?), so don't use the counter for newer chips. The bit is reserved
for newer chips, but the bit sometimes set on 82575 at least.
 1.772 11-May-2023  msaitoh IC{TX,RX}*C registers are for older than 82575.
 1.771 11-May-2023  msaitoh Sort lines. No functional change.

Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach() to match.
 1.770 11-May-2023  msaitoh Sort lines. No functional change.

Rearrange the order of the registers so that they are roughly in ascending
order.
 1.769 11-May-2023  msaitoh Add note for the TORL register.

The TOR register includes error, flow control and broadcast rejected.
 1.768 11-May-2023  msaitoh Count some 64bit counters correctly.

- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Found by knakahara.
 1.767 08-Dec-2022  knakahara branches: 1.767.2;
Workaround for some hypervisor environments.

The environments cannot stop e1000 interrupt immediately.
 1.766 26-Oct-2022  msaitoh Add comment to ICH/PCH's lock stuff in wm_reset().
 1.765 19-Oct-2022  msaitoh Fix typo. No functional change. OK'd by knakahara.
 1.764 08-Sep-2022  msaitoh KNF. Modify comment. No fucntional change.
 1.763 12-Aug-2022  riastradh wm(4): Remove the non-MP-safe scaffolding.

- Where we had #ifndef WM_MPSAFE splnet(), we also had WM_CORE_LOCK,
which implies splnet, so just remove the conditional splnet.

- Make the core lock unconditional and remove macro indirections.

- Pass CALLOUT_MPSAFE, SOFTINT_MPSAFE, and WQ_MPSAFE directly without
macro indirections.
 1.762 12-Aug-2022  riastradh wm(4): Audit sc->phy.acquire and sc->nvm.acquire.

The return value must be used, because some of the acquire/release
pairs hold a mutex from acquire to release, and failing to call
release, or calling release twice, leads to an inconsistent state.
 1.761 12-Aug-2022  riastradh wm: use a workqueue to reset the interface when wm_watchdog determines it needs a reset.


Author: Nick Hudson <skrll@netbsd.org>
Committer: Taylor R Campbell <riastradh@NetBSD.org>
 1.760 12-Aug-2022  riastradh wm(4): if_flags and IFNET_LOCK audit

Don't touch if_flags without IFNET_LOCK:

- If only core lock is held, use sc_if_flags.
- If only txq lock is held, use txq_stopping.
=> Verified all paths guarantee !txq_stopping, so assert.
- Make sure sc_if_flags is updated on stop.
- Make wm_init fail once we enter wm_detach.
- Sprinkle assertions.


Author: Taylor R Campbell <riastradh@NetBSD.org>
 1.759 12-Aug-2022  riastradh wm(4): Revert previous -- mistakenly committed unsquashed change part.
 1.758 12-Aug-2022  riastradh wm(4): if_flags and IFNET_LOCK audit

Don't touch if_flags without IFNET_LOCK:

- If only core lock is held, use sc_if_flags.
- If only txq lock is held, use txq_stopping.
=> Verified all paths guarantee !txq_stopping, so assert.
- Make sure sc_if_flags is updated on stop.
- Sprinkle assertions.
 1.757 08-Aug-2022  msaitoh To avoid releasing mutex temporally, use new wm_set_mdio_slow_mode_hv_locked().
 1.756 08-Aug-2022  msaitoh Consistency use -1 instead of 1 for some error code. Advised by knakahara.
 1.755 08-Aug-2022  msaitoh Pass an error code correctly if phy.acquire() failed.

This is not a real bug because the return value is not used.
 1.754 08-Aug-2022  msaitoh Pass an error code to the upper layer instead of -1. Advised by knakahara.
 1.753 08-Aug-2022  msaitoh Modify debug messages so that we can determine where it happened.
 1.752 05-Aug-2022  skrll Sprinkle const on splfoo call results.
 1.751 03-Aug-2022  skrll Add a KASSERT for the locking protocol in wm_ioctl.

Read the interface up/down status from sc_if_flags (under WM_CORE_LOCK)
when deciding if the multicast filter needs to be updated.

Discussed with msaitoh@, knakahara@ and riastradh@
 1.750 03-Aug-2022  skrll Add some KASSERTs around the locking protocol.

Discussed with msaitoh@, knakahara@ and riastradh@
 1.749 29-Jul-2022  skrll Improve a couple of comments
 1.748 29-Jul-2022  skrll Trailing whitespace
 1.747 28-Jul-2022  skrll KNF the KNF
 1.746 22-Jul-2022  msaitoh Add more statistics countes.

- Add many statics counters that the chip has.
- Attach event counters only if available.
 1.745 19-Jul-2022  riastradh wm(4): Use CSR_WRITE_FLUSH, not bus_space_barrier.

The bus space is mapped non-prefetchable and non-cacheable, so there
is no need for bus_space_barrier and it might not even have any
effect -- bus_space_read/write are totally ordered for non-
prefetchable, non-cacheable mappings anyway. Presumably the intent
here was to wait for acknowledgment of the write from the device --
which bus_space_barrier does not guarantee, and which I expect
requires a read transaction as CSR_WRITE_FLUSH performs.

ok msaitoh@, knakahara@
 1.744 19-Jul-2022  riastradh wm(4): Use bus_dmamap_sync, not bus_space_barrier, for tx desc.

The newly written tx descriptor needs to be visible to the device
before the TDT register is set. There's no bus space mappings that
need any barriers, though -- nothing mapped prefetchable or cacheable
here. So bus_dmamap_sync (via wm_cdtxsync) is necessary, not
bus_space_barrier. By accident, bus_space_barrier implies the same
barrier instructions as bus_dmamap_sync on some architectures, but it
wouldn't work at all if we were bouncing.

ok msaitoh@, knakahara@
 1.743 19-Jul-2022  skrll KNF
 1.742 19-Jul-2022  skrll Don't need sys/malloc.h so remove the #include
 1.741 19-Jul-2022  skrll Turn a locking botch (shouldn't drop lock on error) into a KASSERT
 1.740 11-Jul-2022  msaitoh KNF. No functional change.
 1.739 11-Jul-2022  msaitoh Consistently use semicolon. No functional change.
 1.738 06-Jul-2022  msaitoh Call txeof first, then rxeof for the consistency.

There are three functions where the txeof and rxeof are called. The MSI-X
interrupt function and the workqueue function call rxeof first, then rxeof.
For legacy interrupt. rxeof is called first. Modify it to match with other
two.
 1.737 06-Jul-2022  msaitoh Fix compile error if WM_DEBUG is set.
 1.736 04-Jul-2022  skrll Be less tautological and more explanatory in a comment.
 1.735 02-Jul-2022  skrll Use PRIxBIT instead of casts
 1.734 02-Jul-2022  skrll wm_tick: Add missing splx(s) when not WM_MPSAFE
 1.733 19-May-2022  msaitoh Don't set the more flag when there is no packet to process.

Move the location of the loop limit check next to the DD bit test. This
change prevent from scheduling the next txrx_work that does nothing.
 1.732 19-May-2022  msaitoh Call wm_xxeof() only when limit > 0.

It's not required to call wm_xxeof() when limit == 0. It means that
all xxeof processing will be done by softint or workqueue. Currently,
wm_xxeof() returns quickly before checking the descriptor head when
limit == 0 and return with ture to set the more flag.
 1.731 17-May-2022  msaitoh Call m_freem(m) only if m0 == NULL.
 1.730 03-May-2022  gutteridge if_wm.c: various spelling and grammar fixes
 1.729 26-Feb-2022  rillig if_wm.c: fix value return from void function

lint complained:
if_wm.c(10028): error:
void function wm_txrxintr_disable cannot return value [213]
if_wm.c(10049): error:
void function wm_txrxintr_enable cannot return value [213]

No functional change.
 1.728 26-Feb-2022  rillig if_wm.c: remove stray semicolons from struct declaration

C99 does not allow 'struct { int member;; }'.

No binary change.
 1.727 16-Feb-2022  msaitoh Remove duplicated break. No functional change.
 1.726 31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.725 23-Dec-2021  hannken Keep constants 32 bit, why does __BIT() return uintmax_t?
 1.724 20-Dec-2021  skrll aprint_verbose the DMA range used.
 1.723 20-Dec-2021  skrll whitespace in a comment
 1.722 11-Dec-2021  skrll Typo in comment
 1.721 10-Dec-2021  skrll Simplify. Same code before and after.
 1.720 10-Dec-2021  skrll Trailing whitespace
 1.719 05-Dec-2021  msaitoh s/checkum/checksum/ in comment.
 1.718 05-Nov-2021  msaitoh Fix a bug that device timeout still happens on ICH/PCH. Fixes PR kern/56478.

- if_wm.c rev. 1.695 for PR kern/40981 still had a problem. The workaround
flag was unexpectedly cleared when a cable is not connected, SIOCINITIFADDR
was called, or if_init was called. Fix it.
- Add debug printf()s.
 1.717 05-Nov-2021  msaitoh Use macro. No functional change.
 1.716 04-Nov-2021  msaitoh Add some sysctl info for debugging.
 1.715 20-Oct-2021  msaitoh Use wm_flush_desc_rings() more.

- Use wm_flush_desc_rings() for newer than PCH_SPT, too. Same as other OSes.
It seems that some devices has no this errata, but we don't know how to
identify it. So just use >= PCH_SPT.
- Use wm_flush_desc_rings() before chip reset in wm_resume(), too.
 1.714 20-Oct-2021  msaitoh Disable printf()s in wm_flush_desc_rings() because the code is verified.

The problem was very rare, so I added those printf()s as we can see.
Last week, knakahara and I found a procedure to reproduce the problem and
verified it worked correctly.

To reproduce the problem:

0) Use I219 V1 to V5. Not all of them have the problem and newer than V5 may
have the problem. I used V2 for the test.
1) Define WM_DEBUG or add printf in wm_flush_desc_rings() to see
DESCRING_STATUS_FLUSH_REQ bit.
2) Run "iperf -s" on the DUT.
3) Run "iperf3 -R -u -c 192.168.1.110 -w 8m -b 1g" repeatedly on another
machine. Note that kern.sbmax should be increased on both machines.
4) run
while true; do
ifconfig wm0 down up
sleep 30
done
5) After DESCRING_STATUS_FLUSH_REQ is set, without wm_flush_desc_rings(),
TX stalls and reboot is required to recover from it.
With wm_flush_desc_rings(), no device hang.
6) If you can't see the DESCRING_STATUS_FLUSH_REQ is set, change the media
to 100BASE-T.

Note that if_wm.c rev. 1.710 originally written by chuq is required for the
test. Without the change, the device becomes unrecoverable state before
wm_flush_desc_rings() and the function doesn't recover from the problem.
 1.713 20-Oct-2021  msaitoh Change DMA physical address in wm_flush_desc_rings() to match other OSes.

- Even without this change, the workaround works with my machines.
- Add comment.
 1.712 20-Oct-2021  knakahara Fix return value of interrupt handler, pointed out by msaitoh@n.o.

Even if stopping flag is set (and handler do nothing), the interrupt
itself should be assume to be processed when ICR is not zero. If not,
interrupt count is not incremented correctly.
 1.711 20-Oct-2021  knakahara Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.

Because the difference has caused INTx/MSI own bugs.
 1.710 20-Oct-2021  knakahara Fix Tx stall, reported and implemented original patch by chs@n.o, thanks.

Check if_snd queue because if.c::if_transmit() doesn't call ifp->if_start()
when IFQ_ENQUEUE failed.

Reviewed and tested by chs@n.o and msaitoh@n.o.
 1.709 18-Oct-2021  jmcneill Only print an error about missing I/O BARs for chips that need it.
 1.708 13-Oct-2021  msaitoh Add support for I219V 15-19 and I219LM 16-19.
 1.707 13-Oct-2021  msaitoh Print I219's version number.
 1.706 03-Aug-2021  knakahara Fix locking against myself reported by rin@n.o.

In some machine, INTx interrupts occurs for some reason while holding
txq_lock in softint context.
e.g. https://dmesgd.nycbug.org/index.cgi?do=view&id=6139

The panic message is the following.
 1.705 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.704 12-May-2021  knakahara Fix i386 build failure with options WM_EVENT_COUNTERS.

pointed out by msaitoh@n.o.
 1.703 03-May-2021  rillig branches: 1.703.2;
if_wm: do not return a void value from a void function

This is a GCC extension.
 1.702 11-Mar-2021  msaitoh branches: 1.702.4;
Whitespace fixes. No functional change.
 1.701 01-Mar-2021  knakahara Refactor rxq->rxq_ptr updating.
 1.700 01-Mar-2021  knakahara Remove extra unlock/lock processing around if_percpuq_enqueue().

This temporary unlock/lock processing was required for direct calling
ifp->if_input. After r1.391, wm(4) uses if_percpuq_enqueue() and it
does not hold any mutexes.
 1.699 17-Feb-2021  knakahara In 64 bit architectures, WM_EVENT_COUNTER is enabled by default.

No objection from tech-kern@n.o and tech-net@n.o.

ok'ed by msaitoh@n.o.
 1.698 17-Feb-2021  knakahara wm(4) use atomic_{load,store}_relaxed for evcnt 64 bit counter.

ok'ed by msaitoh@n.o.
 1.697 19-Nov-2020  msaitoh Add some sysctl values for debugging TX/RX queues.
 1.696 16-Nov-2020  rin Fix little-endian dependence in wm_rxeof(), by which packets cannot be
received by 82574 and successors on big-endian machines.

Tested by aarch64eb with I210-T1 on ROCKPro64.

Thanks msaitoh for discussion!

XXX
pullup to netbsd-9 and netbsd-8
 1.695 02-Nov-2020  knakahara Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).

These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981

Reviewed and tested by msaitoh@n.o, thanks.

XXX pullup-[89]
 1.694 30-Oct-2020  msaitoh branches: 1.694.2;
Add WMPHY_I350. Not used yet.
 1.693 30-Oct-2020  msaitoh Add new sysctl hw.wmN.debug_flags. This sysctl can be used if WM_DEBUG is set.
OK'd by knakahara.

% sysctl -d hw.wm0.debug_flags
hw.wm0.debug_flags: Debug flags:
0x01 LINK
0x02 TX
0x04 RX
0x08 GMII
0x10 MANAGE
0x20 NVM
0x40 INIT
0x80 LOCK
 1.692 28-Oct-2020  msaitoh Add missing drain for pcq in wm_stop_locked(). OK'd by knakahara.

This change fixes two problems:
1. If the pcq is full and watchdog timer is fired, the full state of the
pcq is kept and wm_transmit() returns with ENOBUFS.
2. ifconfig down doesn't free mbufs in the pcq.
 1.691 16-Oct-2020  msaitoh Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=000000, model=0000" and
"PHY type is still unknown." Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).
 1.690 24-Sep-2020  msaitoh Small fixes from knakahara:

- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Fix comment.
 1.689 16-Sep-2020  msaitoh Use 12K for packet buffer for jumbo frame on PCH2 and newer.

XXX Note that Linux Use 14K.
 1.688 16-Sep-2020  msaitoh Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.

- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.

XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
FreeBSD and Linux do the same thing that they set the same value on both
jumbo frame's enable case and the disable case. It seems the default value
is 0x0b0c and it's not changed on the enable case, so it might be a bug
on the enable case or the modification is not required.

- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.
 1.687 15-Sep-2020  msaitoh Add new flag named WM_F_CRC_STRIP and use it. No functional change.

This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.
 1.686 24-Aug-2020  msaitoh s/ressource/resource/. Found by knakahara.
 1.685 05-Aug-2020  msaitoh Set if_baudrate for non-MII device. Before this commit, it was 0.
 1.684 05-Aug-2020  msaitoh Explicitly cast from uint16_t to uint32_t before shifting 16bit left
when printing Image Unique ID. Found by kUBSan.
 1.683 03-Aug-2020  msaitoh Setup PCS and SGMII for SFP correctly. It still doesn't support SFP
insertion/removal.

Copper:
wm2: SGMII(SFP)
wm2: 0x1043c440<SPI,IOH_VALID,PCIE,SGMII,NEWQUEUE,ASF_FIRM,EEE,SFP>
makphy0 at wm2 phy 6: Marvell 88E1111 Gigabit PHY, rev. 1

Fiber:
wm3: SERDES(SFP)
wm3: 0x10034440<SPI,IOH_VALID,PCIE,NEWQUEUE,ASF_FIRM,SFP>
wm3: 1000baseSX, 1000baseSX-FDX, auto
 1.682 03-Aug-2020  msaitoh s/MII_IGPHY_/IGPHY_/. No functional change.
 1.681 09-Jul-2020  msaitoh "wmX: 0" on 82542 is difficult to understand, so don't print it.
 1.680 06-Jul-2020  msaitoh Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if the system
uses iNVM.
 1.679 27-Jun-2020  jmcneill prop_data_data_nocopy -> prop_data_value
 1.678 11-Jun-2020  msaitoh No functional change:

- Rename some macros and function.
- Add newline.
 1.677 11-Jun-2020  thorpej Update for proplib(3) API changes.
 1.676 30-Apr-2020  riastradh Make WM_NRXDESC unsigned.
 1.675 30-Apr-2020  riastradh Revert "- rnd_add_*() call must be serialized. Unserialized accesses broke the"

It is no longer necessary to serialize calls to rnd_add_data, so we
can use the same rndsource for every queue.

This also reverts some unrelated changes that were mixed in:

1. WM_NRXDESC was made unsigned
2. The specific samples were changed.

(1) will be redone in a separate commit. (2) was buggy (wrote `='
where `|=' was meant) and is not needed; it's fine to do rnd_add_data
in a thread or softint too, not just in a hard interrupt handler.
 1.674 09-Apr-2020  jdolecek adjust the condition for reusing checksum context, wm_tx_offload() can
be used even for multiqueue case

enable only when the chip supports exactly one queue (same as FreeBSD) -
anything multiqueue-capable later than 82574 should work, but I don't
have the hw to test
 1.673 08-Apr-2020  jdolecek wm_tx_offload() and wm_nq_tx_offload() actually always return 0, make them
return void and remove the check for their return value
 1.672 08-Apr-2020  jdolecek fixup field names in previous
 1.671 08-Apr-2020  jdolecek actually writing always the checksum offload context descriptor
makes the hw do extra processing, avoid doing that if possible -
on my computer with I219 this results in about 2% speedup in Tx performance

change adoped from FreeBSD

XXX should be also done for multiqueue case, but I don't have hw to test it
 1.670 21-Mar-2020  thorpej branches: 1.670.2;
Don't bother with IFF_OACTIVE.
 1.669 15-Mar-2020  thorpej Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.668 18-Feb-2020  msaitoh It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear in
case it's already set.
 1.667 18-Feb-2020  msaitoh Whitespace fix. No functional change.
 1.666 31-Jan-2020  knakahara wm(4) unset RSS UDP flags like ixg(4) and other OS's one.

To handle IP fragmented UDP first packet and second packet by the same
Rx queue.

I tested on I354.
 1.665 31-Jan-2020  knakahara Fix missing workqueue_destroy(). ok by msaitoh@n.o
 1.664 31-Jan-2020  knakahara Fix wm(4) create too many workqueue. Pointed out by msaitoh@n.o
 1.663 29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.662 24-Jan-2020  knakahara wm(4) can use workqueue as deferred Rx/Tx handler like ixg(4).

Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0, that is, use softint
as before.

ok by msaitoh@n.o.
 1.661 23-Jan-2020  knakahara fix softint_disestablish() in wm_detach().

ok by msaitoh@n.o

XXX pullup-8, pullup-9
 1.660 21-Jan-2020  msaitoh Add Intel I219 LM10-LM15 and V10-V14 from OpenBSD.
 1.659 20-Jan-2020  thorpej No longer need to go to splnet() before calling ifmedia_ioctl()
in the NET_MPSAFE; ifmedia_ioctl() will do this for us, if needed.
 1.658 13-Dec-2019  msaitoh branches: 1.658.2;
KNF. No functional change.
 1.657 12-Dec-2019  knakahara fix build failure. ok by msaitoh@n.o.
 1.656 12-Dec-2019  msaitoh Add SFP support part 2.

- Add code for 1000BASE-T SFP. It uses SGMII.
- Add extra delay in wm_serdes_power_up_link_82575(). Same as other OSes.

TODO:
- Module insertion/removal support. Currently, SFP detection is only done
in the driver's attach phase.
 1.655 11-Dec-2019  msaitoh Add SFP support part 1. The code for SerDes and SGMII setting is not include
in this commit. SFP module removal interrupt detects but not used yet:
- Detect SFP's 1000BASE-SX, 1000BASE-LX, 100BASE-FX and 1000BASE-T correctly.
- Detect the Media Auto Sense feature. Not supported yet.
- Add comment.
 1.654 11-Dec-2019  msaitoh - Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580 port 1, 2, 3 and
newer chips. This change fixes a bug that some fiber, serdes or SFP devices
don't detect the link status correctly.
XXX We should check for other NVM reads if they have the same problem. One of
the solution to avoid this type of bug is to check the register layout
in wm_nvm_read().
- Use __BIT()
- Add comment
 1.653 11-Dec-2019  msaitoh - MSI-X doesn't use sc->sc_icr variable, so move the code into non-MSI-X part.
No functional change intended. OK'd by knakahara.
- Modify debug printfs a bit.
 1.652 11-Dec-2019  msaitoh No functional change:
- Add defintion of CONNSW register and PCS_NPTX (not used yet).
- Add some bit definitions of PCS_LCTL.
- Renae macro.
- Fix comment. Add comment.
- KNF.
 1.651 09-Dec-2019  msaitoh Fix a bug that wm_sgmii_readreg_locked() may return error even if error isn't
occured.
 1.650 04-Dec-2019  msaitoh Simplify. No functional change.
 1.649 26-Sep-2019  msaitoh Fix typo in comment.
 1.648 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.647 04-Sep-2019  msaitoh printf -> device_printf
 1.646 01-Aug-2019  msaitoh Use unsigned to avoid undefined behavior in wm_i82543_mii_sendbits().
Found by kUBSan.
 1.645 30-Jul-2019  msaitoh branches: 1.645.2;
- rnd_add_*() call must be serialized. Unserialized accesses broke the
sc->rnd_source structure and caused off by one in kern_rndq.c's
rnd_add_data_ts(). This problem was found by kUBSan. Make krndsource_t's
data per queue-pair and call rnd_add_uint32() in wm_txrxintr_msix(). One of
the reason why rnd_add_uint32() calls were moved from wm_{tx,rx}eof() is that
rnd(9) manual page says "To allow the system to gather the timing information
accurately, this call should be placed within the actual hardware interrupt
service routine."
- Pass a better value to rnd_add_uint32() in wm_intr_legacy().

XXX pullup-8.
 1.644 26-Jul-2019  msaitoh Use aprint_debug_dev() instead of printf() in wm_ulp_disable().
 1.643 25-Jul-2019  tnn wm: change one bus_dmamap_load_mbuf() to bus_dmamap_load() equivalent

This makes wm work on aarch64, where the bus_dma implementation requires
the mbuf data pointer be immutable between bus_dmamap_load_mbuf and
bus_dmamap_sync. Fix suggested by thorpej@
 1.642 09-Jul-2019  msaitoh Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.641 12-Jun-2019  msaitoh Print ICH/PCH's NVM version.
 1.640 07-Jun-2019  msaitoh Use unsigned. Found by UBSan. OK'd by kamil.
 1.639 28-May-2019  msaitoh s/recieve/receive/
 1.638 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.637 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.636 15-May-2019  ozaki-r Store IFF_ALLMULTI in ec_flags instead of if_flags to avoid data races

IFF_ALLMULTI is set/unset to if_flags via if_mcast_op. To avoid data races on
if_flags, IFNET_LOCK was added for if_mcast_op. Unfortunately it produces
a deadlock so we want to remove added IFNET_LOCK by avoiding the data races by
another approach.

This fix introduces ec_flags to struct ethercom and stores IFF_ALLMULTI to it.
ec_flags is protected by ETHER_LOCK and thus IFNET_LOCK is no longer necessary
for if_mcast_op. Note that the fix is applied only to MP-safe drivers that
the data races matter.

In the kernel, IFF_ALLMULTI is set by a driver and used by the driver itself.
So changing the storing place doesn't break anything. One exception is
ioctl(SIOCGIFFLAGS); we have to include IFF_ALLMULTI in a result if needed to
export the flag as well as before.

A upcoming commit will remove IFNET_LOCK.

PR kern/54189
 1.635 14-May-2019  ozaki-r Remove unnecessary checks of IFF_ALLMULTI

IFF_ALLMULTI is changed by only driver itself, so we don't need to check its
change on ec_ifflags_cb.

This is part of PR kern/54189. NFCI.
 1.634 24-Apr-2019  msaitoh SIOCS is 'S'et function and the ioctl argument is ifreq.
SIOCG is 'G'et function and the ioctl argument is ifmediareq.
Before this change, SIOCG modify sc->sc_flowflags unexpectedly.
Don't hook SIOCGIFMEDIA because this driver uses MII(4) and ether_ioctl has
the hook(if_ethersubr.c rev. 1.160). This driver might require some additional
fixes for SIOCSIFMTU and other ioctl()s.

XXX pullup-[78].
 1.633 24-Apr-2019  msaitoh KNF. No functional change.
 1.632 25-Mar-2019  msaitoh Pass error status to the upper layer in wm_gmii_{i82544,i80003}*().
 1.631 05-Mar-2019  msaitoh Add Intel I219 variations for Cannon Lake.
 1.630 04-Mar-2019  msaitoh Use do { ... } whille (0) for DPRINTF(x, y).
 1.629 28-Feb-2019  khorben Typo (s/vaule/value/)
 1.628 23-Feb-2019  kamil Fix GCC7 "avoid ambiguous 'else'" build error in if_wm.c

Detected with kUBSan NetBSD/i386 build.
 1.627 21-Feb-2019  knakahara Fix panic when wm(4) is reattached. ok by msaitoh@n.o.

This panic occured after kern_rndq.c:r1.90.
 1.626 08-Feb-2019  msaitoh - Add support for I210 SGMII Flash-less device.
- Add KASSERT.
- Update TODO list.
 1.625 07-Feb-2019  msaitoh Fix a bug that WOL didn't work on some chips since if_wm.c rev. 1.610.
Set WUC_APME bit older than PCH. Will fixes PR kern/53945 reported by kardel@.
Tested with my own 82574 card.
 1.624 06-Feb-2019  msaitoh I21[01]'s RAL size is not 15 but 16(== 82575's value). Same as other OSes.
 1.623 31-Jan-2019  msaitoh Add yet another PHY workaround. Disable generation of early preamble on 82577
PHY rev. 1 or 2 and 82578 PHY rev. 1.
 1.622 31-Jan-2019  msaitoh We now have IFM_2500_KX and IFM_1000_KX, so use them.
 1.621 31-Jan-2019  msaitoh Add some workarounds which use EMI register or EEE related:
- PCH only: Add workaround for link disconnects on a busy hub in half duplex.
- PCH and PCH2 only: Set MSE higher to enable link to stay up when noise is
high.
- PCH2 only: Drop link after 5 times MSE threshold was reached.
- PCH2 only: Set EEE LPI Update Timer to 200usec.
- For PCH2 and newer: When connected at 10Mbps half-duplex, some parts are
excessively aggressive resulting in many collisions. To avoid this, increase
the IPG and reduce Rx latency in the PHY.
- For I21[789] and if EEE is enabled: Disable LPLU if both link partners
support 100BaseT EEE and 100Full is advertised on both ends of the link, and
enable Auto Enable LPI since there will be no driver to enable LPI while in
Sx.
 1.620 25-Jan-2019  msaitoh 80003's SERDES is not the same as 82575's but the same as legacy devices.
Use the old methods on 80003.

XXX The reason why this bug existed is that our order of WM_T_* was little
different from FreeBSD's enum e1000_mac_type. From 80003 to PCH_CNP and from
82575 to I211 are swapped. I carefully read through if_wm.c and knew only
serdes related test were wrong. When we change WM_T_* to match FreeBSD's,
additional changes also will be required.
 1.619 25-Jan-2019  msaitoh Use __nothing (== ((void)0)) instead of "do {} while (/*CONSTCOND*/false)".
 1.618 24-Jan-2019  msaitoh No functional change intended:
- Use "do {} while (/*CONSTCOND*/false)" for null DPRINTF().
- Reduce indent level of wm_linkintr_gmii().
 1.617 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.616 11-Jan-2019  msaitoh Set I82579_LPI_CTRL register correctly in wm_set_eee_pchlan().
 1.615 09-Jan-2019  msaitoh - Remove an extra register read in wm_kmrn_lock_loss_workaround_ich8lan().
- Don't leave the MDICNFG register modified when the Power Management
capability offset can't get.
 1.614 07-Jan-2019  msaitoh Add EEE(802.3az) support for I350, I210, I211, PCH2 and newer.

Not yet for I354(C2000). It'll be supported after implementing MI MII clause
45 register read/write API.
 1.613 03-Jan-2019  msaitoh Fix error check. reported by David Binderman in kern/53821.
 1.612 30-Dec-2018  msaitoh Accept IFM_NONE.
 1.611 21-Dec-2018  msaitoh Fix WoL detection once again.
 1.610 20-Dec-2018  msaitoh - Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
 1.609 20-Dec-2018  msaitoh Fix WoL capability detection on ICH and PCH.
 1.608 20-Dec-2018  msaitoh Rename functions. Add comment. No functional change.
 1.607 17-Dec-2018  msaitoh When sc->phy.acquire() failed, it's not required to call sc->phy.release().
 1.606 17-Dec-2018  knakahara Fix txqueue assignment. Pointed out by yamaguchi@n.o, thanks.

E.g. When ncpu is six and nqueue is four, the sequence error occurs.

XXX pullup-8
 1.605 15-Dec-2018  msaitoh Print and clear the wakeup status only when the WUS register != 0.
 1.604 14-Dec-2018  msaitoh - Fix availability detection of WoL on some chips. This change has no effect
other than dmesg because WM_F_WOL is currently not used to change the behavior:
- For ICH/PCH, check the capability not from NVM but from the WUC register.
Check the value before clearing the register.
- 82580 and newer have per-port NVM block, so read the area correctly.
Note that 82580, I350 and I354 may have PCI function 2 and 3.
- Some devices can't detect WoL capability neither from NVM nor from WUC.
Use PCI device ID and the function number.
- Print the WUS (WakeUp Status) register bits when resume.
 1.603 12-Dec-2018  msaitoh Add some code for suspend/resume:
- Rename wm_smbustopci() to wm_init_phy_workarounds_pchlan(). It will also
called when resume.
- Call wm_phy_resetisblocked() after PHY reset in
wm_init_phy_workarounds_pchlan() to wait for the PHY to quiesce to an
accessible state.
- Add new wm_resume_workarounds_pchlan() function and use it in wm_resume().
This workaround is only for PCH2 and newer.
- Don't call wm_disable_aspm() neither in wm_attach() nor in wm_resume()
but in wm_reset().
- Do some initialization in wm_resume() when IFF_UP is NOT set.
- Don't continue when it failed to acquire semaphore in wm_ulp_disable().
- Add comment.
 1.602 28-Nov-2018  msaitoh Fix comment. No functional change.
 1.601 22-Nov-2018  msaitoh - Add wm_k1_workaround_lv() from FreeBSD. It's PCH2 specifc:
Workaround to set the K1 beacon duration for 82579 parts in 10Mbps.
Disable K1 for 1000 and 100 speeds.
- Make wm_link_stall_workaround_hv() and move an 82578 specific code into it.
Don't apply the workaround if BMCR_LOOP bit is set. Same as FreeBSD.
- Add comment. Modify comment.
 1.600 20-Nov-2018  msaitoh - Add wm_oem_bits_config_ich8lan() to control LPLU and GbE setting base on
the NVM's info.
- Modify wm_enable_wakeup() to reduce difference against FreeBSD and Linux.
This modification affects to ICH8 and newer devices. I217 Rapid Start
Technology support have not written yet (it's TODO).
 1.599 20-Nov-2018  msaitoh - Fix a bug that i82578 PHY can't detect correctly.
- Print PHY OUI and model number if a PHY's can't be identified.

XXX pullup-[78]
 1.598 19-Nov-2018  msaitoh - Control TX/RX descriptor snooping control bits on ICH8 and newer.
Only on ICH8, No-snoop bits are opposite polarity. On my Thinkpas X61,
the default value of this bits are all zero, so this commit changes
the snoop function enable on the machine. I tested with some other
PCH machines and those bits are all zero (enable snoop by default),
so this commit won't affect to some machines.
- Disable relax ordering on 82546GB(Device ID 0x1099 and 0x10b5) or >= ICH8.
Same as other OSes.
 1.597 14-Nov-2018  msaitoh - Add new wm_gmii_{hv,i82544}_{read,write}reg_locked() and use them in
wm_gmii_{hv,i82544}_{read,write}reg(). *_locked() functions are not
mii(4) API functions, so it's not required to keep the mii API. Change
the PHY register type from int to uint16_t. It also change the usage of
return value. It returns zero on success and non-zero on error.
- Check the return value of *_locked() function and treat it.
- Use *writereg_locked() function to reduce race condition in
wm_init_lcd_from_nvm().
- Add comment.
 1.596 03-Nov-2018  christos make this compile again (rv was uninitialized)
 1.595 02-Nov-2018  msaitoh KNF a bit. No functional change.
 1.594 02-Nov-2018  msaitoh - Add missing wm_gate_hw_phy_config_ich8lan(false) in wm_phy_post_reset()
on PCH2. wm_gate_hw_phy_config_ich8lan(true) is called in wm_reset(), so
wm_phy_post_reset(false) should be called after reset.
- On PCH2, set the phy config counter to 50msec after (PHY) reset.
 1.593 02-Nov-2018  msaitoh After writing MDIC register, don't read quickly the same register but
do delay(50). Same as otehr OSes.
 1.592 02-Nov-2018  msaitoh Fix a PCH2 specific bug that wrong register value can be read when boot.
When a wrong value is read when boot, the read device ID was incorrect and
ukphy(3) is attached instead of ihphy(4). The bug might also result in
MDIC read/write error.

How to reproduce:

0) Boot Windows.
1) Leave some minutes.
2) Reboot to NetBSD.

To fix this problem, adding extra 100us delay at the end of
wm_gmii_mdic_{read,write}reg() on PCH2. Same as FreeBSD and linux.

Reported by David Brownlee a few days ago and also reported by jmcneill
a half year ago. Tested with my own Thinkpad X220.

XXX pullup-[78]
 1.591 02-Nov-2018  msaitoh Add workaround for DMA hang problem which result in TX device timeout on
PCH_LPT with I218. Same as FreeBSD and Linux. This woraround is only for
device ID 0x155a, 0x15a2, 0x1559 and 0x15a3. I observed this problem on my
Shuttle DS57U's I218 port six times in two months.
 1.590 31-Oct-2018  msaitoh - 82574 and newer's document says the status field has neither EC
(Excessive Collision) bit nor LC (Late Collision) bit (reserved).
Refer "PCIe GbE Controller Open Source Software Developer's Manual",
82574 datasheet and newer.

XXX I saw the LC bit was set on I218 even though the media was full duplex,
so the bit might be used for other meaning ...(I have no document).
- Use macro.
 1.589 05-Oct-2018  msaitoh Fix KASSERT to prevent panic on CNP(Intel 300 series + I219) with INTx
interrupt (Xen dom0 or pre netbsd-8).

XXX pullup-[78]
 1.588 12-Sep-2018  msaitoh Fix comment.
 1.587 12-Sep-2018  msaitoh - Try m_defrag() to reduce the number of DMA segment if bus_dmamap_load_mbuf()
returned EFBIG. When m_defrag() is called, txqNNdefrag event counter is
incremented. If the 2nd try of bus_dmamap_load_mbuf() failed, txqNNtoomanyseg
event counter is incremented.

- Reduce the max number of DMA segemts from 256 to 64 (it's the same valuse
as other BSD's (EM_MAX_SCATTER) and more than before if_wm.c rev. 1.75's
value (40)) because we do m_defrag() now.
 1.586 12-Sep-2018  msaitoh - Split txdrop evcnt into pcqdrop and descdrop.
- Simplify evcnt name by removing duplicated "tx" or "rx".
- s/tu/underrun/
 1.585 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.584 09-Aug-2018  msaitoh Fix two bugs for non-SERDES fiber. Tested on 82544EI(0x1009), 82545GM(0x1027),
82546GB(0x107a), 82571GB(0x105f), 82572EI(0x107e). Tested on SERDES
82580(0x150e (Winyao SERDES SFP)) and 82580(0x150e) as regression test:

- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber. When the signal is detected & STATUS_LU == 0 & RXCW == 0,
it's required to set CTRL_SLU and CTRL_FD bit. wm_check_for_link() is the
function to do it. If a link status change interrupt occured, call
wm_check_for_link() before checking current link staus.
- Fix a bug that 82542 misunderstand fiber's signal detection. CTRL_SWDPIN(1)
is used for fiber's signal and it's value is reversed only on 82543 and
82544. Simplify the code and move it into a new function wm_tbi_havesignal()
and use it.
 1.583 26-Jun-2018  msaitoh branches: 1.583.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.582 20-Jun-2018  msaitoh Style fix. No functional change.
 1.581 01-Jun-2018  maxv Rename

M_CSUM_DATA_IPv6_HL -> M_CSUM_DATA_IPv6_IPHL
M_CSUM_DATA_IPv6_HL_SET -> M_CSUM_DATA_IPv6_SET

Reduces the diff against IPv4. Also, clarify the definitions.
 1.580 25-May-2018  ozaki-r Ensure to call if_register after interface initializations finish
 1.579 10-May-2018  msaitoh KNF. No binary change.
 1.578 08-May-2018  msaitoh Fix a bug that TX might stall because WM_TXQ_NO_SPACE is not cleared in
if_init() (though I've never seen this problem). Clear txq->txq_flags in
wm_init_tx_queue(). OK'd by knakahara.
 1.577 08-May-2018  msaitoh rxipsum and rxtusum are not interrupt counter, so use EVCNT_TYPE_MISC
instead of EVCNT_TYPE_INTR.
 1.576 23-Apr-2018  msaitoh - Backout if_wm.c rev.1.574 and print "device timeout (lost interrupt)"
when all descriptors in a queue are free. When all descriptors are free after
wm_txeof(), it's caused by lost interrupt (though I've never seen it). One
possibility is chip bug and another possibility is software bug. We should
reset in any cases. If we don't reset and don't print error message, TX
processing is done intermittently and user might not noticed the problem.

- Rename txq_watchdog to txq_sending to make the meaning clear.
 1.575 23-Apr-2018  msaitoh Count timeout correctly. This change reduce timeout value for 80003 as
expected. Reported by mouse@.
 1.574 20-Apr-2018  msaitoh Fix watchdog timer. Without this change, watchdog timer is unnecessary
fired and device is initialized without any error message. OK'd by knakahara.
 1.573 16-Apr-2018  msaitoh KNF. No functional change.
 1.572 13-Apr-2018  msaitoh I354 uses an external PHY, so don't use wm_set_eee_i350().
 1.571 13-Apr-2018  msaitoh Enable I219.
 1.570 12-Apr-2018  msaitoh Add PCH_CNP support (I219 with Intel 300 series chipset).
It's required more test, so it's disabled by default.
 1.569 12-Apr-2018  msaitoh If the extended configration size in the EXTCNFSIZE register is 0, don't
continue.
 1.568 12-Apr-2018  msaitoh Our PCH_SPT part of wm_nvm_valid_bank_detect_ich8lan() was based on
FreeBSD r287467. After that, they reverted it and committed the different
code in r287762. r287762's bank detect code didn't work for us because our wm
dirver had a problem in flash access. The problem was fixed in if_wm.c rev.
1.567, so we can use the new way now.
 1.567 12-Apr-2018  msaitoh On PCH_SPT (and newer), FLASH access should be done by 32bit.
Especially for ICH_FLASH_HSFCTL register, it's located at 0x0006, so
it should be accessed via ICH_FLASH_HSFSTS(0x0004) and use shift or mask.
 1.566 01-Mar-2018  msaitoh branches: 1.566.2;
Do wm_reset_mdicnfg_82580() on 82580 only.
 1.565 01-Mar-2018  msaitoh - Fix a bug that wm_pll_workaround_i210() is not called on some cases.
As I wrote in if_wm.c rev 1.329's commit message, There are three cases:

a) Chip is I211
b) Chip is I210 and it uses INVM (not FLASH)
c) Chip is I210 (it uses FLASH) and NVM image version < 3.25

Before this commit, the workaround function was not called on a) and b).

- Rename function.
 1.564 16-Feb-2018  knakahara Apply RSS utility to wm(4).

ok by msaitoh@n.o.
 1.563 14-Feb-2018  knakahara Fix a bug that RX and TX may stall on heavy load on wm(4) like ixgbe.c:r1.121.

wm_rxeof() and wm_txeof() have loop limit and the function returns true
if a packet still exists.

XXX need pullup-8
 1.562 30-Jan-2018  knakahara Make wm(4) watchdog MP-safe. There is almost no influence on performance.

wm(4) does not use ifp->if_watchdog now, that is, it does not touch
ifp->if_timer.
It also uses own callout(wm_tick) as watchdog now. The watchdog uses
per-queue counter to check timeout. So, global lock is not required.
 1.561 29-Jan-2018  knakahara Fix unmatched return type. The return value of wm_txeof() is not useded yet.
 1.560 29-Jan-2018  knakahara Fix if_wm.c:r1.557 merge miss, sorry.
 1.559 26-Jan-2018  knakahara Fix 82574 MSI-X mode cannot receive packets after 82574 receives high rate traffic.

In short, 82574 MSI-X mode does not cause RXQ MSI-X vector when 82574's
phys FIFO overflows. I don't know why but 82574 causes not RXQ MSI-X vector
but OTHER MSI-X vector at the situation.
see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.15-rc9&id=4aea7a5c5e940c1723add439f4088844cd26196d

advised by msaitoh@n.o, thanks.
 1.558 21-Jan-2018  christos CID-1427779: Fix uninitialized variables
 1.557 18-Jan-2018  knakahara wm_txeof() can limit the loop count the same as wm_rxeof() now.
 1.556 17-Jan-2018  knakahara Fix duplicated "rxintr" evcnt counting. Pointed out by ozaki-r@n.o, thanks.
 1.555 16-Jan-2018  knakahara Fix wm_watchdog_txq() lock region.

Not only wm_txeof() but also wm_watchdog_txq() itself requires txq_lock
as it reads Tx descriptor management variables such as "txq_free".

There is almost no influence on performance.
 1.554 15-Jan-2018  knakahara improve comments
 1.553 15-Jan-2018  knakahara Fix legacy Tx descriptors printing when WM_DEBUG is enabled.
 1.552 04-Jan-2018  msaitoh Add ASPM workaround for 8257[1234] and 82583 to prevent device timeout or
hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
 1.551 01-Jan-2018  jnemeth PR/52885 - Shinichi Doyashiki -- typo in comment
 1.550 28-Dec-2017  msaitoh Don't use MSI-X if we can use only one queue to save interrupt resource.
Written by knakahara and tested by me.
 1.549 08-Dec-2017  ozaki-r Revert "Make if_timer MP-safe if IFEF_MPSAFE"

Because it has decreased the performance of wm. And also I found that
wm_watchdog doesn't work well with if_watchdog framework at all. Sharing one
counter (if_timer) with multiple instances (hardware multi-queues) can't detect
a single (or some) stall of them because other instances reset the counter even
if the stalled one want the watchdog to fire.

Interfaces without IFEF_MPSAFE works safely with the original if_watchdog thanks
to KENREL_LOCK. OTOH, interfaces with IFEF_MPSAFE shouldn't use if_watchdog and
should implement their own watchdog timer that works with multiple instances.
 1.548 07-Dec-2017  msaitoh Fix a bug that 8257[56] can't receive packet reported by Bert Kiers in
PR#52717. For 82575 and 82576, the RX descriptors must be initialized after
the setting of RCTL.EN in wm_set_filter(). This bug was added in if_wm.c
rev. 1.515.
 1.547 06-Dec-2017  ozaki-r Make if_timer MP-safe if IFEF_MPSAFE

if_timer, a counter used by if_watchdog (if_slowtimo), can be modified in
if_watchdog and if_start and/or interrupt handlers of some device drivers. All
such accesses were serialized by KERNEL_LOCK. If IFEF_MPSAFE is enabled,
KERNEL_LOCK of if_start (and perhaps interrupt handlers) is omitted and if_timer
becomes racy.

Fix the race condition by protecting if_timer by a spin mutex. if_watchdog_reset
and if_watchdog_stop are introduced to ensure to take the mutex on accessing
if_timer. Interface with IFEF_MPSAFE enabled must use the functions.

In addition, if_watchdog callout is now set CALLOUT_MPSAFE if IFEF_MPSAFE. It
means that if_watchdog implemented by a driver must be MP-safe if the driver is
set IFEF_MPSAFE.

Currenlty interfaces with IFEF_MPSAFE implementing if_watchdog and accessing
if_timer in if_start and interrupt handlers are only wm(4). wm is changed to
use the functions. (Its watchdog handler (wm_watchdog) is already MP-safe.

These contracts will be written somewhere in a further commit.

Note that the spin mutex is now ifp->if_snd.ifq_lock to avoid adding another
spin mutex to each interface. For now reusing it isn't problematic (see the
comment to know why) thought if that does matter in the future, feel free to
replace it with a new spin mutex. It's easy to do.
 1.546 30-Nov-2017  msaitoh - 82583 supports jumbo frame. Fixes PR#52773 reported by Shinichi Doyashiki.
- Cleanup comment.
 1.545 30-Nov-2017  msaitoh Don't allocate MSI-X interrupt on 82583. 82583 chip has a MSI-X capability in
the PCI configuration space but it doesn't support it. At least the document
doesn't say anything about MSI-X. Fixes PR#52767 reported by
Shinichi Doyashiki.

XXX pullup-8.
 1.544 22-Nov-2017  msaitoh Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
 1.543 16-Nov-2017  ozaki-r Unify IFEF_*_MPSAFE into IFEF_MPSAFE

There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.

Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).

Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.

Proposed on tech-kern@ and tech-net@
 1.542 23-Oct-2017  knakahara fix wm(4) vlan panic. Reported and tested by Tom Ivar Helbekkmo, thanks.

wm(4) used PRI bits and CFI bit as vlantag by mistake. It is found out
by if_ether.h:r1.67.

XXX need pullup-8
 1.541 23-Oct-2017  msaitoh If if_initialize() failed in the attach function, return.
 1.540 20-Oct-2017  msaitoh On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
 1.539 26-Sep-2017  msaitoh - Correct NVM word size check in wm_nvm_version() to prevent
"EERD polling failed" error on attach. if_wm.c rev. 1.534 was not perfect.
Reported by ozaki-r@.
- Print NVM offset and word count when EERD polling failed.

XXX pullup-8.
 1.538 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.537 31-Jul-2017  knakahara rename unclear functions. pointed out by msaitoh@n.o.
 1.536 28-Jul-2017  knakahara add comment about confusing wm_rxeof() calling.

pointed out by msaitoh@n.o.
 1.535 28-Jul-2017  msaitoh Check some wm_nvm_read()'s return vale.
 1.534 28-Jul-2017  msaitoh Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never seen on
real 82574 hardware with such small SPI ROM. Check sc->sc_nvm_wordsize before
accessing higer address words to prevent timeout.
 1.533 27-Jul-2017  msaitoh Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers say
"In rare circumstances, the SW semaphore may already be held unintentionally."
on I21[01]. PXE boot is one of the case.

XXX pullup-[678].
 1.532 26-Jul-2017  msaitoh On 8254[17] with SPI ROM, wm_nvm_set_addrbits_size_eecd() calls wm_nvm_read(),
so it's required to set flags and functions before calling it. It was broken
again in if_wm.c rev. 1.530 (see also 1.313). Tested with Dell Power Edge 1850.
 1.531 26-Jul-2017  msaitoh - Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required for
these functions to use the same API. So,
- Change return value as error code.
- Change register vaule from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not in
wm_reset(). If the workaround isn't required, don't use the workaround code
in wm_gmii_i80003_{read,write}reg.
 1.530 25-Jul-2017  msaitoh Use new nvm.{acquire,release}() for semaphore. Almost the same except the
following:
- 8257[12]: Don't directly access SPI but use EERD register.
- 82575-I354: If the size of SPI ROM >= 32K words, use direct SPI access
instead of EERD register access.
- Add wm_nvm_eec_clock_raise() and wm_nvm_eec_clock_lower() and use them for
Microwire/SPI bus control. Same as Linux and FreeBSD.
- Redude timeout value for 80003 in wm_get_swfw_semaphore(). Same as
Linux and FreeBSD.
 1.529 20-Jul-2017  msaitoh Fix a bug that sc->sc_flags can't be passed to igphy(4). This bug was added
in if_wm.c rev 1.527.
 1.528 18-Jul-2017  msaitoh - Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access HV_SMB_ADDR
correctly.
- Enable wm_init_lcd_from_nvm() again. Tested by Thinkpad X220.
 1.527 18-Jul-2017  msaitoh Move some initialization stuff in wm_attach() before wm_reset(). Some flags
and callback function is required to set correctly before wm_reset() because
wm_reset() and some helper functions refer them.
 1.526 18-Jul-2017  msaitoh Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to prevent
hungup. A semaphore is get/put in wm_nvm_{read,write}.
 1.525 14-Jul-2017  msaitoh Calling wm_init_lcd_from_nvm() makes hang on some machines reported by
Brad Harder. Until fix this problem correctly, Disable whole of
wm_init_lcd_from_nvm().
 1.524 13-Jul-2017  msaitoh IF TX is not required to flush, RX is also not required to flush. Same as
other OSes.
 1.523 13-Jul-2017  msaitoh - Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if it's
required.
- Add debug printf.
 1.522 13-Jul-2017  msaitoh - Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of page
select. PHY access from igphy() automatically did it, but accessing from
wm(4) for wrokaround didn't work correctly. This change affects 8254[17],
8257[12] ICH8, ICH9 and ICH10.
- Add diagnostic code.
 1.521 13-Jul-2017  msaitoh - Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Add debug printf.
- Rename variables.
 1.520 12-Jul-2017  msaitoh Remove debug printf().
 1.519 12-Jul-2017  msaitoh Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before this commit,
above devices and non-PCIe devices accessed wrong register.
 1.518 06-Jul-2017  msaitoh Move the location of wm_get_hw_control() in wm_init_locked() again. Doing
it "after" wm_reset() is required for some AMT based machines to linkup
1Gbps. Tested with HP dc7700.
 1.517 26-Jun-2017  msaitoh - Make new wm_phy_post_reset() and use this function at all location after
reseting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
 1.516 26-Jun-2017  msaitoh Add missing "else" in wm_nvm_release().
 1.515 26-Jun-2017  msaitoh - Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Add CSR_WRITE_FLUSH() after writing WMREG_CTRL in wm_gmii_mediachange().
 1.514 26-Jun-2017  msaitoh - Fix wm_set_ral():
- Fix a bug that a RAL was written at incorrect address when the index number
is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others.
- Remove wrong comment.
 1.513 26-Jun-2017  msaitoh Print sc_flags with snprintb().
 1.512 23-Jun-2017  msaitoh Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
 1.511 20-Jun-2017  msaitoh - Add debug printf()s.
- If a legacy interrupt is a spurious interrupt, don't print debug message.
- Add comment.
 1.510 19-Jun-2017  msaitoh Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset(). Same as other OSes.
 1.509 12-Jun-2017  msaitoh Use IFM_1000_KX and IFM_2500_KX.
 1.508 13-Apr-2017  knakahara branches: 1.508.4;
wm(4) can disable msi/msix by build option and ddb command.

suggested by nonaka@n.o.
reviewed by msaitoh@n.o and nonaka@n.o.
 1.507 12-Apr-2017  knakahara improve comments about the difference between legacy/msi and msix.

pointed out by msaitoh@n.o.
 1.506 05-Apr-2017  msaitoh Fix a bug that non-GMII devices don't send a routing message when the link
status is changed. Call if_link_state_change(). Tested with 82572EI(TBI) and
I350(SERDES).

XXX pullup-[67].
 1.505 24-Mar-2017  knakahara fix typo

pointed out by ozaki-r@n.o.
 1.504 24-Mar-2017  knakahara remove extra "+"
 1.503 24-Mar-2017  knakahara add comments about the situation wm(4) use MSI-X but does not use multiqueue.
 1.502 24-Mar-2017  knakahara make self-describing function the code reading sc->sc_nintrs or sc->sc_nqueues directly.
 1.501 24-Mar-2017  knakahara add prototype.

I have forgotten the fix by wm_softint_establish(). Thank you christos@n.o!
 1.500 22-Mar-2017  knakahara add comments about transmit context descriptor
 1.499 22-Mar-2017  knakahara missing M_CSUM_IPv4 checking. It does not cause problems, but it is wrong.

The implementations of M_CSUM_DATA_IPv4_IPHL() and M_CSUM_DATA_IPv6_HL()
is the same, so that does not cause problems.
 1.498 21-Mar-2017  knakahara fix PR kern/52068 (82574 Tx csum offload bug in not only i386 but also amd64).

The packets sent from txq[1] could not be enabled any tx offload.
This has been enbugged since r1.454.
 1.497 08-Mar-2017  kardel PR kern/52039: use same safeguard as for the 82578
 1.496 03-Mar-2017  knakahara fix r1.492 bug, sorry
 1.495 03-Mar-2017  knakahara implement AIM(Adaptive Interrupt Moderation), but not enable yet.

Currently, it causes performance degration if enabled.
More ITR calcuration tuning is required...
 1.494 03-Mar-2017  knakahara make kernel config option WM_RX_PROCESS_LIMIT_DEFAULT and WM_RX_INTR_PROCESS_LIMIT_DEFAULT

e.g. if
- WM_RX_PROCESS_LIMIT_DEFAULT is set 0
- WM_RX_INTR_PROCESS_LIMIT_DEFAULT is set -1 (means almost infinite)
that means wm(4) does not use polling mode.
 1.493 03-Mar-2017  knakahara implement polling mode for multiqueue. It can suppress performance degration at high load.

e.g. I354 IP forwarding throughput performance
+ before
- 133Mbps forwarding performance at 200Mbps input load
- 41Mbps forwarding performance at 800Mbps input load
+ after
- 150Mbps forwarding performance at 200Mbps input load
- 150Mbps forwarding performance at 800Mbps input load
 1.492 03-Mar-2017  knakahara IFEF_START_MPSAFE flag should be set only if WM_MPSAFE defined. some refactor.

pointed out and suggested by msaitoh@n.o, thanks.
 1.491 01-Mar-2017  knakahara refactor: functionalize ITR/EITR writing processing.

tested I354 and 82545(VMware e1000).
 1.490 01-Mar-2017  knakahara divide ITR/EITR value from wm_softc to wm_queue as EITR register is bound to each H/W queue.
 1.489 28-Feb-2017  knakahara fix EITR setting.

+ 82574
- add EITR setting, that is MSI-X mode interrupt interval
+ 82575
- fix EITR value. 82575's EITR usage is the same as legacy (not NEWQUEUE)
controllers
- apply workaround which 82575's EITR does not have CNT_INGR bit
+ other NEWQUEUE controllers
- fix interrupt interval field. NEWQUEUE (include 82575) controllers'
interrupt interval field is 2:14
- use CNT_INGR bit which avoid to overwrite counter

tested 82574, 82575 and I354.
ok by msaitoh@n.o.
 1.488 27-Feb-2017  knakahara fix Tx queue assignment when the number of H/W queues is less than ncpu.
 1.487 24-Feb-2017  knakahara apply 82574 RFCTL workaround the same as FreeBSD and linux.

In fact, this workaround reduces interrupt count.
 1.486 24-Feb-2017  knakahara 82574 should follow MSI-X mode IMS manner.

Howerver some legacy interrupts occur as MSI-X other interrupt yet...
 1.485 18-Feb-2017  christos Establish a softint for legacy, otherwise BOOM!
 1.484 17-Feb-2017  knakahara unify Tx softint and Rx softint to uniform ixg(4) design.

Furthermore, that can remove wm_deferred_start() which holds all txq's
txq_lock, so it would reduce lock contention between Tx interrupt handler and
Tx softint handler.
 1.483 17-Feb-2017  knakahara rxq_ptr must be updated holding rxq_lock consistent with the Rx processing.

In previous implementation, wm_rxeof() temporarily unlock rxq->rxq_lock to
call if_percpuq_enqueue(), and then re-lock rxq->rxq_lock to update
rxq->rxq_ptr. So, if multiple CPUs share the same rxq, there is race e.g.
- CPU A: lock rxq->rxq_lock
- CPU A: Rx processing include increment local variable "i"
- CPU A: unlock rxq->rxq_lock
- CPU A: call if_percpuq_enqueue()
- CPU B: lock rxq->rxq_lock
- CPU B: Rx processing include increment local variable "i"
- CPU B: unlock rxq->rxq_lock
- CPU B: call if_percpuq_enqueue()
- CPU B: lock rxq->rxq_lock
- CPU B: update rxq->rxq_ptr, that is, set CPU B's local "i" to rxq->rxq_ptr
- CPU B: unlock rxq->rxq_lock
- CPU A: lock rxq->rxq_lock
- CPU A: update rxq->rxq_ptr, that is, set CPU A's local "i" to rxq->rxq_ptr
- CPU A: unlock rxq->rxq_lock
 1.482 17-Feb-2017  knakahara more fix about IFF_OACTIVE.

fix TODO of r1.479 and reduce IFF_OACTIVE manipulation.
 1.481 17-Feb-2017  knakahara refactor: functionize deferred_start code holding locks.
 1.480 17-Feb-2017  knakahara refactor: functionize txrxintr disable/enable code.
 1.479 16-Feb-2017  knakahara fix about IFF_OACTIVE.

It is required manipulate IFF_OACTIVE for old ethernet controllers and ALTQ
to use if_start. To avoid race, txq_lock of 0th txq is needed to write
IFF_OACTIVE.

TODO: read side refactor
 1.478 13-Feb-2017  knakahara fix typo
 1.477 09-Feb-2017  knakahara detach wm(4) evcnt.

pointed out by msaitoh@n.o, thanks.
 1.476 02-Feb-2017  knakahara remove WM_CORE_LOCK in deferred start routine.

It is enough to check each txq's txq_stopping with
mutex_enter(not mutex_tryenter).

reviewed by ozaki-r@n.o.
 1.475 01-Feb-2017  msaitoh Use new wm_gmii_setup_phytype() function to setup sc_phytype and
mii_{read|write}reg. This function is called twie.

To identify PHY type, correct read/write function should be selected. To
select correct read/write function, PCI ID or MAC type are required without
accessing PHY registers.

On the first call of this function, PHY ID is not known yet. Check PCI ID or
MAC type. The list of the PCI ID may not be perfect, so the result might be
incorrect.

In the second call, PHY OUI and model are used to identify PHY type. It might
not be perfpect because of the lack of compared entry, but it would be better
than the first call.

If the detected new result and previous assumption is different, diagnous
message will be printed.
 1.474 01-Feb-2017  msaitoh Linux and FreeBSD defines 0x10f5 as E1000_DEV_ID_ICH9_IGP_M_AMT. In reality,
This is not IGP but BM. Add new case to identify PHY type correctly on this
device. Fixes PR#51924 reported byJarle Greipsland.

This change fix only for 0x10f5. Need more work to be the best.
 1.473 01-Feb-2017  knakahara fix: wm(4) Rx descriptor is corrupted under high rate.

don't write descriptor which is not set DD bit.
 1.472 31-Jan-2017  knakahara remove obsolete comment. wm(4) vlan have already tested on I354.
 1.471 30-Jan-2017  knakahara fix endianness of "rsshash"(currently, used for debug message only) and tabify.
 1.470 27-Jan-2017  knakahara add comment about txq->txq_lock contentions in wm_nq_transmit().
 1.469 26-Jan-2017  knakahara fix memory leak at wm_detach.

pointed out and reviewed by msaitoh@n.o.
 1.468 16-Jan-2017  maya move declaration to #ifdef WM_DEBUG block as opposed to using __debugused
fixes build with DEBUG but without WM_DEBUG

ok martin
 1.467 16-Jan-2017  knakahara update todo comment
 1.466 16-Jan-2017  knakahara support {extended, advanced} receive descriptor for wm(4).

support below two receive descriptors.
- extended descriptor (used by 82574 only)
- advanced descriptor (used by 82575 and newer)

SPH(split header buffer) is not supported yet.

ok by msaitoh@n.o.
 1.465 10-Jan-2017  msaitoh branches: 1.465.2;
remove debug printf().
 1.464 10-Jan-2017  msaitoh Fix previous. The last code wasn't called.
 1.463 10-Jan-2017  knakahara sc->sc_core_stopping must be checked with holding sc_core_lock.

pointed out by ozaki-r@n.o, thanks.
 1.462 06-Jan-2017  msaitoh - Set IPV6EXDIS bit in RFCTL register because of an Errata on 82575 and newer
devices.
- Update comment in wm_init_rss().
 1.461 04-Jan-2017  knakahara fix typo. pointed out by msaitoh@n.o.
 1.460 28-Dec-2016  ozaki-r Protect ec_multi* with mutex

The data can be accessed from sysctl, ioctl, interface watchdog
(if_slowtimo) and interrupt handlers. We need to protect the data against
parallel accesses from them.

Currently the mutex is applied to some drivers, we need to apply it to all
drivers in the future.

Note that the mutex is adaptive one for ease of implementation but some
drivers access the data in interrupt context so we cannot apply the mutex
to every drivers as is. We have two options: one is to replace the mutex
with a spin one, which requires some additional works (see
ether_multicast_sysctl), and the other is to modify the drivers to access
the data not in interrupt context somehow.
 1.459 26-Dec-2016  msaitoh 0x10cb is not 82801H but 82801I. No functional change (The macro name
was changed but the vaule is the same).
 1.458 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.457 13-Dec-2016  msaitoh - Change to use 2500Base-KX correctly on C2000(I354). It worked, but the
output of ifconfig and if_baudrate was not good. Tested by nils@:
- The STATUS_TBIMODE bit in the STATUS register is deleted since 82575,
so check for 82575 and newer first and then check for old devices.
- Check the 2P5_SKU and 2P5_SKU_OVER bit for KX.
- Set IFM_2500_SX instead of IFM_1000_SX for 2.5G.
- Check SERDES's speed directly from the PCS layer (PCS_LSTS register) for old
devices.
- Style fix.
 1.456 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.455 02-Dec-2016  knakahara fix: ifp->if_obytes and ifp->if_omcasts are not counted up for packets which is sent later.

pointed out by ozaki-r@n.o, thanks.
 1.454 01-Dec-2016  knakahara support Tx multiqueue for 82574(aka e1000e for VMware and QEMU).
 1.453 21-Nov-2016  msaitoh Add note about kumeran registers. No functional change.
 1.452 18-Nov-2016  joerg Remove extra pair of braces.
 1.451 18-Nov-2016  msaitoh Fix WOL related setting of the WUC register for other than PCH*
in wm_enable_wakeup(). Tested with 82567V(ICH8) and 82583V.
 1.450 17-Nov-2016  msaitoh 8257[124] should not set WM_F_ARC_SUBSYS_VALID.
 1.449 17-Nov-2016  msaitoh Fix flag check in wm_get_wakeup()
- 8254[17]* should not set WM_F_ARC_SUBSYS_VALID.
- Add missing WM_T_82541_2 and WM_T_82547_2
- Note that the setting of both Linux's FLAG_HAS_AMT and FreeBSD's has_amt
flag is doubtful on 8257[34] and 82583.
 1.448 16-Nov-2016  msaitoh Move the location of wm_smbustopci() call.
 1.447 16-Nov-2016  msaitoh Sync wm_smbustopci() with Linux and FreeBSD. This change effects PCH and
newer devices.
 1.446 16-Nov-2016  msaitoh Fix a bug that 8257[56], 82580, I35[04] and I21[01] didn't use
wm_{get,release}_hw_control() correctly.
 1.445 16-Nov-2016  msaitoh Add three workarounds for PCH_{LPT,SPT}.
 1.444 14-Nov-2016  msaitoh Set CTRL_MEHE correctly (PCH_{LPT,SPT} only).
 1.443 10-Nov-2016  msaitoh - Move I219 DMA workaround into wm_flush_desc_rings() and call it before
wm_reset().
- Rewite I219 TX DMA workaround based on OpenBSD's one.
- Add I219 RX DMA workaroud from OpenBSD.
 1.442 10-Nov-2016  msaitoh Call wm_enable_phy_wakeup() on PCH2 and newer, too. Now these devices
can do WOL. Tested with Thinkpad X220(PCH2).
 1.441 08-Nov-2016  msaitoh Fix wm_access_phy_wakeup_reg_bm(). This change has no effect because this
function is used for WUC register and our driver currenlty doesn't access
to it.
 1.440 08-Nov-2016  msaitoh Remove debug printf which was added in rev. 1.437.
 1.439 08-Nov-2016  msaitoh Call wm_enable_wakeup() in wm_detach() and wm_suspend(). Now wake on lan
works on Thinkpad X61(ICH8). Some workarounds will be required on PCH*.
 1.438 06-Nov-2016  msaitoh Add "10/100" into non-gigabit devices' name.
 1.437 02-Nov-2016  msaitoh - Fix workaround which did dummy read BM_WUC register. This code was changed to
drop BM_WUC_HOST_WU_BIT of BM_PROT_GEN_CFG register in FreeBSD r228386. The
code was added rev. 1.149, but the location was not the best.
Now I219 doesn't hang quickly after "ifconfig up".
- wm_gmii_hv_{read/write}reg*(): USE PHY address 1 for some special registers.
- Add check code for an 82578 workaround. Not completed yet(check only).
- wm_release_hw_control(): Remove extra line. No any effect.
 1.436 31-Oct-2016  knakahara Fix locking against myself at wm_turn{on,off} when NET_MPSAFE is defined.

Pointed out by ozaki-r@n.o, thanks.
 1.435 28-Oct-2016  msaitoh Fix PHY access on 82567(ICH8 or ICH10), 82574 and 82583:
- Use wm_gmii_bm_{read,write}reg() on 82574 and 82573.
- Issue page select correctly on BM PHYs.
 1.434 28-Oct-2016  msaitoh Change debug flags to be better than before.
 1.433 28-Oct-2016  msaitoh - Define WMPHY_I217, WMPHY_VF and WMPHY_210.
- Use BME1000_PHY_PAGE_SELECT in wm_gmii_bm_{read,write}reg(). This change has
no effect because GG82563_PHY_PAGE_SELECT and BME1000_PHY_PAGE_SELECT have
the same value.
 1.432 28-Oct-2016  msaitoh - Use MII_ADDRMASK.
- Remove debug printf().
 1.431 28-Oct-2016  knakahara Fix wm(4) input drop packet counter.

WMREG_RNBC is incremented when there is no available buffers in host
memory. However, ethernet controller can receive packets in such case
if there is space in phy's FIFO. That is, ethernet controller drops
packet only if there is no available buffers *and* there is no space
in phy's FIFO.
So, the number of dropped packets should be added WMREG_MPC only.

ok by msaitoh@n.o
 1.430 28-Oct-2016  msaitoh - Remove an 82578 workaround which was for PCH rev < 3. FreeBSD removed this
workaround in r228386.
- Add an 82578 workaround which is for PHY rev < 2. From FreeBSD and Linux.
- Add some DPRINTF()s.
 1.429 28-Oct-2016  knakahara Fix sc_stopping race.

To scale, separate sc_stopping flag to wm_softc and each tx,rx queues.

Pointed out by skrll@n.o, thanks.

ok by msaitoh@n.o
 1.428 26-Oct-2016  msaitoh Use wm_gmii_82544_{read,write}reg() on non-82567 ICH8, 9 and 10.
 1.427 26-Oct-2016  msaitoh 82567V_3 is BME1000_E_2(bm). Tested with Advantech AIMB-212 1st Ethernet port.
 1.426 26-Oct-2016  msaitoh 82567V-3 is not ICH9 but ICH8.
 1.425 21-Oct-2016  msaitoh - Fix previous commit in wm_kmrn_readreg().
- Use wm_gii_mdic_readreg/writereg() in wm_access_phy_wakeup_reg_bm()
because these functions are called with taking lock.
- Add some DPRINTF()s.
 1.424 21-Oct-2016  msaitoh - Rewrite PHY related lock stuff. Almost the same as FreeBSD.
This change will fix a bug that PHY read/write fail on some cases.
- Increase delay in wm_phy_resetisblocked(). Same as FreeBSD.
- Use semaphore in wm_hv_phy_workaround_ich8lan() and wm_k1_gig_workaround_hv()
 1.423 20-Oct-2016  msaitoh - Move call of wm_reset() in wm_attach() after setting PHY and NVM related
flags because those flags are used in wm_reset().
- Use mutex for NVM access on ICH8 and newer devices. Same as FreeBSD.
 1.422 20-Oct-2016  msaitoh Add newer I219 devices (not enabled).
 1.421 20-Oct-2016  msaitoh Add more DPRINTF()s.
 1.420 19-Oct-2016  msaitoh No, functional change:
- Add WM_DEBUG_LOCK
- Add some KASSERT
- Modify comment.
 1.419 19-Oct-2016  msaitoh - Drop the host wakeup bit after resetting PHY on PCH and newer devices.
- Increase delay while toggling LANPHYPC
 1.418 11-Oct-2016  skrll Read sc_if_flags after taking core lock
 1.417 10-Aug-2016  knakahara restructure wm(4) evcnt to support multiqueue evcnt.

ok by msaitou@n.o.
 1.416 11-Jul-2016  knakahara branches: 1.416.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.415 20-Jun-2016  knakahara wm(4) can enable IFEF_START_MPSAFE now.
 1.414 14-Jun-2016  knakahara fix: rxq->rxq_lock is uninitialized if NET_MPSAFE is not defined.
 1.413 14-Jun-2016  skrll Simplify the code.

WM_[RT]X_* macros are removed and replaced with mutex_* calls directly.

OK from nakahara@ and msaitoh@
 1.412 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.411 30-May-2016  knakahara fix r1.409 mistake
 1.410 23-May-2016  knakahara Update TODO: evcnt
 1.409 23-May-2016  knakahara fix: ethernet controllers which use wiseman_txdesc_t (earlier than 82575) hang
possibly.
 1.408 23-May-2016  knakahara GENERIC kernel (disabled NET_MPSAFE kernel) also needs txq_lock to avoid race
between tx processing and tx interrupt handler.
 1.407 20-May-2016  knakahara Update TODO

- "TX Multiqueue" -> "TX Multiqueue improvement"
- add "Advanced Recieve Descriptor" (RX NEWQUEUE)
 1.406 19-May-2016  knakahara fix build failure by gcc 4.8.5
 1.405 19-May-2016  knakahara unify TX and RX interrupt handler to use MSI-X vector efficiently
 1.404 19-May-2016  knakahara user-friendly interrupt affinity offset
 1.403 19-May-2016  knakahara initial TX multiqueue support
 1.402 18-May-2016  knakahara Whether Tx interrupt handler kicks if_start() should not depend on wm_txeof()
return value.
 1.401 18-May-2016  knakahara rename WM_TXQ_WORKING to WM_TXQ_NO_SPACE
 1.400 18-May-2016  knakahara device drivers should not divert ifp->if_flags to manage H/W satatus.
 1.399 18-May-2016  knakahara refactor: eliminate "txq->txq_descs_size", use WM_TXDESCS_SIZE instead.
 1.398 18-May-2016  knakahara fix unmatched dma sync size for NEWQUEUE. This bug would have caused
wm_nq_tx_offload() not to work.
 1.397 11-May-2016  msaitoh Fix compile error on some archs (e.g. i386).
 1.396 11-May-2016  knakahara Interrupt handlers read wm_rxqueue or wm_txqueue, so they must be freed after
disestablishing interrupt handlers.
 1.395 11-May-2016  msaitoh Do I219 TX DMA workaround only when TDLEN(0) != 0
 1.394 06-May-2016  msaitoh - Modify wm_smbustopci() to reduce the diff against Linux and FreeBSD.
- wm_gate_hw_phy_config_ich8lan() is for younger than PCH2.
- Add debug code.
 1.393 06-May-2016  msaitoh Add some workaround code for I219. It still doesn't work.
 1.392 06-May-2016  msaitoh Basic support for I219. It doesn't work on I219, so it's disabled.
 1.391 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.390 05-Feb-2016  msaitoh s/max/ralmax/. No functional change.
 1.389 29-Jan-2016  msaitoh Remove debug message.
 1.388 07-Jan-2016  msaitoh - printf->DPRINTF in wm_serdes_mediastatus().
- KNF.
 1.387 25-Dec-2015  msaitoh Modify comment for 82544 Errata 9 "Certain register cannot be written with
particular alignments in PCI-X bus operation".
 1.386 25-Dec-2015  msaitoh - Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Fix typo in comment and modify comment by tnn@.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
 1.385 22-Dec-2015  knakahara fix potentially bug
 1.384 22-Dec-2015  knakahara fix incorrect KASSERT
 1.383 18-Dec-2015  knakahara set Tx/Rx interrupts affinity to other than CPU#0 as much as possible
 1.382 13-Dec-2015  christos PR/50527: David Binderman: Fix impossible code. Odd offsets need special
treatment.
 1.381 30-Oct-2015  msaitoh - On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS sets
this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the function
checks the status correctly but it causes linkdown up to 10 times, so it's
disabled for the time being.
 1.380 30-Oct-2015  msaitoh - Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in wm_reset()
on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix the
behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change might fix
a problem that PHY's read/write functions can't get semaphore.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when WM_WOL is
defined and it's disabled by default.
- KNF.
 1.379 30-Oct-2015  msaitoh Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT.
 1.378 30-Oct-2015  msaitoh Call wm_get_hw_control() correctly. This change fixes a bug that some AMT
based systems doesn't linkup at 1000BaseT. The problem was observed on
HP Compaq dc7700.

A lot of fixes have been done to wm(4) and igphy(4). Now PR#44893 should be
fixed.
 1.377 30-Oct-2015  msaitoh Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH* too.
 1.376 30-Oct-2015  msaitoh igphy(4),ukphy(4): Set mii_mpd_* entries.
wm(4): check PHY type correctly.
 1.375 29-Oct-2015  msaitoh Fix a bug that the multiqueue setting is done in a multiqueue capabile
chip but can't use MSI-X on a machine. In that case, only one queue must
be used. Written by knakahara@ and tested by me.

This change should be fix a problem which was reported by Robert Swindells.
 1.374 22-Oct-2015  knakahara if_wm uses pci_intr_alloc stubs now.
 1.373 22-Oct-2015  knakahara add CTASSERT and KNF.
 1.372 22-Oct-2015  knakahara initial port rss_getkey() from freebsd, and use it instead of random().
 1.371 14-Oct-2015  msaitoh - Update TODO:
- "Multiqueue" -> "TX Multiqueue" because RX Multiqueue was added.
- Sort entries.
- Grouping functions.
 1.370 13-Oct-2015  christos sprinkle __diagused
 1.369 13-Oct-2015  knakahara wm_linkintr_msix() should use WM_DEBUG_LINK instead of WM_DEBUG_TX.
 1.368 13-Oct-2015  knakahara recover if_wm.c:r1.348
 1.367 13-Oct-2015  knakahara fix: XEN3_DOM0(not defined __HAVE_PCI_MSI_MSIX) build
 1.366 13-Oct-2015  knakahara fix: WM_DEBUG build
 1.365 13-Oct-2015  knakahara support RX multiqueue.

ok by msaitoh@n.o
 1.364 13-Oct-2015  knakahara ready to support RX multiqueue.

ok by msaitoh@n.o
 1.363 13-Oct-2015  knakahara refactor: rearrange interrupt handlers argument
 1.362 13-Oct-2015  knakahara refactor: rearrange function arguments without interrupt handlers
 1.361 13-Oct-2015  knakahara change const value register macros to macro expressions to support multiqueue.
 1.360 13-Oct-2015  knakahara refactor: separate interrupts setup processing from wm_attach
 1.359 13-Oct-2015  knakahara allocating queues should be finished before establishing interrupts.
 1.358 13-Oct-2015  knakahara refactor: separate discriptors initialization and registers initialization
 1.357 13-Oct-2015  knakahara separete TX, RX queue mutex from wm_softc and rearrange WM_BOTH_LOCK.

ok by msaitoh@n.o
 1.356 13-Oct-2015  knakahara refactor: separate TX, RX queue variables from wm_softc (without mutex)
 1.355 13-Oct-2015  knakahara refactor: separate busdma initialize processing as functions
 1.354 13-Oct-2015  knakahara separate TX dma control data and RX dma control data.

ok by msaitoh@n.o
 1.353 13-Oct-2015  knakahara refactor: separate busdma allocate processing as functions.
 1.352 13-Oct-2015  knakahara refactor: change some macros to functions

change below macros to functions
- WM_CDTXSYNC
- WM_CDRXSYNC
- WM_INIT_RXDESC
 1.351 08-Oct-2015  msaitoh Fix a bug that LSC's interrupt storm occured when MSI-X is used.
It was observed only on 82575.
 1.350 30-Sep-2015  msaitoh - Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX packets"
and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit. The NVM Image
version 2.1.4 and newer have this workaround.
- Print the NVM image version on 82583, too.

Pointed out by joerg@.
 1.349 28-Sep-2015  knakahara When the driver uses MSI-X, it tunes RX's EITR the same as TX's.

ok by msaitoh@n.o
 1.348 28-Sep-2015  knakahara use sc->sc_itr instead of hard-coded number.

ok by msaitoh@n.o
 1.347 07-Sep-2015  msaitoh - Check iNVM's image version and print it.
- Update TODO.
 1.346 17-Aug-2015  knakahara Add kernel code to support intrctl(8).
 1.345 28-Jul-2015  msaitoh Print interrupt type correctly.
 1.344 23-Jul-2015  msaitoh Fix a bug that I21[01] NVM revision >= 3.25 can't be attached.
Reported by MATSUI Yoshihiro.
 1.343 23-Jul-2015  msaitoh The WM_F_EEPROM_EERDEEWR is not required on iNVM device.
 1.342 22-Jul-2015  knakahara fix typo
 1.341 22-Jul-2015  knakahara Sorry, if_wm turns MSI/MSI-X default off by my mistake.
 1.340 21-Jul-2015  knakahara mofity for if_wm and if_bge to use pci_intr_alloc()
 1.339 15-Jul-2015  msaitoh Cleanup.
 1.338 15-Jul-2015  msaitoh Enable MSI/MSI-X feature by default.
 1.337 15-Jul-2015  msaitoh Don't use MSI on 8257[12] because of errata 63
"Byte Enables 2 and 3 are not set on MSI writes".
 1.336 26-Jun-2015  msaitoh Fix a bug that wm_detach() didn't unmap the FLASH's area.
Now "drvctl -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
 1.335 13-Jun-2015  msaitoh Add MSI/MSI-X support written by Kengo Nakahara. Some old devices' support
is written by me. It's disabled by default. If you'd like to use, define
WM_MSI_MSIX.

Tested with:
8254[3405617] (INTx even if it has MSI CAP because of a errata)
8257[12], 82583 ICH8, ICH10, PCH2, PCH_LPT(I21[78]) (MSI)
8257[456], 82580, I35[04], I21[01] (MSI-X)

Not tested:
82542, 82573, 80003, ICH9, PCH,
 1.334 12-Jun-2015  msaitoh - Print NVM version on 8257[124], too.
- Modify NVM version string a bit.
 1.333 10-Jun-2015  msaitoh Remove extra if_start() in wm_ioctl().
 1.332 08-Jun-2015  msaitoh Call wm_pll_workaround_i210() at the end of the wm_reset() function, too.
 1.331 06-Jun-2015  msaitoh Fix the output of the option ROM version.
 1.330 06-Jun-2015  msaitoh Cleanup.
 1.329 06-Jun-2015  msaitoh - Add workaround for I210 Errata 25 and I211 Errata 10.
- Add wm_gmii_gs40g_{read|write}reg() and use it to access non-standatrd
page.
- Add wm_pll_workaround_i210() and call it when
chip is i211
chip is i210 and it use INVM
chip is i210 and NVM image version < 3.25
- Add comment
- Rename macros.
 1.328 06-Jun-2015  msaitoh Print NVM image version.
 1.327 06-Jun-2015  msaitoh Revert previos. Sorry, I committed in another working directory...
 1.326 06-Jun-2015  msaitoh Print NVM image version.
 1.325 02-Jun-2015  msaitoh Fix a lot of bugs to make 82575 and newer's SERDES based systems work.
- Add SERDES specific functions.
- Fix IO pin configuration.
- Reset autonego timer when link becomes up.

TODO:
- Fix a bug that SFP ROM can't read.
- Perhaps some work is required for 8257[12] serdes systems.
- Remove duplicated code in TBI's link related functions.
 1.324 02-Jun-2015  msaitoh No functional change:
- Reorder functions.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function acts as
mii_tick().
 1.323 02-Jun-2015  msaitoh Fix a bug that flags related to semaphore were incorrectly checked in
wm_kmrn_{readreg,writereg}. i80003, ICH* and PCH* had this problem.
 1.322 22-May-2015  msaitoh - Currently, WM_F_EEE bit is not set on all chips. it's intended to not
to use all of EEE fuctions but wm_set_eee_i350() leaves IPCNFG_10BASE_TE
bit and it causes link negotiation problem on some old switches. Disable
10BASE-Te function, too.
- Call wm_set_eee_i350() on some chips, too.
 1.321 16-May-2015  msaitoh Add support iNVM (integrated Non-Volatile Memory) for I21[01]. This change
fixes a bug that a MAC address is wrongly set on iNVM machines and NICs.
Tested with Shuttle DS57U(iNVM based) and other non iNVM based I210 machines.
 1.320 04-May-2015  msaitoh For 82576 and newer devices, the PBA register is deleted. Don't write PBA
for those chips. Also change the calculation of RX packet buffer size in
new way.
 1.319 04-May-2015  msaitoh Modify (E)ITR, TIDV and TADV related code:
- ITR regiser are not documented in 82575 and newer devices'
manual. The documets say "E"ITR(0) has no alias (to old ITR).
But in reality, the alias really exists. When EITR(0) is
written, the old ITR is changed. Before this commit, ITR was
written after EITR was written. It causes that EITR's value
(450) was overwritten with old ITR(1500). Set sc_itr first
and use the value and don't set ITR if a device >= 82575
(which has MSI-X multi queue function).
- Older than 82540 devices have no TADV register.
- 82575 and newer devices have no TIDV and TADV registers.
 1.318 04-May-2015  msaitoh Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is
more than 4096. Almost the Same as other OSes
 1.317 04-May-2015  msaitoh Remove WMREG_TQSA_LO and WMREG_TQSA_HIGH. Those registers
are not described in documents and other OS's drivers don't
access it.
(I have no the first chip(82542)'s document. Those registers
might be described in the document).
 1.316 17-Apr-2015  msaitoh Fix a bug that newer revision of I218-{LM,V} use wrong PHY access functions.
The problem only occured on devices that the PCI device ID was 0x15a[0123].
 1.315 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.314 28-Mar-2015  msaitoh Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.
 1.313 16-Feb-2015  msaitoh Fix a bug that the first access to NVM is failed on 8254[17] which use
SPI EEPROM. Observed on Dell PowerEdge [12]850. Thanks Tom Ivar Helbekkmo
for debugging.
 1.312 15-Feb-2015  msaitoh - Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Add comment.
- Fix typo in comment.
 1.311 13-Feb-2015  msaitoh Fix a bug that sc_mediatype is evaluated incorrectly. The real problem
might be occured only on fiber and serdes cases.
 1.310 29-Jan-2015  msaitoh Fix a bug that a workaround for SWSM.SMBI bit doesn't work correctly.
This problem was only occured with old boot ROM on 8257[12].

XXX pullup to netbsd-[67]
 1.309 16-Jan-2015  ozaki-r Introduce defflag for NET_MPSAFE
 1.308 16-Nov-2014  msaitoh branches: 1.308.2;
Add C2000 KX and 2.5G.
 1.307 24-Oct-2014  msaitoh Simplify. No functional change.
 1.306 24-Oct-2014  msaitoh Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
 1.305 17-Oct-2014  snj There's an r in "determine"
 1.304 10-Oct-2014  msaitoh - Support DH89XXCC devices.
- Add extra delay for 82580 and newer devices except DH89XXCC SGMII device.
Same as FreeBSD.
 1.303 07-Oct-2014  ozaki-r Tidy up locking in wm_ioctl
 1.302 07-Oct-2014  ozaki-r Don't call ifmedia_ioctl with holding locks
 1.301 06-Oct-2014  msaitoh Fix debug message.
 1.300 06-Oct-2014  msaitoh Delete 82580ER related code. It was from FreeBSD and was removed in r203049.
 1.299 06-Oct-2014  msaitoh Add some devices. Not tested because I have no any of these devices/cards.
 1.298 16-Sep-2014  msaitoh Add some new I218 devices.
 1.297 11-Sep-2014  msaitoh It's not required to print "failed to detect NVM bank" with
aprint_error_dev(). Use DPRINTF(). Same as {Free,Open}BSD.
 1.296 04-Sep-2014  msaitoh Remove one obsolete TODO entry.
 1.295 03-Sep-2014  msaitoh Read SFF SFP ROM and configure driver from the value.
 1.294 01-Sep-2014  msaitoh Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on some
machines.
- Calculate NVM word size correctly.
- Determine timeout value based on the NVM word size.
 1.293 29-Aug-2014  msaitoh No binary change:
- Move some NVM related macros from if_wm.c to if_wmreg.h.
- Rename some macros for consistency.
 1.292 28-Aug-2014  msaitoh Add Internal SERDES mode support newer than or equal to 82575.
Currently, it supports fiber device only. If you use 1000BaseT SFP module,
it won't work. We have to write code to read SFP ROM and set SGMII mode
if the module is copper.
 1.291 26-Aug-2014  msaitoh Modify WMP_F_1000{X,T} to WMP_F_{FIBER,COPPER}. No binary change.
 1.290 24-Aug-2014  msaitoh Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
 1.289 10-Aug-2014  tls branches: 1.289.2;
Merge tls-earlyentropy branch into HEAD.
 1.288 07-Aug-2014  msaitoh Add one more TODO:
- We should check XXX'ed comments.
 1.287 06-Aug-2014  msaitoh Don't check SWSM_SMBI bit if WM_F_LOCK_SWSM isn't set. Fix a problem when
using vmware with e1000"e". With e1000e which is regarded as 82574L,
wm_gmii_init() fails with "could not acquire SWSM SMBI" message without
this change. This problem doesn't occur with real 82574L card.

TODO:
- Change the function name. It's difficult to understand. The name was
from old Intel original e1000 driver.
- Read Intel original driver again and check ALL location where semaphore is
used.
 1.286 05-Aug-2014  msaitoh Add some TODOs in comment.
 1.285 31-Jul-2014  msaitoh Fix fiber link problem (PR#44776 and PR#30880). Tested with 82543GC, 82544EI,
82545EM, 82546GB 82571EB and 82572EI fiber cards.
- Don't use the RXCFG interrupt. It's not required and the interrupt is very
heavy (a lot of interrupts). Same as {Free,Open}BSD.
- Modify wm_tbi_mediachange() to be close to em_setup_fiber_serdes_link()
of {Free,Open}BSD. At least, don't forget to set duplex setting.
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD. Tested with
my own 82545EM card.
 1.284 31-Jul-2014  msaitoh Fix a bug that I added in rev. 1.273. Some old card stopped at the attach
function with ""Please update the Bootagent" message. The code to clear the
SWSM_SMBI bit is only for 8257[1234] and 82583.
 1.283 28-Jul-2014  ozaki-r Use two different mutexes for tx and rx

This change splits the mutex of wm into two: one for tx and the other
for rx. By doing so, lock contentions can be reduced. We lock both for
other operations that need locking, e.g., init, stop and ioctl.

The modification doesn't change the behavior of the driver.
 1.282 25-Jul-2014  msaitoh - Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
 1.281 23-Jul-2014  msaitoh No functional change:
- Grouping functions.
- KNF.
 1.280 23-Jul-2014  msaitoh No functional change:
- Add missing prototypes.
- Rename functions for consistency and clarify.
- KNF.
 1.279 22-Jul-2014  msaitoh Add SERDES support from Matthias Drochner. Not all devices were tested but all
SERDES entries are enabled.
 1.278 14-Jul-2014  msaitoh Cleanup comments. No functional change.
 1.277 14-Jul-2014  ozaki-r Remove a duplicated error message
 1.276 11-Jul-2014  msaitoh Fix compile error.
 1.275 11-Jul-2014  msaitoh Rename some WM_F_* flags to clarify. Renumbering flags. No functional change.

WM_F_EEPROM_HANDSHAKE -> WM_F_LOCK_EECD
WM_F_EEPROM_SEMAPHORE -> WM_F_LOCK_SWSM
WM_F_SWFW_SYNC -> WM_F_LOCK_SWFW
WM_F_SWFWHW_SYNC -> WM_F_LOCK_EXTCNF
 1.274 11-Jul-2014  msaitoh Restore the WM_F_EEPROM_SEMAPHORE flags for 82575-I354 and 80003 cases.
The flag was removed in last commit.
 1.273 11-Jul-2014  msaitoh Fix some bugs realted to semaphore. This change fixes a problem which
was exposed in if_wm.c rev. 1.271. Tested by riastradh@.
- Clear the SMBI bit in SWSM register before accessing NVM and PHY in
wm_attach(). Same as FreeBSD.
- Fix a bug that 82573 doesn't put the hardware semaphore. Same as
FreeBSD r256200.
 1.272 01-Jul-2014  ozaki-r Make if_wm MPSAFE

- Make it MPSAFE only when NET_MPSAFE
- otherwise, its instructions are almost same as before
- the only change is IFQ_POLL/IFQ_DEQUEUE which
is now single IFQ_DEQUEUE
- Protect driver operations with a lock
- further work would make it separate
- Apply MPSAFE flag to
- callout_init
- pci_intr_establish
- Stop proceeding packets when the driver is likely
to stop for graceful ifconfig down

Tested on Rangeley (I354) and KVM (e1000)
Reviewed by msaitoh@
 1.271 30-Jun-2014  ozaki-r Acquire SW semaphore in wm_get_swsm_semaphore

It is required to serialize device drivers running on different CPUs.
The basic instructions are same as the official Intel driver.

ok msaitoh@
 1.270 16-Jun-2014  msaitoh IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.269 27-May-2014  tls From dyoung@ -- bump max TX DMA size to avoid pathological condition with TSO.
 1.268 29-Mar-2014  christos branches: 1.268.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.267 25-Mar-2014  christos kill sprintf
 1.266 07-Jan-2014  msaitoh Insert completion barrier between register write and delay().
One exception is chip reset (to avoid hangup).
 1.265 29-Dec-2013  msaitoh Add support For I354(C2000 interna Ethernet controller):
- Add I354 support.
- Fix SGMII+MDIO case. SGMII+I2C is not supported yet.
- Not tested well.
- Sprinkle "XXX" to check later.
 1.264 13-Sep-2013  martin Remove unused variables
 1.263 08-Sep-2013  msaitoh Remove extra debug message.
 1.262 16-Jul-2013  msaitoh Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with Asus P8P67
Deluxe motherboard and tested by jnemeth.
 1.261 27-Jun-2013  msaitoh branches: 1.261.2;
Move the location of wm_check_mng_mode() and wm_get_wakeup() in wm_attach().
Those functions access EEPROM, so they have to call after identifying EEPROM
access type. This modification may change the behavior of BMC(IPMI).
 1.260 25-Jun-2013  msaitoh Sync the wm_enable_mng_pass_thru() function with FreeBSD. Don't check
MANC_EN_MAC_ADDR_FILTER bit. Add 82574 and 82583 specific check. This
modification may change the setting of WM_F_HAS_MANAGE flag on some machines.

Sync the wm_release_manageablilty() fucntion with FreeBSD. Set MANC_ARP_EN.
This change enables HW ARP function when entering suspend.

When the chip is 82580(ER) or I350, set WM_F_ASF_FIRMWARE_PRES flag and
check for the WM_F_ARC_SUBSYS_VALID flag. Same as FreeBSD.
 1.259 25-Jun-2013  msaitoh Fix "MDIC write error" bug for 82574 and 82583. For those chips, the semaphore
must be released after chip reset. Found and tested by Mark Davies.
 1.258 19-Jun-2013  msaitoh Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
 1.257 19-Jun-2013  msaitoh Add ECC support for the packet buffer. Only 82571 and I21[78] support ECC.
 1.256 19-Jun-2013  msaitoh Fix some bugs on I21[78] to make those devices stable.
 1.255 11-Jun-2013  msaitoh Disable LPLU when the device is WM_T_PCH_LPT series (I21[78]).
This change fixes a bug that wm interface don't negotiate to 1000BaseT.
 1.254 11-Jun-2013  msaitoh The wm_linkintr_gmii() function is called from interrupt, so call
mii_pollstat() instead of mii_tick().
 1.253 04-Jun-2013  msaitoh Fix a bug that the check of reset complete fails on Intel 8 series with
"wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2 but I've never seen the
problem.
 1.252 03-Jun-2013  msaitoh Use wm_gmii_hv_{read,write}reg() for I21[78].
 1.251 03-Jun-2013  msaitoh Cleanup. No functional change.
 1.250 02-Jun-2013  msaitoh - Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank number.
Fixes PR#47878
- Remove a quick hack for NVM checksum that I added in last commit (rev. 1.249)
 1.249 02-Jun-2013  msaitoh Add I217 (and I218) support.
- The name of I217 is similar to I210, but the function is rather similar to
PCH2.
- Not tested well. Tested with my own Intel DQ87PG which has I217LM onboard.
- It seems that PCH2 and PCH_LPT specific function for RAL should be written.
- Quick hack for the NVM checksum mismatch. if_wm.c currently has no
wm_write_eeprom(), so it cannot update NVM's "updated bit". To avoid this
problem, check only the last 12bits of the checksum. My own DQ87PG's
updated bit is not set, and I could avoid the problem using with this
hack.
 1.248 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.247 18-Apr-2013  msaitoh Add support I21[01]. Only tested with my own I210-T1 Ethernet Server Adapter.
 1.246 30-Mar-2013  christos remove trailing whitespace
 1.245 13-Feb-2013  msaitoh No functional change.
- Fix comment.
- Use macro.
 1.244 13-Feb-2013  msaitoh No functional change.
- "struct mii_data *mii = &sc->sc_mii" and use it.
- Add comments.
- Fix some comments.
 1.243 12-Feb-2013  msaitoh Use 82580(and I350) specific PHY read/write functions.
Fixes PR#47542.
 1.242 07-Feb-2013  msaitoh Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
 1.241 07-Feb-2013  msaitoh Skip 64bit BAR correctly. I don't know if this bug causes a real problem.
 1.240 30-Jan-2013  msaitoh - Add WM_DEBUG_NVM.
- If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
 1.239 12-Dec-2012  msaitoh - 82578DC is not PCH2 but PCH. 82579V is not PCH but PCH2. This bug was
introduced in rev. 1.221. Reported by FUKAUMI Naoki.
- Fix comment.
 1.238 15-Nov-2012  msaitoh Change style a bit.
 1.237 07-Nov-2012  msaitoh Fix a bug that PHY isn't set to low-power mode on PCH and PCH2.
 1.236 12-Oct-2012  msaitoh Explicitly cast to uint64_t instead of using PRIxPADDR because
sizeof(paddr_t) != sizeof(bus_addr_t) on some architecture.

See:
http://mail-index.netbsd.org/source-changes-d/2012/10/09/msg005353.html
 1.235 09-Oct-2012  msaitoh Use PRIxPADDR to print a DMA address. This fix a problem that if_wm.c
can't compile with WM_DEBUG on non-64bit platforms.
 1.234 01-Sep-2012  matt branches: 1.234.2;
Shut up gcc about some uninitialized variables.
 1.233 30-Aug-2012  msaitoh Enable VLAN hardware tagging on all chips that have the new queue mechanism.
Tested with 82575{EB,GB}, 82576, 82580, I350 and ICH9.
 1.232 29-Aug-2012  bouyer Make vlan and all ip/ip6 checksum offload work for the I350.

On newer devices, when using the legacy TX descriptors, vlan-related flags
that were set on the last descriptor of a packet have to be set on the
first one.
For tso/checksum offloads, a new "advanced" descriptor format has to be
used.

Change wcd_txdescs to a union defining all types of descriptors (they
are all 16-bytes wide).
Define a new tx function wm_nq_start(), which handle newer devices.
There is some code duplication with wm_start(), but adding support to
the existing wm_start() would make it a if () {} else {} maze. This also
allows to get rid of some workaround for older chips that are not needed
here.
Use wm_nq_start() instead of wm_start() for the I350 (this should probably
be for all WM_F_NEWQUEUE devices, but I have no hardware but the I350 to
test). Call ifp->if_start() instead of wm_start() where is matters.

Tested on a I350, and a i80003 (which use the old format), both with and
without vlans, with and without checksum offloads.
 1.231 09-Aug-2012  msaitoh Fix the check of the device type in last commit.
Reported by Thomas Klausner.
 1.230 09-Aug-2012  msaitoh Add workaround for QEMU and the variants that fail on EEPROM access.

This problem was discovered a few years ago, but some variants and
cloud services still have the bug. This problem is not NetBSD's bug
but qemus' bug. For NetBSD users, existence of buggy virtual machines
is sad thing, so we add a workaroud.
 1.229 22-Jul-2012  matt Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.228 25-May-2012  msaitoh Add support Intel I350 Ethernet.
 1.227 02-Feb-2012  tls branches: 1.227.2;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.226 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.225 28-Nov-2011  bouyer branches: 1.225.2;
There is problem with 82576 chips (and probably 82575 too) with hardware vlan
tagging: some packets are sent untagged on the wire.
Follow OpenBSD and disable hardware vlan tagging for these chips
(I couldn't find a hint in other open-source drivers at what could be
wrong ...)
 1.224 19-Nov-2011  tls First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.223 01-Jul-2011  matt branches: 1.223.2;
Fix uninitialized data warning found by gcc 4.5
 1.222 24-May-2011  msaitoh Fix invalid PBA setting on ICH{9,10}. This bug was introduced in the last
commit. I noticed this problem via mail from spz.
 1.221 20-May-2011  msaitoh - Add PCH2 support.
- Add 82579 support.
- Change PBA size for PCH from 10K to 26K as FreeBSD's em-7.1.7
- Add yet another 82567V support.
- Add ICH10+HANKSVILL support.
- Add 82580 quad-1000BaseX support.
 1.220 22-Feb-2011  dyoung Use /*FALLTHROUGH*/.
 1.219 06-Feb-2011  bouyer wm_gmii_reset(): restore generic reset delays to what they were before
rev 1.186. This makes the following hardware find its PHY again, and I can't
see how these larger delays could be a problem for other hardware:

wm0 at pci6 dev 7 function 0: Intel i82541GI 1000BASE-T Ethernet, rev. 5
wm0: interrupting at ioapic2 pin 0, event channel 5
wm0: 32-bit 66MHz PCI bus
wm0: 65536 word (16 address bits) SPI EEPROM
wm0: Ethernet address 00:13:72:54:ee:13
igphy0 at wm0 phy 1: Intel IGP01E1000 Gigabit PHY, rev. 0
igphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 1.218 26-Jan-2011  msaitoh Fix MAC address check on 8257[156] and 80003 case. Some cards have non 0xffff
pointer but those don't use alternative MAC address in reality. So we check
whether the broadcast bit is set or not like Intel's e1000 driver.
Fixes PR kern/44072 reported by Jean-Yves Moulin.

Remove extra Warning for newer cards.
 1.217 14-Dec-2010  dyoung branches: 1.217.2; 1.217.4;
Stop wm(4) from needlessly resetting when you add or delete a vlan(4):

ifconfig vlan0 create vlan 2 vlanif wm0
ifconfig vlan0 destroy

It pays to avoid a reset because after a reset it can take about 30
seconds before wm0 is back on the net.

The patch garnered no objections on tech-net@.

Sponsored by CoyotePoint Systems Inc.
 1.216 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.215 16-Oct-2010  taca - Change "else" + space + tab "if" to "else" + space + "if".
- A word "mechanism" was accidently separated in to "me" and "chanism"
in comment.

No functional chanage and I found it while reading if_wm.c yesterday.
 1.214 26-Jul-2010  jym Add PAE to ALL kernel, so that most paddr_t format string errors get caught
during compilation.

While here, fix the compilation for ALL.
 1.213 21-Jul-2010  msaitoh Use ether_set_ifflags_cb()
 1.212 19-Jul-2010  jakllsch Omit U+00AE "REGISTERED SIGN" in a product name due to its non-ASCII nature.
wm_release_hw_control() in wm_detach() before we unmap the registers we need.
Unmap I/O space during detach.
 1.211 14-Jul-2010  msaitoh - s/TBDA/TDBA/. It stands for Transmit Descriptor Base Address.
- The document says that the TDH register must be set after
TCL.EN is set on 82575 and newer devices.

TODO:
- ip4csum doesn't work on 82575 and newer devices (reported by Paul Goyette),
so we have to fix it.
 1.210 28-Jun-2010  msaitoh Fix a bug that wm_attach() fails after reading MAC address. Fixes PR#43533.

Fix an uninitialized value on some cases.
 1.209 25-Jun-2010  msaitoh Only 82571 shares port 0 of EEMNGCTL_CFGDONE.
 1.208 25-Jun-2010  msaitoh Add some code to support 82580[ER]. Tested on my own I340-T4.

- Fix CTRL_EXT_SWDPIN() and CTRL_EXT_SWDPIO() macros. The bit order of the
SW definable pin is not 6543 but 3654!!!

- Rewrite the code to read MAC address from eeprom.

- Add some code to support 82580.

TODO:
- ukphy -> somephy
 1.207 25-May-2010  msaitoh Fix the names of 82577L[MC] LAN controllers (for mobile).
Fix typo.
 1.206 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.205 10-Mar-2010  msaitoh branches: 1.205.2;
82576 is dual port, so check the FUNCID and increment the MAC address for
the 2nd port.
 1.204 07-Mar-2010  msaitoh Fix the type of sc_ss. That is not bus_space_handle_t but bus_size_t.
Reported by jdc.
 1.203 07-Mar-2010  msaitoh - Add code for WOL, ASF, IPMI and Intel AMT.
- wm_enable_wakeup() is disabled by default. If you want to use WOL with
the Magic Packet, define WM_WOL.
- Add the following flags:
WM_F_ASF_FIRMWARE_PRESENT
WM_F_ARC_SUBSYSTEM_VALID
WM_F_HAS_AMT
WM_F_HAS_MANAGE
WM_F_WOL
- Add wm_suspend() and wm_resume(). Give/get the control to/from the
firmware.
- Need more work for PCH. See wm_enable_phy_wakeup().
- Enable wm_get_hw_control() for 82574 and 82583.
- Add Yet another workaround for ICH8.
- Add wm_igp3_phy_powerdown_workaround_ich8lan() for power down problem
on D3.
 1.202 07-Mar-2010  msaitoh Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
 1.201 07-Mar-2010  msaitoh Add the detach code.
 1.200 25-Feb-2010  msaitoh Merge if_wm.c rev. 1.162.4.13 and if_wmvar.h rev. 1.2.46.3 into maintrunk.
Increase the timeout value to prevent timeout on 80003. The values are taken
from Intel's e1000 driver. Tested by spz and me.
 1.199 16-Feb-2010  msaitoh Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
 1.198 16-Feb-2010  msaitoh indent, tabify and remove extra spaces.
 1.197 04-Feb-2010  msaitoh branches: 1.197.2;
Don't increment when ICR_RXO is set because we count them by WMREG_MPC
counter.
 1.196 04-Feb-2010  msaitoh - Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Count Missed packet (rx fifo overflow) and Receive no buffers (rx ring full)
into iqdrops.
 1.195 22-Jan-2010  martin Unify the name of the device property to hold a MAC address - there was
no clear majority for either "mac-addr" vs. "mac-address", but a quick
gallup poll among developers selected the latter.
 1.194 21-Jan-2010  msaitoh Remove an extra debug printf(). KNF.
No functional change.
 1.193 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.192 14-Jan-2010  msaitoh Fixes the rx stall problem on 82578 by MANY workaround code.
We need more work for 82577.
 1.191 12-Jan-2010  msaitoh - Add i82567LM-2 i82567LM-4 i82567V-3 LAN controller.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. Now we can linkup 1000BaseT
on PCH. It seems that we have to do the same work for ICH9.
 1.190 11-Jan-2010  msaitoh Add partial support for PCH. We have to do more work for PCH. Especially
I don't know what driver i82578 should be attached to. makephy? or atphy?
MII_OUI() says that the PHY is from Attansic (== Atheros). Intel's e1000
driver says that it's close to makphy...

I can't link up at 1000BaseT yet...
 1.189 07-Jan-2010  msaitoh Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
 1.188 07-Jan-2010  msaitoh bugfixes:
- add missing break in wm_reset()...
- fix the offset of WMREG_PBS...
- fix length of some delay()s in wm_gmii_reset()
 1.187 05-Jan-2010  msaitoh Fix the checking of jumbo frame function though I don't know whether
the function wokrs or not...

Remove the extra macro definition for the offset 0x1a in EEPROM.
 1.186 05-Jan-2010  msaitoh Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
 1.185 29-Dec-2009  msaitoh - Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- Add support for i82583V.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
 1.184 27-Dec-2009  msaitoh Fix the bug that ICH9 can't found a PHY. This fix is not good, but it's
the same as e1000 driver... Fixes PR#42237
 1.183 16-Dec-2009  msaitoh Sync with Intel's original em driver:
- Add dspcode for igp3 and use it when the EEPROM isn't available.
- Add some delays.
- Stop the PHY transmitter before patching the DSP code and restart it after wrote.
- Save and restore register 0x2f5b.
 1.182 16-Dec-2009  msaitoh Re-enable igphy's 82566 support.
- Patch for the DSP code is only for 8254[17] and we have to apply the
different patches between rev. 1 and rev. 2.
- The workaround for analog fuse is only for 82547 rev. 1.
- The workaround for smartspeed is only for 8254[17]

see http://mail-index.netbsd.org/tech-net/2009/08/05/msg001546.html
 1.181 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.180 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.179 06-Aug-2009  msaitoh If the difference bettween last flag and new flag is only IFF_PROMISC or
IFF_ALLMULTI, set multicast filter only to prevent link down. Tested by
Mark Davies and me. Fixes PR#29126 for wm.
 1.178 30-Jul-2009  msaitoh Fix the bug that another lock mechanism is used to access Kumeran registers
on i80003 and ICHs.

Fix yet another i80003 ONLY workaround. The code to modifing TIPG register
is only for i80003.

Set the Re-Transmit on Late Collision(RTLC) flag for all devices.

Fix a typo in a printf message.
 1.177 14-Jul-2009  msaitoh Some fixes for i80003 and ICH{8,9,10} from e1000 driver and document:

Add setting for KABGTXD register for ICH{8,9,10}.

ICH9 and ICH10 has no FCAL, FCAH and FCT like ICH8.

Add special setting for FCTTV and TCTL_EXT register for i80003

The special setting for TIPG is only for i80003.

Some of kumeran settings are only for i80003's bugs.

Add some ICH10 fixes.
 1.176 13-Jul-2009  msaitoh Check PCI-X mode as e1000 driver.
 1.175 29-May-2009  darran Add vlan support and hardware offload capabilities to agr.
These changes allow vlans to be layered above agr, with the attach
and detach propogated to the member ports in the aggregation.
Note the agr interface must be up before the vlan is attached.

Adds SIOCINITIFADDR support to the wm driver for setting the AF_LINK
address, necessary for agr to be able to set the mac addresses of each
port to the agr address (i.e. so it can receive all intended traffic
at the hardware level).

Adds support for disabling the LACP protocol by setting LINK1 on the agr
interface (e.g. ifconfig agr0 link1).

In consultation with tls@.
 1.174 07-Apr-2009  msaitoh Reload sc_ctrl in wm_reset().

Add an ICH10 entry.

Remove some obsolete comments.
 1.173 07-Apr-2009  msaitoh Fix about TBI mode. This fix doesn't influence MII mode.
- Fix panic in mediachange.
- Fix SWDPIN(1)'s polarity on some chips.
- Fix flow control stuff (includes PR#32009).
- Stop RXCFG storm. It ocours easily.
- And more fix about autonego.

Tested on PRO/1000F, PRO/1000XF and PRO/1000 MF.
 1.172 31-Mar-2009  darran Missed a small but important change to enable hardware VLAN support.
 1.171 31-Mar-2009  darran Enable the vlan code that thorpej@NetBSD.org added, and fix a bug where
the vlan tag was read from the rx descriptor after it was reinitialized
(and hence was always 0). Hardware vlan support looks good tested
between two vmware clients.
With support from tls@NetBSD.org.
 1.170 29-Mar-2009  msaitoh Add workaround for 82543GC.
We need to force speed and duplex on the MAC equal to what the PHY
speed and duplex configuration is. Fixes PR#36430.
 1.169 20-Mar-2009  msaitoh Examine the management mode and mark DRV_LOAD (for ICH{8,9,10},80003,
8257{1,2,3,4}).

Add some error's printf().

Make the bank detect routine into the function.
 1.168 20-Mar-2009  msaitoh On i82563, the em driver says that the ready bit in the MDIC register may be
incorrectly set. Insert delay(200) like the em driver. Fixes PR#41014.
 1.167 10-Mar-2009  msaitoh add an entry for 82567LF-3.
fix the register access for ICH10DO.
 1.166 28-Feb-2009  msaitoh Fix the multicast hash bug on ICH9's wm.
Now we can catch ff02::9 on ICH9's wm.
 1.165 27-Feb-2009  sborrill Add support for 82574L (as found on Desktop CT adaptor) based on 82573 support.
 1.164 27-Jan-2009  markd branches: 1.164.2;
Add i82567LM-3
 1.163 02-Dec-2008  sketch Fix '||' vs '&&' mix-up from when ich9 support was added. Fixes nasty
EEPROM-trashing bug on ich8 and ich9 chipsets as described in

http://mail-index.netbsd.org/current-users/2008/12/02/msg006435.html

caused by setting the wrong type of EEPROM.
 1.162 15-Oct-2008  bouyer branches: 1.162.2; 1.162.4;
Add support for more ethenet ICH9 devices. Tested by Pouya D. Tafti
on a 82801I_IGP_M_AMT.
 1.161 09-Sep-2008  cegger make an i386/ALL kernel build
 1.160 08-Sep-2008  christos cf_attach_decl_new
 1.159 15-Aug-2008  simonb When receiving a chain with multiple mbufs (eg a jumbo frame) make sure
the last mbuf in the chain doesn't have a negative length when adjusting
lengths when removing the FCS (which leads to a panic in sbcompress()).

Fix contributed by Wasabi Systems.
 1.158 10-Apr-2008  cegger branches: 1.158.4; 1.158.6; 1.158.10;
use aprint_*_dev and device_xname
 1.157 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.156 11-Mar-2008  dyoung Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.
 1.155 23-Feb-2008  rafal Request DMA-coherent memory for the rx/tx descriptors. Makes this work on
sgimips (tested on my O2). Hint re: descriptor size << cacheline size from
Tsutsui-san; thanks!
 1.154 07-Feb-2008  dyoung branches: 1.154.2; 1.154.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.153 29-Jan-2008  tls Sigh. What was meant here was an ITR register value of 1500, for 2604
interrupts/sec -- not the other way around. Caught by yamt.

When I can confirm that it won't lock the chip up on the models claimed
to be problematic, I'll probably adjust the packet timers a bit further
to see if I can get latency down under low load. But this should be
better.
 1.152 19-Jan-2008  dyoung Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.151 11-Jan-2008  ragge Add entry to match the "Intel� PRO/1000 PT Quad Port Server Adapter".
 1.150 14-Dec-2007  tls Adjust interrupt moderation for newer chips to be saner according to the
82571 manual and Intel Application Note 450. Previously, we were setting
RADV and TIDV/TADV values that didn't make any sense given the enormous
ITR value we were setting (well outside the range recommended by Intel
and quite possibly rejected silently by the chip as junk) and setting
RADV without setting RDTR, which is explicitly documented as having no
effect.

A considerable performance improvement is achieved for TCP and UDP at
gigabit speed. I need to revisit this to deal with the timer ticks
being 4X as long when the chip's in 100mbit mode, and to set values
for the older chips' interrupt timers that are more like what the
appnote recommends. This should help for 82543 and newer, though.
 1.149 09-Dec-2007  jmcneill branches: 1.149.2;
Merge jmcneill-pm branch.
 1.148 30-Oct-2007  simonb branches: 1.148.2; 1.148.4; 1.148.6;
Some space-to-tab changes.
XXX: All the recently added ich8 support functions use 4-space indent,
not touching that...
 1.147 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.146 30-Aug-2007  msaitoh branches: 1.146.4;
Add more work for the EEPROM reaload sequence.
Fix typo.
 1.145 30-Aug-2007  msaitoh EECD_EE_AUTORD is only for 8257{123},80003,ICH{89}.
Will fix "auto read from eeprom failed to complete" problem.
 1.144 28-Aug-2007  msaitoh add ICH9
need more work?
 1.143 26-Aug-2007  dyoung branches: 1.143.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.142 09-Jul-2007  ad branches: 1.142.2; 1.142.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.141 29-May-2007  simonb Fix a tyop.
 1.140 30-Apr-2007  simonb Restore $NetBSD$ tag.
 1.139 29-Apr-2007  bouyer Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller

tested with: Intel i82801H (AMT) LAN Controller, rev. 2
 1.138 27-Mar-2007  salo fix typos in last, Eratta->Errata
 1.137 27-Mar-2007  msaitoh Workaround for 82541 Eratta 29 and 82547 Eratta 28.
These devices have to reset the PHY before reset the MAC.

Reported and tested by salo.
 1.136 13-Mar-2007  msaitoh branches: 1.136.2;
KNF
 1.135 04-Mar-2007  christos branches: 1.135.2; 1.135.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.134 23-Feb-2007  msaitoh fix media link issues with fiber-based card

fixes PR#35797
 1.133 23-Feb-2007  msaitoh fix some negotiation problems on wm(4).

will fix PR#30078, PR#30490, PR#30906, PR#33429, PR#35386.
 1.132 21-Feb-2007  thorpej Pick up some additional files that were missed before due to conflicts
with newlock2 merge:

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.131 23-Nov-2006  yamt branches: 1.131.2; 1.131.4;
implement ipv6 TSO.
partly from Matthias Scheler. tested by him.
 1.130 16-Nov-2006  yamt wm: add IPv6 rx tcp/udp checksum offloading.
 1.129 16-Nov-2006  yamt wm_tx_offload: in the case of "txtsopain",
m_copyback ip header to the correct offset.
 1.128 15-Nov-2006  yamt remove __unused from function parameters.
 1.127 21-Oct-2006  bouyer Add support for the Intel 80003 Gigabit Ethernet controller (found e.g. in
newer server chipsets) to wm(4), from the FreeBSD em(4) driver.
While there, add a few other Intel Ethernet controller that should work as
is.
Properly update the RX error and TX collision counters.
Add ikphy(4), a driver for the Intel i82563 Kumeran 10/100/1000 Ethernet PHYs
 1.126 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.125 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.124 05-Jul-2006  wrstuden branches: 1.124.4; 1.124.6;
Fix len=-4 issues.

When receiving a packet, if a receive buffer has length 0,
treat it the same way we treat a failed mapping.

Fix contributed by Wasabi Systems.
 1.123 20-Jun-2006  jmcneill Add powerhook for wm(4), from George Michaelson <ggm AT apnic DOT net>
 1.122 17-Jun-2006  christos re-factor the pci powestate api. reviewed by gimpy
 1.121 16-Jun-2006  msaitoh fix the MAC address of the second port of the 82571
 1.120 10-Jun-2006  msaitoh branches: 1.120.2;
o i82573 doesn't support jumbo frame
o set PBA for i8257[123]
o set MULA when sc_type == i8257[123]
 1.119 10-Jun-2006  uebayasi KNF.
 1.118 10-Jun-2006  msaitoh fix compile error
 1.117 10-Jun-2006  msaitoh Enable i82573!!!

TODO:
add some code for FLASH
fix phy stuff
 1.116 05-Jun-2006  msaitoh add support 82546GB_PCIE(PRO/100MT), 82541ER_LOM, 82547EI_MOBILE,
82571EB_COPPER, 82571EB_FIBER, 82572EI_COPPER, 82572EI_FIBER
and 82572EI(PRO/1000PT)

TODO: add i82573 support
 1.115 05-May-2006  thorpej branches: 1.115.2;
Remove the devprop API and switch everthing over to the new proplib. Add
a new device_properties() accessor for device_t that returns the device's
property dictionary.
 1.114 27-Feb-2006  thorpej branches: 1.114.2; 1.114.4; 1.114.6;
cfg1, cfg2, and swdpin are not generic properties the same way that
mac-addr is. Prefix them with i82543-
 1.113 22-Feb-2006  gavan Convert MD hook to device property reads.

Device properties, if present, take precedence over EEPROM values.
 1.112 16-Feb-2006  gavan Compute the EEPROM checksum to determine the presence of valid EEPROM data.
If EEPROM data is invalid, allow a MD hook to supply EEPROM data instead.
 1.111 07-Feb-2006  thorpej In the receive interrupt handler, compute the packet length before resetting
m to point to the first buffer in the packet. The bug would cause the
length of jumbo frames to be incorrect.
 1.110 24-Dec-2005  perry branches: 1.110.2; 1.110.4; 1.110.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.109 11-Dec-2005  christos merge ktrace-lwp.
 1.108 29-Oct-2005  yamt don't reset interface on rx overrun because it makes
the situation worse, if the overrun is merely a symptom of heavy load.
increament if_ierrors instead. PR/29831.
 1.107 10-Aug-2005  yamt branches: 1.107.2;
add ipv6 tx checksum offloading support for wm driver.
reviewed by Jason Thorpe.
 1.106 07-Aug-2005  yamt wm_rxintr: ignore h/w assisted checksum results if WRX_ST_IXSM is set.
 1.105 04-Aug-2005  skrll Fix a typo.
 1.104 25-Jul-2005  ross Fix compilation nits with WM_DEBUG.
 1.103 02-May-2005  yamt branches: 1.103.2;
split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.
 1.102 26-Apr-2005  scw In wm_stop():

- Clear the interrupt mask to ensure the device cannot assert its
interrupt line.
- Clear sc->sc_icr to ensure wm_intr() makes no attempt to service any
currently pending or shared interrupt.

This should address the problem reported in both PR/29903 and PR/22493.
(wm(4) is susceptible to crashing in wm_intr() when the interface is downed)
 1.101 19-Mar-2005  tron Add support for Intel PRO/1000 GT. Change provided in private e-mail by
unex at linija dot org.
 1.100 11-Mar-2005  matt branches: 1.100.2;
Set ip_len to 0 in the wm driver when TSO is being used.
 1.99 09-Mar-2005  matt Add TCP Segment Offload support.
 1.98 05-Mar-2005  thorpej - Set IFCS on every data descriptor (hint from Linux driver).
- Make sure IDE is set on context descriptors.
 1.97 05-Mar-2005  thorpej txpullup event counters are no longer needed.
 1.96 27-Feb-2005  perry nuke trailing whitespace
 1.95 21-Feb-2005  thorpej Define M_CSUM_DATA_IPv4_IPHL() and M_CSUM_DATA_IPv4_OFFSET() macros
to extract data from csum_data, rather than just open-coding it.
 1.94 20-Feb-2005  jdolecek use VLAN_* macros for VLAN tag extraction/addition

XXX the HW VLAN tagging code stays disabled, same as before
 1.93 18-Feb-2005  thorpej Re-apply changes that were mistakenly lost by the previous revision.
 1.92 18-Feb-2005  briggs Update the interrupt mitigation support.
Actually initialize the interrupt throttling register.
Actually initialize the tx and tx absolute interrupt delay timer regs.
Update default values for the rx and tx delay timers.
Inspired by Zdenek Salvet in PR kern/29373.
 1.91 18-Feb-2005  heas Adjust csum_data usage; mask off the high 16 bits for L4 header stuff offset
and make use of the L3 header length from the high 16 bits such that an
m_pullup is no londer necessary.
 1.90 30-Jan-2005  thorpej Eliminate use of M_HASFCS.
 1.89 30-Nov-2004  briggs branches: 1.89.4; 1.89.6;
Minor tweak to add newline to an aprint_error().
 1.88 24-Nov-2004  briggs The 8254x apparently doesn't respond well to I/O accesses at 0. Do not
attempt to map the I/O BAR if it is 0. This will have the side-effect
of causing the wm_reset() routine to fall back to memory BAR accesses
for those chips on which it would attempt I/O BAR accesses for the reset.

Also update the comments about why we attempt the I/O BAR accesses for
the reset in favor of the memory BAR accesses.
 1.87 24-Nov-2004  thorpej Don't bother caching the checksum context. Other drivers for this chip
don't, and it seems as though doing it may cause some problems.
 1.86 23-Nov-2004  thorpej If we have to do an m_pullup() when setting up offload parameters,
make sure that the pullup was done into trailing space at the end of
the existing first-mbuf-in-chain. If not, log an error and drop the
packet, because the mbuf chain no longer corresponds to the DMA map,
and we are already committed to transmitting the packet.
 1.85 23-Nov-2004  thorpej Also toggle the second port's Ethernet address lsb on the WM_T_82546_3.
 1.84 22-Nov-2004  thorpej Use log() instead of printf().
 1.83 30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.82 06-Oct-2004  thorpej Define a WM_MAXTXDMA constant to represent the largest Tx DMA any given
packet will require.
 1.81 06-Oct-2004  thorpej Sync the Tx DMA map after offload stuff has been dealt with, since the
offload set-up digs into the packet.
 1.80 06-Oct-2004  thorpej Restructure the loop in wm_start() that passes over the DMA map segments
slightly to make it easier to drop in errata work-arounds that require
adding extra descriptors onto the end of the packet.
 1.79 05-Oct-2004  thorpej Largest Tx descriptor buffer size is actually 4K.
 1.78 05-Oct-2004  thorpej Work around another problem (that causes horrible performance) on the 82547:
- Change the Tx:Rx on-chip RAM allocation ratio based on MTU:
=> 82547: > 8192 18K:22K, else 10K:30K
=> others: > 8192 24K:40K, else 16K:48K
Values derived from Linux driver.
- On the 82547, keep track of how much of the Tx FIFO has been used.
When in half-duplex mode, don't let packets wrap around the FIFO ring
buffer, because that causes the chip to croak. Detect this, stall the
Tx queue, use a timer to wait for the packets to drain from the Tx FIFO,
reset the internal FIFO pointers, and restart the Tx queue. Basic
algorithm (and some magic numbers) derived from FreeBSD and Linux drivers.
 1.77 14-Sep-2004  simonb Remove an unused event counter.
 1.76 21-Aug-2004  thorpej Make the product table static.
 1.75 05-Aug-2004  thorpej - Dump the mbuf chain if we encounter a "too many DMA segments" error
on transmit.
- On 82544 and up, allocate 4096 Tx descriptors rather than just 256.
82543 and down must still use 256, due to errata.
- Allow up to 256 DMA segments per packet. I have observed some truly
pathological mbuf chains under certain (admittedly uncommon) workloads
when jumbo frames are in use.
 1.74 15-Jul-2004  tron Reduce transmit queue len to 16 for the Intel i82547 to avoid FIFO
overruns. This fixes the horrible send performance reported in
PR kern/23782. Reviewed by Frank van der Linden and Jason R. Thorpe.
 1.73 13-Jul-2004  tron The Intel i82547EI gigabit ethernet controller isn't really a PCI
device. So instead trying to find and print out the PCI bus properties
mark it as a CSA device.
 1.72 12-Jul-2004  tron Make this build if WM_DEBUG is defined.
 1.71 16-May-2004  thorpej Add flow control support, based on work by HITOSHI Osada.
 1.70 06-May-2004  ragge Remove the "panic("wm_init: MCLBYTES > 2048 not supported.");" stuff,
the driver works very well with larger MCLBYTES.
 1.69 09-Apr-2004  thorpej Add support for 64-bit PCI DMA addressing.
 1.68 19-Feb-2004  thorpej branches: 1.68.2;
s/WTC_DTYP_D/WTX_DTYP_D/
 1.67 19-Feb-2004  thorpej Fix typo in debug message. From Jeffrey Hsu.
 1.66 19-Feb-2004  thorpej Add missing txseg20 counter name. Pointed out by Jeffrey Hsu.
 1.65 14-Jan-2004  tsutsui Fix hardware cksum problem on big endian machines.
Tested on macppc by HATANO Hiromichi.

Note I guess this bug could be fixed only adding one htole32(),
but I'd rather clean up endianness handling:
- Use htole32() only to accesses against DMA descriptors.
- Don't use uint32_t union member with htole32()/le32toh()
to access uint8_t/uint16_t descriptors.
- Add le32toh() in some DPRINTF.
(XXX: strictly speaking, bus_dmamap_sync() is needed for these DPRINTF)
 1.64 04-Dec-2003  thorpej Bump the Tx DMA segment count to 40. Apparently, it's common to have
DMA segment counts in this ballpark when using jumbo frames (so says
the "ti" driver).
 1.63 22-Nov-2003  thorpej Add a missing i82541 ID to the table.
 1.62 07-Nov-2003  thorpej Fix brain'o in PCIX speed detection. kern/23375 (John R. Shannon).
 1.61 04-Nov-2003  thorpej Enable i82541 and i82547 chips - it works well enough to get broader
testing. Update the TODO list.
 1.60 03-Nov-2003  ichiro Fix uninitialized variable warnings
 1.59 25-Oct-2003  christos Fix uninitialized variable warnings
 1.58 23-Oct-2003  ragge Set snd queue size to max(WM_IFQUEUELEN, IFQ_MAXLEN), instead of hard to
WM_IFQUEUELEN.
 1.57 22-Oct-2003  thorpej Add support for the SPI EEPROM found on the newer i82541 and i82547
chips. Add the i82541 and i82547 product IDs to the table, #if 0'd
out, for now (there are still more changes to come for these new chips
to work properly).
 1.56 21-Oct-2003  thorpej Add a TODO list item.
 1.55 21-Oct-2003  thorpej - Move the i82540EM (LOM) along with the other i82540 product IDs.
- Match the i82545GM (1000BASE-T and 1000BASE-X) and i82546GB
(1000BASE-T and 1000BASE-X) product IDs.
 1.54 21-Oct-2003  thorpej If we're on PCI-X, look up the PCI-X capability. Verify that the
max memory read byte count in the command register is <= the max designed
memory read byte count in the status register. If not, reset it to the
status register's value. This is necessary because some BIOSes configure
the wrong value, and the wrong value confused some versions of the PCI-X
capable chips.
 1.53 21-Oct-2003  thorpej - Map I/O space on chips that support it. While it is not used for
normal operation, it is required to implement a bug work-around on
some chips.
- When issuing a reset on the i82544, i82540, i82545, i82546,
and i82541, use I/O space, if available, to work around a problem
with the memory write cycle (problem only occurs when issuing
a reset).
 1.52 21-Oct-2003  thorpej Record characteristics of the bus connection at attach time.
 1.51 20-Oct-2003  thorpej - Do better error checking on EEPROM access.
- Let the EEPROM wire-protocol handler perform the loop.
 1.50 20-Oct-2003  thorpej Move all the code that handles the MicroWire EEPROM protocol into
a separate function.
 1.49 20-Oct-2003  thorpej Fix a typo in the "failed to acquire eeprom" case.
 1.48 20-Oct-2003  thorpej Move the code that reads a series of bits from the EEPROM into a
separate function.
 1.47 20-Oct-2003  thorpej Make all of the functions in this file static.
 1.46 20-Oct-2003  thorpej Factor out the code that sends bits to the EEPROM into a separate function.
 1.45 20-Oct-2003  thorpej Move the code that handle the EEPROM handshake into separate functions.
 1.44 17-Oct-2003  thorpej Store the number of EEPROM address bits in the softc.
 1.43 17-Oct-2003  thorpej Add internal representation for i82545 rev 3, i82546 rev3, i82541,
i82541 rev 2, i82547, and i82547 rev 2.
 1.42 17-Oct-2003  thorpej Make the "align tweak" factor per-interface (since the MTU is per-interface).
 1.41 10-Sep-2003  tls Add support for jumbo (9K) frames. Add support for larger receive
descriptor sizes if larger mbuf clusters are in use -- currently
commented out because, for some reason, transmit doesn't work at
all with large mbuf cluster sizes.

Note that using actual 9K frames is a _lot_ less efficient than
using frames that are a little smaller than 8K so that they fit
in one or two pages (instead of two or three) and avoid the extra
chained descriptor with only 1K of data in it, too. TCP will
segment things just fine for an 8K total packet size, just as it
does for 1500-byte packets.

On my system, using "mtu 8000" with ifconfig, I get an almost 50%
performance boost for TCP (930Mbit/sec instead of 660Mbit/sec) over
1500-byte frames. "mtu 9000" yields only 770Mbit/sec.
 1.40 04-Sep-2003  thorpej GMII works on the i82543 now.
 1.39 29-Jul-2003  thorpej Add support for the Intel PRO/1000 MT Quad Port server adapter; this
is just 2 i82546EB chips behind an IBM 133 PCI-X bridge.
 1.38 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.37 29-Apr-2003  thorpej branches: 1.37.2;
Use aprint*().
 1.36 15-Apr-2003  tron Pullup short mbuf in wm_tx_cksum() instead of dropping it which fixes
PR kern/21190 by myself. Jason R. Thorpe code reviewed the changes.
 1.35 15-Apr-2003  thorpej wm_tx_cksum(): Set the initial offset correctly for packets using
802.1Q encap.
 1.34 05-Apr-2003  kent Support for 82540EP and 82540EP (LOM).
Not tested.
 1.33 04-Apr-2003  kent Support for i82450EP.
 1.32 04-Feb-2003  thorpej Use bus_dmamap_load_mbuf() in wm_add_rxbuf().
 1.31 21-Jan-2003  itojun m_tag transition mistake (within #if 0)
 1.30 17-Jan-2003  itojun switch from kame-based m_aux mbuf auxiliary data, to openbsd m_tag
implementation. it will simplify porting across *bsd (such as kame/altq),
and make us more synchronized. from Joel Wilsson
 1.29 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.28 21-Dec-2002  kristerw wm_copy_small in not used anywhere. Remove.
 1.27 23-Oct-2002  christos change the macro params to longer names
 1.26 21-Oct-2002  fair Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.
 1.25 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.24 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.23 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.22 23-Aug-2002  itojun #if 0 out call to rnd_add_uint32() in interrupt logic until thorpej
measures performance differences.
 1.21 23-Aug-2002  itojun attach random number source.
 1.20 17-Aug-2002  thorpej * After testing for DD on a descriptor, and finding it clear,
sync that descriptor with PREREAD to make sure that it is evicted
from the data cache. From Allen Briggs.
* With the above bug fixed, stop using BUS_DMA_COHERENT, resulting in
a fairly decent performance improvement on systems where BUS_DMA_COHERENT
causes descriptors to be accessed uncached (most painful in wm_start()).
 1.19 15-Aug-2002  thorpej Update a comment; TCP/IP checksum offloading is fixed!
 1.18 15-Aug-2002  briggs On transmit, zero the upper 32 bits of the address in the tx descriptor.
The descriptor may have been used as as context descriptor in the past,
in which case this field will be non-zero. h/w checksum offload works now.
 1.17 08-Aug-2002  thorpej Add support for the new i82540, i82545, and i82546 Gig-E chips. The
i82546 chip has 2 Gig-E interfaces in a single chip.

The main difference is these chips have a special handshaking protocol
for accessing the EEPROM (due to the shared nature on the i82546).
 1.16 07-Aug-2002  simonb Fix a typo in a comment.
 1.15 06-Aug-2002  simonb Fix a typo in a comment.
 1.14 14-Jul-2002  thorpej Document exactly what the problem with TCP/UDP checksum offloading is.
 1.13 14-Jul-2002  thorpej And thus spake the manual...

When initializing a TCP/IP context descriptor, even if a checksum
offload feature is not going to be used, the IPCSS and TUCSS fields
must be initialized.
 1.12 09-Jul-2002  thorpej * Shuffle the TODO list a bit.
* Fix outbound IPv4 header checksums (missing add of an offset).
* When enabling Rx TCP/UDP checksum offload, make sure that IPv4
header checksum Rx offload is enabled on the chip, as well.
 1.11 09-Jul-2002  thorpej Don't use internal names to identify chips. Add types for the
i82540, i82545, and i82546 (but don't match them yet).
 1.10 09-Jul-2002  thorpej Make a few performance tweaks:
* Bump the number of Rx descriptors from 128 to 256.
* Don't use a sliding Tx interrupt window. Instead, just do reap-behind
when we have <= 1/8 of our available descriptors in wm_start().
* Don't use Tx Queue Empty interrupts, and always set the Tx Interrupt
Delay bit in the Tx descriptor.
* In wm_intr(), always call wm_rxintr() and wm_txintr(), regardless of
their respective ISR bits being set. We're here, might as well do some
work.
* Adjust the Tx and Rx interrupt delay timer values. New values from
Intel's driver for FreeBSD via Allen Briggs.

With these changes, NetBSD can sustain > 900Mb/s userland to userland
*without* using TCP checksum offload using Intel PRO/1000 XT cards.
 1.9 09-May-2002  thorpej branches: 1.9.2; 1.9.4; 1.9.6;
* Increase the number of Tx job queue entries from 32 to 64.
* Garbage-collect some unused stuff.
* Make the Tx window slide along the Tx job queue space, not the
Tx descriptor space. We are more likely to run low on DMA maps
than we are hardware descriptors.
 1.8 09-May-2002  thorpej * Instrument the number of times we force a Tx interrupt.
* When forcing an interrupt, make sure that interrupt-delay-enable is
cleared (necessary with last change to make sure it's set for all
descriptors).
* Crank up the Transmit Interrupt Delay Value to 1024 * 1.024 msec. We
really want these to be deferred.
 1.7 08-May-2002  thorpej Don't set WTX_TCPIP_CMD_TCP or WTX_TCPIP_CMD_IP in the TCP/IP context
descriptor. Those are apparently only valid if using the Cordova's
"segmentation offload" feature.
 1.6 08-May-2002  thorpej * Make sure the interrupt-delay bit gets set on ALL descriptors,
except for the one we want to force a Tx interrupt.
* Tweak the Tx descriptor accounting a little.
 1.5 08-May-2002  thorpej Implement a cache for the outbound IP/TCP/UDP checksum offload
context.
 1.4 08-May-2002  thorpej * Account for the descriptor consumed by the Tx checksum offload
context setup.
* Implement Matt Thomas's sliding Tx interrupt window algorithm,
forcing an interrupt when the Tx desc list is 2/3 consumed.
* Use the Report Packet Sent interrupt, rather than Report Status,
since we use the Tx descriptor to count Tx errors.
 1.3 02-May-2002  thorpej Fix a comment.
 1.2 02-May-2002  thorpej * Deal with errata on the i82542 and i82543 chips: The size of the
transmit and receive descriptor rings is limited to 256 descriptors.
So, set the if_snd queue length to 256 to let the upper layers queue
lots of packets, and let the driver handle up to 32 of them at a time.
(We should probably make this change to most Ethernet drivers, since
it actually saves some resources.)
* Increase the number of Tx DMA segments from 8 to 16.
* Clean up the way we count "how many times did I get a packet with N
DMA segments".
* Add a missing htole32() in wm_tx_cksum().
* Don't set both RS and RPS in the last Tx descriptor of a packet; just
use RS.
* Add some more information to the watchdog message.
 1.1 28-Mar-2002  thorpej branches: 1.1.2;
Device driver for the Intel i82542, i82542, and i82544 Gigabit
Ethernet interfaces.
 1.1.2.11 17-Jan-2003  thorpej Sync with HEAD.
 1.1.2.10 29-Dec-2002  thorpej Sync with HEAD.
 1.1.2.9 11-Nov-2002  nathanw Catch up to -current
 1.1.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.7 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.6 19-Aug-2002  thorpej Sync with trunk.
 1.1.2.5 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.1 28-Mar-2002  nathanw file if_wm.c was added on branch nathanw_sa on 2002-04-01 07:46:27 +0000
 1.9.6.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.6.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.9.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.6.1 09-May-2002  jdolecek file if_wm.c was added on branch kqueue on 2002-06-23 17:47:46 +0000
 1.9.4.10 01-May-2005  tron Pull up revision 1.102 (requested by scw in ticket #5761):
In wm_stop():
- Clear the interrupt mask to ensure the device cannot assert its
interrupt line.
- Clear sc->sc_icr to ensure wm_intr() makes no attempt to service any
currently pending or shared interrupt.
This should address the problem reported in both PR/29903 and PR/22493.
(wm(4) is susceptible to crashing in wm_intr() when the interface is
downed)
 1.9.4.9 16-Jun-2003  grant Pull up revision 1.36 (requested by tron in ticket #1256):

Pullup short mbuf in wm_tx_cksum() instead of dropping it which fixes
PR kern/21190 by myself. Jason R. Thorpe code reviewed the changes.
 1.9.4.8 08-Nov-2002  tron Pull up revision 1.17 (requested by thorpej in ticket #650):
Add support for the new i82540, i82545, and i82546 Gig-E chips. The
i82546 chip has 2 Gig-E interfaces in a single chip.
The main difference is these chips have a special handshaking protocol
for accessing the EEPROM (due to the shared nature on the i82546).
 1.9.4.7 07-Nov-2002  tron Pull up revision 1.11 (requested by thorpej in ticket #453):
Don't use internal names to identify chips. Add types for the
i82540, i82545, and i82546 (but don't match them yet).
 1.9.4.6 17-Aug-2002  lukem Pull up revision 1.19 (requested by thorpej in ticket #684):
Update a comment; TCP/IP checksum offloading is fixed!
 1.9.4.5 17-Aug-2002  lukem Pull up revision 1.18 (requested by briggs in ticket #683):
On transmit, zero the upper 32 bits of the address in the tx descriptor.
The descriptor may have been used as as context descriptor in the past,
in which case this field will be non-zero. h/w checksum offload works now.
 1.9.4.4 15-Jul-2002  thorpej pullup-1-6 ticket #501 (thorpej).

Original log message:
Document exactly what the problem with TCP/UDP checksum offloading is.
 1.9.4.3 15-Jul-2002  thorpej pullup-1-6 ticket #500 (thorpej).

Original log message:
And thus spake the manual...

When initializing a TCP/IP context descriptor, even if a checksum
offload feature is not going to be used, the IPCSS and TUCSS fields
must be initialized.
 1.9.4.2 10-Jul-2002  lukem Pull up revision 1.12 (requested by thorpej in ticket #455):
* Shuffle the TODO list a bit.
* Fix outbound IPv4 header checksums (missing add of an offset).
* When enabling Rx TCP/UDP checksum offload, make sure that IPv4
header checksum Rx offload is enabled on the chip, as well.
 1.9.4.1 10-Jul-2002  lukem Pull up revision 1.10 (requested by thorpej in ticket #451):
Make a few performance tweaks:
* Bump the number of Rx descriptors from 128 to 256.
* Don't use a sliding Tx interrupt window. Instead, just do reap-behind
when we have <= 1/8 of our available descriptors in wm_start().
* Don't use Tx Queue Empty interrupts, and always set the Tx Interrupt
Delay bit in the Tx descriptor.
* In wm_intr(), always call wm_rxintr() and wm_txintr(), regardless of
their respective ISR bits being set. We're here, might as well do some
work.
* Adjust the Tx and Rx interrupt delay timer values. New values from
Intel's driver for FreeBSD via Allen Briggs.
With these changes, NetBSD can sustain > 900Mb/s userland to userland
*without* using TCP checksum offload using Intel PRO/1000 XT cards.
 1.9.2.2 29-Aug-2002  gehenna catch up with -current.
 1.9.2.1 15-Jul-2002  gehenna catch up with -current.
 1.37.2.14 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.37.2.13 01-Apr-2005  skrll Sync with HEAD.
 1.37.2.12 08-Mar-2005  skrll Sync with HEAD.
 1.37.2.11 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.37.2.10 04-Feb-2005  skrll Sync with HEAD.
 1.37.2.9 18-Dec-2004  skrll Sync with HEAD.
 1.37.2.8 29-Nov-2004  skrll Sync with HEAD.
 1.37.2.7 02-Nov-2004  skrll Sync with HEAD.
 1.37.2.6 19-Oct-2004  skrll Sync with HEAD
 1.37.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.37.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.37.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.37.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.37.2.1 03-Aug-2004  skrll Sync with HEAD
 1.68.2.5 08-Jan-2005  jdc Fix pull up merge error.
Pointed out by Martin J. Laubach.
 1.68.2.4 07-Jan-2005  jdc Pull up revision 1.78 (requested by thorpej in ticket #897)

Work around another problem (that causes horrible performance) on the 82547:
- Change the Tx:Rx on-chip RAM allocation ratio based on MTU:
=> 82547: > 8192 18K:22K, else 10K:30K
=> others: > 8192 24K:40K, else 16K:48K
Values derived from Linux driver.
- On the 82547, keep track of how much of the Tx FIFO has been used.
When in half-duplex mode, don't let packets wrap around the FIFO ring
buffer, because that causes the chip to croak. Detect this, stall the
Tx queue, use a timer to wait for the packets to drain from the Tx FIFO,
reset the internal FIFO pointers, and restart the Tx queue. Basic
algorithm (and some magic numbers) derived from FreeBSD and Linux drivers.
 1.68.2.3 16-Jul-2004  he branches: 1.68.2.3.2;
Pull up revision 1.74 (requested by tron in ticket #670):
Reduce transmit queue length to 16 for the Intel i82547 to
avoid FIFO overruns. This fixes the horrible performance
problems reported in PR#23782.
 1.68.2.2 15-Jul-2004  he Pull up revision 1.73 (requested by tron in ticket #665):
The Intel i82547EI gigabit Ethernet controller isn't really
a PCI device. So instead of trying to find and print the
PCI bus properties mark it as a CSA device.
 1.68.2.1 12-Jul-2004  he Pull up revision 1.72 (requested by tron in ticket #640):
Make this build if WM_DEBUG is defined.
 1.68.2.3.2.9 21-Jul-2005  snj Pull up revision 1.101 (requested by tron in ticket #5507):
Add support for Intel PRO/1000 GT. Change provided in private e-mail by
unex at linija dot org.
 1.68.2.3.2.8 01-May-2005  tron Pull up revision 1.102 (requested by scw in ticket #1481):
In wm_stop():
- Clear the interrupt mask to ensure the device cannot assert its
interrupt line.
- Clear sc->sc_icr to ensure wm_intr() makes no attempt to service any
currently pending or shared interrupt.
This should address the problem reported in both PR/29903 and PR/22493.
(wm(4) is susceptible to crashing in wm_intr() when the interface is
downed)
 1.68.2.3.2.7 23-Feb-2005  he Pull up revision 1.85 (requested by thorpej in ticket #1001):
Also toggle the second port's Ethernet address lsb on the
WM_T_82546_3, so the two ports get different MAC addresses.
 1.68.2.3.2.6 24-Jan-2005  he Pull up revision 1.83 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.68.2.3.2.5 13-Jan-2005  he Revert previous commit because the result does not even compile.
Further input on req ticket #899 requested.
 1.68.2.3.2.4 12-Jan-2005  he Pull up revision 1.80 (via patch, requested by thorpej in ticket #899):
Restructure the loop in wm_start() that passes over the DMA map
segments slightly to make it easier to drop in errata work-arounds
that require adding extra descriptors onto the end of the packet.
 1.68.2.3.2.3 12-Jan-2005  he Pull up revision 1.79 (via patch, requested by thorpej in ticket #898):
Largest Tx descriptor buffer size is actually 4K.
 1.68.2.3.2.2 08-Jan-2005  jdc Fix pull up merge error.
Pointed out by Martin J. Laubach.
 1.68.2.3.2.1 07-Jan-2005  jdc Pull up revision 1.78 (requested by thorpej in ticket #897)

Work around another problem (that causes horrible performance) on the 82547:
- Change the Tx:Rx on-chip RAM allocation ratio based on MTU:
=> 82547: > 8192 18K:22K, else 10K:30K
=> others: > 8192 24K:40K, else 16K:48K
Values derived from Linux driver.
- On the 82547, keep track of how much of the Tx FIFO has been used.
When in half-duplex mode, don't let packets wrap around the FIFO ring
buffer, because that causes the chip to croak. Detect this, stall the
Tx queue, use a timer to wait for the packets to drain from the Tx FIFO,
reset the internal FIFO pointers, and restart the Tx queue. Basic
algorithm (and some magic numbers) derived from FreeBSD and Linux drivers.
 1.89.6.3 26-Mar-2005  yamt sync with head.
 1.89.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.89.6.1 12-Feb-2005  yamt sync with head.
 1.89.4.1 29-Apr-2005  kent sync with -current
 1.100.2.13 26-Mar-2009  bouyer Pull up following revision(s) (requested by msaitoh in ticket #2002):
sys/dev/pci/if_wm.c: revision 1.166
Fix the multicast hash bug on ICH9's wm.
Now we can catch ff02::9 on ICH9's wm. Fixes PR#37976.
 1.100.2.12 13-Dec-2008  bouyer Pull up following revision(s) (requested by sketch in ticket #1983):
sys/dev/pci/if_wm.c: revision 1.163
Fix '||' vs '&&' mix-up from when ich9 support was added. Fixes nasty
EEPROM-trashing bug on ich8 and ich9 chipsets as described in
http://mail-index.netbsd.org/current-users/2008/12/02/msg006435.html
caused by setting the wrong type of EEPROM.
 1.100.2.11 10-Nov-2008  snj Pull up following revision(s) (requested by bouyer in ticket #1976):
sys/dev/pci/if_wm.c: revision 1.162
sys/dev/pci/pcidevs: revision 1.961, 1.962 via patch
Add support for more ethenet ICH9 devices. Tested by Pouya D. Tafti
on a 82801I_IGP_M_AMT.
 1.100.2.10 19-Nov-2007  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1863):
sys/dev/pci/if_wm.c 1.137-1.138,1.141,1.144-1.146
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893 via patch
share/man/man4/wm.4 1.18-1.19
Fix typo.
Fix EEPROM reload sequence.
Add ICH9 support.
Workaround for 82541 Errata 29 and 82547 Errata 28:
These devices have to reset the PHY before reset the MAC.
Reported and tested by salo.
 1.100.2.9 14-Oct-2007  riz Pull up following revision(s) (requested by bouyer in ticket #1770):
share/man/man4/wm.4: revision 1.17
sys/dev/pci/if_wmreg.h: revision 1.22
sys/dev/pci/if_wm.c: revision 1.139 via patch
sys/dev/pci/if_wm.c: revision 1.140 via patch
sys/dev/pci/pcidevs: patch
Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller
tested with: Intel i82801H (AMT) LAN Controller, rev. 2
Restore $NetBSD$ tag.
Note ICH8 LAN support.
 1.100.2.8 06-Jun-2007  liamjfoy Pull up following revision(s) (requested by yamt in ticket #1750):
sys/dev/pci/if_wm.c: revision 1.129
wm_tx_offload: in the case of "txtsopain",
m_copyback ip header to the correct offset.
 1.100.2.7 31-Mar-2007  bouyer pullup the following revisions (requested by msaitoh in ticket 1681):
sys/dev/pci/if_wm.c 1.104-1.105, 1.116-1.121,
1.127,1.133-1.134 via patch
sys/dev/pci/if_wmreg.h 1.17-1.20
sys/dev/pci/pcidevs patch
sys/dev/mii/igphy.c 1.11
sys/dev/mii/makphy.c 1.20, 1.23
sys/dev/mii/ikphy.c patch
sys/dev/mii/ikphyreg.h patch
sys/dev/mii/miidevs 1.68
sys/dev/mii/files.mii 1.39
sys/arch/i386/conf/GENERIC 1.788-1.789 via patch
sys/arch/i386/conf/GENERIC.MPACPI patch
sys/arch/i386/conf/GENERIC_LAPTOP 1.209 via patch
sys/arch/i386/conf/INSTALL 1.291 via patch
sys/arch/i386/conf/INSTALL_LAPTOP 1.104 via patch
sys/arch/i386/conf/XEN2_DOM0 1.13 via patch
share/man/man4/wm.4 1.14-1.16
Add support for many cards (include PCI-express based chips).
Many bug fixes about auto negotiations (PR#30078, PR#30490,
PR#30906, PR#33429 and PR#35386).
Fix media link issues with fiber-based card (PR#35797).
 1.100.2.6 11-Nov-2006  bouyer Pull up following revision(s) (requested by hauke in ticket #1578):
sys/dev/pci/if_wm.c: revision 1.108
don't reset interface on rx overrun because it makes
the situation worse, if the overrun is merely a symptom of heavy load.
increament if_ierrors instead. PR/29831.
 1.100.2.5 07-Jul-2006  tron Pull up following revision(s) (requested by lukem in ticket #1400):
sys/dev/pci/if_wm.c: revision 1.124
Fix len=-4 issues.
When receiving a packet, if a receive buffer has length 0,
treat it the same way we treat a failed mapping.
Fix contributed by Wasabi Systems.
 1.100.2.4 08-Feb-2006  tron Pull up following revision(s) (requested by thorpej in ticket #1161):
sys/dev/pci/if_wm.c: revision 1.111
sys/dev/pci/if_sip.c: revision 1.104
In the receive interrupt handler, compute the packet length before
resetting
m to point to the first buffer in the packet. The bug would cause the
length of jumbo frames to be incorrect.
 1.100.2.3 28-Aug-2005  tron Pull up following revision(s) (requested by yamt in ticket #700):
sys/dev/pci/if_wm.c: revision 1.106
wm_rxintr: ignore h/w assisted checksum results if WRX_ST_IXSM is set.
 1.100.2.2 28-Apr-2005  tron Pull up revision 1.102 (requested by scw in ticket #207):
In wm_stop():
- Clear the interrupt mask to ensure the device cannot assert its
interrupt line.
- Clear sc->sc_icr to ensure wm_intr() makes no attempt to service any
currently pending or shared interrupt.
This should address the problem reported in both PR/29903 and PR/22493.
(wm(4) is susceptible to crashing in wm_intr() when the interface is
downed)
 1.100.2.1 07-Apr-2005  jmc Pullup rev 1.101 (requested by tron in ticket #16)

Add support for Intel PRO/1000 GT.
 1.103.2.12 24-Mar-2008  yamt sync with head.
 1.103.2.11 17-Mar-2008  yamt sync with head.
 1.103.2.10 27-Feb-2008  yamt sync with head.
 1.103.2.9 11-Feb-2008  yamt sync with head.
 1.103.2.8 04-Feb-2008  yamt sync with head.
 1.103.2.7 21-Jan-2008  yamt sync with head
 1.103.2.6 15-Nov-2007  yamt sync with head.
 1.103.2.5 27-Oct-2007  yamt sync with head.
 1.103.2.4 03-Sep-2007  yamt sync with head.
 1.103.2.3 26-Feb-2007  yamt sync with head.
 1.103.2.2 30-Dec-2006  yamt sync with head.
 1.103.2.1 21-Jun-2006  yamt sync with head.
 1.107.2.1 02-Nov-2005  yamt sync with head.
 1.110.6.3 07-Jun-2006  kardel Sync with head.
 1.110.6.2 01-Jun-2006  kardel Sync with head.
 1.110.6.1 22-Apr-2006  simonb Sync with head.
 1.110.4.1 09-Sep-2006  rpaulo sync with head
 1.110.2.2 01-Mar-2006  yamt sync with head.
 1.110.2.1 18-Feb-2006  yamt sync with head.
 1.114.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.114.4.1 11-May-2006  elad sync with head
 1.114.2.4 15-Sep-2006  yamt revert unrelated changes erroneously slipped in.
 1.114.2.3 11-Aug-2006  yamt sync with head
 1.114.2.2 26-Jun-2006  yamt sync with head.
 1.114.2.1 24-May-2006  yamt sync with head.
 1.115.2.1 19-Jun-2006  chap Sync with head.
 1.120.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.124.6.2 10-Dec-2006  yamt sync with head.
 1.124.6.1 22-Oct-2006  yamt sync with head
 1.124.4.2 12-Jan-2007  ad Sync with head.
 1.124.4.1 18-Nov-2006  ad Sync with head.
 1.131.4.5 07-May-2007  yamt sync with head.
 1.131.4.4 15-Apr-2007  yamt sync with head.
 1.131.4.3 24-Mar-2007  yamt sync with head.
 1.131.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.131.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.131.2.8 24-Mar-2009  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1291):
sys/dev/pci/if_wm.c: revision 1.166
Fix the multicast hash bug on ICH9's wm.
Now we can catch ff02::9 on ICH9's wm. Fixes PR#37976
 1.131.2.7 13-Dec-2008  bouyer Pull up following revision(s) (requested by sketch in ticket #1246):
sys/dev/pci/if_wm.c: revision 1.163
Fix '||' vs '&&' mix-up from when ich9 support was added. Fixes nasty
EEPROM-trashing bug on ich8 and ich9 chipsets as described in
http://mail-index.netbsd.org/current-users/2008/12/02/msg006435.html
caused by setting the wrong type of EEPROM.
 1.131.2.6 31-Oct-2008  snj Pull up following revision(s) (requested by bouyer in ticket #1215):
sys/dev/pci/if_wm.c: revision 1.162
sys/dev/pci/pcidevs: revision 1.961,1.962
Add support for more ethenet ICH9 devices. Tested by Pouya D. Tafti
on a 82801I_IGP_M_AMT.' sys/dev/pci/if_wm.c sys/dev/pci/pcidevs
 1.131.2.5 11-Sep-2007  xtraeme branches: 1.131.2.5.4;
Pull up following revision(s) (requested by msaitoh in ticket #865):
sys/dev/pci/if_wm.c: revision 1.145
sys/dev/pci/if_wm.c: revision 1.146
share/man/man4/wm.4: revision 1.19
EECD_EE_AUTORD is only for 8257{123},80003,ICH{89}.
Will fix "auto read from eeprom failed to complete" problem.
Add more work for the EEPROM reaload sequence.
Fix typo.
Bump date for previous (ICH9 support).
 1.131.2.4 29-Aug-2007  liamjfoy Pull up following revision(s) (requested by masanobu in ticket #850):

sys/dev/pci/if_wm.c 1.137
sys/dev/pci/if_wm.c 1.138
sys/dev/pci/if_wm.c 1.141
sys/dev/pci/if_wm.c 1.144
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphy.c 1.12
sys/dev/mii/miidevs 1.72
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/wm.4 1.18

Fix for 82541 and 82547's reset bug.
Modify wm_reset() to make some device stable.
Add ICH9 support to wm.
Add I82566 support to igphy.

Pulled done via patch.
 1.131.2.3 03-May-2007  snj branches: 1.131.2.3.2;
Pull up following revision(s) (requested by bouyer in ticket #598):
share/man/man4/wm.4: revision 1.17
sys/dev/pci/if_wmreg.h: revision 1.22
doc/CHANGES: revision 1.836
sys/dev/pci/if_wm.c: revision 1.139
sys/dev/pci/if_wm.c: revision 1.140
Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller
tested with: Intel i82801H (AMT) LAN Controller, rev. 2
Restore $NetBSD$ tag.
Note ICH8 LAN support.
Note ICH8 LAN support.
 1.131.2.2 26-Mar-2007  jdc Pull up revision 1.134 (requested by msaitoh in ticket #515).

fix media link issues with fiber-based card

fixes PR#35797
 1.131.2.1 26-Mar-2007  jdc Pull up revision 1.133 (requested by msaitoh in ticket #514).

fix some negotiation problems on wm(4).

will fix PR#30078, PR#30490, PR#30906, PR#33429, PR#35386.
 1.131.2.5.4.1 13-Dec-2008  bouyer Pull up following revision(s) (requested by sketch in ticket #1246):
sys/dev/pci/if_wm.c: revision 1.163
Fix '||' vs '&&' mix-up from when ich9 support was added. Fixes nasty
EEPROM-trashing bug on ich8 and ich9 chipsets as described in
http://mail-index.netbsd.org/current-users/2008/12/02/msg006435.html
caused by setting the wrong type of EEPROM.
 1.131.2.3.2.2 23-Sep-2007  wrstuden Sync with somewhat-recent netbsd-4.
 1.131.2.3.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.135.4.1 11-Jul-2007  mjf Sync with head.
 1.135.2.7 23-Oct-2007  ad Sync with head.
 1.135.2.6 09-Oct-2007  ad Sync with head.
 1.135.2.5 01-Jul-2007  ad Adapt to callout API change.
 1.135.2.4 09-Jun-2007  ad Sync with head.
 1.135.2.3 27-May-2007  ad Sync with head.
 1.135.2.2 10-Apr-2007  ad Sync with head.
 1.135.2.1 13-Mar-2007  ad Sync with head.
 1.136.2.1 29-Mar-2007  reinoud Pullup to -current
 1.142.6.11 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.142.6.10 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.142.6.9 31-Oct-2007  joerg Sync with HEAD.
 1.142.6.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.142.6.7 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.142.6.6 04-Sep-2007  joerg Register power management function only once.
 1.142.6.5 03-Sep-2007  jmcneill Sync with HEAD.
 1.142.6.4 21-Aug-2007  joerg Explicitly stop interface before going to D3. Don't bother to
init interface again if it is down. Assume wm_init is successful
as all failure causes are critical errors anyway. Remove shutdown
hooks.
 1.142.6.3 10-Aug-2007  he Add a missing "break;" in the power handler function before any
more developers copy this bug over to other drivers.

Pointed out by jmcneill@
 1.142.6.2 04-Aug-2007  jmcneill Make this compile again -- sys/php.h does not exist, and since sys/device.h
pulls in sys/pnp.h anyway, don't bother.
 1.142.6.1 04-Aug-2007  he Convert the old powerhook to a pnp power management handler, based
on the azalia power management handler and what was here before.
 1.142.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.143.2.3 23-Mar-2008  matt sync with HEAD
 1.143.2.2 09-Jan-2008  matt sync with HEAD
 1.143.2.1 06-Nov-2007  matt sync with HEAD
 1.146.4.2 13-Nov-2007  bouyer Sync with HEAD
 1.146.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.148.6.1 11-Dec-2007  yamt sync with head.
 1.148.4.1 26-Dec-2007  ad Sync with head.
 1.148.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.149.2.3 20-Jan-2008  bouyer Sync with HEAD
 1.149.2.2 11-Jan-2008  bouyer Sync with HEAD
 1.149.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.154.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.154.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.154.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.154.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.154.2.1 24-Mar-2008  keiichi sync with head.
 1.158.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.158.10.1 19-Oct-2008  haad Sync with HEAD.
 1.158.6.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.158.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.158.4.7 11-Aug-2010  yamt sync with head.
 1.158.4.6 11-Mar-2010  yamt sync with head
 1.158.4.5 16-Sep-2009  yamt sync with head
 1.158.4.4 19-Aug-2009  yamt sync with head.
 1.158.4.3 18-Jul-2009  yamt sync with head.
 1.158.4.2 20-Jun-2009  yamt sync with head
 1.158.4.1 04-May-2009  yamt sync with head.
 1.162.4.21 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1962):
sys/dev/pci/if_wm.c: revisions 1.259-1.266, 1.269, 1.271, 1.273-1.274, 1.277-1.278, 1.282, 1.284-1.285, 1.287, 1.290, 1.294, 1.297-1.298, 1.300-1.301, 1.304-1.307, 1.310, 1.312-1.314, 1.316 via patch
sys/dev/pci/if_wmreg.c: revisions 1.54-1.57, 1.59-1.60, 1.62, 1.64-1.66 via patch
sys/dev/pci/if_wmvar.c: revisions 1.17, 1.20-1.21 via patch
sys/dev/pci/pcidevs: revisions 1.1172, 1.1195, 1.1201 via patch
- Fix "MDIC write error" bug for 82574 and 82583. For those chips, the
semaphore must be released after chip reset. Found and tested by
Mark Davies.
- Fix BMC related bugs.
- Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with
Asus P8P67 Deluxe motherboard and tested by jnemeth.
- Add support for I354 DH89xxCC and some new I218 devices.
- Fix definition of CTRL_GIO_M_DIS bit.
- Insert completion barrier between register write and delay().
- Bump max TX DMA size to avoid pathological condition with TSO. From dyoung.
- Fix semaphore related bugs.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880).
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- It's not required to print "failed to detect NVM bank" with
aprint_error_dev(). Use DPRINTF(). Same as {Free,Open}BSD.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.
- Delete 82580ER related code. It was from FreeBSD and was removed
in r203049.
- Remove extra debug message.
- Remove unused variable.
- Remove a duplicated error message.
- Cleanup comments.
- Fix debug message.
 1.162.4.20 26-Apr-2015  martin Apply patch, requested by msaitoh in ticket #1961:

sys/dev/pci/if_wm.c: (patch)

Fix a bug (in the backport for #1850) that passed the wrong pointer as the
first argument of bpf_mtap() on 82575 and newer chip.
 1.162.4.19 07-Sep-2013  bouyer sys/dev/pci/if_wm.c 1.246-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16
sys/dev/pci/pcidevs 1.1152-1.1153
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Add comments, fix some comments, use macros and remove trailing
whitespaces.
[msaitoh, ticket #1867]
 1.162.4.18 19-Jun-2013  bouyer Pullup the following revisions via patch, requested by msaitoh in ticket #1850:
sys/dev/pci/if_wm.c 1.201, 1.203-1.204,
1.207-1.212, 1.215,
1.217-1.218, 1.220-1.223,
1.228, 1.232-245
sys/dev/pci/if_wmreg.h 1.40-1.45, 1.47-1.48
sys/dev/pci/if_wmvar.h 1.11-1.13
sys/dev/pci/pcidevs 1.1074, 1.1077, 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.6
sys/dev/mii/ihphy.c 1.1-1.2
sys/dev/mii/ihphyreg.h 1.1
sys/dev/mii/inbmphyreg.h 1.3
sys/dev/mii/files.mii 1.47 via patch
sys/dev/mii/miidevs 1.97 and 1.100
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/arch/i386/conf/ALL 1.280
sys/arch/i386/conf/GENERIC 1.1001
sys/arch/i386/conf/INSTALL_FLOPPY 1.11
sys/arch/i386/conf/XEN2_DOM0 patch
sys/arch/amd64/conf/GENERIC 1.293
sys/arch/amd64/conf/XEN3_DOM0 1.61
share/man/man4/wm.4 1.21-1.24

Apply almost all fixes and improvements from netbsd-6 except for
the rev. 1.196's iqdrops' change.

- Add the detach code.
- Add code for WOL, ASF, IPMI and Intel AMT. WOL is disabled by default
- Add Yet another workaround for ICH8.
- 82576 is dual port, so check the FUNCID and increment the MAC address for
the 2nd port.
- Fix the names of 82577L[MC] LAN controllers (for mobile).
- Fix CTRL_EXT_SWDPIN() and CTRL_EXT_SWDPIO() macros. The bit order of the
SW definable pin is not 6543 but 3654!!!
- Rewrite the code to read MAC address from eeprom.
- Add 82580 support.
- 82571 quirk. Only 82571 shares port 0 of EEMNGCTL_CFGDONE.
- The document says that the TDH register must be set after
TCL.EN is set on 82575 and newer devices.
- Fix some register names. No functional change.
- Omit U+00AE "REGISTERED SIGN" in a product name due to its non-ASCII nature.
- Stop wm(4) from needlessly resetting when you add or delete a vlan(4).
- Fix MAC address check on 8257[156] and 80003 case. Some cards have non 0xffff
pointer but those don't use alternative MAC address in reality. So we check
whether the broadcast bit is set or not like Intel's e1000 driver.
Fixes PR kern/44072 reported by Jean-Yves Moulin.
- Add PCH2(and 82579) support. Fixes PR#46487
- Add yet another 82567V support.
- Add ICH10+HANKSVILL support.
- Add support Intel I350 Ethernet.
- Make vlan and all ip/ip6 checksum offload work for the I350.
- Fix compile error with WM_DEBUG.
- Fix a bug that PHY isn't set to low-power mode on PCH and PCH2.
- Add WM_DEBUG_NVM. If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
- Skip 64bit BAR correctly.
- Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
- Use 82580(and I350) specific PHY read/write functions. Fixes PR#47542.
- Style fix. Fix typo in comment. Fix comments. Add comments.
 1.162.4.17 17-Oct-2012  bouyer Apply patch, requested by msaitoh in ticket 1800:
sys/dev/pci/if_wm.c: revision 1.230-1.231 via patch
Add workaround for QEMU and the variants that fail on
EEPROM access.
This problem was discovered a few years ago, but some variants
and cloud services still have the bug. This problem is not
NetBSD's bug but qemus' bug. For NetBSD users, existence of
buggy virtual machines is sad thing, so we add a workaroud.
 1.162.4.16 25-Jan-2012  riz Pull up following revision(s) (requested by bouyer in ticket #1699):
sys/dev/pci/if_wm.c: revision 1.225
There is problem with 82576 chips (and probably 82575 too) with hardware vlan
tagging: some packets are sent untagged on the wire.
Follow OpenBSD and disable hardware vlan tagging for these chips
(I couldn't find a hint in other open-source drivers at what could be
wrong ...)
 1.162.4.15 07-Mar-2011  riz Pull up following revision(s) (requested by bouyer in ticket #1544):
sys/dev/pci/if_wm.c: revision 1.219
wm_gmii_reset(): restore generic reset delays to what they were before
rev 1.186. This makes the following hardware find its PHY again, and I can't
see how these larger delays could be a problem for other hardware:
wm0 at pci6 dev 7 function 0: Intel i82541GI 1000BASE-T Ethernet, rev. 5
wm0: interrupting at ioapic2 pin 0, event channel 5
wm0: 32-bit 66MHz PCI bus
wm0: 65536 word (16 address bits) SPI EEPROM
wm0: Ethernet address 00:13:72:54:ee:13
igphy0 at wm0 phy 1: Intel IGP01E1000 Gigabit PHY, rev. 0
igphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 1.162.4.14 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1358):
sys/dev/pci/if_wm.c 1.196-1.199,1.202,1.205
sys/dev/pci/if_wmvar.h 1.9
sys/dev/pci/if_wmreg.h 1.36-1.39
sys/dev/pci/pcireg.h 1.61-1.64
sys/dev/pci/pcidevs 1.1023
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
mii/igphy.c 1.21
mii/igphyvar.h 1.1
mii/inbmphyreg.h 1.2

- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
- Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
- (pcireg.h) Add PCIe config register definitions.
- Note that the changes to count Missed packet (rx fifo overflow) and Receive
no buffers (rx ring full) into iqdrops in rev. 1.196 of if_wm.c is not
pulled up.
 1.162.4.13 25-Feb-2010  sborrill branches: 1.162.4.13.2;
Fix regression caused by pullup #1277 requested by msaitoh.
 1.162.4.12 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c 1.184-1.192, 1.194
sys/dev/pci/if_wmreg.h 1.29-1.35
sys/dev/pci/if_wmvar.h 1.5-1.8
sys/dev/pci/pcidevs 1.1006,1.1009-1.1010, 1.1012-1.1013 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.5
sys/dev/mii/inbmphyreg.h 1.1

- Add support for i82583V.
- Add some ICH9 and ICH10 devices.
- Add support for PCH.
- Fix the bug that ICH9 can't found a PHY. Fixes PR#42237
- Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
- Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
- Fix the checking of jumbo frame function
- Remove the extra macro definition for the offset 0x1a in EEPROM.
- Add missing break in wm_reset()...
- Fix the offset of WMREG_PBS...
- Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. It seems that we have to
do the same work for ICH9.
- Fixes the rx stall problem on 82578 by MANY workaround code. We need more
work for 82577.
 1.162.4.11 23-Dec-2009  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: 1.176-1.179, 1.181-1.183
sys/dev/pci/if_wmreg.h: 1.28
sys/dev/pci/if_wmvar.h: 1.1-1.4
sys/dev/mii/igphy.c: 1.18-1.20 via patch

Many bugfixes:
- Some fixes for i80003 and ICH{8,9,10} from e1000 driver and document:
- Add setting for KABGTXD register for ICH{8,9,10}.
- ICH9 and ICH10 has no FCAL, FCAH and FCT like ICH8.
- Add special setting for FCTTV and TCTL_EXT register for i80003
- The special setting for TIPG is only for i80003.
- Some of kumeran settings are only for i80003's bugs.
- Add some ICH10 fixes.
- Fix the bug that another lock mechanism is used to access Kumeran
registers on i80003 and ICHs.
- Fix yet another i80003 ONLY workaround. The code to modifing TIPG
register is only for i80003.
- Set the Re-Transmit on Late Collision(RTLC) flag for all devices.
- Fix a typo in a printf message.
- If the difference bettween last flag and new flag is only IFF_PROMISC
or IFF_ALLMULTI, set multicast filter only to prevent link down.
Tested by Mark Davies and me. Fixes PR#29126 for wm.
- Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
- Fix igphy's 82566 support.
- Patch for the DSP code is only for 8254[17] and we have to apply
the different patches between rev. 1 and rev. 2.
- The workaround for analog fuse is only for 82547 rev. 1.
- The workaround for smartspeed is only for 8254[17]
- Sync with Intel's original em driver:
- Check PCI-X mode as e1000 driver.
- Add dspcode for igp3 and use it when the EEPROM isn't available.
- Add some delays.
- Stop the PHY transmitter before patching the DSP code and
restart it after writing.
- Save and restore register 0x2f5b.
 1.162.4.10 05-Jun-2009  snj Pull up following revision(s) (requested by 792):
sys/dev/pci/if_wm.c: revision 1.175 via patch
sys/net/if_ethersubr.c: revision 1.172 via patch
sys/net/agr/ieee8023ad_lacp.c: revision 1.9 via patch
sys/net/agr/if_agr.c: revision 1.23 via patch
sys/net/agr/if_agrether.c: revision 1.7 via patch
sys/net/agr/if_agrvar_impl.h: revision 1.8 via patch
Add vlan support and hardware offload capabilities to agr.
These changes allow vlans to be layered above agr, with the attach
and detach propogated to the member ports in the aggregation.
Note the agr interface must be up before the vlan is attached.
Adds SIOCSIFADDR support to the wm driver for setting the AF_LINK
address, necessary for agr to be able to set the mac addresses of each
port to the agr address (i.e. so it can receive all intended traffic
at the hardware level).
Adds support for disabling the LACP protocol by setting LINK1 on the agr
interface (e.g. ifconfig agr0 link1).
In consultation with tls@.
 1.162.4.9 21-May-2009  snj Pull up following revision(s) (requested by bouyer in ticket #711):
sys/dev/pci/pcidevs: revisions 1.975, 1.981, 1.982 via patch
sys/dev/pci/if_wm.c: revisions 1.164, 1.167, 1.173, 1.174 via patch
sys/dev/pci/if_wmreg.h: revisions 1.25, 1.27 via patch
Add Intel 82567LM_3 ethernet
--
Add i82567LM-3
--
add i82567LF-3 LAN Controller
--
add an entry for 82567LF-3.
fix the register access for ICH10DO.
--
Fix about TBI mode. This fix doesn't influence MII mode.
--
- Fix panic in mediachange.
- Fix SWDPIN(1)'s polarity on some chips.
- Fix flow control stuff (includes PR#32009).
- Stop RXCFG storm. It ocours easily.
- And more fix about autonego.
--
add 82801J_D_BM_LF (ICH10)
--
Reload sc_ctrl in wm_reset().
Add an ICH10 entry.
Remove some obsolete comments.
 1.162.4.8 11-May-2009  bouyer Apply patch (requested by msaitoh in ticket #751):
sys/dev/pci/if_wm.c: patch
Remove extra printf()s.
 1.162.4.7 03-May-2009  snj Pull up following revision(s) (requested by msaitoh in ticket #630):
sys/dev/pci/if_wm.c: revision 1.170
Add workaround for 82543GC.
We need to force speed and duplex on the MAC equal to what the PHY
speed and duplex configuration is. Fixes PR#36430.
 1.162.4.6 03-May-2009  snj Pull up following revision(s) (requested by tls in ticket #627):
sys/dev/pci/if_wm.c: revision 1.172
Missed a small but important change to enable hardware VLAN support.
 1.162.4.5 03-May-2009  snj Pull up following revision(s) (requested by tls in ticket #627):
sys/dev/pci/if_wm.c: revision 1.171
Enable the vlan code that thorpej@NetBSD.org added, and fix a bug where
the vlan tag was read from the rx descriptor after it was reinitialized
(and hence was always 0). Hardware vlan support looks good tested
between two vmware clients.
With support from tls@NetBSD.org.
 1.162.4.4 03-May-2009  snj Pull up following revision(s) (requested by spz in ticket #621):
sys/dev/pci/if_wm.c: revisions 1.168, 1.169 via patch
sys/dev/pci/if_wmreg.h: revision 1.26 via patch
On i82563, the em driver says that the ready bit in the MDIC register may be
incorrectly set. Insert delay(200) like the em driver.
--
Examine the management mode and mark DRV_LOAD (for ICH{8,9,10},80003,
8257{1,2,3,4}).
Add some error's printf().
Make the bank detect routine into the function.
 1.162.4.3 20-Mar-2009  msaitoh branches: 1.162.4.3.2;
Pull up following revision(s) (requested by sborrill in ticket #587):
sys/dev/pci/pcidevs: revision 1.978
sys/dev/pci/if_wm.c: revision 1.165
Add support for 82574L (as found on Desktop CT adaptor) based on 82573
support.
 1.162.4.2 18-Mar-2009  snj Pull up following revision(s) (requested by msaitoh in ticket #583):
sys/dev/pci/if_wm.c: revision 1.166
Fix the multicast hash bug on ICH9's wm.
Now we can catch ff02::9 on ICH9's wm.
 1.162.4.1 07-Dec-2008  bouyer Pull up following revision(s) (requested by sketch in ticket #160):
sys/dev/pci/if_wm.c: revision 1.163
Fix '||' vs '&&' mix-up from when ich9 support was added. Fixes nasty
EEPROM-trashing bug on ich8 and ich9 chipsets as described in
http://mail-index.netbsd.org/current-users/2008/12/02/msg006435.html
caused by setting the wrong type of EEPROM.
 1.162.4.13.2.1 07-Mar-2011  riz Pull up following revision(s) (requested by bouyer in ticket #1544):
sys/dev/pci/if_wm.c: revision 1.219
wm_gmii_reset(): restore generic reset delays to what they were before
rev 1.186. This makes the following hardware find its PHY again, and I can't
see how these larger delays could be a problem for other hardware:
wm0 at pci6 dev 7 function 0: Intel i82541GI 1000BASE-T Ethernet, rev. 5
wm0: interrupting at ioapic2 pin 0, event channel 5
wm0: 32-bit 66MHz PCI bus
wm0: 65536 word (16 address bits) SPI EEPROM
wm0: Ethernet address 00:13:72:54:ee:13
igphy0 at wm0 phy 1: Intel IGP01E1000 Gigabit PHY, rev. 0
igphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 1.162.4.3.2.1 19-Jul-2009  snj branches: 1.162.4.3.2.1.2;
Pull up following revision(s) (requested by msaitoh in ticket #862):
sys/dev/pci/if_wm.c: revisions 1.168, 1.170, and 1.173 via patch
sys/dev/pci/if_wmreg.h: revision 1.27
Fixes serious three bugs.
1) On i82563, the em driver says that the ready bit in the MDIC
register may be incorrectly set. Insert delay(200) like the em driver.
Fixes PR#41014
2) Add workaround for 82543GC. We need to force speed and duplex on
the MAC equal to what the PHY speed and duplex configuration is.
Fixes PR#36430.
3) Fix many problems and panic on TBI's cards (includes PR#32009).
 1.162.4.3.2.1.2.2 15-Feb-2014  matt sync pcireg.h with HEAD.
update if_wm.c and ppb.c accordingly.
 1.162.4.3.2.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.162.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.162.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.162.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.164.2.2 23-Jul-2009  jym Sync with HEAD.
 1.164.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.197.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.197.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.197.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.205.2.4 31-May-2011  rmind sync with head
 1.205.2.3 05-Mar-2011  rmind sync with head
 1.205.2.2 03-Jul-2010  rmind sync with head
 1.205.2.1 30-May-2010  rmind sync with head
 1.217.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.217.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.217.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.223.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.223.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.223.2.2 30-Oct-2012  yamt sync with head
 1.223.2.1 17-Apr-2012  yamt sync with head
 1.225.2.2 02-Jun-2012  mrg sync to latest -current.
 1.225.2.1 18-Feb-2012  mrg merge to -current.
 1.227.2.20 24-Sep-2016  bouyer Apply patch, requested by martin in ticket #1407:
sys/dev/pci/if_wm.c patch
fix evbppc build, where the older gcc wrongly warns about uninitialized
variable.
 1.227.2.19 06-May-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1366):
sys/dev/pci/if_wm.c: 1.281, 1.318, 1.320, 1.324-1.332, 1.334, 1.336, 1.343-1.344, 1.347-1.348, 1.350, 1.376-1.382, 1.386-1.387, 1.389 via patch
sys/dev/pci/if_wmreg.h: 1.68-1.70, 1.73-1.77, 1.79-1.80, 1.82, 1.86-1.88 via patch
sys/dev/pci/if_wmvar.h: 1.22-1.23, 1.25-1.30 via patch
sys/dev/mii/igphy.c: 1.25
sys/dev/mii/ukphy.c: 1.48
Sync wm(4) as of if_wm.c rev 1.389 except SERDES, MSI/MSI-X, multiqueue
and NET_MPSAFE:
- Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is more
than 4096. Almost the same as other OSes.
- For 82576 and newer devices, the PBA register is deleted. Don't write
PBA for those chips. Also change the calculation of RX packet buffer
size in new way.
- Print NVM image version and option ROM version.
- Add workaround for I210 Errata 25 and I211 Errata 10 (PLL bug). This
workaround is required if the NVM image version < 3.25.
- Fix a bug that wm_detach() didn't unmap the FHASH's area. Now
"drvctl -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
- Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX
packets" and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit.
The NVM Image version 2.1.4 and newer have this workaround.
- Check PHY type correctly. This change is required to use igphy(4)
device correctly.
- Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH*
too.
- Call wm_get_hw_control() correctly. This change fixes a bug that some
AMT based systems doesn't linkup at 1000BaseT. The problem was
observed on HP Compaq dc7700. A lot of fixes have been done for wm(4)
and igphy(4), so now PR#44893 should be fixed.
- Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT. It's required to
check the existence of AMT correctly.
- Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in
wm_reset() on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix
the behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change
might fix a problem that PHY's read/write functions can't get
semaphore.
- On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed
down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS
sets this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the
function checks the status correctly but it causes linkdown up to 10
times, so it's disabled for the time being.
- PR/50527: David Binderman: Fix impossible code. Odd offsets need
special treatment.
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Use sc->sc_itr instead of hard-coded number.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function
acts as mii_tick().
- ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition has not used yet.
- Add ACK data Disable bit's definition (not used yet).
- PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any
effect by default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when
WM_WOL is defined and it's disabled by default.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it
returns bool. No functional change.
- Reorder function definitions and macro definitions. No functional
change.
- Fix comment. Add comment. Update comment.
- KNF.
 1.227.2.18 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1296):
sys/dev/pci/pcidevs: revision 1.1195 via patch
sys/dev/pci/if_wm.c: revisions 1.290, 1.304 via patch
sys/dev/pci/if_wmvar.h: revision 1.20 via patch
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and
check the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- Support DH89xxCC device.
- Add extra delay for 82580 and newer devices except DH89XXCC SGMII device.
Same as FreeBSD.
 1.227.2.17 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #1292):
sys/dev/pci/if_wm.c 1.313-1.314 and 1.316 via patch

Fix a bug that the first access to NVM is failed on 8254[17] which use
SPI EEPROM. Observed on Dell PowerEdge [12]850.
Thanks Tom Ivar Helbekkmo for debugging.

Fix a bug that wm_sgmii_writereg() function doesn't pass the "val"
argument to the I2CCMD register. Reported by Bernard Merindol
in PR#49789.

Fix a bug that newer revision of I218-{LM,V} use wrong PHY access
functions. The problem only occured on devices that the PCI device ID
was 0x15a[0123].
[msaitoh, ticket #1292]
 1.227.2.16 16-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c: revision 1.312 via patch
sys/dev/pci/if_wmreg.h: revision 1.66 via patch
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Add comment.
- Fix typo in comment.
 1.227.2.15 04-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #1244):
sys/dev/pci/if_wm.c: revision 1.310
Fix a bug that a workaround for SWSM.SMBI bit doesn't work correctly.
This problem was only occured with old boot ROM on 8257[12].
XXX pullup to netbsd-[67]
 1.227.2.14 04-Dec-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: revisions 1.271, 1.273-1.274, 1.277-1.278,
1.280, 1.282, 1.284-1.285, 1.287,
1.293-1.294, 1.297-1.298,
1.300-1.301, 1.305-1.307 via patch
sys/dev/pci/if_wmreg.h: revisions 1.57-1.62, 1.64-1.65 via patch
sys/dev/pci/if_wmvar.h: revisions 1.19, 1.21 via patch
- Acquire SW semaphore in wm_get_swsm_semaphore().
- Fix some bugs realted to semaphore. This change fixes a problem which
was exposed in if_wm.c rev. 1.271. Tested by riastradh@.
- Clear the SMBI bit in SWSM register before accessing NVM and PHY in
wm_attach(). Same as FreeBSD.
- Fix a bug that 82573 doesn't put the hardware semaphore. Same as
FreeBSD r256200.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880). Tested with 82543GC, 82544EI,
82545EM, 82546GB 82571EB and 82572EI fiber cards.
- Don't use the RXCFG interrupt. It's not required and the interrupt is very
heavy (a lot of interrupts). Same as {Free,Open}BSD.
- Modify wm_tbi_mediachange() to be close to em_setup_fiber_serdes_link()
of {Free,Open}BSD. At least, don't forget to set duplex setting.
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Don't check SWSM_SMBI bit if WM_F_LOCK_SWSM isn't set. Fix a problem when
using vmware with e1000"e". With e1000e which is regarded as 82574L,
wm_gmii_init() fails with "could not acquire SWSM SMBI" message without
this change. This problem doesn't occur with real 82574L card.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Calculate NVM word size correctly.
- Determine timeout value based on the NVM word size.
- It's not required to print "failed to detect NVM bank" message.
Only print while debugging. Same as {Free,Open}BSD.
- Add some new I218 devices.
- Delete 82580ER related code. It was from FreeBSD and was removed in r203049.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Move some NVM related macros from if_wm.c to if_wmreg.h.
- Sort definitions in if_wmreg.h
- move NVM related values to the bottom.
- sort in register's address' order.
- Simplify wm_read_mac_addr().
- Fix debug message.
- Add missing prototypes.
- Rename some functions for consistency and clarify.
- Rename some macros for consistency.
- Remove a duplicated error message.
- Fix typo in comment.
- Cleanup comments.
- KNF.
 1.227.2.13 09-Nov-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #1189):
sys/dev/pci/if_wm.c: revision 1.270
sys/dev/mii/inphy.c: revision 1.53
sys/dev/mii/glxtphy.c: revision 1.24
sys/dev/mii/tlphy.c: revision 1.62
sys/dev/mii/iophy.c: revision 1.37
sys/dev/mii/brgphy.c: revision 1.70
sys/dev/mii/ihphy.c: revision 1.8
sys/dev/mii/bmtphy.c: revision 1.31
sys/dev/mii/urlphy.c: revision 1.30
sys/dev/mii/makphy.c: revision 1.40
sys/dev/mii/qsphy.c: revision 1.48
sys/dev/mii/igphy.c: revision 1.23
sys/dev/mii/nsphy.c: revision 1.58
sys/dev/mii/mvphy.c: revision 1.10
sys/dev/pci/if_txp.c: revision 1.41
sys/dev/mii/nsphy.c: revision 1.59
sys/dev/mii/rlphy.c: revision 1.28
sys/dev/mii/icsphy.c: revision 1.49
sys/dev/mii/rlphy.c: revision 1.29
sys/dev/mii/lxtphy.c: revision 1.49
sys/dev/mii/ciphyreg.h: revision 1.5
sys/dev/mii/nsphyter.c: revision 1.38
sys/dev/mii/sqphy.c: revision 1.50
sys/dev/mii/gentbi.c: revision 1.26
sys/dev/mii/gentbi.c: revision 1.27
sys/dev/mii/tqphy.c: revision 1.39
sys/dev/mii/ikphy.c: revision 1.10
sys/dev/mii/dmphy.c: revision 1.35
sys/dev/mii/amhphy.c: revision 1.20
sys/dev/mii/acphy.c: revision 1.24
sys/dev/mii/ciphy.c: revision 1.25
sys/dev/mii/brgphyreg.h: revision 1.8
sys/dev/mii/ukphy_subr.c: revision 1.12
sys/dev/ic/rtl80x9.c: revision 1.16
sys/arch/mips/adm5120/dev/if_admsw.c: revision 1.12
sys/dev/pci/if_kse.c: revision 1.28
sys/dev/mii/ukphy_subr.c: revision 1.13
sys/dev/mii/mii.h: revision 1.18
sys/dev/mii/gphyter.c: revision 1.29
No functional change:
- Fix typo.
- Remove trailing white spaces.
- Capitalize comments.
- Tabify.
- KNF.
IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
 1.227.2.12 09-Nov-2014  martin Pullup the following revisions, requested by msaitoh in ticket #1188:
sys/dev/pci/pcidevs 1.1172
sys/dev/pci/if_wm.c 1.263-1.266 via patch
sys/dev/pci/if_wmreg.h 1.55-1.56
sys/dev/pci/if_wmvar.h 1.17
share/man/man4/wm.4 1.26-1.27 and 1.29 via patch

- Add I354 support.
- Insert completion barrier between register write and delay().
- Fix the definition of CTRL_GIO_M_DIS. This bit is not bit 3 but bit 2.
- Cleanup
 1.227.2.11 03-Jun-2014  msaitoh Pull up following revision(s) (requested by tls in ticket #1070):
sys/dev/pci/if_wm.c: revision 1.269
From dyoung@ -- bump max TX DMA size to avoid pathological condition with TSO.
 1.227.2.10 29-Jul-2013  jdc Pull up revisions:
src/sys/dev/pci/if_wm.c revisions 1.259,1.260,1.261,1.262
src/sys/dev/pci/if_wmreg.h revision 1.54
(requested by msaitoh in ticket #918).

Fix "MDIC write error" bug for 82574 and 82583. For those chips, the semaphore
must be released after chip reset. Found and tested by Mark Davies.

Sync the wm_enable_mng_pass_thru() function with FreeBSD. Don't check
MANC_EN_MAC_ADDR_FILTER bit. Add 82574 and 82583 specific check. This
modification may change the setting of WM_F_HAS_MANAGE flag on some machines.

Sync the wm_release_manageablilty() fucntion with FreeBSD. Set MANC_ARP_EN.
This change enables HW ARP function when entering suspend.

When the chip is 82580(ER) or I350, set WM_F_ASF_FIRMWARE_PRES flag and
check for the WM_F_ARC_SUBSYS_VALID flag. Same as FreeBSD.

Move the location of wm_check_mng_mode() and wm_get_wakeup() in wm_attach().
Those functions access EEPROM, so they have to call after identifying EEPROM
access type. This modification may change the behavior of BMC(IPMI).

Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with Asus P8P67
Deluxe motherboard and tested by jnemeth.
 1.227.2.9 14-Jul-2013  riz Apply changes (requested by msaitoh in ticket #907):

sys/dev/pci/if_wm.c 1.238, 1.244-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.50-1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16

Various fixes to wm(4):
Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Change style, add comments, fix some comments, use macros and
remove trailing whitespaces.
[msaitoh, ticket #907]
 1.227.2.8 18-Feb-2013  riz branches: 1.227.2.8.2;
Pull up following revision(s) (requested by msaitoh in ticket #824):
sys/dev/pci/if_wm.c: revision 1.240
sys/dev/pci/if_wm.c: revision 1.241
sys/dev/pci/if_wm.c: revision 1.242
sys/dev/pci/if_wmreg.h: revision 1.49
- Add WM_DEBUG_NVM.
- If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
Skip 64bit BAR correctly. I don't know if this bug causes a real problem.
Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
 1.227.2.7 18-Feb-2013  riz sys/dev/pci/if_wm.c 1.235-1.236 via patch

Use PRIx64 and explicitly cast to uint64_t to print a DMA address.
This fixes a problem that if_wm.c can't compile with WM_DEBUG on
non-64bit platforms.
[msaitoh, ticket #823]
 1.227.2.6 14-Feb-2013  jdc Pull up revisions:
src/sys/dev/pci/if_wm.c revision 1.243
src/sys/dev/pci/if_wmvar.h revision 1.14
(requested by msaitoh in ticket #820).

Use 82580(and I350) specific PHY read/write functions.
Fixes PR#47542.
 1.227.2.5 17-Dec-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #755):
sys/dev/pci/if_wm.c: revision 1.239
- 82578DC is not PCH2 but PCH. 82579V is not PCH but PCH2. This bug was
introduced in rev. 1.221. Reported by FUKAUMI Naoki.
- Fix comment.
 1.227.2.4 23-Nov-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #697):
sys/dev/pci/if_wm.c: revision 1.237
Fix a bug that PHY isn't set to low-power mode on PCH and PCH2.
 1.227.2.3 03-Sep-2012  riz branches: 1.227.2.3.2;
Pull up following revision(s) (requested by bouyer in ticket #534):
sys/dev/pci/if_wmreg.h: revision 1.48
sys/dev/pci/if_wm.c: revision 1.232
sys/dev/pci/if_wm.c: revision 1.233
sys/dev/pci/if_wm.c: revision 1.234
Make vlan and all ip/ip6 checksum offload work for the I350.
On newer devices, when using the legacy TX descriptors, vlan-related flags
that were set on the last descriptor of a packet have to be set on the
first one.
For tso/checksum offloads, a new "advanced" descriptor format has to be
used.
Change wcd_txdescs to a union defining all types of descriptors (they
are all 16-bytes wide).
Define a new tx function wm_nq_start(), which handle newer devices.
There is some code duplication with wm_start(), but adding support to
the existing wm_start() would make it a if () {} else {} maze. This also
allows to get rid of some workaround for older chips that are not needed
here.
Use wm_nq_start() instead of wm_start() for the I350 (this should probably
be for all WM_F_NEWQUEUE devices, but I have no hardware but the I350 to
test). Call ifp->if_start() instead of wm_start() where is matters.
Tested on a I350, and a i80003 (which use the old format), both with and
without vlans, with and without checksum offloads.
Enable VLAN hardware tagging on all chips that have the new queue mechanism.
Tested with 82575{EB,GB}, 82576, 82580, I350 and ICH9.
Shut up gcc about some uninitialized variables.
 1.227.2.2 09-Aug-2012  martin branches: 1.227.2.2.2;
Pull up following revision(s) (requested by msaitoh in ticket #471):
sys/dev/pci/if_wm.c: revision 1.230
sys/dev/pci/if_wm.c: revision 1.231
Add workaround for QEMU and the variants that fail on EEPROM access.
This problem was discovered a few years ago, but some variants and
cloud services still have the bug. This problem is not NetBSD's bug
but qemus's bug. For NetBSD users, existence of buggy virtual machines
s sad thing, so we add a workaroud.
Fix the check of the device type in last commit.
Reported by Thomas Klausner.
 1.227.2.1 28-Jun-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #362):
sys/dev/pci/if_wm.c 1.228
sys/dev/pci/if_wmreg.h 1.47
sys/dev/pci/if_wmvar.h 1.13
sys/dev/pci/pcidevs 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
share/man/man4/wm.4 1.22-1.25

Add support for Intel I350 Ethernet.
Update document.
 1.227.2.8.2.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by tls in ticket #1070):
sys/dev/pci/if_wm.c: revision 1.269
From dyoung@ -- bump max TX DMA size to avoid pathological condition with TSO.
 1.227.2.3.2.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by tls in ticket #1070):
sys/dev/pci/if_wm.c: revision 1.269
From dyoung@ -- bump max TX DMA size to avoid pathological condition with TSO.
 1.227.2.2.2.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.234.2.5 03-Dec-2017  jdolecek update from HEAD
 1.234.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.234.2.3 23-Jun-2013  tls resync from head
 1.234.2.2 25-Feb-2013  tls resync with head
 1.234.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.261.2.2 18-May-2014  rmind sync with head
 1.261.2.1 28-Aug-2013  rmind sync with head
 1.268.2.2 10-Aug-2014  tls Rebase.
 1.268.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.289.2.18 28-Nov-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1656):

sys/dev/pci/if_wm.c: revision 1.599

- Fix a bug that i82578 PHY can't detect correctly.
- Print PHY OUI and model number if a PHY's can't be identified.

XXX pullup-[78]
 1.289.2.17 09-Nov-2018  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1648):
sys/dev/mii/inbmphyreg.h 1.11
sys/dev/pci/if_wm.c 1.586-1.588, 1.590-1.596 via patch
sys/dev/pci/if_wmreg.h 1.108

- rename tu event counter to txunderrun.
- Try m_defrag() to reduce the number of DMA segment if bus_dmamap_load_mbuf()
returned EFBIG. When m_defrag() is called, txqNNdefrag event counter is
incremented. If the 2nd try of bus_dmamap_load_mbuf() failed, txqNNtoomanyseg
event counter is incremented.
- Reduce the max number of DMA segments from 256 to 64 (it's the same value
as other BSD's (EM_MAX_SCATTER) and more than before if_wm.c rev. 1.75's
value (40)) because we do m_defrag() now.
- 82574 and newer document says the status field has neither EC
(Excessive Collision) bit nor LC (Late Collision) bit (reserved), so
don't check the bit.
- Add workaround for DMA hang problem which result in TX device timeout
on PCH_LPT with I218. Same as FreeBSD and Linux. This workaround is
only for device ID 0x155a, 0x15a2, 0x1559 and 0x15a3.
- Fix a PCH2 specific bug that wrong PHY register value can be read
when boot. Same as FreeBSD and Linux.
- After writing MDIC register, don't read quickly the same register but
do delay(50). Same as other OSes.
- Add missing wm_gate_hw_phy_config_ich8lan(false) in
wm_phy_post_reset() on PCH2. wm_gate_hw_phy_config_ich8lan(true) is
called in wm_reset(), so wm_gate_hw_phy_config_ich8lan(false) should
be called after reset in wm_phy_post_reset().
- On PCH2, set the phy config counter to 50msec after (PHY) reset.
- KNF & Use macro.
 1.289.2.16 30-Oct-2018  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1647):
sys/dev/pci/if_wm.c: revision 1.589

Fix KASSERT to prevent panic on CNP (Intel 300 series + I219) with INTx
interrupt (Xen dom0 or pre netbsd-8)
 1.289.2.15 11-Aug-2018  martin Pull up the following, requested by msaitoh in ticket #1628:

share/man/man4/wm.4 1.40 via patch
sys/dev/mii/ihphyreg.h 1.2
sys/dev/mii/inbmphyreg.h 1.10
sys/dev/pci/if_wm.c 1.504, 1.506, 1.510-1.535, 1.539-1.540, 1.546, 1.548, 1.551-1.552, 1.558, 1.565-1.573, 1.575, 1.579, 1.582, 1.584 via patch
sys/dev/pci/if_wmreg.h 1.99-1.103, 1.106-1.107 via patch
sys/dev/pci/if_wmvar.h 1.34-1.39 via patch
sys/dev/pci/pcidevs 1.1327 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/pci/pcireg.h patch

Sync wm(4) up to 2018/08/08 except MSI/MSI-X and NET_MPSAFE:
- remove extra "+"
- Fix a bug that non-GMII devices don't send a routing message when
the link status is changed.
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset(). Same as
other OSes.
- If a interrupt is a spurious interrupt, don't print debug message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Print sc_flags with snprintb().
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Add CSR_WRITE_FLUSH() after writing WMREG_CTRL in
wm_gmii_mediachange().
- Add missing "else" in wm_nvm_release().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for wrokaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if
it's required.
- If TX is not required to flush, RX is also not required to flush
in wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset(). Some
flags and callback function are required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Use new nvm.{acquire,release}() for semaphore.
- Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required
for these functions to use the same API. So,
- Change return value as error code.
- Change register value from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally on I21[01]". PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
sc->sc_nvm_wordsize before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Print NVM offset and word count when EERD polling failed.
- On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
- 82583 supports jumbo frame. Fixes PR#52773 reported by
Shinichi Doyashiki.
- Fix typo in comment. Reported by Shinichi Doyashiki in PR#52885.
- Add ASPM workaround for 8257[1234] and 82583 to prevent device
timeout or hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
- CID-1427779: Fix uninitialized variables.
- Fix a bug that wm_pll_workaround_i210() is not called when
a) Chip is I211 or b) Chip is I210 and it uses iNVM (not FLASH).
- Do wm_reset_mdicnfg_82580() on 82580 only.
- Fix FLASH access on PCH_SPT and newer. Their FLASH access should be
done by 32bit. Especially for ICH_FLASH_HSFCTL register, it's located
at 0x0006, so it must be accessed via ICH_FLASH_HSFSTS(0x0004) and
use shift or mask.
- Make wm_nvm_valid_bank_detect_ich8lan() the same as other OSes.
- If the extended configuration size in the EXTCNFSIZE register is 0,
don't continue in wm_init_lcd_from_nvm().
- Add PCH_CNP support (I219 with Intel 300 series chipset).
- Enable I219 support.
- I354 uses an external PHY, so don't use wm_set_eee_i350().
- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber.
- Fix a bug that 82542 misunderstand fiber's signal detection.
- Add debug printf()s.
- Update comment.
- Rename functions and variables.
- Add diagnostic code.
- Sort registers.
- Lowercase hexadecimal values.
- KNF.
 1.289.2.14 19-Apr-2017  snj Pull up following revision(s) (requested by kardel in ticket #1385):
sys/dev/pci/if_wm.c: revision 1.497
PR kern/52039: use same safeguard as for the 82578
 1.289.2.13 09-Mar-2017  snj branches: 1.289.2.13.2;
Pull up following revision(s) (requested by msaitoh in ticket #1372):
sys/dev/pci/if_wm.c: revisions 1.462, 1.464-1.465 1.474 via patch
sys/dev/pci/if_wmreg.h: revision 1.97
sys/dev/pci/if_wmvar.h: revision 1.33
- Set IPV6EXDIS bit in RFCTL register because of an Errata on 82575 and
newer devices.
- Linux and FreeBSD defines 0x10f5 as E1000_DEV_ID_ICH9_IGP_M_AMT. In
reality, This is not IGP but BM. Add new case to identify PHY type
device. Fixes PR#51924 reported byJarle Greipsland.
- Use new wm_gmii_setup_phytype() function to setup sc_phytype and
mii_{read|write}reg. This change improves detection of PHY type.
- Fix typo in comment.
 1.289.2.12 18-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1327):
sys/dev/pci/if_wm.c: revision 1.457
sys/dev/pci/if_wmreg.h: revision 1.94
- Change to use 2500Base-KX correctly on C2000(I354). It worked, but the
output of ifconfig and if_baudrate was not good. Tested by nils@:
- The STATUS_TBIMODE bit in the STATUS register is deleted since 82575,
so check for 82575 and newer first and then check for old devices.
- Check the 2P5_SKU and 2P5_SKU_OVER bit for KX.
- Set IFM_2500_SX instead of IFM_1000_SX for 2.5G.
- Check SERDES's speed directly from the PCS layer (PCS_LSTS register) for old
devices.
- Style fix.
 1.289.2.11 12-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1302):
sys/dev/mii/igphyreg.h: revisions 1.7-1.10
sys/dev/mii/ikphyreg.h: revisions 1.3
sys/dev/mii/inbmphyreg.h: revisions 1.4-1.9
sys/dev/mii/mii.h: revisions 1.19-1.20
sys/dev/pci/if_wm.c: revisions 1.390, 1.392-1.395, 1.397, 1.419-1.425, 1.427-1.428, 1.430-1.435, 1.437-1.453 via patch
sys/dev/pci/if_wmreg.: revisions 1.89-1.93 via patch
sys/dev/pci/if_wmvar.h: revisions 1.31-1.32
Update wm(4) up to if_wm.c rev. 1.453 except MSI/MSI-X, multiqueue and
NET_MPSAFE:
- Add I219 support. It's not stable so it's disabled by default.
- wm_gate_hw_phy_config_ich8lan() is for younger than PCH2.
- Drop the host wakeup bit after resetting PHY on PCH and newer
devices.
- Increase delay while toggling LANPHYPC
- Move call of wm_reset() in wm_attach() after setting PHY and NVM
related flags because those flags are used in wm_reset().
- Use mutex for NVM access on ICH8 and newer devices. Same as FreeBSD.
- Rewrite PHY related lock stuff. Almost the same as FreeBSD.
This change will fix a bug that PHY read/write fail on some cases.
- Increase delay in wm_phy_resetisblocked(). Same as FreeBSD.
- Use semaphore in wm_hv_phy_workaround_ich8lan() and
wm_k1_gig_workaround_hv()
- Use wm_gii_mdic_readreg/writereg() in wm_access_phy_wakeup_reg_bm()
because these functions are called with taking lock.
- 82567V_3 is BME1000_E_2(bm). Tested with Advantech AIMB-212 1st
Ethernet port.
- Use wm_gmii_82544_{read,write}reg() on non-82567 ICH8, 9 and 10.
- Remove an 82578 workaround which was for PCH rev < 3. FreeBSD
removed this workaround in r228386.
- Add an 82578 workaround which is for PHY rev < 2. From FreeBSD and
Linux.
- Fix wm(4) input drop packet counter. WMREG_RNBC is incremented when
there is no available buffers in host memory. However, ethernet
controller can receive packets in such case if there is space in
phy's FIFO. That is, ethernet controller drops packet only if there
is no available buffers *and* there is no space in phy's FIFO. So,
the number of dropped packets should be added WMREG_MPC only.
- Use MII_ADDRMASK.
- Define WMPHY_I217, WMPHY_VF and WMPHY_210.
- Use BME1000_PHY_PAGE_SELECT in wm_gmii_bm_{read,write}reg(). This
change has no effect because GG82563_PHY_PAGE_SELECT and
BME1000_PHY_PAGE_SELECT have the same value.
- Fix PHY access on 82567(ICH8 or ICH10), 82574 and 82583:
- Use wm_gmii_bm_{read,write}reg() on 82574 and 82573.
- Issue page select correctly on BM PHYs.
- Fix workaround which did dummy read BM_WUC register. This code was
changed to drop BM_WUC_HOST_WU_BIT of BM_PROT_GEN_CFG register in
FreeBSD r228386. The code was added rev. 1.149, but the location was
not the best.
- wm_gmii_hv_{read/write}reg*(): USE PHY address 1 for some special
registers.
- Add check code for an 82578 workaround. Not completed yet.
- wm_release_hw_control(): Remove extra line. No any effect.
- Add "10/100" into non-gigabit devices' name.
- Call wm_enable_wakeup() in wm_detach() and wm_suspend(). Now wake on
lan works on Thinkpad X61(ICH8).
- Fix wm_access_phy_wakeup_reg_bm(). This change has no effect because
this function is used for WUC register and our driver currenlty
doesn't access to it.
- Call wm_enable_phy_wakeup() on PCH2 and newer, too. Now these devices
can do WOL. Tested with Thinkpad X220(PCH2).
- Set CTRL_MEHE correctly (PCH_{LPT,SPT} only).
- Add three workarounds for PCH_{LPT,SPT}.
- Fix a bug that 8257[56], 82580, I35[04] and I21[01] didn't use
wm_{get,release}_hw_control() correctly.
- Sync wm_smbustopci() with Linux and FreeBSD. This change effects PCH
and newer devices.
- Move the location of wm_smbustopci() call.
- Fix flag check in wm_get_wakeup()
- 8254[17]* and 8257[124] should not set WM_F_ARC_SUBSYS_VALID.
- Add missing WM_T_82541_2 and WM_T_82547_2.
- Fix WOL related setting of the WUC register for other than PCH* in
wm_enable_wakeup(). Tested with 82567V(ICH8) and 82583V.
- Use common MII_ADDRMASK.
- igphy(4): No binary change:
- s/IGPPHY/IGPHY/
- Fix the definition of PLHR_VALID_CHANNEL_*
- Fix the definition of MSE_CHANNEL_*
- Add MII_IGPHY_POWER_MGMT.
- Add some KASSERT.
- Add comment. Modify comment.
- Add debug code.
 1.289.2.10 09-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1300):
sys/dev/pci/pcidevs: revision 1.1270
sys/dev/pci/if_wm.c: revision 1.426
i82567V-3 is not ICH9 but ICH8.
--
82567V-3 is not ICH9 but ICH8.
 1.289.2.9 26-Feb-2016  snj branches: 1.289.2.9.2;
Pull up following revision(s) (requested by msaitoh in ticket #1102):
sys/dev/mii/igphy.c: 1.25
sys/dev/mii/ukphy.c: 1.48
sys/dev/pci/if_wm.c: revisions 1.308, 1.318, 1.320, 1.324-1.332, 1.334, 1.336, 1.343-1.344, 1.347-1.348, 1.350, 1.376-1.382, 1.386-1.389 via patch
sys/dev/pci/if_wmreg.h: revisions 1.68-1.70, 1.73-1.77, 1.79-1.80, 1.82, 1.86-1.88 via patch
sys/dev/pci/if_wmvar.h: revisions 1.22-1.23, 1.25-1.30 via patch
Sync wm(4) as of if_wm.c rev 1.389 except MSI/MSI-X, multiqueue and NET_MPSAFE:
- Add C2000 KX and 2.5G support.
- Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is more than
4096. Almost the same as other OSes.
- For 82576 and newer devices, the PBA register is deleted. Don't write PBA
for those chips. Also change the calculation of RX packet buffer size in
new way.
- Fix a lot of bugs to make 82575 and newer SERDES based systems work.
- Print NVM image version and option ROM version.
- Add workaround for I210 Errata 25 and I211 Errata 10 (PLL bug). This
workaround is required if the NVM image version < 3.25.
- Fix a bug that wm_detach() didn't unmap the FHASH's area. Now
"drvct -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
- Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX packets"
and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit. The NVM Image
version 2.1.4 and newer have this workaround.
- Check PHY type correctly. This change is required to use igphy(4) device
correctly.
- Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH* too.
- Call wm_get_hw_control() correctly. This change fixes a bug that some AMT
based systems doesn't linkup at 1000BaseT. The problem was observed on HP
Compaq dc7700. A lot of fixes have been done for wm(4) and igphy(4), so now
PR#44893 should be fixed.
- Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT. It's required to
check the existence of AMT correctly.
- Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in
wm_reset() on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix the
behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change might fix
a problem that PHY's read/write functions can't get semaphore.
- On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS sets
this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the function
checks the status correctly but it causes linkdown up to 10 times, so it's
disabled for the time being.
- PR/50527: David Binderman: Fix impossible code. Odd offsets need special
treatment.
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Use sc->sc_itr instead of hard-coded number.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function acts as
mii_tick().
- ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition has not used yet.
- Add ACK data Disable bit's definition (not used yet).
- PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any effect by
default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when WM_WOL is
defined and it's disabled by default.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
- Reorder function definitions and macro definitions. No functional change.
- Fix comment. Add comment. Update comment.
- KNF.
 1.289.2.8 10-Jun-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #833):
sys/dev/pci/if_wm.c: revisions 1.322, 1.323
sys/dev/pci/if_wmreg.h: revision 1.72
- Currently, WM_F_EEE bit is not set on all chips. It's intened to not
to use all of EEE fuctions but wm_set_eee_i350() leaves IPCNFG_10BASE_TE
bit and it causes link negotiation problem on some old switches. Disable
10BASE-Te function, too.
- Call wm_set_eee_i350() on some chips, too.
--
Fix a bug that flags related to semaphore were incorrectly checked in
wm_kmrn_{readreg,writereg}. i80003, ICH* and PCH* had this problem.
 1.289.2.7 19-May-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #784):
sys/dev/pci/if_wm.c: revision 1.321
sys/dev/pci/if_wmreg.h: revision 1.71
sys/dev/pci/if_wmvar.h: 1.24 via patch
Add support iNVM (integrated Non-Volatile Memory) for I21[01].
This change fixes a bug that a MAC address is wrongly set on
iNVM machines/NICs.
 1.289.2.6 19-Apr-2015  riz Pull up following revision(s) (requested by msaitoh in ticket #698):
sys/dev/pci/if_wm.c: revision 1.316
Fix a bug that newer revision of I218-{LM,V} use wrong PHY access functions.
The problem only occured on devices that the PCI device ID was 0x15a[0123].
 1.289.2.5 16-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #694):
sys/dev/pci/if_wm.c: revision 1.314
Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.
 1.289.2.4 18-Mar-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #614):
sys/dev/pci/if_wm.c: revision 1.311-1.313
sys/dev/pci/if_wmreg.h: revision 1.66
Fix a bug that sc_mediatype is evaluated incorrectly. The real problem
might be occured only on fiber and serdes cases.
#####
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Add comment.
- Fix typo in comment.
#####
Fix a bug that the first access to NVM is failed on 8254[17] which use
SPI EEPROM. Observed on Dell PowerEdge [12]850. Thanks Tom Ivar Helbekkmo
for debugging.
 1.289.2.3 04-Feb-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #490):
sys/dev/pci/if_wm.c: revision 1.310
Fix a bug that a workaround for SWSM.SMBI bit doesn't work correctly.
This problem was only occured with old boot ROM on 8257[12].
 1.289.2.2 07-Nov-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #190):
sys/dev/pci/pcidevs 1.1201-1.1202 via patch
sys/dev/pci/if_wm.c 1.291-1.301, 1.304, 1.306-1.307 via patch
sys/dev/pci/if_wmreg.h 1.61-1.65 via patch
sys/dev/pci/if_wmvar.h 1.21 via patch
share/man/man4/wm.4 1.31 via patch
- Add Internal SERDES mode support newer than or equal to 82575.
- Add new I218 devices.
- Add DH89xxCC device.
- Add some old devices.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Don't print "failed to detect NVM bank" message.
- Delete 82580ER related code.
- Fix typo in comment.
- Fix debug message.
- Cleanup
 1.289.2.1 29-Aug-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #61):
sys/dev/pci/if_wm.c: revision 1.290
sys/dev/pci/if_wmvar.h: revision 1.20
Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
 1.289.2.13.2.1 06-Nov-2017  snj Pull up following revision(s) (requested by kardel in ticket #1385):
sys/dev/pci/if_wm.c: revision 1.497
PR kern/52039: use same safeguard as for the 82578
 1.289.2.9.2.2 13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.289.2.9.2.1 18-Jan-2017  skrll Sync with netbsd-5
 1.308.2.11 28-Aug-2017  skrll Sync with HEAD
 1.308.2.10 05-Feb-2017  skrll Sync with HEAD
 1.308.2.9 05-Dec-2016  skrll Sync with HEAD
 1.308.2.8 05-Oct-2016  skrll Sync with HEAD
 1.308.2.7 09-Jul-2016  skrll Sync with HEAD
 1.308.2.6 29-May-2016  skrll Sync with HEAD
 1.308.2.5 19-Mar-2016  skrll Sync with HEAD
 1.308.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.308.2.3 22-Sep-2015  skrll Sync with HEAD
 1.308.2.2 06-Jun-2015  skrll Sync with HEAD
 1.308.2.1 06-Apr-2015  skrll Sync with HEAD
 1.416.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.416.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.416.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.416.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.465.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.508.4.55 29-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1938:

sys/dev/pci/if_wm.c 1.792,1.794-1.798 via patch
sys/dev/pci/if_wmreg.h 1.131

- Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.
- Drop frames if the RX descriptor ring has no room on multiqueue system.
- Improve dmesg output.
- Print RX packet buffer size.
- Fix the upper 16bit of Image Unique ID(EtrackID).
- Fix comment.
 1.508.4.54 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #1932):

sys/dev/pci/if_wm.c: revision 1.793

Add Intel I219-{LM,V}(20,21) support.
 1.508.4.53 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1915:

sys/dev/pci/pcidevs 1.1497
sys/dev/pci/if_wm.c 1.689,1.790-1.791 via patch
sys/dev/pci/if_wmreg.h 1.120 via patch
sys/dev/pci/if_wmvar.h 1.51

- Use 12K for packet buffer for jumbo frame on PCH2 and newer.
- Add new workaround for Tiger Lake and newer to avoid packet loss.
- Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.508.4.52 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1910):

sys/dev/pci/if_wm.c: revision 1.785
sys/dev/pci/if_wm.c: revision 1.786
sys/dev/pci/if_wm.c: revision 1.787
sys/dev/pci/if_wm.c: revision 1.788
sys/dev/pci/if_wm.c: revision 1.789

wm(4): Use SCVPC and HRMPC for 82575 and newer.
The SCVPC(SerDes/SGMII Code Violation Packet Count) register and the HRMPC
(Header Redirection Missed Packet Count) register were added in if_wm.c
rev. 1.776 but the location in the code were incorrect. Fix them.

wm(4): Add some info to some event counters.
- The difference between the RUC(Rx Undersize) and RFC(Rx Fragment) is whether
the CRC is valid or not.
- The difference between the ROC(Rx Oversize) and RJC(Rx Jabber) is whether
the CRC is valid or not.
- LENERRS(Length Errors) is for the length/type field <= 1500.

wm(4): the IAC(Interrupt Assertion Count) register is for 82571 and newer.

wm(4): Modify descriptions of flow control related event counters.

wm(4): Replace /* nothing */ to __nothing for evcnt macros
Prevent empty if bodies for !WM_EVENT_COUNTERS.
 1.508.4.51 04-Sep-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1894):

sys/dev/pci/if_wmvar.h: revision 1.50
sys/dev/pci/if_wm.c: revision 1.783,1.784 via patch

Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.

Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.508.4.50 27-Jun-2023  martin Pull up the following revisions, requested by msaitoh in #1847:

sys/dev/pci/if_wm.c 1.768-1.782 via patch
sys/dev/pci/if_wmreg.h 1.129-1.130
sys/dev/pci/if_wmvar.h 1.49

wm(4):
- Rework for event counters:
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Rearrange the order of the registers so that they are roughly
in ascending order.
- Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach()
to match.
- IC{TX,RX}*C registers are for older than 82575.
- Fix a bug that the transmit underrun counter is incorrectly
counted.
- Don't add "Count" for event counter's description.
- Some statistics registers were replaced with new counters on newer
chips. Treat 0x403c(CEXTERR->HTDPMC), 0x40fc(TSCTFC->CBRMPC),
0x4124(ICRXOC->HTCBDPC) and from 0x4104 to 0x4124.
- Add some new counters:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- Host Good Octets RX
- Host Good Octets TX
- Length Errors
- SerDes/SGMII Code Violation Packet
- Header Redirection Missed Packet
- EEE TX LPI
- EEE RX LPI
- Fix prc511's comment and description.
- Add SOICZIFDATA (ifconfig -z) support for evcnt(9).
- Use WM_IS_ICHPCH(). No functional change.
- Fix typo. s/ictxact/ictxatc/. No functional change.
- Add comment.
 1.508.4.49 21-Jun-2023  martin Apply patch, requested by riastradh in ticket #1842:

sys/dev/pci/if_wm.c (apply patch)

Fix a bug introduced in ticket #1795.
 1.508.4.48 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1795:

sys/dev/pci/if_wm.c 1.764-1.767 via patch
sys/dev/pci/if_wmreg.h 1.128

- Workaround for some hypervisor environments. The environments
cannot stop e1000 interrupt immediately.
- Rename nq_txdesc' member "nqrx_ctx" to "nqtx_ctx". No functional
change.
- Add comment. Modify comment.
- KNF.
 1.508.4.47 08-Sep-2022  martin Undo accidental whitespace changes from applying the patch for
ticket #1759 by applying a patch from msaitoh (NFC).
 1.508.4.46 07-Sep-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1759:

sys/dev/pci/if_wm.c 1.741-1.749,1.753-1.757,
1.762 via patch
sys/dev/pci/if_wmreg.h 1.126-1.127

- Fix I219 workaround in wm_flush_desc_rings().
- Add more statistics counters.
- To avoid releasing mutex temporally, use new
wm_set_mdio_slow_mode_hv_locked().
- No functional changes:
- Turn a locking botch (shouldn't drop lock on error) into a KASSERT
in wm_deferred_start_locked().
- Remove unneeded header inclusion.
- Use __BIT() a little.
- Modify comment and debug messages.
- Consistency use -1 instead of 1 for some error code.
- KNF.
 1.508.4.45 11-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1751:

sys/dev/pci/if_wmreg.h 1.122-1.125 via patch
sys/dev/pci/if_wmvar.h 1.48
sys/dev/pci/if_wm.c 1.719-1.720,1.722-1.725,
1.727-1.740 via patch

- wm_tick: Add missing splx(s) when not WM_MPSAFE.
- Print DMA range info if the system is booting in the verbose mode.
- Micro optimization:
- Call m_freem(m) only if m0 == NULL.
- Call wm_xxeof() only when limit > 0.
- Don't set the more flag when there is no packet to process.
- No functional changes:
- Call txeof first, then rxeof for the consistency.
- Remove duplicated break.
- Remove stray semicolons from struct declaration.
- Fix value return from void function.
- Use macros.
- Modify comment.
- KNF.
 1.508.4.44 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1707:

sys/dev/pci/if_wm.c 1.716-1.718 via patch
sys/dev/pci/if_wmreg.h 1.121
sys/dev/mii/ihphy.c 1.20

- Fix a bug that device timeout still happens when the link is down
on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.
 1.508.4.43 23-Oct-2021  martin Pull up the following, requested by msaitoh in ticket #1701:

share/man/man4/wm.4 1.42
sys/dev/pci/files.pci 1.434
sys/dev/pci/if_wm.c 1.686-1.687,1.692-1.693,
1.697,1.699-1.703,
1.706-1.715 via patch
sys/dev/pci/if_wmvar.h 1.46

- Add missing drain for pcq in wm_stop_locked().
- Add support for I219V 15-19 and I219LM 16-19.
- Fix Tx stall.
- Use wm_flush_desc_rings() workaround more on I219.
- Change DMA physical address in wm_flush_desc_rings() to match other
OSes.
- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Add new sysctl hw.wmN.debug_flags. This sysctl can be used if
WM_DEBUG is set.
- Add some sysctl values for debugging TX/RX queues.
- WM_EVENT_COUNTER is enabled by default on 64 bit architectures.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxq->rxq_ptr updating.
- Stop legacy interrupts before calling softint.
- Disable printf()s in wm_flush_desc_rings() because the code is
verified.
- Print I219's version number.
- Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.
- Fix return value of interrupt handler.
- Only print an error about missing I/O BARs for chips that need it.
- Do not return a void value from a void function.
- Add new flag named WM_F_CRC_STRIP and use it. No functional change.
- Whitespace fixes. Fix comments. No functional change.
 1.508.4.42 16-Nov-2020  martin Pull up following revision(s) (requested by rin in ticket #1623):

sys/dev/pci/if_wm.c: revision 1.696

Fix little-endian dependence in wm_rxeof(), by which packets cannot be
received by 82574 and successors on big-endian machines.

Tested by aarch64eb with I210-T1 on ROCKPro64.

Thanks msaitoh for discussion!
XXX
pullup to netbsd-9 and netbsd-8
 1.508.4.41 04-Nov-2020  martin Pull up following revision(s) (requested by knakahara in ticket #1620):

sys/dev/pci/if_wm.c: revision 1.694
sys/dev/pci/if_wm.c: revision 1.695 (via patch)
sys/dev/pci/if_wmvar.h: revision 1.47

Add WMPHY_I350. Not used yet.

Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).
These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981
Reviewed and tested by msaitoh@n.o, thanks.
XXX pullup-[89]
 1.508.4.40 16-Oct-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1617):

sys/dev/pci/if_wm.c: revision 1.691

Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=000000, model=0000" and
"PHY type is still unknown." Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).
 1.508.4.39 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1594:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660,
1.662, 1.664-1.668,
1.671-1.674, 1.678,
1.680-1.685 via patch
sys/dev/pci/if_wmreg.c 1.118-1.119 via patch
sys/dev/pci/if_wmvar.c 1.45 via patch
sys/dev/mii/igphy.c 1.35-1.36 via patch
sys/dev/mii/igphyreg.h 1.12-1.13
sys/dev/mii/makphy.c 1.66 via patch
sys/dev/mii/makphyreg.h 1.11

- Add SFP support. Module insertion/removal is not supported yet.
Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler).
Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0 which use softint
as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
fragmented UDP, first packet and second packet should be processed
in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
in case it's already set.
- Actually writing always the checksum offload context descriptor
makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Explicitly cast from uint16_t to uint32_t before shifting 16bit left
when printing Image Unique ID to avoid undefined behavior.
- Set if_baudrate for non-MII device.
- Rename some macros and function.
- KNF. Add comment.
 1.508.4.38 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1492:

sys/dev/pci/if_wm.c 1.650, 1.652-1.654 via patch
sys/dev/pci/if_wmreg.h 1.116-1.117

- Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580
port 1, 2, 3 and newer chips. This change fixes a bug that some
fiber, serdes or SFP devices don't detect the link status correctly.
- Simplify code by using "struct mii_data *mii" more. No functional
change.
- MSI-X doesn't use sc->sc_icr variable, so move the code into
non-MSI-X part. No functional change intended.
- Modify debug printfs a bit.
- Rename macro.
- Use __BIT()
- Fix comment. Add comment.
- KNF.
 1.508.4.37 23-Jan-2020  martin Pull up following revision(s) (requested by knakahara in ticket #1488):

sys/dev/pci/if_wm.c: revision 1.661

fix softint_disestablish() in wm_detach().

ok by msaitoh@n.o
XXX pullup-8, pullup-9
 1.508.4.36 06-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1428:

sys/dev/pci/if_wm.c 1.647, 1.649 via patch

- Use device_printf() instead of printf().
- Fix typo in comment.
 1.508.4.35 04-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1317):

sys/dev/pci/if_wm.c: revision 1.646
sys/dev/pci/if_wm.c: revision 1.612

Accept IFM_NONE.

-

Use unsigned to avoid undefined behavior in wm_i82543_mii_sendbits().
Found by kUBSan.
 1.508.4.34 01-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1312):

sys/dev/pci/if_wm.c: revision 1.644
sys/dev/pci/if_wm.c: revision 1.645
sys/dev/pci/if_wmreg.h: revision 1.115

Define RETA_ENTRY_MASK_Q(used in RSS redirection table) correctly.
Found by UBSan.

Use aprint_debug_dev() instead of printf() in wm_ulp_disable().

- rnd_add_*() call must be serialized. Unserialized accesses broke the
sc->rnd_source structure and caused off by one in kern_rndq.c's
rnd_add_data_ts(). This problem was found by kUBSan. Make krndsource_t's
data per queue-pair and call rnd_add_uint32() in wm_txrxintr_msix(). One of
the reason why rnd_add_uint32() calls were moved from wm_{tx,rx}eof() is that
rnd(9) manual page says "To allow the system to gather the timing information
accurately, this call should be placed within the actual hardware interrupt
service routine."

- Pass a better value to rnd_add_uint32() in wm_intr_legacy().
XXX pullup-8.
 1.508.4.33 17-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1298:

sys/dev/pci/if_wm.c 1.633, 1.637-1.641
sys/dev/pci/if_wmreg.h 1.114

- Use unsigned to avoid undefined behavior.
- Print ICH/PCH's NVM version.
- Fix typo in comment. u_int*_t -> uint*_t. Whitespace fix.
 1.508.4.32 14-May-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1267):

sys/arch/arm/imx/if_enet.c: revision 1.19
sys/dev/pci/if_wm.c: revision 1.634

SIOCS is 'S'et function and the ioctl argument is ifreq.
SIOCG is 'G'et function and the ioctl armument is ifmediareq.

Before this change, SIOCG modify sc->sc_flowflags unexpectedly.


Don't hook SIOCGIFMEDIA becauise this driver uses MII(4) and ether_ioctl has
the hook(if_ethersubr.c rev. 1.160).
real bug because the modification is overriden in ifmedia_ioctl().

This driver might require some additional fixes for SIOCSIFMTU and other
ioctl()s.
XXX pullup-[78].
 1.508.4.31 07-Mar-2019  martin Pull up the following, requested by msaitoh in ticket #1206:

sys/dev/pci/if_wmreg.h 1.113
sys/dev/pci/if_wmvar.h 1.43-1.44
sys/dev/pci/if_wm.c 1.626-1.627, 1.629-1.636 via patch

- Add support for I210 SGMII Flash-less device.
- Add I219 variations for Cannon Lake.
- Add missing rnd_detach_source().
- Use do { ... } while (0) for DPRINTF(x, y).
- Swap enumeration of 82578 and 82577 PHY in if_wmvar.h. No functional
change.
- Add KASSERT.
- Update TODO list. Add comment. Fix typo in comment.
 1.508.4.30 11-Feb-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1189):

sys/dev/pci/if_wm.c: revision 1.622
sys/dev/pci/if_wm.c: revision 1.624
sys/dev/pci/if_wm.c: revision 1.625

We now have IFM_2500_KX and IFM_1000_KX, so use them.

-

I21[01]'s RAL size is not 15 but 16(== 82575's value). Same as other OSes.

-

Fix a bug that WOL didn't work on some chips since if_wm.c rev. 1.610.

Set WUC_APME bit older than PCH. Will fixes PR kern/53945 reported by kardel@.
Tested with my own 82574 card.
 1.508.4.29 31-Jan-2019  martin Pull up the following, requested by msaitoh in ticket #1179:

sys/dev/pci/if_wm.c 1.603-1.605,1.607-1.611,
1.613,1.615,1.618-1.620
via patch
sys/dev/pci/if_wmreg.h 1.110-1.111
sys/dev/pci/if_wmvar.h 1.40-1.42
sys/dev/mii/inbmphyreg.h 1.13-1.15

- Add some code for suspend/resume:
- Rename wm_smbustopci() to wm_init_phy_workarounds_pchlan(). It will
also called when resume.
- Call wm_phy_resetisblocked() after PHY reset in
wm_init_phy_workarounds_pchlan() to wait for the PHY to quiesce to
an accessible state.
- Add new wm_resume_workarounds_pchlan() function and use it in
wm_resume(). This workaround is only for PCH2 and newer.
- Don't call wm_disable_aspm() neither in wm_attach() nor in
wm_resume() but in wm_reset().
- Do some initialization in wm_resume() when IFF_UP is NOT set.
- Don't continue when it failed to acquire semaphore in
wm_ulp_disable().
- Print CLSEM workaround bit correctly.
- Fix availability detection of WoL on some chips.
- Print the WUS (WakeUp Status) register bits when resume.
- Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
- Remove an extra register read in
wm_kmrn_lock_loss_workaround_ich8lan().
- Don't leave the MDICNFG register modified when the Power Management
capability offset can't get.
- Reduce indent level of wm_linkintr_gmii(). No functional change.
- 80003's SERDES is not the same as 82575's but the same as legacy
devices. Use the old methods on 80003.
- Use __nothing for null DPRINTF().
- Rename functions. Add comment.
 1.508.4.28 18-Dec-2018  martin Pull up following revision(s) (requested by knakahara in ticket #1138):

sys/dev/pci/if_wm.c: revision 1.606

Fix txqueue assignment. Pointed out by yamaguchi@n.o, thanks.

E.g. When ncpu is six and nqueue is four, the sequence error occurs.

XXX pullup-8
 1.508.4.27 04-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1117):

sys/dev/pci/if_wmreg.h: revision 1.109
sys/dev/pci/if_wm.c: revision 1.597
sys/dev/pci/if_wm.c: revision 1.598
sys/dev/mii/inbmphyreg.h: revision 1.12
sys/dev/pci/if_wm.c: revision 1.600
sys/dev/pci/if_wm.c: revision 1.601
sys/dev/pci/if_wm.c: revision 1.602

- Add new wm_gmii_{hv,i82544}_{read,write}reg_locked() and use them in
wm_gmii_{hv,i82544}_{read,write}reg(). *_locked() functions are not
mii(4) API functions, so it's not required to keep the mii API. Change
the PHY register type from int to uint16_t. It also change the usage of
return value. It returns zero on success and non-zero on error.
- Check the return value of *_locked() function and treat it.
- Use *writereg_locked() function to reduce race condition in
wm_init_lcd_from_nvm().
- Add comment.
- Control TX/RX descriptor snooping control bits on ICH8 and newer.
Only on ICH8, No-snoop bits are opposite polarity. On my Thinkpad X61,
the default value of this bits are all zero, so this commit changes
the snoop function enable on the machine. I tested with some other
PCH machines and those bits are all zero (enable snoop by default),
so this commit won't affect to some machines.
- Disable relax ordering on 82546GB(Device ID 0x1099 and 0x10b5) or >= ICH8.
Same as other OSes.
- Add wm_oem_bits_config_ich8lan() to control LPLU and GbE setting base on
the NVM's info.
- Modify wm_enable_wakeup() to reduce difference against FreeBSD and Linux.
This modification affects to ICH8 and newer devices. I217 Rapid Start
Technology support have not written yet (it's TODO).
- Add wm_k1_workaround_lv() from FreeBSD. It's PCH2 specific:
Workaround to set the K1 beacon duration for 82579 parts in 10Mbps.
Disable K1 for 1000 and 100 speeds.
- Make wm_link_stall_workaround_hv() and move an 82578 specific code into it.
Don't apply the workaround if BMCR_LOOP bit is set. Same as FreeBSD.
- Add comment. Modify comment.
Fix comment. No functional change.
 1.508.4.26 26-Nov-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #1108):
sys/dev/pci/if_wm.c: revision 1.599
- Fix a bug that i82578 PHY can't detect correctly.
- Print PHY OUI and model number if a PHY's can't be identified.
 1.508.4.25 08-Nov-2018  martin Pull up the following, requested by msaitoh in tickt #1085:

sys/dev/mii/inbmphyreg.h 1.11
sys/dev/pci/if_wmreg.h 1.108
sys/dev/pci/if_wm.c 1.590-1.596 via patch

- 82574 and newer document says the status field has neither EC
(Excessive Collision) bit nor LC (Late Collision) bit (reserved), so
don't check the bit.
- Add workaround for DMA hang problem which result in TX device timeout
on PCH_LPT with I218. Same as FreeBSD and Linux. This workaround is
only for device ID 0x155a, 0x15a2, 0x1559 and 0x15a3.
- Fix a PCH2 specific bug that wrong PHY register value can be read
when boot. Same as FreeBSD and Linux.
- After writing MDIC register, don't read quickly the same register but
do delay(50). Same as other OSes.
- Add missing wm_gate_hw_phy_config_ich8lan(false) in
wm_phy_post_reset() on PCH2. wm_gate_hw_phy_config_ich8lan(true) is
called in wm_reset(), so wm_gate_hw_phy_config_ich8lan(false) should
be called after reset in wm_phy_post_reset().
- On PCH2, set the phy config counter to 50msec after (PHY) reset.
- KNF & Use macro.
 1.508.4.24 30-Oct-2018  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1075):
sys/dev/pci/if_wm.c: revision 1.589

Fix KASSERT to prevent panic on CNP (Intel 300 series + I219) with INTx
interrupt (Xen dom0 or pre netbsd-8)
 1.508.4.23 23-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1027):
sys/dev/pci/if_wm.c: revision 1.586
sys/dev/pci/if_wm.c: revision 1.587
sys/dev/pci/if_wm.c: revision 1.588

- Split txdrop evcnt into pcqdrop and descdrop.
- Simplify evcnt name by removing duplicated "tx" or "rx".
- s/tu/underrun/

- Try m_defrag() to reduce the number of DMA segment if bus_dmamap_load_mbuf()
returned EFBIG. When m_defrag() is called, txqNNdefrag event counter is
incremented. If the 2nd try of bus_dmamap_load_mbuf() failed, txqNNtoomanyseg
event counter is incremented.

- Reduce the max number of DMA segments from 256 to 64 (it's the same value
as other BSD's (EM_MAX_SCATTER) and more than before if_wm.c rev. 1.75's
value (40)) because we do m_defrag() now.

Fix comment.
 1.508.4.22 11-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #969):

sys/dev/pci/if_wm.c: revision 1.584
sys/dev/pci/if_wmvar.h: revision 1.39

Add MDIC_WA and CLSEMWA to snprintb() string for WM_F_* flags.

Fix two bugs for non-SERDES fiber. Tested on 82544EI(0x1009), 82545GM(0x1027),
82546GB(0x107a), 82571GB(0x105f), 82572EI(0x107e). Tested on SERDES
82580(0x150e (Winyao SERDES SFP)) and 82580(0x150e) as regression test:

- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber. When the signal is detected & STATUS_LU == 0 & RXCW == 0,
it's required to set CTRL_SLU and CTRL_FD bit. wm_check_for_link() is the
function to do it. If a link status change interrupt occurred, call
wm_check_for_link() before checking current link status.

- Fix a bug that 82542 misunderstand fiber's signal detection. CTRL_SWDPIN(1)
is used for fiber's signal and it's value is reversed only on 82543 and
82544. Simplify the code and move it into a new function wm_tbi_havesignal()
and use it.
 1.508.4.21 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #928):
sys/dev/pci/if_wm.c: 1.573-1.576, 1.579 and 1.582 via patch
wm(4):
- Count timeout correctly. This change reduce timeout value for 80003
as expected. Reported by mouse@.
- Print "device timeout (lost interrupt)" when all descriptors in a
queue are free.
- Rename txq_watchdog to txq_sending to make the meaning clear.
- KNF. No functional change.
 1.508.4.20 07-Jun-2018  martin Pull up following revision(s) (requested by ozaki-r in ticket #843):

sys/dev/pci/ixgbe/ixv.c: revision 1.101
sys/net/if_bridge.c: revision 1.156
sys/net/if_pppoe.c: revision 1.138
sys/dev/pci/if_wm.c: revision 1.580
sys/dev/pci/ixgbe/ixgbe.c: revision 1.156
sys/net/if_gif.c: revision 1.142

Ensure to call if_register after interface initializations finish
 1.508.4.19 17-May-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #827):

sys/dev/pci/if_wm.c: revision 1.577

rxipsum and rxtusum are not interrupt counter, so use EVCNT_TYPE_MISC
instead of EVCNT_TYPE_INTR.
 1.508.4.18 09-May-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #816):

sys/dev/pci/if_wm.c: revision 1.578

Fix a bug that TX might stall because WM_TXQ_NO_SPACE is not cleared in
if_init() (though I've never seen this problem). Clear txq->txq_flags in
wm_init_tx_queue(). OK'd by knakahara.
 1.508.4.17 16-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #764):

sys/dev/pci/if_wm.c: revision 1.567
sys/dev/pci/if_wm.c: revision 1.568
sys/dev/pci/if_wm.c: revision 1.569
sys/dev/pci/if_wmvar.h: revision 1.38
sys/dev/pci/if_wm.c: revision 1.570
sys/dev/pci/if_wm.c: revision 1.571
sys/dev/pci/if_wm.c: revision 1.572
share/man/man4/wm.4: revision 1.40
sys/dev/pci/if_wmreg.h: revision 1.106
sys/dev/pci/if_wmreg.h: revision 1.107

SW PHY Config Enable bit for ICH8 B0 stepping is not bit 1 but bit 0.

No binary change:
- Sort registers.
- Lowercase hexadecimal value.

On PCH_SPT (and newer), FLASH access should be done by 32bit.
Especially for ICH_FLASH_HSFCTL register, it's located at 0x0006, so
it should be accessed via ICH_FLASH_HSFSTS(0x0004) and use shift or mask.

Our PCH_SPT part of wm_nvm_valid_bank_detect_ich8lan() was based on
FreeBSD r287467. After that, they reverted it and committed the different
code in r287762. r287762's bank detect code didn't work for us because our wm
dirver had a problem in flash access. The problem was fixed in if_wm.c rev.
1.567, so we can use the new way now.

If the extended configration size in the EXTCNFSIZE register is 0, don't
continue.
Add PCH_CNP support (I219 with Intel 300 series chipset).
It's required more test, so it's disabled by default.

Enable I219.

I354 uses an external PHY, so don't use wm_set_eee_i350().
 1.508.4.16 06-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #604):
sys/dev/pci/if_wm.c: revision 1.565-1.566

- Fix a bug that wm_pll_workaround_i210() is not called on some cases.
As I wrote in if_wm.c rev 1.329's commit message, There are three cases:
a) Chip is I211
b) Chip is I210 and it uses INVM (not FLASH)
c) Chip is I210 (it uses FLASH) and NVM image version < 3.25
Before this commit, the workaround function was not called on a) and b).

- Rename function.

Do wm_reset_mdicnfg_82580() on 82580 only.
 1.508.4.15 26-Feb-2018  snj Pull up following revision(s) (requested by knakahara in ticket #567):
distrib/sets/lists/comp/mi: 1.2182-1.2183
sys/dev/pci/if_wm.c: 1.564
sys/dev/pci/ixgbe/ixgbe.c: 1.122
sys/dev/pci/ixgbe/ixgbe_rss.h: 1.3
sys/dev/pci/ixgbe/ixv.c: 1.78
sys/net/Makefile: 1.35-1.36
sys/net/files.net: 1.15
sys/net/rss_config.c: 1.1
sys/net/rss_config.h: 1.1
Introduce very simple Receive Side Scaling (RSS) utility.
ok by msaitoh@n.o.
--
Apply RSS utility to wm(4).
ok by msaitoh@n.o.
--
Apply RSS utility to ixg(4) and ixv(4).
ok by msaitoh@n.o.
--
Fix build failure, sorry.
--
Currently, it is not necessary to install rss_config.h. Pointed out by msaitoh@n.o.
 1.508.4.14 26-Feb-2018  snj Pull up following revision(s) (requested by knakahara in ticket #564):
sys/dev/pci/if_wm.c: 1.563
Fix a bug that RX and TX may stall on heavy load on wm(4) like ixgbe.c:r1.121.
wm_rxeof() and wm_txeof() have loop limit and the function returns true
if a packet still exists.
 1.508.4.13 05-Feb-2018  martin Pull up following revision(s) (requested by knakahara in ticket #529):
sys/dev/pci/if_wm.c: revision 1.560
sys/dev/pci/if_wm.c: revision 1.561
sys/dev/pci/if_wm.c: revision 1.562
share/man/man4/wm.4: revision 1.37
share/man/man4/wm.4: revision 1.38
sys/dev/pci/if_wm.c: revision 1.551
sys/dev/pci/if_wm.c: revision 1.553
sys/dev/pci/if_wm.c: revision 1.554
sys/dev/pci/if_wm.c: revision 1.555
sys/dev/pci/if_wm.c: revision 1.556
sys/dev/pci/if_wm.c: revision 1.557
sys/dev/pci/if_wm.c: revision 1.558
sys/dev/pci/if_wm.c: revision 1.559
PR/52885 - Shinichi Doyashiki -- typo in comment
Fix legacy Tx descriptors printing when WM_DEBUG is enabled.
improve comments
Fix wm_watchdog_txq() lock region.
Not only wm_txeof() but also wm_watchdog_txq() itself requires txq_lock
as it reads Tx descriptor management variables such as "txq_free".
There is almost no influence on performance.
Fix duplicated "rxintr" evcnt counting. Pointed out by ozaki-r@n.o, thanks.
wm_txeof() can limit the loop count the same as wm_rxeof() now.
add WM_TX_PROCESS_LIMIT_DEFAULT and WM_TX_INTR_PROCESS_LIMIT_DEFAULT man.
More markup.
CID-1427779: Fix uninitialized variables
Fix 82574 MSI-X mode cannot receive packets after 82574 receives high rate traffic.
In short, 82574 MSI-X mode does not cause RXQ MSI-X vector when 82574's
phys FIFO overflows. I don't know why but 82574 causes not RXQ MSI-X vector
but OTHER MSI-X vector at the situation.
see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.15-rc9&id=4aea7a5c5e940c1723add439f4088844cd26196d
advised by msaitoh@n.o, thanks.
Fix if_wm.c:r1.557 merge miss, sorry.
Fix unmatched return type. The return value of wm_txeof() is not useded yet.
Make wm(4) watchdog MP-safe. There is almost no influence on performance.
wm(4) does not use ifp->if_watchdog now, that is, it does not touch
ifp->if_timer.
It also uses own callout(wm_tick) as watchdog now. The watchdog uses
per-queue counter to check timeout. So, global lock is not required.
 1.508.4.12 13-Jan-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #491):
sys/dev/pci/if_wm.c: 1.550, 1.552
Don't use MSI-X if we can use only one queue to save interrupt resource.
Written by knakahara and tested by me.
--
Add ASPM workaround for 8257[1234] and 82583 to prevent device timeout or
hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
 1.508.4.11 02-Jan-2018  snj Pull up following revision(s) (requested by ozaki-r in ticket #456):
sys/arch/arm/sunxi/sunxi_emac.c: 1.9
sys/dev/ic/dwc_gmac.c: 1.43-1.44
sys/dev/pci/if_iwm.c: 1.75
sys/dev/pci/if_wm.c: 1.543
sys/dev/pci/ixgbe/ixgbe.c: 1.112
sys/dev/pci/ixgbe/ixv.c: 1.74
sys/kern/sys_socket.c: 1.75
sys/net/agr/if_agr.c: 1.43
sys/net/bpf.c: 1.219
sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
sys/net/if_etherip.c: 1.40
sys/net/if_ethersubr.c: 1.243, 1.246
sys/net/if_faith.c: 1.57
sys/net/if_gif.c: 1.132
sys/net/if_l2tp.c: 1.15, 1.17
sys/net/if_loop.c: 1.98-1.101
sys/net/if_media.c: 1.35
sys/net/if_pppoe.c: 1.131-1.132
sys/net/if_spppsubr.c: 1.176-1.177
sys/net/if_tun.c: 1.142
sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
sys/net/npf/npf_ifaddr.c: 1.3
sys/net/npf/npf_os.c: 1.8-1.9
sys/net/rtsock.c: 1.230
sys/netcan/if_canloop.c: 1.3-1.5
sys/netinet/if_arp.c: 1.255
sys/netinet/igmp.c: 1.65
sys/netinet/in.c: 1.210-1.211
sys/netinet/in_pcb.c: 1.180
sys/netinet/ip_carp.c: 1.92, 1.94
sys/netinet/ip_flow.c: 1.81
sys/netinet/ip_input.c: 1.362
sys/netinet/ip_mroute.c: 1.147
sys/netinet/ip_output.c: 1.283, 1.285, 1.287
sys/netinet6/frag6.c: 1.61
sys/netinet6/in6.c: 1.251, 1.255
sys/netinet6/in6_pcb.c: 1.162
sys/netinet6/ip6_flow.c: 1.35
sys/netinet6/ip6_input.c: 1.183
sys/netinet6/ip6_output.c: 1.196
sys/netinet6/mld6.c: 1.90
sys/netinet6/nd6.c: 1.239-1.240
sys/netinet6/nd6_nbr.c: 1.139
sys/netinet6/nd6_rtr.c: 1.136
sys/netipsec/ipsec_output.c: 1.65
sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
 1.508.4.10 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #432):
sys/dev/pci/if_wm.c: revision 1.548
Fix a bug that 8257[56] can't receive packet reported by Bert Kiers in
PR#52717. For 82575 and 82576, the RX descriptors must be initialized after
the setting of RCTL.EN in wm_set_filter(). This bug was added in if_wm.c
rev. 1.515.
 1.508.4.9 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.508.4.8 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #424):
sys/dev/pci/if_wm.c: 1.545-1.546
Don't allocate MSI-X interrupt on 82583. 82583 chip has a MSI-X capability in
the PCI configuration space but it doesn't support it. At least the document
doesn't say anything about MSI-X. Fixes PR#52767 reported by
Shinichi Doyashiki.
--
- 82583 supports jumbo frame. Fixes PR#52773 reported by Shinichi Doyashiki.
- Cleanup comment.
 1.508.4.7 24-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #389):
sys/net/if_ether.h: revision 1.69
sys/net/if_vlan.c: revision 1.108
sys/dev/pci/if_bge.c: revision 1.313
sys/net/if_vlanvar.h: revision 1.11
sys/net/if_vlanvar.h: revision 1.12
sys/net/if_ether.h: revision 1.70
sys/net/if_vlan.c: revision 1.110
sys/dev/pci/if_wm.c: revision 1.544
sys/dev/pci/if_wmreg.h: revision 1.105
Fix a bug that a vlan packet which has priority or CFI bit in the tag causes
panic.
Revert part of if_bge.c 1.312. It's not required to mask other than VLAN ID
bits in VLAN tag.
Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
No functional change:
- u_int16_t -> uint16_t
- u_short -> uint16_t
- tag_hash_func -> vlan_tag_hash
- 0 -> NULL because vlr_parent is a pointer.
 1.508.4.6 22-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #379):
sys/dev/pci/if_wm.c: revision 1.540
On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
 1.508.4.5 06-Nov-2017  snj Pull up following revision(s) (requested by knakahara in ticket #348):
sys/dev/pci/if_wm.c: revision 1.542
sys/dev/pci/if_wmreg.h: revision 1.104
fix wm(4) vlan panic. Reported and tested by Tom Ivar Helbekkmo, thanks.
wm(4) used PRI bits and CFI bit as vlantag by mistake. It is found out
by if_ether.h:r1.67.
 1.508.4.4 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.508.4.3 15-Oct-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #306):
sys/dev/pci/if_wm.c: revision 1.539
- Correct NVM word size check in wm_nvm_version() to prevent
"EERD polling failed" error on attach. if_wm.c rev. 1.534 was not perfect.
Reported by ozaki-r@.
- Print NVM offset and word count when EERD polling failed.
 1.508.4.2 01-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #173):
sys/dev/pci/if_wmreg.h: 1.99-1.103
sys/dev/pci/if_wmvar.h: 1.34-1.37
sys/dev/pci/if_wm.c: 1.510-1.537
sys/dev/mii/ihphyreg.h: 1.2
sys/dev/mii/inbmphyreg.h: 1.10
sys/dev/mii/igphy.c: 1.27
Sync wm(4) up to if_wm.c rev. 1.537:
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset().
- If a legacy interrupt is a spurious interrupt, don't print debug
message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Flush writing WMREG_CTRL in wm_gmii_mediachange().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Add I219 specific workaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for workaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- IF TX is not required to flush, RX is also not required to flush in
wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset().
Some flags and callback function is required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Configure the LCD with the extended configuration region in NVM if
it's required. Tested with Thinkpad X220.
- 8257[12]: Don't directly access SPI but use EERD register.
- 82575-I354: If the size of SPI ROM >= 32K words, use direct SPI
access instead of EERD register access.
- Add wm_nvm_eec_clock_raise() and wm_nvm_eec_clock_lower() and use
them for Microwire/SPI bus control. Same as Linux and FreeBSD.
- Reduce timeout value for 80003 in wm_get_swfw_semaphore(). Same as
Linux and FreeBSD.
- Change API of kmrn_{read,write}reg() and check the return value.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally." on I21[01]. PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
NVM word size before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Print internal driver flags when attaching.
- Add debug printf()s.
- Rename variables.
- Add comment, update comment and remove wrong comment.
 1.508.4.1 04-Jul-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #81):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.89
sys/dev/pci/if_wm.c: revision 1.509
sys/dev/pci/ixgbe/ixgbe.c: revision 1.90
Use IFM_1000_KX and IFM_2500_KX.
Use IFM_1000_KX more.
 1.566.2.13 26-Jan-2019  pgoyette Sync with HEAD
 1.566.2.12 18-Jan-2019  pgoyette Synch with HEAD
 1.566.2.11 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.566.2.10 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.566.2.9 20-Oct-2018  pgoyette Sync with head
 1.566.2.8 30-Sep-2018  pgoyette Ssync with HEAD
 1.566.2.7 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.566.2.6 28-Jul-2018  pgoyette Sync with HEAD
 1.566.2.5 25-Jun-2018  pgoyette Sync with HEAD
 1.566.2.4 21-May-2018  pgoyette Sync with HEAD
 1.566.2.3 02-May-2018  pgoyette Synch with HEAD
 1.566.2.2 22-Apr-2018  pgoyette Sync with HEAD
 1.566.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.583.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.583.2.1 10-Jun-2019  christos Sync with HEAD
 1.645.2.21 23-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1802:

sys/dev/pci/if_wm.c 1.794-1.798 via patch
sys/dev/pci/if_wmreg.h 1.131

- Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.
- Drop frames if the RX descriptor ring has no room on multiqueue
system.
- Improve dmesg output:
- Print RX packet buffer size.
- Fix the upper 16bit of Image Unique ID(EtrackID).
 1.645.2.20 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #1791):

sys/dev/pci/if_wm.c: revision 1.793

Add Intel I219-{LM,V}(20,21) support.
 1.645.2.19 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1754):

sys/dev/pci/pcidevs: revision 1.1497
sys/dev/pci/if_wm.c: revision 1.790
sys/dev/pci/if_wm.c: revision 1.791
sys/dev/pci/if_wmvar.h: revision 1.51

pcidevs: Add Intel I219{V,LM}({22,23})

wm(4): Add a new workaround for Tiger Lake and newer.
- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.

wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.645.2.18 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1746):

sys/dev/pci/if_wm.c: revision 1.785
sys/dev/pci/if_wm.c: revision 1.786
sys/dev/pci/if_wm.c: revision 1.787
sys/dev/pci/if_wm.c: revision 1.788
sys/dev/pci/if_wm.c: revision 1.789

wm(4): Use SCVPC and HRMPC for 82575 and newer.
The SCVPC(SerDes/SGMII Code Violation Packet Count) register and the HRMPC
(Header Redirection Missed Packet Count) register were added in if_wm.c
rev. 1.776 but the location in the code were incorrect. Fix them.

wm(4): Add some info to some event counters.
- The difference between the RUC(Rx Undersize) and RFC(Rx Fragment) is whether
the CRC is valid or not.
- The difference between the ROC(Rx Oversize) and RJC(Rx Jabber) is whether
the CRC is valid or not.
- LENERRS(Length Errors) is for the length/type field <= 1500.

wm(4): the IAC(Interrupt Assertion Count) register is for 82571 and newer.

wm(4): Modify descriptions of flow control related event counters.

wm(4): Replace /* nothing */ to __nothing for evcnt macros
Prevent empty if bodies for !WM_EVENT_COUNTERS.
 1.645.2.17 04-Sep-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #344):

sys/dev/pci/if_wmvar.h: revision 1.50
sys/dev/pci/if_wm.c: revision 1.783,1.784 via patch

Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.

Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.645.2.16 27-Jun-2023  martin Pull up the following revisions, requested by msaitoh in #1656:

sys/dev/pci/if_wm.c 1.768-1.782 via patch
sys/dev/pci/if_wmreg.h 1.129-1.130
sys/dev/pci/if_wmvar.h 1.49

wm(4):
- Rework for event counters:
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Rearrange the order of the registers so that they are roughly
in ascending order.
- Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach()
to match.
- IC{TX,RX}*C registers are for older than 82575.
- Fix a bug that the transmit underrun counter is incorrectly
counted.
- Don't add "Count" for event counter's description.
- Some statistics registers were replaced with new counters on newer
chips. Treat 0x403c(CEXTERR->HTDPMC), 0x40fc(TSCTFC->CBRMPC),
0x4124(ICRXOC->HTCBDPC) and from 0x4104 to 0x4124.
- Add some new counters:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- Host Good Octets RX
- Host Good Octets TX
- Length Errors
- SerDes/SGMII Code Violation Packet
- Header Redirection Missed Packet
- EEE TX LPI
- EEE RX LPI
- Fix prc511's comment and description.
- Add SOICZIFDATA (ifconfig -z) support for evcnt(9).
- Use WM_IS_ICHPCH(). No functional change.
- Fix typo. s/ictxact/ictxatc/. No functional change.
- Add comment.
 1.645.2.15 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1578:

sys/dev/pci/if_wm.c 1.764-1.767 via patch
sys/dev/pci/if_wmreg.h 1.128

- Workaround for some hypervisor environments. The environments
cannot stop e1000 interrupt immediately.
- Rename nq_txdesc' member "nqrx_ctx" to "nqtx_ctx". No functional
change.
- Add comment. Modify comment.
- KNF.
 1.645.2.14 07-Sep-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1515:

sys/dev/pci/if_wm.c 1.741-1.749,
1.753-1.757,
1.762 via patch
sys/dev/pci/if_wmreg.h 1.126-1.127

- Fix I219 workaround in wm_flush_desc_rings().
- Add more statistics counters.
- To avoid releasing mutex temporally, use new
wm_set_mdio_slow_mode_hv_locked().
- No functional changes:
- Turn a locking botch (shouldn't drop lock on error) into a KASSERT
in wm_deferred_start_locked().
- Remove unneeded header inclusion.
- Use __BIT() a little.
- Modify comment and debug messages.
- Consistency use -1 instead of 1 for some error code.
- KNF.
 1.645.2.13 11-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1477:

sys/dev/pci/if_wmreg.h 1.122-1.125
sys/dev/pci/if_wmvar.h 1.48
sys/dev/pci/if_wm.c 1.719-1.720,
1.722-1.725,
1.727-1.740 via patch

- wm_tick: Add missing splx(s) when not WM_MPSAFE.
- Print DMA range info if the system is booting in the verbose mode.
- Micro optimization:
- Call m_freem(m) only if m0 == NULL.
- Call wm_xxeof() only when limit > 0.
- Don't set the more flag when there is no packet to process.
- No functional changes:
- Call txeof first, then rxeof for the consistency.
- Remove duplicated break.
- Remove stray semicolons from struct declaration.
- Fix value return from void function.
- Use macros.
- Modify comment.
- KNF.
 1.645.2.12 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1373:

sys/dev/pci/if_wm.c 1.716-1.718 via patch
sys/dev/pci/if_wmreg.h 1.121
sys/dev/mii/ihphy.c 1.20

- Fix a bug that device timeout still happens when the link is down
on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.
 1.645.2.11 21-Oct-2021  martin Pull up the following, requested by msaitoh in ticket #1363:

share/man/man4/wm.4 1.42
sys/dev/pci/files.pci 1.434
sys/dev/pci/if_wm.c 1.690,1.692-1.693,1.697-1.704,
1.706-1.715 via patch

- Add missing drain for pcq in wm_stop_locked().
- Add support for I219V 15-19 and I219LM 16-19.
- Fix Tx stall.
- Use wm_flush_desc_rings() workaround more on I219.
- Change DMA physical address in wm_flush_desc_rings() to match other
OSes.
- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Add new sysctl hw.wmN.debug_flags. This sysctl can be used if
WM_DEBUG is set.
- Add some sysctl values for debugging TX/RX queues.
- Use atomic_{load,store}_relaxed for evcnt 64 bit counter.
- WM_EVENT_COUNTER is enabled by default on 64 bit architectures.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxq->rxq_ptr updating.
- Stop legacy interrupts before calling softint.
- Disable printf()s in wm_flush_desc_rings() because the code is
verified.
- Print I219's version number.
- Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.
- Fix return value of interrupt handler.
- Only print an error about missing I/O BARs for chips that need it.
- Do not return a void value from a void function.
- Fix comment.
- Whitespace fixes. No functional change.
 1.645.2.10 16-Nov-2020  martin Pull up following revision(s) (requested by rin in ticket #1133):

sys/dev/pci/if_wm.c: revision 1.696

Fix little-endian dependence in wm_rxeof(), by which packets cannot be
received by 82574 and successors on big-endian machines.

Tested by aarch64eb with I210-T1 on ROCKPro64.

Thanks msaitoh for discussion!
XXX
pullup to netbsd-9 and netbsd-8
 1.645.2.9 04-Nov-2020  martin Pull up following revision(s) (requested by knakahara in ticket #1126):

sys/dev/pci/if_wm.c: revision 1.694
sys/dev/pci/if_wm.c: revision 1.695 (via patch)
sys/dev/pci/if_wmvar.h: revision 1.47

Add WMPHY_I350. Not used yet.

Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).
These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981
Reviewed and tested by msaitoh@n.o, thanks.
XXX pullup-[89]
 1.645.2.8 16-Oct-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1114):

sys/dev/pci/if_wm.c: revision 1.691

Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=000000, model=0000" and
"PHY type is still unknown." Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).
 1.645.2.7 23-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1093):

sys/dev/pci/if_wmreg.h: revision 1.120
sys/dev/pci/if_wmvar.h: revision 1.46
sys/dev/pci/if_wm.c: revision 1.686
sys/dev/pci/if_wm.c: revision 1.687
sys/dev/mii/inbmphyreg.h: revision 1.20
sys/dev/pci/if_wm.c: revision 1.688
sys/dev/pci/if_wm.c: revision 1.689

s/ressource/resource/. Found by knakahara.

Add new flag named WM_F_CRC_STRIP and use it. No functional change.

This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.

Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.

- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.
XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
FreeBSD and Linux do the same thing that they set the same value on both
jumbo frame's enable case and the disable case. It seems the default value
is 0x0b0c and it's not changed on the enable case, so it might be a bug
on the enable case or the modification is not required.
- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.
Use 12K for packet buffer for jumbo frame on PCH2 and newer.

XXX Note that Linux Use 14K.
 1.645.2.6 05-Aug-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1040):

sys/dev/mii/igphy.c: revision 1.35
sys/dev/mii/igphy.c: revision 1.36
sys/dev/mii/igphyreg.h: revision 1.12
sys/dev/mii/igphyreg.h: revision 1.13
sys/dev/mii/makphyreg.h: revision 1.11
sys/dev/pci/if_wm.c: revision 1.682
sys/dev/pci/if_wm.c: revision 1.683
sys/dev/pci/if_wm.c: revision 1.684
sys/dev/pci/if_wm.c: revision 1.685
sys/dev/mii/makphy.c: revision 1.66

s/MII_IGPHY_/IGPHY_/. No functional change.

Rename PSSR_* to MAKPHY_PSSR_* and IGPHY_PSSR_* to avoid conflict.
No functional change.

Setup PCS and SGMII for SFP correctly. It still doesn't support SFP
insertion/removal.

Copper:
wm2: SGMII(SFP)
wm2: 0x1043c440<SPI,IOH_VALID,PCIE,SGMII,NEWQUEUE,ASF_FIRM,EEE,SFP>
makphy0 at wm2 phy 6: Marvell 88E1111 Gigabit PHY, rev. 1

Fiber:
wm3: SERDES(SFP)
wm3: 0x10034440<SPI,IOH_VALID,PCIE,NEWQUEUE,ASF_FIRM,SFP>
wm3: 1000baseSX, 1000baseSX-FDX, auto

Explicitly cast from uint16_t to uint32_t before shifting 16bit left
when printing Image Unique ID. Found by kUBSan.

Set if_baudrate for non-MII device. Before this commit, it was 0.
 1.645.2.5 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #994:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660, 1.662, 1.664-1.668,
1.671-1.674, 1.678,1.680-1.681 via patch
sys/dev/pci/if_wmreg.c 1.118-1.119
sys/dev/pci/if_wmvar.c 1.45

- Add SFP support. Module insertion/removal is not supported yet.
Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler.
Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0 which use softint
as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
fragmented UDP, first packet and second packet should be processed
in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
in case it's already set.
- Actually writing always the checksum offload context descriptor
makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Rename some macros and function.
- KNF. Add comment.
 1.645.2.4 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #650:

sys/dev/pci/if_wm.c 1.650, 1.652-1.654
sys/dev/pci/if_wmreg.h 1.116-1.117

- Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580
port 1, 2, 3 and newer chips. This change fixes a bug that some
fiber, serdes or SFP devices don't detect the link status correctly.
- Simplify code by using "struct mii_data *mii" more. No functional
change.
- MSI-X doesn't use sc->sc_icr variable, so move the code into
non-MSI-X part. No functional change intended.
- Modify debug printfs a bit.
- Rename macro.
- Use __BIT()
- Fix comment. Add comment.
- KNF.
 1.645.2.3 23-Jan-2020  martin Pull up following revision(s) (requested by knakahara in ticket #643):

sys/dev/pci/if_wm.c: revision 1.661

fix softint_disestablish() in wm_detach().

ok by msaitoh@n.o
XXX pullup-8, pullup-9
 1.645.2.2 11-Dec-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #541):

sys/dev/pci/if_wm.c: revision 1.651

Fix a bug that wm_sgmii_readreg_locked() may return error even if error isn't
occurred.
 1.645.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #404):

sys/dev/pci/if_wm.c: revision 1.646
sys/dev/pci/if_wm.c: revision 1.647
sys/dev/pci/if_wm.c: revision 1.649

Use unsigned to avoid undefined behavior in wm_i82543_mii_sendbits().
Found by kUBSan.

printf -> device_printf

Fix typo in comment.
 1.658.2.2 29-Feb-2020  ad Sync with head.
 1.658.2.1 25-Jan-2020  ad Sync with head.
 1.670.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.694.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.694.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.702.4.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.702.4.1 13-May-2021  thorpej Sync with HEAD.
 1.703.2.1 31-May-2021  cjep sync with head
 1.767.2.8 23-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #607):

sys/dev/pci/if_wm.c: revision 1.795
sys/dev/pci/if_wm.c: revision 1.796
sys/dev/pci/if_wm.c: revision 1.797
sys/dev/pci/if_wmreg.h: revision 1.131

wm(4): Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.

The iqdrops counter should include not only MPC(Missed Packet Count)
but also RQDPC(Receive Queue Drop Packet Count). Same as ixgbe(4) and igc(4).

Note that the RQDPC is not currently counted because SRRCTL_DROP_EN
is not set.

wm(4): Drop frames if the RX descriptor ring has no room on multiqueue system.

Drop frames if the RX descriptor ring has no room. This is enabled only on
multiqueue system to avoid bad influence to other queues. The drop count
can be seen by the RQDPC counter (wmN rxqXXdrop evcnt).

wm(4): Fix compile error without WM_EVENT_COUNTERS.
 1.767.2.7 23-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #606):

sys/dev/pci/if_wm.c: revision 1.794
sys/dev/pci/if_wm.c: revision 1.798

wm(4): Print RX packet buffer size.

wm(4): Fix upper 16bit of Image Unique ID(EtrackID).

Don't override uid1 variable while reading option ROM version
to print Image Unique ID correctly.
 1.767.2.6 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #564):

sys/dev/pci/if_wm.c: revision 1.793

Add Intel I219-{LM,V}(20,21) support.
 1.767.2.5 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #421):

sys/dev/pci/pcidevs: revision 1.1497
sys/dev/pci/if_wm.c: revision 1.790
sys/dev/pci/if_wm.c: revision 1.791
sys/dev/pci/if_wmvar.h: revision 1.51

pcidevs: Add Intel I219{V,LM}({22,23})

wm(4): Add a new workaround for Tiger Lake and newer.
- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.

wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.767.2.4 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #396):

sys/dev/pci/if_wm.c: revision 1.785
sys/dev/pci/if_wm.c: revision 1.786
sys/dev/pci/if_wm.c: revision 1.787
sys/dev/pci/if_wm.c: revision 1.788
sys/dev/pci/if_wm.c: revision 1.789

wm(4): Use SCVPC and HRMPC for 82575 and newer.
The SCVPC(SerDes/SGMII Code Violation Packet Count) register and the HRMPC
(Header Redirection Missed Packet Count) register were added in if_wm.c
rev. 1.776 but the location in the code were incorrect. Fix them.

wm(4): Add some info to some event counters.
- The difference between the RUC(Rx Undersize) and RFC(Rx Fragment) is whether
the CRC is valid or not.
- The difference between the ROC(Rx Oversize) and RJC(Rx Jabber) is whether
the CRC is valid or not.
- LENERRS(Length Errors) is for the length/type field <= 1500.

wm(4): the IAC(Interrupt Assertion Count) register is for 82571 and newer.

wm(4): Modify descriptions of flow control related event counters.

wm(4): Replace /* nothing */ to __nothing for evcnt macros
Prevent empty if bodies for !WM_EVENT_COUNTERS.
 1.767.2.3 04-Sep-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #344):

sys/dev/pci/if_wmvar.h: revision 1.50
sys/dev/pci/if_wm.c: revision 1.783
sys/dev/pci/if_wm.c: revision 1.784

Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.

Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.767.2.2 27-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #216):

sys/dev/pci/if_wm.c: revision 1.782

Add missing read to count Circuit Breaker Rx Dropped Packet correctly.
 1.767.2.1 22-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #213):

sys/dev/pci/if_wm.c: revision 1.770
sys/dev/pci/if_wm.c: revision 1.771
sys/dev/pci/if_wm.c: revision 1.772
sys/dev/pci/if_wm.c: revision 1.773
sys/dev/pci/if_wm.c: revision 1.774
sys/dev/pci/if_wm.c: revision 1.775
sys/dev/pci/if_wm.c: revision 1.776
sys/dev/pci/if_wmreg.h: revision 1.129
sys/dev/pci/if_wm.c: revision 1.777
sys/dev/pci/if_wm.c: revision 1.778
sys/dev/pci/if_wmvar.h: revision 1.49
sys/dev/pci/if_wm.c: revision 1.779
sys/dev/pci/if_wm.c: revision 1.768
sys/dev/pci/if_wm.c: revision 1.769
sys/dev/pci/if_wmreg.h: revision 1.130
sys/dev/pci/if_wm.c: revision 1.780
sys/dev/pci/if_wm.c: revision 1.781

Count some 64bit counters correctly.
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Found by knakahara.

Add note for the TORL register.

The TOR register includes error, flow control and broadcast rejected.

Sort lines. No functional change.

Rearrange the order of the registers so that they are roughly in ascending
order.

Sort lines. No functional change.

Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach() to match.
IC{TX,RX}*C registers are for older than 82575.

Fix a bug that the transmit underrun counter is incorrectly counted.
The transmit underrun bit in the transmit status filed is only for 82544
(and older?), so don't use the counter for newer chips. The bit is reserved
for newer chips, but the bit sometimes set on 82575 at least.

Don't add "Count" for event counter's description.

Some statistics registers were replaced with new counters.
- 0x403c was CEXTERR(Carrier Extension Error). 82575 and newer except 80003,
ICHs and PCHs have HTDPMC(Host Tx Discarded Packets by MAC). I don't really
know for 82575. The 82575 datasheet say nothing about it.
- The following two are changed for circuit breaker. Only 82576's datasheet
describes abut it, so the registers might be only for 82576.
Use those registers for 82575 and newer except 80003, ICHs and PCHs just in
case.
- 0x40fc was TSCTFC(TCP Segmentation Context Tx Fail). It was replaced by
the CBRMPC(Circuit Breaker Rx Manageability Packet) register.
- 0x4124 was ICRXOC(Interrupt Cause Receiver Overrun). It was replaced by
the HTCBDPC(Host Tx Circuit Breaker Dropped Packet) register.
- From 0x4104 to 0x4124:
- For 0x4124, 82575's datasheet says it's not changed(ICRXOC).
I don't know if it's correct. We use new HTCBDPC register for 82575.
- 82576 and newer changed the meaning.
- I don't know for 80003, ICHs and PCHs. Don't count those registers.
At least, those registers in PCH2 and PCH_CNP are all zero.

Add some new event counters.

Add the following counters for 82575 and newer except 80003, ICHs and PCHs:
- Only 82576 document describes about the circuit breaker,
so the following two might be only for 82575:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- 82575's document doesn't describe the following two, but we can see
the same value as GO{T,R}C have:
- Host Good Octets RX
- Host Good Octets TX
- 82575's document doesn't describe the LENERRS (Length Errors) counter.
I don't know if it has.
- Perhaps Non-SerDes/SGMII devices don't have SCVPC
(SerDes/SGMII Code Violation Packet) register. We don't care if
it's SerDes/SGMII or not for now.
- HRMPC (Header Redirection Missed Packet) appears only once
in 8257[56]'s datasheet. FreeBSD's igb counts it, so we do, too.
- Count the following two for I350 and newer. I don't know if PCHs have:
- EEE TX LPI
- EEE RX LPI

Move statistics updating code from wm_tick() to new wm_update_stats().
- To reuse.
- No functional change.

Add SOICZIFDATA (ifconfig -z) support for evcnt(9).

First update the statistics data, then clear the event counters,
and finally copy and clear if_data via ether_ioctl().

Fix prc511's comment and description.

Use WM_IS_ICHPCH(). No functional change.

Fix typo. s/ictxact/ictxatc/. No functional change.
 1.799.2.1 02-Aug-2025  perseant Sync with HEAD
 1.131 29-Jan-2024  msaitoh wm(4): Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.

The iqdrops counter should include not only MPC(Missed Packet Count)
but also RQDPC(Receive Queue Drop Packet Count). Same as ixgbe(4) and igc(4).

Note that the RQDPC is not currently counted because SRRCTL_DROP_EN
is not set.
 1.130 11-May-2023  msaitoh Add some new event counters.

Add the following counters for 82575 and newer except 80003, ICHs and PCHs:
- Only 82576 document describes about the circuit breaker,
so the following two might be only for 82575:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- 82575's document doesn't describe the following two, but we can see
the same value as GO{T,R}C have:
- Host Good Octets RX
- Host Good Octets TX
- 82575's document doesn't describe the LENERRS (Length Errors) counter.
I don't know if it has.
- Perhaps Non-SerDes/SGMII devices don't have SCVPC
(SerDes/SGMII Code Violation Packet) register. We don't care if
it's SerDes/SGMII or not for now.
- HRMPC (Header Redirection Missed Packet) appears only once
in 8257[56]'s datasheet. FreeBSD's igb counts it, so we do, too.
- Count the following two for I350 and newer. I don't know if PCHs have:
- EEE TX LPI
- EEE RX LPI
 1.129 11-May-2023  msaitoh Some statistics registers were replaced with new counters.

- 0x403c was CEXTERR(Carrier Extension Error). 82575 and newer except 80003,
ICHs and PCHs have HTDPMC(Host Tx Discarded Packets by MAC). I don't really
know for 82575. The 82575 datasheet say nothing about it.
- The following two are changed for circuit breaker. Only 82576's datasheet
describes abut it, so the registers might be only for 82576.
Use those registers for 82575 and newer except 80003, ICHs and PCHs just in
case.
- 0x40fc was TSCTFC(TCP Segmentation Context Tx Fail). It was replaced by
the CBRMPC(Circuit Breaker Rx Manageability Packet) register.
- 0x4124 was ICRXOC(Interrupt Cause Receiver Overrun). It was replaced by
the HTCBDPC(Host Tx Circuit Breaker Dropped Packet) register.
- From 0x4104 to 0x4124:
- For 0x4124, 82575's datasheet says it's not changed(ICRXOC).
I don't know if it's correct. We use new HTCBDPC register for 82575.
- 82576 and newer changed the meaning.
- I don't know for 80003, ICHs and PCHs. Don't count those registers.
At least, those registers in PCH2 and PCH_CNP are all zero.
 1.128 19-Oct-2022  msaitoh branches: 1.128.2;
Fix typo. No functional change. OK'd by knakahara.
 1.127 22-Jul-2022  msaitoh Add more statistics countes.

- Add many statics counters that the chip has.
- Attach event counters only if available.
 1.126 20-Jul-2022  msaitoh Modify comment. Use __BIT() a little. No functional change.
 1.125 22-Dec-2021  skrll Fixup NQTXC_CMD_{TCP,UDP} after previous
 1.124 22-Dec-2021  skrll In a close run thing use #define<tab> everywhere for consistency
 1.123 22-Dec-2021  skrll Use __BIT() some more. Same code before and after.
 1.122 20-Dec-2021  skrll Trailing whitespace
 1.121 05-Nov-2021  msaitoh Fix comment. No functional change.
 1.120 16-Sep-2020  msaitoh Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.

- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.

XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
FreeBSD and Linux do the same thing that they set the same value on both
jumbo frame's enable case and the disable case. It seems the default value
is 0x0b0c and it's not changed on the enable case, so it might be a bug
on the enable case or the modification is not required.

- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.
 1.119 08-Jan-2020  msaitoh - Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Define SFF_SFP_ETH_FLAGS_100LX with 0x10.
 1.118 11-Dec-2019  msaitoh Add SFP support part 1. The code for SerDes and SGMII setting is not include
in this commit. SFP module removal interrupt detects but not used yet:
- Detect SFP's 1000BASE-SX, 1000BASE-LX, 100BASE-FX and 1000BASE-T correctly.
- Detect the Media Auto Sense feature. Not supported yet.
- Add comment.
 1.117 11-Dec-2019  msaitoh - Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580 port 1, 2, 3 and
newer chips. This change fixes a bug that some fiber, serdes or SFP devices
don't detect the link status correctly.
XXX We should check for other NVM reads if they have the same problem. One of
the solution to avoid this type of bug is to check the register layout
in wm_nvm_read().
- Use __BIT()
- Add comment
 1.116 11-Dec-2019  msaitoh No functional change:
- Add defintion of CONNSW register and PCS_NPTX (not used yet).
- Add some bit definitions of PCS_LCTL.
- Renae macro.
- Fix comment. Add comment.
- KNF.
 1.115 23-Jul-2019  msaitoh branches: 1.115.2;
Define RETA_ENTRY_MASK_Q(used in RSS redirection table) correctly.
Found by UBSan.
 1.114 07-Jun-2019  msaitoh Use unsigned. Found by UBSan. OK'd by kamil.
 1.113 28-Feb-2019  khorben Typo (s/vaule/value/)
 1.112 31-Jan-2019  msaitoh Add some workarounds which use EMI register or EEE related:
- PCH only: Add workaround for link disconnects on a busy hub in half duplex.
- PCH and PCH2 only: Set MSE higher to enable link to stay up when noise is
high.
- PCH2 only: Drop link after 5 times MSE threshold was reached.
- PCH2 only: Set EEE LPI Update Timer to 200usec.
- For PCH2 and newer: When connected at 10Mbps half-duplex, some parts are
excessively aggressive resulting in many collisions. To avoid this, increase
the IPG and reduce Rx latency in the PHY.
- For I21[789] and if EEE is enabled: Disable LPLU if both link partners
support 100BaseT EEE and 100Full is advertised on both ends of the link, and
enable Auto Enable LPI since there will be no driver to enable LPI while in
Sx.
 1.111 20-Dec-2018  msaitoh - Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
 1.110 14-Dec-2018  msaitoh - Fix availability detection of WoL on some chips. This change has no effect
other than dmesg because WM_F_WOL is currently not used to change the behavior:
- For ICH/PCH, check the capability not from NVM but from the WUC register.
Check the value before clearing the register.
- 82580 and newer have per-port NVM block, so read the area correctly.
Note that 82580, I350 and I354 may have PCI function 2 and 3.
- Some devices can't detect WoL capability neither from NVM nor from WUC.
Use PCI device ID and the function number.
- Print the WUS (WakeUp Status) register bits when resume.
 1.109 19-Nov-2018  msaitoh - Control TX/RX descriptor snooping control bits on ICH8 and newer.
Only on ICH8, No-snoop bits are opposite polarity. On my Thinkpas X61,
the default value of this bits are all zero, so this commit changes
the snoop function enable on the machine. I tested with some other
PCH machines and those bits are all zero (enable snoop by default),
so this commit won't affect to some machines.
- Disable relax ordering on 82546GB(Device ID 0x1099 and 0x10b5) or >= ICH8.
Same as other OSes.
 1.108 02-Nov-2018  msaitoh Add workaround for DMA hang problem which result in TX device timeout on
PCH_LPT with I218. Same as FreeBSD and Linux. This woraround is only for
device ID 0x155a, 0x15a2, 0x1559 and 0x15a3. I observed this problem on my
Shuttle DS57U's I218 port six times in two months.
 1.107 12-Apr-2018  msaitoh branches: 1.107.2;
No binary change:
- Sort registers.
- Lowercase hexadecimal value.
 1.106 10-Apr-2018  msaitoh SW PHY Config Enable bit for ICH8 B0 stepping is not bit 1 but bit 0.
 1.105 22-Nov-2017  msaitoh branches: 1.105.2;
Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
 1.104 23-Oct-2017  knakahara fix wm(4) vlan panic. Reported and tested by Tom Ivar Helbekkmo, thanks.

wm(4) used PRI bits and CFI bit as vlantag by mistake. It is found out
by if_ether.h:r1.67.

XXX need pullup-8
 1.103 26-Jul-2017  msaitoh - Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required for
these functions to use the same API. So,
- Change return value as error code.
- Change register vaule from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not in
wm_reset(). If the workaround isn't required, don't use the workaround code
in wm_gmii_i80003_{read,write}reg.
 1.102 13-Jul-2017  msaitoh - Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if it's
required.
- Add debug printf.
 1.101 12-Jul-2017  msaitoh Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before this commit,
above devices and non-PCIe devices accessed wrong register.
 1.100 26-Jun-2017  msaitoh - Make new wm_phy_post_reset() and use this function at all location after
reseting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
 1.99 26-Jun-2017  msaitoh - Fix wm_set_ral():
- Fix a bug that a RAL was written at incorrect address when the index number
is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others.
- Remove wrong comment.
 1.98 28-Feb-2017  knakahara branches: 1.98.6;
fix EITR setting.

+ 82574
- add EITR setting, that is MSI-X mode interrupt interval
+ 82575
- fix EITR value. 82575's EITR usage is the same as legacy (not NEWQUEUE)
controllers
- apply workaround which 82575's EITR does not have CNT_INGR bit
+ other NEWQUEUE controllers
- fix interrupt interval field. NEWQUEUE (include 82575) controllers'
interrupt interval field is 2:14
- use CNT_INGR bit which avoid to overwrite counter

tested 82574, 82575 and I354.
ok by msaitoh@n.o.
 1.97 02-Feb-2017  msaitoh Fix typo in comment.
 1.96 01-Feb-2017  knakahara tabify
 1.95 16-Jan-2017  knakahara support {extended, advanced} receive descriptor for wm(4).

support below two receive descriptors.
- extended descriptor (used by 82574 only)
- advanced descriptor (used by 82575 and newer)

SPH(split header buffer) is not supported yet.

ok by msaitoh@n.o.
 1.94 13-Dec-2016  msaitoh branches: 1.94.2;
- Change to use 2500Base-KX correctly on C2000(I354). It worked, but the
output of ifconfig and if_baudrate was not good. Tested by nils@:
- The STATUS_TBIMODE bit in the STATUS register is deleted since 82575,
so check for 82575 and newer first and then check for old devices.
- Check the 2P5_SKU and 2P5_SKU_OVER bit for KX.
- Set IFM_2500_SX instead of IFM_1000_SX for 2.5G.
- Check SERDES's speed directly from the PCS layer (PCS_LSTS register) for old
devices.
- Style fix.
 1.93 16-Nov-2016  msaitoh Sync wm_smbustopci() with Linux and FreeBSD. This change effects PCH and
newer devices.
 1.92 16-Nov-2016  msaitoh Add three workarounds for PCH_{LPT,SPT}.
 1.91 14-Nov-2016  msaitoh Sort registers. No functional change.
 1.90 11-Nov-2016  msaitoh The MEHE bit in the CTRL register is not bit 17 but 19.
 1.89 06-May-2016  msaitoh branches: 1.89.2;
Basic support for I219. It doesn't work on I219, so it's disabled.
 1.88 25-Dec-2015  msaitoh - Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Fix typo in comment and modify comment by tnn@.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
 1.87 27-Oct-2015  msaitoh Move the definition of CTRL_EXT_PHYPDEN and use __BIT(). No binary change.
 1.86 23-Oct-2015  msaitoh PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any effect by
default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
 1.85 13-Oct-2015  knakahara fix RXCSUM_CRCOFL bit of WMREG_RXCSUM register.
 1.84 13-Oct-2015  knakahara support RX multiqueue.

ok by msaitoh@n.o
 1.83 13-Oct-2015  knakahara change const value register macros to macro expressions to support multiqueue.
 1.82 08-Oct-2015  msaitoh - ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition have not used yet.
- Add ACK data Disable bit's definition.
 1.81 30-Sep-2015  knakahara fix IVARs offset for 82580 and newer.
 1.80 30-Sep-2015  msaitoh - Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX packets"
and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit. The NVM Image
version 2.1.4 and newer have this workaround.
- Print the NVM image version on 82583, too.

Pointed out by joerg@.
 1.79 07-Sep-2015  msaitoh - Check iNVM's image version and print it.
- Update TODO.
 1.78 13-Jun-2015  msaitoh Add MSI/MSI-X support written by Kengo Nakahara. Some old devices' support
is written by me. It's disabled by default. If you'd like to use, define
WM_MSI_MSIX.

Tested with:
8254[3405617] (INTx even if it has MSI CAP because of a errata)
8257[12], 82583 ICH8, ICH10, PCH2, PCH_LPT(I21[78]) (MSI)
8257[456], 82580, I35[04], I21[01] (MSI-X)

Not tested:
82542, 82573, 80003, ICH9, PCH,
 1.77 06-Jun-2015  msaitoh - Add workaround for I210 Errata 25 and I211 Errata 10.
- Add wm_gmii_gs40g_{read|write}reg() and use it to access non-standatrd
page.
- Add wm_pll_workaround_i210() and call it when
chip is i211
chip is i210 and it use INVM
chip is i210 and NVM image version < 3.25
- Add comment
- Rename macros.
 1.76 06-Jun-2015  msaitoh Print NVM image version.
 1.75 06-Jun-2015  msaitoh Revert previos. Sorry, I committed in another working directory...
 1.74 06-Jun-2015  msaitoh Print NVM image version.
 1.73 02-Jun-2015  msaitoh Fix a lot of bugs to make 82575 and newer's SERDES based systems work.
- Add SERDES specific functions.
- Fix IO pin configuration.
- Reset autonego timer when link becomes up.

TODO:
- Fix a bug that SFP ROM can't read.
- Perhaps some work is required for 8257[12] serdes systems.
- Remove duplicated code in TBI's link related functions.
 1.72 22-May-2015  msaitoh - Currently, WM_F_EEE bit is not set on all chips. it's intended to not
to use all of EEE fuctions but wm_set_eee_i350() leaves IPCNFG_10BASE_TE
bit and it causes link negotiation problem on some old switches. Disable
10BASE-Te function, too.
- Call wm_set_eee_i350() on some chips, too.
 1.71 16-May-2015  msaitoh Add support iNVM (integrated Non-Volatile Memory) for I21[01]. This change
fixes a bug that a MAC address is wrongly set on iNVM machines and NICs.
Tested with Shuttle DS57U(iNVM based) and other non iNVM based I210 machines.
 1.70 15-May-2015  msaitoh Fix typo in comment.
 1.69 04-May-2015  msaitoh For 82576 and newer devices, the PBA register is deleted. Don't write PBA
for those chips. Also change the calculation of RX packet buffer size in
new way.
 1.68 04-May-2015  msaitoh Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is
more than 4096. Almost the Same as other OSes
 1.67 04-May-2015  msaitoh Remove WMREG_TQSA_LO and WMREG_TQSA_HIGH. Those registers
are not described in documents and other OS's drivers don't
access it.
(I have no the first chip(82542)'s document. Those registers
might be described in the document).
 1.66 15-Feb-2015  msaitoh - Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Add comment.
- Fix typo in comment.
 1.65 24-Oct-2014  msaitoh branches: 1.65.2;
Simplify. No functional change.
 1.64 24-Oct-2014  msaitoh Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
 1.63 03-Sep-2014  msaitoh Read SFF SFP ROM and configure driver from the value.
 1.62 01-Sep-2014  msaitoh Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on some
machines.
- Calculate NVM word size correctly.
- Determine timeout value based on the NVM word size.
 1.61 29-Aug-2014  msaitoh No binary change:
- Move some NVM related macros from if_wm.c to if_wmreg.h.
- Rename some macros for consistency.
 1.60 31-Jul-2014  msaitoh branches: 1.60.2;
Fix fiber link problem (PR#44776 and PR#30880). Tested with 82543GC, 82544EI,
82545EM, 82546GB 82571EB and 82572EI fiber cards.
- Don't use the RXCFG interrupt. It's not required and the interrupt is very
heavy (a lot of interrupts). Same as {Free,Open}BSD.
- Modify wm_tbi_mediachange() to be close to em_setup_fiber_serdes_link()
of {Free,Open}BSD. At least, don't forget to set duplex setting.
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD. Tested with
my own 82545EM card.
 1.59 25-Jul-2014  msaitoh - Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
 1.58 25-Jul-2014  msaitoh No functional change:
- move NVM related values to the bottom.
- sort in register's address.
 1.57 11-Jul-2014  msaitoh Fix some bugs realted to semaphore. This change fixes a problem which
was exposed in if_wm.c rev. 1.271. Tested by riastradh@.
- Clear the SMBI bit in SWSM register before accessing NVM and PHY in
wm_attach(). Same as FreeBSD.
- Fix a bug that 82573 doesn't put the hardware semaphore. Same as
FreeBSD r256200.
 1.56 11-Apr-2014  msaitoh Fix the definition of CTRL_GIO_M_DIS. This bit is not bit 3 but bit 2.
Reported by pooka@.
 1.55 29-Dec-2013  msaitoh branches: 1.55.2;
Add support For I354(C2000 interna Ethernet controller):
- Add I354 support.
- Fix SGMII+MDIO case. SGMII+I2C is not supported yet.
- Not tested well.
- Sprinkle "XXX" to check later.
 1.54 25-Jun-2013  msaitoh branches: 1.54.2;
Sync the wm_enable_mng_pass_thru() function with FreeBSD. Don't check
MANC_EN_MAC_ADDR_FILTER bit. Add 82574 and 82583 specific check. This
modification may change the setting of WM_F_HAS_MANAGE flag on some machines.

Sync the wm_release_manageablilty() fucntion with FreeBSD. Set MANC_ARP_EN.
This change enables HW ARP function when entering suspend.

When the chip is 82580(ER) or I350, set WM_F_ASF_FIRMWARE_PRES flag and
check for the WM_F_ARC_SUBSYS_VALID flag. Same as FreeBSD.
 1.53 19-Jun-2013  msaitoh Add ECC support for the packet buffer. Only 82571 and I21[78] support ECC.
 1.52 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.51 18-Apr-2013  msaitoh Add support I21[01]. Only tested with my own I210-T1 Ethernet Server Adapter.
 1.50 13-Feb-2013  msaitoh No functional change.
- Fix comment.
- Use macro.
 1.49 07-Feb-2013  msaitoh Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
 1.48 29-Aug-2012  bouyer branches: 1.48.2;
Make vlan and all ip/ip6 checksum offload work for the I350.

On newer devices, when using the legacy TX descriptors, vlan-related flags
that were set on the last descriptor of a packet have to be set on the
first one.
For tso/checksum offloads, a new "advanced" descriptor format has to be
used.

Change wcd_txdescs to a union defining all types of descriptors (they
are all 16-bytes wide).
Define a new tx function wm_nq_start(), which handle newer devices.
There is some code duplication with wm_start(), but adding support to
the existing wm_start() would make it a if () {} else {} maze. This also
allows to get rid of some workaround for older chips that are not needed
here.
Use wm_nq_start() instead of wm_start() for the I350 (this should probably
be for all WM_F_NEWQUEUE devices, but I have no hardware but the I350 to
test). Call ifp->if_start() instead of wm_start() where is matters.

Tested on a I350, and a i80003 (which use the old format), both with and
without vlans, with and without checksum offloads.
 1.47 25-May-2012  msaitoh Add support Intel I350 Ethernet.
 1.46 20-Dec-2011  dyoung branches: 1.46.2;
Mark all of the Rx descriptor fields 'volatile' so that the compiler
will not re-order accesses. Some versions of GCC (such as one in NetBSD
5.x) definitely do re-order reads from these fields if they're not
marked volatile.
 1.45 20-May-2011  msaitoh branches: 1.45.4; 1.45.8;
Add PCH2 support.
 1.44 14-Jul-2010  msaitoh branches: 1.44.2;
- s/TBDA/TDBA/. It stands for Transmit Descriptor Base Address.
- The document says that the TDH register must be set after
TCL.EN is set on 82575 and newer devices.

TODO:
- ip4csum doesn't work on 82575 and newer devices (reported by Paul Goyette),
so we have to fix it.
 1.43 25-Jun-2010  msaitoh fix comment.
 1.42 25-Jun-2010  msaitoh Add some code to support 82580[ER]. Tested on my own I340-T4.

- Fix CTRL_EXT_SWDPIN() and CTRL_EXT_SWDPIO() macros. The bit order of the
SW definable pin is not 6543 but 3654!!!

- Rewrite the code to read MAC address from eeprom.

- Add some code to support 82580.

TODO:
- ukphy -> somephy
 1.41 25-Jun-2010  msaitoh The GIO master enable bit in STATUS register is not bit 16 but bit 19.
It will fix a problem in the reset sequence on PCI-e chips.
 1.40 07-Mar-2010  msaitoh branches: 1.40.2;
- Add code for WOL, ASF, IPMI and Intel AMT.
- wm_enable_wakeup() is disabled by default. If you want to use WOL with
the Magic Packet, define WM_WOL.
- Add the following flags:
WM_F_ASF_FIRMWARE_PRESENT
WM_F_ARC_SUBSYSTEM_VALID
WM_F_HAS_AMT
WM_F_HAS_MANAGE
WM_F_WOL
- Add wm_suspend() and wm_resume(). Give/get the control to/from the
firmware.
- Need more work for PCH. See wm_enable_phy_wakeup().
- Enable wm_get_hw_control() for 82574 and 82583.
- Add Yet another workaround for ICH8.
- Add wm_igp3_phy_powerdown_workaround_ich8lan() for power down problem
on D3.
 1.39 07-Mar-2010  msaitoh Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
 1.38 16-Feb-2010  msaitoh Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
 1.37 16-Feb-2010  msaitoh indent, tabify and remove extra spaces.
 1.36 04-Feb-2010  msaitoh branches: 1.36.2;
- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Count Missed packet (rx fifo overflow) and Receive no buffers (rx ring full)
into iqdrops.
 1.35 14-Jan-2010  msaitoh Fixes the rx stall problem on 82578 by MANY workaround code.
We need more work for 82577.
 1.34 12-Jan-2010  msaitoh - Add i82567LM-2 i82567LM-4 i82567V-3 LAN controller.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. Now we can linkup 1000BaseT
on PCH. It seems that we have to do the same work for ICH9.
 1.33 11-Jan-2010  msaitoh Add partial support for PCH. We have to do more work for PCH. Especially
I don't know what driver i82578 should be attached to. makephy? or atphy?
MII_OUI() says that the PHY is from Attansic (== Atheros). Intel's e1000
driver says that it's close to makphy...

I can't link up at 1000BaseT yet...
 1.32 07-Jan-2010  msaitoh Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
 1.31 07-Jan-2010  msaitoh bugfixes:
- add missing break in wm_reset()...
- fix the offset of WMREG_PBS...
- fix length of some delay()s in wm_gmii_reset()
 1.30 05-Jan-2010  msaitoh Fix the checking of jumbo frame function though I don't know whether
the function wokrs or not...

Remove the extra macro definition for the offset 0x1a in EEPROM.
 1.29 29-Dec-2009  msaitoh - Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- Add support for i82583V.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
 1.28 14-Jul-2009  msaitoh Some fixes for i80003 and ICH{8,9,10} from e1000 driver and document:

Add setting for KABGTXD register for ICH{8,9,10}.

ICH9 and ICH10 has no FCAL, FCAH and FCT like ICH8.

Add special setting for FCTTV and TCTL_EXT register for i80003

The special setting for TIPG is only for i80003.

Some of kumeran settings are only for i80003's bugs.

Add some ICH10 fixes.
 1.27 07-Apr-2009  msaitoh Fix about TBI mode. This fix doesn't influence MII mode.
- Fix SWDPIN(1)'s polarity on some chips.
- Fix flow control stuff (includes PR#32009).
- Stop RXCFG storm. It ocours easily.
- And more fix about autonego.

Tested on PRO/1000F, PRO/1000XF and PRO/1000 MF.
 1.26 20-Mar-2009  msaitoh Examine the management mode and mark DRV_LOAD (for ICH{8,9,10},80003,
8257{1,2,3,4}).

Add some error's printf().

Make the bank detect routine into the function.
 1.25 10-Mar-2009  msaitoh add an entry for 82567LF-3.
fix the register access for ICH10DO.
 1.24 25-Dec-2007  perry branches: 1.24.10; 1.24.18; 1.24.20; 1.24.24; 1.24.26;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.23 28-Aug-2007  msaitoh branches: 1.23.6; 1.23.8; 1.23.12;
add ICH9
need more work?
 1.22 29-Apr-2007  bouyer branches: 1.22.2; 1.22.6; 1.22.8;
Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller

tested with: Intel i82801H (AMT) LAN Controller, rev. 2
 1.21 16-Nov-2006  yamt branches: 1.21.2; 1.21.4; 1.21.8; 1.21.10;
wm: add IPv6 rx tcp/udp checksum offloading.
 1.20 21-Oct-2006  bouyer Add support for the Intel 80003 Gigabit Ethernet controller (found e.g. in
newer server chipsets) to wm(4), from the FreeBSD em(4) driver.
While there, add a few other Intel Ethernet controller that should work as
is.
Properly update the RX error and TX collision counters.
Add ikphy(4), a driver for the Intel i82563 Kumeran 10/100/1000 Ethernet PHYs
 1.19 10-Jun-2006  msaitoh branches: 1.19.6; 1.19.8;
o i82573 doesn't support jumbo frame
o set PBA for i8257[123]
o set MULA when sc_type == i8257[123]
 1.18 10-Jun-2006  uebayasi KNF.
 1.17 10-Jun-2006  msaitoh fix TX_COLLISION_DISTANCE_FDX and TX_COLLISION_DISTANCE_HDX (swapped).

add some register definitions (EERD, EEWR).
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.8; 1.16.14;
merge ktrace-lwp.
 1.15 07-Aug-2005  yamt fix a typo(?) in an unused macro. (WRX_ST_ISXM -> WRX_ST_IXSM)
 1.14 18-Feb-2005  briggs branches: 1.14.4; 1.14.6;
Update the interrupt mitigation support.
Actually initialize the interrupt throttling register.
Actually initialize the tx and tx absolute interrupt delay timer regs.
Update default values for the rx and tx delay timers.
Inspired by Zdenek Salvet in PR kern/29373.
 1.13 05-Oct-2004  thorpej branches: 1.13.4; 1.13.6;
Largest Tx descriptor buffer size is actually 4K.
 1.12 05-Oct-2004  thorpej - Add some useful constants related to the Packet Buffer Allocation
register.
- Add the Receive and Transmit Data FIFO registers.
 1.11 16-May-2004  thorpej Add flow control support, based on work by HITOSHI Osada.
 1.10 19-Feb-2004  thorpej branches: 1.10.2; 1.10.4;
s/WTC_DTYP_D/WTX_DTYP_D/
 1.9 14-Jan-2004  tsutsui Fix hardware cksum problem on big endian machines.
Tested on macppc by HATANO Hiromichi.

Note I guess this bug could be fixed only adding one htole32(),
but I'd rather clean up endianness handling:
- Use htole32() only to accesses against DMA descriptors.
- Don't use uint32_t union member with htole32()/le32toh()
to access uint8_t/uint16_t descriptors.
- Add le32toh() in some DPRINTF.
(XXX: strictly speaking, bus_dmamap_sync() is needed for these DPRINTF)
 1.8 07-Nov-2003  thorpej Fix brain'o in PCIX speed detection. kern/23375 (John R. Shannon).
 1.7 21-Oct-2003  thorpej Fix a typo.
 1.6 21-Oct-2003  thorpej Add some additional register definitions needed for newer chips:
- Control register shadow
- SPI EEPROM stuff
 1.5 30-May-2003  matt branches: 1.5.2;
Use proper shift marcos for EXT. This makes the PHY on i83543 get
recognized. From Doug Donsbach <dldonsbach at tds dot net>
 1.4 18-Oct-2002  yamt fix typos; "wiseman" is 82542, not 82452.
 1.3 08-Aug-2002  thorpej Add support for the new i82540, i82545, and i82546 Gig-E chips. The
i82546 chip has 2 Gig-E interfaces in a single chip.

The main difference is these chips have a special handshaking protocol
for accessing the EEPROM (due to the shared nature on the i82546).
 1.2 14-Jul-2002  thorpej Correct the description of two bits in the TCP context descriptor.
 1.1 28-Mar-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Device driver for the Intel i82542, i82542, and i82544 Gigabit
Ethernet interfaces.
 1.1.8.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.1 28-Mar-2002  jdolecek file if_wmreg.h was added on branch kqueue on 2002-06-23 17:47:47 +0000
 1.1.6.4 20-Jun-2003  msaitoh Pull up revision 1.5 (requested by matt in ticket #1299):
FIx to recognize the PHY on i83543 correctly.
 1.1.6.3 21-Nov-2002  tron Pull up revision 1.4 (requested by yamt in ticket #925):
fix typos; "wiseman" is 82542, not 82452.
 1.1.6.2 08-Nov-2002  tron Pull up revision 1.3 (requested by thorpej in ticket #650):
Add support for the new i82540, i82545, and i82546 Gig-E chips. The
i82546 chip has 2 Gig-E interfaces in a single chip.
The main difference is these chips have a special handshaking protocol
for accessing the EEPROM (due to the shared nature on the i82546).
 1.1.6.1 15-Jul-2002  thorpej pullup-1-6 ticket #499 (thorpej).

Original log message:
Correct the description of two bits in the TCP context descriptor.
 1.1.4.2 29-Aug-2002  gehenna catch up with -current.
 1.1.4.1 15-Jul-2002  gehenna catch up with -current.
 1.1.2.5 11-Nov-2002  nathanw Catch up to -current
 1.1.2.4 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.1 28-Mar-2002  nathanw file if_wmreg.h was added on branch nathanw_sa on 2002-04-01 07:46:28 +0000
 1.5.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.4 19-Oct-2004  skrll Sync with HEAD
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.4.3 12-Jan-2005  he Pull up revision 1.13 (requested by thorpej in ticket #898):
Largest Tx descriptor buffer size is actually 4K.
 1.10.4.2 08-Jan-2005  jdc Fix pull up merge error.
Pointed out by Martin J. Laubach.
 1.10.4.1 07-Jan-2005  jdc Pull up revision 1.12 (requested by thorpej in ticket #897)

- Add some useful constants related to the Packet Buffer Allocation
register.
- Add the Receive and Transmit Data FIFO registers.
 1.10.2.2 08-Jan-2005  jdc Fix pull up merge error.
Pointed out by Martin J. Laubach.
 1.10.2.1 07-Jan-2005  jdc Pull up revision 1.12 (requested by thorpej in ticket #897)

- Add some useful constants related to the Packet Buffer Allocation
register.
- Add the Receive and Transmit Data FIFO registers.
 1.13.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.4.1 29-Apr-2005  kent sync with -current
 1.14.6.4 21-Jan-2008  yamt sync with head
 1.14.6.3 03-Sep-2007  yamt sync with head.
 1.14.6.2 30-Dec-2006  yamt sync with head.
 1.14.6.1 21-Jun-2006  yamt sync with head.
 1.14.4.4 19-Nov-2007  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1863):
sys/dev/pci/if_wm.c 1.137-1.138,1.141,1.144-1.146
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893 via patch
share/man/man4/wm.4 1.18-1.19
Fix typo.
Fix EEPROM reload sequence.
Add ICH9 support.
Workaround for 82541 Errata 29 and 82547 Errata 28:
These devices have to reset the PHY before reset the MAC.
Reported and tested by salo.
 1.14.4.3 14-Oct-2007  riz Pull up following revision(s) (requested by bouyer in ticket #1770):
share/man/man4/wm.4: revision 1.17
sys/dev/pci/if_wmreg.h: revision 1.22
sys/dev/pci/if_wm.c: revision 1.139 via patch
sys/dev/pci/if_wm.c: revision 1.140 via patch
sys/dev/pci/pcidevs: patch
Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller
tested with: Intel i82801H (AMT) LAN Controller, rev. 2
Restore $NetBSD$ tag.
Note ICH8 LAN support.
 1.14.4.2 31-Mar-2007  bouyer pullup the following revisions (requested by msaitoh in ticket 1681):
sys/dev/pci/if_wm.c 1.104-1.105, 1.116-1.121,
1.127,1.133-1.134 via patch
sys/dev/pci/if_wmreg.h 1.17-1.20
sys/dev/pci/pcidevs patch
sys/dev/mii/igphy.c 1.11
sys/dev/mii/makphy.c 1.20, 1.23
sys/dev/mii/ikphy.c patch
sys/dev/mii/ikphyreg.h patch
sys/dev/mii/miidevs 1.68
sys/dev/mii/files.mii 1.39
sys/arch/i386/conf/GENERIC 1.788-1.789 via patch
sys/arch/i386/conf/GENERIC.MPACPI patch
sys/arch/i386/conf/GENERIC_LAPTOP 1.209 via patch
sys/arch/i386/conf/INSTALL 1.291 via patch
sys/arch/i386/conf/INSTALL_LAPTOP 1.104 via patch
sys/arch/i386/conf/XEN2_DOM0 1.13 via patch
share/man/man4/wm.4 1.14-1.16
Add support for many cards (include PCI-express based chips).
Many bug fixes about auto negotiations (PR#30078, PR#30490,
PR#30906, PR#33429 and PR#35386).
Fix media link issues with fiber-based card (PR#35797).
 1.14.4.1 28-Aug-2005  tron Pull up following revision(s) (requested by yamt in ticket #699):
sys/dev/pci/if_wmreg.h: revision 1.15
fix a typo(?) in an unused macro. (WRX_ST_ISXM -> WRX_ST_IXSM)
 1.16.14.1 19-Jun-2006  chap Sync with head.
 1.16.8.1 26-Jun-2006  yamt sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.19.8.2 10-Dec-2006  yamt sync with head.
 1.19.8.1 22-Oct-2006  yamt sync with head
 1.19.6.1 18-Nov-2006  ad Sync with head.
 1.21.10.1 11-Jul-2007  mjf Sync with head.
 1.21.8.2 09-Oct-2007  ad Sync with head.
 1.21.8.1 27-May-2007  ad Sync with head.
 1.21.4.1 07-May-2007  yamt sync with head.
 1.21.2.2 29-Aug-2007  liamjfoy Pull up following revision(s) (requested by masanobu in ticket #850):

sys/dev/pci/if_wm.c 1.137
sys/dev/pci/if_wm.c 1.138
sys/dev/pci/if_wm.c 1.141
sys/dev/pci/if_wm.c 1.144
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphy.c 1.12
sys/dev/mii/miidevs 1.72
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/wm.4 1.18

Fix for 82541 and 82547's reset bug.
Modify wm_reset() to make some device stable.
Add ICH9 support to wm.
Add I82566 support to igphy.

Pulled done via patch.
 1.21.2.1 03-May-2007  snj branches: 1.21.2.1.2;
Pull up following revision(s) (requested by bouyer in ticket #598):
share/man/man4/wm.4: revision 1.17
sys/dev/pci/if_wmreg.h: revision 1.22
doc/CHANGES: revision 1.836
sys/dev/pci/if_wm.c: revision 1.139
sys/dev/pci/if_wm.c: revision 1.140
Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller
tested with: Intel i82801H (AMT) LAN Controller, rev. 2
Restore $NetBSD$ tag.
Note ICH8 LAN support.
Note ICH8 LAN support.
 1.21.2.1.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.22.8.2 09-Jan-2008  matt sync with HEAD
 1.22.8.1 06-Nov-2007  matt sync with HEAD
 1.22.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.22.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.23.12.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.8.1 26-Dec-2007  ad Sync with head.
 1.23.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.24.26.1 19-Jul-2009  snj branches: 1.24.26.1.2;
Pull up following revision(s) (requested by msaitoh in ticket #862):
sys/dev/pci/if_wm.c: revisions 1.168, 1.170, and 1.173 via patch
sys/dev/pci/if_wmreg.h: revision 1.27
Fixes serious three bugs.
1) On i82563, the em driver says that the ready bit in the MDIC
register may be incorrectly set. Insert delay(200) like the em driver.
Fixes PR#41014
2) Add workaround for 82543GC. We need to force speed and duplex on
the MAC equal to what the PHY speed and duplex configuration is.
Fixes PR#36430.
3) Fix many problems and panic on TBI's cards (includes PR#32009).
 1.24.26.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.24.24.2 23-Jul-2009  jym Sync with HEAD.
 1.24.24.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.20.9 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1962):
sys/dev/pci/if_wm.c: revisions 1.259-1.266, 1.269, 1.271, 1.273-1.274, 1.277-1.278, 1.282, 1.284-1.285, 1.287, 1.290, 1.294, 1.297-1.298, 1.300-1.301, 1.304-1.307, 1.310, 1.312-1.314, 1.316 via patch
sys/dev/pci/if_wmreg.c: revisions 1.54-1.57, 1.59-1.60, 1.62, 1.64-1.66 via patch
sys/dev/pci/if_wmvar.c: revisions 1.17, 1.20-1.21 via patch
sys/dev/pci/pcidevs: revisions 1.1172, 1.1195, 1.1201 via patch
- Fix "MDIC write error" bug for 82574 and 82583. For those chips, the
semaphore must be released after chip reset. Found and tested by
Mark Davies.
- Fix BMC related bugs.
- Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with
Asus P8P67 Deluxe motherboard and tested by jnemeth.
- Add support for I354 DH89xxCC and some new I218 devices.
- Fix definition of CTRL_GIO_M_DIS bit.
- Insert completion barrier between register write and delay().
- Bump max TX DMA size to avoid pathological condition with TSO. From dyoung.
- Fix semaphore related bugs.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880).
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- It's not required to print "failed to detect NVM bank" with
aprint_error_dev(). Use DPRINTF(). Same as {Free,Open}BSD.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.
- Delete 82580ER related code. It was from FreeBSD and was removed
in r203049.
- Remove extra debug message.
- Remove unused variable.
- Remove a duplicated error message.
- Cleanup comments.
- Fix debug message.
 1.24.20.8 07-Sep-2013  bouyer sys/dev/pci/if_wm.c 1.246-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16
sys/dev/pci/pcidevs 1.1152-1.1153
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Add comments, fix some comments, use macros and remove trailing
whitespaces.
[msaitoh, ticket #1867]
 1.24.20.7 19-Jun-2013  bouyer Pullup the following revisions via patch, requested by msaitoh in ticket #1850:
sys/dev/pci/if_wm.c 1.201, 1.203-1.204,
1.207-1.212, 1.215,
1.217-1.218, 1.220-1.223,
1.228, 1.232-245
sys/dev/pci/if_wmreg.h 1.40-1.45, 1.47-1.48
sys/dev/pci/if_wmvar.h 1.11-1.13
sys/dev/pci/pcidevs 1.1074, 1.1077, 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.6
sys/dev/mii/ihphy.c 1.1-1.2
sys/dev/mii/ihphyreg.h 1.1
sys/dev/mii/inbmphyreg.h 1.3
sys/dev/mii/files.mii 1.47 via patch
sys/dev/mii/miidevs 1.97 and 1.100
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/arch/i386/conf/ALL 1.280
sys/arch/i386/conf/GENERIC 1.1001
sys/arch/i386/conf/INSTALL_FLOPPY 1.11
sys/arch/i386/conf/XEN2_DOM0 patch
sys/arch/amd64/conf/GENERIC 1.293
sys/arch/amd64/conf/XEN3_DOM0 1.61
share/man/man4/wm.4 1.21-1.24

Apply almost all fixes and improvements from netbsd-6 except for
the rev. 1.196's iqdrops' change.

- Add the detach code.
- Add code for WOL, ASF, IPMI and Intel AMT. WOL is disabled by default
- Add Yet another workaround for ICH8.
- 82576 is dual port, so check the FUNCID and increment the MAC address for
the 2nd port.
- Fix the names of 82577L[MC] LAN controllers (for mobile).
- Fix CTRL_EXT_SWDPIN() and CTRL_EXT_SWDPIO() macros. The bit order of the
SW definable pin is not 6543 but 3654!!!
- Rewrite the code to read MAC address from eeprom.
- Add 82580 support.
- 82571 quirk. Only 82571 shares port 0 of EEMNGCTL_CFGDONE.
- The document says that the TDH register must be set after
TCL.EN is set on 82575 and newer devices.
- Fix some register names. No functional change.
- Omit U+00AE "REGISTERED SIGN" in a product name due to its non-ASCII nature.
- Stop wm(4) from needlessly resetting when you add or delete a vlan(4).
- Fix MAC address check on 8257[156] and 80003 case. Some cards have non 0xffff
pointer but those don't use alternative MAC address in reality. So we check
whether the broadcast bit is set or not like Intel's e1000 driver.
Fixes PR kern/44072 reported by Jean-Yves Moulin.
- Add PCH2(and 82579) support. Fixes PR#46487
- Add yet another 82567V support.
- Add ICH10+HANKSVILL support.
- Add support Intel I350 Ethernet.
- Make vlan and all ip/ip6 checksum offload work for the I350.
- Fix compile error with WM_DEBUG.
- Fix a bug that PHY isn't set to low-power mode on PCH and PCH2.
- Add WM_DEBUG_NVM. If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
- Skip 64bit BAR correctly.
- Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
- Use 82580(and I350) specific PHY read/write functions. Fixes PR#47542.
- Style fix. Fix typo in comment. Fix comments. Add comments.
 1.24.20.6 05-Jan-2012  sborrill Pull up the following revisions(s) (requested by dyoung in ticket #1703):
sys/dev/pci/if_wmreg.h: revision 1.46

Mark all of the wm(4) Rx descriptor fields 'volatile' so that the compiler
will not re-order accesses. Some versions of GCC (such as one in NetBSD
5.x) definitely do re-order reads from these fields if they're not
marked volatile.
 1.24.20.5 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1358):
sys/dev/pci/if_wm.c 1.196-1.199,1.202,1.205
sys/dev/pci/if_wmvar.h 1.9
sys/dev/pci/if_wmreg.h 1.36-1.39
sys/dev/pci/pcireg.h 1.61-1.64
sys/dev/pci/pcidevs 1.1023
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
mii/igphy.c 1.21
mii/igphyvar.h 1.1
mii/inbmphyreg.h 1.2

- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
- Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
- (pcireg.h) Add PCIe config register definitions.
- Note that the changes to count Missed packet (rx fifo overflow) and Receive
no buffers (rx ring full) into iqdrops in rev. 1.196 of if_wm.c is not
pulled up.
 1.24.20.4 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c 1.184-1.192, 1.194
sys/dev/pci/if_wmreg.h 1.29-1.35
sys/dev/pci/if_wmvar.h 1.5-1.8
sys/dev/pci/pcidevs 1.1006,1.1009-1.1010, 1.1012-1.1013 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.5
sys/dev/mii/inbmphyreg.h 1.1

- Add support for i82583V.
- Add some ICH9 and ICH10 devices.
- Add support for PCH.
- Fix the bug that ICH9 can't found a PHY. Fixes PR#42237
- Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
- Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
- Fix the checking of jumbo frame function
- Remove the extra macro definition for the offset 0x1a in EEPROM.
- Add missing break in wm_reset()...
- Fix the offset of WMREG_PBS...
- Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. It seems that we have to
do the same work for ICH9.
- Fixes the rx stall problem on 82578 by MANY workaround code. We need more
work for 82577.
 1.24.20.3 23-Dec-2009  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: 1.176-1.179, 1.181-1.183
sys/dev/pci/if_wmreg.h: 1.28
sys/dev/pci/if_wmvar.h: 1.1-1.4
sys/dev/mii/igphy.c: 1.18-1.20 via patch

Many bugfixes:
- Some fixes for i80003 and ICH{8,9,10} from e1000 driver and document:
- Add setting for KABGTXD register for ICH{8,9,10}.
- ICH9 and ICH10 has no FCAL, FCAH and FCT like ICH8.
- Add special setting for FCTTV and TCTL_EXT register for i80003
- The special setting for TIPG is only for i80003.
- Some of kumeran settings are only for i80003's bugs.
- Add some ICH10 fixes.
- Fix the bug that another lock mechanism is used to access Kumeran
registers on i80003 and ICHs.
- Fix yet another i80003 ONLY workaround. The code to modifing TIPG
register is only for i80003.
- Set the Re-Transmit on Late Collision(RTLC) flag for all devices.
- Fix a typo in a printf message.
- If the difference bettween last flag and new flag is only IFF_PROMISC
or IFF_ALLMULTI, set multicast filter only to prevent link down.
Tested by Mark Davies and me. Fixes PR#29126 for wm.
- Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
- Fix igphy's 82566 support.
- Patch for the DSP code is only for 8254[17] and we have to apply
the different patches between rev. 1 and rev. 2.
- The workaround for analog fuse is only for 82547 rev. 1.
- The workaround for smartspeed is only for 8254[17]
- Sync with Intel's original em driver:
- Check PCI-X mode as e1000 driver.
- Add dspcode for igp3 and use it when the EEPROM isn't available.
- Add some delays.
- Stop the PHY transmitter before patching the DSP code and
restart it after writing.
- Save and restore register 0x2f5b.
 1.24.20.2 21-May-2009  snj Pull up following revision(s) (requested by bouyer in ticket #711):
sys/dev/pci/pcidevs: revisions 1.975, 1.981, 1.982 via patch
sys/dev/pci/if_wm.c: revisions 1.164, 1.167, 1.173, 1.174 via patch
sys/dev/pci/if_wmreg.h: revisions 1.25, 1.27 via patch
Add Intel 82567LM_3 ethernet
--
Add i82567LM-3
--
add i82567LF-3 LAN Controller
--
add an entry for 82567LF-3.
fix the register access for ICH10DO.
--
Fix about TBI mode. This fix doesn't influence MII mode.
--
- Fix panic in mediachange.
- Fix SWDPIN(1)'s polarity on some chips.
- Fix flow control stuff (includes PR#32009).
- Stop RXCFG storm. It ocours easily.
- And more fix about autonego.
--
add 82801J_D_BM_LF (ICH10)
--
Reload sc_ctrl in wm_reset().
Add an ICH10 entry.
Remove some obsolete comments.
 1.24.20.1 03-May-2009  snj Pull up following revision(s) (requested by spz in ticket #621):
sys/dev/pci/if_wm.c: revisions 1.168, 1.169 via patch
sys/dev/pci/if_wmreg.h: revision 1.26 via patch
On i82563, the em driver says that the ready bit in the MDIC register may be
incorrectly set. Insert delay(200) like the em driver.
--
Examine the management mode and mark DRV_LOAD (for ICH{8,9,10},80003,
8257{1,2,3,4}).
Add some error's printf().
Make the bank detect routine into the function.
 1.24.18.1 28-Apr-2009  skrll Sync with HEAD.
 1.24.10.4 11-Aug-2010  yamt sync with head.
 1.24.10.3 11-Mar-2010  yamt sync with head
 1.24.10.2 18-Jul-2009  yamt sync with head.
 1.24.10.1 04-May-2009  yamt sync with head.
 1.36.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.40.2.3 31-May-2011  rmind sync with head
 1.40.2.2 05-Mar-2011  rmind sync with head
 1.40.2.1 03-Jul-2010  rmind sync with head
 1.44.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.8.2 02-Jun-2012  mrg sync to latest -current.
 1.45.8.1 18-Feb-2012  mrg merge to -current.
 1.45.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.4.2 30-Oct-2012  yamt sync with head
 1.45.4.1 17-Apr-2012  yamt sync with head
 1.46.2.9 06-May-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1366):
sys/dev/pci/if_wm.c: 1.281, 1.318, 1.320, 1.324-1.332, 1.334, 1.336, 1.343-1.344, 1.347-1.348, 1.350, 1.376-1.382, 1.386-1.387, 1.389 via patch
sys/dev/pci/if_wmreg.h: 1.68-1.70, 1.73-1.77, 1.79-1.80, 1.82, 1.86-1.88 via patch
sys/dev/pci/if_wmvar.h: 1.22-1.23, 1.25-1.30 via patch
sys/dev/mii/igphy.c: 1.25
sys/dev/mii/ukphy.c: 1.48
Sync wm(4) as of if_wm.c rev 1.389 except SERDES, MSI/MSI-X, multiqueue
and NET_MPSAFE:
- Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is more
than 4096. Almost the same as other OSes.
- For 82576 and newer devices, the PBA register is deleted. Don't write
PBA for those chips. Also change the calculation of RX packet buffer
size in new way.
- Print NVM image version and option ROM version.
- Add workaround for I210 Errata 25 and I211 Errata 10 (PLL bug). This
workaround is required if the NVM image version < 3.25.
- Fix a bug that wm_detach() didn't unmap the FHASH's area. Now
"drvctl -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
- Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX
packets" and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit.
The NVM Image version 2.1.4 and newer have this workaround.
- Check PHY type correctly. This change is required to use igphy(4)
device correctly.
- Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH*
too.
- Call wm_get_hw_control() correctly. This change fixes a bug that some
AMT based systems doesn't linkup at 1000BaseT. The problem was
observed on HP Compaq dc7700. A lot of fixes have been done for wm(4)
and igphy(4), so now PR#44893 should be fixed.
- Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT. It's required to
check the existence of AMT correctly.
- Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in
wm_reset() on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix
the behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change
might fix a problem that PHY's read/write functions can't get
semaphore.
- On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed
down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS
sets this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the
function checks the status correctly but it causes linkdown up to 10
times, so it's disabled for the time being.
- PR/50527: David Binderman: Fix impossible code. Odd offsets need
special treatment.
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Use sc->sc_itr instead of hard-coded number.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function
acts as mii_tick().
- ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition has not used yet.
- Add ACK data Disable bit's definition (not used yet).
- PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any
effect by default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when
WM_WOL is defined and it's disabled by default.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it
returns bool. No functional change.
- Reorder function definitions and macro definitions. No functional
change.
- Fix comment. Add comment. Update comment.
- KNF.
 1.46.2.8 16-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c: revision 1.312 via patch
sys/dev/pci/if_wmreg.h: revision 1.66 via patch
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Add comment.
- Fix typo in comment.
 1.46.2.7 04-Dec-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: revisions 1.271, 1.273-1.274, 1.277-1.278,
1.280, 1.282, 1.284-1.285, 1.287,
1.293-1.294, 1.297-1.298,
1.300-1.301, 1.305-1.307 via patch
sys/dev/pci/if_wmreg.h: revisions 1.57-1.62, 1.64-1.65 via patch
sys/dev/pci/if_wmvar.h: revisions 1.19, 1.21 via patch
- Acquire SW semaphore in wm_get_swsm_semaphore().
- Fix some bugs realted to semaphore. This change fixes a problem which
was exposed in if_wm.c rev. 1.271. Tested by riastradh@.
- Clear the SMBI bit in SWSM register before accessing NVM and PHY in
wm_attach(). Same as FreeBSD.
- Fix a bug that 82573 doesn't put the hardware semaphore. Same as
FreeBSD r256200.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880). Tested with 82543GC, 82544EI,
82545EM, 82546GB 82571EB and 82572EI fiber cards.
- Don't use the RXCFG interrupt. It's not required and the interrupt is very
heavy (a lot of interrupts). Same as {Free,Open}BSD.
- Modify wm_tbi_mediachange() to be close to em_setup_fiber_serdes_link()
of {Free,Open}BSD. At least, don't forget to set duplex setting.
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Don't check SWSM_SMBI bit if WM_F_LOCK_SWSM isn't set. Fix a problem when
using vmware with e1000"e". With e1000e which is regarded as 82574L,
wm_gmii_init() fails with "could not acquire SWSM SMBI" message without
this change. This problem doesn't occur with real 82574L card.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Calculate NVM word size correctly.
- Determine timeout value based on the NVM word size.
- It's not required to print "failed to detect NVM bank" message.
Only print while debugging. Same as {Free,Open}BSD.
- Add some new I218 devices.
- Delete 82580ER related code. It was from FreeBSD and was removed in r203049.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Move some NVM related macros from if_wm.c to if_wmreg.h.
- Sort definitions in if_wmreg.h
- move NVM related values to the bottom.
- sort in register's address' order.
- Simplify wm_read_mac_addr().
- Fix debug message.
- Add missing prototypes.
- Rename some functions for consistency and clarify.
- Rename some macros for consistency.
- Remove a duplicated error message.
- Fix typo in comment.
- Cleanup comments.
- KNF.
 1.46.2.6 09-Nov-2014  martin Pullup the following revisions, requested by msaitoh in ticket #1188:
sys/dev/pci/pcidevs 1.1172
sys/dev/pci/if_wm.c 1.263-1.266 via patch
sys/dev/pci/if_wmreg.h 1.55-1.56
sys/dev/pci/if_wmvar.h 1.17
share/man/man4/wm.4 1.26-1.27 and 1.29 via patch

- Add I354 support.
- Insert completion barrier between register write and delay().
- Fix the definition of CTRL_GIO_M_DIS. This bit is not bit 3 but bit 2.
- Cleanup
 1.46.2.5 29-Jul-2013  jdc Pull up revisions:
src/sys/dev/pci/if_wm.c revisions 1.259,1.260,1.261,1.262
src/sys/dev/pci/if_wmreg.h revision 1.54
(requested by msaitoh in ticket #918).

Fix "MDIC write error" bug for 82574 and 82583. For those chips, the semaphore
must be released after chip reset. Found and tested by Mark Davies.

Sync the wm_enable_mng_pass_thru() function with FreeBSD. Don't check
MANC_EN_MAC_ADDR_FILTER bit. Add 82574 and 82583 specific check. This
modification may change the setting of WM_F_HAS_MANAGE flag on some machines.

Sync the wm_release_manageablilty() fucntion with FreeBSD. Set MANC_ARP_EN.
This change enables HW ARP function when entering suspend.

When the chip is 82580(ER) or I350, set WM_F_ASF_FIRMWARE_PRES flag and
check for the WM_F_ARC_SUBSYS_VALID flag. Same as FreeBSD.

Move the location of wm_check_mng_mode() and wm_get_wakeup() in wm_attach().
Those functions access EEPROM, so they have to call after identifying EEPROM
access type. This modification may change the behavior of BMC(IPMI).

Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with Asus P8P67
Deluxe motherboard and tested by jnemeth.
 1.46.2.4 14-Jul-2013  riz Apply changes (requested by msaitoh in ticket #907):

sys/dev/pci/if_wm.c 1.238, 1.244-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.50-1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16

Various fixes to wm(4):
Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Change style, add comments, fix some comments, use macros and
remove trailing whitespaces.
[msaitoh, ticket #907]
 1.46.2.3 18-Feb-2013  riz Pull up following revision(s) (requested by msaitoh in ticket #824):
sys/dev/pci/if_wm.c: revision 1.240
sys/dev/pci/if_wm.c: revision 1.241
sys/dev/pci/if_wm.c: revision 1.242
sys/dev/pci/if_wmreg.h: revision 1.49
- Add WM_DEBUG_NVM.
- If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
Skip 64bit BAR correctly. I don't know if this bug causes a real problem.
Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
 1.46.2.2 03-Sep-2012  riz Pull up following revision(s) (requested by bouyer in ticket #534):
sys/dev/pci/if_wmreg.h: revision 1.48
sys/dev/pci/if_wm.c: revision 1.232
sys/dev/pci/if_wm.c: revision 1.233
sys/dev/pci/if_wm.c: revision 1.234
Make vlan and all ip/ip6 checksum offload work for the I350.
On newer devices, when using the legacy TX descriptors, vlan-related flags
that were set on the last descriptor of a packet have to be set on the
first one.
For tso/checksum offloads, a new "advanced" descriptor format has to be
used.
Change wcd_txdescs to a union defining all types of descriptors (they
are all 16-bytes wide).
Define a new tx function wm_nq_start(), which handle newer devices.
There is some code duplication with wm_start(), but adding support to
the existing wm_start() would make it a if () {} else {} maze. This also
allows to get rid of some workaround for older chips that are not needed
here.
Use wm_nq_start() instead of wm_start() for the I350 (this should probably
be for all WM_F_NEWQUEUE devices, but I have no hardware but the I350 to
test). Call ifp->if_start() instead of wm_start() where is matters.
Tested on a I350, and a i80003 (which use the old format), both with and
without vlans, with and without checksum offloads.
Enable VLAN hardware tagging on all chips that have the new queue mechanism.
Tested with 82575{EB,GB}, 82576, 82580, I350 and ICH9.
Shut up gcc about some uninitialized variables.
 1.46.2.1 28-Jun-2012  riz branches: 1.46.2.1.2;
Pull up following revision(s) (requested by msaitoh in ticket #362):
sys/dev/pci/if_wm.c 1.228
sys/dev/pci/if_wmreg.h 1.47
sys/dev/pci/if_wmvar.h 1.13
sys/dev/pci/pcidevs 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
share/man/man4/wm.4 1.22-1.25

Add support for Intel I350 Ethernet.
Update document.
 1.46.2.1.2.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.48.2.4 03-Dec-2017  jdolecek update from HEAD
 1.48.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.2.2 23-Jun-2013  tls resync from head
 1.48.2.1 25-Feb-2013  tls resync with head
 1.54.2.1 18-May-2014  rmind sync with head
 1.55.2.1 10-Aug-2014  tls Rebase.
 1.60.2.10 09-Nov-2018  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1648):
sys/dev/mii/inbmphyreg.h 1.11
sys/dev/pci/if_wm.c 1.586-1.588, 1.590-1.596 via patch
sys/dev/pci/if_wmreg.h 1.108

- rename tu event counter to txunderrun.
- Try m_defrag() to reduce the number of DMA segment if bus_dmamap_load_mbuf()
returned EFBIG. When m_defrag() is called, txqNNdefrag event counter is
incremented. If the 2nd try of bus_dmamap_load_mbuf() failed, txqNNtoomanyseg
event counter is incremented.
- Reduce the max number of DMA segments from 256 to 64 (it's the same value
as other BSD's (EM_MAX_SCATTER) and more than before if_wm.c rev. 1.75's
value (40)) because we do m_defrag() now.
- 82574 and newer document says the status field has neither EC
(Excessive Collision) bit nor LC (Late Collision) bit (reserved), so
don't check the bit.
- Add workaround for DMA hang problem which result in TX device timeout
on PCH_LPT with I218. Same as FreeBSD and Linux. This workaround is
only for device ID 0x155a, 0x15a2, 0x1559 and 0x15a3.
- Fix a PCH2 specific bug that wrong PHY register value can be read
when boot. Same as FreeBSD and Linux.
- After writing MDIC register, don't read quickly the same register but
do delay(50). Same as other OSes.
- Add missing wm_gate_hw_phy_config_ich8lan(false) in
wm_phy_post_reset() on PCH2. wm_gate_hw_phy_config_ich8lan(true) is
called in wm_reset(), so wm_gate_hw_phy_config_ich8lan(false) should
be called after reset in wm_phy_post_reset().
- On PCH2, set the phy config counter to 50msec after (PHY) reset.
- KNF & Use macro.
 1.60.2.9 11-Aug-2018  martin Pull up the following, requested by msaitoh in ticket #1628:

share/man/man4/wm.4 1.40 via patch
sys/dev/mii/ihphyreg.h 1.2
sys/dev/mii/inbmphyreg.h 1.10
sys/dev/pci/if_wm.c 1.504, 1.506, 1.510-1.535, 1.539-1.540, 1.546, 1.548, 1.551-1.552, 1.558, 1.565-1.573, 1.575, 1.579, 1.582, 1.584 via patch
sys/dev/pci/if_wmreg.h 1.99-1.103, 1.106-1.107 via patch
sys/dev/pci/if_wmvar.h 1.34-1.39 via patch
sys/dev/pci/pcidevs 1.1327 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/pci/pcireg.h patch

Sync wm(4) up to 2018/08/08 except MSI/MSI-X and NET_MPSAFE:
- remove extra "+"
- Fix a bug that non-GMII devices don't send a routing message when
the link status is changed.
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset(). Same as
other OSes.
- If a interrupt is a spurious interrupt, don't print debug message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Print sc_flags with snprintb().
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Add CSR_WRITE_FLUSH() after writing WMREG_CTRL in
wm_gmii_mediachange().
- Add missing "else" in wm_nvm_release().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for wrokaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if
it's required.
- If TX is not required to flush, RX is also not required to flush
in wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset(). Some
flags and callback function are required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Use new nvm.{acquire,release}() for semaphore.
- Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required
for these functions to use the same API. So,
- Change return value as error code.
- Change register value from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally on I21[01]". PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
sc->sc_nvm_wordsize before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Print NVM offset and word count when EERD polling failed.
- On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
- 82583 supports jumbo frame. Fixes PR#52773 reported by
Shinichi Doyashiki.
- Fix typo in comment. Reported by Shinichi Doyashiki in PR#52885.
- Add ASPM workaround for 8257[1234] and 82583 to prevent device
timeout or hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
- CID-1427779: Fix uninitialized variables.
- Fix a bug that wm_pll_workaround_i210() is not called when
a) Chip is I211 or b) Chip is I210 and it uses iNVM (not FLASH).
- Do wm_reset_mdicnfg_82580() on 82580 only.
- Fix FLASH access on PCH_SPT and newer. Their FLASH access should be
done by 32bit. Especially for ICH_FLASH_HSFCTL register, it's located
at 0x0006, so it must be accessed via ICH_FLASH_HSFSTS(0x0004) and
use shift or mask.
- Make wm_nvm_valid_bank_detect_ich8lan() the same as other OSes.
- If the extended configuration size in the EXTCNFSIZE register is 0,
don't continue in wm_init_lcd_from_nvm().
- Add PCH_CNP support (I219 with Intel 300 series chipset).
- Enable I219 support.
- I354 uses an external PHY, so don't use wm_set_eee_i350().
- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber.
- Fix a bug that 82542 misunderstand fiber's signal detection.
- Add debug printf()s.
- Update comment.
- Rename functions and variables.
- Add diagnostic code.
- Sort registers.
- Lowercase hexadecimal values.
- KNF.
 1.60.2.8 09-Mar-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #1372):
sys/dev/pci/if_wm.c: revisions 1.462, 1.464-1.465 1.474 via patch
sys/dev/pci/if_wmreg.h: revision 1.97
sys/dev/pci/if_wmvar.h: revision 1.33
- Set IPV6EXDIS bit in RFCTL register because of an Errata on 82575 and
newer devices.
- Linux and FreeBSD defines 0x10f5 as E1000_DEV_ID_ICH9_IGP_M_AMT. In
reality, This is not IGP but BM. Add new case to identify PHY type
device. Fixes PR#51924 reported byJarle Greipsland.
- Use new wm_gmii_setup_phytype() function to setup sc_phytype and
mii_{read|write}reg. This change improves detection of PHY type.
- Fix typo in comment.
 1.60.2.7 18-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1327):
sys/dev/pci/if_wm.c: revision 1.457
sys/dev/pci/if_wmreg.h: revision 1.94
- Change to use 2500Base-KX correctly on C2000(I354). It worked, but the
output of ifconfig and if_baudrate was not good. Tested by nils@:
- The STATUS_TBIMODE bit in the STATUS register is deleted since 82575,
so check for 82575 and newer first and then check for old devices.
- Check the 2P5_SKU and 2P5_SKU_OVER bit for KX.
- Set IFM_2500_SX instead of IFM_1000_SX for 2.5G.
- Check SERDES's speed directly from the PCS layer (PCS_LSTS register) for old
devices.
- Style fix.
 1.60.2.6 12-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1302):
sys/dev/mii/igphyreg.h: revisions 1.7-1.10
sys/dev/mii/ikphyreg.h: revisions 1.3
sys/dev/mii/inbmphyreg.h: revisions 1.4-1.9
sys/dev/mii/mii.h: revisions 1.19-1.20
sys/dev/pci/if_wm.c: revisions 1.390, 1.392-1.395, 1.397, 1.419-1.425, 1.427-1.428, 1.430-1.435, 1.437-1.453 via patch
sys/dev/pci/if_wmreg.: revisions 1.89-1.93 via patch
sys/dev/pci/if_wmvar.h: revisions 1.31-1.32
Update wm(4) up to if_wm.c rev. 1.453 except MSI/MSI-X, multiqueue and
NET_MPSAFE:
- Add I219 support. It's not stable so it's disabled by default.
- wm_gate_hw_phy_config_ich8lan() is for younger than PCH2.
- Drop the host wakeup bit after resetting PHY on PCH and newer
devices.
- Increase delay while toggling LANPHYPC
- Move call of wm_reset() in wm_attach() after setting PHY and NVM
related flags because those flags are used in wm_reset().
- Use mutex for NVM access on ICH8 and newer devices. Same as FreeBSD.
- Rewrite PHY related lock stuff. Almost the same as FreeBSD.
This change will fix a bug that PHY read/write fail on some cases.
- Increase delay in wm_phy_resetisblocked(). Same as FreeBSD.
- Use semaphore in wm_hv_phy_workaround_ich8lan() and
wm_k1_gig_workaround_hv()
- Use wm_gii_mdic_readreg/writereg() in wm_access_phy_wakeup_reg_bm()
because these functions are called with taking lock.
- 82567V_3 is BME1000_E_2(bm). Tested with Advantech AIMB-212 1st
Ethernet port.
- Use wm_gmii_82544_{read,write}reg() on non-82567 ICH8, 9 and 10.
- Remove an 82578 workaround which was for PCH rev < 3. FreeBSD
removed this workaround in r228386.
- Add an 82578 workaround which is for PHY rev < 2. From FreeBSD and
Linux.
- Fix wm(4) input drop packet counter. WMREG_RNBC is incremented when
there is no available buffers in host memory. However, ethernet
controller can receive packets in such case if there is space in
phy's FIFO. That is, ethernet controller drops packet only if there
is no available buffers *and* there is no space in phy's FIFO. So,
the number of dropped packets should be added WMREG_MPC only.
- Use MII_ADDRMASK.
- Define WMPHY_I217, WMPHY_VF and WMPHY_210.
- Use BME1000_PHY_PAGE_SELECT in wm_gmii_bm_{read,write}reg(). This
change has no effect because GG82563_PHY_PAGE_SELECT and
BME1000_PHY_PAGE_SELECT have the same value.
- Fix PHY access on 82567(ICH8 or ICH10), 82574 and 82583:
- Use wm_gmii_bm_{read,write}reg() on 82574 and 82573.
- Issue page select correctly on BM PHYs.
- Fix workaround which did dummy read BM_WUC register. This code was
changed to drop BM_WUC_HOST_WU_BIT of BM_PROT_GEN_CFG register in
FreeBSD r228386. The code was added rev. 1.149, but the location was
not the best.
- wm_gmii_hv_{read/write}reg*(): USE PHY address 1 for some special
registers.
- Add check code for an 82578 workaround. Not completed yet.
- wm_release_hw_control(): Remove extra line. No any effect.
- Add "10/100" into non-gigabit devices' name.
- Call wm_enable_wakeup() in wm_detach() and wm_suspend(). Now wake on
lan works on Thinkpad X61(ICH8).
- Fix wm_access_phy_wakeup_reg_bm(). This change has no effect because
this function is used for WUC register and our driver currenlty
doesn't access to it.
- Call wm_enable_phy_wakeup() on PCH2 and newer, too. Now these devices
can do WOL. Tested with Thinkpad X220(PCH2).
- Set CTRL_MEHE correctly (PCH_{LPT,SPT} only).
- Add three workarounds for PCH_{LPT,SPT}.
- Fix a bug that 8257[56], 82580, I35[04] and I21[01] didn't use
wm_{get,release}_hw_control() correctly.
- Sync wm_smbustopci() with Linux and FreeBSD. This change effects PCH
and newer devices.
- Move the location of wm_smbustopci() call.
- Fix flag check in wm_get_wakeup()
- 8254[17]* and 8257[124] should not set WM_F_ARC_SUBSYS_VALID.
- Add missing WM_T_82541_2 and WM_T_82547_2.
- Fix WOL related setting of the WUC register for other than PCH* in
wm_enable_wakeup(). Tested with 82567V(ICH8) and 82583V.
- Use common MII_ADDRMASK.
- igphy(4): No binary change:
- s/IGPPHY/IGPHY/
- Fix the definition of PLHR_VALID_CHANNEL_*
- Fix the definition of MSE_CHANNEL_*
- Add MII_IGPHY_POWER_MGMT.
- Add some KASSERT.
- Add comment. Modify comment.
- Add debug code.
 1.60.2.5 26-Feb-2016  snj branches: 1.60.2.5.2;
Pull up following revision(s) (requested by msaitoh in ticket #1102):
sys/dev/mii/igphy.c: 1.25
sys/dev/mii/ukphy.c: 1.48
sys/dev/pci/if_wm.c: revisions 1.308, 1.318, 1.320, 1.324-1.332, 1.334, 1.336, 1.343-1.344, 1.347-1.348, 1.350, 1.376-1.382, 1.386-1.389 via patch
sys/dev/pci/if_wmreg.h: revisions 1.68-1.70, 1.73-1.77, 1.79-1.80, 1.82, 1.86-1.88 via patch
sys/dev/pci/if_wmvar.h: revisions 1.22-1.23, 1.25-1.30 via patch
Sync wm(4) as of if_wm.c rev 1.389 except MSI/MSI-X, multiqueue and NET_MPSAFE:
- Add C2000 KX and 2.5G support.
- Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is more than
4096. Almost the same as other OSes.
- For 82576 and newer devices, the PBA register is deleted. Don't write PBA
for those chips. Also change the calculation of RX packet buffer size in
new way.
- Fix a lot of bugs to make 82575 and newer SERDES based systems work.
- Print NVM image version and option ROM version.
- Add workaround for I210 Errata 25 and I211 Errata 10 (PLL bug). This
workaround is required if the NVM image version < 3.25.
- Fix a bug that wm_detach() didn't unmap the FHASH's area. Now
"drvct -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
- Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX packets"
and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit. The NVM Image
version 2.1.4 and newer have this workaround.
- Check PHY type correctly. This change is required to use igphy(4) device
correctly.
- Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH* too.
- Call wm_get_hw_control() correctly. This change fixes a bug that some AMT
based systems doesn't linkup at 1000BaseT. The problem was observed on HP
Compaq dc7700. A lot of fixes have been done for wm(4) and igphy(4), so now
PR#44893 should be fixed.
- Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT. It's required to
check the existence of AMT correctly.
- Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in
wm_reset() on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix the
behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change might fix
a problem that PHY's read/write functions can't get semaphore.
- On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS sets
this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the function
checks the status correctly but it causes linkdown up to 10 times, so it's
disabled for the time being.
- PR/50527: David Binderman: Fix impossible code. Odd offsets need special
treatment.
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Use sc->sc_itr instead of hard-coded number.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function acts as
mii_tick().
- ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition has not used yet.
- Add ACK data Disable bit's definition (not used yet).
- PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any effect by
default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when WM_WOL is
defined and it's disabled by default.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
- Reorder function definitions and macro definitions. No functional change.
- Fix comment. Add comment. Update comment.
- KNF.
 1.60.2.4 10-Jun-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #833):
sys/dev/pci/if_wm.c: revisions 1.322, 1.323
sys/dev/pci/if_wmreg.h: revision 1.72
- Currently, WM_F_EEE bit is not set on all chips. It's intened to not
to use all of EEE fuctions but wm_set_eee_i350() leaves IPCNFG_10BASE_TE
bit and it causes link negotiation problem on some old switches. Disable
10BASE-Te function, too.
- Call wm_set_eee_i350() on some chips, too.
--
Fix a bug that flags related to semaphore were incorrectly checked in
wm_kmrn_{readreg,writereg}. i80003, ICH* and PCH* had this problem.
 1.60.2.3 19-May-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #784):
sys/dev/pci/if_wm.c: revision 1.321
sys/dev/pci/if_wmreg.h: revision 1.71
sys/dev/pci/if_wmvar.h: 1.24 via patch
Add support iNVM (integrated Non-Volatile Memory) for I21[01].
This change fixes a bug that a MAC address is wrongly set on
iNVM machines/NICs.
 1.60.2.2 18-Mar-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #614):
sys/dev/pci/if_wm.c: revision 1.311-1.313
sys/dev/pci/if_wmreg.h: revision 1.66
Fix a bug that sc_mediatype is evaluated incorrectly. The real problem
might be occured only on fiber and serdes cases.
#####
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Add comment.
- Fix typo in comment.
#####
Fix a bug that the first access to NVM is failed on 8254[17] which use
SPI EEPROM. Observed on Dell PowerEdge [12]850. Thanks Tom Ivar Helbekkmo
for debugging.
 1.60.2.1 07-Nov-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #190):
sys/dev/pci/pcidevs 1.1201-1.1202 via patch
sys/dev/pci/if_wm.c 1.291-1.301, 1.304, 1.306-1.307 via patch
sys/dev/pci/if_wmreg.h 1.61-1.65 via patch
sys/dev/pci/if_wmvar.h 1.21 via patch
share/man/man4/wm.4 1.31 via patch
- Add Internal SERDES mode support newer than or equal to 82575.
- Add new I218 devices.
- Add DH89xxCC device.
- Add some old devices.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Don't print "failed to detect NVM bank" message.
- Delete 82580ER related code.
- Fix typo in comment.
- Fix debug message.
- Cleanup
 1.60.2.5.2.2 13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.60.2.5.2.1 18-Jan-2017  skrll Sync with netbsd-5
 1.65.2.8 28-Aug-2017  skrll Sync with HEAD
 1.65.2.7 05-Feb-2017  skrll Sync with HEAD
 1.65.2.6 05-Dec-2016  skrll Sync with HEAD
 1.65.2.5 29-May-2016  skrll Sync with HEAD
 1.65.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.65.2.3 22-Sep-2015  skrll Sync with HEAD
 1.65.2.2 06-Jun-2015  skrll Sync with HEAD
 1.65.2.1 06-Apr-2015  skrll Sync with HEAD
 1.89.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.89.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.94.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.98.6.19 29-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1938:

sys/dev/pci/if_wm.c 1.792,1.794-1.798 via patch
sys/dev/pci/if_wmreg.h 1.131

- Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.
- Drop frames if the RX descriptor ring has no room on multiqueue system.
- Improve dmesg output.
- Print RX packet buffer size.
- Fix the upper 16bit of Image Unique ID(EtrackID).
- Fix comment.
 1.98.6.18 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1915:

sys/dev/pci/pcidevs 1.1497
sys/dev/pci/if_wm.c 1.689,1.790-1.791 via patch
sys/dev/pci/if_wmreg.h 1.120 via patch
sys/dev/pci/if_wmvar.h 1.51

- Use 12K for packet buffer for jumbo frame on PCH2 and newer.
- Add new workaround for Tiger Lake and newer to avoid packet loss.
- Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.98.6.17 27-Jun-2023  martin Pull up the following revisions, requested by msaitoh in #1847:

sys/dev/pci/if_wm.c 1.768-1.782 via patch
sys/dev/pci/if_wmreg.h 1.129-1.130
sys/dev/pci/if_wmvar.h 1.49

wm(4):
- Rework for event counters:
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Rearrange the order of the registers so that they are roughly
in ascending order.
- Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach()
to match.
- IC{TX,RX}*C registers are for older than 82575.
- Fix a bug that the transmit underrun counter is incorrectly
counted.
- Don't add "Count" for event counter's description.
- Some statistics registers were replaced with new counters on newer
chips. Treat 0x403c(CEXTERR->HTDPMC), 0x40fc(TSCTFC->CBRMPC),
0x4124(ICRXOC->HTCBDPC) and from 0x4104 to 0x4124.
- Add some new counters:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- Host Good Octets RX
- Host Good Octets TX
- Length Errors
- SerDes/SGMII Code Violation Packet
- Header Redirection Missed Packet
- EEE TX LPI
- EEE RX LPI
- Fix prc511's comment and description.
- Add SOICZIFDATA (ifconfig -z) support for evcnt(9).
- Use WM_IS_ICHPCH(). No functional change.
- Fix typo. s/ictxact/ictxatc/. No functional change.
- Add comment.
 1.98.6.16 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1795:

sys/dev/pci/if_wm.c 1.764-1.767 via patch
sys/dev/pci/if_wmreg.h 1.128

- Workaround for some hypervisor environments. The environments
cannot stop e1000 interrupt immediately.
- Rename nq_txdesc' member "nqrx_ctx" to "nqtx_ctx". No functional
change.
- Add comment. Modify comment.
- KNF.
 1.98.6.15 07-Sep-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1759:

sys/dev/pci/if_wm.c 1.741-1.749,1.753-1.757,
1.762 via patch
sys/dev/pci/if_wmreg.h 1.126-1.127

- Fix I219 workaround in wm_flush_desc_rings().
- Add more statistics counters.
- To avoid releasing mutex temporally, use new
wm_set_mdio_slow_mode_hv_locked().
- No functional changes:
- Turn a locking botch (shouldn't drop lock on error) into a KASSERT
in wm_deferred_start_locked().
- Remove unneeded header inclusion.
- Use __BIT() a little.
- Modify comment and debug messages.
- Consistency use -1 instead of 1 for some error code.
- KNF.
 1.98.6.14 11-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1751:

sys/dev/pci/if_wmreg.h 1.122-1.125 via patch
sys/dev/pci/if_wmvar.h 1.48
sys/dev/pci/if_wm.c 1.719-1.720,1.722-1.725,
1.727-1.740 via patch

- wm_tick: Add missing splx(s) when not WM_MPSAFE.
- Print DMA range info if the system is booting in the verbose mode.
- Micro optimization:
- Call m_freem(m) only if m0 == NULL.
- Call wm_xxeof() only when limit > 0.
- Don't set the more flag when there is no packet to process.
- No functional changes:
- Call txeof first, then rxeof for the consistency.
- Remove duplicated break.
- Remove stray semicolons from struct declaration.
- Fix value return from void function.
- Use macros.
- Modify comment.
- KNF.
 1.98.6.13 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1707:

sys/dev/pci/if_wm.c 1.716-1.718 via patch
sys/dev/pci/if_wmreg.h 1.121
sys/dev/mii/ihphy.c 1.20

- Fix a bug that device timeout still happens when the link is down
on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.
 1.98.6.12 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1594:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660,
1.662, 1.664-1.668,
1.671-1.674, 1.678,
1.680-1.685 via patch
sys/dev/pci/if_wmreg.c 1.118-1.119 via patch
sys/dev/pci/if_wmvar.c 1.45 via patch
sys/dev/mii/igphy.c 1.35-1.36 via patch
sys/dev/mii/igphyreg.h 1.12-1.13
sys/dev/mii/makphy.c 1.66 via patch
sys/dev/mii/makphyreg.h 1.11

- Add SFP support. Module insertion/removal is not supported yet.
Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler).
Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0 which use softint
as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
fragmented UDP, first packet and second packet should be processed
in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
in case it's already set.
- Actually writing always the checksum offload context descriptor
makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Explicitly cast from uint16_t to uint32_t before shifting 16bit left
when printing Image Unique ID to avoid undefined behavior.
- Set if_baudrate for non-MII device.
- Rename some macros and function.
- KNF. Add comment.
 1.98.6.11 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1492:

sys/dev/pci/if_wm.c 1.650, 1.652-1.654 via patch
sys/dev/pci/if_wmreg.h 1.116-1.117

- Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580
port 1, 2, 3 and newer chips. This change fixes a bug that some
fiber, serdes or SFP devices don't detect the link status correctly.
- Simplify code by using "struct mii_data *mii" more. No functional
change.
- MSI-X doesn't use sc->sc_icr variable, so move the code into
non-MSI-X part. No functional change intended.
- Modify debug printfs a bit.
- Rename macro.
- Use __BIT()
- Fix comment. Add comment.
- KNF.
 1.98.6.10 01-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1312):

sys/dev/pci/if_wm.c: revision 1.644
sys/dev/pci/if_wm.c: revision 1.645
sys/dev/pci/if_wmreg.h: revision 1.115

Define RETA_ENTRY_MASK_Q(used in RSS redirection table) correctly.
Found by UBSan.

Use aprint_debug_dev() instead of printf() in wm_ulp_disable().

- rnd_add_*() call must be serialized. Unserialized accesses broke the
sc->rnd_source structure and caused off by one in kern_rndq.c's
rnd_add_data_ts(). This problem was found by kUBSan. Make krndsource_t's
data per queue-pair and call rnd_add_uint32() in wm_txrxintr_msix(). One of
the reason why rnd_add_uint32() calls were moved from wm_{tx,rx}eof() is that
rnd(9) manual page says "To allow the system to gather the timing information
accurately, this call should be placed within the actual hardware interrupt
service routine."

- Pass a better value to rnd_add_uint32() in wm_intr_legacy().
XXX pullup-8.
 1.98.6.9 17-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1298:

sys/dev/pci/if_wm.c 1.633, 1.637-1.641
sys/dev/pci/if_wmreg.h 1.114

- Use unsigned to avoid undefined behavior.
- Print ICH/PCH's NVM version.
- Fix typo in comment. u_int*_t -> uint*_t. Whitespace fix.
 1.98.6.8 07-Mar-2019  martin Pull up the following, requested by msaitoh in ticket #1206:

sys/dev/pci/if_wmreg.h 1.113
sys/dev/pci/if_wmvar.h 1.43-1.44
sys/dev/pci/if_wm.c 1.626-1.627, 1.629-1.636 via patch

- Add support for I210 SGMII Flash-less device.
- Add I219 variations for Cannon Lake.
- Add missing rnd_detach_source().
- Use do { ... } while (0) for DPRINTF(x, y).
- Swap enumeration of 82578 and 82577 PHY in if_wmvar.h. No functional
change.
- Add KASSERT.
- Update TODO list. Add comment. Fix typo in comment.
 1.98.6.7 31-Jan-2019  martin Pull up the following, requested by msaitoh in ticket #1179:

sys/dev/pci/if_wm.c 1.603-1.605,1.607-1.611,
1.613,1.615,1.618-1.620
via patch
sys/dev/pci/if_wmreg.h 1.110-1.111
sys/dev/pci/if_wmvar.h 1.40-1.42
sys/dev/mii/inbmphyreg.h 1.13-1.15

- Add some code for suspend/resume:
- Rename wm_smbustopci() to wm_init_phy_workarounds_pchlan(). It will
also called when resume.
- Call wm_phy_resetisblocked() after PHY reset in
wm_init_phy_workarounds_pchlan() to wait for the PHY to quiesce to
an accessible state.
- Add new wm_resume_workarounds_pchlan() function and use it in
wm_resume(). This workaround is only for PCH2 and newer.
- Don't call wm_disable_aspm() neither in wm_attach() nor in
wm_resume() but in wm_reset().
- Do some initialization in wm_resume() when IFF_UP is NOT set.
- Don't continue when it failed to acquire semaphore in
wm_ulp_disable().
- Print CLSEM workaround bit correctly.
- Fix availability detection of WoL on some chips.
- Print the WUS (WakeUp Status) register bits when resume.
- Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
- Remove an extra register read in
wm_kmrn_lock_loss_workaround_ich8lan().
- Don't leave the MDICNFG register modified when the Power Management
capability offset can't get.
- Reduce indent level of wm_linkintr_gmii(). No functional change.
- 80003's SERDES is not the same as 82575's but the same as legacy
devices. Use the old methods on 80003.
- Use __nothing for null DPRINTF().
- Rename functions. Add comment.
 1.98.6.6 04-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1117):

sys/dev/pci/if_wmreg.h: revision 1.109
sys/dev/pci/if_wm.c: revision 1.597
sys/dev/pci/if_wm.c: revision 1.598
sys/dev/mii/inbmphyreg.h: revision 1.12
sys/dev/pci/if_wm.c: revision 1.600
sys/dev/pci/if_wm.c: revision 1.601
sys/dev/pci/if_wm.c: revision 1.602

- Add new wm_gmii_{hv,i82544}_{read,write}reg_locked() and use them in
wm_gmii_{hv,i82544}_{read,write}reg(). *_locked() functions are not
mii(4) API functions, so it's not required to keep the mii API. Change
the PHY register type from int to uint16_t. It also change the usage of
return value. It returns zero on success and non-zero on error.
- Check the return value of *_locked() function and treat it.
- Use *writereg_locked() function to reduce race condition in
wm_init_lcd_from_nvm().
- Add comment.
- Control TX/RX descriptor snooping control bits on ICH8 and newer.
Only on ICH8, No-snoop bits are opposite polarity. On my Thinkpad X61,
the default value of this bits are all zero, so this commit changes
the snoop function enable on the machine. I tested with some other
PCH machines and those bits are all zero (enable snoop by default),
so this commit won't affect to some machines.
- Disable relax ordering on 82546GB(Device ID 0x1099 and 0x10b5) or >= ICH8.
Same as other OSes.
- Add wm_oem_bits_config_ich8lan() to control LPLU and GbE setting base on
the NVM's info.
- Modify wm_enable_wakeup() to reduce difference against FreeBSD and Linux.
This modification affects to ICH8 and newer devices. I217 Rapid Start
Technology support have not written yet (it's TODO).
- Add wm_k1_workaround_lv() from FreeBSD. It's PCH2 specific:
Workaround to set the K1 beacon duration for 82579 parts in 10Mbps.
Disable K1 for 1000 and 100 speeds.
- Make wm_link_stall_workaround_hv() and move an 82578 specific code into it.
Don't apply the workaround if BMCR_LOOP bit is set. Same as FreeBSD.
- Add comment. Modify comment.
Fix comment. No functional change.
 1.98.6.5 08-Nov-2018  martin Pull up the following, requested by msaitoh in tickt #1085:

sys/dev/mii/inbmphyreg.h 1.11
sys/dev/pci/if_wmreg.h 1.108
sys/dev/pci/if_wm.c 1.590-1.596 via patch

- 82574 and newer document says the status field has neither EC
(Excessive Collision) bit nor LC (Late Collision) bit (reserved), so
don't check the bit.
- Add workaround for DMA hang problem which result in TX device timeout
on PCH_LPT with I218. Same as FreeBSD and Linux. This workaround is
only for device ID 0x155a, 0x15a2, 0x1559 and 0x15a3.
- Fix a PCH2 specific bug that wrong PHY register value can be read
when boot. Same as FreeBSD and Linux.
- After writing MDIC register, don't read quickly the same register but
do delay(50). Same as other OSes.
- Add missing wm_gate_hw_phy_config_ich8lan(false) in
wm_phy_post_reset() on PCH2. wm_gate_hw_phy_config_ich8lan(true) is
called in wm_reset(), so wm_gate_hw_phy_config_ich8lan(false) should
be called after reset in wm_phy_post_reset().
- On PCH2, set the phy config counter to 50msec after (PHY) reset.
- KNF & Use macro.
 1.98.6.4 16-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #764):

sys/dev/pci/if_wm.c: revision 1.567
sys/dev/pci/if_wm.c: revision 1.568
sys/dev/pci/if_wm.c: revision 1.569
sys/dev/pci/if_wmvar.h: revision 1.38
sys/dev/pci/if_wm.c: revision 1.570
sys/dev/pci/if_wm.c: revision 1.571
sys/dev/pci/if_wm.c: revision 1.572
share/man/man4/wm.4: revision 1.40
sys/dev/pci/if_wmreg.h: revision 1.106
sys/dev/pci/if_wmreg.h: revision 1.107

SW PHY Config Enable bit for ICH8 B0 stepping is not bit 1 but bit 0.

No binary change:
- Sort registers.
- Lowercase hexadecimal value.

On PCH_SPT (and newer), FLASH access should be done by 32bit.
Especially for ICH_FLASH_HSFCTL register, it's located at 0x0006, so
it should be accessed via ICH_FLASH_HSFSTS(0x0004) and use shift or mask.

Our PCH_SPT part of wm_nvm_valid_bank_detect_ich8lan() was based on
FreeBSD r287467. After that, they reverted it and committed the different
code in r287762. r287762's bank detect code didn't work for us because our wm
dirver had a problem in flash access. The problem was fixed in if_wm.c rev.
1.567, so we can use the new way now.

If the extended configration size in the EXTCNFSIZE register is 0, don't
continue.
Add PCH_CNP support (I219 with Intel 300 series chipset).
It's required more test, so it's disabled by default.

Enable I219.

I354 uses an external PHY, so don't use wm_set_eee_i350().
 1.98.6.3 24-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #389):
sys/net/if_ether.h: revision 1.69
sys/net/if_vlan.c: revision 1.108
sys/dev/pci/if_bge.c: revision 1.313
sys/net/if_vlanvar.h: revision 1.11
sys/net/if_vlanvar.h: revision 1.12
sys/net/if_ether.h: revision 1.70
sys/net/if_vlan.c: revision 1.110
sys/dev/pci/if_wm.c: revision 1.544
sys/dev/pci/if_wmreg.h: revision 1.105
Fix a bug that a vlan packet which has priority or CFI bit in the tag causes
panic.
Revert part of if_bge.c 1.312. It's not required to mask other than VLAN ID
bits in VLAN tag.
Revert if_wmreg.h 1.104 and if_wm.c 1.542. It's not required to mask other
than VLAN ID bits in VLAN tag.
No functional change:
- u_int16_t -> uint16_t
- u_short -> uint16_t
- tag_hash_func -> vlan_tag_hash
- 0 -> NULL because vlr_parent is a pointer.
 1.98.6.2 06-Nov-2017  snj Pull up following revision(s) (requested by knakahara in ticket #348):
sys/dev/pci/if_wm.c: revision 1.542
sys/dev/pci/if_wmreg.h: revision 1.104
fix wm(4) vlan panic. Reported and tested by Tom Ivar Helbekkmo, thanks.
wm(4) used PRI bits and CFI bit as vlantag by mistake. It is found out
by if_ether.h:r1.67.
 1.98.6.1 01-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #173):
sys/dev/pci/if_wmreg.h: 1.99-1.103
sys/dev/pci/if_wmvar.h: 1.34-1.37
sys/dev/pci/if_wm.c: 1.510-1.537
sys/dev/mii/ihphyreg.h: 1.2
sys/dev/mii/inbmphyreg.h: 1.10
sys/dev/mii/igphy.c: 1.27
Sync wm(4) up to if_wm.c rev. 1.537:
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset().
- If a legacy interrupt is a spurious interrupt, don't print debug
message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Flush writing WMREG_CTRL in wm_gmii_mediachange().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Add I219 specific workaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for workaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- IF TX is not required to flush, RX is also not required to flush in
wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset().
Some flags and callback function is required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Configure the LCD with the extended configuration region in NVM if
it's required. Tested with Thinkpad X220.
- 8257[12]: Don't directly access SPI but use EERD register.
- 82575-I354: If the size of SPI ROM >= 32K words, use direct SPI
access instead of EERD register access.
- Add wm_nvm_eec_clock_raise() and wm_nvm_eec_clock_lower() and use
them for Microwire/SPI bus control. Same as Linux and FreeBSD.
- Reduce timeout value for 80003 in wm_get_swfw_semaphore(). Same as
Linux and FreeBSD.
- Change API of kmrn_{read,write}reg() and check the return value.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally." on I21[01]. PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
NVM word size before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Print internal driver flags when attaching.
- Add debug printf()s.
- Rename variables.
- Add comment, update comment and remove wrong comment.
 1.105.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.105.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.105.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.107.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.107.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.107.2.1 10-Jun-2019  christos Sync with HEAD
 1.115.2.9 23-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1802:

sys/dev/pci/if_wm.c 1.794-1.798 via patch
sys/dev/pci/if_wmreg.h 1.131

- Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.
- Drop frames if the RX descriptor ring has no room on multiqueue
system.
- Improve dmesg output:
- Print RX packet buffer size.
- Fix the upper 16bit of Image Unique ID(EtrackID).
 1.115.2.8 27-Jun-2023  martin Pull up the following revisions, requested by msaitoh in #1656:

sys/dev/pci/if_wm.c 1.768-1.782 via patch
sys/dev/pci/if_wmreg.h 1.129-1.130
sys/dev/pci/if_wmvar.h 1.49

wm(4):
- Rework for event counters:
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Rearrange the order of the registers so that they are roughly
in ascending order.
- Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach()
to match.
- IC{TX,RX}*C registers are for older than 82575.
- Fix a bug that the transmit underrun counter is incorrectly
counted.
- Don't add "Count" for event counter's description.
- Some statistics registers were replaced with new counters on newer
chips. Treat 0x403c(CEXTERR->HTDPMC), 0x40fc(TSCTFC->CBRMPC),
0x4124(ICRXOC->HTCBDPC) and from 0x4104 to 0x4124.
- Add some new counters:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- Host Good Octets RX
- Host Good Octets TX
- Length Errors
- SerDes/SGMII Code Violation Packet
- Header Redirection Missed Packet
- EEE TX LPI
- EEE RX LPI
- Fix prc511's comment and description.
- Add SOICZIFDATA (ifconfig -z) support for evcnt(9).
- Use WM_IS_ICHPCH(). No functional change.
- Fix typo. s/ictxact/ictxatc/. No functional change.
- Add comment.
 1.115.2.7 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1578:

sys/dev/pci/if_wm.c 1.764-1.767 via patch
sys/dev/pci/if_wmreg.h 1.128

- Workaround for some hypervisor environments. The environments
cannot stop e1000 interrupt immediately.
- Rename nq_txdesc' member "nqrx_ctx" to "nqtx_ctx". No functional
change.
- Add comment. Modify comment.
- KNF.
 1.115.2.6 07-Sep-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1515:

sys/dev/pci/if_wm.c 1.741-1.749,
1.753-1.757,
1.762 via patch
sys/dev/pci/if_wmreg.h 1.126-1.127

- Fix I219 workaround in wm_flush_desc_rings().
- Add more statistics counters.
- To avoid releasing mutex temporally, use new
wm_set_mdio_slow_mode_hv_locked().
- No functional changes:
- Turn a locking botch (shouldn't drop lock on error) into a KASSERT
in wm_deferred_start_locked().
- Remove unneeded header inclusion.
- Use __BIT() a little.
- Modify comment and debug messages.
- Consistency use -1 instead of 1 for some error code.
- KNF.
 1.115.2.5 11-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1477:

sys/dev/pci/if_wmreg.h 1.122-1.125
sys/dev/pci/if_wmvar.h 1.48
sys/dev/pci/if_wm.c 1.719-1.720,
1.722-1.725,
1.727-1.740 via patch

- wm_tick: Add missing splx(s) when not WM_MPSAFE.
- Print DMA range info if the system is booting in the verbose mode.
- Micro optimization:
- Call m_freem(m) only if m0 == NULL.
- Call wm_xxeof() only when limit > 0.
- Don't set the more flag when there is no packet to process.
- No functional changes:
- Call txeof first, then rxeof for the consistency.
- Remove duplicated break.
- Remove stray semicolons from struct declaration.
- Fix value return from void function.
- Use macros.
- Modify comment.
- KNF.
 1.115.2.4 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1373:

sys/dev/pci/if_wm.c 1.716-1.718 via patch
sys/dev/pci/if_wmreg.h 1.121
sys/dev/mii/ihphy.c 1.20

- Fix a bug that device timeout still happens when the link is down
on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.
 1.115.2.3 23-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1093):

sys/dev/pci/if_wmreg.h: revision 1.120
sys/dev/pci/if_wmvar.h: revision 1.46
sys/dev/pci/if_wm.c: revision 1.686
sys/dev/pci/if_wm.c: revision 1.687
sys/dev/mii/inbmphyreg.h: revision 1.20
sys/dev/pci/if_wm.c: revision 1.688
sys/dev/pci/if_wm.c: revision 1.689

s/ressource/resource/. Found by knakahara.

Add new flag named WM_F_CRC_STRIP and use it. No functional change.

This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.

Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.

- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.
XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
FreeBSD and Linux do the same thing that they set the same value on both
jumbo frame's enable case and the disable case. It seems the default value
is 0x0b0c and it's not changed on the enable case, so it might be a bug
on the enable case or the modification is not required.
- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.
Use 12K for packet buffer for jumbo frame on PCH2 and newer.

XXX Note that Linux Use 14K.
 1.115.2.2 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #994:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660, 1.662, 1.664-1.668,
1.671-1.674, 1.678,1.680-1.681 via patch
sys/dev/pci/if_wmreg.c 1.118-1.119
sys/dev/pci/if_wmvar.c 1.45

- Add SFP support. Module insertion/removal is not supported yet.
Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler.
Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0 which use softint
as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
fragmented UDP, first packet and second packet should be processed
in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
in case it's already set.
- Actually writing always the checksum offload context descriptor
makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Rename some macros and function.
- KNF. Add comment.
 1.115.2.1 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #650:

sys/dev/pci/if_wm.c 1.650, 1.652-1.654
sys/dev/pci/if_wmreg.h 1.116-1.117

- Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580
port 1, 2, 3 and newer chips. This change fixes a bug that some
fiber, serdes or SFP devices don't detect the link status correctly.
- Simplify code by using "struct mii_data *mii" more. No functional
change.
- MSI-X doesn't use sc->sc_icr variable, so move the code into
non-MSI-X part. No functional change intended.
- Modify debug printfs a bit.
- Rename macro.
- Use __BIT()
- Fix comment. Add comment.
- KNF.
 1.128.2.2 23-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #607):

sys/dev/pci/if_wm.c: revision 1.795
sys/dev/pci/if_wm.c: revision 1.796
sys/dev/pci/if_wm.c: revision 1.797
sys/dev/pci/if_wmreg.h: revision 1.131

wm(4): Add RQDPC(Receive Queue Drop Packet Count) to iqdrops.

The iqdrops counter should include not only MPC(Missed Packet Count)
but also RQDPC(Receive Queue Drop Packet Count). Same as ixgbe(4) and igc(4).

Note that the RQDPC is not currently counted because SRRCTL_DROP_EN
is not set.

wm(4): Drop frames if the RX descriptor ring has no room on multiqueue system.

Drop frames if the RX descriptor ring has no room. This is enabled only on
multiqueue system to avoid bad influence to other queues. The drop count
can be seen by the RQDPC counter (wmN rxqXXdrop evcnt).

wm(4): Fix compile error without WM_EVENT_COUNTERS.
 1.128.2.1 22-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #213):

sys/dev/pci/if_wm.c: revision 1.770
sys/dev/pci/if_wm.c: revision 1.771
sys/dev/pci/if_wm.c: revision 1.772
sys/dev/pci/if_wm.c: revision 1.773
sys/dev/pci/if_wm.c: revision 1.774
sys/dev/pci/if_wm.c: revision 1.775
sys/dev/pci/if_wm.c: revision 1.776
sys/dev/pci/if_wmreg.h: revision 1.129
sys/dev/pci/if_wm.c: revision 1.777
sys/dev/pci/if_wm.c: revision 1.778
sys/dev/pci/if_wmvar.h: revision 1.49
sys/dev/pci/if_wm.c: revision 1.779
sys/dev/pci/if_wm.c: revision 1.768
sys/dev/pci/if_wm.c: revision 1.769
sys/dev/pci/if_wmreg.h: revision 1.130
sys/dev/pci/if_wm.c: revision 1.780
sys/dev/pci/if_wm.c: revision 1.781

Count some 64bit counters correctly.
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Found by knakahara.

Add note for the TORL register.

The TOR register includes error, flow control and broadcast rejected.

Sort lines. No functional change.

Rearrange the order of the registers so that they are roughly in ascending
order.

Sort lines. No functional change.

Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach() to match.
IC{TX,RX}*C registers are for older than 82575.

Fix a bug that the transmit underrun counter is incorrectly counted.
The transmit underrun bit in the transmit status filed is only for 82544
(and older?), so don't use the counter for newer chips. The bit is reserved
for newer chips, but the bit sometimes set on 82575 at least.

Don't add "Count" for event counter's description.

Some statistics registers were replaced with new counters.
- 0x403c was CEXTERR(Carrier Extension Error). 82575 and newer except 80003,
ICHs and PCHs have HTDPMC(Host Tx Discarded Packets by MAC). I don't really
know for 82575. The 82575 datasheet say nothing about it.
- The following two are changed for circuit breaker. Only 82576's datasheet
describes abut it, so the registers might be only for 82576.
Use those registers for 82575 and newer except 80003, ICHs and PCHs just in
case.
- 0x40fc was TSCTFC(TCP Segmentation Context Tx Fail). It was replaced by
the CBRMPC(Circuit Breaker Rx Manageability Packet) register.
- 0x4124 was ICRXOC(Interrupt Cause Receiver Overrun). It was replaced by
the HTCBDPC(Host Tx Circuit Breaker Dropped Packet) register.
- From 0x4104 to 0x4124:
- For 0x4124, 82575's datasheet says it's not changed(ICRXOC).
I don't know if it's correct. We use new HTCBDPC register for 82575.
- 82576 and newer changed the meaning.
- I don't know for 80003, ICHs and PCHs. Don't count those registers.
At least, those registers in PCH2 and PCH_CNP are all zero.

Add some new event counters.

Add the following counters for 82575 and newer except 80003, ICHs and PCHs:
- Only 82576 document describes about the circuit breaker,
so the following two might be only for 82575:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- 82575's document doesn't describe the following two, but we can see
the same value as GO{T,R}C have:
- Host Good Octets RX
- Host Good Octets TX
- 82575's document doesn't describe the LENERRS (Length Errors) counter.
I don't know if it has.
- Perhaps Non-SerDes/SGMII devices don't have SCVPC
(SerDes/SGMII Code Violation Packet) register. We don't care if
it's SerDes/SGMII or not for now.
- HRMPC (Header Redirection Missed Packet) appears only once
in 8257[56]'s datasheet. FreeBSD's igb counts it, so we do, too.
- Count the following two for I350 and newer. I don't know if PCHs have:
- EEE TX LPI
- EEE RX LPI

Move statistics updating code from wm_tick() to new wm_update_stats().
- To reuse.
- No functional change.

Add SOICZIFDATA (ifconfig -z) support for evcnt(9).

First update the statistics data, then clear the event counters,
and finally copy and clear if_data via ether_ioctl().

Fix prc511's comment and description.

Use WM_IS_ICHPCH(). No functional change.

Fix typo. s/ictxact/ictxatc/. No functional change.
 1.51 11-Oct-2023  msaitoh wm(4): Add a new workaround for Tiger Lake and newer.

- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.
 1.50 25-Aug-2023  msaitoh Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.
 1.49 11-May-2023  msaitoh Some statistics registers were replaced with new counters.

- 0x403c was CEXTERR(Carrier Extension Error). 82575 and newer except 80003,
ICHs and PCHs have HTDPMC(Host Tx Discarded Packets by MAC). I don't really
know for 82575. The 82575 datasheet say nothing about it.
- The following two are changed for circuit breaker. Only 82576's datasheet
describes abut it, so the registers might be only for 82576.
Use those registers for 82575 and newer except 80003, ICHs and PCHs just in
case.
- 0x40fc was TSCTFC(TCP Segmentation Context Tx Fail). It was replaced by
the CBRMPC(Circuit Breaker Rx Manageability Packet) register.
- 0x4124 was ICRXOC(Interrupt Cause Receiver Overrun). It was replaced by
the HTCBDPC(Host Tx Circuit Breaker Dropped Packet) register.
- From 0x4104 to 0x4124:
- For 0x4124, 82575's datasheet says it's not changed(ICRXOC).
I don't know if it's correct. We use new HTCBDPC register for 82575.
- 82576 and newer changed the meaning.
- I don't know for 80003, ICHs and PCHs. Don't count those registers.
At least, those registers in PCH2 and PCH_CNP are all zero.
 1.48 20-Dec-2021  skrll branches: 1.48.4;
Trailing whitespace
 1.47 30-Oct-2020  msaitoh Add WMPHY_I350. Not used yet.
 1.46 15-Sep-2020  msaitoh Add new flag named WM_F_CRC_STRIP and use it. No functional change.

This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.
 1.45 11-Dec-2019  msaitoh Add SFP support part 1. The code for SerDes and SGMII setting is not include
in this commit. SFP module removal interrupt detects but not used yet:
- Detect SFP's 1000BASE-SX, 1000BASE-LX, 100BASE-FX and 1000BASE-T correctly.
- Detect the Media Auto Sense feature. Not supported yet.
- Add comment.
 1.44 19-Feb-2019  msaitoh branches: 1.44.4;
Modify PHY tree in comment.
 1.43 07-Feb-2019  msaitoh Swap enumeration of 82578 and 82577. Same as FreeBSD. Chip Model number of
82578 is +1 from 82577 but 82577 is functionally newer than 82578 (and 82577's
MII_MODEL(0x05) is greater than 82578's (0x04)). This change doesn't affect any
behavior to if_wm.c (NFCI).

Add comment.
 1.42 25-Dec-2018  msaitoh Add comment.
 1.41 20-Dec-2018  msaitoh - Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
 1.40 14-Dec-2018  msaitoh Print CLSEM workaround bit correctly.
 1.39 08-Aug-2018  msaitoh Add MDIC_WA and CLSEMWA to snprintb() string for WM_F_* flags.
 1.38 12-Apr-2018  msaitoh branches: 1.38.2;
Add PCH_CNP support (I219 with Intel 300 series chipset).
It's required more test, so it's disabled by default.
 1.37 27-Jul-2017  msaitoh branches: 1.37.2;
Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers say
"In rare circumstances, the SW semaphore may already be held unintentionally."
on I21[01]. PXE boot is one of the case.

XXX pullup-[678].
 1.36 26-Jul-2017  msaitoh - Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required for
these functions to use the same API. So,
- Change return value as error code.
- Change register vaule from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not in
wm_reset(). If the workaround isn't required, don't use the workaround code
in wm_gmii_i80003_{read,write}reg.
 1.35 25-Jul-2017  msaitoh Use new nvm.{acquire,release}() for semaphore. Almost the same except the
following:
- 8257[12]: Don't directly access SPI but use EERD register.
- 82575-I354: If the size of SPI ROM >= 32K words, use direct SPI access
instead of EERD register access.
- Add wm_nvm_eec_clock_raise() and wm_nvm_eec_clock_lower() and use them for
Microwire/SPI bus control. Same as Linux and FreeBSD.
- Redude timeout value for 80003 in wm_get_swfw_semaphore(). Same as
Linux and FreeBSD.
 1.34 26-Jun-2017  msaitoh Print sc_flags with snprintb().
 1.33 01-Feb-2017  msaitoh branches: 1.33.6;
Use new wm_gmii_setup_phytype() function to setup sc_phytype and
mii_{read|write}reg. This function is called twie.

To identify PHY type, correct read/write function should be selected. To
select correct read/write function, PCI ID or MAC type are required without
accessing PHY registers.

On the first call of this function, PHY ID is not known yet. Check PCI ID or
MAC type. The list of the PCI ID may not be perfect, so the result might be
incorrect.

In the second call, PHY OUI and model are used to identify PHY type. It might
not be perfpect because of the lack of compared entry, but it would be better
than the first call.

If the detected new result and previous assumption is different, diagnous
message will be printed.
 1.32 28-Oct-2016  msaitoh branches: 1.32.2;
- Define WMPHY_I217, WMPHY_VF and WMPHY_210.
- Use BME1000_PHY_PAGE_SELECT in wm_gmii_bm_{read,write}reg(). This change has
no effect because GG82563_PHY_PAGE_SELECT and BME1000_PHY_PAGE_SELECT have
the same value.
 1.31 06-May-2016  msaitoh branches: 1.31.2;
Basic support for I219. It doesn't work on I219, so it's disabled.
 1.30 25-Dec-2015  msaitoh - Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Fix typo in comment and modify comment by tnn@.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
 1.29 06-Jun-2015  msaitoh - Add workaround for I210 Errata 25 and I211 Errata 10.
- Add wm_gmii_gs40g_{read|write}reg() and use it to access non-standatrd
page.
- Add wm_pll_workaround_i210() and call it when
chip is i211
chip is i210 and it use INVM
chip is i210 and NVM image version < 3.25
- Add comment
- Rename macros.
 1.28 06-Jun-2015  msaitoh Print NVM image version.
 1.27 06-Jun-2015  msaitoh Revert previos. Sorry, I committed in another working directory...
 1.26 06-Jun-2015  msaitoh Print NVM image version.
 1.25 02-Jun-2015  msaitoh Fix a lot of bugs to make 82575 and newer's SERDES based systems work.
- Add SERDES specific functions.
- Fix IO pin configuration.
- Reset autonego timer when link becomes up.

TODO:
- Fix a bug that SFP ROM can't read.
- Perhaps some work is required for 8257[12] serdes systems.
- Remove duplicated code in TBI's link related functions.
 1.24 16-May-2015  msaitoh Add support iNVM (integrated Non-Volatile Memory) for I21[01]. This change
fixes a bug that a MAC address is wrongly set on iNVM machines and NICs.
Tested with Shuttle DS57U(iNVM based) and other non iNVM based I210 machines.
 1.23 27-Nov-2014  msaitoh branches: 1.23.2;
Fix typo in comment.
 1.22 25-Nov-2014  msaitoh Add note about the variations of Intel gigabit Ethernet controller.
 1.21 06-Oct-2014  msaitoh Delete 82580ER related code. It was from FreeBSD and was removed in r203049.
 1.20 24-Aug-2014  msaitoh Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
 1.19 14-Jul-2014  msaitoh branches: 1.19.2;
Cleanup comments. No functional change.
 1.18 11-Jul-2014  msaitoh Rename some WM_F_* flags to clarify. Renumbering flags. No functional change.

WM_F_EEPROM_HANDSHAKE -> WM_F_LOCK_EECD
WM_F_EEPROM_SEMAPHORE -> WM_F_LOCK_SWSM
WM_F_SWFW_SYNC -> WM_F_LOCK_SWFW
WM_F_SWFWHW_SYNC -> WM_F_LOCK_EXTCNF
 1.17 29-Dec-2013  msaitoh branches: 1.17.2;
Add support For I354(C2000 interna Ethernet controller):
- Add I354 support.
- Fix SGMII+MDIO case. SGMII+I2C is not supported yet.
- Not tested well.
- Sprinkle "XXX" to check later.
 1.16 02-Jun-2013  msaitoh branches: 1.16.2;
Add I217 (and I218) support.
- The name of I217 is similar to I210, but the function is rather similar to
PCH2.
- Not tested well. Tested with my own Intel DQ87PG which has I217LM onboard.
- It seems that PCH2 and PCH_LPT specific function for RAL should be written.
- Quick hack for the NVM checksum mismatch. if_wm.c currently has no
wm_write_eeprom(), so it cannot update NVM's "updated bit". To avoid this
problem, check only the last 12bits of the checksum. My own DQ87PG's
updated bit is not set, and I could avoid the problem using with this
hack.
 1.15 18-Apr-2013  msaitoh Add support I21[01]. Only tested with my own I210-T1 Ethernet Server Adapter.
 1.14 12-Feb-2013  msaitoh Use 82580(and I350) specific PHY read/write functions.
Fixes PR#47542.
 1.13 25-May-2012  msaitoh branches: 1.13.2;
Add support Intel I350 Ethernet.
 1.12 20-May-2011  msaitoh branches: 1.12.4; 1.12.8; 1.12.10;
Add PCH2 support.
 1.11 07-Mar-2010  msaitoh branches: 1.11.2; 1.11.4; 1.11.6;
- Add code for WOL, ASF, IPMI and Intel AMT.
- wm_enable_wakeup() is disabled by default. If you want to use WOL with
the Magic Packet, define WM_WOL.
- Add the following flags:
WM_F_ASF_FIRMWARE_PRESENT
WM_F_ARC_SUBSYSTEM_VALID
WM_F_HAS_AMT
WM_F_HAS_MANAGE
WM_F_WOL
- Add wm_suspend() and wm_resume(). Give/get the control to/from the
firmware.
- Need more work for PCH. See wm_enable_phy_wakeup().
- Enable wm_get_hw_control() for 82574 and 82583.
- Add Yet another workaround for ICH8.
- Add wm_igp3_phy_powerdown_workaround_ich8lan() for power down problem
on D3.
 1.10 25-Feb-2010  msaitoh Merge if_wm.c rev. 1.162.4.13 and if_wmvar.h rev. 1.2.46.3 into maintrunk.
Increase the timeout value to prevent timeout on 80003. The values are taken
from Intel's e1000 driver. Tested by spz and me.
 1.9 16-Feb-2010  msaitoh Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
 1.8 14-Jan-2010  msaitoh branches: 1.8.2;
Fixes the rx stall problem on 82578 by MANY workaround code.
We need more work for 82577.
 1.7 11-Jan-2010  msaitoh Add partial support for PCH. We have to do more work for PCH. Especially
I don't know what driver i82578 should be attached to. makephy? or atphy?
MII_OUI() says that the PHY is from Attansic (== Atheros). Intel's e1000
driver says that it's close to makphy...

I can't link up at 1000BaseT yet...
 1.6 07-Jan-2010  msaitoh Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
 1.5 29-Dec-2009  msaitoh - Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- Add support for i82583V.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
 1.4 16-Dec-2009  msaitoh Sync with Intel's original em driver:
- Add dspcode for igp3 and use it when the EEPROM isn't available.
- Add some delays.
- Stop the PHY transmitter before patching the DSP code and restart it after wrote.
- Save and restore register 0x2f5b.
 1.3 16-Dec-2009  msaitoh Re-enable igphy's 82566 support.
- Patch for the DSP code is only for 8254[17] and we have to apply the
different patches between rev. 1 and rev. 2.
- The workaround for analog fuse is only for 82547 rev. 1.
- The workaround for smartspeed is only for 8254[17]

see http://mail-index.netbsd.org/tech-net/2009/08/05/msg001546.html
 1.2 22-Feb-2006  gavan branches: 1.2.40; 1.2.46;
Convert MD hook to device property reads.

Device properties, if present, take precedence over EEPROM values.
 1.1 16-Feb-2006  gavan branches: 1.1.2;
Compute the EEPROM checksum to determine the presence of valid EEPROM data.
If EEPROM data is invalid, allow a MD hook to supply EEPROM data instead.
 1.1.2.3 01-Mar-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 16-Feb-2006  yamt file if_wmvar.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:08 +0000
 1.2.46.7 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1962):
sys/dev/pci/if_wm.c: revisions 1.259-1.266, 1.269, 1.271, 1.273-1.274, 1.277-1.278, 1.282, 1.284-1.285, 1.287, 1.290, 1.294, 1.297-1.298, 1.300-1.301, 1.304-1.307, 1.310, 1.312-1.314, 1.316 via patch
sys/dev/pci/if_wmreg.c: revisions 1.54-1.57, 1.59-1.60, 1.62, 1.64-1.66 via patch
sys/dev/pci/if_wmvar.c: revisions 1.17, 1.20-1.21 via patch
sys/dev/pci/pcidevs: revisions 1.1172, 1.1195, 1.1201 via patch
- Fix "MDIC write error" bug for 82574 and 82583. For those chips, the
semaphore must be released after chip reset. Found and tested by
Mark Davies.
- Fix BMC related bugs.
- Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with
Asus P8P67 Deluxe motherboard and tested by jnemeth.
- Add support for I354 DH89xxCC and some new I218 devices.
- Fix definition of CTRL_GIO_M_DIS bit.
- Insert completion barrier between register write and delay().
- Bump max TX DMA size to avoid pathological condition with TSO. From dyoung.
- Fix semaphore related bugs.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880).
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- It's not required to print "failed to detect NVM bank" with
aprint_error_dev(). Use DPRINTF(). Same as {Free,Open}BSD.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.
- Delete 82580ER related code. It was from FreeBSD and was removed
in r203049.
- Remove extra debug message.
- Remove unused variable.
- Remove a duplicated error message.
- Cleanup comments.
- Fix debug message.
 1.2.46.6 07-Sep-2013  bouyer sys/dev/pci/if_wm.c 1.246-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16
sys/dev/pci/pcidevs 1.1152-1.1153
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Add comments, fix some comments, use macros and remove trailing
whitespaces.
[msaitoh, ticket #1867]
 1.2.46.5 19-Jun-2013  bouyer Pullup the following revisions via patch, requested by msaitoh in ticket #1850:
sys/dev/pci/if_wm.c 1.201, 1.203-1.204,
1.207-1.212, 1.215,
1.217-1.218, 1.220-1.223,
1.228, 1.232-245
sys/dev/pci/if_wmreg.h 1.40-1.45, 1.47-1.48
sys/dev/pci/if_wmvar.h 1.11-1.13
sys/dev/pci/pcidevs 1.1074, 1.1077, 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.6
sys/dev/mii/ihphy.c 1.1-1.2
sys/dev/mii/ihphyreg.h 1.1
sys/dev/mii/inbmphyreg.h 1.3
sys/dev/mii/files.mii 1.47 via patch
sys/dev/mii/miidevs 1.97 and 1.100
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/arch/i386/conf/ALL 1.280
sys/arch/i386/conf/GENERIC 1.1001
sys/arch/i386/conf/INSTALL_FLOPPY 1.11
sys/arch/i386/conf/XEN2_DOM0 patch
sys/arch/amd64/conf/GENERIC 1.293
sys/arch/amd64/conf/XEN3_DOM0 1.61
share/man/man4/wm.4 1.21-1.24

Apply almost all fixes and improvements from netbsd-6 except for
the rev. 1.196's iqdrops' change.

- Add the detach code.
- Add code for WOL, ASF, IPMI and Intel AMT. WOL is disabled by default
- Add Yet another workaround for ICH8.
- 82576 is dual port, so check the FUNCID and increment the MAC address for
the 2nd port.
- Fix the names of 82577L[MC] LAN controllers (for mobile).
- Fix CTRL_EXT_SWDPIN() and CTRL_EXT_SWDPIO() macros. The bit order of the
SW definable pin is not 6543 but 3654!!!
- Rewrite the code to read MAC address from eeprom.
- Add 82580 support.
- 82571 quirk. Only 82571 shares port 0 of EEMNGCTL_CFGDONE.
- The document says that the TDH register must be set after
TCL.EN is set on 82575 and newer devices.
- Fix some register names. No functional change.
- Omit U+00AE "REGISTERED SIGN" in a product name due to its non-ASCII nature.
- Stop wm(4) from needlessly resetting when you add or delete a vlan(4).
- Fix MAC address check on 8257[156] and 80003 case. Some cards have non 0xffff
pointer but those don't use alternative MAC address in reality. So we check
whether the broadcast bit is set or not like Intel's e1000 driver.
Fixes PR kern/44072 reported by Jean-Yves Moulin.
- Add PCH2(and 82579) support. Fixes PR#46487
- Add yet another 82567V support.
- Add ICH10+HANKSVILL support.
- Add support Intel I350 Ethernet.
- Make vlan and all ip/ip6 checksum offload work for the I350.
- Fix compile error with WM_DEBUG.
- Fix a bug that PHY isn't set to low-power mode on PCH and PCH2.
- Add WM_DEBUG_NVM. If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
- Skip 64bit BAR correctly.
- Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
- Use 82580(and I350) specific PHY read/write functions. Fixes PR#47542.
- Style fix. Fix typo in comment. Fix comments. Add comments.
 1.2.46.4 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1358):
sys/dev/pci/if_wm.c 1.196-1.199,1.202,1.205
sys/dev/pci/if_wmvar.h 1.9
sys/dev/pci/if_wmreg.h 1.36-1.39
sys/dev/pci/pcireg.h 1.61-1.64
sys/dev/pci/pcidevs 1.1023
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
mii/igphy.c 1.21
mii/igphyvar.h 1.1
mii/inbmphyreg.h 1.2

- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
- Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
- (pcireg.h) Add PCIe config register definitions.
- Note that the changes to count Missed packet (rx fifo overflow) and Receive
no buffers (rx ring full) into iqdrops in rev. 1.196 of if_wm.c is not
pulled up.
 1.2.46.3 25-Feb-2010  sborrill Fix regression caused by pullup #1277 requested by msaitoh.
 1.2.46.2 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c 1.184-1.192, 1.194
sys/dev/pci/if_wmreg.h 1.29-1.35
sys/dev/pci/if_wmvar.h 1.5-1.8
sys/dev/pci/pcidevs 1.1006,1.1009-1.1010, 1.1012-1.1013 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.5
sys/dev/mii/inbmphyreg.h 1.1

- Add support for i82583V.
- Add some ICH9 and ICH10 devices.
- Add support for PCH.
- Fix the bug that ICH9 can't found a PHY. Fixes PR#42237
- Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
- Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
- Fix the checking of jumbo frame function
- Remove the extra macro definition for the offset 0x1a in EEPROM.
- Add missing break in wm_reset()...
- Fix the offset of WMREG_PBS...
- Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. It seems that we have to
do the same work for ICH9.
- Fixes the rx stall problem on 82578 by MANY workaround code. We need more
work for 82577.
 1.2.46.1 23-Dec-2009  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: 1.176-1.179, 1.181-1.183
sys/dev/pci/if_wmreg.h: 1.28
sys/dev/pci/if_wmvar.h: 1.1-1.4
sys/dev/mii/igphy.c: 1.18-1.20 via patch

Many bugfixes:
- Some fixes for i80003 and ICH{8,9,10} from e1000 driver and document:
- Add setting for KABGTXD register for ICH{8,9,10}.
- ICH9 and ICH10 has no FCAL, FCAH and FCT like ICH8.
- Add special setting for FCTTV and TCTL_EXT register for i80003
- The special setting for TIPG is only for i80003.
- Some of kumeran settings are only for i80003's bugs.
- Add some ICH10 fixes.
- Fix the bug that another lock mechanism is used to access Kumeran
registers on i80003 and ICHs.
- Fix yet another i80003 ONLY workaround. The code to modifing TIPG
register is only for i80003.
- Set the Re-Transmit on Late Collision(RTLC) flag for all devices.
- Fix a typo in a printf message.
- If the difference bettween last flag and new flag is only IFF_PROMISC
or IFF_ALLMULTI, set multicast filter only to prevent link down.
Tested by Mark Davies and me. Fixes PR#29126 for wm.
- Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
- Fix igphy's 82566 support.
- Patch for the DSP code is only for 8254[17] and we have to apply
the different patches between rev. 1 and rev. 2.
- The workaround for analog fuse is only for 82547 rev. 1.
- The workaround for smartspeed is only for 8254[17]
- Sync with Intel's original em driver:
- Check PCI-X mode as e1000 driver.
- Add dspcode for igp3 and use it when the EEPROM isn't available.
- Add some delays.
- Stop the PHY transmitter before patching the DSP code and
restart it after writing.
- Save and restore register 0x2f5b.
 1.2.40.1 11-Mar-2010  yamt sync with head
 1.8.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.4.2 21-Apr-2010  matt sync to netbsd-5
 1.11.4.1 07-Mar-2010  matt file if_wmvar.h was added on branch matt-nb5-mips64 on 2010-04-21 00:27:42 +0000
 1.11.2.1 31-May-2011  rmind sync with head
 1.12.10.7 06-May-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1366):
sys/dev/pci/if_wm.c: 1.281, 1.318, 1.320, 1.324-1.332, 1.334, 1.336, 1.343-1.344, 1.347-1.348, 1.350, 1.376-1.382, 1.386-1.387, 1.389 via patch
sys/dev/pci/if_wmreg.h: 1.68-1.70, 1.73-1.77, 1.79-1.80, 1.82, 1.86-1.88 via patch
sys/dev/pci/if_wmvar.h: 1.22-1.23, 1.25-1.30 via patch
sys/dev/mii/igphy.c: 1.25
sys/dev/mii/ukphy.c: 1.48
Sync wm(4) as of if_wm.c rev 1.389 except SERDES, MSI/MSI-X, multiqueue
and NET_MPSAFE:
- Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is more
than 4096. Almost the same as other OSes.
- For 82576 and newer devices, the PBA register is deleted. Don't write
PBA for those chips. Also change the calculation of RX packet buffer
size in new way.
- Print NVM image version and option ROM version.
- Add workaround for I210 Errata 25 and I211 Errata 10 (PLL bug). This
workaround is required if the NVM image version < 3.25.
- Fix a bug that wm_detach() didn't unmap the FHASH's area. Now
"drvctl -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
- Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX
packets" and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit.
The NVM Image version 2.1.4 and newer have this workaround.
- Check PHY type correctly. This change is required to use igphy(4)
device correctly.
- Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH*
too.
- Call wm_get_hw_control() correctly. This change fixes a bug that some
AMT based systems doesn't linkup at 1000BaseT. The problem was
observed on HP Compaq dc7700. A lot of fixes have been done for wm(4)
and igphy(4), so now PR#44893 should be fixed.
- Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT. It's required to
check the existence of AMT correctly.
- Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in
wm_reset() on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix
the behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change
might fix a problem that PHY's read/write functions can't get
semaphore.
- On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed
down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS
sets this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the
function checks the status correctly but it causes linkdown up to 10
times, so it's disabled for the time being.
- PR/50527: David Binderman: Fix impossible code. Odd offsets need
special treatment.
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Use sc->sc_itr instead of hard-coded number.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function
acts as mii_tick().
- ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition has not used yet.
- Add ACK data Disable bit's definition (not used yet).
- PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any
effect by default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when
WM_WOL is defined and it's disabled by default.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it
returns bool. No functional change.
- Reorder function definitions and macro definitions. No functional
change.
- Fix comment. Add comment. Update comment.
- KNF.
 1.12.10.6 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1296):
sys/dev/pci/pcidevs: revision 1.1195 via patch
sys/dev/pci/if_wm.c: revisions 1.290, 1.304 via patch
sys/dev/pci/if_wmvar.h: revision 1.20 via patch
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and
check the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- Support DH89xxCC device.
- Add extra delay for 82580 and newer devices except DH89XXCC SGMII device.
Same as FreeBSD.
 1.12.10.5 04-Dec-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #1203):
sys/dev/pci/if_wm.c: revisions 1.271, 1.273-1.274, 1.277-1.278,
1.280, 1.282, 1.284-1.285, 1.287,
1.293-1.294, 1.297-1.298,
1.300-1.301, 1.305-1.307 via patch
sys/dev/pci/if_wmreg.h: revisions 1.57-1.62, 1.64-1.65 via patch
sys/dev/pci/if_wmvar.h: revisions 1.19, 1.21 via patch
- Acquire SW semaphore in wm_get_swsm_semaphore().
- Fix some bugs realted to semaphore. This change fixes a problem which
was exposed in if_wm.c rev. 1.271. Tested by riastradh@.
- Clear the SMBI bit in SWSM register before accessing NVM and PHY in
wm_attach(). Same as FreeBSD.
- Fix a bug that 82573 doesn't put the hardware semaphore. Same as
FreeBSD r256200.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880). Tested with 82543GC, 82544EI,
82545EM, 82546GB 82571EB and 82572EI fiber cards.
- Don't use the RXCFG interrupt. It's not required and the interrupt is very
heavy (a lot of interrupts). Same as {Free,Open}BSD.
- Modify wm_tbi_mediachange() to be close to em_setup_fiber_serdes_link()
of {Free,Open}BSD. At least, don't forget to set duplex setting.
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Don't check SWSM_SMBI bit if WM_F_LOCK_SWSM isn't set. Fix a problem when
using vmware with e1000"e". With e1000e which is regarded as 82574L,
wm_gmii_init() fails with "could not acquire SWSM SMBI" message without
this change. This problem doesn't occur with real 82574L card.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Calculate NVM word size correctly.
- Determine timeout value based on the NVM word size.
- It's not required to print "failed to detect NVM bank" message.
Only print while debugging. Same as {Free,Open}BSD.
- Add some new I218 devices.
- Delete 82580ER related code. It was from FreeBSD and was removed in r203049.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Move some NVM related macros from if_wm.c to if_wmreg.h.
- Sort definitions in if_wmreg.h
- move NVM related values to the bottom.
- sort in register's address' order.
- Simplify wm_read_mac_addr().
- Fix debug message.
- Add missing prototypes.
- Rename some functions for consistency and clarify.
- Rename some macros for consistency.
- Remove a duplicated error message.
- Fix typo in comment.
- Cleanup comments.
- KNF.
 1.12.10.4 09-Nov-2014  martin Pullup the following revisions, requested by msaitoh in ticket #1188:
sys/dev/pci/pcidevs 1.1172
sys/dev/pci/if_wm.c 1.263-1.266 via patch
sys/dev/pci/if_wmreg.h 1.55-1.56
sys/dev/pci/if_wmvar.h 1.17
share/man/man4/wm.4 1.26-1.27 and 1.29 via patch

- Add I354 support.
- Insert completion barrier between register write and delay().
- Fix the definition of CTRL_GIO_M_DIS. This bit is not bit 3 but bit 2.
- Cleanup
 1.12.10.3 14-Jul-2013  riz Apply changes (requested by msaitoh in ticket #907):

sys/dev/pci/if_wm.c 1.238, 1.244-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.50-1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16

Various fixes to wm(4):
Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Change style, add comments, fix some comments, use macros and
remove trailing whitespaces.
[msaitoh, ticket #907]
 1.12.10.2 14-Feb-2013  jdc Pull up revisions:
src/sys/dev/pci/if_wm.c revision 1.243
src/sys/dev/pci/if_wmvar.h revision 1.14
(requested by msaitoh in ticket #820).

Use 82580(and I350) specific PHY read/write functions.
Fixes PR#47542.
 1.12.10.1 28-Jun-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #362):
sys/dev/pci/if_wm.c 1.228
sys/dev/pci/if_wmreg.h 1.47
sys/dev/pci/if_wmvar.h 1.13
sys/dev/pci/pcidevs 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
share/man/man4/wm.4 1.22-1.25

Add support for Intel I350 Ethernet.
Update document.
 1.12.8.1 02-Jun-2012  mrg sync to latest -current.
 1.12.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.4.1 30-Oct-2012  yamt sync with head
 1.13.2.4 03-Dec-2017  jdolecek update from HEAD
 1.13.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.2.2 23-Jun-2013  tls resync from head
 1.13.2.1 25-Feb-2013  tls resync with head
 1.16.2.1 18-May-2014  rmind sync with head
 1.17.2.1 10-Aug-2014  tls Rebase.
 1.19.2.7 11-Aug-2018  martin Pull up the following, requested by msaitoh in ticket #1628:

share/man/man4/wm.4 1.40 via patch
sys/dev/mii/ihphyreg.h 1.2
sys/dev/mii/inbmphyreg.h 1.10
sys/dev/pci/if_wm.c 1.504, 1.506, 1.510-1.535, 1.539-1.540, 1.546, 1.548, 1.551-1.552, 1.558, 1.565-1.573, 1.575, 1.579, 1.582, 1.584 via patch
sys/dev/pci/if_wmreg.h 1.99-1.103, 1.106-1.107 via patch
sys/dev/pci/if_wmvar.h 1.34-1.39 via patch
sys/dev/pci/pcidevs 1.1327 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/pci/pcireg.h patch

Sync wm(4) up to 2018/08/08 except MSI/MSI-X and NET_MPSAFE:
- remove extra "+"
- Fix a bug that non-GMII devices don't send a routing message when
the link status is changed.
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset(). Same as
other OSes.
- If a interrupt is a spurious interrupt, don't print debug message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Print sc_flags with snprintb().
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Add CSR_WRITE_FLUSH() after writing WMREG_CTRL in
wm_gmii_mediachange().
- Add missing "else" in wm_nvm_release().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for wrokaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if
it's required.
- If TX is not required to flush, RX is also not required to flush
in wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset(). Some
flags and callback function are required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Use new nvm.{acquire,release}() for semaphore.
- Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required
for these functions to use the same API. So,
- Change return value as error code.
- Change register value from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally on I21[01]". PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
sc->sc_nvm_wordsize before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Print NVM offset and word count when EERD polling failed.
- On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
- 82583 supports jumbo frame. Fixes PR#52773 reported by
Shinichi Doyashiki.
- Fix typo in comment. Reported by Shinichi Doyashiki in PR#52885.
- Add ASPM workaround for 8257[1234] and 82583 to prevent device
timeout or hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
- CID-1427779: Fix uninitialized variables.
- Fix a bug that wm_pll_workaround_i210() is not called when
a) Chip is I211 or b) Chip is I210 and it uses iNVM (not FLASH).
- Do wm_reset_mdicnfg_82580() on 82580 only.
- Fix FLASH access on PCH_SPT and newer. Their FLASH access should be
done by 32bit. Especially for ICH_FLASH_HSFCTL register, it's located
at 0x0006, so it must be accessed via ICH_FLASH_HSFSTS(0x0004) and
use shift or mask.
- Make wm_nvm_valid_bank_detect_ich8lan() the same as other OSes.
- If the extended configuration size in the EXTCNFSIZE register is 0,
don't continue in wm_init_lcd_from_nvm().
- Add PCH_CNP support (I219 with Intel 300 series chipset).
- Enable I219 support.
- I354 uses an external PHY, so don't use wm_set_eee_i350().
- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber.
- Fix a bug that 82542 misunderstand fiber's signal detection.
- Add debug printf()s.
- Update comment.
- Rename functions and variables.
- Add diagnostic code.
- Sort registers.
- Lowercase hexadecimal values.
- KNF.
 1.19.2.6 09-Mar-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #1372):
sys/dev/pci/if_wm.c: revisions 1.462, 1.464-1.465 1.474 via patch
sys/dev/pci/if_wmreg.h: revision 1.97
sys/dev/pci/if_wmvar.h: revision 1.33
- Set IPV6EXDIS bit in RFCTL register because of an Errata on 82575 and
newer devices.
- Linux and FreeBSD defines 0x10f5 as E1000_DEV_ID_ICH9_IGP_M_AMT. In
reality, This is not IGP but BM. Add new case to identify PHY type
device. Fixes PR#51924 reported byJarle Greipsland.
- Use new wm_gmii_setup_phytype() function to setup sc_phytype and
mii_{read|write}reg. This change improves detection of PHY type.
- Fix typo in comment.
 1.19.2.5 12-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1302):
sys/dev/mii/igphyreg.h: revisions 1.7-1.10
sys/dev/mii/ikphyreg.h: revisions 1.3
sys/dev/mii/inbmphyreg.h: revisions 1.4-1.9
sys/dev/mii/mii.h: revisions 1.19-1.20
sys/dev/pci/if_wm.c: revisions 1.390, 1.392-1.395, 1.397, 1.419-1.425, 1.427-1.428, 1.430-1.435, 1.437-1.453 via patch
sys/dev/pci/if_wmreg.: revisions 1.89-1.93 via patch
sys/dev/pci/if_wmvar.h: revisions 1.31-1.32
Update wm(4) up to if_wm.c rev. 1.453 except MSI/MSI-X, multiqueue and
NET_MPSAFE:
- Add I219 support. It's not stable so it's disabled by default.
- wm_gate_hw_phy_config_ich8lan() is for younger than PCH2.
- Drop the host wakeup bit after resetting PHY on PCH and newer
devices.
- Increase delay while toggling LANPHYPC
- Move call of wm_reset() in wm_attach() after setting PHY and NVM
related flags because those flags are used in wm_reset().
- Use mutex for NVM access on ICH8 and newer devices. Same as FreeBSD.
- Rewrite PHY related lock stuff. Almost the same as FreeBSD.
This change will fix a bug that PHY read/write fail on some cases.
- Increase delay in wm_phy_resetisblocked(). Same as FreeBSD.
- Use semaphore in wm_hv_phy_workaround_ich8lan() and
wm_k1_gig_workaround_hv()
- Use wm_gii_mdic_readreg/writereg() in wm_access_phy_wakeup_reg_bm()
because these functions are called with taking lock.
- 82567V_3 is BME1000_E_2(bm). Tested with Advantech AIMB-212 1st
Ethernet port.
- Use wm_gmii_82544_{read,write}reg() on non-82567 ICH8, 9 and 10.
- Remove an 82578 workaround which was for PCH rev < 3. FreeBSD
removed this workaround in r228386.
- Add an 82578 workaround which is for PHY rev < 2. From FreeBSD and
Linux.
- Fix wm(4) input drop packet counter. WMREG_RNBC is incremented when
there is no available buffers in host memory. However, ethernet
controller can receive packets in such case if there is space in
phy's FIFO. That is, ethernet controller drops packet only if there
is no available buffers *and* there is no space in phy's FIFO. So,
the number of dropped packets should be added WMREG_MPC only.
- Use MII_ADDRMASK.
- Define WMPHY_I217, WMPHY_VF and WMPHY_210.
- Use BME1000_PHY_PAGE_SELECT in wm_gmii_bm_{read,write}reg(). This
change has no effect because GG82563_PHY_PAGE_SELECT and
BME1000_PHY_PAGE_SELECT have the same value.
- Fix PHY access on 82567(ICH8 or ICH10), 82574 and 82583:
- Use wm_gmii_bm_{read,write}reg() on 82574 and 82573.
- Issue page select correctly on BM PHYs.
- Fix workaround which did dummy read BM_WUC register. This code was
changed to drop BM_WUC_HOST_WU_BIT of BM_PROT_GEN_CFG register in
FreeBSD r228386. The code was added rev. 1.149, but the location was
not the best.
- wm_gmii_hv_{read/write}reg*(): USE PHY address 1 for some special
registers.
- Add check code for an 82578 workaround. Not completed yet.
- wm_release_hw_control(): Remove extra line. No any effect.
- Add "10/100" into non-gigabit devices' name.
- Call wm_enable_wakeup() in wm_detach() and wm_suspend(). Now wake on
lan works on Thinkpad X61(ICH8).
- Fix wm_access_phy_wakeup_reg_bm(). This change has no effect because
this function is used for WUC register and our driver currenlty
doesn't access to it.
- Call wm_enable_phy_wakeup() on PCH2 and newer, too. Now these devices
can do WOL. Tested with Thinkpad X220(PCH2).
- Set CTRL_MEHE correctly (PCH_{LPT,SPT} only).
- Add three workarounds for PCH_{LPT,SPT}.
- Fix a bug that 8257[56], 82580, I35[04] and I21[01] didn't use
wm_{get,release}_hw_control() correctly.
- Sync wm_smbustopci() with Linux and FreeBSD. This change effects PCH
and newer devices.
- Move the location of wm_smbustopci() call.
- Fix flag check in wm_get_wakeup()
- 8254[17]* and 8257[124] should not set WM_F_ARC_SUBSYS_VALID.
- Add missing WM_T_82541_2 and WM_T_82547_2.
- Fix WOL related setting of the WUC register for other than PCH* in
wm_enable_wakeup(). Tested with 82567V(ICH8) and 82583V.
- Use common MII_ADDRMASK.
- igphy(4): No binary change:
- s/IGPPHY/IGPHY/
- Fix the definition of PLHR_VALID_CHANNEL_*
- Fix the definition of MSE_CHANNEL_*
- Add MII_IGPHY_POWER_MGMT.
- Add some KASSERT.
- Add comment. Modify comment.
- Add debug code.
 1.19.2.4 26-Feb-2016  snj branches: 1.19.2.4.2;
Pull up following revision(s) (requested by msaitoh in ticket #1102):
sys/dev/mii/igphy.c: 1.25
sys/dev/mii/ukphy.c: 1.48
sys/dev/pci/if_wm.c: revisions 1.308, 1.318, 1.320, 1.324-1.332, 1.334, 1.336, 1.343-1.344, 1.347-1.348, 1.350, 1.376-1.382, 1.386-1.389 via patch
sys/dev/pci/if_wmreg.h: revisions 1.68-1.70, 1.73-1.77, 1.79-1.80, 1.82, 1.86-1.88 via patch
sys/dev/pci/if_wmvar.h: revisions 1.22-1.23, 1.25-1.30 via patch
Sync wm(4) as of if_wm.c rev 1.389 except MSI/MSI-X, multiqueue and NET_MPSAFE:
- Add C2000 KX and 2.5G support.
- Set ICH9 and ICH10's PBA size to 14K if the RX buffer size is more than
4096. Almost the same as other OSes.
- For 82576 and newer devices, the PBA register is deleted. Don't write PBA
for those chips. Also change the calculation of RX packet buffer size in
new way.
- Fix a lot of bugs to make 82575 and newer SERDES based systems work.
- Print NVM image version and option ROM version.
- Add workaround for I210 Errata 25 and I211 Errata 10 (PLL bug). This
workaround is required if the NVM image version < 3.25.
- Fix a bug that wm_detach() didn't unmap the FHASH's area. Now
"drvct -d wm0" -> "drvctl -r pci0" works on ICH* and PCH*.
- Add workaround for 82574 Errata 25 and 82583 Errata 12 "Dropped RX packets"
and for 82573 (unknown). Set GCR_L1_ACT_WITHOUT_L0S_RX bit. The NVM Image
version 2.1.4 and newer have this workaround.
- Check PHY type correctly. This change is required to use igphy(4) device
correctly.
- Disable LPLU (Low Power Link Up) on D0 state on 82574, 82583 and ICH* too.
- Call wm_get_hw_control() correctly. This change fixes a bug that some AMT
based systems doesn't linkup at 1000BaseT. The problem was observed on HP
Compaq dc7700. A lot of fixes have been done for wm(4) and igphy(4), so now
PR#44893 should be fixed.
- Call wm_get_wakeup(sc) before checking WM_F_HAS_AMT. It's required to
check the existence of AMT correctly.
- Fix a problem that wm_gate_hw_phy_config_ich8lan() isn't called in
wm_reset() on PCH2.
- Clear WMREG_WUC in wm_reset() if the chip >= 82544. This might fix the
behavior on suspend/resume.
- Fix logic of wm_check_reset_block() on ICH* and PCH*. This change might fix
a problem that PHY's read/write functions can't get semaphore.
- On ICH8, call wm_gig_downshift_workaround_ich8lan() when link changed down.
- Drop PHY_CTRL_GBE_DIS explicitly in wm_lplu_d0_disable() in case BIOS sets
this bit.
- Fix two bugs in wm_kmrn_lock_loss_workaround_ich8lan(). Now the function
checks the status correctly but it causes linkdown up to 10 times, so it's
disabled for the time being.
- PR/50527: David Binderman: Fix impossible code. Odd offsets need special
treatment.
- Fix RAL table's size of PCH2 and PCH_LPT.
- PCH_LPT (and newer device) is required to check FWSM_WLOCK_MAC bit to
determine the range of the RAL.
- Use sc->sc_itr instead of hard-coded number.
- Rename wm_tbi_check_link() to wm_tbi_tick() because this function acts as
mii_tick().
- ACK Accelerate Disable in the RFCTL register is not bit 13 but 12.
No binary change because this definition has not used yet.
- Add ACK data Disable bit's definition (not used yet).
- PHY_CTRL_GBE_DIS is not bit 4 but bit 6. This change has no any effect by
default because WM_WOL is not defined yet and
m_kmrn_lock_loss_workaround_ich8lan() is broken.
- Fix wm_check_mng_mode_ich8lan(). This function is used only when WM_WOL is
defined and it's disabled by default.
- Rename wm_check_reset_block() to wm_phy_resetisblocked() and make it returns
bool. No functional change.
- Reorder function definitions and macro definitions. No functional change.
- Fix comment. Add comment. Update comment.
- KNF.
 1.19.2.3 19-May-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #784):
sys/dev/pci/if_wm.c: revision 1.321
sys/dev/pci/if_wmreg.h: revision 1.71
sys/dev/pci/if_wmvar.h: 1.24 via patch
Add support iNVM (integrated Non-Volatile Memory) for I21[01].
This change fixes a bug that a MAC address is wrongly set on
iNVM machines/NICs.
 1.19.2.2 07-Nov-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #190):
sys/dev/pci/pcidevs 1.1201-1.1202 via patch
sys/dev/pci/if_wm.c 1.291-1.301, 1.304, 1.306-1.307 via patch
sys/dev/pci/if_wmreg.h 1.61-1.65 via patch
sys/dev/pci/if_wmvar.h 1.21 via patch
share/man/man4/wm.4 1.31 via patch
- Add Internal SERDES mode support newer than or equal to 82575.
- Add new I218 devices.
- Add DH89xxCC device.
- Add some old devices.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Don't print "failed to detect NVM bank" message.
- Delete 82580ER related code.
- Fix typo in comment.
- Fix debug message.
- Cleanup
 1.19.2.1 29-Aug-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #61):
sys/dev/pci/if_wm.c: revision 1.290
sys/dev/pci/if_wmvar.h: revision 1.20
Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
 1.19.2.4.2.2 13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.19.2.4.2.1 18-Jan-2017  skrll Sync with netbsd-5
 1.23.2.6 28-Aug-2017  skrll Sync with HEAD
 1.23.2.5 05-Feb-2017  skrll Sync with HEAD
 1.23.2.4 05-Dec-2016  skrll Sync with HEAD
 1.23.2.3 29-May-2016  skrll Sync with HEAD
 1.23.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.23.2.1 06-Jun-2015  skrll Sync with HEAD
 1.31.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.31.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.32.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.6.12 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1915:

sys/dev/pci/pcidevs 1.1497
sys/dev/pci/if_wm.c 1.689,1.790-1.791 via patch
sys/dev/pci/if_wmreg.h 1.120 via patch
sys/dev/pci/if_wmvar.h 1.51

- Use 12K for packet buffer for jumbo frame on PCH2 and newer.
- Add new workaround for Tiger Lake and newer to avoid packet loss.
- Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.33.6.11 04-Sep-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1894):

sys/dev/pci/if_wmvar.h: revision 1.50
sys/dev/pci/if_wm.c: revision 1.783,1.784 via patch

Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.

Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.33.6.10 27-Jun-2023  martin Pull up the following revisions, requested by msaitoh in #1847:

sys/dev/pci/if_wm.c 1.768-1.782 via patch
sys/dev/pci/if_wmreg.h 1.129-1.130
sys/dev/pci/if_wmvar.h 1.49

wm(4):
- Rework for event counters:
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Rearrange the order of the registers so that they are roughly
in ascending order.
- Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach()
to match.
- IC{TX,RX}*C registers are for older than 82575.
- Fix a bug that the transmit underrun counter is incorrectly
counted.
- Don't add "Count" for event counter's description.
- Some statistics registers were replaced with new counters on newer
chips. Treat 0x403c(CEXTERR->HTDPMC), 0x40fc(TSCTFC->CBRMPC),
0x4124(ICRXOC->HTCBDPC) and from 0x4104 to 0x4124.
- Add some new counters:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- Host Good Octets RX
- Host Good Octets TX
- Length Errors
- SerDes/SGMII Code Violation Packet
- Header Redirection Missed Packet
- EEE TX LPI
- EEE RX LPI
- Fix prc511's comment and description.
- Add SOICZIFDATA (ifconfig -z) support for evcnt(9).
- Use WM_IS_ICHPCH(). No functional change.
- Fix typo. s/ictxact/ictxatc/. No functional change.
- Add comment.
 1.33.6.9 11-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1751:

sys/dev/pci/if_wmreg.h 1.122-1.125 via patch
sys/dev/pci/if_wmvar.h 1.48
sys/dev/pci/if_wm.c 1.719-1.720,1.722-1.725,
1.727-1.740 via patch

- wm_tick: Add missing splx(s) when not WM_MPSAFE.
- Print DMA range info if the system is booting in the verbose mode.
- Micro optimization:
- Call m_freem(m) only if m0 == NULL.
- Call wm_xxeof() only when limit > 0.
- Don't set the more flag when there is no packet to process.
- No functional changes:
- Call txeof first, then rxeof for the consistency.
- Remove duplicated break.
- Remove stray semicolons from struct declaration.
- Fix value return from void function.
- Use macros.
- Modify comment.
- KNF.
 1.33.6.8 23-Oct-2021  martin Pull up the following, requested by msaitoh in ticket #1701:

share/man/man4/wm.4 1.42
sys/dev/pci/files.pci 1.434
sys/dev/pci/if_wm.c 1.686-1.687,1.692-1.693,
1.697,1.699-1.703,
1.706-1.715 via patch
sys/dev/pci/if_wmvar.h 1.46

- Add missing drain for pcq in wm_stop_locked().
- Add support for I219V 15-19 and I219LM 16-19.
- Fix Tx stall.
- Use wm_flush_desc_rings() workaround more on I219.
- Change DMA physical address in wm_flush_desc_rings() to match other
OSes.
- Check return value correctly in wm_lv_jumbo_workaround_ich8lan().
- Add new sysctl hw.wmN.debug_flags. This sysctl can be used if
WM_DEBUG is set.
- Add some sysctl values for debugging TX/RX queues.
- WM_EVENT_COUNTER is enabled by default on 64 bit architectures.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxq->rxq_ptr updating.
- Stop legacy interrupts before calling softint.
- Disable printf()s in wm_flush_desc_rings() because the code is
verified.
- Print I219's version number.
- Uniform INTx/MSI handler's Tx/Rx behavior to MSI-X's one.
- Fix return value of interrupt handler.
- Only print an error about missing I/O BARs for chips that need it.
- Do not return a void value from a void function.
- Add new flag named WM_F_CRC_STRIP and use it. No functional change.
- Whitespace fixes. Fix comments. No functional change.
 1.33.6.7 04-Nov-2020  martin Pull up following revision(s) (requested by knakahara in ticket #1620):

sys/dev/pci/if_wm.c: revision 1.694
sys/dev/pci/if_wm.c: revision 1.695 (via patch)
sys/dev/pci/if_wmvar.h: revision 1.47

Add WMPHY_I350. Not used yet.

Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).
These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981
Reviewed and tested by msaitoh@n.o, thanks.
XXX pullup-[89]
 1.33.6.6 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1594:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660,
1.662, 1.664-1.668,
1.671-1.674, 1.678,
1.680-1.685 via patch
sys/dev/pci/if_wmreg.c 1.118-1.119 via patch
sys/dev/pci/if_wmvar.c 1.45 via patch
sys/dev/mii/igphy.c 1.35-1.36 via patch
sys/dev/mii/igphyreg.h 1.12-1.13
sys/dev/mii/makphy.c 1.66 via patch
sys/dev/mii/makphyreg.h 1.11

- Add SFP support. Module insertion/removal is not supported yet.
Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler).
Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0 which use softint
as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
fragmented UDP, first packet and second packet should be processed
in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
in case it's already set.
- Actually writing always the checksum offload context descriptor
makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Explicitly cast from uint16_t to uint32_t before shifting 16bit left
when printing Image Unique ID to avoid undefined behavior.
- Set if_baudrate for non-MII device.
- Rename some macros and function.
- KNF. Add comment.
 1.33.6.5 07-Mar-2019  martin Pull up the following, requested by msaitoh in ticket #1206:

sys/dev/pci/if_wmreg.h 1.113
sys/dev/pci/if_wmvar.h 1.43-1.44
sys/dev/pci/if_wm.c 1.626-1.627, 1.629-1.636 via patch

- Add support for I210 SGMII Flash-less device.
- Add I219 variations for Cannon Lake.
- Add missing rnd_detach_source().
- Use do { ... } while (0) for DPRINTF(x, y).
- Swap enumeration of 82578 and 82577 PHY in if_wmvar.h. No functional
change.
- Add KASSERT.
- Update TODO list. Add comment. Fix typo in comment.
 1.33.6.4 31-Jan-2019  martin Pull up the following, requested by msaitoh in ticket #1179:

sys/dev/pci/if_wm.c 1.603-1.605,1.607-1.611,
1.613,1.615,1.618-1.620
via patch
sys/dev/pci/if_wmreg.h 1.110-1.111
sys/dev/pci/if_wmvar.h 1.40-1.42
sys/dev/mii/inbmphyreg.h 1.13-1.15

- Add some code for suspend/resume:
- Rename wm_smbustopci() to wm_init_phy_workarounds_pchlan(). It will
also called when resume.
- Call wm_phy_resetisblocked() after PHY reset in
wm_init_phy_workarounds_pchlan() to wait for the PHY to quiesce to
an accessible state.
- Add new wm_resume_workarounds_pchlan() function and use it in
wm_resume(). This workaround is only for PCH2 and newer.
- Don't call wm_disable_aspm() neither in wm_attach() nor in
wm_resume() but in wm_reset().
- Do some initialization in wm_resume() when IFF_UP is NOT set.
- Don't continue when it failed to acquire semaphore in
wm_ulp_disable().
- Print CLSEM workaround bit correctly.
- Fix availability detection of WoL on some chips.
- Print the WUS (WakeUp Status) register bits when resume.
- Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
- Remove an extra register read in
wm_kmrn_lock_loss_workaround_ich8lan().
- Don't leave the MDICNFG register modified when the Power Management
capability offset can't get.
- Reduce indent level of wm_linkintr_gmii(). No functional change.
- 80003's SERDES is not the same as 82575's but the same as legacy
devices. Use the old methods on 80003.
- Use __nothing for null DPRINTF().
- Rename functions. Add comment.
 1.33.6.3 11-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #969):

sys/dev/pci/if_wm.c: revision 1.584
sys/dev/pci/if_wmvar.h: revision 1.39

Add MDIC_WA and CLSEMWA to snprintb() string for WM_F_* flags.

Fix two bugs for non-SERDES fiber. Tested on 82544EI(0x1009), 82545GM(0x1027),
82546GB(0x107a), 82571GB(0x105f), 82572EI(0x107e). Tested on SERDES
82580(0x150e (Winyao SERDES SFP)) and 82580(0x150e) as regression test:

- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber. When the signal is detected & STATUS_LU == 0 & RXCW == 0,
it's required to set CTRL_SLU and CTRL_FD bit. wm_check_for_link() is the
function to do it. If a link status change interrupt occurred, call
wm_check_for_link() before checking current link status.

- Fix a bug that 82542 misunderstand fiber's signal detection. CTRL_SWDPIN(1)
is used for fiber's signal and it's value is reversed only on 82543 and
82544. Simplify the code and move it into a new function wm_tbi_havesignal()
and use it.
 1.33.6.2 16-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #764):

sys/dev/pci/if_wm.c: revision 1.567
sys/dev/pci/if_wm.c: revision 1.568
sys/dev/pci/if_wm.c: revision 1.569
sys/dev/pci/if_wmvar.h: revision 1.38
sys/dev/pci/if_wm.c: revision 1.570
sys/dev/pci/if_wm.c: revision 1.571
sys/dev/pci/if_wm.c: revision 1.572
share/man/man4/wm.4: revision 1.40
sys/dev/pci/if_wmreg.h: revision 1.106
sys/dev/pci/if_wmreg.h: revision 1.107

SW PHY Config Enable bit for ICH8 B0 stepping is not bit 1 but bit 0.

No binary change:
- Sort registers.
- Lowercase hexadecimal value.

On PCH_SPT (and newer), FLASH access should be done by 32bit.
Especially for ICH_FLASH_HSFCTL register, it's located at 0x0006, so
it should be accessed via ICH_FLASH_HSFSTS(0x0004) and use shift or mask.

Our PCH_SPT part of wm_nvm_valid_bank_detect_ich8lan() was based on
FreeBSD r287467. After that, they reverted it and committed the different
code in r287762. r287762's bank detect code didn't work for us because our wm
dirver had a problem in flash access. The problem was fixed in if_wm.c rev.
1.567, so we can use the new way now.

If the extended configration size in the EXTCNFSIZE register is 0, don't
continue.
Add PCH_CNP support (I219 with Intel 300 series chipset).
It's required more test, so it's disabled by default.

Enable I219.

I354 uses an external PHY, so don't use wm_set_eee_i350().
 1.33.6.1 01-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #173):
sys/dev/pci/if_wmreg.h: 1.99-1.103
sys/dev/pci/if_wmvar.h: 1.34-1.37
sys/dev/pci/if_wm.c: 1.510-1.537
sys/dev/mii/ihphyreg.h: 1.2
sys/dev/mii/inbmphyreg.h: 1.10
sys/dev/mii/igphy.c: 1.27
Sync wm(4) up to if_wm.c rev. 1.537:
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset().
- If a legacy interrupt is a spurious interrupt, don't print debug
message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Flush writing WMREG_CTRL in wm_gmii_mediachange().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Add I219 specific workaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for workaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- IF TX is not required to flush, RX is also not required to flush in
wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset().
Some flags and callback function is required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Configure the LCD with the extended configuration region in NVM if
it's required. Tested with Thinkpad X220.
- 8257[12]: Don't directly access SPI but use EERD register.
- 82575-I354: If the size of SPI ROM >= 32K words, use direct SPI
access instead of EERD register access.
- Add wm_nvm_eec_clock_raise() and wm_nvm_eec_clock_lower() and use
them for Microwire/SPI bus control. Same as Linux and FreeBSD.
- Reduce timeout value for 80003 in wm_get_swfw_semaphore(). Same as
Linux and FreeBSD.
- Change API of kmrn_{read,write}reg() and check the return value.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally." on I21[01]. PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
NVM word size before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Print internal driver flags when attaching.
- Add debug printf()s.
- Rename variables.
- Add comment, update comment and remove wrong comment.
 1.37.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.37.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.37.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.38.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.38.2.1 10-Jun-2019  christos Sync with HEAD
 1.44.4.7 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1754):

sys/dev/pci/pcidevs: revision 1.1497
sys/dev/pci/if_wm.c: revision 1.790
sys/dev/pci/if_wm.c: revision 1.791
sys/dev/pci/if_wmvar.h: revision 1.51

pcidevs: Add Intel I219{V,LM}({22,23})

wm(4): Add a new workaround for Tiger Lake and newer.
- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.

wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.44.4.6 04-Sep-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #344):

sys/dev/pci/if_wmvar.h: revision 1.50
sys/dev/pci/if_wm.c: revision 1.783,1.784 via patch

Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.

Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.44.4.5 27-Jun-2023  martin Pull up the following revisions, requested by msaitoh in #1656:

sys/dev/pci/if_wm.c 1.768-1.782 via patch
sys/dev/pci/if_wmreg.h 1.129-1.130
sys/dev/pci/if_wmvar.h 1.49

wm(4):
- Rework for event counters:
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Rearrange the order of the registers so that they are roughly
in ascending order.
- Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach()
to match.
- IC{TX,RX}*C registers are for older than 82575.
- Fix a bug that the transmit underrun counter is incorrectly
counted.
- Don't add "Count" for event counter's description.
- Some statistics registers were replaced with new counters on newer
chips. Treat 0x403c(CEXTERR->HTDPMC), 0x40fc(TSCTFC->CBRMPC),
0x4124(ICRXOC->HTCBDPC) and from 0x4104 to 0x4124.
- Add some new counters:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- Host Good Octets RX
- Host Good Octets TX
- Length Errors
- SerDes/SGMII Code Violation Packet
- Header Redirection Missed Packet
- EEE TX LPI
- EEE RX LPI
- Fix prc511's comment and description.
- Add SOICZIFDATA (ifconfig -z) support for evcnt(9).
- Use WM_IS_ICHPCH(). No functional change.
- Fix typo. s/ictxact/ictxatc/. No functional change.
- Add comment.
 1.44.4.4 11-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1477:

sys/dev/pci/if_wmreg.h 1.122-1.125
sys/dev/pci/if_wmvar.h 1.48
sys/dev/pci/if_wm.c 1.719-1.720,
1.722-1.725,
1.727-1.740 via patch

- wm_tick: Add missing splx(s) when not WM_MPSAFE.
- Print DMA range info if the system is booting in the verbose mode.
- Micro optimization:
- Call m_freem(m) only if m0 == NULL.
- Call wm_xxeof() only when limit > 0.
- Don't set the more flag when there is no packet to process.
- No functional changes:
- Call txeof first, then rxeof for the consistency.
- Remove duplicated break.
- Remove stray semicolons from struct declaration.
- Fix value return from void function.
- Use macros.
- Modify comment.
- KNF.
 1.44.4.3 04-Nov-2020  martin Pull up following revision(s) (requested by knakahara in ticket #1126):

sys/dev/pci/if_wm.c: revision 1.694
sys/dev/pci/if_wm.c: revision 1.695 (via patch)
sys/dev/pci/if_wmvar.h: revision 1.47

Add WMPHY_I350. Not used yet.

Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).
These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981
Reviewed and tested by msaitoh@n.o, thanks.
XXX pullup-[89]
 1.44.4.2 23-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1093):

sys/dev/pci/if_wmreg.h: revision 1.120
sys/dev/pci/if_wmvar.h: revision 1.46
sys/dev/pci/if_wm.c: revision 1.686
sys/dev/pci/if_wm.c: revision 1.687
sys/dev/mii/inbmphyreg.h: revision 1.20
sys/dev/pci/if_wm.c: revision 1.688
sys/dev/pci/if_wm.c: revision 1.689

s/ressource/resource/. Found by knakahara.

Add new flag named WM_F_CRC_STRIP and use it. No functional change.

This change also sets the RCTL_SECRC bit on I211 but it doesn't change
the behavior because I211 always strips CRC like I35[04] and I210.

Add a workaround for jumbo frame on PCH2 and newer. Tested by chs@.

- Add wm_lv_jumbo_workaround_ich8lan() and use it. From FreeBSD.
XXX For KUMCTRLSTA_OFFSET_HD_CTRL register modification, it's doubtful.
FreeBSD and Linux do the same thing that they set the same value on both
jumbo frame's enable case and the disable case. It seems the default value
is 0x0b0c and it's not changed on the enable case, so it might be a bug
on the enable case or the modification is not required.
- Rename I219_UNKNOWN1 to I82579_UNKNOWN1.
Use 12K for packet buffer for jumbo frame on PCH2 and newer.

XXX Note that Linux Use 14K.
 1.44.4.1 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #994:

sys/dev/pci/if_wm.c 1.655-1.658, 1.660, 1.662, 1.664-1.668,
1.671-1.674, 1.678,1.680-1.681 via patch
sys/dev/pci/if_wmreg.c 1.118-1.119
sys/dev/pci/if_wmvar.c 1.45

- Add SFP support. Module insertion/removal is not supported yet.
Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler.
Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
The default value of hw.wm*.txrx_workqueue is 0 which use softint
as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
fragmented UDP, first packet and second packet should be processed
in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
in case it's already set.
- Actually writing always the checksum offload context descriptor
makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Rename some macros and function.
- KNF. Add comment.
 1.48.4.3 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #421):

sys/dev/pci/pcidevs: revision 1.1497
sys/dev/pci/if_wm.c: revision 1.790
sys/dev/pci/if_wm.c: revision 1.791
sys/dev/pci/if_wmvar.h: revision 1.51

pcidevs: Add Intel I219{V,LM}({22,23})

wm(4): Add a new workaround for Tiger Lake and newer.
- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.

wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.48.4.2 04-Sep-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #344):

sys/dev/pci/if_wmvar.h: revision 1.50
sys/dev/pci/if_wm.c: revision 1.783
sys/dev/pci/if_wm.c: revision 1.784

Delay sending LINK_STATE_UP to prevent dropping packets on I35[04] and I21[01].

Some (not all) systems use I35[04] or I21[01] don't send packet soon
after linkup. The MAC send a packet to the PHY and any error is not
observed. This behavior causes a problem that gratuitous ARP and/or
IPv6 DAD packet are silently dropped. To avoid this problem, don't
call mii_pollstat() here which will send LINK_STATE_UP notification
to the upper layer. Instead, mii_pollstat() will be called in
wm_gmii_mediastatus() or mii_tick() will be called in wm_tick().

Note that the similar workaround is in Linux's igb driver though it's
only for I21[01].

OK'd by hikaru@ and knakahara@.

Fix #ifdef WM_DEBUG code in wm_gmii_i82544_{read,write}reg_locked.
 1.48.4.1 22-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #213):

sys/dev/pci/if_wm.c: revision 1.770
sys/dev/pci/if_wm.c: revision 1.771
sys/dev/pci/if_wm.c: revision 1.772
sys/dev/pci/if_wm.c: revision 1.773
sys/dev/pci/if_wm.c: revision 1.774
sys/dev/pci/if_wm.c: revision 1.775
sys/dev/pci/if_wm.c: revision 1.776
sys/dev/pci/if_wmreg.h: revision 1.129
sys/dev/pci/if_wm.c: revision 1.777
sys/dev/pci/if_wm.c: revision 1.778
sys/dev/pci/if_wmvar.h: revision 1.49
sys/dev/pci/if_wm.c: revision 1.779
sys/dev/pci/if_wm.c: revision 1.768
sys/dev/pci/if_wm.c: revision 1.769
sys/dev/pci/if_wmreg.h: revision 1.130
sys/dev/pci/if_wm.c: revision 1.780
sys/dev/pci/if_wm.c: revision 1.781

Count some 64bit counters correctly.
- Fix calculation of GORC, GOTC, TOR and TOT counters correctly.
- Found by knakahara.

Add note for the TORL register.

The TOR register includes error, flow control and broadcast rejected.

Sort lines. No functional change.

Rearrange the order of the registers so that they are roughly in ascending
order.

Sort lines. No functional change.

Reorder evcnt_attach_dynamic(), WM_EVCNT_ADD() and evcnt_detach() to match.
IC{TX,RX}*C registers are for older than 82575.

Fix a bug that the transmit underrun counter is incorrectly counted.
The transmit underrun bit in the transmit status filed is only for 82544
(and older?), so don't use the counter for newer chips. The bit is reserved
for newer chips, but the bit sometimes set on 82575 at least.

Don't add "Count" for event counter's description.

Some statistics registers were replaced with new counters.
- 0x403c was CEXTERR(Carrier Extension Error). 82575 and newer except 80003,
ICHs and PCHs have HTDPMC(Host Tx Discarded Packets by MAC). I don't really
know for 82575. The 82575 datasheet say nothing about it.
- The following two are changed for circuit breaker. Only 82576's datasheet
describes abut it, so the registers might be only for 82576.
Use those registers for 82575 and newer except 80003, ICHs and PCHs just in
case.
- 0x40fc was TSCTFC(TCP Segmentation Context Tx Fail). It was replaced by
the CBRMPC(Circuit Breaker Rx Manageability Packet) register.
- 0x4124 was ICRXOC(Interrupt Cause Receiver Overrun). It was replaced by
the HTCBDPC(Host Tx Circuit Breaker Dropped Packet) register.
- From 0x4104 to 0x4124:
- For 0x4124, 82575's datasheet says it's not changed(ICRXOC).
I don't know if it's correct. We use new HTCBDPC register for 82575.
- 82576 and newer changed the meaning.
- I don't know for 80003, ICHs and PCHs. Don't count those registers.
At least, those registers in PCH2 and PCH_CNP are all zero.

Add some new event counters.

Add the following counters for 82575 and newer except 80003, ICHs and PCHs:
- Only 82576 document describes about the circuit breaker,
so the following two might be only for 82575:
- Circuit Breaker TX Manageability Packet
- Circuit Breaker RX Dropped Packet
- 82575's document doesn't describe the following two, but we can see
the same value as GO{T,R}C have:
- Host Good Octets RX
- Host Good Octets TX
- 82575's document doesn't describe the LENERRS (Length Errors) counter.
I don't know if it has.
- Perhaps Non-SerDes/SGMII devices don't have SCVPC
(SerDes/SGMII Code Violation Packet) register. We don't care if
it's SerDes/SGMII or not for now.
- HRMPC (Header Redirection Missed Packet) appears only once
in 8257[56]'s datasheet. FreeBSD's igb counts it, so we do, too.
- Count the following two for I350 and newer. I don't know if PCHs have:
- EEE TX LPI
- EEE RX LPI

Move statistics updating code from wm_tick() to new wm_update_stats().
- To reuse.
- No functional change.

Add SOICZIFDATA (ifconfig -z) support for evcnt(9).

First update the statistics data, then clear the event counters,
and finally copy and clear if_data via ether_ioctl().

Fix prc511's comment and description.

Use WM_IS_ICHPCH(). No functional change.

Fix typo. s/ictxact/ictxatc/. No functional change.
 1.92 05-Dec-2021  msaitoh s/persistant/persistent/ in comment.
 1.91 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.90 05-Feb-2021  christos branches: 1.90.4;
PR/55975: Riccardo Mottola: Don't try to lock a mutex from an interrupt context.
 1.89 20-Mar-2020  sevan branches: 1.89.4;
Apply the same change as for if_iwi.c r1.114 here.

This driver sleeps during wpi_media_change(), and thus requires an adaptive
mutex for the media lock.
 1.88 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.87 10-Nov-2019  chs branches: 1.87.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.86 24-Jun-2019  jakllsch Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.
 1.85 22-Dec-2018  maxv Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
 1.84 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.83 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.82 20-Aug-2018  riastradh Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.
 1.81 20-Aug-2018  riastradh What we have created, we must destroy.
 1.80 26-Jun-2018  msaitoh branches: 1.80.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.79 23-Oct-2017  msaitoh branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.
 1.78 23-May-2017  ozaki-r branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.
 1.77 02-Feb-2017  nonaka wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.76 02-Feb-2017  jakllsch wpi(4): use MSI if available.
 1.75 08-Dec-2016  ozaki-r branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.74 10-Jun-2016  ozaki-r branches: 1.74.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.73 26-May-2016  ozaki-r Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.
 1.72 26-May-2016  ozaki-r Use M_GETCTX

No functional change.
 1.71 09-Jan-2015  bouyer Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net
 1.70 06-Jan-2015  bouyer As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.
 1.69 19-Dec-2014  bouyer Consistently take the interface down when the radio swicth is off.
 1.68 08-Aug-2014  jmcneill branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes
 1.67 07-Aug-2014  jmcneill Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.
 1.66 07-Aug-2014  jmcneill scanning fixes
 1.65 07-Aug-2014  jmcneill simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me
 1.64 05-Aug-2014  jmcneill bus_dmamap_sync for rx descriptors too, derived from openbsd driver
 1.63 05-Aug-2014  jmcneill Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.
 1.62 05-Jul-2014  jakllsch Use M_ZERO. From OpenBSD if_wpi.c 1.53.
 1.61 05-Jul-2014  jakllsch Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.
 1.60 02-Jul-2014  jakllsch No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.
 1.59 16-Jun-2014  jakllsch wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.
 1.58 29-Mar-2014  christos branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.57 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.56 30-Mar-2013  christos branches: 1.56.4;
replace function with macro
 1.55 30-Mar-2013  christos remove trailing whitespace
 1.54 25-Nov-2012  riastradh Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.
 1.53 04-Aug-2012  riastradh branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.
 1.52 02-Jun-2012  dsl Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.51 12-May-2012  khorben No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@
 1.50 30-Jan-2012  drochner branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.49 02-Apr-2011  mbalmer branches: 1.49.4; 1.49.8;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.
 1.48 15-Nov-2010  uebayasi branches: 1.48.2;
tsleep needs sys/proc.h.
 1.47 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.46 24-Feb-2010  dyoung branches: 1.46.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.45 19-Jan-2010  pooka branches: 1.45.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.44 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.43 05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.42 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.41 12-Nov-2008  joerg branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.
 1.40 07-Nov-2008  dyoung *** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.39 02-Jul-2008  cube branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.
 1.38 28-Apr-2008  drochner branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()
 1.37 11-Mar-2008  dyoung branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.
 1.36 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.35 19-Jan-2008  simonb branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.
 1.34 09-Jan-2008  degroote Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).
 1.33 09-Dec-2007  jmcneill branches: 1.33.2;
Merge jmcneill-pm branch.
 1.32 01-Dec-2007  jmcneill branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.
 1.31 28-Nov-2007  degroote In wpi_init, check for the status of radio switch and print a useful message
in this case.
 1.30 23-Nov-2007  plunky when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;
 1.29 23-Nov-2007  joerg If memory for the firmware image couldn't be allocated, print only
one error message.
 1.28 16-Nov-2007  degroote Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected
 1.27 07-Nov-2007  ad Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
 1.26 21-Oct-2007  degroote branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.
 1.25 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.24 02-Sep-2007  degroote branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.
 1.23 02-Sep-2007  degroote Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.
 1.22 01-Sep-2007  dyoung Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().
 1.21 01-Sep-2007  dyoung Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.20 26-Aug-2007  dyoung branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).
 1.19 15-Aug-2007  degroote Fix possible "packet corruption" which appears on high load
 1.18 04-Aug-2007  degroote branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).
 1.17 18-Jul-2007  degroote branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.
 1.16 11-Jul-2007  degroote branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)
 1.15 11-Jul-2007  xtraeme Use %zu to print a size_t, fixes the build on amd64.
 1.14 09-Jul-2007  ad Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.13 09-Jul-2007  degroote Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.
 1.12 09-Jul-2007  degroote Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org
 1.11 04-Jul-2007  pooka wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.
 1.10 18-Jun-2007  degroote Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.
 1.9 04-Mar-2007  christos branches: 1.9.2; 1.9.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.8 25-Jan-2007  njoly branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@
 1.7 13-Jan-2007  degroote Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@
 1.6 16-Nov-2006  christos branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.
 1.5 31-Oct-2006  joerg Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.2 13-Aug-2006  oster branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().
 1.1 13-Aug-2006  simonb Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.
 1.2.8.2 10-Dec-2006  yamt sync with head.
 1.2.8.1 22-Oct-2006  yamt sync with head
 1.2.6.2 09-Sep-2006  rpaulo sync with head
 1.2.6.1 13-Aug-2006  rpaulo file if_wpi.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:18 +0000
 1.2.4.2 01-Feb-2007  ad Sync with head.
 1.2.4.1 18-Nov-2006  ad Sync with head.
 1.2.2.2 03-Sep-2006  yamt sync with head.
 1.2.2.1 13-Aug-2006  yamt file if_wpi.c was added on branch yamt-pdpolicy on 2006-09-03 15:24:22 +0000
 1.6.6.2 30-Sep-2007  wrstuden Catch up on netbsd-4 as of a few days ago.
 1.6.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.6.4.9 17-Mar-2008  yamt sync with head.
 1.6.4.8 21-Jan-2008  yamt sync with head
 1.6.4.7 07-Dec-2007  yamt sync with head
 1.6.4.6 15-Nov-2007  yamt sync with head.
 1.6.4.5 27-Oct-2007  yamt sync with head.
 1.6.4.4 03-Sep-2007  yamt sync with head.
 1.6.4.3 26-Feb-2007  yamt sync with head.
 1.6.4.2 30-Dec-2006  yamt sync with head.
 1.6.4.1 16-Nov-2006  yamt file if_wpi.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:46 +0000
 1.6.2.3 27-Sep-2007  xtraeme Pull up following revision(s) (requested by degroote in ticket #860):
sys/dev/pci/if_wpivar.h: revision 1.7 (via patch)
sys/dev/pci/if_wpi.c: revision 1.18 (via patch)
sys/dev/pci/if_wpi.c: revision 1.19 (via patch)
sys/dev/pci/if_wpi.c: revision 1.23 (via patch)

Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).
Fix possible "packet corruption" which appears on high load
Fix scanning code for wpi based on the iwi code.
Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.
Moreover, it fixes WPA issues for me.
 1.6.2.2 27-Jul-2007  liamjfoy Pullup requested by degroote in ticket 795:
Rewrite of the rbuf management
Sync with the last OpenBSD driver
Use the last firmware available from Intel (2.4.14).
Use legal limitations and Tx regulation embedded in the eeprom.
Rewrite the way we handle the firmware.

Pullup the following revisions of this files
sys/dev/pci/if_wpi.c rev 1.7 1.8 1.10 1.12 1.13 1.15 1.16 1.17 via patch
sys/dev/pci/if_wpireg.h rev 1.3 1.4 1.5 via patch
sys/dev/pci/if_wpivar.h rev 1.3 1.5 1.6 via patch
 1.6.2.1 06-Jul-2007  liamjfoy Pull up following revision(s) (requested by pooka in ticket #756)
sys/dev/pci/if_wpi.c: revision 1.11

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.
 1.8.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.4.1 11-Jul-2007  mjf Sync with head.
 1.9.2.7 23-Oct-2007  ad Sync with head.
 1.9.2.6 09-Oct-2007  ad Sync with head.
 1.9.2.5 01-Sep-2007  ad Update for pool_cache API changes.
 1.9.2.4 20-Aug-2007  ad Sync with HEAD.
 1.9.2.3 15-Jul-2007  ad Sync with head.
 1.9.2.2 15-Jul-2007  ad Sync with head.
 1.9.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.16.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.16.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.17.4.15 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.17.4.14 03-Dec-2007  joerg Sync with HEAD.
 1.17.4.13 01-Dec-2007  jmcneill Sync with HEAD.
 1.17.4.12 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.17.4.11 21-Nov-2007  joerg Sync with HEAD.
 1.17.4.10 11-Nov-2007  joerg Sync with HEAD.
 1.17.4.9 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.17.4.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.4.7 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.17.4.6 04-Sep-2007  degroote Convert wpi_power to use pci_net_generic_power.
With this, I can use the card after resume.
 1.17.4.5 03-Sep-2007  jmcneill Sync with HEAD.
 1.17.4.4 02-Sep-2007  jmcneill Sync with HEAD.
 1.17.4.3 16-Aug-2007  jmcneill Sync with HEAD.
 1.17.4.2 09-Aug-2007  jmcneill Sync with HEAD.
 1.17.4.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.18.2.2 04-Aug-2007  degroote Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).
 1.18.2.1 04-Aug-2007  degroote file if_wpi.c was added on branch matt-mips64 on 2007-08-04 18:24:25 +0000
 1.20.2.4 23-Mar-2008  matt sync with HEAD
 1.20.2.3 09-Jan-2008  matt sync with HEAD
 1.20.2.2 08-Nov-2007  matt sync with -HEAD
 1.20.2.1 06-Nov-2007  matt sync with HEAD
 1.24.4.3 18-Nov-2007  bouyer Sync with HEAD
 1.24.4.2 13-Nov-2007  bouyer Sync with HEAD
 1.24.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.26.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.26.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.26.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.32.4.1 11-Dec-2007  yamt sync with head.
 1.32.2.1 26-Dec-2007  ad Sync with head.
 1.33.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.33.2.1 10-Jan-2008  bouyer Sync with HEAD
 1.35.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.35.6.3 02-Jul-2008  mjf Sync with HEAD.
 1.35.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.35.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.35.2.1 24-Mar-2008  keiichi sync with head.
 1.37.4.6 11-Aug-2010  yamt sync with head.
 1.37.4.5 11-Mar-2010  yamt sync with head
 1.37.4.4 16-Sep-2009  yamt sync with head
 1.37.4.3 16-May-2009  yamt sync with head
 1.37.4.2 04-May-2009  yamt sync with head.
 1.37.4.1 16-May-2008  yamt sync with head.
 1.37.2.1 18-May-2008  yamt sync with head.
 1.38.4.1 03-Jul-2008  simonb Sync with head.
 1.38.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.39.6.1 16-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #62):
sys/dev/pci/if_wpivar.h: revision 1.13
sys/dev/pci/if_wpi.c: revision 1.41
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.
 1.39.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.39.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.41.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.45.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.46.2.3 21-Apr-2011  rmind sync with head
 1.46.2.2 05-Mar-2011  rmind sync with head
 1.46.2.1 30-May-2010  rmind sync with head
 1.48.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.49.8.2 02-Jun-2012  mrg sync to latest -current.
 1.49.8.1 18-Feb-2012  mrg merge to -current.
 1.49.4.5 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.49.4.4 16-Jan-2013  yamt sync with (a bit old) head
 1.49.4.3 30-Oct-2012  yamt sync with head
 1.49.4.2 23-May-2012  yamt sync with head.
 1.49.4.1 17-Apr-2012  yamt sync with head
 1.50.2.4 08-Feb-2013  riz Pull up following revision(s) (requested by riastradh in ticket #784):
sys/dev/pci/if_wpi.c: revision 1.54
Rework firmware reference counting and error messages in wpi(4).
. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.
Based on a patch from dh in PR kern/44144.
 1.50.2.3 12-Aug-2012  martin Pull up following revision(s) (requested by riastradh in ticket #478):
sys/dev/pci/if_wpi.c: revision 1.53
Fix error branch in wpi(4) firmware loading.
Fixes panic if firmware is not available.
 1.50.2.2 22-May-2012  riz Pull up following revision(s) (requested by khorben in ticket #266):
sys/dev/pci/if_wpi.c: patch

Fix harmless typo which was previously pulled up.
 1.50.2.1 19-May-2012  riz Pull up following revision(s) (requested by khorben in ticket #266):
sys/dev/pci/if_wpi.c: revision 1.51
No longer wrongly advertise ad-hoc (IBSS) mode as being supported.
Fixes kern/46101
No objection from current-users@
 1.53.2.4 03-Dec-2017  jdolecek update from HEAD
 1.53.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.2.2 23-Jun-2013  tls resync from head
 1.53.2.1 25-Feb-2013  tls resync with head
 1.56.4.1 18-May-2014  rmind sync with head
 1.58.2.1 10-Aug-2014  tls Rebase.
 1.68.4.5 28-Aug-2017  skrll Sync with HEAD
 1.68.4.4 05-Feb-2017  skrll Sync with HEAD
 1.68.4.3 09-Jul-2016  skrll Sync with HEAD
 1.68.4.2 29-May-2016  skrll Sync with HEAD
 1.68.4.1 06-Apr-2015  skrll Sync with HEAD
 1.68.2.2 12-Jan-2015  snj Pull up following revision(s) (requested by bouyer in ticket #415):
share/man/man9/sysmon_pswitch.9: revision 1.6
sys/dev/pci/if_wpi.c: revision 1.70, 1.71
sys/dev/pci/if_wpivar.h: revision 1.19
sys/dev/sysmon/sysmon_power.c: revision 1.49
sys/sys/power.h: revision 1.20
As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.
--
Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net
 1.68.2.1 21-Dec-2014  snj Pull up following revision(s) (requested by bouyer in ticket #338):
sys/dev/pci/if_wpi.c: revision 1.69
Consistently take the interface down when the radio swicth is off.
 1.74.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.74.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.75.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.78.2.2 27-Jul-2019  martin Pull up following revision(s) (requested by jakllsch in ticket #1308):

sys/dev/pci/if_wpi.c: revision 1.86

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.
 1.78.2.1 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.79.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.79.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.79.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.80.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.80.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.80.2.1 10-Jun-2019  christos Sync with HEAD
 1.87.2.1 29-Feb-2020  ad Sync with head.
 1.89.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.90.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.13 02-Jul-2014  jakllsch fix boot code maximum size.

From OpenBSD if_wpireg.h 1.19.
 1.12 02-Jul-2014  jakllsch No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.
 1.11 30-Jun-2014  jakllsch Apply OpenBSD src/sys/dev/pci/if_wpireg.h 1.17.
 1.10 30-Jun-2014  jakllsch Sync with OpenBSD src/sys/dev/pci/if_wpireg.h 1.16.
 1.9 25-Dec-2007  perry branches: 1.9.54; 1.9.70;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.8 28-Nov-2007  degroote branches: 1.8.2; 1.8.6;
In wpi_init, check for the status of radio switch and print a useful message
in this case.
 1.7 21-Oct-2007  degroote branches: 1.7.2;
802.11 header may have different sizes. Deals correctly with this.
 1.6 02-Sep-2007  degroote branches: 1.6.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.
 1.5 18-Jul-2007  degroote branches: 1.5.4; 1.5.6; 1.5.8;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.
 1.4 09-Jul-2007  degroote branches: 1.4.2;
Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org
 1.3 13-Jan-2007  degroote branches: 1.3.6; 1.3.8;
Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@
 1.2 31-Oct-2006  joerg branches: 1.2.2; 1.2.4; 1.2.6;
Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.
 1.1 13-Aug-2006  simonb branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.
 1.1.8.1 10-Dec-2006  yamt sync with head.
 1.1.6.2 09-Sep-2006  rpaulo sync with head
 1.1.6.1 13-Aug-2006  rpaulo file if_wpireg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:18 +0000
 1.1.4.2 01-Feb-2007  ad Sync with head.
 1.1.4.1 18-Nov-2006  ad Sync with head.
 1.1.2.2 03-Sep-2006  yamt sync with head.
 1.1.2.1 13-Aug-2006  yamt file if_wpireg.h was added on branch yamt-pdpolicy on 2006-09-03 15:24:22 +0000
 1.2.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.2.4.7 21-Jan-2008  yamt sync with head
 1.2.4.6 07-Dec-2007  yamt sync with head
 1.2.4.5 27-Oct-2007  yamt sync with head.
 1.2.4.4 03-Sep-2007  yamt sync with head.
 1.2.4.3 26-Feb-2007  yamt sync with head.
 1.2.4.2 30-Dec-2006  yamt sync with head.
 1.2.4.1 31-Oct-2006  yamt file if_wpireg.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:46 +0000
 1.2.2.1 27-Jul-2007  liamjfoy Pullup requested by degroote in ticket 795:
Rewrite of the rbuf management
Sync with the last OpenBSD driver
Use the last firmware available from Intel (2.4.14).
Use legal limitations and Tx regulation embedded in the eeprom.
Rewrite the way we handle the firmware.

Pullup the following revisions of this files
sys/dev/pci/if_wpi.c rev 1.7 1.8 1.10 1.12 1.13 1.15 1.16 1.17 via patch
sys/dev/pci/if_wpireg.h rev 1.3 1.4 1.5 via patch
sys/dev/pci/if_wpivar.h rev 1.3 1.5 1.6 via patch
 1.3.8.1 11-Jul-2007  mjf Sync with head.
 1.3.6.3 09-Oct-2007  ad Sync with head.
 1.3.6.2 20-Aug-2007  ad Sync with HEAD.
 1.3.6.1 15-Jul-2007  ad Sync with head.
 1.4.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.4.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.5.8.2 18-Jul-2007  degroote change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.
 1.5.8.1 18-Jul-2007  degroote file if_wpireg.h was added on branch matt-mips64 on 2007-07-18 18:49:18 +0000
 1.5.6.2 09-Jan-2008  matt sync with HEAD
 1.5.6.1 06-Nov-2007  matt sync with HEAD
 1.5.4.3 03-Dec-2007  joerg Sync with HEAD.
 1.5.4.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.4.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.6.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.7.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.8.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.2.1 26-Dec-2007  ad Sync with head.
 1.9.70.1 10-Aug-2014  tls Rebase.
 1.9.54.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23 20-Mar-2020  sevan Apply the same change as for if_iwi.c r1.114 here.

This driver sleeps during wpi_media_change(), and thus requires an adaptive
mutex for the media lock.
 1.22 20-Aug-2018  riastradh Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.
 1.21 02-Feb-2017  nonaka branches: 1.21.12; 1.21.14;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE
 1.20 02-Feb-2017  jakllsch wpi(4): use MSI if available.
 1.19 06-Jan-2015  bouyer branches: 1.19.2; 1.19.4;
As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.
 1.18 09-Aug-2014  jmcneill branches: 1.18.2; 1.18.4;
increase WPI_RBUF_COUNT
 1.17 07-Aug-2014  jmcneill simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me
 1.16 05-Aug-2014  jmcneill bus_dmamap_sync for rx descriptors too, derived from openbsd driver
 1.15 19-Jan-2010  pooka branches: 1.15.22; 1.15.36;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.14 17-Jan-2010  pooka Forward declare struct bpf_if and use that as the type for bpf_if
instead of "void *". Buys us oo times the type-safety for 0 times
the price.
(no functional change)
 1.13 12-Nov-2008  joerg Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.
 1.12 02-Jul-2008  cube branches: 1.12.2; 1.12.4; 1.12.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.
 1.11 09-Jan-2008  degroote branches: 1.11.6; 1.11.10; 1.11.12; 1.11.14;
Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).
 1.10 09-Dec-2007  jmcneill branches: 1.10.2;
Merge jmcneill-pm branch.
 1.9 16-Nov-2007  degroote branches: 1.9.2; 1.9.4;
Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected
 1.8 02-Sep-2007  degroote branches: 1.8.4; 1.8.6;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.
 1.7 02-Sep-2007  degroote Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.
 1.6 09-Jul-2007  degroote branches: 1.6.2; 1.6.6; 1.6.8;
Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org
 1.5 18-Jun-2007  degroote Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.
 1.4 04-Mar-2007  christos branches: 1.4.2; 1.4.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 13-Jan-2007  degroote branches: 1.3.2;
Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@
 1.2 31-Oct-2006  joerg branches: 1.2.2; 1.2.4; 1.2.6;
Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.
 1.1 13-Aug-2006  simonb branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.
 1.1.8.1 10-Dec-2006  yamt sync with head.
 1.1.6.2 09-Sep-2006  rpaulo sync with head
 1.1.6.1 13-Aug-2006  rpaulo file if_wpivar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:18 +0000
 1.1.4.2 01-Feb-2007  ad Sync with head.
 1.1.4.1 18-Nov-2006  ad Sync with head.
 1.1.2.2 03-Sep-2006  yamt sync with head.
 1.1.2.1 13-Aug-2006  yamt file if_wpivar.h was added on branch yamt-pdpolicy on 2006-09-03 15:24:22 +0000
 1.2.6.2 30-Sep-2007  wrstuden Catch up on netbsd-4 as of a few days ago.
 1.2.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.2.4.6 21-Jan-2008  yamt sync with head
 1.2.4.5 07-Dec-2007  yamt sync with head
 1.2.4.4 03-Sep-2007  yamt sync with head.
 1.2.4.3 26-Feb-2007  yamt sync with head.
 1.2.4.2 30-Dec-2006  yamt sync with head.
 1.2.4.1 31-Oct-2006  yamt file if_wpivar.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:46 +0000
 1.2.2.2 27-Sep-2007  xtraeme Pull up following revision(s) (requested by degroote in ticket #860):
sys/dev/pci/if_wpivar.h: revision 1.7 (via patch)
sys/dev/pci/if_wpi.c: revision 1.18 (via patch)
sys/dev/pci/if_wpi.c: revision 1.19 (via patch)
sys/dev/pci/if_wpi.c: revision 1.23 (via patch)

Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).
Fix possible "packet corruption" which appears on high load
Fix scanning code for wpi based on the iwi code.
Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.
Moreover, it fixes WPA issues for me.
 1.2.2.1 27-Jul-2007  liamjfoy Pullup requested by degroote in ticket 795:
Rewrite of the rbuf management
Sync with the last OpenBSD driver
Use the last firmware available from Intel (2.4.14).
Use legal limitations and Tx regulation embedded in the eeprom.
Rewrite the way we handle the firmware.

Pullup the following revisions of this files
sys/dev/pci/if_wpi.c rev 1.7 1.8 1.10 1.12 1.13 1.15 1.16 1.17 via patch
sys/dev/pci/if_wpireg.h rev 1.3 1.4 1.5 via patch
sys/dev/pci/if_wpivar.h rev 1.3 1.5 1.6 via patch
 1.3.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.4.1 11-Jul-2007  mjf Sync with head.
 1.4.2.2 09-Oct-2007  ad Sync with head.
 1.4.2.1 15-Jul-2007  ad Sync with head.
 1.6.8.3 23-Mar-2008  matt sync with HEAD
 1.6.8.2 09-Jan-2008  matt sync with HEAD
 1.6.8.1 06-Nov-2007  matt sync with HEAD
 1.6.6.7 21-Nov-2007  joerg Sync with HEAD.
 1.6.6.6 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.6.6.5 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.6.6.4 04-Sep-2007  degroote Convert wpi_power to use pci_net_generic_power.
With this, I can use the card after resume.
 1.6.6.3 03-Sep-2007  jmcneill Sync with HEAD.
 1.6.6.2 02-Sep-2007  jmcneill Sync with HEAD.
 1.6.6.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.6.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.8.6.3 18-Feb-2008  mjf Sync with HEAD.
 1.8.6.2 27-Dec-2007  mjf Sync with HEAD.
 1.8.6.1 19-Nov-2007  mjf Sync with HEAD.
 1.8.4.1 18-Nov-2007  bouyer Sync with HEAD
 1.9.4.1 11-Dec-2007  yamt sync with head.
 1.9.2.1 26-Dec-2007  ad Sync with head.
 1.10.2.1 10-Jan-2008  bouyer Sync with HEAD
 1.11.14.1 03-Jul-2008  simonb Sync with head.
 1.11.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.11.10.2 11-Mar-2010  yamt sync with head
 1.11.10.1 04-May-2009  yamt sync with head.
 1.11.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.11.6.1 02-Jul-2008  mjf Sync with HEAD.
 1.12.6.1 16-Nov-2008  snj Pull up following revision(s) (requested by joerg in ticket #62):
sys/dev/pci/if_wpivar.h: revision 1.13
sys/dev/pci/if_wpi.c: revision 1.41
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.
 1.12.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.36.1 10-Aug-2014  tls Rebase.
 1.15.22.2 03-Dec-2017  jdolecek update from HEAD
 1.15.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.4.2 05-Feb-2017  skrll Sync with HEAD
 1.18.4.1 06-Apr-2015  skrll Sync with HEAD
 1.18.2.1 12-Jan-2015  snj Pull up following revision(s) (requested by bouyer in ticket #415):
share/man/man9/sysmon_pswitch.9: revision 1.6
sys/dev/pci/if_wpi.c: revision 1.70, 1.71
sys/dev/pci/if_wpivar.h: revision 1.19
sys/dev/sysmon/sysmon_power.c: revision 1.49
sys/sys/power.h: revision 1.20
As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.
--
Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net
 1.19.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.19.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.21.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.14.1 10-Jun-2019  christos Sync with HEAD
 1.21.12.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.35 24-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.34 01-Mar-2020  thorpej Use the 64-bit PCI DMA tag if available.
 1.33 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.32 29-May-2019  msaitoh branches: 1.32.4;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.31 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.30 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.29 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.28 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.27 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.26 26-Jun-2018  msaitoh branches: 1.26.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.25 15-Dec-2016  ozaki-r branches: 1.25.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.24 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.23 14-Jul-2016  msaitoh branches: 1.23.2;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.22 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.21 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.20 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.19 29-Mar-2014  christos branches: 1.19.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.18 30-Mar-2013  christos branches: 1.18.4;
remove trailing whitespace
 1.17 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.16 02-Feb-2012  tls branches: 1.16.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.15 05-Apr-2010  joerg branches: 1.15.8; 1.15.12;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.14 19-Jan-2010  pooka branches: 1.14.2; 1.14.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.13 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.12 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.11 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.10 16-Dec-2008  christos branches: 1.10.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.9 10-Apr-2008  cegger branches: 1.9.4; 1.9.12;
use aprint_*_dev and device_xname
 1.8 07-Feb-2008  dyoung branches: 1.8.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.7 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.6 19-Oct-2007  ad branches: 1.6.2; 1.6.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 04-Mar-2007  christos branches: 1.5.2; 1.5.14; 1.5.16; 1.5.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 16-Nov-2006  christos branches: 1.4.4;
__unused removal on arguments; approved by core.
 1.3 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.22; 1.2.24;
merge ktrace-lwp.
 1.1 09-Sep-2005  ragge branches: 1.1.2; 1.1.8;
Device driver for the Neterion (S2io) Xframe-I 10Gbit ethernet card.
Still missing: VLAN + IPv6 checksum support.
 1.1.8.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.8.1 09-Sep-2005  skrll file if_xge.c was added on branch ktrace-lwp on 2005-11-10 14:06:02 +0000
 1.1.2.2 13-Sep-2005  tron Pull up following revision(s) (requested by ragge in ticket #768):
sys/dev/pci/if_xge.c: revision 1.1 via patch
sys/dev/pci/if_xgereg.h: revision 1.1
sys/dev/pci/files.pci: revision 1.238
Device driver for the Neterion (S2io) Xframe-I 10Gbit ethernet card.
Still missing: VLAN + IPv6 checksum support.
 1.1.2.1 09-Sep-2005  tron file if_xge.c was added on branch netbsd-3 on 2005-09-13 20:59:37 +0000
 1.2.24.2 10-Dec-2006  yamt sync with head.
 1.2.24.1 22-Oct-2006  yamt sync with head
 1.2.22.1 18-Nov-2006  ad Sync with head.
 1.2.18.6 11-Feb-2008  yamt sync with head.
 1.2.18.5 21-Jan-2008  yamt sync with head
 1.2.18.4 27-Oct-2007  yamt sync with head.
 1.2.18.3 03-Sep-2007  yamt sync with head.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file if_xge.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:05 +0000
 1.4.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.16.3 23-Mar-2008  matt sync with HEAD
 1.5.16.2 09-Jan-2008  matt sync with HEAD
 1.5.16.1 06-Nov-2007  matt sync with HEAD
 1.5.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.2.1 23-Oct-2007  ad Sync with head.
 1.6.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.6.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.8.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.9.4.4 11-Aug-2010  yamt sync with head.
 1.9.4.3 11-Mar-2010  yamt sync with head
 1.9.4.2 16-May-2009  yamt sync with head
 1.9.4.1 04-May-2009  yamt sync with head.
 1.10.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.4.1 30-May-2010  rmind sync with head
 1.14.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.15.12.1 18-Feb-2012  mrg merge to -current.
 1.15.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.8.2 30-Oct-2012  yamt sync with head
 1.15.8.1 17-Apr-2012  yamt sync with head
 1.16.6.4 03-Dec-2017  jdolecek update from HEAD
 1.16.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.6.2 23-Jun-2013  tls resync from head
 1.16.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.4.1 18-May-2014  rmind sync with head
 1.19.6.5 05-Feb-2017  skrll Sync with HEAD
 1.19.6.4 05-Oct-2016  skrll Sync with HEAD
 1.19.6.3 09-Jul-2016  skrll Sync with HEAD
 1.19.6.2 19-Mar-2016  skrll Sync with HEAD
 1.19.6.1 06-Jun-2015  skrll Sync with HEAD
 1.23.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.25.14.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.25.14.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.25.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.26.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.26.2.1 10-Jun-2019  christos Sync with HEAD
 1.32.4.1 29-Feb-2020  ad Sync with head.
 1.3 29-Aug-2019  msaitoh Add missing NUL to prevent buffer overrun.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.158; 1.2.166; 1.2.172;
merge ktrace-lwp.
 1.1 09-Sep-2005  ragge branches: 1.1.2; 1.1.8;
Device driver for the Neterion (S2io) Xframe-I 10Gbit ethernet card.
Still missing: VLAN + IPv6 checksum support.
 1.1.8.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.8.1 09-Sep-2005  skrll file if_xgereg.h was added on branch ktrace-lwp on 2005-11-10 14:06:02 +0000
 1.1.2.2 13-Sep-2005  tron Pull up following revision(s) (requested by ragge in ticket #768):
sys/dev/pci/if_xge.c: revision 1.1 via patch
sys/dev/pci/if_xgereg.h: revision 1.1
sys/dev/pci/files.pci: revision 1.238
Device driver for the Neterion (S2io) Xframe-I 10Gbit ethernet card.
Still missing: VLAN + IPv6 checksum support.
 1.1.2.1 09-Sep-2005  tron file if_xgereg.h was added on branch netbsd-3 on 2005-09-13 20:59:37 +0000
 1.2.172.1 01-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #145):

sys/arch/sparc/include/ctlreg.h: revision 1.30
sys/dev/pci/if_xgereg.h: revision 1.3

Add missing NUL to prevent buffer overrun.
 1.2.166.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.158.1 26-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1387):

sys/arch/sparc/include/ctlreg.h: revision 1.30
sys/dev/pci/if_xgereg.h: revision 1.3

Add missing NUL to prevent buffer overrun.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file if_xgereg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:05 +0000
 1.33 22-Sep-2018  maxv Remove ifpci(4). It is part of ISDN, which we are retiring.
 1.32 29-Mar-2014  christos branches: 1.32.28; 1.32.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.31 27-Oct-2012  chs branches: 1.31.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.30 06-Dec-2009  dyoung branches: 1.30.12; 1.30.22;
Simplify device-activation hooks.
 1.29 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.28 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.27 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.26 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.25 10-Apr-2008  cegger branches: 1.25.4; 1.25.18;
use aprint_*_dev and device_xname
 1.24 19-Oct-2007  ad branches: 1.24.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.23 09-Jul-2007  ad branches: 1.23.6; 1.23.8; 1.23.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.22 04-Mar-2007  christos branches: 1.22.2; 1.22.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.21 16-Nov-2006  christos branches: 1.21.4;
__unused removal on arguments; approved by core.
 1.20 16-Oct-2006  pooka * __unused games + other relevant fixes
* give me ANSI C or give me death (at least where it could be easily spotted)
 1.19 10-Sep-2006  simonb branches: 1.19.2;
Add NetBSD RCS tag to top of file.
 1.18 11-Dec-2005  christos branches: 1.18.8; 1.18.20;
merge ktrace-lwp.
 1.17 09-Jul-2005  christos make the isdn drivers compile again with -Wconst, -Wshadow
 1.16 27-Feb-2005  perry branches: 1.16.4;
nuke trailing whitespace
 1.15 28-Oct-2003  pooka branches: 1.15.8; 1.15.10;
fix uninitialized uses caught by gcc
 1.14 03-Oct-2003  pooka Ready the kernel side of i4b for primary rate interface support by
removing assumptions that there are only two B channels and by
adding support for a varying number of channels.

Due to this, rename previously used isdn identified "bri" to "isdnif",
which better describes the current situation.
 1.13 02-Oct-2002  thorpej branches: 1.13.6;
Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.9 21-May-2002  martin branches: 1.9.4;
Uniformly pass a "struct isdn_l3_driver *" through layer 2, so we
do not have to search for that driver later while we already knew it
at layer 1.
 1.8 10-Apr-2002  martin branches: 1.8.2;
Remove some redundant tries to disable interupts. We already avoided enabling
them.
Fix a stupid typo when enabling/disabling interrupts: we clear pending
interrupts when enabling, not disbling isac interrupts.
 1.7 08-Apr-2002  martin Combine sc_enabled and sc_dying into one field sc_intr_valid, they are used
for the same purpose (ignoring invalid interrupts).

For cards that are not able to stop all interrupts (or we don't know a way
to do that in software, at least) run the clearirq callback even when
ignoring an interrupt because we are not enabled. Otherwise the card would
stop interrupting.

Reserve a driver specific callout handle and an int value in the generic
isic_softc to allow card drivers to implement fancy blinkenlights.
 1.6 06-Apr-2002  martin Ooops, forgot to adopt this to the previous change of isic_isac_intr.
 1.5 30-Mar-2002  martin branches: 1.5.2;
Be a nice citizen, enable interrupts only when we are ready to talk
to the ISDN (i.e. when userland has /dev/isdn open).
 1.4 30-Mar-2002  martin Avoid duplicate expensive lookups by passing a pointer to the call
descriptor/a pointer to the layer 3 state directly to driver functions,
instead of their ID/index.
 1.3 29-Mar-2002  martin Split BRI attaching into two phases, so lower layer drivers can get their
BRI identifier and L3 driver state early on, then finish initializing and
announce the controller to userland when it's ready.
 1.2 27-Mar-2002  martin After Jason Thorpe explained to me how it is supposed to work, implement
(de)activate for pcmcia cards.
Implement detach/(de)activate for PCI cards.
Clean up internal state (free call-descriptors) if a controller is
detached while it has open connections.
 1.1 25-Mar-2002  martin Now that we have all pieces in place (and enough granularity to specify
B-channel and D-channel drivers separately) split the Fritz!PCI card
driver out of the isic driver.

The new device is called "ifpci" and uses the same D-channel driver as the
isic devices, but has it's own B-channel driver.
 1.5.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.5.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.5.2.3 17-Apr-2002  nathanw Catch up to -current.
 1.5.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.2.1 30-Mar-2002  nathanw file ifpci.c was added on branch nathanw_sa on 2002-04-01 07:46:29 +0000
 1.8.2.1 30-May-2002  gehenna Catch up with -current.
 1.9.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.4.1 21-May-2002  jdolecek file ifpci.c was added on branch kqueue on 2002-06-23 17:47:47 +0000
 1.13.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.15.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.16.4.4 27-Oct-2007  yamt sync with head.
 1.16.4.3 03-Sep-2007  yamt sync with head.
 1.16.4.2 30-Dec-2006  yamt sync with head.
 1.16.4.1 21-Jun-2006  yamt sync with head.
 1.18.20.1 18-Nov-2006  ad Sync with head.
 1.18.8.1 14-Sep-2006  yamt sync with head.
 1.19.2.2 10-Dec-2006  yamt sync with head.
 1.19.2.1 22-Oct-2006  yamt sync with head
 1.21.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.4.1 11-Jul-2007  mjf Sync with head.
 1.22.2.2 23-Oct-2007  ad Sync with head.
 1.22.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.23.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.24.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.4.2 11-Mar-2010  yamt sync with head
 1.25.4.1 16-May-2009  yamt sync with head
 1.30.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.30.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.30.12.1 30-Oct-2012  yamt sync with head
 1.31.2.1 18-May-2014  rmind sync with head
 1.32.30.1 10-Jun-2019  christos Sync with HEAD
 1.32.28.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.23 22-Sep-2018  maxv Remove the "ifritz" driver (no man page). It is part of ISDN, which we are
retiring.
 1.22 29-Mar-2014  christos branches: 1.22.28; 1.22.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.21 23-Mar-2014  christos remove unused
 1.20 27-Oct-2012  chs branches: 1.20.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.19 06-Dec-2009  dyoung branches: 1.19.12; 1.19.22;
Simplify device-activation hooks.
 1.18 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.17 27-Oct-2009  martin Fix endianess issues when accessing the B-channel fifos.
 1.16 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.15 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.14 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.13 10-Apr-2008  cegger branches: 1.13.4; 1.13.14; 1.13.18; 1.13.22;
use aprint_*_dev and device_xname
 1.12 19-Oct-2007  ad branches: 1.12.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 09-Jul-2007  ad branches: 1.11.6; 1.11.8; 1.11.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.10 04-Mar-2007  christos branches: 1.10.2; 1.10.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 16-Nov-2006  christos branches: 1.9.4;
__unused removal on arguments; approved by core.
 1.8 16-Oct-2006  pooka * __unused games + other relevant fixes
* give me ANSI C or give me death (at least where it could be easily spotted)
 1.7 11-Dec-2005  christos branches: 1.7.20; 1.7.22;
merge ktrace-lwp.
 1.6 01-Jun-2005  drochner branches: 1.6.2;
quell cast-qual and shadow warnings
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 06-Jul-2004  martin branches: 1.4.4; 1.4.6;
Give a magic value a name - inspired by a post on the FreeBSD isdn mailing
list.
 1.3 28-Oct-2003  pooka fix uninitialized uses caught by gcc
 1.2 03-Oct-2003  pooka Ready the kernel side of i4b for primary rate interface support by
removing assumptions that there are only two B channels and by
adding support for a varying number of channels.

Due to this, rename previously used isdn identified "bri" to "isdnif",
which better describes the current situation.
 1.1 25-Oct-2002  leo branches: 1.1.2; 1.1.8;
Fritz!PCI v2.0 ISDN driver from FreeBSD.
 1.1.8.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.8.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 25-Oct-2002  nathanw file ifpci2.c was added on branch nathanw_sa on 2002-11-11 22:11:15 +0000
 1.4.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.6.2.3 27-Oct-2007  yamt sync with head.
 1.6.2.2 03-Sep-2007  yamt sync with head.
 1.6.2.1 30-Dec-2006  yamt sync with head.
 1.7.22.2 10-Dec-2006  yamt sync with head.
 1.7.22.1 22-Oct-2006  yamt sync with head
 1.7.20.1 18-Nov-2006  ad Sync with head.
 1.9.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.4.1 11-Jul-2007  mjf Sync with head.
 1.10.2.2 23-Oct-2007  ad Sync with head.
 1.10.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.11.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.8.1 06-Nov-2007  matt sync with HEAD
 1.11.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.22.1 21-Apr-2010  matt sync to netbsd-5
 1.13.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.14.1 31-Oct-2009  sborrill Pull up the following revisions(s) (requested by martin in ticket #1119):
sys/dev/pci/ifpci2.c: revision 1.17

Fix endianess issues with ifritz(4) when accessing the B-channel fifos.
 1.13.4.2 11-Mar-2010  yamt sync with head
 1.13.4.1 16-May-2009  yamt sync with head
 1.19.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.12.1 30-Oct-2012  yamt sync with head
 1.20.2.1 18-May-2014  rmind sync with head
 1.22.30.1 10-Jun-2019  christos Sync with HEAD
 1.22.28.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.6 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.5 24-Apr-2021  thorpej branches: 1.5.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.4 22-Dec-2019  thorpej branches: 1.4.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.3 14-Feb-2016  chs branches: 1.3.18;
zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.2 13-Jul-2014  mlelstv branches: 1.2.4; 1.2.6;
The vga driver now detaches wscons.
 1.1 21-Jan-2014  mlelstv branches: 1.1.2; 1.1.4; 1.1.6;
wscons driver for Intel Graphics Media Accelerator.
Initial commit that already works for a couple of Notebooks
based on G35, G45, Sandy Bridge and Ivy Bridge chips.

Despite the word 'Accelerator' there is nothing acclerated yet.
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 21-Jan-2014  yamt file igma.c was added on branch yamt-pagecache on 2014-05-22 11:40:25 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 21-Jan-2014  rmind file igma.c was added on branch rmind-smpnet on 2014-05-18 17:45:40 +0000
 1.1.2.1 10-Aug-2014  tls Rebase.
 1.2.6.1 19-Mar-2016  skrll Sync with HEAD
 1.2.4.3 03-Dec-2017  jdolecek update from HEAD
 1.2.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.1 13-Jul-2014  tls file igma.c was added on branch tls-maxphys on 2014-08-20 00:03:43 +0000
 1.3.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.10.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.5.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 21-Jan-2014  mlelstv branches: 1.1.4; 1.1.6; 1.1.10;
wscons driver for Intel Graphics Media Accelerator.
Initial commit that already works for a couple of Notebooks
based on G35, G45, Sandy Bridge and Ivy Bridge chips.

Despite the word 'Accelerator' there is nothing acclerated yet.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 21-Jan-2014  tls file igmareg.h was added on branch tls-maxphys on 2014-08-20 00:03:43 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 21-Jan-2014  yamt file igmareg.h was added on branch yamt-pagecache on 2014-05-22 11:40:25 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 21-Jan-2014  rmind file igmareg.h was added on branch rmind-smpnet on 2014-05-18 17:45:40 +0000
 1.1 21-Jan-2014  mlelstv branches: 1.1.4; 1.1.6; 1.1.10;
wscons driver for Intel Graphics Media Accelerator.
Initial commit that already works for a couple of Notebooks
based on G35, G45, Sandy Bridge and Ivy Bridge chips.

Despite the word 'Accelerator' there is nothing acclerated yet.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 21-Jan-2014  tls file igmavar.h was added on branch tls-maxphys on 2014-08-20 00:03:43 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 21-Jan-2014  yamt file igmavar.h was added on branch yamt-pagecache on 2014-05-22 11:40:25 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 21-Jan-2014  rmind file igmavar.h was added on branch rmind-smpnet on 2014-05-18 17:45:40 +0000
 1.25 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.24 14-Jul-2016  msaitoh branches: 1.24.18;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.23 30-Jan-2012  drochner branches: 1.23.6; 1.23.24;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.22 27-Aug-2011  martin branches: 1.22.2; 1.22.6;
I suppose mrg did mean to include this change in yesterday commit:
use CFATTACH_DECL_NEW for real.
 1.21 26-Jul-2011  mrg convert to device_t, cfdata_t and CFATTACH_DECL_NEW.
 1.20 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.19 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.18 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.17 19-Oct-2007  ad branches: 1.17.20; 1.17.34;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 13-Jan-2007  cube branches: 1.16.6; 1.16.18; 1.16.20; 1.16.24;
Not all archs have dma tags that can be compared with "==", so use memcmp
instead.
 1.15 20-May-2006  uwe branches: 1.15.6;
Redo previous fix properly. Original code had a typo caused by very similar
function and variable names. We need to protect tag comparison b/c we don't
want to perform it against an uninitialized tag.
 1.14 20-May-2006  mrg in code that looks like:
igsfb_pci_is_console(pci_chipset_tag_t pc, pcitag_t tag)
{
return igsfb_pci_is_console && (tag == igsfb_pci_constag);
}

delete "igsfb_pci_is_console &&" as the address of igsfb_pci_is_console
is always true. thanks gcc4.
 1.13 05-Apr-2006  uwe branches: 1.13.2;
KNF: no parentheses around return value.
 1.12 05-Apr-2006  uwe ANSI'ify.
 1.11 24-Feb-2006  uwe branches: 1.11.2; 1.11.4; 1.11.6;
Whitespace cleanup (hi, macallan).
 1.10 23-Feb-2006  macallan Add support for virtual consoles to igsfb.
Works fine on a Krups, needs testing on other ports.
 1.9 11-Dec-2005  christos branches: 1.9.2; 1.9.4; 1.9.6;
merge ktrace-lwp.
 1.8 23-Apr-2004  itojun branches: 1.8.12;
pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.7 10-May-2003  uwe branches: 1.7.2;
Redo attachment to support proper cnattach.
wscons on netwinder almost works now.
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 24-Sep-2002  uwe Add some preliminary support for setting up the CyberPro in Netwinder.
Setup sequence obtained from Krups OFW with some CyberPro-specific
magic from Linux driver. The driver still has a lot of hardcoded
stuff, but it is useful enough to bring up wscons on netwinder.

XXX: Proper console attachment needs to be written (the driver was
originally developed on sparc, where our approach to attaching console
is totally different).

Caveat emptor!
 1.3 21-Jul-2002  uwe Add definitions of IGS coprocessor registers (not used yet).
Always init chip via I/O space.
Map only I/O registers we actually need.
Automatically detect if we need to do bswapping
Add (untested) code to use automagic bswap on CyberPro.
Report video memory amount.
Report if/how bswapping is done.
 1.2 04-Apr-2002  uwe branches: 1.2.2; 1.2.4; 1.2.8;
Nuke ugly ms-IIep specific hack now that mspcic knows about phys->pci
address translation.
 1.1 30-Mar-2002  uwe First cut at framebuffer driver for Integraphics Systems IGA1682.
It's not finished yet, but it can do enough to get wscons working for
Krups JavaStation.
 1.2.8.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 04-Apr-2002  jdolecek file igsfb_pci.c was added on branch kqueue on 2002-06-23 17:47:47 +0000
 1.2.4.1 29-Aug-2002  gehenna catch up with -current.
 1.2.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.2.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.2.2.1 04-Apr-2002  nathanw file igsfb_pci.c was added on branch nathanw_sa on 2002-04-17 00:06:02 +0000
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.12.3 27-Oct-2007  yamt sync with head.
 1.8.12.2 26-Feb-2007  yamt sync with head.
 1.8.12.1 21-Jun-2006  yamt sync with head.
 1.9.6.2 01-Jun-2006  kardel Sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.9.2.1 01-Mar-2006  yamt sync with head.
 1.11.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.11.4.1 19-Apr-2006  elad sync with head.
 1.11.2.2 24-May-2006  yamt sync with head.
 1.11.2.1 11-Apr-2006  yamt sync with head
 1.13.2.1 19-Jun-2006  chap Sync with head.
 1.15.6.1 01-Feb-2007  ad Sync with head.
 1.16.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.20.1 06-Nov-2007  matt sync with HEAD
 1.16.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.6.1 23-Oct-2007  ad Sync with head.
 1.17.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.20.1 16-May-2009  yamt sync with head
 1.22.6.1 18-Feb-2012  mrg merge to -current.
 1.22.2.1 17-Apr-2012  yamt sync with head
 1.23.24.1 05-Oct-2016  skrll Sync with HEAD
 1.23.6.1 03-Dec-2017  jdolecek update from HEAD
 1.24.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1 10-May-2003  uwe Redo attachment to support proper cnattach.
wscons on netwinder almost works now.
 1.20 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.19 29-Mar-2014  christos branches: 1.19.28; 1.19.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.18 30-Jan-2012  drochner branches: 1.18.6; 1.18.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.17 13-Nov-2010  uebayasi branches: 1.17.8; 1.17.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.16 14-May-2008  tsutsui branches: 1.16.20;
Normalize my licenses.
 1.15 12-Apr-2008  tsutsui branches: 1.15.2; 1.15.4; 1.15.6;
Split device_t/softc.
 1.14 10-Apr-2008  cegger use aprint_*_dev and device_xname
 1.13 16-Nov-2006  christos branches: 1.13.48;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 16-Jun-2005  tsutsui branches: 1.10.2;
Rename iha_pci_probe() -> iha_pci_match() because we don't have to
probe PCI devices.
 1.9 25-Sep-2004  tsutsui Use ANSI function decls.
 1.8 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.7 14-Nov-2002  tsutsui branches: 1.7.6;
Sync with copyright verbiage update of OpenBSD's iha(4).
 1.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 27-Sep-2001  tsutsui Include uvm/uvm_extern.h for PAGE_SIZE.
 1.1 03-Jun-2001  tsutsui branches: 1.1.2; 1.1.4; 1.1.6;
Add a driver for the Initio INIC-940/950 PCI SCSI controllers.
Based on OpenBSD's iha driver, and modified some structures by me.

Tested on arc, i386 and macppc.
 1.1.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.1.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.1.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.1 03-Jun-2001  nathanw file iha_pci.c was added on branch nathanw_sa on 2001-06-21 20:04:54 +0000
 1.7.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.6.4 19-Oct-2004  skrll Sync with HEAD
 1.7.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.13.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.20.1 05-Mar-2011  rmind sync with head
 1.17.12.1 18-Feb-2012  mrg merge to -current.
 1.17.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.8.1 17-Apr-2012  yamt sync with head
 1.18.10.1 18-May-2014  rmind sync with head
 1.18.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.30.1 10-Jun-2019  christos Sync with HEAD
 1.19.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.30 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.29 14-Jul-2016  msaitoh branches: 1.29.16; 1.29.18;
Use aprint*() instead of printf() in the attach function.
KNF.
 1.28 29-Mar-2014  christos branches: 1.28.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.27 27-Oct-2012  chs branches: 1.27.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.26 12-May-2009  cegger branches: 1.26.12; 1.26.22;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.25 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.24 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.23 28-Apr-2008  martin branches: 1.23.14;
Remove clause 3 and 4 from TNF licenses
 1.22 10-Apr-2008  cegger branches: 1.22.2; 1.22.4;
use aprint_*_dev and device_xname
 1.21 19-Oct-2007  ad branches: 1.21.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.20 09-Jul-2007  ad branches: 1.20.6; 1.20.8; 1.20.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.19 16-Jun-2007  ad opt_i2o.h is gone.
 1.18 16-Nov-2006  christos branches: 1.18.8; 1.18.10;
__unused removal on arguments; approved by core.
 1.17 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16 11-Dec-2005  christos branches: 1.16.20; 1.16.22;
merge ktrace-lwp.
 1.15 27-Feb-2005  perry branches: 1.15.4;
nuke trailing whitespace
 1.14 09-Dec-2003  ad branches: 1.14.8; 1.14.10;
Match Promise controllers.
 1.13 15-Nov-2002  itojun branches: 1.13.6;
typo
 1.12 15-Nov-2002  ad Cosmetic changes.
 1.11 08-Nov-2002  msaitoh Add support for Adaptec 200[05]S
reviewed by Andrew Doran
 1.10 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.9 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.7 13-Nov-2001  lukem branches: 1.7.10;
add RCSID
 1.6 22-Sep-2001  ad branches: 1.6.4;
Save some info about the board for dpti.
 1.5 01-Apr-2001  ad branches: 1.5.2; 1.5.4;
- Allocate any private space thats requested.
- Just use mapreg_map().
 1.4 20-Mar-2001  ad +#include <dev/i2o/iopio.h>
 1.3 28-Dec-2000  sommerfeld branches: 1.3.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.2 03-Dec-2000  ad - Force the memory mapping uncacheable.
- We don't need a record of the I/O space mapping.
 1.1 08-Nov-2000  ad branches: 1.1.2;
Add support for I2O adapters and SCSI/FC-AL/BSA class devices. This needs
more testing with different configurations, and work in a number of areas
(which I'm not able to do for a little while), but is at least functional
and stable on i386 with DPT adapters.
 1.1.2.6 01-Apr-2001  ad Sync w/-current.
 1.1.2.5 27-Mar-2001  bouyer Sync with HEAD.
 1.1.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 08-Nov-2000  bouyer file iop_pci.c was added on branch thorpej_scsipi on 2000-11-22 16:04:08 +0000
 1.3.2.6 27-Nov-2002  christos make this compile again [sync to current]
 1.3.2.5 11-Nov-2002  nathanw Catch up to -current
 1.3.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.2 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.3.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.5.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.5.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.4.3 09-Dec-2001  he Pull up revision 1.6 (requested by ad):
Add driver for DPT/Adaptec I2O RAID management interface.
 1.6.4.2 25-Oct-2001  he Pull up revisions 1.1-1.5 (new, via patch, requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.6.4.1 22-Sep-2001  he file iop_pci.c was added on branch netbsd-1-5 on 2001-10-25 18:02:16 +0000
 1.7.10.1 12-Dec-2002  he Pull up revisions 1.11-1.13 (requested by ad in ticket #1030):
Add support for Adaptec 2005S.
Handle DPT ioctls() from native binaries.
Fix SCSI probe problem.
 1.13.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.8.1 29-Apr-2005  kent sync with -current
 1.15.4.3 27-Oct-2007  yamt sync with head.
 1.15.4.2 03-Sep-2007  yamt sync with head.
 1.15.4.1 30-Dec-2006  yamt sync with head.
 1.16.22.2 10-Dec-2006  yamt sync with head.
 1.16.22.1 22-Oct-2006  yamt sync with head
 1.16.20.1 18-Nov-2006  ad Sync with head.
 1.18.10.1 11-Jul-2007  mjf Sync with head.
 1.18.8.3 23-Oct-2007  ad Sync with head.
 1.18.8.2 15-Jul-2007  ad Sync with head.
 1.18.8.1 27-May-2007  ad Checkpoint work in progress. Seems to break block I/O but I am not sure
why yet:

- Avoid a NULL pointer dereference in bus_dmamap_sync.
- MP safety changes, incomplete.
 1.20.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.20.8.1 06-Nov-2007  matt sync with HEAD
 1.20.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.21.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.4.2 16-May-2009  yamt sync with head
 1.22.4.1 16-May-2008  yamt sync with head.
 1.22.2.1 18-May-2008  yamt sync with head.
 1.23.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.26.22.3 03-Dec-2017  jdolecek update from HEAD
 1.26.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.26.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.12.1 30-Oct-2012  yamt sync with head
 1.27.2.1 18-May-2014  rmind sync with head
 1.28.6.1 05-Oct-2016  skrll Sync with HEAD
 1.29.18.1 10-Jun-2019  christos Sync with HEAD
 1.29.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7 08-Jan-2024  chs ips: fix a couple more device_t/softc split bugs
 1.6 12-Feb-2022  riastradh branches: 1.6.4;
ips(4): Missed a couple spots in device_t/softc split.
 1.5 12-Feb-2022  riastradh ips(4): device_t/softc split
 1.4 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.3 24-Apr-2021  thorpej branches: 1.3.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.2 10-Nov-2019  chs branches: 1.2.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.1 03-Dec-2017  jdolecek branches: 1.1.4;
port ips(4) driver from OpenBSD; needs a lot more work, right now just compilable
 1.1.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.3.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6.4.1 14-Jan-2024  martin Pull up following revision(s) (requested by chs in ticket #541):

sys/dev/pci/ips.c: revision 1.7

ips: fix a couple more device_t/softc split bugs
 1.42 22-Sep-2018  maxv Remove isic(4). It is part of ISDN, which we are now retiring.
 1.41 14-Jul-2016  msaitoh branches: 1.41.16; 1.41.18;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.40 29-Mar-2014  christos branches: 1.40.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.39 27-Oct-2012  chs branches: 1.39.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.38 03-Feb-2012  christos branches: 1.38.6;
ansi prototypes
 1.37 06-Dec-2009  dyoung branches: 1.37.12; 1.37.16;
Simplify device-activation hooks.
 1.36 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.35 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.34 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.33 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.31 28-Apr-2008  martin branches: 1.31.8; 1.31.14;
Remove clause 3 and 4 from TNF licenses
 1.30 10-Apr-2008  cegger branches: 1.30.2; 1.30.4;
use aprint_*_dev and device_xname
 1.29 19-Oct-2007  ad branches: 1.29.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.28 09-Jul-2007  ad branches: 1.28.6; 1.28.8; 1.28.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.27 16-Nov-2006  christos branches: 1.27.8; 1.27.10;
__unused removal on arguments; approved by core.
 1.26 16-Oct-2006  pooka * __unused games + other relevant fixes
* give me ANSI C or give me death (at least where it could be easily spotted)
 1.25 11-Dec-2005  christos branches: 1.25.20; 1.25.22;
merge ktrace-lwp.
 1.24 01-Jun-2005  drochner branches: 1.24.2;
quell cast-qual and shadow warnings
 1.23 27-Feb-2005  perry nuke trailing whitespace
 1.22 04-Feb-2005  perry de-__P
 1.21 22-Jul-2004  drochner branches: 1.21.4; 1.21.6;
if the register space os the ISDN card can't be mapped, abort device
attachment instead of dereferencing NULL and so
(this needs a serious cleanup -- the framework was thought to be generally
usable for ~all PCI ISDN cards; this didn't work out, so we are left
with a lot of nonsense to support just 1 particular card type...)
 1.20 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.19 03-Oct-2003  pooka Ready the kernel side of i4b for primary rate interface support by
removing assumptions that there are only two B channels and by
adding support for a varying number of channels.

Due to this, rename previously used isdn identified "bri" to "isdnif",
which better describes the current situation.
 1.18 02-Oct-2002  thorpej branches: 1.18.6;
Add trailing ; to CFATTACH_DECL.
 1.17 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.16 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.15 19-Apr-2002  drochner check interrupt status of the PCI interface chip (if possible)
before calling the (slow) isic handler
being here, remove #ifdefs for FreeBSD and old version support
and add RCS ID tags
 1.14 14-Apr-2002  martin Fix copyright notice.
 1.13 13-Apr-2002  martin Defer initialization of the ISAC chip until we enable interrupts - it gets
into a strange failure mode if we do it with disabled interrupt. When
(re-)enabling interrupts reset transmitter and receiver and clear any
pending state.
 1.12 10-Apr-2002  martin Remove some redundant tries to disable interupts. We already avoided enabling
them.
Fix a stupid typo when enabling/disabling interrupts: we clear pending
interrupts when enabling, not disbling isac interrupts.
 1.11 08-Apr-2002  martin Combine sc_enabled and sc_dying into one field sc_intr_valid, they are used
for the same purpose (ignoring invalid interrupts).

For cards that are not able to stop all interrupts (or we don't know a way
to do that in software, at least) run the clearirq callback even when
ignoring an interrupt because we are not enabled. Otherwise the card would
stop interrupting.

Reserve a driver specific callout handle and an int value in the generic
isic_softc to allow card drivers to implement fancy blinkenlights.
 1.10 30-Mar-2002  martin Be a nice citizen, enable interrupts only when we are ready to talk
to the ISDN (i.e. when userland has /dev/isdn open).
 1.9 27-Mar-2002  martin After Jason Thorpe explained to me how it is supposed to work, implement
(de)activate for pcmcia cards.
Implement detach/(de)activate for PCI cards.
Clean up internal state (free call-descriptors) if a controller is
detached while it has open connections.
 1.8 25-Mar-2002  martin Now that we have all pieces in place (and enough granularity to specify
B-channel and D-channel drivers separately) split the Fritz!PCI card
driver out of the isic driver.

The new device is called "ifpci" and uses the same D-channel driver as the
isic devices, but has it's own B-channel driver.
 1.7 24-Mar-2002  martin Now that we have all the pieces of the puzzle available start to unriddle
and move them in their proper places.

Move the BRI registry from layer 2 (duh!) to layer 4, so active cards
(which don't have layer 3 or layer 2 in their driver). Remove all remaining
hard coded controller and driver types. Remove any arbitrary hard coded
limits, at least those that show up in the internal API.

This fixes PR 15950.
 1.6 10-Feb-2002  wiz pcmcia -> pci in comment.
 1.5 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.4 13-Nov-2001  lukem add RCSID
 1.3 24-Mar-2001  martin branches: 1.3.2;
First step to cleanup the hardware driver <-> upper layers interface.
This now provides slightly more functionality than the FreeBSD layer1-newbus
interface. It was meant to be a simple change to one header and a few
c files, but the change rippled all through various stuff.

To prevent a change to the kernel<->userland interface right now the kernel
is now lying about card types to userland (but who cares). This will be fixed
when the userland interface changes, after layer 3 <-> layer 4 has been
fixed.

Functional changes:

Provide a clean interface for hardware drivers to attach to the upper
layers. This will need another small change in the B-channel handling
when a similar change to the layer 3 <-> layer 4 interface happens.

Avoid passing indices into global arrays of pointers around, instead pass
the pointers itself. Don't code hardware driver types by predefined magic
numbers (think LKM). Prepare for detachable drivers (think pcmcia).

While there remove some sets of function pointers always pointing to the
same function (meant to be the configurable set of D channel protocol
handlers). It is unlikely another supported D-channel protocol will fit into
that (maximal layer interface) abstraction. When we get support for another
protocol, we will need to come up with a workable interface. Besides, the
old implementation was, uhm, strange.
 1.2 20-Feb-2001  martin branches: 1.2.2; 1.2.4;
Filename cleanup: remove i4b_ prefixes outside sys/netisdn, last round.

Renamed in sys/dev/ic:
i4b_hscx.c -> hscx.c
i4b_hscx.h -> hscx.h
i4b_ipac.h -> ipac.h
i4b_isac.c -> isac.c
i4b_isac.h -> isac.h
i4b_isic.c -> isic.c
i4b_isicbchan.c -> isic_bchan.c
i4b_isicl1.c -> isic_l1.c
i4b_isicl1.h -> isic_l1.h
i4b_isicl1fsm.c -> isic_l1fsm.c
 1.1 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.2.4.3 27-Mar-2001  bouyer Sync with HEAD.
 1.2.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.1 20-Feb-2001  bouyer file isic_pci.c was added on branch thorpej_scsipi on 2001-03-12 13:31:08 +0000
 1.2.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.7 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.6 17-Apr-2002  nathanw Catch up to -current.
 1.2.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.2.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.3.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.6.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.18.6.2 04-Feb-2005  skrll Sync with HEAD.
 1.18.6.1 03-Aug-2004  skrll Sync with HEAD
 1.21.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.6.1 12-Feb-2005  yamt sync with head.
 1.21.4.1 29-Apr-2005  kent sync with -current
 1.24.2.3 27-Oct-2007  yamt sync with head.
 1.24.2.2 03-Sep-2007  yamt sync with head.
 1.24.2.1 30-Dec-2006  yamt sync with head.
 1.25.22.2 10-Dec-2006  yamt sync with head.
 1.25.22.1 22-Oct-2006  yamt sync with head
 1.25.20.1 18-Nov-2006  ad Sync with head.
 1.27.10.1 11-Jul-2007  mjf Sync with head.
 1.27.8.2 23-Oct-2007  ad Sync with head.
 1.27.8.1 01-Jul-2007  ad Adapt to callout API change.
 1.28.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.28.8.1 06-Nov-2007  matt sync with HEAD
 1.28.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.29.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.30.4.4 11-Mar-2010  yamt sync with head
 1.30.4.3 16-May-2009  yamt sync with head
 1.30.4.2 04-May-2009  yamt sync with head.
 1.30.4.1 16-May-2008  yamt sync with head.
 1.30.2.1 18-May-2008  yamt sync with head.
 1.31.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.37.16.1 18-Feb-2012  mrg merge to -current.
 1.37.12.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.12.2 30-Oct-2012  yamt sync with head
 1.37.12.1 17-Apr-2012  yamt sync with head
 1.38.6.3 03-Dec-2017  jdolecek update from HEAD
 1.38.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.39.2.1 18-May-2014  rmind sync with head
 1.40.6.1 05-Oct-2016  skrll Sync with HEAD
 1.41.18.1 10-Jun-2019  christos Sync with HEAD
 1.41.16.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.12 22-Sep-2018  maxv Remove isic(4). It is part of ISDN, which we are now retiring.
 1.11 28-Apr-2008  martin branches: 1.11.86; 1.11.88;
Remove clause 3 and 4 from TNF licenses
 1.10 11-Dec-2005  christos branches: 1.10.70; 1.10.72; 1.10.74;
merge ktrace-lwp.
 1.9 04-Feb-2005  perry de-__P
 1.8 22-Jul-2004  drochner branches: 1.8.4; 1.8.6;
if the register space os the ISDN card can't be mapped, abort device
attachment instead of dereferencing NULL and so
(this needs a serious cleanup -- the framework was thought to be generally
usable for ~all PCI ISDN cards; this didn't work out, so we are left
with a lot of nonsense to support just 1 particular card type...)
 1.7 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.6 03-May-2002  drochner branches: 1.6.10;
make the LEDs work with both channels active, some cleanup and
simplification
 1.5 19-Apr-2002  drochner check interrupt status of the PCI interface chip (if possible)
before calling the (slow) isic handler
being here, remove #ifdefs for FreeBSD and old version support
and add RCS ID tags
 1.4 14-Apr-2002  martin Fix copyright notice.
 1.3 27-Mar-2002  martin After Jason Thorpe explained to me how it is supposed to work, implement
(de)activate for pcmcia cards.
Implement detach/(de)activate for PCI cards.
Clean up internal state (free call-descriptors) if a controller is
detached while it has open connections.
 1.2 24-Mar-2002  martin Now that we have all the pieces of the puzzle available start to unriddle
and move them in their proper places.

Move the BRI registry from layer 2 (duh!) to layer 4, so active cards
(which don't have layer 3 or layer 2 in their driver). Remove all remaining
hard coded controller and driver types. Remove any arbitrary hard coded
limits, at least those that show up in the internal API.

This fixes PR 15950.
 1.1 18-Feb-2001  martin branches: 1.1.2; 1.1.4; 1.1.6;
Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.1.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.1.4.1 18-Feb-2001  bouyer file isic_pci.h was added on branch thorpej_scsipi on 2001-03-12 13:31:08 +0000
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.10.2 04-Feb-2005  skrll Sync with HEAD.
 1.6.10.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.1 12-Feb-2005  yamt sync with head.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.74.1 16-May-2008  yamt sync with head.
 1.10.72.1 18-May-2008  yamt sync with head.
 1.10.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.88.1 10-Jun-2019  christos Sync with HEAD
 1.11.86.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.9 25-Mar-2002  martin Now that we have all pieces in place (and enough granularity to specify
B-channel and D-channel drivers separately) split the Fritz!PCI card
driver out of the isic driver.

The new device is called "ifpci" and uses the same D-channel driver as the
isic devices, but has it's own B-channel driver.
 1.8 25-Mar-2002  martin Remove a leftover from the BRI registry at layer 2.
Initialize layer 2's idea of it's BRI id after attaching.
 1.7 24-Mar-2002  martin Now that we have all the pieces of the puzzle available start to unriddle
and move them in their proper places.

Move the BRI registry from layer 2 (duh!) to layer 4, so active cards
(which don't have layer 3 or layer 2 in their driver). Remove all remaining
hard coded controller and driver types. Remove any arbitrary hard coded
limits, at least those that show up in the internal API.

This fixes PR 15950.
 1.6 17-Mar-2002  martin Remove all knowledge about specific application (layer 4) drivers from
the generic layer 4 and layer 3 management system.

This should make the layer 4 driver API LKM clean - finaly.

Make the Fritz!PCI driver work again after resent changes (oops!),
noted by Frank Kardel (PR 15948) and Matthias Scheeler.
 1.5 13-Nov-2001  lukem add RCSID
 1.4 07-Jul-2001  thorpej branches: 1.4.2;
bcopy -> memcpy
 1.3 24-Mar-2001  martin First step to cleanup the hardware driver <-> upper layers interface.
This now provides slightly more functionality than the FreeBSD layer1-newbus
interface. It was meant to be a simple change to one header and a few
c files, but the change rippled all through various stuff.

To prevent a change to the kernel<->userland interface right now the kernel
is now lying about card types to userland (but who cares). This will be fixed
when the userland interface changes, after layer 3 <-> layer 4 has been
fixed.

Functional changes:

Provide a clean interface for hardware drivers to attach to the upper
layers. This will need another small change in the B-channel handling
when a similar change to the layer 3 <-> layer 4 interface happens.

Avoid passing indices into global arrays of pointers around, instead pass
the pointers itself. Don't code hardware driver types by predefined magic
numbers (think LKM). Prepare for detachable drivers (think pcmcia).

While there remove some sets of function pointers always pointing to the
same function (meant to be the configurable set of D channel protocol
handlers). It is unlikely another supported D-channel protocol will fit into
that (maximal layer interface) abstraction. When we get support for another
protocol, we will need to come up with a workable interface. Besides, the
old implementation was, uhm, strange.
 1.2 20-Feb-2001  martin branches: 1.2.2; 1.2.4;
Filename cleanup: remove i4b_ prefixes outside sys/netisdn, last round.

Renamed in sys/dev/ic:
i4b_hscx.c -> hscx.c
i4b_hscx.h -> hscx.h
i4b_ipac.h -> ipac.h
i4b_isac.c -> isac.c
i4b_isac.h -> isac.h
i4b_isic.c -> isic.c
i4b_isicbchan.c -> isic_bchan.c
i4b_isicl1.c -> isic_l1.c
i4b_isicl1.h -> isic_l1.h
i4b_isicl1fsm.c -> isic_l1fsm.c
 1.1 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.2.4.3 27-Mar-2001  bouyer Sync with HEAD.
 1.2.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.1 20-Feb-2001  bouyer file isic_pci_avm_fritz_pci.c was added on branch thorpej_scsipi on 2001-03-12 13:31:08 +0000
 1.2.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.2.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.4.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21 22-Sep-2018  maxv Remove isic(4). It is part of ISDN, which we are now retiring.
 1.20 27-Oct-2012  chs branches: 1.20.36; 1.20.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.19 14-Mar-2009  dsl branches: 1.19.12; 1.19.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.18 10-Apr-2008  cegger branches: 1.18.4; 1.18.12; 1.18.18;
use aprint_*_dev and device_xname
 1.17 19-Oct-2007  ad branches: 1.17.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 09-Jul-2007  ad branches: 1.16.6; 1.16.8; 1.16.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.15 11-Dec-2005  christos branches: 1.15.30; 1.15.32;
merge ktrace-lwp.
 1.14 01-Jun-2005  drochner branches: 1.14.2;
quell cast-qual and shadow warnings
 1.13 27-Feb-2005  perry nuke trailing whitespace
 1.12 22-Jul-2004  drochner branches: 1.12.4; 1.12.6;
if the register space os the ISDN card can't be mapped, abort device
attachment instead of dereferencing NULL and so
(this needs a serious cleanup -- the framework was thought to be generally
usable for ~all PCI ISDN cards; this didn't work out, so we are left
with a lot of nonsense to support just 1 particular card type...)
 1.11 08-May-2003  martin branches: 1.11.2;
We are getting passed an integer value via a void* arg (in an ioctl() like
function) - cast it to an intptr_t.
Addresses parts of PR kern/21448 by Frank Kardel.
 1.10 03-May-2002  drochner make the LEDs work with both channels active, some cleanup and
simplification
 1.9 19-Apr-2002  drochner check interrupt status of the PCI interface chip (if possible)
before calling the (slow) isic handler
being here, remove #ifdefs for FreeBSD and old version support
and add RCS ID tags
 1.8 18-Apr-2002  martin Duh, 0 bits enable interrupts in the IPAC!
So to disable them all better use 0xff instead of 0x00 as mask. Noted
by Matthias Drochner.

Move some initialization unrelated to interrupts back to its place at
attach time.
 1.7 17-Apr-2002  martin Be carefull not to cause interrupts while /dev/isdn is not open.
Make the LEDs work.
 1.6 27-Mar-2002  martin After Jason Thorpe explained to me how it is supposed to work, implement
(de)activate for pcmcia cards.
Implement detach/(de)activate for PCI cards.
Clean up internal state (free call-descriptors) if a controller is
detached while it has open connections.
 1.5 25-Mar-2002  martin Now that we have all pieces in place (and enough granularity to specify
B-channel and D-channel drivers separately) split the Fritz!PCI card
driver out of the isic driver.

The new device is called "ifpci" and uses the same D-channel driver as the
isic devices, but has it's own B-channel driver.
 1.4 24-Mar-2002  martin Now that we have all the pieces of the puzzle available start to unriddle
and move them in their proper places.

Move the BRI registry from layer 2 (duh!) to layer 4, so active cards
(which don't have layer 3 or layer 2 in their driver). Remove all remaining
hard coded controller and driver types. Remove any arbitrary hard coded
limits, at least those that show up in the internal API.

This fixes PR 15950.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 20-Feb-2001  martin branches: 1.2.2; 1.2.4; 1.2.6;
Filename cleanup: remove i4b_ prefixes outside sys/netisdn, last round.

Renamed in sys/dev/ic:
i4b_hscx.c -> hscx.c
i4b_hscx.h -> hscx.h
i4b_ipac.h -> ipac.h
i4b_isac.c -> isac.c
i4b_isac.h -> isac.h
i4b_isic.c -> isic.c
i4b_isicbchan.c -> isic_bchan.c
i4b_isicl1.c -> isic_l1.c
i4b_isicl1.h -> isic_l1.h
i4b_isicl1fsm.c -> isic_l1fsm.c
 1.1 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.2.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.1 20-Feb-2001  bouyer file isic_pci_elsa_qs1p.c was added on branch thorpej_scsipi on 2001-03-12 13:31:09 +0000
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.4.1 29-Apr-2005  kent sync with -current
 1.14.2.2 27-Oct-2007  yamt sync with head.
 1.14.2.1 03-Sep-2007  yamt sync with head.
 1.15.32.1 11-Jul-2007  mjf Sync with head.
 1.15.30.2 23-Oct-2007  ad Sync with head.
 1.15.30.1 01-Jul-2007  ad Adapt to callout API change.
 1.16.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.8.1 06-Nov-2007  matt sync with HEAD
 1.16.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.4.1 04-May-2009  yamt sync with head.
 1.19.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.12.1 30-Oct-2012  yamt sync with head
 1.20.38.1 10-Jun-2019  christos Sync with HEAD
 1.20.36.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.12 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.11 07-Aug-2023  msaitoh ichsmb(4),ismt(4): Add Snow Ridge support.
 1.10 10-May-2023  riastradh ismt(4): Use config_detach_children.
 1.9 07-Aug-2021  thorpej branches: 1.9.6;
Merge thorpej-cfargs2.
 1.8 24-Apr-2021  thorpej branches: 1.8.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.7 22-Dec-2019  thorpej branches: 1.7.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.6 17-Aug-2017  msaitoh branches: 1.6.2; 1.6.6; 1.6.12;
Add C3000 devices.
 1.5 27-Apr-2017  msaitoh branches: 1.5.2;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.4 11-Jul-2016  knakahara branches: 1.4.8;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.3 01-Feb-2016  msaitoh branches: 1.3.2;
Add parenthesis for the addr argument of ISMT_DESC_ADDR_RW(addr, is_read).
It was no real bug.
 1.2 06-Jan-2016  christos fix 32 bit compilation
 1.1 05-Jan-2016  msaitoh Port FreeBSD's ismt(4) driver. ismt(4) supports Intel Chipset internal
SMBus 2.0 controller with DMA. It's different from ichsmb(4). Supported
chipsets are S1200 and C2000.
 1.3.2.4 28-Aug-2017  skrll Sync with HEAD
 1.3.2.3 05-Oct-2016  skrll Sync with HEAD
 1.3.2.2 19-Mar-2016  skrll Sync with HEAD
 1.3.2.1 01-Feb-2016  skrll file ismt.c was added on branch nick-nhusb on 2016-03-19 11:30:11 +0000
 1.4.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.5.2.2 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1891):

sys/dev/pci/ichsmb.c: revision 1.85
sys/dev/pci/ismt.c: revision 1.11

ichsmb(4),ismt(4): Add Snow Ridge support.
 1.5.2.1 26-Feb-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #565):
sys/dev/pci/ichsmb.c: 1.51
sys/dev/pci/ismt.c: 1.6
Add C3000 devices.
 1.6.12.1 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1723):

sys/dev/pci/ichsmb.c: revision 1.85
sys/dev/pci/ismt.c: revision 1.11

ichsmb(4),ismt(4): Add Snow Ridge support.
 1.6.6.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.2.2 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 17-Aug-2017  jdolecek file ismt.c was added on branch tls-maxphys on 2017-12-03 11:37:08 +0000
 1.7.10.2 03-Apr-2021  thorpej ismt_config_interrupts(): remove a now-unused variable.
 1.7.10.1 24-Mar-2021  thorpej Don't filter interface attributes in rescan functions for devices that
carry only a single interface attribute. The autoconfiguration machinery
already considers interface attributes when searching for possible parents.
 1.8.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.9.6.1 23-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #338):

sys/dev/pci/ichsmb.c: revision 1.85
sys/dev/pci/ismt.c: revision 1.11

ichsmb(4),ismt(4): Add Snow Ridge support.
 1.122 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.121 15-Oct-2019  christos remove conditional portion that was wrong and always false.
 1.120 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.119 14-Jul-2016  msaitoh branches: 1.119.16; 1.119.18;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.118 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.117 29-Mar-2014  christos branches: 1.117.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.116 14-Sep-2013  martin Remove unused variable
 1.115 24-May-2011  joerg branches: 1.115.4; 1.115.14; 1.115.18;
Use proper format string
 1.114 28-Feb-2011  mjacob Update isp driver to be in sync with other platforms. Mostly very minor changes
with effectively zero impact on NetBSD.
 1.113 13-Nov-2010  uebayasi branches: 1.113.2; 1.113.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.112 12-Apr-2010  mjacob Oops. Don't forget to set the isp_port value based upon PCI function code.
Otherwise you end up with both ports using the same WWPN. Bad.
Discovered by Havard. Pointy hat to me.
 1.111 26-Mar-2010  mjacob Synchronize with other platforms:

Strongly architect handles so we can more easily detect bogus
handles. This switches us to a full 32 bits for all handles.

Handle the case of FC disks disappearing and then reappearing-
at least at the FC transport level.

Some better and finer control of debug and non-debug printouts.
 1.110 07-Sep-2009  tsutsui branches: 1.110.2; 1.110.4;
Split device_t/softc.
Tested QLogic 1020 Fast Wide SCSI HBA at PCI.
Sbus attachment is untested, but not so much quirks in it.
 1.109 25-Jun-2009  mjacob Update ISP driver to latest and greatest. Includes support for the 8Gb part.
 1.108 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.107 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.106 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.105 07-Apr-2008  cegger branches: 1.105.4; 1.105.18;
use aprint_*_dev and device_xname and get rid of isp_name
 1.104 11-Mar-2008  mjacob Checkpoint of some fairly major isp(4) rototilling.

Reintroduce more of a 'channel' concept in preparation for NP-IV support.
This gets rid of the chanA/chanB concept as the 2400 can have up to 128
virtual channels. Actually, with MID firmware you can also have the 2200
and 2300 support 'channels, but they do it with an FL-Port topology.
Because FC cards can now have 'channels', just about every support
function for fibre channel had to be redone to have a channel index
as well. Rototill isp_ioctl.h for channel stuff as well.

Pick up a lot of work about fabric management (hopefully better) and keep
work in place that will allow for dynamic attachment/detachment of devices
(if I can figure out how to make the midlayer support it).

Merge the target code with external trees. Eventually it might even
be sorted out on NetBSD.

Update some firmware stuff.
 1.103 26-Jun-2007  mjacob branches: 1.103.8; 1.103.24; 1.103.28;
If we have 2K Login firmware for 23XX cards, remember to put out the
'extended' structure- not the older one. Matters for the swozzling
that goes on for big endian machines.
 1.102 25-May-2007  mjacob Whoops- I almost forgot. Thank MetrumRG Associates for material
support in making 4Gb NetBSD support possible.
 1.101 24-May-2007  mjacob Major update to isp(4) driver to bring it in line with external sources.

The major changes are:

+ 4Gb (24XX) card support
+ Rewritten fabric and loop evaluation code
+ New f/w sets

The 4Gb changes required major rototilling, which caused a rewrite of
fabric and loop eval code. The latter can now be set up to tune for
dynamic device arrival/departure if the framework is set up for it,
or to be firm about waiting for devices.

Testing has been principally on amd64, i386 and sparc64 and seems to
not have broken things for me.
 1.100 04-Mar-2007  christos branches: 1.100.2; 1.100.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.99 13-Jan-2007  cube branches: 1.99.2;
Make the logic of handling the options right.
 1.98 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.97 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.96 02-Sep-2006  christos branches: 1.96.2; 1.96.4;
add missing initializers
 1.95 29-Mar-2006  thorpej Use device_cfdata().
 1.94 11-Dec-2005  christos branches: 1.94.4; 1.94.6; 1.94.8; 1.94.10; 1.94.12;
merge ktrace-lwp.
 1.93 30-May-2005  christos branches: 1.93.2;
- const poisoning
- avoid variable shadowing.
 1.92 27-Feb-2005  perry nuke trailing whitespace
 1.91 10-Mar-2004  matt branches: 1.91.8; 1.91.10;
Fixes for that only support for the 2030 can be compiled in.
 1.90 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.89 07-Aug-2003  mjacob Add in changes from Matt Thomas to check for 64 bit PCI stuff.

Note that a Qlogic 1020 is Fast Wide, not Ultra Fast Wide.
 1.88 03-May-2003  wiz branches: 1.88.2;
DMA, not dma nor Dma.
 1.87 25-Nov-2002  thorpej Add ULL to 64-bit integer constants.
 1.86 18-Oct-2002  mjacob Put in, sight unseen, changes which should enable 10160 support.

Interestingly enough, Sun actually made a product out of the 10160,
which is a single channel variant of the 12160 (Ultra3) card.
 1.85 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.84 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.83 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.82 12-Aug-2002  mjacob Various changes to allow for overriding just loopid and/or iid.
Fix a random 23XX ISR reading bug. Be chattier about HBA_BOTCH
errors. More f/w cashdump layering.
 1.81 15-Jun-2002  mjacob Make all 23XX cards 'touched'. We seem to, too often, hang when trying
to run ABOUT FIRMWARE at the first isp_reset call. We *do* check for
the registers being set with values which would tell us if there's
firmware running or not- but this seems to not always work. It's not
essential, so move on.
 1.80 17-May-2002  mjacob Slight touchup on last change- make sure HBA_BOTCH is set (just in case
somebody at a different level does the wrong thing) on ENOMEM/EAGAIN returns
from loading DMA.
 1.79 12-May-2002  matt branches: 1.79.2;
If a dma map can't be loaded due to resource shortage, make we report that
as a resource shortage instead of a driver stuffup.
 1.78 28-Apr-2002  mjacob suggestion from Jason: have (in non-verbose boot case) card type printed out
on same line as attachment line.
 1.77 22-Mar-2002  mjacob Handle Port Unavailable the same as Port Logout (i.e., send a LIP).

Unconst pointer to f/w in the ispdv structure. Too many compilers get
unhappy over our walking the array. Make casts as appropriate so that
initialization in structure is still happy.

Limit length of fabric to 256. This will all go away soon.

Do a cleaner case of keeping multiple CPUs/threads from reading the
same response queue entries.
 1.76 21-Feb-2002  mjacob Implement F/W crashdumps for 2200 && 2300 cards (kernel compile option).

Distinguish between 2312 and 2300 cards (they *are* different). Enable
RIO (Reduced Interrupt Operation) for the LVD cards (hey- I've seen
batched completions of the 30 commands at a time with this,....)...

If we get a Port Logout on local loop topologies, we have to force the
f/w to log back in. The easiest way (for us) to do this is to force
a LIP. This also will wake up the disk that probably just had a f/w crash.

Implement mailbox 'continuations'- this allows interrupts to re-drive
a mailbox command if it's one that just essentially repeats the previous
mailbox command (e.g., f/w download). This saves a boatload of sleep/wakeup
twitches.

If we're not a 2300 and we're about to return with a 'bogus interrupt'- check
the semaphore register to be non-zero at all and outgoing mailbox 0- this
seems to be where some of the lost ISP1080 commands came from.
 1.75 14-Dec-2001  mjacob Major restructuring for swizzling to the request queue and unswizzling from
the response queue. Instead of the ad hoc ISP_SWIZZLE_REQUEST, we now have
a complete set of inline functions in isp_inline.h. Each platform is
responsible for providing just one of a set of ISP_IOX_{GET,PUT}{8,16,32}
macros.

The reason this needs to be done is that we need to have a single set of
functions that will work correctly on multiple architectures for both little
and big endian machines. It also needs to work correctly in the case that
we have the request or response queues in memory that has to be treated
specially (e.g., have ddi_dma_sync called on it for Solaris after we update
it or before we read from it).

One thing that falls out of this is that we no longer build requests in the
request queue itself. Instead, we build the request locally (e.g., on the
stack) and then as part of the swizzling operation, copy it to the request
queue entry we've allocated. I thought long and hard about whether this was
too expensive a change to make as it in a lot of cases requires an extra
copy. On balance, the flexbility is worth it. With any luck, the entry that
we build locally stays in a processor writeback cache (after all, it's only
64 bytes) so that the cost of actually flushing it to the memory area that is
the shared queue with the PCI device is not all that expensive. We may examine
this again and try to get clever in the future to try and avoid copies.

Another change that falls out of this is that MEMORYBARRIER should be taken
a lot more seriously. The macro ISP_ADD_REQUEST does a MEMORYBARRIER on the
entry being added. But there had been many other places this had been missing.
It's now very important that it be done.

For NetBSD, it does a ddi_dmamap_sync as appropriate. This gets us out of
the explicit ddi_dmamap_sync on the whole response queue that we did for SBus
cards at each interrupt.

Set things up so that platforms that cannot have an SBus don't get a lot of
the SBus code checks (dead coded out).

Additional changes:

Fix a longstanding buglet of sorts. When we get an entry via isp_getrqentry,
the iptr value that gets returned is the value we intend to eventually plug
into the ISP registers as the entry *one past* the last one we've written-
*not* the current entry we're updating. All along we've been calling sync
functions on the wrong index value. Argh. The 'fix' here is to rename all
'iptr' variables as 'nxti' to remember that this is the 'next' pointer-
not the current pointer.

Devote a single bit to mboxbsy- and set aside bits for output mbox registers
that we need to pick up- we can have at least one command which does not
have any defined output registers (MBOX_EXECUTE_FIRMWARE).

Explicitly decode GetAllNext SNS Response back *as* a GetAllNext response.
Otherwise, we won't unswizzle it correctly.

Nuke some additional __P macros.
 1.74 13-Nov-2001  lukem add RCSID
 1.73 06-Oct-2001  mjacob Respect QLogic's errata- read BIU_ISR even on the 2300
to see if there's an interrupt (avoids PCI parity errors
which can occur on the 2312 if you access some registers
from the host at the same time the RISC on the 2312 is
accessing them).
 1.72 01-Sep-2001  mjacob branches: 1.72.2;
Add support for 2 Gigabit cards (2300/2312). This necessitated a change
in how interrupts are down- the 23XX has not only a different place to check
for an interrupt, but unlike all other QLogic cards, you have to read the
status as a 32 bit word- not 16 bit words. Rather than have device specific
functions as called from the core module (in isp_intr), it makes more sense
to have the platform/bus modules do the gruntwork of splitting out the
isr, semaphore register and the first outgoing mailbox register (if needed)
*prior* to calling isp_intr (if calling isp_intr is necessary at all).
 1.71 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.70 07-Jul-2001  thorpej branches: 1.70.2;
bzero -> memset
 1.69 14-Jun-2001  mjacob Ooops- we need to allocate an array of pointers to scsipi_xfer structures
isp_maxcmds in length- not an array of scsipi_xfer structures isp_maxcmds
in length.
 1.68 14-Mar-2001  mjacob Clean up licence a bit. ANSIfy.
 1.67 07-Mar-2001  thorpej Add BUS_DMA_STREAMING to data transfer maps.
 1.66 12-Feb-2001  mjacob branches: 1.66.2;
set default HBA role
 1.65 30-Dec-2000  mjacob Use bootverbose to now set whether or not we add
ISP_LOGCONFIG and ISP_LOGINFO messages into the
default logging mask.
 1.64 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.63 28-Dec-2000  mjacob Apply Bill Sommerfeld's -Wformat changes.
 1.62 23-Dec-2000  wiz Fix pathnames in comment.
 1.61 09-Dec-2000  mjacob Finally fix this driver to be sensible about the ENDIAN dance. It's not
quite simply a question of the Qlogic being little endian and having
to have stuff swapped on big endian machines- it also has to do with the
fact that the SBus and PCI DMA layouts are wierd with respect to this.

At any rate, now finally fixed- works on Mac G4, tested it on a SS10
for sparc, checked on alpha to see if I've broken anything, and as
soon as I get another spare afternoon I'll finally install a sparc64
version which should just work (as it'll be like the Mac).
 1.60 06-Dec-2000  mjacob Correct omission by the previous committer.
 1.59 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.58 17-Oct-2000  mjacob quiet chatty boot messages
 1.57 16-Oct-2000  mjacob Remember to establish default PORT WWN. Add in some LOGDEBUG2 messages
for the dma mapping code.
 1.56 14-Aug-2000  mjacob Add a maintenance note. Minor change in some logic in the DMA mapping.
 1.55 03-Aug-2000  mjacob More compilation breakage in the non-DEBUG case
(from Castor Fu <castor@geocast.com>)
 1.54 02-Aug-2000  mjacob Fix bonehead bug for compiles w/o DEBUG set
(thanks to KANETA Shin'ichi <kaneta@cr.chiba-u.ac.jp>)
 1.53 01-Aug-2000  mjacob Core version 2.0 (platform version 1.0) rewrite of ISP driver. Some
interace cleanups, some new common functions. The major impact that
will be noticeable right away is that if you boot with not Fibre connected
to the FC cards, you no longer hang indefinitely.
 1.52 05-Jul-2000  mjacob Use new isp_handle_index function. Redo how firmware is checked for
and loaded. Remember to enable interrupts after isp_reset but before
isp_attach. Return CMD_EAGAIN on request queue overflow so we can retry
the command when there's more queue space.
 1.51 19-Feb-2000  mjacob branches: 1.51.4;
Support for > 12 byte commands for parallel SCSI.
 1.50 12-Feb-2000  mjacob add (untested in NetBSD yet) Qlogic 12160 (Ultra3) suppot
 1.49 20-Dec-1999  mjacob get back to looking at config flags
 1.48 16-Dec-1999  mjacob Dual LVD (1280) support.
 1.47 04-Dec-1999  mjacob request/response queues now indexed via u_int16_t. Add back in f/w inclusion
and clean up it's compilation. get chip rev out of pci header.
 1.46 28-Oct-1999  mjacob Remove reference to loadable f/w.
 1.45 17-Oct-1999  mjacob branches: 1.45.2; 1.45.4;
Oops- missed a MAXISPREQUEST sized thing- these are all gone now. It's amazing
this didn't eat me.
 1.44 17-Oct-1999  mjacob stylistic cleanups
 1.43 14-Oct-1999  mjacob F/W version no longer relevant. Only do WWN seed for FC cards.
Now we malloc xflist and dma maps in mailbox setup routines.
We also do the appropriate endian swizzling at the end of a dma
map routine.
 1.42 30-Sep-1999  thorpej branches: 1.42.2;
Update for SCSPI changes.
 1.41 05-Jul-1999  mjacob Change to approved NASA/Ames copyright. Add in Qlogic 2200 support.
 1.40 12-May-1999  mjacob Do a fairly large internal restructuring to accomodate dual-bus host adapters
(e.g., the 1240). Include the new 1080/1240 NVRAM layout reading code. Some
moderately significant mailbox changes were necessary also to accomodate a
second channel.
 1.39 04-Apr-1999  mjacob Read the board revision and trim cache line size back from 16 to 1
for early revision 2100 boards. Make sure to turn ROM off for these
boards.
 1.38 27-Mar-1999  mjacob branches: 1.38.2; 1.38.4;
Oops- if you enable 1080 support, remember to load the f/w
 1.37 26-Mar-1999  mjacob add isp1080 support and some basic PDB change stuff
 1.36 17-Mar-1999  mjacob prototype 1080/1240 support
 1.35 09-Feb-1999  mjacob clean up pci configuration a bit
 1.34 30-Jan-1999  mjacob roll internal release tag
 1.33 10-Jan-1999  mjacob oops. Forgot to turn on PCI burst.
 1.32 28-Dec-1998  mjacob I mean *really* clean up headers
 1.31 28-Dec-1998  mjacob clean up headers; remove early revision 2100 workarounds
 1.30 17-Sep-1998  mjacob dma setup now returns CMD_QUEUED or CMD_COMPLETE. Clarify a ternary
operation that needed some parentheses.
 1.29 08-Sep-1998  mjacob Remove clocks as common code now can determine what clock rates to use.

Remove other than 8 byte bursts- until we clarify whether or not buggy
PCI implementatiosn really cause problems.
 1.28 12-Aug-1998  mjacob minor change to make the message less linux like
 1.27 31-Jul-1998  thorpej Back out part of previous; it is perfectly reasonable, and desirable, to
print out debugging info ifdef DEBUG.
 1.26 31-Jul-1998  mjacob Part A (Cosmetic nonsense):
>We're not Linux. If we still want driver version strings to be displayed
>at boot, then I suppose DEBUG is a reasonable compromise.
Makes the whole concept useless. This is for default printouts. If you
can build a debug kernel, you know what version you have. This was under
the concept of 'RAS' so that hapless users could tell you microversion
things. But I guess this isn't the right way according to our local
Jesuits. Oh, well. I'll think up something different and hopefully
less objectionable. And yes, NetBSD isn't linux. The developers seem
to be equally bad tempered, but linux is more successful.

Part B:
Field interrupts in OS layer so that (in this OS) bus_dmamap_sync(POSTREAD)
can (formally) ensure that the result queue is stable wrt to buffering
and that for sending a command a bus_dmamap_sync(PREWRITE) is done to
ensure that the device gets a good view of what the mailbox contents
should be.
 1.25 20-Jul-1998  thorpej branches: 1.25.2;
Oops, unused variable warning.
 1.24 20-Jul-1998  thorpej We're not Linux. If we still want driver version strings to be displayed
at boot, then I suppose DEBUG is a reasonable compromise.
 1.23 18-Jul-1998  mjacob fix bogus initialization
 1.22 18-Jul-1998  mjacob locking now out of main framework for isp_reset/isp_init
 1.21 15-Jul-1998  mjacob no framework
 1.20 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.19 04-Feb-1998  thorpej Add offset and length parameters to bus_dmamap_sync(), used for specifiying
partial syncs of a DMA mapping.
 1.18 04-Feb-1998  thorpej Add dm_mapsize to bus_dmamap_t and rename BUS_DMAMEM_NOSYNC to
BUS_DMA_COHERENT.
 1.17 10-Sep-1997  mjacob branches: 1.17.2;
For the 2100- the flags weren't quite right- but things worked anyway. Wierd.
 1.16 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.15 16-Aug-1997  mjacob Major rework to support Qlogic ISP2100 (Fibre Channel PCI card). Also now
able to read SXP registers (instead of panicing). Probably have done a bit
of setup overkill- we now alloc some scratch memory for the 2100 that I thought
I would need for the Port database, but so far I haven't needed to retrieve
the port database. Well, early days yet.
 1.14 08-Jun-1997  thorpej branches: 1.14.2; 1.14.4;
Fix pasto: sbus -> pci
 1.13 08-Jun-1997  thorpej - Update for changes to core ISP driver.
- Convert to use bus dma, greatly simplifying DMA setup.
 1.12 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.11 13-Apr-1997  cgd use pci_map_register(). map both mem and I/O spaces, preferring mem
space if it's usable, but falling back to I/O space if mem isn't usable.
 1.10 05-Apr-1997  mjacob Add 60 (MHz) value for PCI clock frequency value. Also enable DMA bursting.
 1.9 28-Mar-1997  cgd clean up (unify) the register mapping code a bit
 1.8 28-Mar-1997  cgd punt pci_mem_find's &cacheable arg, and pass NULL instead. We never
want to map the memory register cacheable.
 1.7 28-Mar-1997  cgd clean up isp_pci_prefer_io comment
 1.6 16-Mar-1997  cgd map either via memory or I/O space, depending on the setting of a
patchable kernel variable. eventually, it might make sense to turn
this into a driver flag or something.
 1.5 13-Mar-1997  cgd change microcode array definitions from "unsigned short" to the more
correct u_int16_t, and remove bogus casts that the old definition
required.
 1.4 13-Mar-1997  mycroft Make the microcode table const.
 1.3 13-Mar-1997  cgd include <vm/vm.h> for vtophys() on x86. kill extra <sys/kernel.h> incl.
 1.2 12-Mar-1997  cgd NetBSD RCS ID tweaks, a few comment block tweaks. Also, make copyright
notices consistent (per Matt Jacob).
 1.1 12-Mar-1997  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 12-Mar-1997  cgd ISP 10x0 driver from Matthew Jacob of NASA Ames Research Center.
(March 12, 1997 version).
 1.14.4.3 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.4.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.2.2 26-Aug-1997  bouyer Update from trunk.
 1.14.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.17.2.1 07-Nov-1998  cgd pull up revs 1.18-1.30 from trunk, and patch to make functional in
1.3.x. (mjacob)
 1.25.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.38.4.2 02-Aug-1999  thorpej Update from trunk.
 1.38.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.38.2.2 13-May-2000  he Apply patch (requested by Matthew Jacob via he):
Correctly account for F-port vs. F-port (no FLOGI_ACC) topologies.
Make sure we get a port database entry for the fabric name server.
Preserve fabric logins if the device didn't change across fabric
or port database changes, or the device has already logged into
us (e.g., for target/initiator dual role devices like Veritas
SANbox). Propagate class 3 service parameter changes where devices
can change roles.

Fix all occurrences of setting a sendmarker so that setting it
for one bus on dual bus cards doesn't wipe a pending sendmarker
for other busses on the same card.

Comments added and clarifications made in some of the target mode code.

Add support for > 12 byte CDBs. Split out nvram reading into
per-card functions. Add proper Ultra2/Ultra3 support. Upgrade
firmware.
 1.38.2.1 08-Jan-2000  he Pull up revisions 1.31-1.41,1.43-1.49 (via patch, requested by mjacob):
Untangle Qlogic firmware copyright problems and update firmware.
Untangle some MD support issues for said firmware. Add 1280 (Dual
LVD), 1240 (Dual Ultra), 2200 (2nd Generation Qlogic FC chipset).
Fix some synchronous negotiation problems for parallel SCSI.
Firm up some Fabric Support issues.
 1.42.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.45.4.1 15-Nov-1999  fvdl Sync with -current
 1.45.2.8 27-Mar-2001  bouyer Sync with HEAD.
 1.45.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.45.2.6 05-Jan-2001  bouyer Sync with HEAD
 1.45.2.5 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.45.2.4 08-Dec-2000  bouyer Sync with HEAD.
 1.45.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.45.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.45.2.1 20-Oct-1999  thorpej Eliminate sleeping from adapter routines.
 1.51.4.4 16-Mar-2001  he Pull up revisions 1.62-1.63,1.66,1.68 (requested by mjacob):
Fix pathnames in comment. Apply -Wformat changes.
Set default HBA role (to ISP_ROLE_INITIATOR).
 1.51.4.3 26-Jan-2001  jhawk Back out revision 1.60 (requested by mjacob), erroneously pulled up.
 1.51.4.2 25-Jan-2001  jhawk Pull up revisions 1.57-1.58, 1.60-1.61 (requested by mjacob):
Add in correct SBus bursting; upgrade to 2.01.26 firmware; pull to latest
initiator mode level; make changes to WWN default handling; quiet
chatty boot messages; fix endian code so MacPPC works; fix bug in
lock recursion counter; fix bug which excluded all but NL-ports from
being logged into on a fabric.
 1.51.4.1 28-Aug-2000  mjacob Complete rewrite of internals for isp core version 2.0.
Pullup to netbsd-1-5 approved by thorpej@netbsd.org.
 1.66.2.14 11-Dec-2002  thorpej Sync with HEAD.
 1.66.2.13 11-Nov-2002  nathanw Catch up to -current
 1.66.2.12 18-Oct-2002  nathanw Catch up to -current.
 1.66.2.11 13-Aug-2002  nathanw Catch up to -current.
 1.66.2.10 20-Jun-2002  nathanw Catch up to -current.
 1.66.2.9 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.66.2.8 28-Feb-2002  nathanw Catch up to -current.
 1.66.2.7 08-Jan-2002  nathanw Catch up to -current.
 1.66.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.66.2.5 22-Oct-2001  nathanw Catch up to -current.
 1.66.2.4 21-Sep-2001  nathanw Catch up to -current.
 1.66.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.66.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.66.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.70.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.70.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.70.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.70.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.70.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.70.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.70.2.1 03-Aug-2001  lukem update to -current
 1.72.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.79.2.3 29-Aug-2002  gehenna catch up with -current.
 1.79.2.2 20-Jun-2002  gehenna catch up with -current.
 1.79.2.1 30-May-2002  gehenna Catch up with -current.
 1.88.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.88.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.88.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.88.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.88.2.1 03-Aug-2004  skrll Sync with HEAD
 1.91.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.91.8.1 29-Apr-2005  kent sync with -current
 1.93.2.5 17-Mar-2008  yamt sync with head.
 1.93.2.4 03-Sep-2007  yamt sync with head.
 1.93.2.3 26-Feb-2007  yamt sync with head.
 1.93.2.2 30-Dec-2006  yamt sync with head.
 1.93.2.1 21-Jun-2006  yamt sync with head.
 1.94.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.94.10.1 19-Apr-2006  elad sync with head.
 1.94.8.2 03-Sep-2006  yamt sync with head.
 1.94.8.1 01-Apr-2006  yamt sync with head.
 1.94.6.1 22-Apr-2006  simonb Sync with head.
 1.94.4.1 09-Sep-2006  rpaulo sync with head
 1.96.4.2 10-Dec-2006  yamt sync with head.
 1.96.4.1 22-Oct-2006  yamt sync with head
 1.96.2.2 01-Feb-2007  ad Sync with head.
 1.96.2.1 18-Nov-2006  ad Sync with head.
 1.99.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.100.4.1 11-Jul-2007  mjf Sync with head.
 1.100.2.2 15-Jul-2007  ad Sync with head.
 1.100.2.1 27-May-2007  ad Sync with head.
 1.103.28.2 02-Jun-2008  mjf Sync with HEAD.
 1.103.28.1 03-Apr-2008  mjf Sync with HEAD.
 1.103.24.1 24-Mar-2008  keiichi sync with head.
 1.103.8.1 23-Mar-2008  matt sync with HEAD
 1.105.18.2 23-Jul-2009  jym Sync with HEAD.
 1.105.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.105.4.4 11-Aug-2010  yamt sync with head.
 1.105.4.3 16-Sep-2009  yamt sync with head
 1.105.4.2 18-Jul-2009  yamt sync with head.
 1.105.4.1 16-May-2009  yamt sync with head
 1.110.4.3 31-May-2011  rmind sync with head
 1.110.4.2 05-Mar-2011  rmind sync with head
 1.110.4.1 30-May-2010  rmind sync with head
 1.110.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.113.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.113.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.115.18.1 18-May-2014  rmind sync with head
 1.115.14.2 03-Dec-2017  jdolecek update from HEAD
 1.115.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.115.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.117.6.2 05-Oct-2016  skrll Sync with HEAD
 1.117.6.1 09-Jul-2016  skrll Sync with HEAD
 1.119.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.119.18.1 10-Jun-2019  christos Sync with HEAD
 1.119.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.19 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.18 27-Oct-2012  chs branches: 1.18.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.17 31-Jul-2012  bouyer branches: 1.17.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.16 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.15 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.14 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.13 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.12 04-Apr-2011  dyoung branches: 1.12.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.11 05-Nov-2010  jakllsch branches: 1.11.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.10 10-Apr-2008  cegger branches: 1.10.24; 1.10.26;
use aprint_*_dev and device_xname
 1.9 18-Mar-2008  cube Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.8 09-Feb-2007  ad branches: 1.8.20; 1.8.36; 1.8.40;
Merge newlock2 to head.
 1.7 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.6 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.5 30-Jun-2006  xtraeme branches: 1.5.4; 1.5.6;
Match IT8211 IDE Controller.
 1.4 11-Dec-2005  christos branches: 1.4.4; 1.4.8; 1.4.16;
merge ktrace-lwp.
 1.3 24-May-2005  lukem branches: 1.3.2;
add __KERNEL_RCSID
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 01-Dec-2004  grant branches: 1.1.4; 1.1.6; 1.1.8;
add iteide(4) driver for ITE8212-based IDE controllers. from
OpenBSD, ported to NetBSD by me.

ok'd by bouyer@, thorpej@.
 1.1.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 29-Apr-2005  kent sync with -current
 1.1.4.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.2 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.1 01-Dec-2004  skrll file iteide.c was added on branch ktrace-lwp on 2004-12-18 09:32:08 +0000
 1.3.2.3 24-Mar-2008  yamt sync with head.
 1.3.2.2 26-Feb-2007  yamt sync with head.
 1.3.2.1 30-Dec-2006  yamt sync with head.
 1.4.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.4.8.1 11-Aug-2006  yamt sync with head
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.6.2 10-Dec-2006  yamt sync with head.
 1.5.6.1 22-Oct-2006  yamt sync with head
 1.5.4.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.5.4.1 18-Nov-2006  ad Sync with head.
 1.8.40.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.36.1 24-Mar-2008  keiichi sync with head.
 1.8.20.1 23-Mar-2008  matt sync with HEAD
 1.10.26.2 21-Apr-2011  rmind sync with head
 1.10.26.1 05-Mar-2011  rmind sync with head
 1.10.24.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.11.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.4.1 30-Oct-2012  yamt sync with head
 1.17.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.18.2.1 18-May-2014  rmind sync with head
 1.11 22-Sep-2018  maxv Remove iwic(4). It is part of ISDN, which we are now retiring. This driver
was still marked as experimental (its man page dates back to 2002).
 1.10 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.9 23-Mar-2014  christos branches: 1.9.28; 1.9.30;
remove unused
 1.8 27-Oct-2012  chs branches: 1.8.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.7 10-Apr-2008  cegger branches: 1.7.38; 1.7.48;
use aprint_*_dev and device_xname
 1.6 19-Oct-2007  ad branches: 1.6.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 11-Dec-2005  christos branches: 1.5.30; 1.5.44; 1.5.46; 1.5.50;
merge ktrace-lwp.
 1.4 09-Jul-2005  christos make the isdn drivers compile again with -Wconst, -Wshadow
 1.3 27-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 27-Sep-2002  provos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.18; 1.2.20;
remove trailing \n in panic(). approved perry.
 1.1 24-Sep-2002  pooka Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.2.20.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.18.1 29-Apr-2005  kent sync with -current
 1.2.10.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.10.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.4.1 27-Sep-2002  nathanw file iwic_bchan.c was added on branch nathanw_sa on 2002-10-18 02:43:10 +0000
 1.2.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.1 27-Sep-2002  jdolecek file iwic_bchan.c was added on branch kqueue on 2002-10-10 18:40:53 +0000
 1.3.4.2 27-Oct-2007  yamt sync with head.
 1.3.4.1 21-Jun-2006  yamt sync with head.
 1.5.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.46.1 06-Nov-2007  matt sync with HEAD
 1.5.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.30.1 23-Oct-2007  ad Sync with head.
 1.6.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.48.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.48.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.7.38.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.38.1 30-Oct-2012  yamt sync with head
 1.8.2.1 18-May-2014  rmind sync with head
 1.9.30.1 10-Jun-2019  christos Sync with HEAD
 1.9.28.2 30-Sep-2018  pgoyette Ssync with HEAD
 1.9.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.11 22-Sep-2018  maxv Remove iwic(4). It is part of ISDN, which we are now retiring. This driver
was still marked as experimental (its man page dates back to 2002).
 1.10 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.9 23-Mar-2014  christos branches: 1.9.28; 1.9.30;
remove unused
 1.8 23-Mar-2014  christos remove unused
 1.7 27-Oct-2012  chs branches: 1.7.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.6 10-Apr-2008  cegger branches: 1.6.38; 1.6.48;
use aprint_*_dev and device_xname
 1.5 19-Oct-2007  ad branches: 1.5.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.4 11-Dec-2005  christos branches: 1.4.30; 1.4.44; 1.4.46; 1.4.50;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 27-Sep-2002  provos branches: 1.2.2; 1.2.4; 1.2.10; 1.2.18; 1.2.20;
remove trailing \n in panic(). approved perry.
 1.1 24-Sep-2002  pooka Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.2.20.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.18.1 29-Apr-2005  kent sync with -current
 1.2.10.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.4.1 27-Sep-2002  nathanw file iwic_dchan.c was added on branch nathanw_sa on 2002-10-18 02:43:10 +0000
 1.2.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.1 27-Sep-2002  jdolecek file iwic_dchan.c was added on branch kqueue on 2002-10-10 18:40:53 +0000
 1.3.4.1 27-Oct-2007  yamt sync with head.
 1.4.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.4.46.1 06-Nov-2007  matt sync with HEAD
 1.4.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.4.30.1 23-Oct-2007  ad Sync with head.
 1.5.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.48.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.48.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.6.38.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.38.1 30-Oct-2012  yamt sync with head
 1.7.2.1 18-May-2014  rmind sync with head
 1.9.30.1 10-Jun-2019  christos Sync with HEAD
 1.9.28.2 30-Sep-2018  pgoyette Ssync with HEAD
 1.9.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.5 22-Sep-2018  maxv Remove iwic(4). It is part of ISDN, which we are now retiring. This driver
was still marked as experimental (its man page dates back to 2002).
 1.4 19-Oct-2007  ad branches: 1.4.106; 1.4.108;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.3 11-Dec-2005  christos branches: 1.3.30; 1.3.44; 1.3.46; 1.3.50;
merge ktrace-lwp.
 1.2 09-Jul-2005  christos make the isdn drivers compile again with -Wconst, -Wshadow
 1.1 24-Sep-2002  pooka branches: 1.1.2; 1.1.4; 1.1.10; 1.1.26;
Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.1.26.2 27-Oct-2007  yamt sync with head.
 1.1.26.1 21-Jun-2006  yamt sync with head.
 1.1.10.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.1 24-Sep-2002  nathanw file iwic_fsm.c was added on branch nathanw_sa on 2002-10-18 02:43:10 +0000
 1.1.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.1 24-Sep-2002  jdolecek file iwic_fsm.c was added on branch kqueue on 2002-10-10 18:40:53 +0000
 1.3.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.46.1 06-Nov-2007  matt sync with HEAD
 1.3.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.30.1 23-Oct-2007  ad Sync with head.
 1.4.108.1 10-Jun-2019  christos Sync with HEAD
 1.4.106.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.21 22-Sep-2018  maxv Remove iwic(4). It is part of ISDN, which we are now retiring. This driver
was still marked as experimental (its man page dates back to 2002).
 1.20 14-Jul-2016  msaitoh branches: 1.20.16; 1.20.18;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.19 29-Mar-2014  christos branches: 1.19.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.18 27-Oct-2012  chs branches: 1.18.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.17 22-May-2011  mrg branches: 1.17.4; 1.17.14;
add some fujitsu ethernet id's and a new vendor id. partly from
Michael Moll <kvedulv@kvedulv.de>, taken from openbsd.

XXX: move the #if 0'd usage of PCI_VENDOR_CITICORP inside the #if 0 code
XXX: region, as this id conflits with the (4th) fijutsi id.
 1.16 26-Nov-2009  njoly branches: 1.16.4; 1.16.6;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.15 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.14 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.13 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.12 10-Apr-2008  cegger branches: 1.12.4; 1.12.18;
use aprint_*_dev and device_xname
 1.11 19-Oct-2007  ad branches: 1.11.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.10 16-Nov-2006  christos branches: 1.10.8; 1.10.22; 1.10.24; 1.10.28;
__unused removal on arguments; approved by core.
 1.9 16-Oct-2006  pooka * __unused games + other relevant fixes
* give me ANSI C or give me death (at least where it could be easily spotted)
 1.8 11-Dec-2005  christos branches: 1.8.20; 1.8.22;
merge ktrace-lwp.
 1.7 03-Oct-2003  pooka branches: 1.7.16;
Ready the kernel side of i4b for primary rate interface support by
removing assumptions that there are only two B channels and by
adding support for a varying number of channels.

Due to this, rename previously used isdn identified "bri" to "isdnif",
which better describes the current situation.
 1.6 08-May-2003  martin branches: 1.6.2;
We are getting passed an integer value via a void* arg (in an ioctl() like
function) - cast it to an intptr_t.
Addresses parts of PR kern/21448 by Frank Kardel.
 1.5 23-Oct-2002  pooka avoid namespace collision with IMASK
 1.4 02-Oct-2002  thorpej branches: 1.4.2; 1.4.4;
Add trailing ; to CFATTACH_DECL.
 1.3 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 24-Sep-2002  pooka Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.4.4.3 11-Nov-2002  nathanw Catch up to -current
 1.4.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.4.4.1 02-Oct-2002  nathanw file iwic_pci.c was added on branch nathanw_sa on 2002-10-18 02:43:10 +0000
 1.4.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.2.1 02-Oct-2002  jdolecek file iwic_pci.c was added on branch kqueue on 2002-10-10 18:40:54 +0000
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.16.2 27-Oct-2007  yamt sync with head.
 1.7.16.1 30-Dec-2006  yamt sync with head.
 1.8.22.2 10-Dec-2006  yamt sync with head.
 1.8.22.1 22-Oct-2006  yamt sync with head
 1.8.20.1 18-Nov-2006  ad Sync with head.
 1.10.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.24.1 06-Nov-2007  matt sync with HEAD
 1.10.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.10.8.1 23-Oct-2007  ad Sync with head.
 1.11.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.4.2 11-Mar-2010  yamt sync with head
 1.12.4.1 16-May-2009  yamt sync with head
 1.16.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.4.1 31-May-2011  rmind sync with head
 1.17.14.3 03-Dec-2017  jdolecek update from HEAD
 1.17.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.4.1 30-Oct-2012  yamt sync with head
 1.18.2.1 18-May-2014  rmind sync with head
 1.19.6.1 05-Oct-2016  skrll Sync with HEAD
 1.20.18.1 10-Jun-2019  christos Sync with HEAD
 1.20.16.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.3 22-Sep-2018  maxv Remove iwic(4). It is part of ISDN, which we are now retiring. This driver
was still marked as experimental (its man page dates back to 2002).
 1.2 23-Oct-2002  pooka branches: 1.2.194; 1.2.196;
avoid namespace collision with IMASK
 1.1 24-Sep-2002  pooka branches: 1.1.2; 1.1.4;
Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.1.4.3 11-Nov-2002  nathanw Catch up to -current
 1.1.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.1 24-Sep-2002  nathanw file iwicreg.h was added on branch nathanw_sa on 2002-10-18 02:43:10 +0000
 1.1.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.1 24-Sep-2002  jdolecek file iwicreg.h was added on branch kqueue on 2002-10-10 18:40:54 +0000
 1.2.196.1 10-Jun-2019  christos Sync with HEAD
 1.2.194.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.7 22-Sep-2018  maxv Remove iwic(4). It is part of ISDN, which we are now retiring. This driver
was still marked as experimental (its man page dates back to 2002).
 1.6 27-Oct-2012  chs branches: 1.6.36; 1.6.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.5 19-Oct-2007  ad branches: 1.5.54; 1.5.64;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.4 11-Dec-2005  christos branches: 1.4.30; 1.4.44; 1.4.46; 1.4.50;
merge ktrace-lwp.
 1.3 09-Jul-2005  christos make the isdn drivers compile again with -Wconst, -Wshadow
 1.2 08-Jul-2003  itojun branches: 1.2.16;
function prototype must not have variable name
 1.1 24-Sep-2002  pooka branches: 1.1.2; 1.1.4; 1.1.10;
Driver for Winbond W6692 passive ISDN cards.

Ported from the FreeBSD driver by Ilpo Ruotsalainen <lonewolf@cubical.fi>,
and reviewed by Martin.
 1.1.10.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.10.1 03-Aug-2004  skrll Sync with HEAD
 1.1.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.1 24-Sep-2002  nathanw file iwicvar.h was added on branch nathanw_sa on 2002-10-18 02:43:10 +0000
 1.1.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.1 24-Sep-2002  jdolecek file iwicvar.h was added on branch kqueue on 2002-10-10 18:40:54 +0000
 1.2.16.2 27-Oct-2007  yamt sync with head.
 1.2.16.1 21-Jun-2006  yamt sync with head.
 1.4.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.4.46.1 06-Nov-2007  matt sync with HEAD
 1.4.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.4.30.1 23-Oct-2007  ad Sync with head.
 1.5.64.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.54.1 30-Oct-2012  yamt sync with head
 1.6.38.1 10-Jun-2019  christos Sync with HEAD
 1.6.36.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.25 14-Jul-2016  msaitoh KNF. No functional change.
 1.24 31-Jul-2012  bouyer branches: 1.24.2; 1.24.16;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.23 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.22 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.21 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.20 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.19 04-Apr-2011  dyoung branches: 1.19.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.18 13-Feb-2011  jakllsch Turn on detachment for ixpide(4).
 1.17 05-Nov-2010  jakllsch branches: 1.17.2; 1.17.4;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.16 24-Feb-2010  dyoung branches: 1.16.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.15 08-Jan-2010  dyoung branches: 1.15.2;
Expand PMF_FN_* macros.
 1.14 04-Nov-2008  reinoud Implement powersave for ixpide(4). Tested it on an Asus IXP250 with IGP.

It seems to sleep and awake fine now without errors or warnings.
 1.13 06-Sep-2008  rmind branches: 1.13.2; 1.13.4;
PR/39442: Jeff Thieleke: Support for ATI SB700/SB800 controllers.
 1.12 29-Apr-2008  martin branches: 1.12.2; 1.12.6;
Convert to new 2 clause license
 1.11 18-Mar-2008  cube branches: 1.11.2; 1.11.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.10 10-Sep-2007  cube branches: 1.10.16; 1.10.20;
Remove 3rd clause and my name from all the licences which were only in my
name.
 1.9 09-Feb-2007  ad branches: 1.9.6; 1.9.18; 1.9.20;
Merge newlock2 to head.
 1.8 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.7 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.6 30-Jun-2006  xtraeme branches: 1.6.4; 1.6.6;
Match ATI IXP SB600 IDE/SATA.
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.8; 1.5.16;
merge ktrace-lwp.
 1.4 04-Jul-2005  augustss branches: 1.4.2;
The SB400 SATA controllers seem to work fine for me with this driver.
 1.3 07-Mar-2005  christos PR/29614: Andrzej Kukula: Missing PCI IDs of ATI IXP 300 and 400 ATA controller
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 06-Dec-2004  cube branches: 1.1.4; 1.1.6; 1.1.8;
Add ixpide(4), a driver for the IDE controller found in the ATI IXP series
of integrated chipsets.

Documented from the Linux driver. Tested by reinoud@, ok'd by bouyer@.
 1.1.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 29-Apr-2005  kent sync with -current
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 08-Mar-2005  skrll Sync with HEAD.
 1.1.4.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.2 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.1 06-Dec-2004  skrll file ixpide.c was added on branch ktrace-lwp on 2004-12-18 09:32:08 +0000
 1.4.2.4 24-Mar-2008  yamt sync with head.
 1.4.2.3 27-Oct-2007  yamt sync with head.
 1.4.2.2 26-Feb-2007  yamt sync with head.
 1.4.2.1 30-Dec-2006  yamt sync with head.
 1.5.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.8.1 11-Aug-2006  yamt sync with head
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.6.2 10-Dec-2006  yamt sync with head.
 1.6.6.1 22-Oct-2006  yamt sync with head
 1.6.4.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.6.4.1 18-Nov-2006  ad Sync with head.
 1.9.20.2 23-Mar-2008  matt sync with HEAD
 1.9.20.1 06-Nov-2007  matt sync with HEAD
 1.9.18.1 02-Oct-2007  joerg Sync with HEAD.
 1.9.6.1 09-Oct-2007  ad Sync with head.
 1.10.20.4 17-Jan-2009  mjf Sync with HEAD.
 1.10.20.3 28-Sep-2008  mjf Sync with HEAD.
 1.10.20.2 02-Jun-2008  mjf Sync with HEAD.
 1.10.20.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.16.1 24-Mar-2008  keiichi sync with head.
 1.11.4.3 11-Mar-2010  yamt sync with head
 1.11.4.2 04-May-2009  yamt sync with head.
 1.11.4.1 16-May-2008  yamt sync with head.
 1.11.2.1 18-May-2008  yamt sync with head.
 1.12.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.12.6.1 19-Oct-2008  haad Sync with HEAD.
 1.12.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.4.1 12-Nov-2008  snj Pull up following revision(s) (requested by reinoud in ticket #42):
sys/dev/pci/ixpide.c: revision 1.14
Implement powersave for ixpide(4). Tested it on an Asus IXP250 with IGP.
It seems to sleep and awake fine now without errors or warnings.
 1.13.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.15.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.2 21-Apr-2011  rmind sync with head
 1.16.2.1 05-Mar-2011  rmind sync with head
 1.17.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.4.1 30-Oct-2012  yamt sync with head
 1.24.16.1 05-Oct-2016  skrll Sync with HEAD
 1.24.2.2 03-Dec-2017  jdolecek update from HEAD
 1.24.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.25 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.24 24-Apr-2021  thorpej branches: 1.24.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.23 10-Nov-2019  chs branches: 1.23.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.22 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.21 14-Jul-2016  msaitoh branches: 1.21.16; 1.21.18;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.20 14-Jul-2016  msaitoh KNF. No functional change.
 1.19 29-Mar-2014  christos branches: 1.19.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.18 31-Jul-2012  bouyer branches: 1.18.2; 1.18.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.17 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.16 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.15 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.14 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.13 29-Mar-2012  pgoyette Add match for JMB362 (with two SATA ports).
 1.12 30-Jan-2012  drochner branches: 1.12.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.11 13-Aug-2011  jakllsch branches: 1.11.2; 1.11.6;
Make correct spelling in comments a higher priority.
 1.10 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.9 05-Nov-2010  jakllsch branches: 1.9.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.8 27-Jul-2010  jakllsch Support detachment of ahcisata(4).
Use use 64-bit DMA tag (where available) for ahcisata(4) at jmide(4).
Beginnings of detach/resume support for jmide(4).
Sprinkle static. Misc. little changes.
 1.7 19-Oct-2009  bouyer branches: 1.7.2; 1.7.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.6 05-Jun-2008  bouyer Call ahci_intr() with the device's softc, not the device_t.
Should fix kern/38742
 1.5 21-Mar-2008  xtraeme branches: 1.5.2; 1.5.4; 1.5.6;
Don't forget to set the atac dev pointer in the softc; ahcisata at jmide
works again after that.

Also use CFATTACH_DECL_NEW, device_t and related changes for the NJMAHCI
block.
 1.4 18-Mar-2008  cube Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.3 11-Feb-2008  xtraeme branches: 1.3.2; 1.3.6;
Attach ahcisata(4) to any RAID controller that supports AHCI, and make it
pass the ATAC_CAP_RAID capability for them. ok'ed by bouyer@.
 1.2 31-May-2007  bouyer branches: 1.2.2; 1.2.4; 1.2.12; 1.2.14; 1.2.16; 1.2.18; 1.2.24;
Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.
 1.1 15-May-2007  bouyer branches: 1.1.2;
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).

Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.
 1.1.2.2 17-May-2007  yamt sync with head.
 1.1.2.1 15-May-2007  yamt file jmide.c was added on branch yamt-idlelwp on 2007-05-17 13:41:31 +0000
 1.2.24.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.18.4 24-Mar-2008  yamt sync with head.
 1.2.18.3 11-Feb-2008  yamt sync with head.
 1.2.18.2 03-Sep-2007  yamt sync with head.
 1.2.18.1 31-May-2007  yamt file jmide.c was added on branch yamt-lazymbuf on 2007-09-03 14:37:10 +0000
 1.2.16.2 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.2.16.1 31-May-2007  wrstuden file jmide.c was added on branch wrstuden-fixsa on 2007-09-03 07:04:35 +0000
 1.2.14.2 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.2.14.1 31-May-2007  pavel file jmide.c was added on branch netbsd-4 on 2007-08-31 20:09:25 +0000
 1.2.12.1 23-Mar-2008  matt sync with HEAD
 1.2.4.2 11-Jul-2007  mjf Sync with head.
 1.2.4.1 31-May-2007  mjf file jmide.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:51 +0000
 1.2.2.3 09-Jun-2007  ad Sync with head.
 1.2.2.2 09-Jun-2007  ad Sync with head.
 1.2.2.1 31-May-2007  ad file jmide.c was added on branch vmlocking on 2007-06-09 21:37:24 +0000
 1.3.6.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.3.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.2.1 24-Mar-2008  keiichi sync with head.
 1.5.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.4.3 11-Aug-2010  yamt sync with head.
 1.5.4.2 11-Mar-2010  yamt sync with head
 1.5.4.1 04-May-2009  yamt sync with head.
 1.5.2.1 17-Jun-2008  yamt sync with head.
 1.7.4.2 21-Apr-2011  rmind sync with head
 1.7.4.1 05-Mar-2011  rmind sync with head
 1.7.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.7.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.6.2 05-Apr-2012  mrg sync to latest -current.
 1.11.6.1 18-Feb-2012  mrg merge to -current.
 1.11.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.2.2 30-Oct-2012  yamt sync with head
 1.11.2.1 17-Apr-2012  yamt sync with head
 1.12.2.1 03-Apr-2012  riz Pull up following revision(s) (requested by pgoyette in ticket #149):
sys/dev/pci/pcidevs: revision 1.1108
sys/dev/pci/jmide.c: revision 1.13
Add JMB 362 (as found on ASUS M5A99X motherboard)
Add match for JMB362 (with two SATA ports).
 1.18.4.1 18-May-2014  rmind sync with head
 1.18.2.3 03-Dec-2017  jdolecek update from HEAD
 1.18.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.19.6.1 05-Oct-2016  skrll Sync with HEAD
 1.21.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.21.18.1 10-Jun-2019  christos Sync with HEAD
 1.21.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.23.10.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.24.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 24-Oct-2011  njoly Remove unused local defines for PCI_COMMAND_STATUS_REG bits (already
available from pcireg.h).
 1.3 24-Jul-2010  jakllsch correct transposition in comment
 1.2 19-Oct-2009  bouyer branches: 1.2.2; 1.2.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.1 15-May-2007  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.16; 1.1.18; 1.1.20; 1.1.44;
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).

Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.
 1.1.44.2 11-Aug-2010  yamt sync with head.
 1.1.44.1 11-Mar-2010  yamt sync with head
 1.1.20.2 03-Sep-2007  yamt sync with head.
 1.1.20.1 15-May-2007  yamt file jmide_reg.h was added on branch yamt-lazymbuf on 2007-09-03 14:37:10 +0000
 1.1.18.2 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.18.1 15-May-2007  wrstuden file jmide_reg.h was added on branch wrstuden-fixsa on 2007-09-03 07:04:36 +0000
 1.1.16.2 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.1.16.1 15-May-2007  pavel file jmide_reg.h was added on branch netbsd-4 on 2007-08-31 20:09:25 +0000
 1.1.6.2 11-Jul-2007  mjf Sync with head.
 1.1.6.1 15-May-2007  mjf file jmide_reg.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:52 +0000
 1.1.4.2 09-Jun-2007  ad Sync with head.
 1.1.4.1 15-May-2007  ad file jmide_reg.h was added on branch vmlocking on 2007-06-09 21:37:24 +0000
 1.1.2.2 17-May-2007  yamt sync with head.
 1.1.2.1 15-May-2007  yamt file jmide_reg.h was added on branch yamt-idlelwp on 2007-05-17 13:41:32 +0000
 1.2.4.1 05-Mar-2011  rmind sync with head
 1.2.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.17 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.16 26-Apr-2021  thorpej branches: 1.16.6;
Be explicit about the "eap" interface attribute when attaching a "joy"
instance.
 1.15 24-Apr-2021  thorpej branches: 1.15.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.14 08-May-2019  isaki branches: 1.14.12;
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.13 23-Nov-2011  jmcneill branches: 1.13.50; 1.13.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.12 07-May-2009  cegger branches: 1.12.12; 1.12.14;
use device_private()
 1.11 06-May-2009  cegger use device_private()
 1.10 10-Apr-2008  cegger branches: 1.10.4; 1.10.16; 1.10.18;
use aprint_*_dev and device_xname
 1.9 26-Mar-2008  xtraeme Split device_t/softc for joy(4) and all its attachments. Also
use device_lookup_private() and related cosmetic changes.

Reviewed by cube@.
 1.8 11-Dec-2007  lukem branches: 1.8.8;
use __KERNEL_RCSID()
 1.7 19-Oct-2007  ad branches: 1.7.4; 1.7.6; 1.7.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 16-Nov-2006  christos branches: 1.6.8; 1.6.22; 1.6.24; 1.6.28;
__unused removal on arguments; approved by core.
 1.5 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.4 11-Dec-2005  christos branches: 1.4.20; 1.4.22;
merge ktrace-lwp.
 1.3 28-Jun-2005  thorpej branches: 1.3.2;
Use ANSI function decls and static.
 1.2 03-Aug-2004  drochner use joydetach() now that we have it
 1.1 08-Jul-2004  drochner branches: 1.1.2;
support the game port on eap1371
This is only usable with some caution because these soundcards only
allow to map IO port 0x20x for this, thus bypassing PCI address
management. Very likely this will only work on primary PCI buses, and there
is some potential for conflicts with ISA devices as well.
(XXX cannot be detached because the "joy" driver doesn't support it yet)
 1.1.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 08-Jul-2004  skrll file joy_eap.c was added on branch ktrace-lwp on 2004-08-03 10:49:09 +0000
 1.3.2.3 21-Jan-2008  yamt sync with head
 1.3.2.2 27-Oct-2007  yamt sync with head.
 1.3.2.1 30-Dec-2006  yamt sync with head.
 1.4.22.2 10-Dec-2006  yamt sync with head.
 1.4.22.1 22-Oct-2006  yamt sync with head
 1.4.20.1 18-Nov-2006  ad Sync with head.
 1.6.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.24.2 09-Jan-2008  matt sync with HEAD
 1.6.24.1 06-Nov-2007  matt sync with HEAD
 1.6.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.8.1 23-Oct-2007  ad Sync with head.
 1.7.8.2 02-Jan-2008  bouyer Sync with HEAD
 1.7.8.1 13-Dec-2007  bouyer Sync with HEAD
 1.7.6.1 11-Dec-2007  yamt sync with head.
 1.7.4.1 26-Dec-2007  ad Sync with head.
 1.8.8.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.8.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.16.1 12-Dec-2008  ad Checkpoint work in progress.
 1.10.4.1 16-May-2009  yamt sync with head
 1.12.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.12.12.1 17-Apr-2012  yamt sync with head
 1.13.54.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.13.50.1 10-Jun-2019  christos Sync with HEAD
 1.14.12.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.15.2.1 13-May-2021  thorpej Sync with HEAD.
 1.16.6.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.17 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.16 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.15 23-Nov-2011  jmcneill branches: 1.15.50; 1.15.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.14 28-Apr-2008  martin branches: 1.14.12; 1.14.34; 1.14.36;
Remove clause 3 and 4 from TNF licenses
 1.13 26-Mar-2008  xtraeme branches: 1.13.2; 1.13.4;
Split device_t/softc for joy(4) and all its attachments. Also
use device_lookup_private() and related cosmetic changes.

Reviewed by cube@.
 1.12 19-Oct-2007  ad branches: 1.12.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 16-Nov-2006  christos branches: 1.11.8; 1.11.22; 1.11.24; 1.11.28;
__unused removal on arguments; approved by core.
 1.10 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9 11-Dec-2005  christos branches: 1.9.20; 1.9.22;
merge ktrace-lwp.
 1.8 28-Jun-2005  thorpej branches: 1.8.2;
Use ANSI function decls and static.
 1.7 04-Feb-2005  perry de-__P
 1.6 04-Dec-2003  keihan branches: 1.6.8; 1.6.10;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.4 02-Oct-2002  thorpej branches: 1.4.6;
Add trailing ; to CFATTACH_DECL.
 1.3 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 25-Apr-2002  kleink branches: 1.1.6; 1.1.8;
Add a joystick attachment to the ESS Solo-1 driver.
 1.1.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.1 25-Apr-2002  jdolecek file joy_eso.c was added on branch kqueue on 2002-06-23 17:47:50 +0000
 1.1.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.6.1 25-Apr-2002  nathanw file joy_eso.c was added on branch nathanw_sa on 2002-06-20 03:45:35 +0000
 1.4.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.6.4 04-Feb-2005  skrll Sync with HEAD.
 1.4.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.6.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 12-Feb-2005  yamt sync with head.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.8.2.2 27-Oct-2007  yamt sync with head.
 1.8.2.1 30-Dec-2006  yamt sync with head.
 1.9.22.2 10-Dec-2006  yamt sync with head.
 1.9.22.1 22-Oct-2006  yamt sync with head
 1.9.20.1 18-Nov-2006  ad Sync with head.
 1.11.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.24.1 06-Nov-2007  matt sync with HEAD
 1.11.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.8.1 23-Oct-2007  ad Sync with head.
 1.12.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.14.34.1 17-Apr-2012  yamt sync with head
 1.14.12.1 12-Dec-2008  ad Checkpoint work in progress.
 1.15.54.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.15.50.1 10-Jun-2019  christos Sync with HEAD
 1.21 07-May-2014  joerg Fix impossible error condition.
 1.20 30-Jan-2012  drochner branches: 1.20.6; 1.20.10; 1.20.20;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.19 05-Dec-2011  christos make joy code consistent (avoid games with pointers), and fix the isa softc
declaration
 1.18 23-Nov-2011  jmcneill branches: 1.18.2;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.17 28-Apr-2008  martin branches: 1.17.12; 1.17.34; 1.17.36;
Remove clause 3 and 4 from TNF licenses
 1.16 26-Mar-2008  xtraeme branches: 1.16.2; 1.16.4;
Split device_t/softc for joy(4) and all its attachments. Also
use device_lookup_private() and related cosmetic changes.

Reviewed by cube@.
 1.15 19-Oct-2007  ad branches: 1.15.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.14 16-Nov-2006  christos branches: 1.14.8; 1.14.22; 1.14.24; 1.14.28;
__unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 11-Dec-2005  christos branches: 1.12.20; 1.12.22;
merge ktrace-lwp.
 1.11 28-Jun-2005  thorpej branches: 1.11.2;
Use ANSI function decls and static.
 1.10 04-Feb-2005  perry de-__P
 1.9 23-Apr-2004  itojun branches: 1.9.4; 1.9.6;
pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.8 03-Apr-2004  martti Added another SB Live! 5.1 soundcard and joystick version
 1.7 04-Dec-2003  keihan branches: 1.7.2;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.6 16-Oct-2002  jdolecek branches: 1.6.6;
match the joystick device on Creative SBLive! card; note this only works
when emuxki(4) driver is compiled into the kernel, it has to enable
the joystick port
 1.5 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 14-Apr-2002  martin Fix copyright notice.
 1.1 02-Feb-2002  jdolecek branches: 1.1.2; 1.1.4;
Reduce the massive code duplication regarding joy(4). Split it into
MI and MD parts, and make ISA/ISAPNP/PCI joy(4) attachments MI.
 1.1.4.5 11-Nov-2002  nathanw Catch up to -current
 1.1.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.3 17-Apr-2002  nathanw Catch up to -current.
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 02-Feb-2002  nathanw file joy_pci.c was added on branch nathanw_sa on 2002-02-28 04:14:03 +0000
 1.1.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 02-Feb-2002  jdolecek file joy_pci.c was added on branch kqueue on 2002-02-11 20:10:01 +0000
 1.6.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.4 04-Feb-2005  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 05-Apr-2004  tron Pull up revision 1.8 (requested by martti in ticket #54):
Added another SB Live! 5.1 soundcard and joystick version
 1.9.6.1 12-Feb-2005  yamt sync with head.
 1.9.4.1 29-Apr-2005  kent sync with -current
 1.11.2.2 27-Oct-2007  yamt sync with head.
 1.11.2.1 30-Dec-2006  yamt sync with head.
 1.12.22.2 10-Dec-2006  yamt sync with head.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.14.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.14.24.1 06-Nov-2007  matt sync with HEAD
 1.14.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.8.1 23-Oct-2007  ad Sync with head.
 1.15.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.15.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.4.1 16-May-2008  yamt sync with head.
 1.16.2.1 18-May-2008  yamt sync with head.
 1.17.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.17.34.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.34.1 17-Apr-2012  yamt sync with head
 1.17.12.1 12-Dec-2008  ad Checkpoint work in progress.
 1.18.2.1 18-Feb-2012  mrg merge to -current.
 1.20.20.1 10-Aug-2014  tls Rebase.
 1.20.10.1 18-May-2014  rmind sync with head
 1.20.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26 13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.25 27-Sep-2016  pgoyette branches: 1.25.54;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.24 16-Sep-2016  jdolecek modify ldattach() to have default strategy as a parameter
 1.23 13-Apr-2015  riastradh branches: 1.23.2;
Convert sys/dev to use <sys/rndsource.h>.
 1.22 02-Mar-2015  christos From Tom Ivar Helbekkmo:

- Use mutexes and condvars instead of spl() calls.
- Add a couple of bugfixes from FreeBSD (the easily observed ones).
- Add a simple watchdog thread for the newer versions of the hardware,
that tickles the controller at task submission time if it seems not ready
(from FreeBSD).
- Add a buffer allocation size hack to the ioctl handler, to work around
a firmware bug in some versions of the controller (also from FreeBSD).
- Rearrange the bus_dmamap_sync() calls to make the use match the
documentation.
 1.21 02-Feb-2012  tls branches: 1.21.6; 1.21.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.20 13-Nov-2010  uebayasi branches: 1.20.8; 1.20.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.19 12-May-2009  cegger branches: 1.19.4;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.18 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.17 09-Sep-2008  tron branches: 1.17.8;
Complete device_t/softc split for the ld(4) attachments. This should
prevent crashes while attaching a drive.

Patch supplied by Juan RP in PR kern/39468.
 1.16 28-Apr-2008  martin branches: 1.16.2; 1.16.6;
Remove clause 3 and 4 from TNF licenses
 1.15 10-Apr-2008  cegger branches: 1.15.2; 1.15.4;
use aprint_*_dev and device_xname
 1.14 19-Oct-2007  ad branches: 1.14.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 29-Jul-2007  ad branches: 1.13.4; 1.13.6; 1.13.10; 1.13.12;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.18;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 23-Jul-2006  bouyer branches: 1.10.4; 1.10.6;
Add a /dev/amr* control file for amr(4) devices, which allows sending raw
commands to the controller.
Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and individual
drives).
From FreeBSD, with some adjustements by Andrew Doran and me.
 1.9 25-Mar-2006  thorpej Use device_parent().
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
merge ktrace-lwp.
 1.7 28-Jun-2005  thorpej branches: 1.7.2;
Use ANSI function decls and static.
 1.6 28-Oct-2004  yamt branches: 1.6.10;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.5 04-May-2003  ad branches: 1.5.2;
- Fix the mailbox protocol. Not tested with newer 'Quartz' controllers.
- Handle failure during initalisation more gracefully.
- Create a watchdog thread to poke the board and check for status changes.
- Make ready for > 64kB transfers.
 1.4 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.3 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 30-Jan-2002  ad branches: 1.1.2; 1.1.4;
Bare-bones driver for AMI RAID. Parts taken from FreeBSD. This was tried a
good while ago and it had problems under load. Changes were made to address
that, but I don't have the ability to test them. So, I'm committing it
before it rots.
 1.1.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 30-Jan-2002  nathanw file ld_amr.c was added on branch nathanw_sa on 2002-02-28 04:14:03 +0000
 1.1.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 30-Jan-2002  jdolecek file ld_amr.c was added on branch kqueue on 2002-02-11 20:10:01 +0000
 1.5.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.1 02-Nov-2004  skrll Sync with HEAD.
 1.6.10.1 30-Jul-2006  tron Apply patch (requested by bouyer in ticket #1431):
- Add a /dev/amr* control file for amr(4) devices, which allows sending
raw commands to the controller.
- Add a amrctl(8) control tool, which for now only allows to get status
from the adapter (status of adapter, logical volumes and and
individual drives).
 1.7.2.4 27-Oct-2007  yamt sync with head.
 1.7.2.3 03-Sep-2007  yamt sync with head.
 1.7.2.2 30-Dec-2006  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.8.10.1 19-Apr-2006  elad sync with head.
 1.8.8.2 11-Aug-2006  yamt sync with head
 1.8.8.1 01-Apr-2006  yamt sync with head.
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.10.6.2 10-Dec-2006  yamt sync with head.
 1.10.6.1 22-Oct-2006  yamt sync with head
 1.10.4.1 18-Nov-2006  ad Sync with head.
 1.12.18.1 15-Aug-2007  skrll Sync with HEAD.
 1.12.8.3 23-Oct-2007  ad Sync with head.
 1.12.8.2 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.12.8.1 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.13.12.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.13.12.1 29-Jul-2007  ad file ld_amr.c was added on branch matt-mips64 on 2007-07-29 12:50:23 +0000
 1.13.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.6.1 06-Nov-2007  matt sync with HEAD
 1.13.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.14.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.4.3 16-May-2009  yamt sync with head
 1.15.4.2 04-May-2009  yamt sync with head.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.6.1 19-Oct-2008  haad Sync with HEAD.
 1.16.2.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.17.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.20.12.1 18-Feb-2012  mrg merge to -current.
 1.20.8.1 17-Apr-2012  yamt sync with head
 1.21.24.3 05-Oct-2016  skrll Sync with HEAD
 1.21.24.2 06-Jun-2015  skrll Sync with HEAD
 1.21.24.1 06-Apr-2015  skrll Sync with HEAD
 1.21.6.1 03-Dec-2017  jdolecek update from HEAD
 1.23.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.25.54.1 02-Aug-2025  perseant Sync with HEAD
 1.21 13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.20 27-Feb-2017  jdolecek branches: 1.20.52;
refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
 1.19 27-Sep-2016  pgoyette branches: 1.19.2;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.18 16-Sep-2016  jdolecek modify ldattach() to have default strategy as a parameter
 1.17 13-Apr-2015  riastradh branches: 1.17.2;
Convert sys/dev to use <sys/rndsource.h>.
 1.16 17-Oct-2013  christos branches: 1.16.6;
- remove unused variables
- move debugging code inside debugging sections
 1.15 02-Feb-2012  tls branches: 1.15.6; 1.15.10;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.14 13-Nov-2010  uebayasi branches: 1.14.8; 1.14.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.13 09-Sep-2008  tron branches: 1.13.16;
Complete device_t/softc split for the ld(4) attachments. This should
prevent crashes while attaching a drive.

Patch supplied by Juan RP in PR kern/39468.
 1.12 11-Aug-2008  simonb Add a flags argument to the ld(4) flush handlers, and call these with a
"poll" flag when called from ld_shutdown().

This is the infrastructure part of kern/38655 - in itself it doesn't
fix the panic referenced in that PR.

XXX: At least ld_twa.c and perhaps ld_iop.c and ld_icp.c need to
check for this new poll flag and do something useful.
 1.11 07-May-2008  joerg branches: 1.11.2; 1.11.4; 1.11.6;
First part of twa(4) improvements:
- more/better diagnostic messages
- dynamically allocate units in preparation for 9650+ support
- better distribute queue slots over disks according to size
- drain large request queue on 9550
- keep track of resets, will be needed for 9650.

This changes have been contributed by Wasabi Systems.
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 19-Oct-2007  ad branches: 1.9.16; 1.9.18; 1.9.20;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.8 07-Aug-2007  simonb branches: 1.8.2; 1.8.6;
Unwrap not-too-long line.
 1.7 29-Jul-2007  ad branches: 1.7.4; 1.7.6;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.6 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.5 08-Feb-2007  ad branches: 1.5.6; 1.5.14;
Add a quick hack to allow addressing over 2G sectors. XXX This driver
needs to be rewritten to use the scsipi layer. Additionally:

- Missing copyright years: 2000, 2001, 2002, 2003
- Missing attribution: Andrew Doran and Jason R. Thorpe
 1.4 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.3 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.2 25-May-2006  wrstuden branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10; 1.2.12; 1.2.16; 1.2.18; 1.2.20;
Add $NetBSD: ids, which work better than $netbsd: ones.
 1.1 24-May-2006  wrstuden 3ware 9000 driver, contributed by Wasabi Systems and written
by Jordan Rhody (based on the FreeBSD driver).

Contributed in NetBSD PR 33364.
 1.2.20.2 10-Dec-2006  yamt sync with head.
 1.2.20.1 22-Oct-2006  yamt sync with head
 1.2.18.2 09-Sep-2006  rpaulo sync with head
 1.2.18.1 25-May-2006  rpaulo file ld_twa.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:18 +0000
 1.2.16.2 09-Feb-2007  ad Sync with HEAD.
 1.2.16.1 18-Nov-2006  ad Sync with head.
 1.2.12.2 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.2.12.1 25-May-2006  tron file ld_twa.c was added on branch netbsd-3 on 2006-07-31 12:35:22 +0000
 1.2.10.2 26-Jun-2006  yamt sync with head.
 1.2.10.1 25-May-2006  yamt file ld_twa.c was added on branch yamt-pdpolicy on 2006-06-26 12:51:22 +0000
 1.2.8.6 27-Oct-2007  yamt sync with head.
 1.2.8.5 03-Sep-2007  yamt sync with head.
 1.2.8.4 26-Feb-2007  yamt sync with head.
 1.2.8.3 30-Dec-2006  yamt sync with head.
 1.2.8.2 21-Jun-2006  yamt sync with head.
 1.2.8.1 25-May-2006  yamt file ld_twa.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:05 +0000
 1.2.6.2 19-Jun-2006  chap Sync with head.
 1.2.6.1 25-May-2006  chap file ld_twa.c was added on branch chap-midi on 2006-06-19 04:01:36 +0000
 1.2.2.2 01-Jun-2006  kardel Sync with head.
 1.2.2.1 25-May-2006  kardel file ld_twa.c was added on branch simonb-timecounters on 2006-06-01 22:36:46 +0000
 1.5.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.5.6.5 23-Oct-2007  ad Sync with head.
 1.5.6.4 09-Oct-2007  ad Sync with head.
 1.5.6.3 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.5.6.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.5.6.1 05-Apr-2007  ad Compile fixes.
 1.7.6.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.7.6.1 29-Jul-2007  ad file ld_twa.c was added on branch matt-mips64 on 2007-07-29 12:50:23 +0000
 1.7.4.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.4.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.8.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.8.2.1 06-Nov-2007  matt sync with HEAD
 1.9.20.2 04-May-2009  yamt sync with head.
 1.9.20.1 16-May-2008  yamt sync with head.
 1.9.18.1 18-May-2008  yamt sync with head.
 1.9.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.9.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.6.1 19-Oct-2008  haad Sync with HEAD.
 1.11.4.2 11-Jun-2008  simonb Revert my suggested fix for kern/38655 - that shouldn't have snuck in
to this branch.
 1.11.4.1 10-Jun-2008  simonb Initial commit of Wasabi System's WAPBL (Write Ahead Physical Block
Logging) journaling code. Originally written by Darrin B. Jewell
while at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

Still a number of issues - look in doc/BRANCHES for "simonb-wapbl"
for more info.
 1.11.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.11.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.16.1 05-Mar-2011  rmind sync with head
 1.14.12.1 18-Feb-2012  mrg merge to -current.
 1.14.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.8.1 17-Apr-2012  yamt sync with head
 1.15.10.1 18-May-2014  rmind sync with head
 1.15.6.2 03-Dec-2017  jdolecek update from HEAD
 1.15.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.6.3 28-Aug-2017  skrll Sync with HEAD
 1.16.6.2 05-Oct-2016  skrll Sync with HEAD
 1.16.6.1 06-Jun-2015  skrll Sync with HEAD
 1.17.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.17.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.19.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.20.52.1 02-Aug-2025  perseant Sync with HEAD
 1.41 13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.40 27-Feb-2017  jdolecek branches: 1.40.52;
refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
 1.39 27-Sep-2016  pgoyette branches: 1.39.2;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.38 16-Sep-2016  jdolecek modify ldattach() to have default strategy as a parameter
 1.37 13-Apr-2015  riastradh branches: 1.37.2;
Convert sys/dev to use <sys/rndsource.h>.
 1.36 02-Feb-2012  tls branches: 1.36.6; 1.36.24;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.35 13-Nov-2010  uebayasi branches: 1.35.8; 1.35.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.34 12-May-2009  cegger branches: 1.34.4;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.33 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.32 09-Sep-2008  tron branches: 1.32.8;
Complete device_t/softc split for the ld(4) attachments. This should
prevent crashes while attaching a drive.

Patch supplied by Juan RP in PR kern/39468.
 1.31 11-Aug-2008  simonb Add polling support to ld_twe_flush().

Fixes the "cpu_switcho: switching above IPL_SCHED" panic for ld@twe
disks on shutdown in kern/38655.
 1.30 28-Apr-2008  martin branches: 1.30.2; 1.30.4; 1.30.6;
Remove clause 3 and 4 from TNF licenses
 1.29 19-Oct-2007  ad branches: 1.29.16; 1.29.18; 1.29.20;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.28 29-Jul-2007  ad branches: 1.28.4; 1.28.6; 1.28.10; 1.28.12;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.27 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.26 16-Nov-2006  christos branches: 1.26.8; 1.26.18;
__unused removal on arguments; approved by core.
 1.25 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.24 25-Mar-2006  thorpej branches: 1.24.8; 1.24.10;
Use device_parent().
 1.23 11-Dec-2005  christos branches: 1.23.4; 1.23.6; 1.23.8; 1.23.10; 1.23.12;
merge ktrace-lwp.
 1.22 08-Feb-2005  briggs branches: 1.22.6;
Use aprint_*() instead of printf() at attach time.
 1.21 28-Oct-2004  yamt branches: 1.21.4; 1.21.6;
move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.20 27-May-2004  thorpej Add a "flush" operation so the array's write cache is flushed on
close and at shutdown.
 1.19 22-Apr-2004  itojun sprintf -> snprintf
 1.18 26-Sep-2003  thorpej branches: 1.18.2;
Confirmed; don't need to query stripe size on TwinStor.
 1.17 23-Sep-2003  thorpej - Make CCB allocation slightly more efficient by changing how the
CCB is returned to the caller.
- Make code paths that can use twe_ccb_alloc_wait() use it, and assert
that a CCB is always returned from that function.
- Assert that a CCB is always returned when allocating the reserved CCB
for an AEN fetch.
 1.16 22-Sep-2003  thorpej Add support for dynamically attaching and detaching RAID array units.
 1.15 21-Sep-2003  thorpej Report the status of the logical drive (normal, degraded, etc.) at
attach time.
 1.14 21-Sep-2003  thorpej - Record more information about the array unit, including array
type and stripe depth.
- Report array type and stripe depth when attaching the logical drive.
 1.13 02-Oct-2002  thorpej branches: 1.13.6;
Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 24-May-2002  christos NBPG is not constant on the sparc, so don't use CPP tricks.
 1.9 18-May-2002  ad branches: 1.9.2;
- Use write barriers.
- NBPG -> PAGE_SIZE.
 1.8 13-Nov-2001  lukem branches: 1.8.8;
add RCSID
 1.7 10-Jun-2001  ad branches: 1.7.2; 1.7.8;
Centralise the geometry fudge.
 1.6 26-Jan-2001  ad branches: 1.6.2;
No need to submit before poll any more.
 1.5 22-Jan-2001  ad Nuke useless argument to ld_twe_dobio().
 1.4 22-Jan-2001  ad Minor optimisation.
 1.3 22-Jan-2001  ad opt_twe.h isn't needed any more.
 1.2 22-Jan-2001  ad Don't artificially clamp the maximum number of outstanding commands.
 1.1 26-Nov-2000  ad branches: 1.1.2;
lsu -> ld, by popular request.
 1.1.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.1.2.1 26-Nov-2000  bouyer file ld_twe.c was added on branch thorpej_scsipi on 2000-12-08 09:12:32 +0000
 1.6.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.6.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.6.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.8.2 25-Oct-2001  he Pull up revisions 1.1-1.7 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.7.8.1 10-Jun-2001  he file ld_twe.c was added on branch netbsd-1-5 on 2001-10-25 17:54:07 +0000
 1.7.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.8.1 30-May-2002  gehenna Catch up with -current.
 1.9.2.1 26-May-2002  perry partially resolve 1.6 pullup ticket #29 from grant
pulls up revision 1.10
Original commit message (by christos):

> NBPG is not constant on the sparc, so don't use CPP tricks.
 1.13.6.5 09-Feb-2005  skrll Sync with HEAD.
 1.13.6.4 02-Nov-2004  skrll Sync with HEAD.
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.18.2.1 30-May-2004  tron Pull up revision 1.20 (requested by thorpej in ticket #411):
Add a "flush" operation so the array's write cache is flushed on
close and at shutdown.
 1.21.6.1 12-Feb-2005  yamt sync with head.
 1.21.4.1 29-Apr-2005  kent sync with -current
 1.22.6.4 27-Oct-2007  yamt sync with head.
 1.22.6.3 03-Sep-2007  yamt sync with head.
 1.22.6.2 30-Dec-2006  yamt sync with head.
 1.22.6.1 21-Jun-2006  yamt sync with head.
 1.23.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.23.10.1 19-Apr-2006  elad sync with head.
 1.23.8.1 01-Apr-2006  yamt sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.24.10.2 10-Dec-2006  yamt sync with head.
 1.24.10.1 22-Oct-2006  yamt sync with head
 1.24.8.1 18-Nov-2006  ad Sync with head.
 1.26.18.1 15-Aug-2007  skrll Sync with HEAD.
 1.26.8.4 23-Oct-2007  ad Sync with head.
 1.26.8.3 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.26.8.2 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.26.8.1 05-Apr-2007  ad Compile fixes.
 1.28.12.2 29-Jul-2007  ad It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.28.12.1 29-Jul-2007  ad file ld_twe.c was added on branch matt-mips64 on 2007-07-29 12:50:23 +0000
 1.28.10.1 25-Oct-2007  bouyer Sync with HEAD.
 1.28.6.1 06-Nov-2007  matt sync with HEAD
 1.28.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.29.20.3 16-May-2009  yamt sync with head
 1.29.20.2 04-May-2009  yamt sync with head.
 1.29.20.1 16-May-2008  yamt sync with head.
 1.29.18.1 18-May-2008  yamt sync with head.
 1.29.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.29.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.30.6.1 19-Oct-2008  haad Sync with HEAD.
 1.30.4.2 11-Jun-2008  simonb Revert my suggested fix for kern/38655 - that shouldn't have snuck in
to this branch.
 1.30.4.1 10-Jun-2008  simonb Initial commit of Wasabi System's WAPBL (Write Ahead Physical Block
Logging) journaling code. Originally written by Darrin B. Jewell
while at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

Still a number of issues - look in doc/BRANCHES for "simonb-wapbl"
for more info.
 1.30.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.30.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.4.1 05-Mar-2011  rmind sync with head
 1.35.12.1 18-Feb-2012  mrg merge to -current.
 1.35.8.1 17-Apr-2012  yamt sync with head
 1.36.24.3 28-Aug-2017  skrll Sync with HEAD
 1.36.24.2 05-Oct-2016  skrll Sync with HEAD
 1.36.24.1 06-Jun-2015  skrll Sync with HEAD
 1.36.6.1 03-Dec-2017  jdolecek update from HEAD
 1.37.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.37.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.39.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.40.52.1 02-Aug-2025  perseant Sync with HEAD
 1.46 21-Oct-2025  pgoyette When building the module we actually need the ioconf.c
 1.45 27-Aug-2025  isaki Fix string length in T_GET_ID response.
 1.44 05-Jul-2025  mlelstv Ignore empty id_data and keep default string.
 1.43 13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.42 27-Feb-2025  jakllsch Implement VIRTIO_BLK_F_TOPOLOGY support for physical sector size information
 1.41 23-Feb-2025  mlelstv Need to allocate DMA buffer.
 1.40 22-Feb-2025  mlelstv For fetching id data:
- actually enter synchronous mode.
- add and use polling support, which is necessary during attach.
- exit synchronous mode on errors.
 1.39 22-Feb-2025  mlelstv Query device for id string.
 1.38 22-Feb-2025  mlelstv Remove module attachment hack, use more of standard boilerplate for
modules.
 1.37 20-Feb-2025  jakllsch Remove trailing whitespace
 1.36 06-Feb-2025  jakllsch Add discard support to ld@virtio.
 1.35 12-Jun-2024  riastradh branches: 1.35.2;
ld@virtio(4): Fix maximum size parameters.

- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.

The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.

=> Don't add two extra segments in the dmamap vr_payload for the
header and status -- we already have a separate dmamap vr_cmdsts
for that.

=> Don't recalculate payload dmamap parameters based on division by
NBPG, just use the ones specified by the host.

=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
MAXPHYS.

Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.

PR kern/58338
 1.34 09-Mar-2024  isaki Modify a confused expression in ld_virtio_attach().
VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.
 1.33 12-Feb-2024  isaki Fix typo in error message.
 1.32 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.31 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.30 13-Apr-2022  uwe branches: 1.30.4;
virtio: use the new syntax for snprintb(3) format strings.

The old syntax is limited to 32 bits only (and has 1-based bit numbers
which is rather incovenient too).
 1.29 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.28 24-Oct-2020  skrll branches: 1.28.2;
Use BUS_DMA_WAITOK in ld_virtio_alloc_reqs which is called at attached
time...
 1.27 17-Jan-2019  hannken Use cv_broadcast() on "sc_sync_wait" to prevent deadlock
when more than one thread try to "DIOCCACHESYNC" at the
same time.
 1.26 23-Nov-2018  jmcneill Use MSIX when available
 1.25 12-Jul-2018  jakllsch revert previous, unintended, commit
 1.24 12-Jul-2018  jakllsch <sys/pmc.h> is gone; dont
 1.23 21-Jun-2018  jakllsch branches: 1.23.2;
destroy 'sc_sync_wait' condvar and mutex upon detach
 1.22 10-Jun-2018  jakllsch remove irrelevant pci(9) #includes from virtio child drivers
 1.21 10-Jun-2018  jakllsch The virtio block device capacity config item is expressed always in
request protocol sector units of 512 bytes.

Also, add and use a symbolic constant to refer to request protocol
sector units.
 1.20 07-Jun-2018  jakllsch Make ld_virtio aware of a possible device-side write cache.
 1.19 03-Jun-2018  jakllsch unload payload dma map upon command completion
 1.18 03-Jun-2018  jakllsch add feature/register definitions from virtio-v1.0-cs04
 1.17 03-Jun-2018  jakllsch remove trailing whitespace
 1.16 09-Aug-2017  mlelstv branches: 1.16.2;
While ld(4) is MP safe, many backends are not.

Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.

Fixes PR 52462.
 1.15 25-Mar-2017  jdolecek branches: 1.15.6;
reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.14 27-Feb-2017  jdolecek refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
 1.13 30-Nov-2016  christos branches: 1.13.2;
Don't call virtio_enqueue_abort when virtio_enqueue_reserve fails.
Pointed out by uwe@
 1.12 27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.11 16-Sep-2016  jdolecek modify ldattach() to have default strategy as a parameter
 1.10 07-Jul-2016  msaitoh branches: 1.10.2;
KNF. Remove extra spaces. No functional change.
 1.9 27-Oct-2015  christos - Print the negotiated feature bits
- Define a constant for the minimum number of segments and use that.
- Remove unused sc_lock
- Use single variables instead of arrays of 1 element
- To the transfer size and segment size negotiation more correctly
- Make vr_bp NULL when unused.
- Add missing abort calls
 1.8 05-May-2015  ozaki-r Use NULL for initialization of sc_config_change
 1.7 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.6 22-Jul-2014  ozaki-r branches: 1.6.4;
Introduce VIRTIO_F_PCI_INTR_MPSAFE for virtio

It is set by a child driver, e.g., if_vioif. If set, virtio sets
PCI_INTR_MPSAFE for pci_intr_establish.
 1.5 02-Feb-2012  tls branches: 1.5.6; 1.5.20;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.4 03-Dec-2011  hannken branches: 1.4.2; 1.4.4;
Don't try to set ld->sc_maxxfer below MAXPHYS.
At least genfs_io assumes 'ld->sc_maxxfer == MAXPHYS'.
 1.3 23-Nov-2011  hannken According to "Virtio PCI Card Specification v0.9.2 DRAFT" there is no
feature named VIRTIO_BLK_F_SECTOR_MAX so remove it. Linux seems to use
this feature bit as VIRTIO_BLK_F_TOPOLOGY.

Use VIRTIO_BLK_F_BLK_SIZE * VIRTIO_BLK_F_SEG_MAX as the drivers maxxfer
and reorder so sc_secsize gets set before use.

As maxxfer may not be a multiple of page size add one more segment to
the dma maps.

Tested on Linux 3.1.1 host by Guillaume Lasmayous.
 1.2 02-Nov-2011  hannken branches: 1.2.2;
Make sure we allocate enough segments for the request dma maps.
 1.1 30-Oct-2011  hannken Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.4.4.2 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.4.4.1 03-Dec-2011  riz file ld_virtio.c was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.4.2.1 18-Feb-2012  mrg merge to -current.
 1.5.20.1 10-Aug-2014  tls Rebase.
 1.5.6.2 03-Dec-2017  jdolecek update from HEAD
 1.5.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.4.6 28-Aug-2017  skrll Sync with HEAD
 1.6.4.5 05-Dec-2016  skrll Sync with HEAD
 1.6.4.4 05-Oct-2016  skrll Sync with HEAD
 1.6.4.3 09-Jul-2016  skrll Sync with HEAD
 1.6.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.6.4.1 06-Jun-2015  skrll Sync with HEAD
 1.10.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.10.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.10.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.13.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.15.6.2 22-Jun-2018  martin Pull up following revision(s) (requested by jakllsch in ticket #888):

sys/dev/pci/ld_virtio.c: revision 1.19-1.21,1.23

remove trailing whitespace

add feature/register definitions from virtio-v1.0-cs04

unload payload dma map upon command completion

Make ld_virtio aware of a possible device-side write cache.

The virtio block device capacity config item is expressed always in
request protocol sector units of 512 bytes.

Also, add and use a symbolic constant to refer to request protocol
sector units.

destroy 'sc_sync_wait' condvar and mutex upon detach
 1.15.6.1 01-Sep-2017  martin Pull up following revision(s) (requested by mlelstv in ticket #261):
sys/dev/sdmmc/ld_sdmmc.c: revision 1.32
sys/dev/sdmmc/ld_sdmmc.c: revision 1.33
sys/dev/sdmmc/ld_sdmmc.c: revision 1.34
sys/dev/sdmmc/sdmmc_mem.c: revision 1.62
sys/dev/i2o/ld_iop.c: revision 1.39
sys/dev/ld.c: revision 1.102
sys/dev/ld.c: revision 1.103
sys/dev/dksubr.c: revision 1.98
sys/dev/dksubr.c: revision 1.99
sys/dev/sdmmc/sdmmcvar.h: revision 1.29
sys/dev/ic/ld_nvme.c: revision 1.17
sys/dev/ldvar.h: revision 1.31
sys/dev/ldvar.h: revision 1.32
sys/dev/ic/ld_cac.c: revision 1.31
sys/dev/pci/ld_virtio.c: revision 1.16
While ld(4) is MP safe, many backends are not.
Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.
Fixes PR 52462.
Defer sdmmc discard operations to the sdmmc task queue. Fixes a panic
introduced by ld.c r1.102.
validate length for discard operation and split operation when byte length
doesn't fit into 'int'.
make the sc_discard interface for the ld backend asynchronous and
signal completion through new callback lddiscardend. Use a standard
struct buf to pass disk address and range instead of two off_t values.
make lddiscard synchronous again. This is a requirement of the current
ffs discard code.
Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.
reported by: GCC, but with different compile flags
 1.16.2.4 18-Jan-2019  pgoyette Synch with HEAD
 1.16.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.16.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.16.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.23.2.1 10-Jun-2019  christos Sync with HEAD
 1.28.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.30.4.2 02-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #914):

sys/dev/pci/virtio_pci.c: revision 1.50
sys/dev/pci/virtio_pci.c: revision 1.51
sys/dev/pci/virtio_pci.c: revision 1.52
sys/dev/pci/virtio_pci.c: revision 1.53
sys/dev/pci/virtio_pci.c: revision 1.54
sys/dev/pci/vioscsi.c: revision 1.35
sys/dev/pci/ld_virtio.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.34
sys/dev/virtio/viocon.c: revision 1.9
sys/dev/pci/ld_virtio.c: revision 1.35
sys/dev/pci/virtio.c: revision 1.80
sys/dev/pci/virtio.c: revision 1.81
sys/dev/pci/virtio.c: revision 1.82
sys/dev/pci/virtio_pci.c: revision 1.45
sys/dev/pci/virtio_pci.c: revision 1.46
sys/dev/pci/virtio_pci.c: revision 1.47
sys/dev/pci/virtio_pci.c: revision 1.48
sys/dev/pci/virtio_pci.c: revision 1.49
sys/dev/pci/virtio.c: revision 1.79

A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.

viocon(4): Show error in assertion failure.

virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
fix spelling mistakes, mainly in comments and log messages.

Split KASSERT(A && B) into KASSERT(A); KASSERT(B).

Fix typo in error message.

Modify a confused expression in ld_virtio_attach().

VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.

ld@virtio(4): Fix maximum size parameters.
- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.
The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.
=> Don't add two extra segments in the dmamap vr_payload for the
header and status -- we already have a separate dmamap vr_cmdsts
for that.
=> Don't recalculate payload dmamap parameters based on division by
NBPG, just use the ones specified by the host.
=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
MAXPHYS.
Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.
PR kern/58338

virtio_pci.c: Nix trailing whitespace.

virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.
PR kern/58335

virtio@pci: Nix useless sc_mapped_iosize.
This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.
Prompted by PR kern/58335.

virtio@pci: Don't detach on shutdown.
The virtio bus does not keep state in memory that needs to flushed to
persistent storage. Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).
Prompted by PR kern/58335.

virtio@pci: Zero sc_bars_iosize[i] on unmap.
No functional change intended, but this makes the code less brittle.
Prompted by PR kern/58335.

virtio_pci.c: Sort includes.
No functional change intended.

virtio_pci.c: Omit needless blank lines and commented code.
No functional change intended.

virtio_pci.c: Sprinkle KNF.
- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
virtio_pci.c: Sprinkle const.
No functional change intended.

virtio_pci.c: Use container_of, not cast.
virtio(4): Assert child attach finished before we allow queueing.
Should help catch mistakes like:
PR kern/58555: Kernel panic during boot when using viocon with PCIe
 1.30.4.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.35.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 30-Nov-2018  jmcneill Add support for polling com devices when no interrupt is available.
 1.18 27-Apr-2017  msaitoh branches: 1.18.8; 1.18.10;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.17 29-Mar-2014  christos branches: 1.17.6; 1.17.20;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.16 31-Jul-2013  soren On x86, print the I/O address of lpt_puc as for com_puc so that hacks
using iopl/ioperm can be told where to find the parallel port.

Closes PR kern/43683.
 1.15 22-Jul-2013  soren Since puc(4) serial ports are typically not identified in the
BIOS COM[1234] table, the I/O address must be manually set using
installboot(8) in order to enable a serial console.
Print the address here so the user doesn't have to dig through
PCI configuration space to find it.

Enable suspend/resume hooks.
 1.14 07-Mar-2008  cube branches: 1.14.38; 1.14.48; 1.14.54; 1.14.62;
Split the softc from the device_t for all lpt(4) variants and attachments
except the ppbus stuff (which doesn't compile) and ulpt(4) which is
unrelated and can be dealt with separately.

As usual, it comes with related cosmetic changes.
 1.13 19-Oct-2007  ad branches: 1.13.12; 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 27-Feb-2005  perry nuke trailing whitespace
 1.7 04-Feb-2005  perry de-__P
 1.6 02-Oct-2002  thorpej branches: 1.6.6; 1.6.14; 1.6.16;
Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.2 13-Nov-2001  lukem add RCSID
 1.1 26-Jun-1998  cgd branches: 1.1.26; 1.1.28;
add a driver for "PCI 'universal' communications" cards, that is, PCI cards
which contain 'standard' com- and lpt-type ports. Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not. (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.) Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
 1.1.28.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.28.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.26.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.26.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.26.1 14-Nov-2001  nathanw Catch up to -current.
 1.6.16.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.16.1 12-Feb-2005  yamt sync with head.
 1.6.14.1 29-Apr-2005  kent sync with -current
 1.6.6.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.6.1 04-Feb-2005  skrll Sync with HEAD.
 1.9.2.3 17-Mar-2008  yamt sync with head.
 1.9.2.2 27-Oct-2007  yamt sync with head.
 1.9.2.1 30-Dec-2006  yamt sync with head.
 1.10.22.2 10-Dec-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.2 23-Mar-2008  matt sync with HEAD
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.12.1 24-Mar-2008  keiichi sync with head.
 1.14.62.1 23-Jul-2013  riastradh sync with HEAD
 1.14.54.2 18-May-2014  rmind sync with head
 1.14.54.1 28-Aug-2013  rmind sync with head
 1.14.48.2 03-Dec-2017  jdolecek update from HEAD
 1.14.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.38.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.20.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.17.6.1 28-Aug-2017  skrll Sync with HEAD
 1.18.10.1 10-Jun-2019  christos Sync with HEAD
 1.18.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.3 26-Nov-2000  ad lsu -> ld, by popular request.
 1.2 14-Nov-2000  itojun branches: 1.2.2;
need uvm/uvm_extern.h for PAGE_SIZE
 1.1 08-Nov-2000  ad Move lsu stuff to more logical locations, and push queueing into the lsu
driver.
 1.2.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.1 14-Nov-2000  bouyer file lsu_twe.c was added on branch thorpej_scsipi on 2000-11-22 16:04:09 +0000
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.5 10-Jul-2016  jmcneill branches: 1.5.34;
fix inverted screen blanking logic
 1.4 14-Mar-2012  nonaka branches: 1.4.2; 1.4.4; 1.4.16; 1.4.18;
lynxfb too.

> Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
> something meaningful. All relevant documentation has been updated or
> written.
 1.3 11-Mar-2012  nonaka fix mmaped offset.
X works on Yeeloong Notebook now.
 1.2 11-Mar-2012  nonaka path correct device to wsdisplayio_busid_pci().
 1.1 02-Mar-2012  nonaka branches: 1.1.2;
Added Lemote Yeeloong Notebook support.
 1.1.2.5 05-Apr-2012  mrg sync to latest -current.
 1.1.2.4 06-Mar-2012  mrg sync to -current
 1.1.2.3 06-Mar-2012  mrg sync to -current
 1.1.2.2 04-Mar-2012  mrg sync to latest -current.
 1.1.2.1 02-Mar-2012  mrg file lynxfb.c was added on branch jmcneill-usbmp on 2012-03-04 00:46:20 +0000
 1.4.18.1 05-Oct-2016  skrll Sync with HEAD
 1.4.16.1 11-Jul-2016  martin Pull up following revision(s) (requested by jmcneill in ticket #1203):
sys/dev/pci/lynxfb.c: revision 1.5
fix inverted screen blanking logic
 1.4.4.1 03-Dec-2017  jdolecek update from HEAD
 1.4.2.2 17-Apr-2012  yamt sync with head
 1.4.2.1 14-Mar-2012  yamt file lynxfb.c was added on branch yamt-pagecache on 2012-04-17 00:07:51 +0000
 1.5.34.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 11-Mar-2012  nonaka branches: 1.2.2;
fix mmaped offset.
X works on Yeeloong Notebook now.
 1.1 02-Mar-2012  nonaka branches: 1.1.2;
Added Lemote Yeeloong Notebook support.
 1.1.2.5 05-Apr-2012  mrg sync to latest -current.
 1.1.2.4 06-Mar-2012  mrg sync to -current
 1.1.2.3 06-Mar-2012  mrg sync to -current
 1.1.2.2 04-Mar-2012  mrg sync to latest -current.
 1.1.2.1 02-Mar-2012  mrg file lynxfbreg.h was added on branch jmcneill-usbmp on 2012-03-04 00:46:20 +0000
 1.2.2.2 17-Apr-2012  yamt sync with head
 1.2.2.1 11-Mar-2012  yamt file lynxfbreg.h was added on branch yamt-pagecache on 2012-04-17 00:07:51 +0000
 1.1 02-Mar-2012  nonaka branches: 1.1.2; 1.1.4;
Added Lemote Yeeloong Notebook support.
 1.1.4.2 17-Apr-2012  yamt sync with head
 1.1.4.1 02-Mar-2012  yamt file lynxfbvar.h was added on branch yamt-pagecache on 2012-04-17 00:07:51 +0000
 1.1.2.4 06-Mar-2012  mrg sync to -current
 1.1.2.3 06-Mar-2012  mrg sync to -current
 1.1.2.2 04-Mar-2012  mrg sync to latest -current.
 1.1.2.1 02-Mar-2012  mrg file lynxfbvar.h was added on branch jmcneill-usbmp on 2012-03-04 00:46:20 +0000
 1.107 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.106 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.105 21-Jun-2021  christos branches: 1.105.2;
fix proplib deprecation
 1.104 24-Apr-2021  thorpej branches: 1.104.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.103 10-Oct-2020  jdc branches: 1.103.4;
Don't change a videomode that's been setup in the firmware.
Extend the register debugging output (and hopefully make it easier to read).
 1.102 07-Aug-2020  macallan the drawing engine needs a stride that's a multiple of 8 in pixels, so
let's actually distinguish between width and stride, and always round the stride
up to the next multiple of 8
now modes with odd widths work
 1.101 07-Aug-2020  jdc Also set the bits for horizontal sync start delay. This makes machfb work
correctly for some modes (e.g. 1152x720).
Modify mach64_get_mode() to get the mode from the chip registers (only used
with debug on).
Whilst here tidy up some other debug output.
 1.100 30-Jul-2020  macallan if we find composity sync enabled, leave it on instead of unconditionally
enabling it on sparc*
 1.99 05-Jul-2020  martin Adapt to proplib interface changes
 1.98 07-Dec-2019  macallan clean up the video mode selection logic, switch modes only when actually
necessary
while there make some debug output optional
 1.97 05-Feb-2019  mrg branches: 1.97.4;
add or adjust fallthru comments.
 1.96 03-Feb-2019  tnn machfb: guard against absent mode information from firmware
 1.95 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.94 02-Jun-2017  macallan branches: 1.94.8; 1.94.10;
enable font loading and screen resizing, now that the glyph cache can be
reconfigured whenever needed
 1.93 28-May-2017  macallan g/c some unused / #if 0-ed goop, support firmware-provided EDID, get rid of
private list of video modes
tested on macppc, should Just Work(tm) on sparc64
 1.92 11-Jul-2016  msaitoh KNF. No functional change.
 1.91 18-Dec-2013  macallan branches: 1.91.6;
get rid of /dev/fb support which has never been used for anything other than
some highly experimental code in xf86/Xsun
 1.90 06-Nov-2013  macallan Don't turn off aperture registers - some firmwares don't know how to turn
them back on. Also distinguish between WSDISPLAYIO_MODE_MAPPED and _DUMBFB -
we only need to turn the registers off in _DUMBFB mode when mapping all 8MB
of video memory.
 1.89 09-Oct-2013  macallan support WSDISPLAYIO_GET_FBINFO
 1.88 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.87 28-May-2013  macallan branches: 1.87.2;
support RI_FULLCLEAR
 1.86 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.85 05-Oct-2012  macallan gc_attr is no more
 1.84 01-Oct-2012  jdc Match the Rage Mobility M1 used in the Tadpole SPARCle.
 1.83 16-Aug-2012  macallan branches: 1.83.2;
fix a bunch of typos, thinkos and cargocultos
 1.82 15-Aug-2012  macallan don't forget to clear the screen and wipe the glyph cache when re-entering
terminal emulation mode
 1.81 15-Aug-2012  macallan some cleanup:
- get rid of some redundant variables ( sc_*phys and sc_*base were essentially
the same )
- we don't access video memory directly anymore, so:
* no more need for byte order tests
* don't map video memory if we have a MMIO register aperture
* get rid of various bits of support code dealing with video memory
access
- use MMIO register aperture if available, turn off register blocks in the main
aperture if not in use, to avoid overlap with video memory on 8MB cards
- don't scissor off access to off-screen memory. How the hell did this work on
Rage II? Apparently Rage XL treats the scissor registers slightly different.
Now this works properly on 8MB and Rage XL boards like Sun's PGX64.
 1.80 03-Aug-2012  macallan machfb's memsize is in MB, glyphcache_init expects bytes. doh.
 1.79 02-Aug-2012  macallan add support for anti-aliased fonts
 1.78 14-Jun-2012  macallan more preparation for alpha support:
- use R3G3B2 colour map
- consistently use ri_devcmap[]
- reshuffle cmap setup, screen cleaning, msg buffer replay etc. to deal
with the above
 1.77 14-Jun-2012  macallan do some minimal setup if we're not the console
 1.76 14-Jun-2012  macallan cosmetics:
- fix/remove outdated comments
- printf() -> aprint_*()
- #if 1 removal
 1.75 08-May-2012  macallan don't enable IO access - we don't use it and at least on some macppc machines
the IO BAR contains garbage
should probably be pulled into 6.0
 1.74 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.73 30-Jan-2012  drochner branches: 1.73.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.72 11-Jan-2012  macallan use rasops_init(0, 0)
 1.71 04-Aug-2011  jakllsch branches: 1.71.2; 1.71.6;
Fix machfb build on ports not based on powerpc or sparc.
 1.70 03-Aug-2011  macallan don't try to a 'better' vertical frequency, it's almost certainly wrong with
flat panels
 1.69 01-Aug-2011  mbalmer According to the Oxford Dictionary of Etymology, a wether is a male sheep
or ram.
 1.68 29-Jun-2011  macallan support WSDISPLAYIO_GET_EDID
 1.67 01-Jun-2011  macallan move wsdisplay_accessops into the softc so multiple instances have a chance
to work without stepping on each other's toes
 1.66 16-May-2011  macallan don't leave a mess on screen when attaching, while there use VCONS_DONT_READ
if VCONS_DRAW_INTR is set
 1.65 10-May-2011  dyoung Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.64 04-May-2011  macallan add support for (ancient) Mach64 CX and GX, while there make sure the visible
vram area starts at the same offset as the area we're going to draw into -
zero that is.
from David Riley
 1.63 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.62 16-Dec-2010  cegger branches: 1.62.2; 1.62.4;
ioctl: KNF switch-case, remove useless brackets
 1.61 02-Oct-2010  macallan cleanup debug code
 1.60 02-Oct-2010  macallan fix a typo
 1.59 04-May-2010  macallan this has been sitting in my tree too long:
- device_t-ify
- sanitize debugging #ifdefs
- deal with firmwares setting up modes using other clocks than #0
- get rid of sparc and macppc-specific code, use device properties instead
- while there, use alternate box drawing font if needed
 1.58 11-Mar-2010  mrg branches: 1.58.2;
various aprint_* fixes.
 1.57 06-May-2009  elad branches: 1.57.2;
Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.56 03-Jan-2009  yamt branches: 1.56.2;
remove extra semicolons.
 1.55 01-Jul-2008  dyoung branches: 1.55.4;
Comment out some device IDs that do not actually belong to mach64
devices. This stops machfb0 from trying and failing to attach as
console on my G4 PowerBook. Now, genfb0 will attach as console,
instead.

Apparently, Michael Lorenz made a similar change on the netbsd-4
branch, but it was never committed to -current.
 1.54 01-Jul-2008  dyoung Cosmetic: use device_t, cfdata_t, __arraycount(), device_private().
 1.53 12-Jun-2008  cegger use device_lookup_private to get softc
 1.52 10-Apr-2008  cegger branches: 1.52.2; 1.52.4; 1.52.6; 1.52.8;
use aprint_*_dev and device_xname
 1.51 24-Mar-2008  elad Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.

This and similar requests will be replaced Soon, but these two in
particular should be pulled up to netbsd-4, and to allow doing that
smoothly, we're first introducing the "issuser" version.

Discussed with and okay macallan@.
 1.50 15-Jan-2008  jmcneill branches: 1.50.6;
For WSDISPLAY_GINFO, depth should be sc->bits_per_pixel, not
sc->color_depth. While we're here, implement WSDISPLAYIO_LINEBYTES.
 1.49 04-Mar-2007  christos branches: 1.49.16; 1.49.22; 1.49.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.48 16-Nov-2006  christos branches: 1.48.2; 1.48.4; 1.48.8;
__unused removal on arguments; approved by core.
 1.47 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.46 02-Sep-2006  christos branches: 1.46.2; 1.46.4;
add missing initializers
 1.45 10-May-2006  mrg quell GCC 4.1 uninitialised variable warnings.

XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
 1.44 19-Apr-2006  macallan fix some ugly mixup of virtual and physical addresses
 1.43 16-Apr-2006  macallan correct a cast to avoid a warning. Pointed out by he.
 1.42 15-Apr-2006  jmmv Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.41 12-Apr-2006  macallan convert to vcons
while there, attach an fb device when running on sparc
 1.40 12-Apr-2006  jmmv Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.39 05-Apr-2006  drochner update for accessops change (get/serborder removed)
 1.38 18-Dec-2005  macallan branches: 1.38.4; 1.38.6; 1.38.8; 1.38.10; 1.38.12;
Add devname: to printf()s
From rivo nurges
 1.37 12-Dec-2005  christos welcome to the new lwp world.
 1.36 11-Dec-2005  christos merge ktrace-lwp.
 1.35 03-Oct-2005  macallan Build mach64_get_mode only on SPARC and PowerPC to shut up a compiler warning.
 1.34 01-Oct-2005  macallan Cleanup, remove some duplicate code, behave better with more than one instance
present.
 1.33 21-Sep-2005  macallan - avoid using global variables unless necessary, this should fix weird
problems when more than one mach64 is present
- check memory BARs in mach64_mmap() and adjust allowed ranges in case
something ( XFree86 for instance ) changed them
- disable 'standard' framebuffer mapping at offset 0 on sparc64 because some
Sun/ATI firmware likes to map PCI resources there. May be necessary on other
64bit architectures as well.
 1.32 02-Aug-2005  macallan fix a stupid typo
 1.31 02-Aug-2005  macallan disable mmap()ing the framebuffer at offset 0 on sparc64 because some ATI
firmware likes to put PCI memory resources into this range, notably a Rage
IIc which puts the 2nd register aperture to 0x2000.
This should allow a few graphics chips to work with XFree86 which previously
failed with something like this:
(WW) ATI: PCI/AGP Mach64 in slot 2:5:0 could not be detected!
No devices to configure. Configuration failed.

Thanks to Florian Stoehr for doing most of the work tracking this down.
 1.30 07-Jul-2005  thorpej Apply const and static where appropriate.
 1.29 31-May-2005  christos branches: 1.29.2;
Always call mach64_init_screen, otherwise we'll panic later if DIAGNOSTIC
when we call switch screen and the machine has a serial console. Thanks to
martin for the fix.
 1.28 31-May-2005  christos minor knf. no functional change.
 1.27 30-May-2005  christos add const.
 1.26 02-May-2005  macallan more formatting fixes
 1.25 02-May-2005  macallan fixed formatting
 1.24 02-May-2005  macallan - made blitter operationd asynchronous
- removed some debug code
- prevent blitter operations when not in WSDISPLAYIO_MODE_EMUL
(approved by martin)
 1.23 07-Mar-2005  martin branches: 1.23.2;
Make it compile for 32bit sparc kernels (bus_addr_t is larger than void*
there)
 1.22 27-Feb-2005  perry nuke trailing whitespace
 1.21 25-Feb-2005  martin From Michael Lorenz: more cleanup and various bugfixes, support
for WSDISPLAYIO_GETWSCHAR and WSDISPLAYIO_PUTWSCHAR ioctls.
 1.20 17-Jan-2005  martin branches: 1.20.2;
More changes from Michael Lorenz:
- fix a panic in mach64_alloc_screen()
- some cleanup
- restrict mach64_mmap() to addresses which belong to it
- mach64_attach now prints bus addresses instead of kernel vm addresses
- initial support for macppc
 1.19 09-Jan-2005  martin branches: 1.19.2;
Bugfixes and acceleration support.
From Michael Lorenz.
 1.18 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.17 22-Mar-2004  pk sparc: OF_instance_to_package => prom_instance_to_package
 1.16 22-Mar-2004  martin Adapt to promlib changes on sparc.
 1.15 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.14 29-Jun-2003  fvdl branches: 1.14.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.13 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.12 20-Jan-2003  martin Grrr, add another set of casts working around sc_aperbase having the wrong
type. We should fix this!

This makes it compile for 32bit sparc64 kernels.
 1.11 15-Jan-2003  martin Fix typo - make it compile with DIAGNOSTIC.
 1.10 11-Dec-2002  junyoung '.' was missing in license notice.
 1.9 25-Nov-2002  martin Remove assumptions about endianess of bus_space_vaddr mappings, replace
with an explicit probe.
 1.8 02-Nov-2002  martin branches: 1.8.2;
Need to cast a bus_space_addr_t to (u_long) before gcc allows us to cast
it to a pointer on 32bit spacr64 kernels. Sigh.
 1.7 31-Oct-2002  martin Rearange struct mach64screen to be derived from struct rasops_info,
move a few bits around and make adding screens after attach time
actually work.

When not booting as console, try to properly set up the hardware to
get a display nevertheless (XXX - does not yet work on my U5).

#if 0 some unused functions planned for future extensions (to make clear
they are unused now)
 1.6 29-Oct-2002  junyoung Reduce the number of #ifdef __sparc__ from 5 to 3.
 1.5 29-Oct-2002  junyoung Rename sparc_screen_is_console() to mach64_is_console() and turn it into
a MI interface.
 1.4 25-Oct-2002  junyoung Register aperture is now mapped as a subregion of the framebuffer aperture
using bus_space_subregion(). This makes reg*() look better.
 1.3 25-Oct-2002  martin Sprinkle a few bus_space_read*/bus_space_write* calls and simplify register
offset calculation. Mostly from Bang Jun Young.

Don't call wsdisplay_cnattach unconditionally.

On sparc use OF to decide whether we are console output.

This makes it actually work on my U5 - if only we had a keyboard driver
to produce wskbd events (coming soon).
 1.2 24-Oct-2002  martin A few 64bit nits.
 1.1 24-Oct-2002  junyoung Add machfb, ATI Mach64/Rage framebuffer display driver.

XXX this version is not fully functional yet. More to come shortly.
 1.8.2.5 17-Jan-2003  thorpej Sync with HEAD.
 1.8.2.4 19-Dec-2002  thorpej Sync with HEAD.
 1.8.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.8.2.2 11-Nov-2002  nathanw Catch up to -current
 1.8.2.1 02-Nov-2002  nathanw file machfb.c was added on branch nathanw_sa on 2002-11-11 22:11:19 +0000
 1.14.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.8 08-Mar-2005  skrll Sync with HEAD.
 1.14.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.6 24-Jan-2005  skrll Sync with HEAD.
 1.14.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.14.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.2 03-Aug-2004  skrll Sync with HEAD
 1.14.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.19.2.1 29-Apr-2005  kent sync with -current
 1.20.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.2.5 08-Jun-2005  tron Pull up revision 1.29 (requested by martin in ticket #377):
Always call mach64_init_screen, otherwise we'll panic later if DIAGNOSTIC
when we call switch screen and the machine has a serial console. Thanks to
martin for the fix.
 1.23.2.4 08-Jun-2005  tron Pull up revision 1.28 (requested by martin in ticket #377):
minor knf. no functional change.
 1.23.2.3 08-Jun-2005  tron Pull up revision 1.26 (requested by martin in ticket #377):
more formatting fixes
 1.23.2.2 08-Jun-2005  tron Pull up revision 1.25 (requested by martin in ticket #377):
fixed formatting
 1.23.2.1 08-Jun-2005  tron Pull up revision 1.24 (requested by martin in ticket #377):
- made blitter operationd asynchronous
- removed some debug code
- prevent blitter operations when not in WSDISPLAYIO_MODE_EMUL
(approved by martin)
 1.29.2.4 21-Jan-2008  yamt sync with head
 1.29.2.3 03-Sep-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.38.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.38.10.2 11-May-2006  elad sync with head
 1.38.10.1 19-Apr-2006  elad sync with head.
 1.38.8.3 03-Sep-2006  yamt sync with head.
 1.38.8.2 24-May-2006  yamt sync with head.
 1.38.8.1 11-Apr-2006  yamt sync with head
 1.38.6.2 01-Jun-2006  kardel Sync with head.
 1.38.6.1 22-Apr-2006  simonb Sync with head.
 1.38.4.1 09-Sep-2006  rpaulo sync with head
 1.46.4.2 10-Dec-2006  yamt sync with head.
 1.46.4.1 22-Oct-2006  yamt sync with head
 1.46.2.1 18-Nov-2006  ad Sync with head.
 1.48.8.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.48.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.48.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.48.2.2 24-Mar-2008  bouyer Pull up following revision(s) (requested by elad in ticket #1107):
sys/dev/pci/machfb.c: revision 1.51
sys/dev/pci/voodoofb.c: revision 1.14
Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.
Discussed with and okay macallan@.
 1.48.2.1 21-Jul-2007  liamjfoy branches: 1.48.2.1.4;
Pull up following revision(s) (requested by macallan in ticket #781):
This keeps machfb from matching Rage Mobility chips which we don't
support properly, mainly for lack of hardware in the right hands.

Provided by a patch.
 1.48.2.1.4.1 24-Mar-2008  bouyer Pull up following revision(s) (requested by elad in ticket #1107):
sys/dev/pci/machfb.c: revision 1.51
sys/dev/pci/voodoofb.c: revision 1.14
Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.
Discussed with and okay macallan@.
 1.49.28.1 19-Jan-2008  bouyer Sync with HEAD
 1.49.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.49.16.1 23-Mar-2008  matt sync with HEAD
 1.50.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.50.6.4 02-Jul-2008  mjf Sync with HEAD.
 1.50.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.50.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.50.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.52.8.2 03-Jul-2008  simonb Sync with head.
 1.52.8.1 18-Jun-2008  simonb Sync with head.
 1.52.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.52.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.4.4 09-Oct-2010  yamt sync with head
 1.52.4.3 11-Aug-2010  yamt sync with head.
 1.52.4.2 16-May-2009  yamt sync with head
 1.52.4.1 04-May-2009  yamt sync with head.
 1.52.2.1 17-Jun-2008  yamt sync with head.
 1.55.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.56.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.57.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.57.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.57.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.58.2.4 12-Jun-2011  rmind sync with head
 1.58.2.3 31-May-2011  rmind sync with head
 1.58.2.2 05-Mar-2011  rmind sync with head
 1.58.2.1 30-May-2010  rmind sync with head
 1.62.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.62.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.71.6.3 02-Jun-2012  mrg sync to latest -current.
 1.71.6.2 05-Apr-2012  mrg sync to latest -current.
 1.71.6.1 18-Feb-2012  mrg merge to -current.
 1.71.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.71.2.3 30-Oct-2012  yamt sync with head
 1.71.2.2 23-May-2012  yamt sync with head.
 1.71.2.1 17-Apr-2012  yamt sync with head
 1.73.2.1 12-Jun-2012  riz Pull up following revision(s) (requested by macallan in ticket #322):
sys/dev/pci/machfb.c: revision 1.75
don't enable IO access - we don't use it and at least on some macppc machines
the IO BAR contains garbage
should probably be pulled into 6.0
 1.83.2.4 03-Dec-2017  jdolecek update from HEAD
 1.83.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.83.2.2 23-Jun-2013  tls resync from head
 1.83.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.87.2.2 18-May-2014  rmind sync with head
 1.87.2.1 28-Aug-2013  rmind sync with head
 1.91.6.2 28-Aug-2017  skrll Sync with HEAD
 1.91.6.1 05-Oct-2016  skrll Sync with HEAD
 1.94.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.94.10.1 10-Jun-2019  christos Sync with HEAD
 1.94.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.97.4.1 16-Apr-2020  martin Pull up following revision(s) (requested by jdc in ticket #836):

sys/dev/pci/machfb.c: revision 1.98

clean up the video mode selection logic, switch modes only when actually
necessary

while there make some debug output optional
 1.103.4.3 24-Apr-2021  thorpej Make sure to explcitly specify the "wsemuldisplaydev" interface attribute
when attaching the wscons display instance, because these devices can
also attach children using the "drm" interface attribute.
 1.103.4.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.103.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.104.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.105.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 15-Aug-2012  macallan add a few register definitions
 1.4 04-May-2010  macallan branches: 1.4.8;
add some PLL-specific register definitions
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.96; 1.3.98;
merge ktrace-lwp.
 1.2 03-Oct-2005  macallan Cleanup, remove some duplicate code, behave better with more than one instance present. ( for machfb.c 1.34+ )
 1.1 24-Oct-2002  junyoung branches: 1.1.2; 1.1.8; 1.1.24;
Add machfb, ATI Mach64/Rage framebuffer display driver.

XXX this version is not fully functional yet. More to come shortly.
 1.1.24.1 21-Jun-2006  yamt sync with head.
 1.1.8.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 24-Oct-2002  nathanw file machfbreg.h was added on branch nathanw_sa on 2002-11-11 22:11:20 +0000
 1.3.98.1 30-May-2010  rmind sync with head
 1.3.96.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.74.1 11-Aug-2010  yamt sync with head.
 1.4.8.1 30-Oct-2012  yamt sync with head
 1.2 03-Sep-2002  augustss Replace the mr driver with the gtp driver. From OpenBSD.
 1.1 01-Jan-2002  augustss branches: 1.1.2; 1.1.4;
Add support for radio cards. Written by Maxim Tsyplakov and Vladimir Popov
for OpenBSD, from where it was imported.
 1.1.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 01-Jan-2002  thorpej file maxiradio.c was added on branch kqueue on 2002-01-10 19:56:50 +0000
 1.1.2.3 17-Sep-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 01-Jan-2002  nathanw file maxiradio.c was added on branch nathanw_sa on 2002-01-08 00:31:08 +0000
 1.22 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.21 05-May-2022  msaitoh Add some code for the SKINNY variant to make Dell PERC H310 work.
 1.20 09-Dec-2018  jdolecek branches: 1.20.4;
use pci_intr_establish_xname() everywhere
 1.19 14-Jul-2016  msaitoh branches: 1.19.10; 1.19.16; 1.19.18;
- Use aprint*() instead of printf() in xxx_attach().
- Add missing aprint_naive("\n");
- KNF
 1.18 29-Mar-2014  christos branches: 1.18.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.17 31-Aug-2012  jnemeth branches: 1.17.2; 1.17.4;
PR/46877 - Wolfgang Stukenbrock -- missing definition for Symbios SAS 9261-8i
 1.16 23-Aug-2012  bouyer Add support newer LSI RAID controllers based on the SAS2208 chip,
codenamed "ThunderBolt". Add tagged queuing support for all adapters
supported by mfi(4).
Tested with a MegaRAID SAS 9265-8i adapter, and an older Dell PERC 5/i.
 1.15 05-Aug-2012  bouyer MFI_IOP_SKINNY is an enum not a single bit value, so it can't be used as
a bit flag. As sc_flags is really used to hold an enum mfi_iop value,
change it to enum mfi_iop and rename to sc_ioptype. While there init it
in mfi_attach() instead of mfi_pci_attach().
 1.14 22-Mar-2012  sborrill Add IBM ServeRAID M5014 as subtype
 1.13 21-Mar-2012  sborrill Add support for skinny variants (e.g. IBM ServeRAID M1015). Based on OpenBSD
changes with some improvements. Tested on IBM x3550M3 with RAID0 and RAID1
volumes including bioctl(8) operation.
 1.12 09-Feb-2010  msaitoh branches: 1.12.10; 1.12.14; 1.12.16;
Add newer cars supports. Tested on MegaRAID SAS 9260-8i.
- Add MFI gen2 support from OpenBSD.
- Add entry for MegaRAID SAS 9260-8i
 1.11 16-Jul-2009  dyoung branches: 1.11.2;
Let us detach & re-attach children of mfi0. Detach mfi0 at shutdown.

Detachment may fail after freeing some but not all resources, so
take care not to re-release any resource during detachment.

Tested on a Dell PowerEdge 1950.
 1.10 16-Jul-2009  dyoung device_t/softc split. Tested and shown to work on a Dell PowerEdge
1950.
 1.9 16-Jul-2009  dyoung Add a rudimentary detachment hook for mfi(4).
 1.8 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.7 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.6 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.5 26-Feb-2008  xtraeme branches: 1.5.4; 1.5.14; 1.5.18; 1.5.22;
Make it follow the standard convention of autoconf printing:

mfi0 at pci0 ...
mfi0: interrupting at ...

and only print the model string if it was matched.

Add the Dell PERC 5/i integraded subproduct ID.
 1.4 25-Feb-2008  xtraeme Added support for the mfi(4) controllers with powerpc IOPs such as
LSI SAS1078 or Dell PERC 6, from OpenBSD.

Tested by Akira Kato on current-users@.
 1.3 19-Oct-2007  ad branches: 1.3.12; 1.3.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.2 20-Dec-2006  bouyer branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14; 1.2.26; 1.2.28; 1.2.32;
Add missing $NetBSD: $
 1.1 17-Dec-2006  bouyer branches: 1.1.2;
Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
 1.1.2.3 21-Dec-2006  yamt sync with head.
 1.1.2.2 18-Dec-2006  yamt sync with head.
 1.1.2.1 17-Dec-2006  yamt file mfi_pci.c was added on branch yamt-splraiseipl on 2006-12-18 11:42:13 +0000
 1.2.32.1 25-Oct-2007  bouyer Sync with HEAD.
 1.2.28.2 23-Mar-2008  matt sync with HEAD
 1.2.28.1 06-Nov-2007  matt sync with HEAD
 1.2.26.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.2.14.1 23-Oct-2007  ad Sync with head.
 1.2.8.2 12-Jan-2007  ad Sync with head.
 1.2.8.1 20-Dec-2006  ad file mfi_pci.c was added on branch newlock2 on 2007-01-12 00:57:41 +0000
 1.2.6.4 27-Feb-2008  yamt sync with head.
 1.2.6.3 27-Oct-2007  yamt sync with head.
 1.2.6.2 30-Dec-2006  yamt sync with head.
 1.2.6.1 20-Dec-2006  yamt file mfi_pci.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:46 +0000
 1.2.4.2 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1609):
sys/arch/i386/conf/INSTALL: revision 1.298
sys/arch/i386/conf/GENERIC: revision 1.802
sys/dev/pci/files.pci: revision 1.274
sys/arch/amd64/conf/GENERIC: revision 1.122
sys/dev/pci/mfi_pci.c: revision 1.1 via patch
distrib/sets/lists/man/mi: revision 1.958
sys/arch/amd64/conf/INSTALL: revision 1.61
sys/dev/ic/mfireg.h: revision 1.1
share/man/man4/Makefile: revision 1.416 via patch
sys/dev/ic/mfi.c: revision 1.1
sys/arch/i386/conf/XEN2_DOM0: revision 1.19
sys/dev/ic/mfivar.h: revision 1.1
sys/conf/files: revision 1.821
share/man/man4/mfi.4: revision 1.1
share/man/man4/mfi.4: revision 1.2
sys/dev/pci/pcidevs via patch
Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
Punctuation issues.
 1.2.4.1 20-Dec-2006  ghen file mfi_pci.c was added on branch netbsd-3 on 2006-12-23 16:43:18 +0000
 1.2.2.3 21-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #286):
sys/dev/pci/mfi_pci.c: revision 1.2
sys/dev/ic/mfireg.h: revision 1.2
sys/dev/ic/mfi.c: revision 1.2
sys/dev/ic/mfivar.h: revision 1.2
Add missing $NetBSD: $
 1.2.2.2 21-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #286):
sys/arch/i386/conf/INSTALL: revision 1.298
sys/arch/i386/conf/GENERIC: revision 1.802
sys/dev/pci/files.pci: revision 1.274
sys/arch/amd64/conf/GENERIC: revision 1.122
sys/dev/pci/mfi_pci.c: revision 1.1
distrib/sets/lists/man/mi: revision 1.958
sys/arch/amd64/conf/INSTALL: revision 1.61
sys/arch/i386/conf/ALL: revision 1.75
sys/dev/ic/mfireg.h: revision 1.1
share/man/man4/Makefile: revision 1.416
sys/dev/ic/mfi.c: revision 1.1
sys/arch/i386/conf/XEN2_DOM0: revision 1.19
sys/dev/ic/mfivar.h: revision 1.1
sys/conf/files: revision 1.821
share/man/man4/mfi.4: revision 1.1
Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
 1.2.2.1 20-Dec-2006  tron file mfi_pci.c was added on branch netbsd-4 on 2006-12-21 12:46:21 +0000
 1.3.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.3.12.1 24-Mar-2008  keiichi sync with head.
 1.5.22.1 21-Apr-2010  matt sync to netbsd-5
 1.5.18.2 23-Jul-2009  jym Sync with HEAD.
 1.5.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.14.2 30-Sep-2012  bouyer Pull up following revision(s) (requested by jnemeth in ticket #1795):
sys/dev/pci/mfi_pci.c: revision 1.17 via patch
PR/46877 - Wolfgang Stukenbrock -- missing definition for Symbios SAS 9261-8i
 1.5.14.1 28-Mar-2010  snj Apply patch (requested by msaitoh in ticket #1326):
Add support for MFI gen2 devices. Mention newer devices, RAID 6 and
RAID60 in mfi.4.
 1.5.4.3 11-Mar-2010  yamt sync with head
 1.5.4.2 18-Jul-2009  yamt sync with head.
 1.5.4.1 16-May-2009  yamt sync with head
 1.11.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.12.16.4 24-Oct-2012  riz Pull up following revision(s) (requested by bouyer in ticket #628):
sys/dev/ic/mfi.c: revision 1.40
sys/dev/ic/mfi.c: revision 1.41
sys/dev/ic/mfi.c: revision 1.42
sys/dev/ic/mfi.c: revision 1.43
sys/dev/ic/mfi.c: revision 1.44
sys/dev/ic/mfi.c: revision 1.45
sys/dev/ic/mfi.c: revision 1.46
sys/dev/pci/pcidevs: revision 1.1128
sys/dev/pci/mfi_pci.c: revision 1.15
sys/dev/pci/mfi_pci.c: revision 1.16
sys/dev/ic/mfi.c: revision 1.39
sys/dev/ic/mfivar.h: revision 1.16
sys/dev/ic/mfireg.h: revision 1.6
sys/dev/ic/mfivar.h: revision 1.17
sys/dev/ic/mfireg.h: revision 1.7
sys/dev/ic/mfivar.h: revision 1.18
sys/dev/ic/mfivar.h: revision 1.19
Add some support for 64bit DMA but stick to 32bit DMA for now.
From OpenBSD mfi.c rev 1.119.
Add LSI MegaRAID SAS2208
MFI_IOP_SKINNY is an enum not a single bit value, so it can't be used as
a bit flag. As sc_flags is really used to hold an enum mfi_iop value,
change it to enum mfi_iop and rename to sc_ioptype. While there init it
in mfi_attach() instead of mfi_pci_attach().
sg64.len is 32bits, so use htole32()
Really init sc_ioptype in mfi_attach()
Add support newer LSI RAID controllers based on the SAS2208 chip,
codenamed "ThunderBolt". Add tagged queuing support for all adapters
supported by mfi(4).
Tested with a MegaRAID SAS 9265-8i adapter, and an older Dell PERC 5/i.
Avoid "unused variable" warning for non-DIAGNOSTIC kernels.
Pointed out by Havard Eidnes
After discussion on tech-kern@, fix performance issue related to
cache flush commands from WAPBL, by skipping the cache flush if the
BBU is present and considered good. Users which still want the write back
cache with a non-working BBU can set vfs.wapbl.flush_disk_cache to 0.
- add commands to monitor the BBU state. Add a boolean BBU sensor
to monitor the BBU state via sysmon_envsys(9).
- if the BBU is considered good, turn SCSI_SYNCHRONIZE_CACHE_10 and
SCSI_SYNCHRONIZE_CACHE_16 commands from upper layer into NOOPs.
While there, handle SCSI_SYNCHRONIZE_CACHE_16 in addition to
SCSI_SYNCHRONIZE_CACHE_10.
- Add a shutdown pmf(9) handler, which flushes the cache and shutdown the
firmware
- on detach, also flush cache and shutdown firmware.
- on attach, print the firmware-provided name, and the BBU state
Tested on a LSI MegaRAID SAS 9265-8i and a PERC 5/i Integrated
Make MFI_DEBUG build on i386.
Report BBU state changes with aprint_normal(), it seems that sysmon_envsys()
doens't report changes for ENVSYS_INDICATOR as it does for ENVSYS_DRIVE.
 1.12.16.3 03-Sep-2012  riz Pull up following revision(s) (requested by jnemeth in ticket #536):
sys/dev/pci/mfi_pci.c: revision 1.17
PR/46877 - Wolfgang Stukenbrock -- missing definition for Symbios SAS 9261-8i
 1.12.16.2 19-May-2012  riz branches: 1.12.16.2.2;
Pull up following revision(s) (requested by sborrill in ticket #261):
sys/dev/pci/mfi_pci.c: revision 1.14
share/man/man4/mfi.4: revision 1.11
Add IBM ServeRAID M5014 as subtype
Add IBM ServeRAID M1015 and M5014
 1.12.16.1 22-Mar-2012  riz Pull up following revision(s) (requested by sborrill in ticket #138):
sys/dev/pci/mfi_pci.c: revision 1.13
sys/dev/ic/mfi.c: revision 1.38
sys/dev/ic/mfivar.h: revision 1.15
sys/dev/ic/mfireg.h: revision 1.5
Add support for skinny variants (e.g. IBM ServeRAID M1015). Based on OpenBSD
changes with some improvements. Tested on IBM x3550M3 with RAID0 and RAID1
volumes including bioctl(8) operation.
 1.12.16.2.2.1 01-Nov-2012  matt sync with netbsd-6-0-RELEASE.
 1.12.14.1 05-Apr-2012  mrg sync to latest -current.
 1.12.10.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.10.2 30-Oct-2012  yamt sync with head
 1.12.10.1 17-Apr-2012  yamt sync with head
 1.17.4.1 18-May-2014  rmind sync with head
 1.17.2.2 03-Dec-2017  jdolecek update from HEAD
 1.17.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.6.1 05-Oct-2016  skrll Sync with HEAD
 1.19.18.1 10-Jun-2019  christos Sync with HEAD
 1.19.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.19.10.1 17-May-2022  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1454):
sys/dev/ic/mfi.c: revisions 1.63, 1.66-77
sys/dev/ic/mfireg.h: revisions 1.11-1.20 via patch
sys/dev/pci/mfi_pci.c: revision 1.21
sys/dev/pci/mfii.c: revisions 1.6-1.7, 1.10-1.15
share/man/man4/mfi.4: revision 1.13

Improve mfi(4) and mfii(4):
- Set 'ld_sync' to NULL as part of 'again', to prevent use-after-free.
- Add some code for the SKINNY variant to make Dell PERC H310 work.
- Print the percentage correctly when the background initialization is
running.
- Clear mailbox to not to pass garbage data.
- Use union mbox instead of unit8_t xxx[] to avoid unaligned access.
- Set stripe size for BIOCVOL to show the size correctly in bioctl.
- Add support for iBBU-09 to show BBU voltage, current and temperature
correctly.
- Fix typos in comments.
- Sprinkle static.
- Improve debug printf()s.
- KNF. Remove extra semicolon. Whitespace fixes.
 1.20.4.1 17-May-2022  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1454):
sys/dev/ic/mfi.c: revisions 1.63, 1.66-77
sys/dev/ic/mfireg.h: revisions 1.11-1.20 via patch
sys/dev/pci/mfi_pci.c: revision 1.21
sys/dev/pci/mfii.c: revisions 1.6-1.7, 1.10-1.15
share/man/man4/mfi.4: revision 1.13

Improve mfi(4) and mfii(4):
- Set 'ld_sync' to NULL as part of 'again', to prevent use-after-free.
- Add some code for the SKINNY variant to make Dell PERC H310 work.
- Print the percentage correctly when the background initialization is
running.
- Clear mailbox to not to pass garbage data.
- Use union mbox instead of unit8_t xxx[] to avoid unaligned access.
- Set stripe size for BIOCVOL to show the size correctly in bioctl.
- Add support for iBBU-09 to show BBU voltage, current and temperature
correctly.
- Fix typos in comments.
- Sprinkle static.
- Improve debug printf()s.
- KNF. Remove extra semicolon. Whitespace fixes.
 1.32 13-Feb-2024  msaitoh mfii(4): Apply two changes from OpenBSD to fix an unknown firmware state.

My own MegaRAID 946N-8i 2G", firmware 50.5.0-2594 failed to attach.

mfii0: unknown firmware state 1879048192

1879048192 equals to 0x70000000(== MFI_STATE_FW_INIT_2).
Apply following two OpenBSD commits to resolve this problem.
 1.31 05-Oct-2023  christos provide a separate pointer that points to the drive sensors (Edgar Fuss)
 1.30 23-Sep-2023  christos When attaching and detaching disks, use the proper index, skipping the
first 4, which are used for the controller itself (Edgar Fuss)
 1.29 22-Sep-2023  christos update present variable when disks are added or removed (Edgar Fuss)
 1.28 29-Sep-2022  bouyer Convert from pci_intr_map() to pci_intr_alloc(); makes the driver use
MSI/MSI-x when available. Tested by Edgar Fu�.
 1.27 14-Sep-2022  msaitoh mfii: Don't panic on detach.

Call sysmon_envsys_destroy() and clear sc->sc_sme to NULL if
sysmon_envsys_register failed.
 1.26 16-Jul-2022  msaitoh Enable Aero.
 1.25 16-Jul-2022  msaitoh It seems that a logical volume number and the target ID is different
on newer systems. It's observed on an Aero. Add sc->sc_ld[X].ld_target_id
to keep the target ID and use it for scsipi layer. Now sdX is attached
on Aero system. Tested by Mark Davies.
 1.24 16-Jul-2022  msaitoh Add max 256 VD support.
 1.23 09-Jul-2022  msaitoh Add preliminary support for Aero.

- Aero supports 32bit descriptor.
- Even if the Aero card supports 32bit descriptor, 64bit descriptor
access is required for MFI_CMD_INIT.
- Add quirk for Aero to retry register read.
- The PCI ID table for Aero is disabled. Even if it's enabled, any logical
volumes are not found. Perhaps the reason is that our mfii driver is
currently not supports more than 64 logical volumes and MR_DCMD_LD_GET_LIST
returns incorrect value. Tested by Mark Daies' H750.
 1.22 09-Jul-2022  msaitoh Use bus_space_write_8() if available.
 1.21 09-Jul-2022  msaitoh Modify strange bus_space_barrier().
 1.20 29-Jun-2022  msaitoh Add CVPM02 BBU support.
 1.19 27-Jun-2022  msaitoh KNF a little. No functional change.
 1.18 27-Jun-2022  msaitoh Add some MegaRAID devices (except Aero series). Not tested.
 1.17 27-Jun-2022  msaitoh Add comment. Sort entries. No functional change.
 1.16 22-Jun-2022  msaitoh Fix wrong access in mfii_start(). I hope this fixes kern/55192 and kern/56669.
 1.15 13-May-2022  msaitoh Fix compile error when MFII_DEBUG is set. Whitespace fix.
 1.14 12-May-2022  msaitoh Use IBBU's data structure for iBBU-09.
 1.13 11-May-2022  msaitoh Add support for iBBU-09 to show BBU voltage, current and temp correctly.
 1.12 11-May-2022  msaitoh mfii(4): Set stripe size correctly for BIOCVOL. Same as mfi.c rev. 1.75.
 1.11 07-May-2022  msaitoh Use mlp_bgi for MFI_LD_PROG_BGI. Same as OpenBSD.
 1.10 05-May-2022  msaitoh Whitespace.
 1.9 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.8 24-Apr-2021  thorpej branches: 1.8.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.7 14-May-2020  msaitoh branches: 1.7.4;
Remove extra semicolon.
 1.6 27-Nov-2019  maxv localify
 1.5 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.4 24-Apr-2019  bouyer branches: 1.4.2; 1.4.4;
Clean up timeout logic. Now the system survives to a ccb timeout; before
the filesystem would stall because one I/O did never completes.
 1.3 03-Dec-2018  bouyer branches: 1.3.2;
Update the mpii(4) driver to the latest OpenBSD version.
This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.
adjust mfii.c for changes in mpiireg.h

Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
 1.2 24-Nov-2018  bouyer branches: 1.2.2;
Add my name in copyright list
 1.1 24-Nov-2018  bouyer Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.
Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.
Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.
 1.2.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2.2.1 24-Nov-2018  pgoyette file mfii.c was added on branch pgoyette-compat on 2018-11-26 01:52:32 +0000
 1.3.2.7 29-Sep-2022  snj Pull up following revision(s) (requested by bouyer in ticket #1768):
sys/dev/pci/mfii.c: 1.28
Convert from pci_intr_map() to pci_intr_alloc(); makes the driver use
MSI/MSI-x when available. Tested by Edgar Fu?.
 1.3.2.6 16-Sep-2022  martin Pull up the following, requested by msaitoh in ticket #1764:

sys/dev/ic/mfireg.h 1.22
sys/dev/pci/mfii.c 1.16-1.22,1.27 via patch
share/man/man4/mfii.4 1.3 via patch

- Fix wrong access in mfii_start().
- Add SAS3216,SAS3224,SAS3316 and SAS3324 support.
- Add CVPM02 BBU support.
- Use bus_space_write_8() if available.
- Don't panic on detach if no any sensor device.
- Add comment. Sort entries. KNF.
 1.3.2.5 17-May-2022  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1454):
sys/dev/ic/mfi.c: revisions 1.63, 1.66-77
sys/dev/ic/mfireg.h: revisions 1.11-1.20 via patch
sys/dev/pci/mfi_pci.c: revision 1.21
sys/dev/pci/mfii.c: revisions 1.6-1.7, 1.10-1.15
share/man/man4/mfi.4: revision 1.13

Improve mfi(4) and mfii(4):
- Set 'ld_sync' to NULL as part of 'again', to prevent use-after-free.
- Add some code for the SKINNY variant to make Dell PERC H310 work.
- Print the percentage correctly when the background initialization is
running.
- Clear mailbox to not to pass garbage data.
- Use union mbox instead of unit8_t xxx[] to avoid unaligned access.
- Set stripe size for BIOCVOL to show the size correctly in bioctl.
- Add support for iBBU-09 to show BBU voltage, current and temperature
correctly.
- Fix typos in comments.
- Sprinkle static.
- Improve debug printf()s.
- KNF. Remove extra semicolon. Whitespace fixes.
 1.3.2.4 26-Apr-2019  martin Pull up following revision(s) (requested by bouyer in ticket #1247):

sys/dev/pci/mfii.c: revision 1.4

Clean up timeout logic. Now the system survives to a ccb timeout; before
the filesystem would stall because one I/O did never completes.
 1.3.2.3 08-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1131):

sys/dev/pci/mpiireg.h: revision 1.2
sys/dev/pci/mfii.c: revision 1.3
share/man/man4/mpii.4: revision 1.3
share/man/man4/mpii.4: revision 1.4
sys/dev/pci/mpii.c: revision 1.15
sys/dev/pci/mpii.c: revision 1.16
sys/dev/pci/mpii.c: revision 1.17
sys/dev/pci/mpii.c: revision 1.18

Update the mpii(4) driver to the latest OpenBSD version.

This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.

adjust mfii.c for changes in mpiireg.h

Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
Update for the new mpii(4) driver, mostly from OpenBSD.

Also tell the scsi layer that we are MPSAFE

Remove trailing whitespace

NULL-terminate mpii_devices[], this is the end condition of the loop
in mpii_match(). Noticed by Mike Pumford

There's no sensors for physical disks so don't try to detach them.
 1.3.2.2 07-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1129):

sys/arch/amd64/conf/XEN3_DOM0: revision 1.159
sys/arch/amd64/conf/GENERIC: revision 1.508
sys/arch/i386/conf/ALL: revision 1.458
sys/dev/ic/mfi.c: revision 1.60
sys/dev/pci/mpiireg.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1628
sys/dev/pci/mfii.c: revision 1.1,1.2 (adapted)
sys/arch/i386/conf/GENERIC: revision 1.1194
sys/dev/pci/mpii.c: revision 1.13
sys/dev/ic/mfireg.h: revision 1.9
share/man/man4/mfii.4: revision 1.1
share/man/man4/Makefile: revision 1.673 (patch)
sys/dev/pci/files.pci: revision 1.410
share/man/man4/mfii.4: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.108
sys/arch/i386/conf/XEN3PAE_DOM0: revision 1.8 (patch, in XEN3_DOM0)

Add some definitions from OpenBSD, needed by the upcoming mfii driver.
No functionnal change.

-

Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.

-

Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.

Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.

Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.

-

Add my name in copyright list

-

add a man page for the new mpii, mostly from OpenBSD.

-

Sort SEE ALSO. Fix date. Whitespace fixes.
 1.3.2.1 03-Dec-2018  martin file mfii.c was added on branch netbsd-8 on 2018-12-07 17:11:37 +0000
 1.4.4.3 29-Sep-2022  martin Pull up following revision(s) (requested by bouyer in ticket #1534):

sys/dev/pci/mfii.c: revision 1.28

Convert from pci_intr_map() to pci_intr_alloc(); makes the driver use
MSI/MSI-x when available. Tested by Edgar Fu?.
 1.4.4.2 16-Sep-2022  martin Pull up the following, requested by msaitoh in ticket #1524:

sys/dev/ic/mfireg.h 1.22
sys/dev/pci/mfii.c 1.16-1.22,1.27 via patch
share/man/man4/mfii.4 1.3 via patch

- Fix wrong access in mfii_start().
- Add SAS3216,SAS3224,SAS3316 and SAS3324 support.
- Add CVPM02 BBU support.
- Use bus_space_write_8() if available.
- Don't panic on detach if no any sensor device.
- Add comment. Sort entries. KNF.
 1.4.4.1 17-May-2022  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1454):
sys/dev/ic/mfi.c: revisions 1.63, 1.66-77
sys/dev/ic/mfireg.h: revisions 1.11-1.20 via patch
sys/dev/pci/mfi_pci.c: revision 1.21
sys/dev/pci/mfii.c: revisions 1.6-1.7, 1.10-1.15
share/man/man4/mfi.4: revision 1.13

Improve mfi(4) and mfii(4):
- Set 'ld_sync' to NULL as part of 'again', to prevent use-after-free.
- Add some code for the SKINNY variant to make Dell PERC H310 work.
- Print the percentage correctly when the background initialization is
running.
- Clear mailbox to not to pass garbage data.
- Use union mbox instead of unit8_t xxx[] to avoid unaligned access.
- Set stripe size for BIOCVOL to show the size correctly in bioctl.
- Add support for iBBU-09 to show BBU voltage, current and temperature
correctly.
- Fix typos in comments.
- Sprinkle static.
- Improve debug printf()s.
- KNF. Remove extra semicolon. Whitespace fixes.
 1.4.2.4 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.2.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.2.2 10-Jun-2019  christos Sync with HEAD
 1.4.2.1 24-Apr-2019  christos file mfii.c was added on branch phil-wifi on 2019-06-10 22:07:17 +0000
 1.7.4.3 28-Mar-2021  thorpej No need to pass interface attribute or locators to config_found().
 1.7.4.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.7.4.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.8.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.28 24-Apr-2021  thorpej Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.27 09-Dec-2018  jdolecek branches: 1.27.14;
use pci_intr_establish_xname() everywhere
 1.26 27-Sep-2016  pgoyette branches: 1.26.14; 1.26.16;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.25 29-Mar-2014  christos branches: 1.25.6; 1.25.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.24 27-Oct-2012  chs branches: 1.24.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.23 26-Nov-2009  njoly branches: 1.23.12; 1.23.22;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.22 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.21 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.20 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.19 28-Apr-2008  martin branches: 1.19.14;
Remove clause 3 and 4 from TNF licenses
 1.18 10-Apr-2008  cegger branches: 1.18.2; 1.18.4;
use aprint_*_dev and device_xname
 1.17 19-Oct-2007  ad branches: 1.17.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 16-Nov-2006  christos branches: 1.16.8; 1.16.22; 1.16.24; 1.16.28;
__unused removal on arguments; approved by core.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 02-Sep-2006  christos branches: 1.14.2; 1.14.4;
static goes first
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.8;
merge ktrace-lwp.
 1.12 27-Feb-2005  perry branches: 1.12.4;
nuke trailing whitespace
 1.11 02-Oct-2002  thorpej branches: 1.11.6; 1.11.14; 1.11.16;
Add trailing ; to CFATTACH_DECL.
 1.10 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.9 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.8 31-Aug-2002  ad Nuke incorrect mailbox length defines and just use 13 everywhere. May help
with PR/14266.
 1.7 26-Aug-2002  ad Handle aincent firmware as found on EISA/MCA boards. Untested.
 1.6 13-Nov-2001  lukem branches: 1.6.8; 1.6.10;
add RCSID
 1.5 26-Jul-2001  ad branches: 1.5.6;
Map both memory and IO space, but prefer using memory space.
 1.4 26-Jul-2001  ad Don't map I/O space if we have already have a good memory mapping.
 1.3 15-May-2001  ad branches: 1.3.2;
Correct arguments to bus_dmamap_create(), and add a reset routine for the v3
interface.
 1.2 18-Feb-2001  mjacob branches: 1.2.2;
Make it compile (for alpha). The porting author might want to look
at this more closely than I have.
 1.1 04-Feb-2001  ad branches: 1.1.2;
Add a driver for the Mylex DAC960 family (including DEC SWXCR).
 1.1.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 04-Feb-2001  bouyer file mlx_pci.c was added on branch thorpej_scsipi on 2001-02-11 19:15:58 +0000
 1.2.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.2.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 03-Aug-2001  lukem update to -current
 1.5.6.2 25-Oct-2001  he Pull up revisions 1.1-1.5 (new, via patch, requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.5.6.1 26-Jul-2001  he file mlx_pci.c was added on branch netbsd-1-5 on 2001-10-25 18:02:41 +0000
 1.6.10.1 28-Jul-2003  he Pull up revisions 1.7-1.8 (requested by ad in ticket #1128):
Improve stability of the mlx driver.
o Better handling of old firmware
o Use correct mailbox length, fixes PR#14266
 1.6.8.2 31-Aug-2002  gehenna catch up with -current.
 1.6.8.1 29-Aug-2002  gehenna catch up with -current.
 1.11.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.14.1 29-Apr-2005  kent sync with -current
 1.11.6.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.4.2 27-Oct-2007  yamt sync with head.
 1.12.4.1 30-Dec-2006  yamt sync with head.
 1.13.8.1 03-Sep-2006  yamt sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.4.2 10-Dec-2006  yamt sync with head.
 1.14.4.1 22-Oct-2006  yamt sync with head
 1.14.2.1 18-Nov-2006  ad Sync with head.
 1.16.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.24.1 06-Nov-2007  matt sync with HEAD
 1.16.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.8.1 23-Oct-2007  ad Sync with head.
 1.17.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.4.3 11-Mar-2010  yamt sync with head
 1.18.4.2 16-May-2009  yamt sync with head
 1.18.4.1 16-May-2008  yamt sync with head.
 1.18.2.1 18-May-2008  yamt sync with head.
 1.19.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.22.3 03-Dec-2017  jdolecek update from HEAD
 1.23.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.23.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.12.1 30-Oct-2012  yamt sync with head
 1.24.2.1 18-May-2014  rmind sync with head
 1.25.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.25.6.1 05-Oct-2016  skrll Sync with HEAD
 1.26.16.1 10-Jun-2019  christos Sync with HEAD
 1.26.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.27.14.1 28-Mar-2021  thorpej Correct the names of the arguments passed to the rescan function.
 1.56 03-Sep-2021  andvar s/existant/existent/ in comments and messages, plus few more similar fixes.
 1.55 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.54 24-Apr-2021  thorpej branches: 1.54.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.53 10-Nov-2019  chs branches: 1.53.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.52 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.51 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.50 07-Jul-2016  msaitoh branches: 1.50.16; 1.50.18;
KNF. Remove extra spaces. No functional change.
 1.49 25-Jul-2014  dholland branches: 1.49.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.48 29-Mar-2014  christos branches: 1.48.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.47 16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.46 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.45 27-Oct-2012  chs branches: 1.45.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.44 13-Nov-2010  uebayasi branches: 1.44.8; 1.44.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.43 26-Nov-2009  njoly branches: 1.43.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.42 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.41 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.40 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.39 08-Jun-2008  tsutsui branches: 1.39.12;
Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
 1.38 28-Apr-2008  martin branches: 1.38.2;
Remove clause 3 and 4 from TNF licenses
 1.37 10-Apr-2008  cegger branches: 1.37.2; 1.37.4;
use aprint_*_dev and device_xname
 1.36 19-Oct-2007  ad branches: 1.36.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.35 09-Jul-2007  ad branches: 1.35.6; 1.35.8; 1.35.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.34 04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 02-Dec-2006  elad branches: 1.33.2;
Change kauth(9) KPI for kauth_authorize_device_passthru() to add another
argument, u_long, serving as a bit-mask of generic requests for the
passthru request.

Discussed on tech-security@ and tech-kern@. Okay tls@.
 1.32 16-Nov-2006  christos branches: 1.32.2;
__unused removal on arguments; approved by core.
 1.31 08-Nov-2006  elad Replace securelevel checks with kauth(9) calls.
 1.30 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.29 02-Sep-2006  christos branches: 1.29.2; 1.29.4;
- fix incomplete initializer
- static goes first
 1.28 23-Aug-2006  christos Acting as Elad's keyboard:

Place the securelevel checks in their logical locations.
This will be clearer in the future when code changes to use kauth(9) calls.

input and okay ad@
 1.27 14-May-2006  elad integrate kauth.
 1.26 14-Apr-2006  christos Coverity CID 1103: Avoid NULL pointer deref.
 1.25 14-Apr-2006  christos Coverity CID 2439: Remove bogus test.
 1.24 11-Dec-2005  christos branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10; 1.24.12;
merge ktrace-lwp.
 1.23 27-Feb-2005  perry branches: 1.23.4;
nuke trailing whitespace
 1.22 21-Feb-2005  thorpej Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding. Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes. Place items described
by the SCSI Primary Commands document into scsi_spc.h.
 1.21 29-Jun-2003  fvdl branches: 1.21.2; 1.21.10; 1.21.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.20 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.19 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.18 31-Mar-2003  perry For consistency, initialise->initialize.
(No it isn't anti-UK bias -- just trying to keep the whole system to
one consistent spelling.)
 1.17 06-Jan-2003  wiz interrupt with two rs.
 1.16 25-Nov-2002  thorpej Avoid strict-alias warnings.
 1.15 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.14 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.13 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.10 01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.9 14-Jan-2002  tsutsui branches: 1.9.8;
Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.8 13-Nov-2001  lukem add RCSID
 1.7 03-Aug-2001  ad branches: 1.7.2; 1.7.4;
Remove unnecessary test.
 1.6 01-Aug-2001  ad branches: 1.6.2;
Hook in the mly control interface on i386.
 1.5 31-Jul-2001  ad Oops, put back the initalization of "done" in mly_thread().
 1.4 30-Jul-2001  ad Assume that me->lun contains the device number if this event is for a
logical device.
 1.3 30-Jul-2001  ad - Forget to report events from logical devices.
- Cosmetic changes.
 1.2 30-Jul-2001  ad Don't match boards with a PCI class code of `I2O'.
 1.1 30-Jul-2001  ad Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.6.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.5 11-Feb-2002  jdolecek Sync w/ -current.
 1.6.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.3 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.6.2.2 03-Aug-2001  lukem update to -current
 1.6.2.1 01-Aug-2001  lukem file mly.c was added on branch kqueue on 2001-08-03 04:13:18 +0000
 1.7.4.3 01-Oct-2001  fvdl Catch up with -current.
 1.7.4.2 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.7.4.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.7.2.10 07-Jan-2003  thorpej Sync with HEAD.
 1.7.2.9 11-Dec-2002  thorpej Sync with HEAD.
 1.7.2.8 11-Nov-2002  nathanw Catch up to -current
 1.7.2.7 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.6 17-Sep-2002  nathanw Catch up to -current.
 1.7.2.5 20-Jun-2002  nathanw Catch up to -current.
 1.7.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.7.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.7.2.1 03-Aug-2001  nathanw file mly.c was added on branch nathanw_sa on 2001-08-24 00:10:13 +0000
 1.9.8.2 20-Jun-2002  gehenna catch up with -current.
 1.9.8.1 16-May-2002  gehenna Add the character device switch.
 1.21.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.10.1 29-Apr-2005  kent sync with -current
 1.21.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.23.4.4 27-Oct-2007  yamt sync with head.
 1.23.4.3 03-Sep-2007  yamt sync with head.
 1.23.4.2 30-Dec-2006  yamt sync with head.
 1.23.4.1 21-Jun-2006  yamt sync with head.
 1.24.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.24.10.1 19-Apr-2006  elad sync with head.
 1.24.8.2 03-Sep-2006  yamt sync with head.
 1.24.8.1 24-May-2006  yamt sync with head.
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.29.4.2 10-Dec-2006  yamt sync with head.
 1.29.4.1 22-Oct-2006  yamt sync with head
 1.29.2.2 12-Jan-2007  ad Sync with head.
 1.29.2.1 18-Nov-2006  ad Sync with head.
 1.32.2.1 04-Dec-2006  tron Pull up following revision(s) (requested by elad in ticket #247):
sys/dev/ic/dpt.c: revision 1.55
sys/dev/pci/amr.c: revision 1.43
sys/secmodel/bsd44/secmodel_bsd44_securelevel.c: revision 1.19
sys/dev/pci/mly.c: revision 1.33
share/man/man9/kauth.9: revision 1.37
sys/dev/ic/mlx.c: revision 1.49
sys/dev/ic/icp_ioctl.c: revision 1.14
sys/dev/i2o/iop.c: revision 1.62
sys/dev/pci/twe.c: revision 1.82
sys/sys/kauth.h: revision 1.25
sys/dev/i2o/dpti.c: revision 1.31
sys/kern/kern_auth.c: revision 1.33
sys/dev/tc/stic.c: revision 1.37
Change kauth(9) KPI for kauth_authorize_device_passthru() to add another
argument, u_long, serving as a bit-mask of generic requests for the
passthru request.
Discussed on tech-security@ and tech-kern@. Okay tls@.
 1.33.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.4 23-Oct-2007  ad Sync with head.
 1.34.2.3 13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.34.2.2 10-Apr-2007  ad Nuke the deferred kthread creation stuff, as it's no longer needed.
Pointed out by thorpej@.
 1.34.2.1 09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.35.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.35.8.1 06-Nov-2007  matt sync with HEAD
 1.35.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.36.16.3 29-Jun-2008  mjf Sync with HEAD.
 1.36.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.36.16.1 05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.37.4.4 11-Mar-2010  yamt sync with head
 1.37.4.3 16-May-2009  yamt sync with head
 1.37.4.2 04-May-2009  yamt sync with head.
 1.37.4.1 16-May-2008  yamt sync with head.
 1.37.2.2 17-Jun-2008  yamt sync with head.
 1.37.2.1 18-May-2008  yamt sync with head.
 1.38.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.39.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.43.4.1 05-Mar-2011  rmind sync with head
 1.44.18.3 03-Dec-2017  jdolecek update from HEAD
 1.44.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.44.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.44.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.44.8.1 30-Oct-2012  yamt sync with head
 1.45.2.1 18-May-2014  rmind sync with head
 1.48.2.1 10-Aug-2014  tls Rebase.
 1.49.4.1 09-Jul-2016  skrll Sync with HEAD
 1.50.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.18.1 10-Jun-2019  christos Sync with HEAD
 1.50.16.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.50.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.53.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.54.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.70; 1.5.72; 1.5.74;
merge ktrace-lwp.
 1.4 27-Feb-2005  perry nuke trailing whitespace
 1.3 31-Mar-2003  perry branches: 1.3.2; 1.3.10; 1.3.12;
revert for now -- cancelled seems to be used more often than canceled
 1.2 31-Mar-2003  perry again, for consistency, cancelled->canceled (I fear the flames)
 1.1 30-Jul-2001  ad branches: 1.1.2; 1.1.4;
Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 30-Jul-2001  nathanw file mly_tables.h was added on branch nathanw_sa on 2001-08-24 00:10:13 +0000
 1.1.2.2 03-Aug-2001  lukem update to -current
 1.1.2.1 30-Jul-2001  lukem file mly_tables.h was added on branch kqueue on 2001-08-03 04:13:18 +0000
 1.3.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.10.1 29-Apr-2005  kent sync with -current
 1.3.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.74.1 16-May-2008  yamt sync with head.
 1.5.72.1 18-May-2008  yamt sync with head.
 1.5.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.5 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.4 28-Apr-2008  martin branches: 1.4.44; 1.4.64;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.70; 1.3.72; 1.3.74;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 30-Jul-2001  ad branches: 1.1.2; 1.1.4; 1.1.24; 1.1.32; 1.1.34;
Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.1.34.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.32.1 29-Apr-2005  kent sync with -current
 1.1.24.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 30-Jul-2001  nathanw file mlyio.h was added on branch nathanw_sa on 2001-08-24 00:10:14 +0000
 1.1.2.2 03-Aug-2001  lukem update to -current
 1.1.2.1 30-Jul-2001  lukem file mlyio.h was added on branch kqueue on 2001-08-03 04:13:18 +0000
 1.3.74.1 16-May-2008  yamt sync with head.
 1.3.72.1 18-May-2008  yamt sync with head.
 1.3.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.64.1 22-Sep-2015  skrll Sync with HEAD
 1.4.44.1 03-Dec-2017  jdolecek update from HEAD
 1.9 10-Feb-2024  andvar fix various typos in comments and log messages.
 1.8 24-Oct-2021  andvar fix various typos in comments, mainly copypasta.
 1.7 28-Dec-2019  gutteridge Fix typo in comment.
 1.6 21-Nov-2017  maxv branches: 1.6.4;
Mmh, surprising bug. It's __packed, not __packed__. Here the structure is
not packed for real, but instead a global __packed__ symbol is declared.
 1.5 08-Sep-2008  gmcgarry branches: 1.5.38; 1.5.74;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.4 28-Apr-2008  martin branches: 1.4.2; 1.4.6;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.70; 1.3.72; 1.3.74;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 30-Jul-2001  ad branches: 1.1.2; 1.1.4; 1.1.24; 1.1.32; 1.1.34;
Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.1.34.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.32.1 29-Apr-2005  kent sync with -current
 1.1.24.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 30-Jul-2001  nathanw file mlyreg.h was added on branch nathanw_sa on 2001-08-24 00:10:14 +0000
 1.1.2.2 03-Aug-2001  lukem update to -current
 1.1.2.1 30-Jul-2001  lukem file mlyreg.h was added on branch kqueue on 2001-08-03 04:13:18 +0000
 1.3.74.2 04-May-2009  yamt sync with head.
 1.3.74.1 16-May-2008  yamt sync with head.
 1.3.72.1 18-May-2008  yamt sync with head.
 1.3.70.2 28-Sep-2008  mjf Sync with HEAD.
 1.3.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.6.1 19-Oct-2008  haad Sync with HEAD.
 1.4.2.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.5.74.1 27-Nov-2017  martin Pull up following revision(s) (requested by maxv in ticket #399):
sys/dev/pci/mlyreg.h: revision 1.6
Mmh, surprising bug. It's __packed, not __packed__. Here the structure is
not packed for real, but instead a global __packed__ symbol is declared.
 1.5.38.1 03-Dec-2017  jdolecek update from HEAD
 1.6.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.5 28-Apr-2008  martin branches: 1.5.34; 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 09-Jul-2007  ad branches: 1.4.28; 1.4.30; 1.4.32;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.3 16-Feb-2006  perry branches: 1.3.24; 1.3.26;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.2 24-Dec-2005  perry branches: 1.2.2; 1.2.4; 1.2.6;
__inline__ -> inline
 1.1 30-Jul-2001  ad branches: 1.1.2; 1.1.4; 1.1.40;
Add a driver for Mylex AcceleRAID and eXtremeRAID controllers with v6
firmware. Based off the FreeBSD driver, and re-worked by tls, erh and I.
 1.1.40.2 03-Sep-2007  yamt sync with head.
 1.1.40.1 21-Jun-2006  yamt sync with head.
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 30-Jul-2001  nathanw file mlyvar.h was added on branch nathanw_sa on 2001-08-24 00:10:14 +0000
 1.1.2.2 03-Aug-2001  lukem update to -current
 1.1.2.1 30-Jul-2001  lukem file mlyvar.h was added on branch kqueue on 2001-08-03 04:13:18 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 18-Feb-2006  yamt sync with head.
 1.3.26.1 11-Jul-2007  mjf Sync with head.
 1.3.24.1 09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.4.32.1 16-May-2008  yamt sync with head.
 1.4.30.1 18-May-2008  yamt sync with head.
 1.4.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.44.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.44.1 12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.5.34.1 30-Oct-2012  yamt sync with head
 1.31 04-Feb-2024  andvar s/substract/subtract/ in comments.
 1.30 25-Oct-2023  buhrow Fixes for PR kern/57133:

I can now explain why this assert is firing and have a fix for it. It is a
regression introduced in R1.22 of mpii.c.

If a request comes in and the IOC returns a MPII_SCSIIO_STATUS_CHECK_COND condition, after
a successful transfer, or one that is a recovered error,
mpii(4) correctly sets the xs->error to XS_SENSE, but incorrectly sets xs->resid to 0 before
returning the xfer to the upper scsi layers. Once the upper layers get it, they notice the
XS_SENSE check condition and because it's a retryable error, they increment xs_requeuecnt, set
ERESTART and send the xfer request down to the mpii(4) layer again for a retry. What they do
not do is reset xs->resid equal to xs->datalen. When the xfer comes down to mpii(4) again, the
assert happens. The fix is for the mpii(4) driver to leave xs->resid alone when it encounters
a MPII_SCSIIO_STATUS_CHECK_COND condition.

This bug affects NetBSD-10, netbsd-9 and netbsd-8.
 1.29 07-Aug-2021  thorpej branches: 1.29.6;
Merge thorpej-cfargs2.
 1.28 24-Apr-2021  thorpej branches: 1.28.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.27 23-Feb-2021  skrll branches: 1.27.2;
Whitespace (mostly trailing)
 1.26 23-Feb-2021  skrll Use the PCI_MAPREG_TYPE macro. No binary change.
 1.25 08-Aug-2020  jnemeth branches: 1.25.2;
make this compile without bio(4)
 1.24 28-Nov-2019  maxv localify
 1.23 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.22 11-Mar-2019  kardel branches: 1.22.4;
PR/54045

fix mpii to adhere to physio diagnostic invariant that
fully processed data must not post an error:
1) verify expected scspi state via KASSERT() instead of just
setting the variables.
2) set xs->resid only in known good conditions
3) insure setting errors in all error paths and refrain
from clearing xs->resid in error paths.

While there do some cosmectic clean up:
1) extend and relocate some debug output
2) mpii HBAs can also manage non-disk devices like tapes etc,
so log that physical "devices" instead of physical "disks" are
attached or detached.

Tested with NEOSeries FlexStor II and luckily a broken tape drive 8-(

mpii0 at pci1 dev 0 function 0: vendor 1000 product 00ab (rev. 0x01)
mpii0: interrupting at irq 11
mpii0: HBA 9400-8i8e, firmware 3.0.4.0, MPI 2.6
mpii0: physical device inserted in slot 9
mpii0: physical device inserted in slot 13
mpii0: physical device inserted in slot 16
st0 at scsibus0 target 9 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st0: density code 92, variable blocks, write-enabled
ch0 at scsibus0 target 9 lun 1: <BDT, FlexStor II, 5.50> changer removable
ch0: 23 slots, 2 drives, 1 picker, 1 portal
st0: tagged queueing
ch0: tagged queueing
st1 at scsibus0 target 13 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st1: density code 92, variable blocks, write-enabled
st1: tagged queueing
ses0 at scsibus0 target 16 lun 0: <LSI, VirtualSES, 01> enclosure services fixed

Note: pullup-8
 1.21 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.20 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.19 28-Dec-2018  kardel fix LUN handling (byte order issue)

now ch0 on a NEOSeries FlexStor II is detected again on LUN 1
this is a regression introduced in 1.15 update and 1.8.10.3 pullup

Tested with NEOSeries FlexStor II:
mpii0 at pci1 dev 0 function 0: vendor 1000 product 00ab (rev. 0x01)
mpii0: interrupting at irq 11
mpii0: HBA 9400-8i8e, firmware 3.0.4.0, MPI 2.6
mpii0: physical disk inserted in slot 9
mpii0: physical disk inserted in slot 13
mpii0: physical disk inserted in slot 16
st0 at scsibus0 target 9 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st0: drive empty
st0: tagged queueing
st1 at scsibus0 target 13 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st1: drive empty
ch0 at scsibus0 target 13 lun 1: <BDT, FlexStor II, 5.50> changer removable
ch0: 23 slots, 2 drives, 1 picker, 1 portal
st1: tagged queueing
ch0: tagged queueing
ses0 at scsibus0 target 16 lun 0: <LSI, VirtualSES, 01> enclosure services fixed
ses0: SCSI-3 SES Device
 1.18 05-Dec-2018  bouyer There's no sensors for physical disks so don't try to detach them.
 1.17 04-Dec-2018  bouyer NULL-terminate mpii_devices[], this is the end condition of the loop
in mpii_match(). Noticed by Mike Pumford
 1.16 03-Dec-2018  bouyer Also tell the scsi layer that we are MPSAFE
 1.15 03-Dec-2018  bouyer Update the mpii(4) driver to the latest OpenBSD version.
This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.
adjust mfii.c for changes in mpiireg.h

Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
 1.14 02-Dec-2018  jdolecek use pci_intr_establish_xname()
 1.13 24-Nov-2018  bouyer Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.
 1.12 14-Oct-2018  jdolecek remove M_CANFAIL flag for malloc(9) - it was completely ignored, so had
actually no effect
 1.11 15-Jan-2018  maya branches: 1.11.2; 1.11.4;
indent to magic logic
 1.10 09-Oct-2017  maya Reorder to avoid null deref before null test
 1.9 25-Jun-2017  christos PR/52330: Jia-Ju Bai: mpii driver: a sleep-in-interrupt bug in mpii_intr
Since the enclosing routime mpii_event_raid already calls malloc with
M_NOWAIT, fix the cache routine to do the same. While there check the
result of the cache routine and change some error prints to aprint.
 1.8 02-May-2016  christos branches: 1.8.10;
move scsipi_strvis -> libkern:strnvisx()
change the prototype to match userland
fix sizes of strings passed to it
 1.7 08-Feb-2016  christos PR/50785: David Binderman: Remove dead code.
 1.6 12-Mar-2015  christos Dedup the conversion of bioc_disk and bioc_vol to envsys_data_t
 1.5 29-Mar-2014  christos branches: 1.5.4; 1.5.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.4 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.3 09-Aug-2013  kardel fix issues when reading variable block sized tapes.

symptoms:
generic HBA error on console when reading
with a larger blocksize. blocks read
are padded to requested block size with
a 5a... a5... pattern.

problems fixed:
- controller scsi_status values did not match
the ones used by the spsipi layer.
a mapping function was introduced.
- when experiencing an underrun (read 64k and
get a 63k block) the controller posted
not a SUCCESS status but CHECK status. handle
that like SUCCESS adjusting xs->resid and set
XS_SENSE.
now the correct data amount is returned and
nothing is 'added' and no 'generic HBA error'
occurs.
- make decisions using variables and constants
from the controller domain.
 1.2 08-Aug-2013  kardel Allow 8 luns instead of 1. This enables access to the changer device on
a Dell PV-124T:
ch0 at scsibus0 target 9 lun 1: <DELL, PV-124T, 0086> changer removable
ch0: 16 slots, 1 drive, 1 picker, 0 portals
 1.1 19-Apr-2012  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add mpii(4), a driver for LSI Logic Fusion-MPT Message Passing Interface II
SAS controllers. Ported from OpenBSD.
 1.1.10.2 18-May-2014  rmind sync with head
 1.1.10.1 28-Aug-2013  rmind sync with head
 1.1.8.2 03-Dec-2017  jdolecek update from HEAD
 1.1.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.2 23-May-2012  yamt sync with head.
 1.1.6.1 19-Apr-2012  yamt file mpii.c was added on branch yamt-pagecache on 2012-05-23 10:07:58 +0000
 1.1.4.2 29-Apr-2012  mrg sync to latest -current.
 1.1.4.1 19-Apr-2012  mrg file mpii.c was added on branch jmcneill-usbmp on 2012-04-29 23:04:51 +0000
 1.1.2.3 07-Sep-2013  bouyer Pull up following revision(s) (requested by kardel in ticket #932):
sys/dev/pci/mpii.c: revision 1.2
sys/dev/pci/mpii.c: revision 1.3
Allow 8 luns instead of 1. This enables access to the changer device on
a Dell PV-124T:
ch0 at scsibus0 target 9 lun 1: <DELL, PV-124T, 0086> changer removable
ch0: 16 slots, 1 drive, 1 picker, 0 portals
fix issues when reading variable block sized tapes.
symptoms:
generic HBA error on console when reading
with a larger blocksize. blocks read
are padded to requested block size with
a 5a... a5... pattern.
problems fixed:
- controller scsi_status values did not match
the ones used by the spsipi layer.
a mapping function was introduced.
- when experiencing an underrun (read 64k and
get a 63k block) the controller posted
not a SUCCESS status but CHECK status. handle
that like SUCCESS adjusting xs->resid and set
XS_SENSE.
now the correct data amount is returned and
nothing is 'added' and no 'generic HBA error'
occurs.
- make decisions using variables and constants
from the controller domain.
 1.1.2.2 23-Apr-2012  riz Pull up following revision(s) (requested by bouyer in ticket #193):
sys/arch/i386/conf/GENERIC: revision 1.1072
sys/dev/pci/mpii.c: revision 1.1
sys/arch/i386/conf/XEN3_DOM0: revision 1.66
sys/dev/pci/files.pci: revision 1.357
share/man/man4/Makefile: revision 1.584
distrib/sets/lists/man/mi: revision 1.1387
share/man/man4/mpii.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.354
sys/arch/amd64/conf/XEN3_DOM0: revision 1.83
sys/arch/i386/conf/ALL: revision 1.337
Add mpii(4), a driver for LSI Logic Fusion-MPT Message Passing Interface II
SAS controllers. Ported from OpenBSD.
 1.1.2.1 19-Apr-2012  riz file mpii.c was added on branch netbsd-6 on 2012-04-23 16:31:36 +0000
 1.5.6.4 28-Aug-2017  skrll Sync with HEAD
 1.5.6.3 29-May-2016  skrll Sync with HEAD
 1.5.6.2 19-Mar-2016  skrll Sync with HEAD
 1.5.6.1 06-Apr-2015  skrll Sync with HEAD
 1.5.4.1 06-Jun-2018  martin Pull up following revision(s) (requested by maya in ticket #1614):

sys/dev/pci/mpii.c: revision 1.9

PR/52330: Jia-Ju Bai: mpii driver: a sleep-in-interrupt bug in mpii_intr
Since the enclosing routime mpii_event_raid already calls malloc with
M_NOWAIT, fix the cache routine to do the same. While there check the
result of the cache routine and change some error prints to aprint.
 1.8.10.8 26-Oct-2023  martin Pull up following revision(s) (requested by buhrow in ticket #1916):

sys/dev/pci/mpii.c: revision 1.30

Fixes for PR kern/57133:

I can now explain why this assert is firing and have a fix for it. It is a regression introduced in R1.22 of mpii.c.

If a request comes in and the IOC returns a MPII_SCSIIO_STATUS_CHECK_COND condition, after
a successful transfer, or one that is a recovered error,
mpii(4) correctly sets the xs->error to XS_SENSE, but incorrectly sets xs->resid to 0 before
returning the xfer to the upper scsi layers. Once the upper layers get it, they notice the
XS_SENSE check condition and because it's a retryable error, they increment xs_requeuecnt, set
ERESTART and send the xfer request down to the mpii(4) layer again for a retry. What they do
not do is reset xs->resid equal to xs->datalen. When the xfer comes down to mpii(4) again, the
assert happens. The fix is for the mpii(4) driver to leave xs->resid alone when it encounters
a MPII_SCSIIO_STATUS_CHECK_COND condition.

This bug affects NetBSD-10, netbsd-9 and netbsd-8.
 1.8.10.7 29-Sep-2022  snj Apply patch (requested by bouyer in ticket #1767):
Convert from pci_intr_map() to pci_intr_alloc(); makes the driver use
MSI/MSI-x when available.
 1.8.10.6 09-Aug-2020  martin Pull up following revision(s) (requested by jnemeth in ticket #1596):

sys/dev/pci/mpii.c: revision 1.25

make this compile without bio(4)
 1.8.10.5 15-Mar-2019  martin Pull up following revision(s) (requested by kardel in ticket #1217):

sys/dev/pci/mpii.c: revision 1.22

PR/54045

fix mpii to adhere to physio diagnostic invariant that
fully processed data must not post an error:

1) verify expected scspi state via KASSERT() instead of just
setting the variables.
2) set xs->resid only in known good conditions
3) insure setting errors in all error paths and refrain
from clearing xs->resid in error paths.

While there do some cosmectic clean up:
1) extend and relocate some debug output
2) mpii HBAs can also manage non-disk devices like tapes etc,
so log that physical "devices" instead of physical "disks" are
attached or detached.

Tested with NEOSeries FlexStor II and luckily a broken tape drive 8-(

mpii0 at pci1 dev 0 function 0: vendor 1000 product 00ab (rev. 0x01)
mpii0: interrupting at irq 11
mpii0: HBA 9400-8i8e, firmware 3.0.4.0, MPI 2.6
mpii0: physical device inserted in slot 9
mpii0: physical device inserted in slot 13
mpii0: physical device inserted in slot 16
st0 at scsibus0 target 9 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st0: density code 92, variable blocks, write-enabled
ch0 at scsibus0 target 9 lun 1: <BDT, FlexStor II, 5.50> changer removable
ch0: 23 slots, 2 drives, 1 picker, 1 portal
st0: tagged queueing
ch0: tagged queueing
st1 at scsibus0 target 13 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st1: density code 92, variable blocks, write-enabled
st1: tagged queueing
ses0 at scsibus0 target 16 lun 0: <LSI, VirtualSES, 01> enclosure
services fixed

Note: pullup-8
 1.8.10.4 07-Jan-2019  martin Pull up following revision(s) (requested by kardel in ticket #1157):

sys/dev/pci/mpii.c: revision 1.19

fix LUN handling (byte order issue)

now ch0 on a NEOSeries FlexStor II is detected again on LUN 1
this is a regression introduced in 1.15 update and 1.8.10.3 pullup

Tested with NEOSeries FlexStor II:
mpii0 at pci1 dev 0 function 0: vendor 1000 product 00ab (rev. 0x01)
mpii0: interrupting at irq 11
mpii0: HBA 9400-8i8e, firmware 3.0.4.0, MPI 2.6
mpii0: physical disk inserted in slot 9
mpii0: physical disk inserted in slot 13
mpii0: physical disk inserted in slot 16
st0 at scsibus0 target 9 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st0: drive empty
st0: tagged queueing
st1 at scsibus0 target 13 lun 0: <IBM, ULTRIUM-HH7, J4D1> tape removable
st1: drive empty
ch0 at scsibus0 target 13 lun 1: <BDT, FlexStor II, 5.50> changer removable
ch0: 23 slots, 2 drives, 1 picker, 1 portal
st1: tagged queueing
ch0: tagged queueing
ses0 at scsibus0 target 16 lun 0: <LSI, VirtualSES, 01> enclosure
services fixed
ses0: SCSI-3 SES Device
 1.8.10.3 08-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1131):

sys/dev/pci/mpiireg.h: revision 1.2
sys/dev/pci/mfii.c: revision 1.3
share/man/man4/mpii.4: revision 1.3
share/man/man4/mpii.4: revision 1.4
sys/dev/pci/mpii.c: revision 1.15
sys/dev/pci/mpii.c: revision 1.16
sys/dev/pci/mpii.c: revision 1.17
sys/dev/pci/mpii.c: revision 1.18

Update the mpii(4) driver to the latest OpenBSD version.

This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.

adjust mfii.c for changes in mpiireg.h

Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
Update for the new mpii(4) driver, mostly from OpenBSD.

Also tell the scsi layer that we are MPSAFE

Remove trailing whitespace

NULL-terminate mpii_devices[], this is the end condition of the loop
in mpii_match(). Noticed by Mike Pumford

There's no sensors for physical disks so don't try to detach them.
 1.8.10.2 07-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1129):

sys/arch/amd64/conf/XEN3_DOM0: revision 1.159
sys/arch/amd64/conf/GENERIC: revision 1.508
sys/arch/i386/conf/ALL: revision 1.458
sys/dev/ic/mfi.c: revision 1.60
sys/dev/pci/mpiireg.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1628
sys/dev/pci/mfii.c: revision 1.1,1.2 (adapted)
sys/arch/i386/conf/GENERIC: revision 1.1194
sys/dev/pci/mpii.c: revision 1.13
sys/dev/ic/mfireg.h: revision 1.9
share/man/man4/mfii.4: revision 1.1
share/man/man4/Makefile: revision 1.673 (patch)
sys/dev/pci/files.pci: revision 1.410
share/man/man4/mfii.4: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.108
sys/arch/i386/conf/XEN3PAE_DOM0: revision 1.8 (patch, in XEN3_DOM0)

Add some definitions from OpenBSD, needed by the upcoming mfii driver.
No functionnal change.

-

Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.

-

Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.

Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.

Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.

-

Add my name in copyright list

-

add a man page for the new mpii, mostly from OpenBSD.

-

Sort SEE ALSO. Fix date. Whitespace fixes.
 1.8.10.1 09-Jun-2018  martin Pull up following revision(s) (requested by maya in ticket #857):

sys/dev/pci/mpii.c: revision 1.9

PR/52330: Jia-Ju Bai: mpii driver: a sleep-in-interrupt bug in mpii_intr
Since the enclosing routime mpii_event_raid already calls malloc with
M_NOWAIT, fix the cache routine to do the same. While there check the
result of the cache routine and change some error prints to aprint.
 1.11.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.4.1 10-Jun-2019  christos Sync with HEAD
 1.11.2.4 18-Jan-2019  pgoyette Synch with HEAD
 1.11.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.11.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.11.2.1 20-Oct-2018  pgoyette Sync with head
 1.22.4.2 26-Oct-2023  martin Pull up following revision(s) (requested by buhrow in ticket #1756):

sys/dev/pci/mpii.c: revision 1.30

Fixes for PR kern/57133:

I can now explain why this assert is firing and have a fix for it. It is a regression introduced in R1.22 of mpii.c.

If a request comes in and the IOC returns a MPII_SCSIIO_STATUS_CHECK_COND condition, after
a successful transfer, or one that is a recovered error,
mpii(4) correctly sets the xs->error to XS_SENSE, but incorrectly sets xs->resid to 0 before
returning the xfer to the upper scsi layers. Once the upper layers get it, they notice the
XS_SENSE check condition and because it's a retryable error, they increment xs_requeuecnt, set
ERESTART and send the xfer request down to the mpii(4) layer again for a retry. What they do
not do is reset xs->resid equal to xs->datalen. When the xfer comes down to mpii(4) again, the
assert happens. The fix is for the mpii(4) driver to leave xs->resid alone when it encounters
a MPII_SCSIIO_STATUS_CHECK_COND condition.

This bug affects NetBSD-10, netbsd-9 and netbsd-8.
 1.22.4.1 09-Aug-2020  martin Pull up following revision(s) (requested by jnemeth in ticket #1044):

sys/dev/pci/mpii.c: revision 1.25

make this compile without bio(4)
 1.25.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.27.2.3 28-Mar-2021  thorpej No need to pass interface attribute or locators to config_found().
 1.27.2.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.27.2.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.28.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.29.6.1 26-Oct-2023  martin Pull up following revision(s) (requested by buhrow in ticket #435):

sys/dev/pci/mpii.c: revision 1.30

Fixes for PR kern/57133:

I can now explain why this assert is firing and have a fix for it. It is a regression introduced in R1.22 of mpii.c.

If a request comes in and the IOC returns a MPII_SCSIIO_STATUS_CHECK_COND condition, after
a successful transfer, or one that is a recovered error,
mpii(4) correctly sets the xs->error to XS_SENSE, but incorrectly sets xs->resid to 0 before
returning the xfer to the upper scsi layers. Once the upper layers get it, they notice the
XS_SENSE check condition and because it's a retryable error, they increment xs_requeuecnt, set
ERESTART and send the xfer request down to the mpii(4) layer again for a retry. What they do
not do is reset xs->resid equal to xs->datalen. When the xfer comes down to mpii(4) again, the
assert happens. The fix is for the mpii(4) driver to leave xs->resid alone when it encounters
a MPII_SCSIIO_STATUS_CHECK_COND condition.

This bug affects NetBSD-10, netbsd-9 and netbsd-8.
 1.2 03-Dec-2018  bouyer branches: 1.2.2; 1.2.6;
Update the mpii(4) driver to the latest OpenBSD version.
This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.
adjust mfii.c for changes in mpiireg.h

Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
 1.1 24-Nov-2018  bouyer branches: 1.1.2;
Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.
 1.1.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.2.1 24-Nov-2018  pgoyette file mpiireg.h was added on branch pgoyette-compat on 2018-11-26 01:52:32 +0000
 1.2.6.2 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 03-Dec-2018  christos file mpiireg.h was added on branch phil-wifi on 2019-06-10 22:07:17 +0000
 1.2.2.3 08-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1131):

sys/dev/pci/mpiireg.h: revision 1.2
sys/dev/pci/mfii.c: revision 1.3
share/man/man4/mpii.4: revision 1.3
share/man/man4/mpii.4: revision 1.4
sys/dev/pci/mpii.c: revision 1.15
sys/dev/pci/mpii.c: revision 1.16
sys/dev/pci/mpii.c: revision 1.17
sys/dev/pci/mpii.c: revision 1.18

Update the mpii(4) driver to the latest OpenBSD version.

This adds support for the SAS3xxx LSI controllers, and this also makes the
driver MP-safe.

adjust mfii.c for changes in mpiireg.h

Tested with a
mpii0: SMC2008-IR, firmware 9.0.0.0 IR, MPI 2.0
Update for the new mpii(4) driver, mostly from OpenBSD.

Also tell the scsi layer that we are MPSAFE

Remove trailing whitespace

NULL-terminate mpii_devices[], this is the end condition of the loop
in mpii_match(). Noticed by Mike Pumford

There's no sensors for physical disks so don't try to detach them.
 1.2.2.2 07-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1129):

sys/arch/amd64/conf/XEN3_DOM0: revision 1.159
sys/arch/amd64/conf/GENERIC: revision 1.508
sys/arch/i386/conf/ALL: revision 1.458
sys/dev/ic/mfi.c: revision 1.60
sys/dev/pci/mpiireg.h: revision 1.1
distrib/sets/lists/man/mi: revision 1.1628
sys/dev/pci/mfii.c: revision 1.1,1.2 (adapted)
sys/arch/i386/conf/GENERIC: revision 1.1194
sys/dev/pci/mpii.c: revision 1.13
sys/dev/ic/mfireg.h: revision 1.9
share/man/man4/mfii.4: revision 1.1
share/man/man4/Makefile: revision 1.673 (patch)
sys/dev/pci/files.pci: revision 1.410
share/man/man4/mfii.4: revision 1.2
sys/arch/amd64/conf/ALL: revision 1.108
sys/arch/i386/conf/XEN3PAE_DOM0: revision 1.8 (patch, in XEN3_DOM0)

Add some definitions from OpenBSD, needed by the upcoming mfii driver.
No functionnal change.

-

Move registers definitions to a separate file, needed for the upcomning mpii
driver. No functionnal change.

-

Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.

Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.

Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.

-

Add my name in copyright list

-

add a man page for the new mpii, mostly from OpenBSD.

-

Sort SEE ALSO. Fix date. Whitespace fixes.
 1.2.2.1 03-Dec-2018  martin file mpiireg.h was added on branch netbsd-8 on 2018-12-07 17:11:37 +0000
 1.26 02-Dec-2018  jdolecek use pci_intr_establish_xname()
 1.25 14-Jul-2016  msaitoh branches: 1.25.16; 1.25.18;
KNF. No functional change.
 1.24 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.23 29-Mar-2014  christos branches: 1.23.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.22 18-Mar-2012  martin branches: 1.22.2; 1.22.4;
Split device_t
 1.21 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.20 24-Nov-2009  njoly branches: 1.20.12; 1.20.16;
Do not use aprint_normal for error messages.
 1.19 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.18 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.17 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.16 10-Apr-2008  cegger branches: 1.16.4; 1.16.18;
use aprint_*_dev and device_xname
 1.15 25-Feb-2008  xtraeme Do not attach on Symbios SAS1078, doesn't work and it will be matched
soon by the mfi(4) driver.
 1.14 04-Feb-2008  joerg branches: 1.14.2; 1.14.6;
Fix quirk to clean only PCI register 0x6a and 0x6b, which is likely
what the original code intended. This avoids the unaligned access.
According to jmmv@'s testing, this seems to work.
 1.13 03-Jan-2008  tron Fix perfomance problems for old revisions of the Symbios 53c1030.
Patch supplied by Patrick Welche in PR kern/30531.
 1.12 17-Sep-2007  msaitoh branches: 1.12.6; 1.12.12;
add SAS1068_2, SAS1064E_2 and SAS1068E_2
 1.11 27-Jul-2007  tron branches: 1.11.4; 1.11.6; 1.11.8;
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.

These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.10 16-Nov-2006  christos branches: 1.10.2; 1.10.8; 1.10.16; 1.10.18;
__unused removal on arguments; approved by core.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 29-Mar-2006  thorpej branches: 1.8.8; 1.8.10;
mpt_pci_link_peer(): Rather than testing if the candidate device is attached
with mpt_pci (by comparing the dv_cfattach pointer), check to see if it has
the same parent. If so, then it is guaranteed to have the same attachment
(which is mpt_pci).
 1.7 28-Mar-2006  thorpej Use device_unit().
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8; 1.6.10; 1.6.12;
merge ktrace-lwp.
 1.5 27-Feb-2005  perry branches: 1.5.2; 1.5.4; 1.5.12; 1.5.14;
nuke trailing whitespace
 1.4 06-Jan-2005  he branches: 1.4.2; 1.4.4;
Add recognition of LSI Logic FC919X chips, as found on
LSI Logic LSI7102XP-LC controllers.
Document FC919X and FC929X with separate entries in the man page.
 1.3 18-Sep-2004  martin Add support for PCI-X version of LSI FC929; from Bert Kiers in PR kern/26836.
 1.2 14-Jul-2003  lukem branches: 1.2.2;
add missing __KERNEL_RCSID()
 1.1 16-Apr-2003  thorpej branches: 1.1.2;
Device driver for the LSI Logic Fusion-MPT based SCSI and Fibre Channel
adapters. Currently supports:

* LSI 53c1030 Ultra320 SCSI
* LSI FC909, FC909A, FC919, and FC929 Fibre Channel

Ported from the FreeBSD "mpt" driver, written by Greg Ansley. Thanks
to Frank van der Linden for testing and some bug finding.

This work was sponsored by Wasabi Systems, Inc.
 1.1.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 18-Sep-2004  he Pull up revision 1.3 (requested by martin in ticket #856):
Add support for PCI-X version of LSI FC929, from PR#26836.
 1.4.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.5.14.1 04-Oct-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1822):
sys/dev/ic/mpt_netbsd.c: revision 1.12 via patch
sys/dev/ic/mpt_netbsd.h: revision 1.6 via patch
sys/dev/ic/mpt_mpilib.h: revision 1.3 via patch
sys/dev/ic/mpt.h: revision 1.6 via patch
sys/dev/ic/mpt.c: revisions 1.9, 1.10 via patch
sys/dev/ic/mpt_debug.c: patch
sys/dev/pci/mpt_pci.c: revision 1.11 via patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/pcidevs_data.h: patch
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.5.12.1 04-Oct-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1822):
sys/dev/ic/mpt_netbsd.c: revision 1.12 via patch
sys/dev/ic/mpt_netbsd.h: revision 1.6 via patch
sys/dev/ic/mpt_mpilib.h: revision 1.3 via patch
sys/dev/ic/mpt.h: revision 1.6 via patch
sys/dev/ic/mpt.c: revisions 1.9, 1.10 via patch
sys/dev/ic/mpt_debug.c: patch
sys/dev/pci/mpt_pci.c: revision 1.11 via patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/pcidevs_data.h: patch
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.5.4.7 27-Feb-2008  yamt sync with head.
 1.5.4.6 11-Feb-2008  yamt sync with head.
 1.5.4.5 21-Jan-2008  yamt sync with head
 1.5.4.4 27-Oct-2007  yamt sync with head.
 1.5.4.3 03-Sep-2007  yamt sync with head.
 1.5.4.2 30-Dec-2006  yamt sync with head.
 1.5.4.1 21-Jun-2006  yamt sync with head.
 1.5.2.1 13-Sep-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1822):
sys/dev/ic/mpt_netbsd.c: revision 1.12 via patch
sys/dev/ic/mpt_netbsd.h: revision 1.6 via patch
sys/dev/ic/mpt_mpilib.h: revision 1.3 via patch
sys/dev/ic/mpt.h: revision 1.6 via patch
sys/dev/ic/mpt.c: revisions 1.9, 1.10 via patch
sys/dev/ic/mpt_debug.c: patch
sys/dev/pci/mpt_pci.c: revision 1.11 via patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/pcidevs_data.h: patch
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.6.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.6.10.1 19-Apr-2006  elad sync with head.
 1.6.8.1 01-Apr-2006  yamt sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.8.10.2 10-Dec-2006  yamt sync with head.
 1.8.10.1 22-Oct-2006  yamt sync with head
 1.8.8.1 18-Nov-2006  ad Sync with head.
 1.10.18.1 15-Aug-2007  skrll Sync with HEAD.
 1.10.16.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.10.8.2 09-Oct-2007  ad Sync with head.
 1.10.8.1 20-Aug-2007  ad Sync with HEAD.
 1.10.2.2 29-Sep-2008  jdc Pull up revision 1.12 (requested by bouyer in ticket #1192).

add SAS1068_2, SAS1064E_2 and SAS1068E_2
 1.10.2.1 30-Jul-2007  liamjfoy Pull up following revision(s) (requested by tron in ticket #797):
sys/dev/ic/mpt_netbsd.c: revision 1.12
sys/dev/ic/mpt_mpilib.h: revision 1.3
sys/dev/ic/mpt.h: revision 1.6
sys/dev/ic/mpt.c: revision 1.9
sys/dev/ic/mpt_netbsd.h: revision 1.6
sys/dev/pci/mpt_pci.c: revision 1.11
doc/CHANGES: revision 1.893
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
Mention support for new hardware in mpt(4).
 1.11.8.2 27-Jul-2007  tron Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.

These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.11.8.1 27-Jul-2007  tron file mpt_pci.c was added on branch matt-mips64 on 2007-07-27 13:06:52 +0000
 1.11.6.3 23-Mar-2008  matt sync with HEAD
 1.11.6.2 09-Jan-2008  matt sync with HEAD
 1.11.6.1 06-Nov-2007  matt sync with HEAD
 1.11.4.1 02-Oct-2007  joerg Sync with HEAD.
 1.12.12.1 08-Jan-2008  bouyer Sync with HEAD
 1.12.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.2.1 24-Mar-2008  keiichi sync with head.
 1.16.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.4.2 11-Mar-2010  yamt sync with head
 1.16.4.1 16-May-2009  yamt sync with head
 1.20.16.2 05-Apr-2012  mrg sync to latest -current.
 1.20.16.1 18-Feb-2012  mrg merge to -current.
 1.20.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.12.1 17-Apr-2012  yamt sync with head
 1.22.4.1 18-May-2014  rmind sync with head
 1.22.2.3 03-Dec-2017  jdolecek update from HEAD
 1.22.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.2.1 12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.23.6.2 05-Oct-2016  skrll Sync with HEAD
 1.23.6.1 09-Jul-2016  skrll Sync with HEAD
 1.25.18.1 10-Jun-2019  christos Sync with HEAD
 1.25.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.17 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.16 23-Nov-2011  jmcneill branches: 1.16.50; 1.16.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.15 28-Apr-2008  martin branches: 1.15.12; 1.15.34; 1.15.36;
Remove clause 3 and 4 from TNF licenses
 1.14 27-Mar-2008  xtraeme branches: 1.14.2; 1.14.4;
Split device_t/softc for mpu(4) and its attachments, plus other
related cosmetic changes.

Reviewed by cube@.
 1.13 19-Oct-2007  ad branches: 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 04-Feb-2005  perry de-__P
 1.7 02-Dec-2004  xtraeme branches: 1.7.4; 1.7.6;
Add ACPI mpu(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed by christos@, cube@ and martin@.

While here, remove a printf() in mpu_attach() (ic/mpu.c) to remove
an empty line in some frontends (mpu_isa.c, etc).
 1.6 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 02-Oct-2002  thorpej branches: 1.5.6;
Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 13-Nov-2001  lukem add RCSID
 1.1 04-Sep-2001  itohy branches: 1.1.4; 1.1.6;
MPU-401 compatible MIDI UART driver for C-Media CMI8x38
 1.1.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.6.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.6.1 04-Sep-2001  nathanw file mpu_cmpci.c was added on branch nathanw_sa on 2001-09-21 22:35:57 +0000
 1.1.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.4.1 04-Sep-2001  thorpej file mpu_cmpci.c was added on branch kqueue on 2001-09-13 01:15:55 +0000
 1.5.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.5 04-Feb-2005  skrll Sync with HEAD.
 1.5.6.4 18-Dec-2004  skrll Sync with HEAD.
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.6.1 12-Feb-2005  yamt sync with head.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.9.2.1 27-Oct-2007  yamt sync with head.
 1.10.22.2 10-Dec-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.15.34.1 17-Apr-2012  yamt sync with head
 1.15.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.16.54.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.16.50.1 10-Jun-2019  christos Sync with HEAD
 1.18 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.17 23-Nov-2011  jmcneill branches: 1.17.50; 1.17.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.16 28-Apr-2008  martin branches: 1.16.12; 1.16.34; 1.16.36;
Remove clause 3 and 4 from TNF licenses
 1.15 27-Mar-2008  xtraeme branches: 1.15.2; 1.15.4;
Split device_t/softc for mpu(4) and its attachments, plus other
related cosmetic changes.

Reviewed by cube@.
 1.14 19-Oct-2007  ad branches: 1.14.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 16-Nov-2006  christos branches: 1.13.8; 1.13.22; 1.13.24; 1.13.28;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 28-Jun-2005  thorpej branches: 1.10.2;
Use ANSI function decls and static.
 1.9 04-Feb-2005  perry de-__P
 1.8 02-Dec-2004  xtraeme branches: 1.8.4; 1.8.6;
Add ACPI mpu(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed by christos@, cube@ and martin@.

While here, remove a printf() in mpu_attach() (ic/mpu.c) to remove
an empty line in some frontends (mpu_isa.c, etc).
 1.7 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.6 02-Oct-2002  thorpej branches: 1.6.6;
Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 14-Aug-1999  kleink branches: 1.2.14; 1.2.16;
Add missing MPU interrupt glue.
 1.1 03-Aug-1999  augustss Add the file I forgot at the previous MPU changes.
 1.2.16.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.14.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.14.1 14-Nov-2001  nathanw Catch up to -current.
 1.6.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.5 04-Feb-2005  skrll Sync with HEAD.
 1.6.6.4 18-Dec-2004  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.1 12-Feb-2005  yamt sync with head.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.2.1 27-Oct-2007  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.13.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.24.1 06-Nov-2007  matt sync with HEAD
 1.13.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.14.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.16.34.1 17-Apr-2012  yamt sync with head
 1.16.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.17.54.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.17.50.1 10-Jun-2019  christos Sync with HEAD
 1.18 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.17 23-Nov-2011  jmcneill branches: 1.17.50; 1.17.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.16 28-Apr-2008  martin branches: 1.16.12; 1.16.34; 1.16.36;
Remove clause 3 and 4 from TNF licenses
 1.15 27-Mar-2008  xtraeme branches: 1.15.2; 1.15.4;
Split device_t/softc for mpu(4) and its attachments, plus other
related cosmetic changes.

Reviewed by cube@.
 1.14 19-Oct-2007  ad branches: 1.14.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 16-Nov-2006  christos branches: 1.13.8; 1.13.22; 1.13.24; 1.13.28;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 28-Jun-2005  thorpej branches: 1.10.2;
Use ANSI function decls and static.
 1.9 04-Feb-2005  perry de-__P
 1.8 02-Dec-2004  xtraeme branches: 1.8.4; 1.8.6;
Add ACPI mpu(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed by christos@, cube@ and martin@.

While here, remove a printf() in mpu_attach() (ic/mpu.c) to remove
an empty line in some frontends (mpu_isa.c, etc).
 1.7 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.6 02-Oct-2002  thorpej branches: 1.6.6;
Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 15-May-2000  thorpej branches: 1.2.6; 1.2.8; 1.2.10;
ac97.h -> ac97var.h
 1.1 01-Nov-1999  augustss branches: 1.1.4; 1.1.6;
Add FM801 audio device driver. From Witold J. Wnuk ww181302@zodiac.mimuw.edu.pl
Closes PR kern/8729.
 1.1.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.2 15-Nov-1999  fvdl Sync with -current
 1.1.4.1 01-Nov-1999  fvdl file mpu_fms.c was added on branch fvdl-softdep on 1999-11-15 00:41:04 +0000
 1.2.10.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.8.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 15-May-2000  bouyer file mpu_fms.c was added on branch thorpej_scsipi on 2000-11-20 11:42:25 +0000
 1.6.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.5 04-Feb-2005  skrll Sync with HEAD.
 1.6.6.4 18-Dec-2004  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.1 12-Feb-2005  yamt sync with head.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.2.1 27-Oct-2007  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.13.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.24.1 06-Nov-2007  matt sync with HEAD
 1.13.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.14.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.16.34.1 17-Apr-2012  yamt sync with head
 1.16.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.17.54.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.17.50.1 10-Jun-2019  christos Sync with HEAD
 1.17 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.16 23-Nov-2011  jmcneill branches: 1.16.50; 1.16.54;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.15 28-Apr-2008  martin branches: 1.15.12; 1.15.34; 1.15.36;
Remove clause 3 and 4 from TNF licenses
 1.14 27-Mar-2008  xtraeme branches: 1.14.2; 1.14.4;
Split device_t/softc for mpu(4) and its attachments, plus other
related cosmetic changes.

Reviewed by cube@.
 1.13 19-Oct-2007  ad branches: 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 02-Dec-2004  xtraeme Add ACPI mpu(4) attachment, based on lpt_acpi.c by jmcneill@,
reviewed by christos@, cube@ and martin@.

While here, remove a printf() in mpu_attach() (ic/mpu.c) to remove
an empty line in some frontends (mpu_isa.c, etc).
 1.7 08-Nov-2004  kent ANSIfy and style fixes
 1.6 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 02-Oct-2002  thorpej branches: 1.5.6;
Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 13-Nov-2001  lukem add RCSID
 1.1 30-Mar-2001  minoura branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Yamaha YMF724/740/744/754 (DS-1) PCI audio driver.
 1.1.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.2 01-May-2001  he Pull up revision 1.1 (new, requested by minoura):
Add Yamaha YMF724/740/744/745-based sound driver and
its subordinates.
 1.1.6.1 30-Mar-2001  he file mpu_yds.c was added on branch netbsd-1-5 on 2001-05-01 11:45:26 +0000
 1.1.4.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.1 30-Mar-2001  bouyer file mpu_yds.c was added on branch thorpej_scsipi on 2001-04-21 17:49:16 +0000
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.1 30-Mar-2001  nathanw file mpu_yds.c was added on branch nathanw_sa on 2001-04-09 01:57:03 +0000
 1.5.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.5 18-Dec-2004  skrll Sync with HEAD.
 1.5.6.4 14-Nov-2004  skrll Sync with HEAD.
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 27-Oct-2007  yamt sync with head.
 1.10.22.2 10-Dec-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.15.34.1 17-Apr-2012  yamt sync with head
 1.15.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.16.54.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.16.50.1 10-Jun-2019  christos Sync with HEAD
 1.10 31-Aug-2018  jdolecek constify mvsata_pci_products[]
 1.9 21-Jun-2017  jdolecek branches: 1.9.4; 1.9.6;
switch to pci_intr_establish_xname()
 1.8 29-Mar-2014  christos branches: 1.8.6; 1.8.22;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.7 30-Jan-2012  drochner branches: 1.7.6; 1.7.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.6 31-Jan-2011  jakllsch branches: 1.6.4; 1.6.8;
Make the Adaptec 1420SA entry match the Marvell 88SX6041 entry.

According to
http://lists.freebsd.org/pipermail/freebsd-current/2010-April/016973.html
the Adaptec 1420SA is a 88SX6041 (and the 1430SA is a 88SX7042).

This should fix the problem described in
http://mail-index.netbsd.org/current-users/2010/10/14/msg014526.html
 1.5 01-Aug-2010  kiyohara branches: 1.5.2; 1.5.4;
Remove mvsata_pci_products's terminator(-1). Instead of it use __arraycount().
 1.4 13-Jul-2010  kiyohara Move to pci/mvsata_pci.c (marvell/mvsata_mv.c) splitting mvsata_products[].
mvsata(4) uses these to match.
 1.3 24-Feb-2010  dyoung branches: 1.3.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.2 08-Jan-2010  dyoung branches: 1.2.2;
Expand PMF_FN_* macros.
 1.1 27-Jul-2009  kiyohara branches: 1.1.2;
Support Marvell Hercules-I/II SATA Controllers.
 1.1.2.4 11-Aug-2010  yamt sync with head.
 1.1.2.3 11-Mar-2010  yamt sync with head
 1.1.2.2 19-Aug-2009  yamt sync with head.
 1.1.2.1 27-Jul-2009  yamt file mvsata_pci.c was added on branch yamt-nfs-mp on 2009-08-19 18:47:12 +0000
 1.2.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.2.1 05-Mar-2011  rmind sync with head
 1.5.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.5.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.8.1 18-Feb-2012  mrg merge to -current.
 1.6.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.4.1 17-Apr-2012  yamt sync with head
 1.7.10.1 18-May-2014  rmind sync with head
 1.7.6.2 03-Dec-2017  jdolecek update from HEAD
 1.7.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.22.1 25-Jun-2017  snj Pull up following revision(s) (requested by jdolecek in ticket #56):
sys/dev/pci/mvsata_pci.c: revision 1.9
sys/dev/pci/siisata_pci.c: revision 1.16
switch to pci_intr_establish_xname()
 1.8.6.1 28-Aug-2017  skrll Sync with HEAD
 1.9.6.1 10-Jun-2019  christos Sync with HEAD
 1.9.4.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.1 01-Apr-2010  jakllsch branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14; 1.1.18;
Add support for Domex 536 PCI SCSI controller to nca(4).
This truly remarkable chip is found on the Domex DMX-3191D SCSI adapter.
 1.1.18.1 18-Feb-2012  mrg merge to -current.
 1.1.14.1 17-Apr-2012  yamt sync with head
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 01-Apr-2010  yamt file nca_pci.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:50 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 01-Apr-2010  rmind file nca_pci.c was added on branch rmind-uvmplock on 2010-05-30 05:17:36 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 01-Apr-2010  uebayasi file nca_pci.c was added on branch uebayasi-xip on 2010-04-30 14:43:39 +0000
 1.107 07-Jul-2001  thorpej Remove the old NCR 53c8xx driver. It no longer compiles (it was not
updated for the thorpej_scsipi branch), and has been replaced by Manuel's
MUCH BETTER `siop' driver.

The code can still be referenced by using cvsweb, checking out an
old revision, whatever. But it's no longer useful to have it appear
in a checked out source tree.
 1.106 25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.105 28-Dec-2000  sommerfeld branches: 1.105.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.104 24-Sep-2000  jdolecek use new generic bootverbose instead of local definition
 1.103 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.102 26-Jun-2000  mrg remove redundant vm includes
 1.101 08-Apr-2000  tsutsui Remove #ifdef __NetBSD__ code inside !__NetBSD__ part.
 1.100 08-Apr-2000  tsutsui Add vaddr_t cast to vtophys() arg. (for powerpc)
 1.99 06-Apr-2000  tsutsui Fix bogus byte-swap code in ncr_snooptest().
XXX This snoop test is not needed if ncr had real bus_dma(9) support...
 1.98 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.97 18-Mar-2000  cgd * rework the quirk table ('device_tab'):
* QUIRK_NOMSG only has any meaning when NCR_GETCC_WITHMSG
is defined. Therefore, there's no harm in using it when
NCR_GETCC_WITHMSG is not defined. so, simplify the table
by removing the #ifdef.
* there's really no point in having table entries after
an entry which will match everything.
* add some comments, clean up spacing.

* add an entry for "QUANTUM"/"ATLAS IV" drives with flags
QUIRK_NOTAGS|QUIRK_NOMSG. (I included the latter flag only
because everything else had it before! ... which means that
all the functionality added with the NCR_GETCC_WITHMSG define
would never get used! *sigh*) The latter fixes the problems
I was having on an Atlas, and should fix the problems mentioned
by Hans Hoppe <hopha@casema.net> in comments on PR#7694.
 1.96 18-Mar-2000  cgd undo the non-script changes from rev 1.87. They caused problems in
1.4.x and i have concerns (but no concrete proof) they will cause/have caused
problems in -current as well. Really, the right way to fix this is to
rewrite the driver, and push up tagged queueing handling into a common
middle layer that'll do it right in a low-level-driver-independent manner.
I'll fix my particular issues by using the ncr driver quirk mechanism.
 1.95 17-Mar-2000  soren Use a kvtophys() hack for mips like for alpha. No idea if it actually works..
 1.94 20-Feb-2000  sommerfeld deal with a DELAY vs. delay issue
 1.93 26-Dec-1999  tsutsui Use htole32() and le32toh() instead of SCR_BO().

XXX Should we still keep non-NetBSD part?
 1.92 20-Dec-1999  tsutsui Add more SCR_BO(). NCR53c875 now works on macppc.

XXX All SCR_BO() macros should be replaced with htole32() or le32toh().
 1.91 05-Dec-1999  thorpej Mark exactly 3 uses of the SCR_BO() macro as being bogus; these 3 uses
already involve byte swapping on big-endian systems due to bus_space_*().

However, the use is self-consistent, and the value is not interpreted
by the chip, so it probably does not matter. Leave them in for now; we
can always look at their removal later.
 1.90 05-Dec-1999  thorpej Slight change to previous, to make it more obvious as to what's going on.
 1.89 05-Dec-1999  thorpej I have the feeling that OpenBSD has never tried the 53c825a, 53c875, 53c875j,
53c885, 53c895, or 53c896 on big-endian systems.
 1.88 05-Dec-1999  thorpej Changes from the OpenBSD `ncr' driver to byte-swap the script on big-endian
systems. Should make this go on e.g. the Apple Network Server.
 1.87 08-Oct-1999  cgd branches: 1.87.2;
Don't burst into flame when a QUEUE FULL message is received. Also,
do a gross hack which allows seemingly-broken quantum drives to function
with this driver. The gross hack is to disable tagged queueing completely
when QUEUE FULL is received. That costs performance on drives which
do tagged queueing properly and which return QUEUE FULL, but given the way
this driver works it's seems to be the only thing short of significant
recoding which will make it function with the quantum drives in question.
 1.86 05-Oct-1999  thorpej branches: 1.86.4;
Have I mentioned how much I love this driver? Fix the code in the tagged
queueing support that decreases the number of openings on a device; it
previously assumed that a scsipi_link's `openings' were descreased as
commands were issued, which is not longer the case (`active' is increased).
 1.85 05-Oct-1999  thorpej Fix a botch when updating for the SCSIPI changes.
 1.84 30-Sep-1999  thorpej Update for SCSPI changes.
 1.83 19-Aug-1999  matt after bus_dmamem creating some memory, zero it out. This has stopped
my alpha from getting COMMAND FAILED on random boots.
 1.82 04-Aug-1999  tron Add missing prototype for read_tekram_eeprom() to make driver compile if
"options NCR_TEKRAM_EEPROM" is specified in the kernel configuration file.
Patch supplied by Hans Hoppe in PR kern/8141.
 1.81 29-Jul-1999  bouyer Bump MAX_START to 256, so that the ncr driver can work with more than 5
devices on the same bus. See PR kern/6347 for details.
 1.80 13-Dec-1998  thorpej branches: 1.80.2; 1.80.4;
Don't DMA the scsi command from or the sense data to the scsipi_xfer
directly. That would require that we map the scsipi_xfer into DMA
space. Instead, copy to/from the NCR CCB, which the script already
has to DMA to/from. These copies are small, and don't seem to affect
performance.
 1.79 12-Dec-1998  thorpej Step 3:

Use DMA maps for the actual data transfers.
 1.78 12-Dec-1998  thorpej Step two:

Use DMA-safe memory for the script instances. The most important thing
here is that is guarantees that the script is contiguous in DMA space.
 1.77 11-Dec-1998  thorpej Step one of bus_dma'ing the PCI NCR driver:

Separate the ncb (i.e. softc) members that are accessed by the script into
a separate structure. Allocate one of these structures in DMA safe memory
using bus_dma, and change RELOC_SOFTC to use the DMA address of this
structure.
 1.76 05-Dec-1998  mjacob Update HBAs to incorporate the new max_lun property.
 1.75 19-Nov-1998  thorpej Adapt to the new scsipi_adapter interface.
 1.74 10-Oct-1998  thorpej Garbage-collect the open_target_lu and close_target_lu entry points from
struct scsipi_adapter; they were not used.

Add a scsipi_ioctl entry point to struct scsipi_adapter. This will be
used to issue ioctl commands to the host adapters.

Inspired by PR #6090, from Matt Jacob.
 1.73 21-Sep-1998  mjacob Roll back to 1.71 version- too many unexplainable problems with 1.72.
 1.72 08-Sep-1998  mjacob add more general probe to regular more operation stuff
 1.71 20-Aug-1998  veego branches: 1.71.2;
Add some braces to stop the new egcs warnings.
 1.70 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.69 10-Aug-1998  ross Fix a race involving determination of pollmode. This is not known to be
associated with any observed lossage...it was just noticed while reading
ncr_start().

g/c some now-unreachable code produced by the earlier race condition fix.
 1.68 08-Aug-1998  ross 1. Untangle preprocessor conditionals for sanity and {} balance
2. Fix a race between the first callout and the first non-polled ncr_start()
 1.67 08-Jun-1998  thorpej branches: 1.67.2;
Nuke __BROKEN_INDIRECT_CONFIG.
 1.66 28-May-1998  matt Use PCI_REVISION and eliminate some pci_conf_reads
 1.65 28-Jan-1998  thorpej Use offsetof() from libkern.h
 1.64 12-Jan-1998  thorpej Update for config changes.
 1.63 23-Sep-1997  perry ncr_reg.h -> ncrreg.h per Dave Huang
 1.62 23-Sep-1997  perry updates from FreeBSD via Dave Huang <khym@bga.com>
 1.61 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.60 01-Jul-1997  cjs branches: 1.60.2; 1.60.4;
Add QUIRK_NOTAGS quirk to disable tagged command queuing for particular
drives. Add a quirk entry for HP C372x drives with QUIRK_NOTAGS. Also,
print quirks being used if quirks other than QUIRK_NOSYNC are being used.
 1.59 17-Apr-1997  mikel end line after printing WIDE SCSI status; fixes PR kern 3505.
 1.58 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.57 13-Apr-1997  cgd use pci_map_register(). map both mem and I/O spaces, preferring mem space
by default if it's usable, but falling back to I/O space if mem isn't usable.
If NCR_IOMAPPED is defined (default on the x86), prefer I/O space
then fall back to mem. Also, clean up the various memory consistency checks
so that they can deal with run-time determination of whether or not the
device is to be memory- or I/O-mapped.
 1.56 04-Mar-1997  mycroft Fix a couple of splhigh()s that should be splbio().
 1.55 10-Jan-1997  perry branches: 1.55.4;
Commit latest fixes/upgrades to NCR SCSI driver. From FreeBSD via
Dave Huang <khym@bga.com>

Tested on alpha by cgd, tested on several i386 boxes. Certainly causes
no harm to the goddamned mess, but the NCR driver only works when you
perform voodoo rituals on it anyway.

This is what Dave said (in email) has been added to the driver:

----------------------------------------------------------------------
This seems to be the most significant change:
General cleanup and new features for 53c875 based cards, especially the
Tekram DC390W/U/F, whose config EEPROM can now be dumped, if the kernel
is built with option NCR_TEKRAM_EEPROM.

Other changes:

- add brackets to expansion of OUTB/W/L macro arguments.
- remove unused NCB structure element ns_async
- support sync. SCSI offset of 16 (instead of only 8) on 825A and 875
- correctly identify 53c810A and 53c825A chips
- preserve SCSI BIOS settings of PCI performance options
- remove (already disabled) support for NCR reset because of command timeout
- reverse order of reading of SCSI and DMA specific interrupt cause registers
- add definition of Tekram config EEPROM contents (not currently used)
----------------------------------------------------------------------
 1.54 10-Dec-1996  thorpej Fill in sc_link.max_target
 1.53 05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.52 23-Nov-1996  cgd cast pointers to long, not int, and fix the resulting printf format goof.
 1.51 20-Nov-1996  perry Incorporate updated version of fixes from FreeBSD submitted in PR
2841, plus some fixes to make the patches work on the Alpha. Seems to
improve the NCR driver a lot. We probably should try to incorporate
any updates that have happened since, too.
 1.50 14-Nov-1996  cgd print ptrdiff_t's by casting to long and printing with %l<whatever>.
(This fixes problems with the printf format fixes i checked in yesterday.
ptrdiff_t is an 'int' on the i386 but a 'long' on the alpha, so the cast
really is necessary... *sigh*)
 1.49 13-Nov-1996  cgd fix a bunch of printf format botches
 1.48 25-Oct-1996  cgd update alpha_XXX_dmamap() invocations to match prototype.
 1.47 25-Oct-1996  cgd make script_kvars an array of unsigned longs, and cast when assigning the
elements, to avoid warnings (with -Wcast-qual) about 'volatile'
qualifiers being discarded.
 1.46 23-Oct-1996  cgd update drivers to use the new NetBSD/alpha DMA mapping hack, since
the old one is not workable with the new bus.h.
 1.45 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.44 13-Oct-1996  christos backout kprintf changes
 1.43 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.42 20-Sep-1996  cgd put set of 'channel' field of scsi_link in the right #ifdef
 1.41 28-Aug-1996  cgd (1) set scsi_link channel to either the appropriate channel (if a
multi-channel driver), or to SCSI_CHANNEL_ONLY_ONE if a
single-channel driver.
(2) use scsiprint() rather than a locally-defined autoconfig print
function, and kill any locally-defined print function.
 1.40 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.39 27-Aug-1996  cgd #undef assert before defining it, so the new libkern definition doesn't
conflict with this one.
 1.38 10-Aug-1996  mycroft Eliminate reference to stddef.h.
 1.37 15-Jul-1996  cgd before #defining the vtophys() hack for the alpha, #undef vtophys since
it may be a macro.
 1.36 03-Jun-1996  cgd convert alpha vtophys() #defines to use __alpha_bus_XXX_dmamap(), to
get rid of the nasty (vtophys(va) | 0x40000000) expressions, and to make
the code more correct.
 1.35 13-May-1996  mycroft branches: 1.35.4;
Use intr.h.
 1.34 03-May-1996  christos - fix printf format strings
- #ifdef out unused variables/functions
- parenthesize
 1.33 03-Apr-1996  mycroft Implement ncr_print().
 1.32 30-Mar-1996  cgd make sure that chipset tags are used properly (because the alpha cares),
and include <machine/intr.h> on the alpha, for interrupt information.
(i386 will probably switch to this eventually.)
 1.31 27-Mar-1996  cgd modify these to use the new PCI interfaces:
(1) use pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register, and bus_{io,mem}_map() to map it.
(2) use pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(5) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.30 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.29 14-Mar-1996  cgd fix types on a bunch of variables (were u_long's, now are U_INT32s or ncrcmds,
and a few other fixes). print pointers with %p, rather than casting to
(unsigned), which breaks on the Alpha.
 1.28 14-Mar-1996  cgd include pcireg before pcivar.h
 1.27 11-Mar-1996  cgd kill extraneous empty line in comment block at start of file
 1.26 11-Mar-1996  cgd mostly convert to use interfaces provided by <machine/bus.h>. (For now,
assumes that pci_map_mem/pci_map_io provide interfaces which utilitize
bus_{io,mem}_handle_t's, or types which are compatible. This works on the
i386, and will change eventually anyway.)
 1.25 11-Mar-1996  cgd Move INT32, U_INT32, TIMEOUT definitions to ncr_reg.h, and add definitions
for U_INT8, INT16, U_INT16 definitions. Convert structs and
definitions in ncr_reg.h (e.g. ncrcmd, the chip register layout, etc.)
to use these definitions.
Add INB_OFF, INL_OFF, and OUTL_OFF macros to access specified offsets into
I/O or memory space. Convert register dumps (etc.), and cache snoop
test to use these new macros, so that nothing accesses the device
I/O or memory space directly. (Register dumps now come from I/O space
if NCR_IOMAPPED. They used to bogusly use memory space.)
Add a new relocation type for script entries, RELOC_KVAR. Allow scripts
access to mono_time.tv_sec, mono_time, and ncr_cache via this
mechanism, and convert scripts to use it. An ncrcmd is only 32 bits
wide, and KVAs may be > 32 bits wide (e.g. on Alpha), leading to
linker problems. This is a safer way to do this anyway; relocation is
more deterministic this way, and doesn't rely on KVAs not looking like
other relocation types.
Panic if an unmatched relocation other than 'zero' is specified. That's
now a script bug. (This used to be used to convert KVAs of kernel
variables referenced in the script to PCI bus physical addresses,
and that is now handled by RELOC_KVAR relocations.)
Figure out and print the model of chip.
 1.24 24-Feb-1996  cgd use mono_time, rather than time, to keep track of timeouts. time can change
unpredictably.
 1.23 28-Dec-1995  thorpej Squish a couple of rogue old-style RCS ids.
 1.22 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.21 30-Nov-1995  jtc merge in changes from 1.1 release branch
 1.20 23-Oct-1995  pk DV_NULL should be DV_DULL.
 1.19 22-Oct-1995  pk DV_DISK => DV_NULL (from Mike Long; PR#1607).
 1.18 02-Oct-1995  mycroft branches: 1.18.2;
Fix an oversight in the minphys routine.
 1.17 01-Oct-1995  mycroft Incorporate recent changes from Wolfgang and Stefan.
 1.16 12-Aug-1995  mycroft minphys() functions really should return void.
 1.15 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.14 17-Apr-1995  cgd clean up several ISA device interfaces: autoconfiguration, header
inclusion, and interrupt configuration. more work still needs to be done,
but it's getting better...
 1.13 28-Mar-1995  jtc KERNEL -> _KERNEL
 1.12 01-Feb-1995  mycroft Patch from Wolfgang to fix a missing spl.
 1.11 27-Jan-1995  cgd include files from the correct places.
 1.10 16-Jan-1995  mycroft Incorporate recent changes from Wolfgang. Recognize the 815.
 1.9 04-Jan-1995  mycroft Remove many of the `static's, to facilitate debugging.
 1.8 28-Dec-1994  mycroft Numerous changes. Many bugs fixed, better autoconfig, a few new features.
 1.7 04-Nov-1994  mycroft Make a wrapper match function to check the bus and device numbers, rather
than insisting that every driver do it.
 1.6 03-Nov-1994  mycroft Always use direct configuration.
 1.5 27-Oct-1994  cgd new RCS ID format.
 1.4 27-Oct-1994  andrew Default to decent performance.
 1.3 27-Oct-1994  andrew Merge changes from Wolfgang Stanglmeier's 941012 release.
 1.2 01-Oct-1994  mycroft Update from Wolfgang Stanglemeier.
 1.1 09-Aug-1994  mycroft branches: 1.1.1;
Add NCR 53c8XX driver, originally from Wolfgang Stanglmeier.
 1.1.1.1 29-Aug-1998  ross Import current FreeBSD ncr.c, but without the id strings.
 1.18.2.2 23-Nov-1995  perry Changed to use the hacked up version Thor got from the original
maintainers. It is uglier than mycroft's version, but it works on a
lot more machines than his does. Hopefully this can be fixed "for
real" after the release. Note that although it works on a superset of
the machines that mycroft's did, it is still broken on some slower
machines with fast disks. The thing is full of timing bugs. Sigh.
 1.18.2.1 23-Oct-1995  pk From trunk: DV_DISK -> DV_DULL
 1.35.4.2 10-Dec-1996  mycroft Eliminate references to user-level include files.
 1.35.4.1 03-Jun-1996  cgd pull up from trunk:
>convert alpha vtophys() #defines to use __alpha_bus_XXX_dmamap(), to
>get rid of the nasty (vtophys(va) | 0x40000000) expressions, and to make
>the code more correct.
 1.55.4.1 12-Mar-1997  is Merge in changes from The Trunk
 1.60.4.2 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.60.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.60.2.2 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.60.2.1 01-Jul-1997  bouyer file ncr.c was added on branch bouyer-scsipi on 1997-07-01 17:35:37 +0000
 1.67.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.71.2.1 30-Aug-1998  ross This is a merge *on a branch* of all NetBSD ncr.c changes into the
FreeBSD-current (1.123) ncr.c. It didn't actually solve my '875
problems; we will decide whether to actually use this work later.

ross-ncr-fb1-123-base the branch point
ross-ncr-fb1-123-merge the branch
 1.80.4.1 02-Aug-1999  thorpej Update from trunk.
 1.80.2.6 02-Apr-2000  he Pull up revisions 1.87 and 1.96-1.97 (requested by cgd):
Fix script bug in processing QUEUE FULL response (would always
trigger an assertion failure), and add Quantum Atlas IV drives
to the quirk table so that they don't use tagged queueing.
Fixes problems reported in PR#7694.
 1.80.2.5 08-Nov-1999  cgd Back out pullup of rev. 1.87. It seems a bit broken, and the known
evil is better than the unknown evil.
 1.80.2.4 18-Oct-1999  cgd pull up rev 1.87 from trunk (requested by cgd):
Fix bugs in handling QUEUE FULL messages. Also, when a QUEUE FULL
message is seen, disable tagged queueing completely for the target
which generated it. This is (much) more conservative than necessary
for normal operation, but allows the driver to function properly
even with some broken drives at the cost of some performance on
drives that have a very low tagged command limit.
 1.80.2.3 18-Sep-1999  cgd pull up rev 1.83 from trunk (cgd):
Zero out DMA memory regions to avoid use of uninitialized
memory (and resutling "COMMAND FAILED" errors) on systems
which don't clear memory on boot. (cgd)
 1.80.2.2 18-Sep-1999  cgd pull up rev 1.82 (tron):
Make driver build with Tekram EEPROM support enabled.
Fixes PR#8141. (tron)
 1.80.2.1 18-Sep-1999  cgd pull up rev 1.81 (bouyer):
Make the ncr driver work with more than 5 devices on the same
bus. Fixes PR#6347. (bouyer)
 1.86.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.87.2.6 15-Jan-2001  bouyer req_sense_length is dead.
 1.87.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.87.2.4 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.87.2.3 26-Oct-1999  thorpej Update for:

Deal a little more gracefully with the fact that xfer mode parameters
are for the I_T Nexus, and make all xfer mode updates `async events'.
 1.87.2.2 20-Oct-1999  thorpej Eliminate sleeping from adapter routines.
 1.87.2.1 19-Oct-1999  thorpej Adapt to scsipi API changes.
 1.105.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.105.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file ncr.c.old was initially added on branch thorpej_scsipi.
 1.1.2.2 22-Nov-2000  bouyer Should not be there
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file ncr.c.orig was initially added on branch thorpej_scsipi.
 1.1.2.2 20-Nov-2000  bouyer Remove files that should not have been added
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file ncr.c.rej was initially added on branch thorpej_scsipi.
 1.1.2.2 20-Nov-2000  bouyer Remove files that should not have been added
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.15 23-Sep-1997  perry ncr_reg.h -> ncrreg.h per Dave Huang
 1.14 23-Sep-1997  perry updates from FreeBSD via Dave Huang <khym@bga.com>
 1.13 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.12 23-Jul-1997  bouyer branches: 1.12.2;
Back out previous change. This was for bouyer-scsipi, and not for the trunk.
 1.11 23-Jul-1997  bouyer Forgot a scsi->dev/scsipi.
 1.10 10-Jan-1997  perry branches: 1.10.8;
Commit latest fixes/upgrades to NCR SCSI driver. From FreeBSD via
Dave Huang <khym@bga.com>

Tested on alpha by cgd, tested on several i386 boxes. Certainly causes
no harm to the goddamned mess, but the NCR driver only works when you
perform voodoo rituals on it anyway.

This is what Dave said (in email) has been added to the driver:

----------------------------------------------------------------------
This seems to be the most significant change:
General cleanup and new features for 53c875 based cards, especially the
Tekram DC390W/U/F, whose config EEPROM can now be dumped, if the kernel
is built with option NCR_TEKRAM_EEPROM.

Other changes:

- add brackets to expansion of OUTB/W/L macro arguments.
- remove unused NCB structure element ns_async
- support sync. SCSI offset of 16 (instead of only 8) on 825A and 875
- correctly identify 53c810A and 53c825A chips
- preserve SCSI BIOS settings of PCI performance options
- remove (already disabled) support for NCR reset because of command timeout
- reverse order of reading of SCSI and DMA specific interrupt cause registers
- add definition of Tekram config EEPROM contents (not currently used)
----------------------------------------------------------------------
 1.9 20-Nov-1996  perry Incorporate updated version of fixes from FreeBSD submitted in PR
2841, plus some fixes to make the patches work on the Alpha. Seems to
improve the NCR driver a lot. We probably should try to incorporate
any updates that have happened since, too.
 1.8 11-Mar-1996  cgd RCS ID police; get rid of Id keyword.
 1.7 11-Mar-1996  cgd Move INT32, U_INT32, TIMEOUT definitions to ncr_reg.h, and add definitions
for U_INT8, INT16, U_INT16 definitions. Convert structs and
definitions in ncr_reg.h (e.g. ncrcmd, the chip register layout, etc.)
to use these definitions.
Add INB_OFF, INL_OFF, and OUTL_OFF macros to access specified offsets into
I/O or memory space. Convert register dumps (etc.), and cache snoop
test to use these new macros, so that nothing accesses the device
I/O or memory space directly. (Register dumps now come from I/O space
if NCR_IOMAPPED. They used to bogusly use memory space.)
Add a new relocation type for script entries, RELOC_KVAR. Allow scripts
access to mono_time.tv_sec, mono_time, and ncr_cache via this
mechanism, and convert scripts to use it. An ncrcmd is only 32 bits
wide, and KVAs may be > 32 bits wide (e.g. on Alpha), leading to
linker problems. This is a safer way to do this anyway; relocation is
more deterministic this way, and doesn't rely on KVAs not looking like
other relocation types.
Panic if an unmatched relocation other than 'zero' is specified. That's
now a script bug. (This used to be used to convert KVAs of kernel
variables referenced in the script to PCI bus physical addresses,
and that is now handled by RELOC_KVAR relocations.)
Figure out and print the model of chip.
 1.6 30-Nov-1995  jtc merge in changes from 1.1 release branch
 1.5 01-Oct-1995  mycroft branches: 1.5.2;
Incorporate recent changes from Wolfgang and Stefan.
 1.4 28-Dec-1994  mycroft Numerous changes. Many bugs fixed, better autoconfig, a few new features.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 01-Oct-1994  mycroft Update from Wolfgang Stanglemeier.
 1.1 09-Aug-1994  mycroft Add NCR 53c8XX driver, originally from Wolfgang Stanglmeier.
 1.5.2.1 23-Nov-1995  perry Changed to use the hacked up version Thor got from the original
maintainers. It is uglier than mycroft's version, but it works on a
lot more machines than his does. Hopefully this can be fixed "for
real" after the release. Note that although it works on a superset of
the machines that mycroft's did, it is still broken on some slower
machines with fast disks. The thing is full of timing bugs. Sigh.
 1.10.8.1 23-Jul-1997  bouyer scsi/->dev/scsipi/
 1.12.2.2 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.18 07-Jul-2001  thorpej Remove the old NCR 53c8xx driver. It no longer compiles (it was not
updated for the thorpej_scsipi branch), and has been replaced by Manuel's
MUCH BETTER `siop' driver.

The code can still be referenced by using cvsweb, checking out an
old revision, whatever. But it's no longer useful to have it appear
in a checked out source tree.
 1.17 26-Dec-1999  tsutsui branches: 1.17.6;
Use htole32() and le32toh() instead of SCR_BO().

XXX Should we still keep non-NetBSD part?
 1.16 18-Dec-1999  tsutsui Use bswap32() as SCR_BO() macro to avoid unexpected side effects.
SCR_BO(*src++) caused some trouble.
 1.15 05-Dec-1999  thorpej Changes from the OpenBSD `ncr' driver to byte-swap the script on big-endian
systems. Should make this go on e.g. the Apple Network Server.
 1.14 23-Sep-1997  perry branches: 1.14.2; 1.14.18; 1.14.24;
updates from FreeBSD via Dave Huang <khym@bga.com>
 1.13 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.12 23-Jul-1997  bouyer branches: 1.12.2;
Back out previous change. This was for bouyer-scsipi, and not for the trunk.
 1.11 23-Jul-1997  bouyer Forgot a scsi->dev/scsipi.
 1.10 10-Jan-1997  perry branches: 1.10.8;
Commit latest fixes/upgrades to NCR SCSI driver. From FreeBSD via
Dave Huang <khym@bga.com>

Tested on alpha by cgd, tested on several i386 boxes. Certainly causes
no harm to the goddamned mess, but the NCR driver only works when you
perform voodoo rituals on it anyway.

This is what Dave said (in email) has been added to the driver:

----------------------------------------------------------------------
This seems to be the most significant change:
General cleanup and new features for 53c875 based cards, especially the
Tekram DC390W/U/F, whose config EEPROM can now be dumped, if the kernel
is built with option NCR_TEKRAM_EEPROM.

Other changes:

- add brackets to expansion of OUTB/W/L macro arguments.
- remove unused NCB structure element ns_async
- support sync. SCSI offset of 16 (instead of only 8) on 825A and 875
- correctly identify 53c810A and 53c825A chips
- preserve SCSI BIOS settings of PCI performance options
- remove (already disabled) support for NCR reset because of command timeout
- reverse order of reading of SCSI and DMA specific interrupt cause registers
- add definition of Tekram config EEPROM contents (not currently used)
----------------------------------------------------------------------
 1.9 20-Nov-1996  perry Incorporate updated version of fixes from FreeBSD submitted in PR
2841, plus some fixes to make the patches work on the Alpha. Seems to
improve the NCR driver a lot. We probably should try to incorporate
any updates that have happened since, too.
 1.8 11-Mar-1996  cgd RCS ID police; get rid of Id keyword.
 1.7 11-Mar-1996  cgd Move INT32, U_INT32, TIMEOUT definitions to ncr_reg.h, and add definitions
for U_INT8, INT16, U_INT16 definitions. Convert structs and
definitions in ncr_reg.h (e.g. ncrcmd, the chip register layout, etc.)
to use these definitions.
Add INB_OFF, INL_OFF, and OUTL_OFF macros to access specified offsets into
I/O or memory space. Convert register dumps (etc.), and cache snoop
test to use these new macros, so that nothing accesses the device
I/O or memory space directly. (Register dumps now come from I/O space
if NCR_IOMAPPED. They used to bogusly use memory space.)
Add a new relocation type for script entries, RELOC_KVAR. Allow scripts
access to mono_time.tv_sec, mono_time, and ncr_cache via this
mechanism, and convert scripts to use it. An ncrcmd is only 32 bits
wide, and KVAs may be > 32 bits wide (e.g. on Alpha), leading to
linker problems. This is a safer way to do this anyway; relocation is
more deterministic this way, and doesn't rely on KVAs not looking like
other relocation types.
Panic if an unmatched relocation other than 'zero' is specified. That's
now a script bug. (This used to be used to convert KVAs of kernel
variables referenced in the script to PCI bus physical addresses,
and that is now handled by RELOC_KVAR relocations.)
Figure out and print the model of chip.
 1.6 30-Nov-1995  jtc merge in changes from 1.1 release branch
 1.5 01-Oct-1995  mycroft branches: 1.5.2;
Incorporate recent changes from Wolfgang and Stefan.
 1.4 28-Dec-1994  mycroft Numerous changes. Many bugs fixed, better autoconfig, a few new features.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 01-Oct-1994  mycroft Update from Wolfgang Stanglemeier.
 1.1 09-Aug-1994  mycroft Add NCR 53c8XX driver, originally from Wolfgang Stanglmeier.
 1.5.2.1 23-Nov-1995  perry Changed to use the hacked up version Thor got from the original
maintainers. It is uglier than mycroft's version, but it works on a
lot more machines than his does. Hopefully this can be fixed "for
real" after the release. Note that although it works on a superset of
the machines that mycroft's did, it is still broken on some slower
machines with fast disks. The thing is full of timing bugs. Sigh.
 1.10.8.1 23-Jul-1997  bouyer scsi/->dev/scsipi/
 1.12.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.24.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.18.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.14.2.2 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.2.1 23-Sep-1997  thorpej file ncrreg.h was added on branch marc-pcmcia on 1997-09-29 07:21:05 +0000
 1.17.6.1 28-Feb-2002  nathanw Catch up to -current.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file ncrreg.h.old was initially added on branch thorpej_scsipi.
 1.1.2.2 22-Nov-2000  bouyer Should not be there
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8 07-Jul-2001  thorpej Remove the old NCR 53c8xx driver. It no longer compiles (it was not
updated for the thorpej_scsipi branch), and has been replaced by Manuel's
MUCH BETTER `siop' driver.

The code can still be referenced by using cvsweb, checking out an
old revision, whatever. But it's no longer useful to have it appear
in a checked out source tree.
 1.7 17-Mar-1996  thorpej branches: 1.7.42;
New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.6 27-Jan-1995  cgd include files from the correct places.
 1.5 18-Nov-1994  mycroft Convert port, IRQ, and DRQ numbers to ints.
 1.4 27-Oct-1994  cgd new RCS ID format.
 1.3 01-Oct-1994  mycroft Update from Wolfgang Stanglemeier.
 1.2 11-Aug-1994  mycroft Make this work.
 1.1 09-Aug-1994  mycroft branches: 1.1.2;
Add NCR 53c8XX driver, originally from Wolfgang Stanglmeier.
 1.1.2.1 11-Aug-1994  mycroft update from trunk
 1.7.42.1 28-Feb-2002  nathanw Catch up to -current.
 1.2 02-Nov-2002  perry change array to unsigned char. fixes 23430 lint warnings. "really!"
 1.1 05-Nov-2000  thorpej branches: 1.1.2; 1.1.4; 1.1.6;
Driver for NeoMagic 256 audio. Based on the OpenBSD driver, which is
in turn based on the FreeBSD driver, ported to NetBSD and somewhat
modified by me. Thanks to Matt Thomas for testing.
 1.1.6.2 06-May-2001  he Pull up revision 1.1 (new, requested by sommerfeld):
Add a driver for the NeoMagic 256 AC'97 chip.
 1.1.6.1 05-Nov-2000  he file neo-coeff.h was added on branch netbsd-1-5 on 2001-05-06 14:39:09 +0000
 1.1.4.1 11-Nov-2002  nathanw Catch up to -current
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 05-Nov-2000  bouyer file neo-coeff.h was added on branch thorpej_scsipi on 2000-11-22 16:04:10 +0000
 1.56 06-Sep-2021  andvar fix various typos in comments.
 1.55 12-Nov-2019  msaitoh Add missing initialization of sc_dev.
 1.54 08-Jun-2019  isaki branches: 1.54.2;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.53 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.52 16-Mar-2019  isaki branches: 1.52.2;
Use C99 style struct initializer to audio_hw_if.
 1.51 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.50 29-Mar-2014  christos branches: 1.50.22; 1.50.28; 1.50.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.49 27-Oct-2012  chs branches: 1.49.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.48 24-Aug-2012  msaitoh branches: 1.48.2;
Fix typos
 1.47 24-Nov-2011  mrg put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.46 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.45 24-Feb-2010  dyoung branches: 1.45.10; 1.45.12;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.44 08-Jan-2010  dyoung branches: 1.44.2;
Expand PMF_FN_* macros.
 1.43 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.42 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.41 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.40 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.39 10-Apr-2008  cegger branches: 1.39.4; 1.39.16; 1.39.18;
use aprint_*_dev and device_xname
 1.38 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.37 09-Dec-2007  jmcneill branches: 1.37.6; 1.37.10;
Merge jmcneill-pm branch.
 1.36 19-Oct-2007  ad branches: 1.36.4; 1.36.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.35 16-Nov-2006  christos branches: 1.35.6; 1.35.8; 1.35.22; 1.35.24; 1.35.28;
__unused removal on arguments; approved by core.
 1.34 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.33 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.32 02-Sep-2006  christos branches: 1.32.2; 1.32.4;
add missing initializer
 1.31 25-Feb-2006  wiz branches: 1.31.2;
Fix some typos.
 1.30 11-Dec-2005  christos branches: 1.30.2; 1.30.4; 1.30.6;
merge ktrace-lwp.
 1.29 28-Jun-2005  thorpej branches: 1.29.2;
Use ANSI function decls and static.
 1.28 08-Apr-2005  kent * neo_intr()
update the watermark for the recording buffer
The fix was provided in PR#26706 by Chapman Flack.
 1.27 27-Feb-2005  perry branches: 1.27.2;
nuke trailing whitespace
 1.26 15-Jan-2005  kent branches: 1.26.2; 1.26.4;
ansify and KNF
 1.25 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.24 29-Oct-2004  yamt branches: 1.24.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.23 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.22 09-Jul-2004  mycroft Clean up. Attempt to make these safer against stray interrupts.
 1.21 09-Jul-2004  mycroft There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.20 30-Oct-2003  simonb branches: 1.20.2;
Remove some assigned-to but otherwise unused variables.
 1.19 03-May-2003  wiz branches: 1.19.2;
DMA, not dma nor Dma.
 1.18 22-Feb-2003  tsutsui hz -> Hz
 1.17 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 14-Jun-2002  thorpej Map the device's memory space with BUS_SPACE_MAP_LINEAR, since we
need to be able to access it as such.

Fixes kern/17114.
 1.12 15-Apr-2002  simonb branches: 1.12.2; 1.12.4;
Fix a couple of tyops.
 1.11 13-Nov-2001  lukem add RCSID
 1.10 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.9 04-Sep-2001  thorpej branches: 1.9.2;
Use bus_space_mmap().
 1.8 14-Mar-2001  drochner branches: 1.8.2; 1.8.4;
this driver doesn't work on my thinkpad, so disable the match for the
IBM/0x00dd subsystem ID too
 1.7 28-Dec-2000  sommerfeld branches: 1.7.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.6 27-Nov-2000  thorpej Power management (well, suspend/resume) is now implemented. Remove
it from the TODO list.
 1.5 27-Nov-2000  sommerfeld Add a powerhook to reload AC97 registers after a resume.
Sound now works after suspend/resume on my Sony PCG-Z505S
 1.4 05-Nov-2000  thorpej branches: 1.4.2;
Two things off the TODO list.
 1.3 05-Nov-2000  thorpej Add mmap support (i386-specific for the moment).
 1.2 05-Nov-2000  thorpej Weed out the Dell and HP versions which are known to work in
WSS emulation mode (i.e. won't work in AC'97 mode).
 1.1 05-Nov-2000  thorpej Driver for NeoMagic 256 audio. Based on the OpenBSD driver, which is
in turn based on the FreeBSD driver, ported to NetBSD and somewhat
modified by me. Thanks to Matt Thomas for testing.
 1.4.2.5 27-Mar-2001  bouyer Sync with HEAD.
 1.4.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.4.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.4.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.1 05-Nov-2000  bouyer file neo.c was added on branch thorpej_scsipi on 2000-11-22 16:04:11 +0000
 1.7.2.7 18-Oct-2002  nathanw Catch up to -current.
 1.7.2.6 20-Jun-2002  nathanw Catch up to -current.
 1.7.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.7.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.3 08-Oct-2001  nathanw Catch up to -current.
 1.7.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.7.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.8.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.2.2 06-May-2001  he Pull up revisions 1.1-1.6, 1.8 (new, requested by sommerfeld):
Add a driver for the NeoMagic 256 AC'97 chip.
 1.8.2.1 14-Mar-2001  he file neo.c was added on branch netbsd-1-5 on 2001-05-06 14:39:36 +0000
 1.9.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.12.4.1 13-Apr-2005  tron Pull up revision 1.28 (requested by kent in ticket #5743):
* neo_intr()
update the watermark for the recording buffer
The fix was provided in PR#26706 by Chapman Flack.
 1.12.2.1 20-Jun-2002  gehenna catch up with -current.
 1.19.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.6 17-Jan-2005  skrll Sync with HEAD.
 1.19.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.19.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.2.1 22-Sep-2004  jmc branches: 1.20.2.1.2;
Pullup rev 1.23 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.20.2.1.2.1 11-May-2005  riz Pull up revision 1.28 (requested by kent in ticket #1413):
* neo_intr()
update the watermark for the recording buffer
The fix was provided in PR#26706 by Chapman Flack.
 1.24.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.24.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.26.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.26.2.1 29-Apr-2005  kent sync with -current
 1.27.2.1 08-Apr-2005  he Pull up revision 1.28 (requested by kent in ticket #127):
In neo_intr(), update the watermark for the recording buffer.
Fixes PR#26706.
 1.29.2.5 17-Mar-2008  yamt sync with head.
 1.29.2.4 21-Jan-2008  yamt sync with head
 1.29.2.3 27-Oct-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.30.6.1 22-Apr-2006  simonb Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.30.2.1 01-Mar-2006  yamt sync with head.
 1.31.2.1 03-Sep-2006  yamt sync with head.
 1.32.4.2 10-Dec-2006  yamt sync with head.
 1.32.4.1 22-Oct-2006  yamt sync with head
 1.32.2.1 18-Nov-2006  ad Sync with head.
 1.35.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.35.24.3 23-Mar-2008  matt sync with HEAD
 1.35.24.2 09-Jan-2008  matt sync with HEAD
 1.35.24.1 06-Nov-2007  matt sync with HEAD
 1.35.22.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.35.22.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.35.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.35.22.1 05-Oct-2007  joerg Convert neo(4) to PNP power management.
 1.35.8.1 23-Oct-2007  ad Sync with head.
 1.35.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.36.6.1 11-Dec-2007  yamt sync with head.
 1.36.4.1 26-Dec-2007  ad Sync with head.
 1.37.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.37.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.37.6.1 24-Mar-2008  keiichi sync with head.
 1.39.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.16.2 12-Dec-2008  ad Checkpoint work in progress.
 1.39.16.1 11-Dec-2008  ad Checkpoint work in progress.
 1.39.4.2 11-Mar-2010  yamt sync with head
 1.39.4.1 16-May-2009  yamt sync with head
 1.44.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.45.12.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.45.12.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.45.10.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.10.2 30-Oct-2012  yamt sync with head
 1.45.10.1 17-Apr-2012  yamt sync with head
 1.48.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.49.2.1 18-May-2014  rmind sync with head
 1.50.30.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.30.1 10-Jun-2019  christos Sync with HEAD
 1.50.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.50.22.1 14-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1439):

sys/dev/sbus/sio16.c: revision 1.25
sys/dev/gpib/mt.c: revision 1.33
sys/arch/mvme68k/dev/wdsc.c: revision 1.33
sys/dev/gpib/ct.c: revision 1.31
sys/dev/isa/mcd.c: revision 1.119
sys/dev/pci/if_stge.c: revision 1.73
sys/dev/gpib/ppi.c: revision 1.25
sys/dev/pcmcia/if_tr_pcmcia.c: revision 1.29
sys/arch/amiga/dev/zssc.c: revision 1.46
sys/arch/mac68k/obio/iwm_fd.c: revision 1.57
sys/arch/amiga/dev/if_qn.c: revision 1.48
sys/dev/isa/tcic2_isa.c: revision 1.28
sys/dev/isa/uha_isa.c: revision 1.42
sys/dev/pci/neo.c: revision 1.55
sys/arch/next68k/dev/nextdisplay.c: revision 1.22
sys/dev/isa/if_iy.c: revision 1.111

Add missing initialization of sc_dev.


Initialize sc_dev correctly to avoid null pointer dereference when
bus_space_map() failed.


Add missing initialization of sc_dev.
 1.52.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.52.2.2 28-Apr-2019  isaki Adapt to audio2.
- XXX In audio2, number of blocks must be 3 or greater, so
modify round_blocksize() to return bufsize / 4.
- XXX Doesn't neo_trigger_input() need to subtract ssz from
buffer end like trigger_output()?
 1.52.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.54.2.1 14-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #425):

sys/dev/sbus/sio16.c: revision 1.25
sys/dev/gpib/mt.c: revision 1.33
sys/arch/mvme68k/dev/wdsc.c: revision 1.33
sys/dev/gpib/ct.c: revision 1.31
sys/dev/isa/mcd.c: revision 1.119
sys/dev/pci/if_stge.c: revision 1.73
sys/dev/gpib/ppi.c: revision 1.25
sys/dev/pcmcia/if_tr_pcmcia.c: revision 1.29
sys/arch/amiga/dev/zssc.c: revision 1.46
sys/arch/mac68k/obio/iwm_fd.c: revision 1.57
sys/arch/amiga/dev/if_qn.c: revision 1.48
sys/dev/isa/tcic2_isa.c: revision 1.28
sys/dev/isa/uha_isa.c: revision 1.42
sys/dev/pci/neo.c: revision 1.55
sys/arch/next68k/dev/nextdisplay.c: revision 1.22
sys/dev/isa/if_iy.c: revision 1.111

Add missing initialization of sc_dev.

Initialize sc_dev correctly to avoid null pointer dereference when
bus_space_map() failed.

Add missing initialization of sc_dev.
 1.1 05-Nov-2000  thorpej branches: 1.1.2; 1.1.6;
Driver for NeoMagic 256 audio. Based on the OpenBSD driver, which is
in turn based on the FreeBSD driver, ported to NetBSD and somewhat
modified by me. Thanks to Matt Thomas for testing.
 1.1.6.2 06-May-2001  he Pull up revision 1.1 (new, requested by sommerfeld):
Add a driver for the NeoMagic 256 AC'97 chip.
 1.1.6.1 05-Nov-2000  he file neoreg.h was added on branch netbsd-1-5 on 2001-05-06 14:39:10 +0000
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 05-Nov-2000  bouyer file neoreg.h was added on branch thorpej_scsipi on 2000-11-22 16:04:12 +0000
 1.29 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.28 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.27 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.26 24-Apr-2021  thorpej branches: 1.26.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.25 22-Dec-2019  thorpej branches: 1.25.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.24 14-Feb-2016  chs branches: 1.24.18;
zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.23 14-Feb-2012  pgoyette branches: 1.23.6; 1.23.24;
Replace the xxx_acquire()/xxx_release() rwlocks with mutexes. There are
only RW_WRITERs for these, and no RW_READERs, so no need to incur the
extra overhead of allowing for both. As discussed on tech-kern.

For piixpm and ichsmb, the acquire/release protocol needs to be used,
even if the request is I2C_F_POLL'd (or if the device supports only
polled mode). Otherwise multiple requests can be running at the same
time, and they stomp on each other and create anomolous results.

Part 2 addresses my PR kern/45889

3 ACKs from releng
 1.22 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.21 08-May-2010  pgoyette branches: 1.21.8; 1.21.12;
Recognize additional SMBus controllers. From FreeBSD.
 1.20 09-May-2009  pgoyette branches: 1.20.2; 1.20.4;
For multi-byte transfers, the bytes need to be written to or read from
consecutive data registers. Discovered while debugging sdtemp(4) driver
which does _only_ 16-bit transfers!
 1.19 09-May-2009  pgoyette You can't use a BYTE protocol to read 16-bits worth of data from the
i2c bus. Discovered while debugging my sdtemp(4) driver.
 1.18 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.17 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.16 03-Feb-2009  pgoyette branches: 1.16.2;
Update the i2c_exec() functions to handle quick_read/quick_write protocol.

Although interface routines i2c_smbus_*() exist, nothing in NetBSD actually
uses them yet.
 1.15 15-Oct-2008  pgoyette branches: 1.15.2;
If we're doing a 2-byte read, return the entire 16-bit result.
 1.14 25-May-2008  cegger branches: 1.14.4;
add comment why NULL handlers are sufficient.
requested and ok'd by jmcneill
 1.13 25-May-2008  cegger add power management support
 1.12 27-Mar-2008  kiyohara branches: 1.12.2; 1.12.4; 1.12.6;
Split device_t/softc.
 1.11 14-Jan-2008  xtraeme branches: 1.11.6;
Fix the BARs on nForce 430, which failed to attach. Reported by
atsushi fukumoto in PR kern/37756.
 1.10 04-Dec-2007  xtraeme branches: 1.10.4;
Newer nForce MCP SMBus devices use different PCI BARs than the old ones
(nForce 2/3/4).

nfsmb(4) is now properly working on newer MCPs, tested by wiz@ on MCP55:

nfsmbc0 at pci0 dev 1 function 1: NVIDIA nForce MCP55 SMBus Controller (rev. 0xa2)
nfsmb0 at nfsmbc0 SMBus 1
iic0 at nfsmb0: I2C bus
spdmem0 at iic0 addr 0x51
spdmem0: DDR2 SDRAM memory, data ECC, 1024MB, 667MHz, PC2-5300
spdmem0: 14 rows, 10 cols, 2 ranks, 4 banks/chip, 3.00ns cycle time
spdmem0: voltage SSTL 1.8V, refresh time 7.8us (self-refreshing)
nfsmb1 at nfsmbc0 SMBus 2
iic1 at nfsmb1: I2C bus
 1.9 14-Nov-2007  xtraeme branches: 1.9.2;
Attach to NVIDIA MCP73 now that we have the PCI id.
 1.8 14-Nov-2007  xtraeme Attach to more NVIDIA SMBus controllers.
 1.7 19-Oct-2007  ad branches: 1.7.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 01-Sep-2007  riz branches: 1.6.2; 1.6.6;
For SMBus, add the ability to enumerate devices on the bus.
This does NOT identify the devices, merely indicates the
presence of devices at certain addresses. Tested on ichsmb
and nfsmb - other SMBus devices will need to ensure the
proper bus type is set. (I2C_TYPE_SMBUS)

From Nicolas Joly, via Paul Goyette, in PR#36744.
 1.5 27-Aug-2007  xtraeme branches: 1.5.2;
Use rwlock(9) rather than lockmgr(9).
 1.4 14-Aug-2007  kiyohara Remove and insert null-line.
No parentheses are needed around the return value.
 1.3 28-Jul-2007  kiyohara branches: 1.3.4; 1.3.6;
s/uint32_t reg/pcireg_t reg/.
Check condition `!= 0'.
 1.2 21-Jul-2007  kiyohara We wait for the clearness of the NFORCE_SMB_PROTOCOL as transfer completion.
And, the maximum is assumed to be 10msec. I think that the thing for which
it waits any further is dangerous for the system.
 1.1 11-Jul-2007  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Add support for NVIDIA nForce 2/3/4 SMBus controller and SMBus driver.
 1.1.6.2 03-Sep-2007  skrll Sync with HEAD.
 1.1.6.1 15-Aug-2007  skrll Sync with HEAD.
 1.1.4.5 23-Oct-2007  ad Sync with head.
 1.1.4.4 09-Oct-2007  ad Sync with head.
 1.1.4.3 20-Aug-2007  ad Sync with HEAD.
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 11-Jul-2007  ad file nfsmb.c was added on branch vmlocking on 2007-07-15 13:21:37 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 11-Jul-2007  mjf file nfsmb.c was added on branch mjf-ufs-trans on 2007-07-11 20:07:53 +0000
 1.3.6.2 28-Jul-2007  kiyohara s/uint32_t reg/pcireg_t reg/.
Check condition `!= 0'.
 1.3.6.1 28-Jul-2007  kiyohara file nfsmb.c was added on branch matt-mips64 on 2007-07-28 12:31:51 +0000
 1.3.4.5 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.4.4 14-Nov-2007  joerg Sync with HEAD.
 1.3.4.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.4.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.3.4.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.5.2.3 23-Mar-2008  matt sync with HEAD
 1.5.2.2 09-Jan-2008  matt sync with HEAD
 1.5.2.1 06-Nov-2007  matt sync with HEAD
 1.6.6.2 18-Nov-2007  bouyer Sync with HEAD
 1.6.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.2.6 21-Jan-2008  yamt sync with head
 1.6.2.5 07-Dec-2007  yamt sync with head
 1.6.2.4 15-Nov-2007  yamt sync with head.
 1.6.2.3 27-Oct-2007  yamt sync with head.
 1.6.2.2 03-Sep-2007  yamt sync with head.
 1.6.2.1 01-Sep-2007  yamt file nfsmb.c was added on branch yamt-lazymbuf on 2007-09-03 14:37:13 +0000
 1.7.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.7.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.7.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.9.2.1 08-Dec-2007  ad Sync with head.
 1.10.4.1 19-Jan-2008  bouyer Sync with HEAD
 1.11.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.11.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.4.3 11-Aug-2010  yamt sync with head.
 1.12.4.2 16-May-2009  yamt sync with head
 1.12.4.1 04-May-2009  yamt sync with head.
 1.12.2.1 04-Jun-2008  yamt sync with head
 1.14.4.1 19-Oct-2008  haad Sync with HEAD.
 1.15.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.16.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.4.1 30-May-2010  rmind sync with head
 1.20.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.12.1 18-Feb-2012  mrg merge to -current.
 1.21.8.1 17-Apr-2012  yamt sync with head
 1.23.24.1 19-Mar-2016  skrll Sync with HEAD
 1.23.6.1 03-Dec-2017  jdolecek update from HEAD
 1.24.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.25.10.2 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.25.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.26.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 04-Dec-2007  xtraeme Newer nForce MCP SMBus devices use different PCI BARs than the old ones
(nForce 2/3/4).

nfsmb(4) is now properly working on newer MCPs, tested by wiz@ on MCP55:

nfsmbc0 at pci0 dev 1 function 1: NVIDIA nForce MCP55 SMBus Controller (rev. 0xa2)
nfsmb0 at nfsmbc0 SMBus 1
iic0 at nfsmb0: I2C bus
spdmem0 at iic0 addr 0x51
spdmem0: DDR2 SDRAM memory, data ECC, 1024MB, 667MHz, PC2-5300
spdmem0: 14 rows, 10 cols, 2 ranks, 4 banks/chip, 3.00ns cycle time
spdmem0: voltage SSTL 1.8V, refresh time 7.8us (self-refreshing)
nfsmb1 at nfsmbc0 SMBus 2
iic1 at nfsmb1: I2C bus
 1.1 11-Jul-2007  kiyohara branches: 1.1.2; 1.1.4; 1.1.10; 1.1.12; 1.1.14; 1.1.20; 1.1.22;
Add support for NVIDIA nForce 2/3/4 SMBus controller and SMBus driver.
 1.1.22.1 08-Dec-2007  ad Sync with head.
 1.1.20.1 08-Dec-2007  mjf Sync with HEAD.
 1.1.14.3 07-Dec-2007  yamt sync with head
 1.1.14.2 03-Sep-2007  yamt sync with head.
 1.1.14.1 11-Jul-2007  yamt file nfsmbreg.h was added on branch yamt-lazymbuf on 2007-09-03 14:37:14 +0000
 1.1.12.1 09-Jan-2008  matt sync with HEAD
 1.1.10.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.1.4.2 15-Jul-2007  ad Sync with head.
 1.1.4.1 11-Jul-2007  ad file nfsmbreg.h was added on branch vmlocking on 2007-07-15 13:21:37 +0000
 1.1.2.2 11-Jul-2007  mjf Sync with head.
 1.1.2.1 11-Jul-2007  mjf file nfsmbreg.h was added on branch mjf-ufs-trans on 2007-07-11 20:07:54 +0000
 1.13 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.12 14-Jul-2016  msaitoh branches: 1.12.16; 1.12.18;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.11 11-Jul-2016  msaitoh KNF. No functional change.
 1.10 29-Mar-2014  christos branches: 1.10.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.9 09-Jul-2008  joerg branches: 1.9.28; 1.9.38; 1.9.44;
- device/softc split
 1.8 28-Apr-2008  martin branches: 1.8.2; 1.8.4; 1.8.6;
Remove clause 3 and 4 from TNF licenses
 1.7 10-Apr-2008  cegger branches: 1.7.2; 1.7.4;
use aprint_*_dev and device_xname
 1.6 19-Oct-2007  ad branches: 1.6.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 16-Nov-2006  christos branches: 1.5.8; 1.5.22; 1.5.24; 1.5.28;
__unused removal on arguments; approved by core.
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 11-Dec-2005  christos branches: 1.3.20; 1.3.22;
merge ktrace-lwp.
 1.2 26-Aug-2004  thorpej branches: 1.2.2; 1.2.4; 1.2.6; 1.2.18;
Use ANSI function decls, more static.
 1.1 26-Aug-2004  itohy Workbit NinjaSCSI-32 PCI/CardBus SCSI driver (njs)
 1.2.18.2 27-Oct-2007  yamt sync with head.
 1.2.18.1 30-Dec-2006  yamt sync with head.
 1.2.6.2 11-Nov-2004  he Pull up revisions 1.1-1.2 (via patch, requested by itohy in ticket #1741):
Add support for the Workbit NinjaSCSI-32 PCI/Cardbus
SCSI driver, njs(4).
 1.2.6.1 26-Aug-2004  he file njs_pci.c was added on branch netbsd-1-6 on 2004-11-11 23:21:34 +0000
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Sep-2004  skrll Sync with HEAD
 1.2.4.1 26-Aug-2004  skrll file njs_pci.c was added on branch ktrace-lwp on 2004-09-03 12:45:28 +0000
 1.2.2.3 30-Aug-2004  tron Pull up revision 1.2 (requested by itohy in ticket #800):
Use ANSI function decls, more static.
 1.2.2.2 30-Aug-2004  tron Pull up revision 1.1 (requested by itohy in ticket #800):
Workbit NinjaSCSI-32 PCI/CardBus SCSI driver (njs)
 1.2.2.1 26-Aug-2004  tron file njs_pci.c was added on branch netbsd-2-0 on 2004-08-30 09:24:58 +0000
 1.3.22.2 10-Dec-2006  yamt sync with head.
 1.3.22.1 22-Oct-2006  yamt sync with head
 1.3.20.1 18-Nov-2006  ad Sync with head.
 1.5.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.24.1 06-Nov-2007  matt sync with HEAD
 1.5.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.8.1 23-Oct-2007  ad Sync with head.
 1.6.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.6.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.4.2 04-May-2009  yamt sync with head.
 1.7.4.1 16-May-2008  yamt sync with head.
 1.7.2.1 18-May-2008  yamt sync with head.
 1.8.6.1 19-Oct-2008  haad Sync with HEAD.
 1.8.4.1 18-Jul-2008  simonb Sync with head.
 1.8.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.44.1 18-May-2014  rmind sync with head
 1.9.38.2 03-Dec-2017  jdolecek update from HEAD
 1.9.38.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.28.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.6.1 05-Oct-2016  skrll Sync with HEAD
 1.12.18.1 10-Jun-2019  christos Sync with HEAD
 1.12.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.10 04-Jan-2017  christos PR/51774: David Binderman: Remove unused variable.
 1.9 07-Oct-2013  jakllsch branches: 1.9.6; 1.9.10;
Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.8 07-Oct-2013  jakllsch Remove unused structure.
 1.7 31-Jul-2012  bouyer branches: 1.7.2; 1.7.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.6 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.5 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.4 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.3 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.2 04-Apr-2011  dyoung branches: 1.2.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.1 10-Nov-2010  skrll branches: 1.1.2; 1.1.6;
Add nside(4) - a driver for the National Semiconductor PC87415 IDE
controller as found in many HP PA-RISC machines.

From OpenBSD.

Reviewed by Manuel Bouyer.
 1.1.6.3 21-Apr-2011  rmind sync with head
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 10-Nov-2010  rmind file nside.c was added on branch rmind-uvmplock on 2011-03-05 20:53:47 +0000
 1.1.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.1 30-Oct-2012  yamt sync with head
 1.7.4.1 18-May-2014  rmind sync with head
 1.7.2.3 03-Dec-2017  jdolecek update from HEAD
 1.7.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.9.10.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.6.1 05-Feb-2017  skrll Sync with HEAD
 1.37 15-Aug-2022  pgoyette Remove stray debug line (already commented out)
 1.36 09-Jul-2022  pgoyette Remove redundant ``devsw_ok = false;''

Thanks mrg@
 1.35 08-Jul-2022  pgoyette devsw_ok needs to survive across invocations of nvme_modcmd() so
allocate it statically.

Should address remaining issues with kern/56914
 1.34 08-Jul-2022  pgoyette Initialize cmajor & bmajor so the devsw_attach() has a chance of
succeeding.

Record the success of devsw_attach(), and do not try later to
devsw_detach() unless the attach succeeded.

Partial fix for kern/56914
 1.33 07-Jul-2022  pgoyette Add errno tto message when fail to attach the devsw
 1.32 31-Mar-2022  pgoyette For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence. This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

devsw_attach()
config_init_component() or config_cf*_attach()
...
config_fini_component() or config_cf*_detach()
devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
1. compile without build break
2. no related test failures from atf
3. modload/modunload work as well as
before.

No functional device testing done, since I don't have any
of these devices. Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken; see kern/56772. This commit does not break
any additional modules (as far as I know).
 1.31 10-Oct-2021  skrll Catch up with pcireg.h change
 1.30 29-May-2021  riastradh nvme(4): Add suspend/resume, derived from OpenBSD.
 1.29 29-Jul-2020  jdolecek branches: 1.29.6; 1.29.8;
rename label now that it has dual purpose; suggested by mrg@
 1.28 28-Jul-2020  jdolecek add a quirk to disable MSI, and enable it for Intel SSD DC P4500

this device seems to cause serious system responsiveness issues when configured
to use MSI, while it works fine when configured for either INTx or MSI-X

this is important so this works well under Xen Dom0, which doesn't
support MSI-X yet

fixes another issue reported as feedback for PR port-xen/55285 by Frank Kardel
 1.27 02-Dec-2019  msaitoh Use PCI_MSIX_"TBL"BIR_MASK instead of PCI_MSIX_"PBA"BIR_MASK for MSI-X table.
This is not a real bug because both macros have the same value.
 1.26 23-Jan-2019  msaitoh branches: 1.26.4;
Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them expilicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.25 07-Dec-2018  msaitoh No functional change. OK'd by nonaka:
- Use correct macro.
- Don't use magic number.
 1.24 01-Dec-2018  jdolecek fix pasto (MSI -> MSIX)
 1.23 01-Dec-2018  jdolecek allow MSI-X even with just one interrupt, on some systems MSI/INTx might
not be available (or working, for that matter)
 1.22 01-Dec-2018  jdolecek simplify the interrupt allocation - it's not necessary to do the explicit
fallbacks, pci_intr_alloc() does this already internally
 1.21 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.20 18-Apr-2018  nonaka branches: 1.20.2;
nvme(4): Added some delay before check RDY bit quirk when disabling device.

Pick from FreeBSD nvme(4) r326937.
 1.19 01-Jun-2017  chs branches: 1.19.2; 1.19.8; 1.19.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.18 13-Feb-2017  nonaka remove extra crlf.
 1.17 25-Nov-2016  knakahara branches: 1.17.2;
"#ifdef __HAVE_PCI_MSI_MSIX" workaround is not required any more.

see sys/dev/pci/pci_stub.c r1.6
 1.16 19-Oct-2016  jdolecek follow advice of spec and block interrupts via INTMS/INTMC for intx handler;
this also makes it possible to offload the actual interrupt processing to softintr
handler, similar as for MSI/MSI-X
 1.15 27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.14 18-Sep-2016  jdolecek fix several bugs, make nvme(4) MPSAFE by default and also bump default
number of ioq from 128 to 1024; tested with VirtualBox and QEMU

* remove NVME_INTMC/NVME_INTMS writes in hw intr handler as this is not MPSAFE,
fortunately they don't seem to be necessary; shaves two register writes
* need to use full mutex_enter() in nvme_q_complete(), to avoid small
race between one handler exiting the loop and another entering
* for MSI, handover the command result processing to softintr; unfortunately
can't easily do that for INTx interrupts as they require doorbell write
to deassert
* unlock/relock q->q_cq_mtx before calling ccb_done to avoid potential deadlocks
* make sure to destroy queue mutexes when destroying the queue (LOCKDEBUG)
* make ns ctx pool per-device, so that it's deallocated properly on module
unload
* handle ctx allocation failure in ld_nvme_dobio()
* remove splbio() calls in ld_nvme_dobio() and sync, the paths are exercised
only for dump/shutdown, and that already disables interrupts
* free the ns ctx in ld_nvme_biodone() before calling lddone() to avoid
memory starvation, as lddone() can trigger another i/o request
* be more careful with using PR_WAITOK, the paths are called from interrupt
context and there we can't wait
 1.13 18-Sep-2016  jdolecek attach also the nvme_cdevsw when loaded as module, so /dev/nvme* works
 1.12 17-Sep-2016  jdolecek remove dev code included in previous commit by mistake
 1.11 17-Sep-2016  jdolecek #ifdef out MSI related code on platforms not supporting MSI, so that it's
possible to load the driver as module on those platforms (the weak symbols
are not found by module load, claiming they don't exist); this makes it possible
to load the driver on e.g. sparc64, which is supposed to be working
under OpenBSD

unfortunately QEMU sparc64 emulator starts causing data access errors
on first device register read in nvme_attach(), so can't confirm the driver
is actually working on sparc64; same happens in QEMU when booting OpenBSD
image, so it seems to be emulator bug
 1.10 17-Sep-2016  jdolecek actually detach the ld {b,c}devsw on unload, and fail load if it's already
present
 1.9 17-Sep-2016  jdolecek need to set PCI_COMMAND_MASTER_ENABLE flag; fixes the driver under QEMU
 1.8 17-Sep-2016  pgoyette Since the ld code included with the nvme module references stuff in
the dk_subr module, add a dependency.
 1.7 16-Sep-2016  pgoyette We need sys/module.h for built-in modules as well as for the .kmod so
#include it unconditionally.
 1.6 16-Sep-2016  jdolecek make it possible to load nvme(4) as module to ease testing; currently somewhat
non-optimal, since it includes the ld(4) code also and hence requires the
kernel config to have 'no ld'
 1.5 16-Sep-2016  jdolecek fix nvme_pci_detach() to not pci_intr_disestablish(); the interrupts
are disestablished and handler pointers are set to NULL already by
nvme_detach(), leading to panic here; this was happening when running
on system without MSI/MSI-X

change all the alloc/dealloc code for sc_ih to use psc->psc_nintrs, so
that we avoid some duplicated logic
 1.4 11-Jul-2016  knakahara branches: 1.4.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.3 24-Jun-2016  nonaka fix free memory size.
 1.2 11-May-2016  nonaka branches: 1.2.2;
Don't establish interrupt in nvme_pci_attach() when multi queue isn't used.
 1.1 01-May-2016  nonaka Added nvme(4) for Non-Volatile Memory Host Controller Interface devices.
Ported from OpenBSD.
 1.2.2.6 28-Aug-2017  skrll Sync with HEAD
 1.2.2.5 05-Dec-2016  skrll Sync with HEAD
 1.2.2.4 05-Oct-2016  skrll Sync with HEAD
 1.2.2.3 09-Jul-2016  skrll Sync with HEAD
 1.2.2.2 29-May-2016  skrll Sync with HEAD
 1.2.2.1 11-May-2016  skrll file nvme_pci.c was added on branch nick-nhusb on 2016-05-29 08:44:22 +0000
 1.4.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.17.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.19.10.4 26-Jan-2019  pgoyette Sync with HEAD
 1.19.10.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.19.10.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.19.10.1 22-Apr-2018  pgoyette Sync with HEAD
 1.19.8.2 03-Dec-2017  jdolecek update from HEAD
 1.19.8.1 01-Jun-2017  jdolecek file nvme_pci.c was added on branch tls-maxphys on 2017-12-03 11:37:08 +0000
 1.19.2.3 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1714:

sys/dev/pci/pcireg.h 1.148-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.217-1.222, 1.224, 1.227-1.232
via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158
sys/dev/pci/ppb.c 1.74

- Print Bridge Config Retry Enable bit and Retimer Presence Detect
Supported bit.
- Add PCIe 4.0 stuff a little:
- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.
- Change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack.
- Print some DPC register values not with %04x but with %08x because
those are 32bit.
- Fix a bug that the virtual channel extended configuration's
arbitration phase register can't be decoded correctly.
- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Remove unused shift and mask definitions.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.19.2.2 27-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1172):

sys/dev/pci/nvme_pci.c: revision 1.26
sys/dev/pci/xhci_pci.c: revision 1.21
sys/dev/pci/ixgbe/ixv.c: revision 1.108
sys/dev/pci/ixgbe/ixgbe.c: revision 1.171
sys/dev/pci/if_fxp_pci.c: revision 1.84
sys/dev/pci/if_fxp_pci.c: revision 1.85
sys/dev/pci/xhci_pci.c: revision 1.16

remove #ifdef DEBUG printf, it seems to have outlived it's usefulness

-

KNF. No functional change.

-

Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them explicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.19.2.1 19-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #781):

sbin/nvmectl/Makefile 1.4
sbin/nvmectl/bignum.c 1.2
sbin/nvmectl/devlist.c 1.3-1.5
sbin/nvmectl/firmware.c 1.3,1.4
sbin/nvmectl/identify.c 1.3-1.5
sbin/nvmectl/logpage.c 1.5-1.7
sbin/nvmectl/nvme.h 1.3
sbin/nvmectl/nvmectl.8 1.5
sbin/nvmectl/nvmectl.c 1.5-1.7
sbin/nvmectl/nvmectl.h 1.5-1.8
sbin/nvmectl/perftest.c 1.3-1.5
sbin/nvmectl/power.c 1.3,1.4
sbin/nvmectl/reset.c 1.2,1.3
sbin/nvmectl/util.c 1.1,1.2
sbin/nvmectl/wdc.c 1.2-1.4
sys/dev/ic/ld_nvme.c 1.20
sys/dev/ic/nvme.c 1.38,1.39
sys/dev/ic/nvmeio.h 1.2
sys/dev/ic/nvmereg.h 1.10,1.11
sys/dev/ic/nvmevar.h 1.16
sys/dev/pci/nvme_pci.c 1.20

nvmectl(8): Sync with FreeBSD nvmecontrol(8) r328763.

nvmectl(8): fix wdc command usage.

nvme(4): Added some delay before check RDY bit quirk when disabling device.
Pick from FreeBSD nvme(4) r326937.

Add some new structure fileds, opcodes and statuses from NVMe 1.3a.

nvmectl(8): Add big-endian support.
from FreeBSD nvmecontolr(8) r329824.

nvmectl(8): fix subcommand usage.

nvmectl(8): Remove some wdc subcommands from man page.
- wdc drive-log
- wdc get-crash-dump
- wdc purge
- wdc purge-monitor

Typos.

use setprogname()/getprogname(), do not hardcode the prognam name in fixed
strings
 1.20.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.20.2.1 10-Jun-2019  christos Sync with HEAD
 1.26.4.2 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1384:

sys/dev/pci/pcireg.h 1.152-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.222, 1.227-1.232 via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158, 1.163
sys/dev/pci/ppb.c 1.74

- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.26.4.1 21-Jun-2021  martin Pull up following revision(s) (requested by riastradh in ticket #1305):

sys/dev/ic/nvmevar.h: revision 1.22
sys/dev/ic/nvme.c: revision 1.56
sys/dev/ic/nvme.c: revision 1.57
sys/dev/pci/nvme_pci.c: revision 1.30

nvme(4): Add suspend/resume, derived from OpenBSD.

nvme(4): Move disestablishment of admin q interrupt to nvme_detach.

Nothing re-established this after suspend/resume, so attempting
suspend/resume/suspend would crash, and presumably we would miss
interrupts after resume. This keeps the establish/disestablish more
symmetric in attach/detach.
 1.29.8.1 31-May-2021  cjep sync with head
 1.29.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.51 26-Sep-2021  thorpej - Use seltrue_filtops rather than rolling our own with filt_seltrue.
- Remove sc_wsel completely; nothing actually uses it.
 1.50 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.49 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.48 24-Apr-2021  thorpej branches: 1.48.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.47 18-Dec-2020  thorpej branches: 1.47.2;
Use sel{record,remove}_knote().
 1.46 09-Dec-2018  jdolecek branches: 1.46.12;
use pci_intr_establish_xname() everywhere
 1.45 25-Oct-2017  maya branches: 1.45.2; 1.45.4;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.44 20-Aug-2017  maxv M_WAITOK cannot fail, so remove the test branches. Otherwise it looks
like leak/uninitialized area.
 1.43 24-Jul-2015  martin Pass the device, not the struct softc to config_found().
Avoids a crash at attach time, PR port-i386/50076.
 1.42 29-Mar-2014  christos branches: 1.42.4; 1.42.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.41 20-Mar-2014  christos fix format confusion
 1.40 20-Mar-2014  christos make it compile on amd64
 1.39 27-Oct-2012  chs branches: 1.39.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.38 13-Nov-2010  uebayasi branches: 1.38.8; 1.38.18;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.37 26-Nov-2009  njoly branches: 1.37.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.36 12-Nov-2009  dyoung Remove superfluous activation hook.
 1.35 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.34 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.33 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32 28-Apr-2008  martin branches: 1.32.14;
Remove clause 3 and 4 from TNF licenses
 1.31 10-Apr-2008  cegger branches: 1.31.2; 1.31.4;
use aprint_*_dev and device_xname
 1.30 01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.29 15-Dec-2007  perry branches: 1.29.2; 1.29.6;
__FUNCTION__ -> __func__
 1.28 05-Dec-2007  pooka branches: 1.28.4;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.27 19-Oct-2007  ad branches: 1.27.2; 1.27.4;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.26 09-Jul-2007  ad branches: 1.26.6; 1.26.8; 1.26.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.25 04-Mar-2007  christos branches: 1.25.2; 1.25.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.24 16-Nov-2006  christos branches: 1.24.4;
__unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 17-Aug-2006  he branches: 1.22.2; 1.22.4;
Make this build again without OBOE_DEBUG defined (get rid of warnings
about unused variables).
 1.21 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.20 11-Dec-2005  christos branches: 1.20.4; 1.20.8;
merge ktrace-lwp.
 1.19 28-Jun-2005  thorpej branches: 1.19.2;
Use ANSI function decls and static.
 1.18 27-Feb-2005  perry nuke trailing whitespace
 1.17 28-Oct-2003  mycroft branches: 1.17.8; 1.17.10;
Remove unnecessary code.
 1.16 25-Oct-2003  christos Fix uninitialized variable warnings
 1.15 21-Oct-2003  fvdl And the wise man said: An u_int32_t is not a pointer, my young apprentice,
so thou shalt not compare it to NULL.
 1.14 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.13 29-Jun-2003  fvdl branches: 1.13.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.12 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.11 26-Nov-2002  christos si_ -> sel_
 1.10 26-Nov-2002  fvdl Add a comment marking this file as broken on most non-i386 -- vtophys usage.
 1.9 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.8 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.7 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 11-Dec-2001  augustss branches: 1.5.2; 1.5.4;
Recognized Danube chip as well.
Small cleanup.
 1.4 05-Dec-2001  augustss Do SIR framing on incoming frames.
 1.3 04-Dec-2001  augustss Simplify interface to irframe.
 1.2 02-Dec-2001  augustss Touch up a little. No functional change.
 1.1 02-Dec-2001  augustss Add driver for the Toshiba's Oboe IrDA chip. From Jan Sparud.
 1.5.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.4.3 02-Oct-2002  jdolecek do not need the (void *) cast for kn_hook anymore
 1.5.4.2 10-Jan-2002  thorpej Add kqueue support to the IrDA framework.
 1.5.4.1 11-Dec-2001  thorpej file oboe.c was added on branch kqueue on 2002-01-10 18:29:10 +0000
 1.5.2.5 11-Dec-2002  thorpej Sync with HEAD.
 1.5.2.4 11-Nov-2002  nathanw Catch up to -current
 1.5.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.5.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.5.2.1 11-Dec-2001  nathanw file oboe.c was added on branch nathanw_sa on 2002-01-08 00:31:08 +0000
 1.13.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.2 03-Aug-2004  skrll Sync with HEAD
 1.13.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.17.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.8.1 29-Apr-2005  kent sync with -current
 1.19.2.7 17-Mar-2008  yamt sync with head.
 1.19.2.6 21-Jan-2008  yamt sync with head
 1.19.2.5 07-Dec-2007  yamt sync with head
 1.19.2.4 27-Oct-2007  yamt sync with head.
 1.19.2.3 03-Sep-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.20.8.1 03-Sep-2006  yamt sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.22.4.2 10-Dec-2006  yamt sync with head.
 1.22.4.1 22-Oct-2006  yamt sync with head
 1.22.2.1 18-Nov-2006  ad Sync with head.
 1.24.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.4.1 11-Jul-2007  mjf Sync with head.
 1.25.2.2 23-Oct-2007  ad Sync with head.
 1.25.2.1 05-Apr-2007  ad Compile fixes.
 1.26.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.8.3 23-Mar-2008  matt sync with HEAD
 1.26.8.2 09-Jan-2008  matt sync with HEAD
 1.26.8.1 06-Nov-2007  matt sync with HEAD
 1.26.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.26.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.27.4.2 26-Dec-2007  ad Sync with head.
 1.27.4.1 08-Dec-2007  ad Sync with head.
 1.27.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.27.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.28.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.29.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.29.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.29.2.1 24-Mar-2008  keiichi sync with head.
 1.31.4.3 11-Mar-2010  yamt sync with head
 1.31.4.2 16-May-2009  yamt sync with head
 1.31.4.1 16-May-2008  yamt sync with head.
 1.31.2.1 18-May-2008  yamt sync with head.
 1.32.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.37.4.1 05-Mar-2011  rmind sync with head
 1.38.18.3 03-Dec-2017  jdolecek update from HEAD
 1.38.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.38.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.8.1 30-Oct-2012  yamt sync with head
 1.39.2.1 18-May-2014  rmind sync with head
 1.42.6.2 28-Aug-2017  skrll Sync with HEAD
 1.42.6.1 22-Sep-2015  skrll Sync with HEAD
 1.42.4.1 30-Jul-2015  snj Pull up following revision(s) (requested by martin in ticket #887):
sys/dev/pci/oboe.c: revision 1.43
Pass the device, not the struct softc to config_found().
Avoids a crash at attach time, PR port-i386/50076.
 1.45.4.1 10-Jun-2019  christos Sync with HEAD
 1.45.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.46.12.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.47.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.48.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 02-Dec-2001  augustss branches: 1.1.2; 1.1.4; 1.1.118; 1.1.120; 1.1.122;
Add driver for the Toshiba's Oboe IrDA chip. From Jan Sparud.
 1.1.122.1 16-May-2008  yamt sync with head.
 1.1.120.1 18-May-2008  yamt sync with head.
 1.1.118.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 02-Dec-2001  thorpej file oboereg.h was added on branch kqueue on 2002-01-10 19:56:51 +0000
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 02-Dec-2001  nathanw file oboereg.h was added on branch nathanw_sa on 2002-01-08 00:31:08 +0000
 1.61 31-Mar-2025  riastradh ohci@pci: Don't detach on shutdown.

If there's some USB device that requires detach on shutdown (which
would be surprising, because USB devices should generally be safe to
yank at any time, and _storage_ drivers such as ld(4) or sd(4) should
already be synced at shutdown some other way) then that driver should
have DVF_DETACH_SHUTDOWN -- not the entire HCI.

PR port-amd64/59180: System reboots instead of shutting down
PR kern/59179: DVF_DETACH_SHUTDOWN: audit drivers for unnecessary use
 1.60 31-Mar-2025  riastradh ohci(4): Rework detach logic and justify the ordering.

Handle failed attach when we detach.

This changes the signature of the ohci_detach function, but it is
only ever used by statically linked ohci bus attachments, never by
modules so far, so no kernel revbump.

PR port-amd64/59180: System reboots instead of shutting down
 1.59 07-Aug-2021  thorpej branches: 1.59.12;
Merge thorpej-cfargs2.
 1.58 24-Apr-2021  thorpej branches: 1.58.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.57 09-Apr-2018  jakllsch branches: 1.57.18;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.
 1.56 10-May-2017  msaitoh branches: 1.56.8;
Use pci_intr_establish_xname().
 1.55 23-Apr-2016  skrll branches: 1.55.8;
Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
 1.54 19-Aug-2015  skrll Interrupt handlers aren't MP-safe yet so use IPL_USB which is IPL_VM
which takes the kernel lock.
 1.53 21-Sep-2014  christos branches: 1.53.2;
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.52 29-Mar-2014  christos branches: 1.52.4; 1.52.8;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.51 28-Jan-2014  skrll Support the OHCI in the NS "SUPERIO" chip as found in hppa machines by
twiddling the same bits as Linux.
 1.50 10-Jun-2012  mrg branches: 1.50.2; 1.50.4;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.
 1.49 05-Apr-2012  macallan abort attach if memory access is not enabled
this avoids a panic later on when trying to attach to an unconfigured ohci
found for example in later iBooks when DIAGNOSTIC is set
 1.48 30-Jan-2012  drochner branches: 1.48.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.47 04-Apr-2011  dyoung branches: 1.47.4; 1.47.8;
Deregister PMF handlers during detachment. Complete the host controller
shutdown.
 1.46 25-May-2010  pgoyette branches: 1.46.2;
Revert earlier changes to callers of pci_find{vendor,product} since
the original routine entrypoint name has been restored.

Requested by dyoung@ and mrg@
 1.45 24-May-2010  pgoyette Update all callers of the pci_find{vendor,product} routines to now call
these routines through their global pointers.
 1.44 11-Mar-2010  mrg branches: 1.44.2;
various aprint_* fixes.
 1.43 26-Apr-2009  cegger branches: 1.43.2;
detach ohci on shutdown
 1.42 26-Apr-2009  cegger Fix error handling.
 1.41 17-Apr-2009  dyoung Use device_t instead of 'struct device *' or device_ptr_t. Use cfdata_t
instead of 'struct cfdata *'. Delete some gratuitous parentheses.
 1.40 17-Apr-2009  dyoung Disable interrupts on the h/w before disestablishing the PCI interrupt
handler.
 1.39 28-Apr-2008  martin branches: 1.39.8; 1.39.14;
Remove clause 3 and 4 from TNF licenses
 1.38 29-Mar-2008  nakayama branches: 1.38.2; 1.38.4;
Fix ohci brokenness in previous commit.
 1.37 28-Mar-2008  drochner split device/softc for USB host controllers and the usb (control)
device,
this is hairy stuff, and I've only tested with uhci/ehci at pci,
please test the rest and report problems
 1.36 07-Mar-2008  dyoung Use device_t and accessors.

In ohci_{pci,cardbus}_attach, do not get the device_t by casting
the softc to void *, but use `self' instead.
 1.35 07-Mar-2008  dyoung Register the shutdown hook using pmf_device_register1().
 1.34 22-Feb-2008  dyoung Add method to detach children.

Temporary: use PMF_FN_PROTO, PMF_FN_ARGS.
 1.33 09-Dec-2007  jmcneill branches: 1.33.6; 1.33.10;
Merge jmcneill-pm branch.
 1.32 19-Oct-2007  ad branches: 1.32.4; 1.32.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.31 16-Nov-2006  christos branches: 1.31.8; 1.31.18; 1.31.24; 1.31.26; 1.31.30;
__unused removal on arguments; approved by core.
 1.30 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.29 11-Dec-2005  christos branches: 1.29.20; 1.29.22;
merge ktrace-lwp.
 1.28 28-Jun-2005  thorpej branches: 1.28.2;
Use ANSI function decls and static.
 1.27 27-Feb-2005  perry nuke trailing whitespace
 1.26 02-Aug-2004  mycroft branches: 1.26.4; 1.26.6;
For the PCIVERBOSE case, separate vendors and products into separate tables.
Eliminating redundant pointers in the tables saves nearly 20K (20% of the table
size). In the process, add a pci_findproduct() and make that and
pci_findvendor() return a "const char *".
 1.25 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.24 22-Apr-2004  itojun sprintf -> snprintf
 1.23 02-Oct-2002  thorpej branches: 1.23.6;
Add trailing ; to CFATTACH_DECL.
 1.22 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.21 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20 13-Nov-2001  lukem add RCSID
 1.19 06-Nov-2001  augustss Add some data structures to keep enable finding companion controllers
for EHCI.
 1.18 28-Dec-2000  sommerfeld branches: 1.18.2; 1.18.4; 1.18.8;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.17 06-Sep-2000  augustss ANSIfy.
 1.16 27-Apr-2000  augustss Change my email address.
 1.15 25-Apr-2000  augustss Move the size of the mapped bus_space region into the bus independent softc.
 1.14 12-Oct-1999  augustss branches: 1.14.2;
Deallocate resources (bus space and interrupts) when detaching from
the bus.
 1.13 15-Sep-1999  augustss branches: 1.13.2;
Add preliminary (untested) code for detaching the USB host controller
(needed for CardBus based controllers).
 1.12 14-Sep-1999  augustss And commit two files I forgot in the rearrangement for testing for
interrupt context.
 1.11 04-Sep-1999  augustss Make sure not to use the io handle before it's been initialized.
 1.10 21-Aug-1999  augustss Disable interrupts early.
 1.9 20-May-1999  augustss Keep track of vendor id and make sure the vendor string is NUL terminated.
 1.8 13-May-1999  thorpej Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>
 1.7 06-May-1999  thorpej Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.
 1.6 27-Dec-1998  augustss branches: 1.6.2;
Fold lines to 80 chars.
 1.5 25-Nov-1998  augustss Make the copyright header conform to the NetBSD template.
 1.4 25-Jul-1998  augustss Use PCI class/subclass/interface to match USB host controllers instead
of vendor/product id. This makes the probe find more controllers
without recompilation.
 1.3 25-Jul-1998  augustss I forgot to commit these when usb_mem was added.
 1.2 22-Jul-1998  augustss Add an Acer labs USB controller.
 1.1 12-Jul-1998  augustss Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers
 1.6.2.2 28-Jun-1999  perry pullup 1.7->1.8 (wrstuden)
 1.6.2.1 06-May-1999  perry branches: 1.6.2.1.2; 1.6.2.1.4;
pullup 1.6->1.7 (thorpej)
 1.6.2.1.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.6.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18.8.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.18.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.18.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.23.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.23.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.23.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.23.6.1 03-Aug-2004  skrll Sync with HEAD
 1.26.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.26.4.1 29-Apr-2005  kent sync with -current
 1.28.2.5 17-Mar-2008  yamt sync with head.
 1.28.2.4 27-Feb-2008  yamt sync with head.
 1.28.2.3 21-Jan-2008  yamt sync with head
 1.28.2.2 27-Oct-2007  yamt sync with head.
 1.28.2.1 30-Dec-2006  yamt sync with head.
 1.29.22.2 10-Dec-2006  yamt sync with head.
 1.29.22.1 22-Oct-2006  yamt sync with head
 1.29.20.1 18-Nov-2006  ad Sync with head.
 1.31.30.1 25-Oct-2007  bouyer Sync with HEAD.
 1.31.26.3 23-Mar-2008  matt sync with HEAD
 1.31.26.2 09-Jan-2008  matt sync with HEAD
 1.31.26.1 06-Nov-2007  matt sync with HEAD
 1.31.24.5 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.31.24.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.31.24.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.31.24.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.31.24.1 14-Aug-2007  jmcneill Add ohci power management support, currently untested.
 1.31.18.1 22-May-2007  itohy Overhaul of USB stack, mostly DMA related

This applies to NetBSD 4.99.13 (March 1, 2007)

usbdi(9) interface is based on FreeBSD version, excluding
- removal of portability code

Patch most NetBSD changes, excluding
- DMA memory "reserve", since we don't need contiguous buffers any longer
- volatiles in DMA structure, since it should not be needed
with proper bus_dmamap_sync(9)s

DMA/non-DMA memory management overhaul
- Move all DMA related code to usb_mem.[ch]
(add usb_alloc_buffer_dma(), usb_free_buffer_dma(), etc.).
XXX Should usb_mem.[ch] be renamed as usb_mem_dma.[ch] ?
- Add corresponding non-DMA code to usb_mem_nodma.[ch] .
Currently just use malloc(9).
- Above files are conditionally used by config framework (added
attributes to conf/files and dev/usb/files.usb).
- Add diagnostic panics when resource allocation is requested
on interrupt context.
- Change memory allocations (that require context) from NOWAIT to WAITOK.

Allocate DMA/non-DMA buffer per host interface, not globally.
advantage: Buffers can be freed on detaching host interface.
Activity of a host interface does not affect others.
disadvantages: It possibly consumes more memory.

API changes
- usbd_alloc_xfer() is changed:
old: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev);
new: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev,
usbd_pipe_handle pipe);
- pipe argument of usbd_setup_*xfer() are now unused
XXX the pipe argument should be removed?
- add mapping APIs
- async request will be processed as a task (kernel thread context),
and delayed to some extent
- usbdivar.h: struct usbd_xfer: renamed a member "allocbuf" to "hcbuffer"
(mapped/allocated/refered buffer for HCI driver)
- usb_port.h: change usb_proc_ptr from struct ptoc * to struct lwp *
- usb_port.h: add usb_sigproc_ptr for psignal(9) (struct proc *)
- usb.h: add UE_MAXPKTSZ(ep) and UE_MAXPKTSZ_MASK macros for USB 2.0

changes to USB device drivers
- atu, aue, axe, cdce, cue, kue, rum, udav, upl, ural, url,
uaudio, ubt, ucom, ugen, uhidev, uirda, ulpt, umidi, urio,
uscanner, ustir, utoppy:
* catch up API change of usbd_alloc_xfer()
- umass, usscanner:
* catch up API change of usbd_alloc_xfer()
* eliminate memory copy for large transfer

ohci
- free resources on detach
- add lots of bus_dmamap_sync() operations
- simplify the code of loading std chain
- rewrite code of looking up TD/ITD from DMA addr by using allocation chunk
- add workaround for CMD Tech 670 and 673 chipsets
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

slhci
- allocate xfer and slhci_xfer at once, and simplify relevant code
- add slhci_detach()
- remove second arg of slhci_attach() since it is the same as the first arg.
- add support for "mapping" (no, it doesn't map since it doesn't do DMA)
buffer and mbuf
- add pcmcia frontend
- NOT TESTED, missing hardware

ehci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf
- done only simple test

uhci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

To do
- review, test, debug
- rewrite network drivers to utilize usbd_map_buffer_mbuf()
- rewrite uaudio(4) to eliminate memcpy
- "pipe" argument of usbd_setup_*xfer() should eventually be removed
 1.31.8.1 23-Oct-2007  ad Sync with head.
 1.32.6.1 11-Dec-2007  yamt sync with head.
 1.32.4.1 26-Dec-2007  ad Sync with head.
 1.33.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.33.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.33.6.1 24-Mar-2008  keiichi sync with head.
 1.38.4.3 11-Aug-2010  yamt sync with head.
 1.38.4.2 04-May-2009  yamt sync with head.
 1.38.4.1 16-May-2008  yamt sync with head.
 1.38.2.1 18-May-2008  yamt sync with head.
 1.39.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.43.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.44.2.1 21-Apr-2011  rmind sync with head
 1.46.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.47.8.3 05-Apr-2012  mrg sync to latest -current.
 1.47.8.2 18-Feb-2012  mrg merge to -current.
 1.47.8.1 09-Dec-2011  mrg - make pipe->close method take the thread lock

- convert usb_taskq to use mutex/cv

- convert needs_explore usage into a cv on the thread lock

- remove KERNEL_*LOCK from uaudio and umidi, since we're supposedly
MPSAFE here now

- use IPL_SCHED instead of IPL_USB (aka biglocked) interrupts

- drop the audio thread lock when calling into usb when it may sleep,
avoiding a deadlock between audiowrite and audioioctl. this fixes
mixerctl -a vs. playing hanging the system
XXX probably need to check this in a bunch more places.
 1.47.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.47.4.2 30-Oct-2012  yamt sync with head
 1.47.4.1 17-Apr-2012  yamt sync with head
 1.48.2.1 16-Apr-2012  riz Pull up following revision(s) (requested by macallan in ticket #182):
sys/dev/pci/ohci_pci.c: revision 1.49
abort attach if memory access is not enabled
this avoids a panic later on when trying to attach to an unconfigured ohci
found for example in later iBooks when DIAGNOSTIC is set
 1.50.4.1 18-May-2014  rmind sync with head
 1.50.2.2 03-Dec-2017  jdolecek update from HEAD
 1.50.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.8.2 14-Sep-2016  skrll Use IPL_USB for interrupt handler
 1.52.8.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.52.4.1 05-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1395):
share/man/man4/axe.4: netbsd-7-nhusb
share/man/man4/axen.4: netbsd-7-nhusb
share/man/man4/cdce.4: netbsd-7-nhusb
share/man/man4/uaudio.4: netbsd-7-nhusb
share/man/man4/ucom.4: netbsd-7-nhusb
share/man/man4/uep.4: netbsd-7-nhusb
share/man/man4/urtw.4: netbsd-7-nhusb
share/man/man4/usb.4: netbsd-7-nhusb
share/man/man4/uyap.4: netbsd-7-nhusb
share/man/man4/xhci.4: netbsd-7-nhusb
share/man/man9/usbdi.9: netbsd-7-nhusb
sys/arch/amd64/conf/ALL: netbsd-7-nhusb
sys/arch/amd64/conf/GENERIC: netbsd-7-nhusb
sys/arch/amiga/dev/slhci_zbus.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_otg.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_usb.c: netbsd-7-nhusb
sys/arch/arm/amlogic/amlogic_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/at91/at91ohci.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm2835_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm53xx_usb.c: netbsd-7-nhusb
sys/arch/arm/ep93xx/epohci.c: netbsd-7-nhusb
sys/arch/arm/gemini/obio_ehci.c: netbsd-7-nhusb
sys/arch/arm/imx/files.imx23: netbsd-7-nhusb
sys/arch/arm/imx/imxusb.c: netbsd-7-nhusb
sys/arch/arm/imx/imxusbreg.h: netbsd-7-nhusb
sys/arch/arm/omap/obio_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/omap3_ehci.c: netbsd-7-nhusb
sys/arch/arm/omap/omapl1x_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/tiotg.c: netbsd-7-nhusb
sys/arch/arm/s3c2xx0/ohci_s3c24x0.c: netbsd-7-nhusb
sys/arch/arm/samsung/exynos_usb.c: netbsd-7-nhusb
sys/arch/arm/xscale/pxa2x0_ohci.c: netbsd-7-nhusb
sys/arch/arm/zynq/zynq_usb.c: netbsd-7-nhusb
sys/arch/hpcarm/dev/nbp_slhci.c: netbsd-7-nhusb
sys/arch/hpcmips/dev/plumohci.c: netbsd-7-nhusb
sys/arch/i386/conf/ALL: netbsd-7-nhusb
sys/arch/i386/conf/GENERIC: netbsd-7-nhusb
sys/arch/i386/pci/gcscehci.c: netbsd-7-nhusb
sys/arch/luna68k/conf/GENERIC: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahci.c: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahcivar.h: netbsd-7-nhusb
sys/arch/mips/alchemy/dev/ohci_aubus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ehci_arbus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ohci_arbus.c: netbsd-7-nhusb
sys/arch/mips/conf/files.adm5120: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ehci.c: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ohci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ehci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ohci.c: netbsd-7-nhusb
sys/arch/playstation2/dev/ohci_sbus.c: netbsd-7-nhusb
sys/arch/powerpc/booke/dev/pq3ehci.c: netbsd-7-nhusb
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c: netbsd-7-nhusb
sys/arch/x68k/dev/slhci_intio.c: netbsd-7-nhusb
sys/conf/files: netbsd-7-nhusb
sys/dev/cardbus/ehci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/ohci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/uhci_cardbus.c: netbsd-7-nhusb
sys/dev/ic/sl811hs.c: netbsd-7-nhusb
sys/dev/ic/sl811hsvar.h: netbsd-7-nhusb
sys/dev/isa/slhci_isa.c: netbsd-7-nhusb
sys/dev/marvell/ehci_mv.c: netbsd-7-nhusb
sys/dev/pci/ehci_pci.c: netbsd-7-nhusb
sys/dev/pci/ohci_pci.c: netbsd-7-nhusb
sys/dev/pci/uhci_pci.c: netbsd-7-nhusb
sys/dev/pci/xhci_pci.c: netbsd-7-nhusb
sys/dev/pcmcia/slhci_pcmcia.c: netbsd-7-nhusb
sys/dev/usb/Makefile.usbdevs: netbsd-7-nhusb
sys/dev/usb/TODO: netbsd-7-nhusb
sys/dev/usb/TODO.usbmp: netbsd-7-nhusb
sys/dev/usb/aubtfwl.c: netbsd-7-nhusb
sys/dev/usb/auvitek.c: netbsd-7-nhusb
sys/dev/usb/auvitek_audio.c: netbsd-7-nhusb
sys/dev/usb/auvitek_dtv.c: netbsd-7-nhusb
sys/dev/usb/auvitek_i2c.c: netbsd-7-nhusb
sys/dev/usb/auvitek_video.c: netbsd-7-nhusb
sys/dev/usb/auvitekvar.h: netbsd-7-nhusb
sys/dev/usb/ehci.c: netbsd-7-nhusb
sys/dev/usb/ehcireg.h: netbsd-7-nhusb
sys/dev/usb/ehcivar.h: netbsd-7-nhusb
sys/dev/usb/emdtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_dtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_ir.c: netbsd-7-nhusb
sys/dev/usb/emdtvvar.h: netbsd-7-nhusb
sys/dev/usb/ezload.c: netbsd-7-nhusb
sys/dev/usb/ezload.h: netbsd-7-nhusb
sys/dev/usb/files.usb: netbsd-7-nhusb
sys/dev/usb/hid.c: netbsd-7-nhusb
sys/dev/usb/hid.h: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.c: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.h: netbsd-7-nhusb
sys/dev/usb/if_atu.c: netbsd-7-nhusb
sys/dev/usb/if_atureg.h: netbsd-7-nhusb
sys/dev/usb/if_aue.c: netbsd-7-nhusb
sys/dev/usb/if_auereg.h: netbsd-7-nhusb
sys/dev/usb/if_axe.c: netbsd-7-nhusb
sys/dev/usb/if_axen.c: netbsd-7-nhusb
sys/dev/usb/if_axenreg.h: netbsd-7-nhusb
sys/dev/usb/if_axereg.h: netbsd-7-nhusb
sys/dev/usb/if_cdce.c: netbsd-7-nhusb
sys/dev/usb/if_cdcereg.h: netbsd-7-nhusb
sys/dev/usb/if_cue.c: netbsd-7-nhusb
sys/dev/usb/if_cuereg.h: netbsd-7-nhusb
sys/dev/usb/if_kue.c: netbsd-7-nhusb
sys/dev/usb/if_kuereg.h: netbsd-7-nhusb
sys/dev/usb/if_otus.c: netbsd-7-nhusb
sys/dev/usb/if_otusvar.h: netbsd-7-nhusb
sys/dev/usb/if_rum.c: netbsd-7-nhusb
sys/dev/usb/if_rumreg.h: netbsd-7-nhusb
sys/dev/usb/if_rumvar.h: netbsd-7-nhusb
sys/dev/usb/if_run.c: netbsd-7-nhusb
sys/dev/usb/if_runvar.h: netbsd-7-nhusb
sys/dev/usb/if_smsc.c: netbsd-7-nhusb
sys/dev/usb/if_smscreg.h: netbsd-7-nhusb
sys/dev/usb/if_smscvar.h: netbsd-7-nhusb
sys/dev/usb/if_udav.c: netbsd-7-nhusb
sys/dev/usb/if_udavreg.h: netbsd-7-nhusb
sys/dev/usb/if_upgt.c: netbsd-7-nhusb
sys/dev/usb/if_upgtvar.h: netbsd-7-nhusb
sys/dev/usb/if_upl.c: netbsd-7-nhusb
sys/dev/usb/if_ural.c: netbsd-7-nhusb
sys/dev/usb/if_uralreg.h: netbsd-7-nhusb
sys/dev/usb/if_uralvar.h: netbsd-7-nhusb
sys/dev/usb/if_url.c: netbsd-7-nhusb
sys/dev/usb/if_urlreg.h: netbsd-7-nhusb
sys/dev/usb/if_urndis.c: netbsd-7-nhusb
sys/dev/usb/if_urndisreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtw.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn_data.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnvar.h: netbsd-7-nhusb
sys/dev/usb/if_urtwreg.h: netbsd-7-nhusb
sys/dev/usb/if_zyd.c: netbsd-7-nhusb
sys/dev/usb/if_zydreg.h: netbsd-7-nhusb
sys/dev/usb/irmce.c: netbsd-7-nhusb
sys/dev/usb/moscom.c: netbsd-7-nhusb
sys/dev/usb/motg.c: netbsd-7-nhusb
sys/dev/usb/motgvar.h: netbsd-7-nhusb
sys/dev/usb/ohci.c: netbsd-7-nhusb
sys/dev/usb/ohcireg.h: netbsd-7-nhusb
sys/dev/usb/ohcivar.h: netbsd-7-nhusb
sys/dev/usb/pseye.c: netbsd-7-nhusb
sys/dev/usb/slurm.c: netbsd-7-nhusb
sys/dev/usb/stuirda.c: netbsd-7-nhusb
sys/dev/usb/u3g.c: netbsd-7-nhusb
sys/dev/usb/uark.c: netbsd-7-nhusb
sys/dev/usb/uatp.c: netbsd-7-nhusb
sys/dev/usb/uaudio.c: netbsd-7-nhusb
sys/dev/usb/uberry.c: netbsd-7-nhusb
sys/dev/usb/ubsa.c: netbsd-7-nhusb
sys/dev/usb/ubsa_common.c: netbsd-7-nhusb
sys/dev/usb/ubsavar.h: netbsd-7-nhusb
sys/dev/usb/ubt.c: netbsd-7-nhusb
sys/dev/usb/uchcom.c: netbsd-7-nhusb
sys/dev/usb/ucom.c: netbsd-7-nhusb
sys/dev/usb/ucomvar.h: netbsd-7-nhusb
sys/dev/usb/ucycom.c: netbsd-7-nhusb
sys/dev/usb/udl.c: netbsd-7-nhusb
sys/dev/usb/udl.h: netbsd-7-nhusb
sys/dev/usb/udsbr.c: netbsd-7-nhusb
sys/dev/usb/udsir.c: netbsd-7-nhusb
sys/dev/usb/uep.c: netbsd-7-nhusb
sys/dev/usb/uftdi.c: netbsd-7-nhusb
sys/dev/usb/uftdireg.h: netbsd-7-nhusb
sys/dev/usb/ugen.c: netbsd-7-nhusb
sys/dev/usb/ugensa.c: netbsd-7-nhusb
sys/dev/usb/uhci.c: netbsd-7-nhusb
sys/dev/usb/uhcireg.h: netbsd-7-nhusb
sys/dev/usb/uhcivar.h: netbsd-7-nhusb
sys/dev/usb/uhid.c: netbsd-7-nhusb
sys/dev/usb/uhidev.c: netbsd-7-nhusb
sys/dev/usb/uhidev.h: netbsd-7-nhusb
sys/dev/usb/uhmodem.c: netbsd-7-nhusb
sys/dev/usb/uhso.c: netbsd-7-nhusb
sys/dev/usb/uhub.c: netbsd-7-nhusb
sys/dev/usb/uipad.c: netbsd-7-nhusb
sys/dev/usb/uipaq.c: netbsd-7-nhusb
sys/dev/usb/uirda.c: netbsd-7-nhusb
sys/dev/usb/uirdavar.h: netbsd-7-nhusb
sys/dev/usb/ukbd.c: netbsd-7-nhusb
sys/dev/usb/ukbdmap.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.h: netbsd-7-nhusb
sys/dev/usb/ulpt.c: netbsd-7-nhusb
sys/dev/usb/umass.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.h: netbsd-7-nhusb
sys/dev/usb/umass_quirks.c: netbsd-7-nhusb
sys/dev/usb/umass_quirks.h: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.c: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.h: netbsd-7-nhusb
sys/dev/usb/umassvar.h: netbsd-7-nhusb
sys/dev/usb/umcs.c: netbsd-7-nhusb
sys/dev/usb/umct.c: netbsd-7-nhusb
sys/dev/usb/umidi.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.h: netbsd-7-nhusb
sys/dev/usb/umodem.c: netbsd-7-nhusb
sys/dev/usb/umodem_common.c: netbsd-7-nhusb
sys/dev/usb/umodemvar.h: netbsd-7-nhusb
sys/dev/usb/ums.c: netbsd-7-nhusb
sys/dev/usb/uplcom.c: netbsd-7-nhusb
sys/dev/usb/urio.c: netbsd-7-nhusb
sys/dev/usb/urio.h: netbsd-7-nhusb
sys/dev/usb/usb.c: netbsd-7-nhusb
sys/dev/usb/usb.h: netbsd-7-nhusb
sys/dev/usb/usb_mem.c: netbsd-7-nhusb
sys/dev/usb/usb_mem.h: netbsd-7-nhusb
sys/dev/usb/usb_quirks.c: netbsd-7-nhusb
sys/dev/usb/usb_quirks.h: netbsd-7-nhusb
sys/dev/usb/usb_subr.c: netbsd-7-nhusb
sys/dev/usb/usbdevices.config: netbsd-7-nhusb
sys/dev/usb/usbdevs: netbsd-7-nhusb
sys/dev/usb/usbdevs.h: netbsd-7-nhusb
sys/dev/usb/usbdevs_data.h: netbsd-7-nhusb
sys/dev/usb/usbdi.c: netbsd-7-nhusb
sys/dev/usb/usbdi.h: netbsd-7-nhusb
sys/dev/usb/usbdi_util.c: netbsd-7-nhusb
sys/dev/usb/usbdi_util.h: netbsd-7-nhusb
sys/dev/usb/usbdivar.h: netbsd-7-nhusb
sys/dev/usb/usbhid.h: netbsd-7-nhusb
sys/dev/usb/usbhist.h: netbsd-7-nhusb
sys/dev/usb/usbroothub.c: netbsd-7-nhusb
sys/dev/usb/usbroothub.h: netbsd-7-nhusb
sys/dev/usb/usbroothub_subr.c: delete
sys/dev/usb/usbroothub_subr.h: delete
sys/dev/usb/uscanner.c: netbsd-7-nhusb
sys/dev/usb/uslsa.c: netbsd-7-nhusb
sys/dev/usb/usscanner.c: netbsd-7-nhusb
sys/dev/usb/ustir.c: netbsd-7-nhusb
sys/dev/usb/uthum.c: netbsd-7-nhusb
sys/dev/usb/utoppy.c: netbsd-7-nhusb
sys/dev/usb/uts.c: netbsd-7-nhusb
sys/dev/usb/uvideo.c: netbsd-7-nhusb
sys/dev/usb/uvisor.c: netbsd-7-nhusb
sys/dev/usb/uvscom.c: netbsd-7-nhusb
sys/dev/usb/uyap.c: netbsd-7-nhusb
sys/dev/usb/uyap_firmware.h: netbsd-7-nhusb
sys/dev/usb/uyurex.c: netbsd-7-nhusb
sys/dev/usb/x1input_rdesc.h: netbsd-7-nhusb
sys/dev/usb/xhci.c: netbsd-7-nhusb
sys/dev/usb/xhcireg.h: netbsd-7-nhusb
sys/dev/usb/xhcivar.h: netbsd-7-nhusb
sys/dev/usb/xinput_rdesc.h: netbsd-7-nhusb
sys/external/bsd/common/conf/files.linux: netbsd-7-nhusb
sys/external/bsd/common/include/linux/err.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/kernel.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/workqueue.h: netbsd-7-nhusb
sys/external/bsd/common/linux/linux_work.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/atombios_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/drm/files.drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/i915drm/files.i915drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/include/linux/err.h: delete
sys/external/bsd/drm2/include/linux/workqueue.h: delete
sys/external/bsd/drm2/linux/files.drmkms_linux: netbsd-7-nhusb
sys/external/bsd/drm2/linux/linux_work.c: delete
sys/external/bsd/dwc2/dwc2.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2var.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwctwo2netbsd: netbsd-7-nhusb
sys/external/bsd/dwc2/conf/files.dwc2: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_coreintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdddma.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hw.h: netbsd-7-nhusb
sys/modules/drmkms_linux/Makefile: netbsd-7-nhusb
sys/modules/i915drmkms/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libugenhc/ugenhc.c: netbsd-7-nhusb
sys/rump/dev/lib/libusb/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libusb/USB.ioconf: netbsd-7-nhusb
sys/rump/dev/lib/libusb/usb_at_ugenhc.c: delete
sys/rump/dev/lib/libusb/opt/opt_usb.h: delete
sys/rump/dev/lib/libusb/opt/opt_usbverbose.h: delete
sys/sys/mbuf.h: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.8: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.c: netbsd-7-nhusb
Merge netbsd-7-nhusb:
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
- Change the SOFTINT level from NET to SERIAL for the USB softint handler.
This gives the callback a chance of running when another softint handler
at SOFTINT_NET has blocked holding a lock, e.g. softnet_lock and most of
the network stack.
- kern/49065 - ifconfig tun0 ... sequence locks up system / lockup:
softnet_lock held across usb xfr
- kern/50491 - unkillable wait in usbd_transfer while using usmsc0
on raspberry pi 2
- kern/51395 - USB Ethernet makes xhci hang
- Various improvements to slhci(4)
- Various improvements to dwc2(4)
 1.53.2.4 28-Aug-2017  skrll Sync with HEAD
 1.53.2.3 22-Sep-2015  skrll Sync with HEAD
 1.53.2.2 05-Dec-2014  skrll Use int for return type for [eou]chi_init and motg_init.
 1.53.2.1 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.55.8.1 11-May-2017  pgoyette Sync with HEAD
 1.56.8.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.57.18.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.58.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.59.12.1 02-Aug-2025  perseant Sync with HEAD
 1.19 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.18 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.17 09-Apr-2012  plunky branches: 1.17.40; 1.17.44;
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
the device 'self' in opl_softc and fix opl_attach() to use this
opl_softc->dev field directly rather than a field in an otherwise
unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
provides that)

reviewed by mrg
 1.16 07-Dec-2011  jakllsch Initialize the opl softc lock pointer to the parent's interrupt lock.
Briefly tested only on wss@isapnp.
 1.15 28-Apr-2008  martin branches: 1.15.34; 1.15.38;
Remove clause 3 and 4 from TNF licenses
 1.14 15-Mar-2008  cube branches: 1.14.2; 1.14.4;
Split device_t and softc for opl(4). That should have been done along with
midi(4), because opl_softc embed a midi_softc.
Fixes PR#38242 by Onno van der Linden.
 1.13 19-Oct-2007  ad branches: 1.13.12; 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 09-Jun-2006  christos branches: 1.10.6; 1.10.8;
stack police: Introduce an opl_match function that uses malloc instead of
allocating ~2K of softc on the stack.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.8; 1.9.14;
merge ktrace-lwp.
 1.8 28-Jun-2005  thorpej branches: 1.8.2;
Use ANSI function decls and static.
 1.7 04-Feb-2005  perry de-__P
 1.6 04-Dec-2003  keihan branches: 1.6.8; 1.6.10;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 02-Oct-2002  thorpej branches: 1.5.6;
Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 13-Nov-2001  lukem add RCSID
 1.1 04-Sep-2001  itohy branches: 1.1.4; 1.1.6;
OPL3 driver for C-Media CMI8x38
 1.1.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.6.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.6.1 04-Sep-2001  nathanw file opl_cmpci.c was added on branch nathanw_sa on 2001-09-21 22:35:58 +0000
 1.1.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.4.1 04-Sep-2001  thorpej file opl_cmpci.c was added on branch kqueue on 2001-09-13 01:15:56 +0000
 1.5.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.4 04-Feb-2005  skrll Sync with HEAD.
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 12-Feb-2005  yamt sync with head.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.8.2.3 17-Mar-2008  yamt sync with head.
 1.8.2.2 27-Oct-2007  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.9.14.1 19-Jun-2006  chap Sync with head.
 1.9.8.1 26-Jun-2006  yamt sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.8.2 10-Dec-2006  yamt sync with head.
 1.10.8.1 22-Oct-2006  yamt sync with head
 1.10.6.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.2 23-Mar-2008  matt sync with HEAD
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.12.1 24-Mar-2008  keiichi sync with head.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.38.2 29-Apr-2012  mrg sync to latest -current.
 1.15.38.1 18-Feb-2012  mrg merge to -current.
 1.15.34.1 17-Apr-2012  yamt sync with head
 1.17.44.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.17.40.1 10-Jun-2019  christos Sync with HEAD
 1.20 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.19 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.18 09-Apr-2012  plunky branches: 1.18.40; 1.18.44;
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
the device 'self' in opl_softc and fix opl_attach() to use this
opl_softc->dev field directly rather than a field in an otherwise
unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
provides that)

reviewed by mrg
 1.17 23-Nov-2011  jmcneill branches: 1.17.2;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.16 28-Apr-2008  martin branches: 1.16.12; 1.16.34; 1.16.36;
Remove clause 3 and 4 from TNF licenses
 1.15 15-Mar-2008  cube branches: 1.15.2; 1.15.4;
Split device_t and softc for opl(4). That should have been done along with
midi(4), because opl_softc embed a midi_softc.
Fixes PR#38242 by Onno van der Linden.
 1.14 19-Oct-2007  ad branches: 1.14.12; 1.14.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 16-Nov-2006  christos branches: 1.13.8; 1.13.22; 1.13.24; 1.13.28;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 28-Jun-2005  thorpej branches: 1.10.2;
Use ANSI function decls and static.
 1.9 04-Feb-2005  perry de-__P
 1.8 04-Dec-2003  keihan branches: 1.8.8; 1.8.10;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.7 02-Oct-2002  thorpej branches: 1.7.6;
Add trailing ; to CFATTACH_DECL.
 1.6 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 13-Nov-2001  lukem add RCSID
 1.3 01-Sep-1999  kleink branches: 1.3.14; 1.3.16;
No longer requires mpuvar.h.
 1.2 01-Aug-1999  augustss branches: 1.2.2;
Move the MPU driver isa/ to ic/.
(I didn't move it in the repository because the revision history
is very short and uninteresting. :)
 1.1 12-Jul-1999  kleink Add a driver for the ESS Technology Solo-1 PCI AudioDrive line of chips.
 1.2.2.2 02-Aug-1999  thorpej Update from trunk.
 1.2.2.1 01-Aug-1999  thorpej file opl_eso.c was added on branch chs-ubc2 on 1999-08-02 22:03:59 +0000
 1.3.16.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.14.2 18-Oct-2002  nathanw Catch up to -current.
 1.3.14.1 14-Nov-2001  nathanw Catch up to -current.
 1.7.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.6.4 04-Feb-2005  skrll Sync with HEAD.
 1.7.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.1 12-Feb-2005  yamt sync with head.
 1.8.8.1 29-Apr-2005  kent sync with -current
 1.10.2.3 17-Mar-2008  yamt sync with head.
 1.10.2.2 27-Oct-2007  yamt sync with head.
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.22.2 10-Dec-2006  yamt sync with head.
 1.11.22.1 22-Oct-2006  yamt sync with head
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.13.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.24.2 23-Mar-2008  matt sync with HEAD
 1.13.24.1 06-Nov-2007  matt sync with HEAD
 1.13.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.14.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.14.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.12.1 24-Mar-2008  keiichi sync with head.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.36.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.16.34.1 17-Apr-2012  yamt sync with head
 1.16.12.1 09-Dec-2008  ad Checkpoint work on MIDI.
 1.17.2.1 29-Apr-2012  mrg sync to latest -current.
 1.18.44.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.18.40.1 10-Jun-2019  christos Sync with HEAD
 1.19 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.18 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.17 09-Apr-2012  plunky branches: 1.17.40; 1.17.44;
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
the device 'self' in opl_softc and fix opl_attach() to use this
opl_softc->dev field directly rather than a field in an otherwise
unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
provides that)

reviewed by mrg
 1.16 07-Dec-2011  jakllsch Initialize the opl softc lock pointer to the parent's interrupt lock.
Briefly tested only on wss@isapnp.
 1.15 28-Apr-2008  martin branches: 1.15.34; 1.15.38;
Remove clause 3 and 4 from TNF licenses
 1.14 15-Mar-2008  cube branches: 1.14.2; 1.14.4;
Split device_t and softc for opl(4). That should have been done along with
midi(4), because opl_softc embed a midi_softc.
Fixes PR#38242 by Onno van der Linden.
 1.13 19-Oct-2007  ad branches: 1.13.12; 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 04-Feb-2005  perry de-__P
 1.7 04-Dec-2003  keihan branches: 1.7.8; 1.7.10;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.6 02-Oct-2002  thorpej branches: 1.6.6;
Add trailing ; to CFATTACH_DECL.
 1.5 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 15-May-2000  thorpej branches: 1.2.6; 1.2.8; 1.2.10;
ac97.h -> ac97var.h
 1.1 01-Nov-1999  augustss branches: 1.1.4; 1.1.6;
Add FM801 audio device driver. From Witold J. Wnuk ww181302@zodiac.mimuw.edu.pl
Closes PR kern/8729.
 1.1.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.2 15-Nov-1999  fvdl Sync with -current
 1.1.4.1 01-Nov-1999  fvdl file opl_fms.c was added on branch fvdl-softdep on 1999-11-15 00:41:05 +0000
 1.2.10.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.8.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 15-May-2000  bouyer file opl_fms.c was added on branch thorpej_scsipi on 2000-11-20 11:42:29 +0000
 1.6.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.4 04-Feb-2005  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 12-Feb-2005  yamt sync with head.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.9.2.3 17-Mar-2008  yamt sync with head.
 1.9.2.2 27-Oct-2007  yamt sync with head.
 1.9.2.1 30-Dec-2006  yamt sync with head.
 1.10.22.2 10-Dec-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.2 23-Mar-2008  matt sync with HEAD
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.12.1 24-Mar-2008  keiichi sync with head.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.38.2 29-Apr-2012  mrg sync to latest -current.
 1.15.38.1 18-Feb-2012  mrg merge to -current.
 1.15.34.1 17-Apr-2012  yamt sync with head
 1.17.44.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.17.40.1 10-Jun-2019  christos Sync with HEAD
 1.18 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.17 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.16 09-Apr-2012  plunky branches: 1.16.40; 1.16.44;
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
the device 'self' in opl_softc and fix opl_attach() to use this
opl_softc->dev field directly rather than a field in an otherwise
unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
provides that)

reviewed by mrg
 1.15 07-Dec-2011  jakllsch Initialize the opl softc lock pointer to the parent's interrupt lock.
Briefly tested only on wss@isapnp.
 1.14 28-Apr-2008  martin branches: 1.14.34; 1.14.38;
Remove clause 3 and 4 from TNF licenses
 1.13 15-Mar-2008  cube branches: 1.13.2; 1.13.4;
Split device_t and softc for opl(4). That should have been done along with
midi(4), because opl_softc embed a midi_softc.
Fixes PR#38242 by Onno van der Linden.
 1.12 19-Oct-2007  ad branches: 1.12.12; 1.12.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 16-Nov-2006  christos branches: 1.11.8; 1.11.22; 1.11.24; 1.11.28;
__unused removal on arguments; approved by core.
 1.10 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9 11-Dec-2005  christos branches: 1.9.20; 1.9.22;
merge ktrace-lwp.
 1.8 28-Jun-2005  thorpej branches: 1.8.2;
Use ANSI function decls and static.
 1.7 04-Feb-2005  perry de-__P
 1.6 04-Dec-2003  keihan branches: 1.6.8; 1.6.10;
netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 02-Oct-2002  thorpej branches: 1.5.6;
Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 13-Nov-2001  lukem add RCSID
 1.1 10-Dec-1998  augustss branches: 1.1.20; 1.1.22;
Add a driver for the S3 SonicVibes chip. From OpenBSD and
Constantine Paul Sapuntzakis (csapuntz@cvs.openbsd.org) with
some changes by me.
XXX The driver still needs work.
 1.1.22.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.22.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.20.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.20.1 14-Nov-2001  nathanw Catch up to -current.
 1.5.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.4 04-Feb-2005  skrll Sync with HEAD.
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 12-Feb-2005  yamt sync with head.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.8.2.3 17-Mar-2008  yamt sync with head.
 1.8.2.2 27-Oct-2007  yamt sync with head.
 1.8.2.1 30-Dec-2006  yamt sync with head.
 1.9.22.2 10-Dec-2006  yamt sync with head.
 1.9.22.1 22-Oct-2006  yamt sync with head
 1.9.20.1 18-Nov-2006  ad Sync with head.
 1.11.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.24.2 23-Mar-2008  matt sync with HEAD
 1.11.24.1 06-Nov-2007  matt sync with HEAD
 1.11.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.8.1 23-Oct-2007  ad Sync with head.
 1.12.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.12.1 24-Mar-2008  keiichi sync with head.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.38.2 29-Apr-2012  mrg sync to latest -current.
 1.14.38.1 18-Feb-2012  mrg merge to -current.
 1.14.34.1 17-Apr-2012  yamt sync with head
 1.16.44.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.16.40.1 10-Jun-2019  christos Sync with HEAD
 1.19 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.18 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.17 09-Apr-2012  plunky branches: 1.17.40; 1.17.44;
Tidy up a little, the way that midi attachment code works

- change midi_attach() to omit the 'parent' arg (there are
only two callers of this and it is not used)

- change midisyn_attach() to midisyn_init(), so not needing a midi_softc,
and fix the midi_pcppi driver to set hw_if and hw_hdl directly in
its midi_softc before calling midi_attach()

- add a device_t to opl_softc structure, change opl drivers to store
the device 'self' in opl_softc and fix opl_attach() to use this
opl_softc->dev field directly rather than a field in an otherwise
unused midi_softc

- remove unnecessary midi_softc from opl and cms drivers (child device
provides that)

reviewed by mrg
 1.16 07-Dec-2011  jakllsch Initialize the opl softc lock pointer to the parent's interrupt lock.
Briefly tested only on wss@isapnp.
 1.15 28-Apr-2008  martin branches: 1.15.34; 1.15.38;
Remove clause 3 and 4 from TNF licenses
 1.14 15-Mar-2008  cube branches: 1.14.2; 1.14.4;
Split device_t and softc for opl(4). That should have been done along with
midi(4), because opl_softc embed a midi_softc.
Fixes PR#38242 by Onno van der Linden.
 1.13 19-Oct-2007  ad branches: 1.13.12; 1.13.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.12 16-Nov-2006  christos branches: 1.12.8; 1.12.22; 1.12.24; 1.12.28;
__unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 09-Jun-2006  christos branches: 1.10.6; 1.10.8;
stack police: Introduce an opl_match function that uses malloc instead of
allocating ~2K of softc on the stack.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.8; 1.9.14;
merge ktrace-lwp.
 1.8 28-Jun-2005  thorpej branches: 1.8.2;
Use ANSI function decls and static.
 1.7 08-Nov-2004  kent ANSIfy and style fixes
 1.6 04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.5 02-Oct-2002  thorpej branches: 1.5.6;
Add trailing ; to CFATTACH_DECL.
 1.4 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 13-Nov-2001  lukem add RCSID
 1.1 30-Mar-2001  minoura branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Yamaha YMF724/740/744/754 (DS-1) PCI audio driver.
 1.1.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.2 01-May-2001  he Pull up revision 1.1 (new, requested by minoura):
Add Yamaha YMF724/740/744/745-based sound driver and
its subordinates.
 1.1.6.1 30-Mar-2001  he file opl_yds.c was added on branch netbsd-1-5 on 2001-05-01 11:45:26 +0000
 1.1.4.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.1 30-Mar-2001  bouyer file opl_yds.c was added on branch thorpej_scsipi on 2001-04-21 17:49:16 +0000
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.1 30-Mar-2001  nathanw file opl_yds.c was added on branch nathanw_sa on 2001-04-09 01:57:04 +0000
 1.5.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.4 14-Nov-2004  skrll Sync with HEAD.
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.2.3 17-Mar-2008  yamt sync with head.
 1.8.2.2 27-Oct-2007  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.9.14.1 19-Jun-2006  chap Sync with head.
 1.9.8.1 26-Jun-2006  yamt sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.8.2 10-Dec-2006  yamt sync with head.
 1.10.8.1 22-Oct-2006  yamt sync with head
 1.10.6.1 18-Nov-2006  ad Sync with head.
 1.12.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.24.2 23-Mar-2008  matt sync with HEAD
 1.12.24.1 06-Nov-2007  matt sync with HEAD
 1.12.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.8.1 23-Oct-2007  ad Sync with head.
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.12.1 24-Mar-2008  keiichi sync with head.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.38.2 29-Apr-2012  mrg sync to latest -current.
 1.15.38.1 18-Feb-2012  mrg merge to -current.
 1.15.34.1 17-Apr-2012  yamt sync with head
 1.17.44.1 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.17.40.1 10-Jun-2019  christos Sync with HEAD
 1.25 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.24 31-Jul-2012  bouyer branches: 1.24.2; 1.24.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.23 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.22 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.21 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.20 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.19 04-Apr-2011  dyoung branches: 1.19.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.18 05-Nov-2010  jakllsch branches: 1.18.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.17 28-Apr-2008  martin branches: 1.17.20; 1.17.22;
Remove clause 3 and 4 from TNF licenses
 1.16 18-Mar-2008  cube branches: 1.16.2; 1.16.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.15 09-Feb-2007  ad branches: 1.15.20; 1.15.36; 1.15.40;
Merge newlock2 to head.
 1.14 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.13 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.12 11-Dec-2005  christos branches: 1.12.20; 1.12.22;
merge ktrace-lwp.
 1.11 24-May-2005  lukem branches: 1.11.2;
add __KERNEL_RCSID
 1.10 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.9 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.8 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.7 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.6 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.5 03-Jan-2004  thorpej branches: 1.5.4;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.4 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.3 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.5.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.5.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.5.4.2 03-Aug-2004  skrll Sync with HEAD
 1.5.4.1 03-Jan-2004  skrll file optiide.c was added on branch ktrace-lwp on 2004-08-03 10:49:10 +0000
 1.11.2.3 24-Mar-2008  yamt sync with head.
 1.11.2.2 26-Feb-2007  yamt sync with head.
 1.11.2.1 30-Dec-2006  yamt sync with head.
 1.12.22.2 10-Dec-2006  yamt sync with head.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.15.40.2 02-Jun-2008  mjf Sync with HEAD.
 1.15.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.36.1 24-Mar-2008  keiichi sync with head.
 1.15.20.1 23-Mar-2008  matt sync with HEAD
 1.16.4.1 16-May-2008  yamt sync with head.
 1.16.2.1 18-May-2008  yamt sync with head.
 1.17.22.2 21-Apr-2011  rmind sync with head
 1.17.22.1 05-Mar-2011  rmind sync with head
 1.17.20.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.4.1 30-Oct-2012  yamt sync with head
 1.24.4.1 18-May-2014  rmind sync with head
 1.24.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.217 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.216 24-Apr-2021  thorpej branches: 1.216.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.215 10-Nov-2019  chs branches: 1.215.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.214 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.213 01-Mar-2019  msaitoh No functional change:
- u_int* -> uint*
- KNF.
 1.212 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.211 10-May-2017  msaitoh branches: 1.211.8; 1.211.10;
Use pci_intr_establish_xname().
 1.210 07-Jul-2016  msaitoh branches: 1.210.8;
KNF. Remove extra spaces. No functional change.
 1.209 17-Feb-2016  christos PR/50820: David Binderman: Fail when !(edge|pulse) instead of !edge && edge
 1.208 26-Mar-2015  nakayama Add missing new lines.
 1.207 16-Nov-2014  ozaki-r branches: 1.207.2;
Replace callout_stop with callout_halt

In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.

Discussed with martin@ and riastradh@.
 1.206 29-Mar-2014  christos branches: 1.206.4;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.205 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.204 30-Jan-2012  drochner branches: 1.204.2; 1.204.6; 1.204.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.203 01-Aug-2011  drochner branches: 1.203.2; 1.203.6;
remove some bloat:
-cardbus doesn't use multiple interrupt lines like PCI, and it doesn't
use machanisms like interrupt line register and swizzling -- no need
to carry around dummy information, this is all dealt with by the
bridge
(I'm asking myself how "rbus_ppb" can work -- a bridge attached to
cardbus just can't work like a normal PCI bridge as far as interrupts
are concerned. I thing that should be a hardware specific driver
because behavior is not covered by a standard.)
-cardbus always uses 3.3V -- no need for a variable to keep track
of the voltage
 1.202 26-Jul-2011  dyoung Don't set the iobase and iosize members of pcmciabus_attach_args because
they're not used in any meaningful way.
 1.201 04-Jan-2011  jruoho Stop using aprint_debug(9) in an interrupt handler.
 1.200 27-Dec-2010  phx Add TI PCI1510.
Enable TI12XX PCI interrupt in MFUNC when MFUNC pin0 and pin1 are zero.
Ignore the other pins, which may be non-zero (e.g. IRQSER in pin3).
 1.199 20-Apr-2010  dyoung Change sc_pil_intr_enable from an int to a bool. No functional change
intended.
 1.198 19-Apr-2010  dyoung Add default implementations for bus_space_is_equal(9),
bus_space_tag_create(9), and bus_space_tag_destroy(9). Use
bus_space_is_equal(9) throughout the kernel to compare
bus_space_tag_t's. Tested on i386 and on sparc64.
 1.197 15-Mar-2010  dyoung rbus is always #defined as 1, so unifdef -D rbus=1.
 1.196 25-Feb-2010  dyoung branches: 1.196.2;
Cardbus_free_tag() and cardbus_free_tag() are no-ops, so get rid of them
to simplify the code a bit.
 1.195 24-Feb-2010  dyoung Start to tuck Cardbus under the PCI abstraction. Step #1, textual
substitution: for all practical purposes, pcitag_t and cardbustag_t are
interchangeable, so just use pcitag_t. Ditto pcireg_t and cardbusreg_t.

Poison new uses of cardbusreg_t and cardbustag_t by deleting the type
definitions.
 1.194 24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.193 08-Jan-2010  dyoung branches: 1.193.2;
Expand PMF_FN_* macros.
 1.192 15-Dec-2009  snj Move to 2-clause license. Approved by HAYAKAWA Koichi (copyright holder).
 1.191 07-Aug-2009  blymn Destroy mutex and condvar initialised in pccbbattach().
 1.190 07-Aug-2009  blymn Clean up extraneous white space.
 1.189 23-Jul-2009  dyoung Use kpause(9), cv_timedwait(9), and cv_signal(9) instead of tsleep(9)
and wakeup(9).

Use mstohz(9).

XXX Protection against spurious wakeups is still needed, but this patch
XXX makes the code no worse than before in this regard.
 1.188 21-May-2009  dyoung Let us detach pcmcia0 and cardbus0 at cardslot0, and cardslot0 at
cardbus0.
 1.187 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.186 03-May-2009  dyoung In pccbb_pci_callback(), set CBB_SPECMAPPED in sc_flags if we've
acquired bus space from bus_space_alloc(9) or from rbus_space_alloc(),
so that we use the appropriate routine to release the bus space in
pccbbdetach(). This stops panics during cbb(4) detachment (esp. at
shutdown) on some systems.

Thanks to Kurt Schreiner for testing the fix, Kurt, Patrick Welche,
Pouya D. Tafti, and Matt Green for reporting.
 1.185 02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.184 05-Mar-2009  msaitoh Fix typo(s/interupt/interrupt/)
 1.183 13-Feb-2009  bouyer Fix bus_addr_t/bus_size_t confusion
 1.182 06-Feb-2009  dyoung branches: 1.182.2;
When the power status changes, always note the change and wake the
socket events thread. Sometimes we would not note the power-status
change if the socket also indicated a change in card status.
 1.181 11-Jan-2009  christos merge christos-time_t
 1.180 25-Oct-2008  christos branches: 1.180.2; 1.180.4; 1.180.8; 1.180.12;
another TI bridge.
 1.179 06-Aug-2008  dyoung Identify the O2 Micro OZ711E0 and treat it the same as all of the
other O2 Micro bridges, which seem to spuriously report bus errors
if parity-error detection is enabled.
 1.178 03-Jul-2008  drochner branches: 1.178.2;
On cardbus configuration reads, check for a master abort in the cbb
and return all-ones explicitely.
Since pccbb.c rev. 1.151 the cbb is set to translate cardbus master
aborts which makes that the PCI configuration read on the primary bus
returns random junk. This can cause the probing code to get confused.
The issue was reported by KIYOHARA Takashi and Jonathan A. Kollasch,
the patch was tested by KIYOHARA Takashi.
 1.177 26-Jun-2008  drochner delete more dead code, remove use of pcic_handle except of some local
uses in pcmcia ressource management which is copied from ISA pcic,
so use our softc as handle exported to generic pcmcia code and kill
the ph_parent backpointer - this makes the code simpler and smaller
 1.176 26-Jun-2008  drochner remove some more dead code, and use the softc as handle in more internal
functions rather than pcic_handle
 1.175 26-Jun-2008  drochner remove references to nonexisting members of pcic_handle in commented out
and debug code, from Patrick Welche
(we could as well drop pcic_handle completely and use our softc as
the opaque handle for the pcmcia code - this would simplify the code
even more)
 1.174 26-Jun-2008  drochner constify the pcmcia/cardbus method tables
 1.173 25-Jun-2008  drochner Avoid the use of i82365var.h - we don't use any functions from there.
Extract some data structures for ressource management into our private
header instead. This allows to use a typed pointer instead of a
generic one which saves a lot of typecasts.
Also remove something marked as "dirty hack" which I admittedly don't
understand, but it doesn't look useful...
 1.172 25-Jun-2008  drochner split device/softc for pccbb, the cardbus half of cardslot and cardbus
(not yet pcmcia, there is a lot of md code involved)
 1.171 24-Jun-2008  drochner clean up the cardbus interrupt stuff:
There were cardbus_intr_line_t and cardbus_intr_handle_t used intermixed
for the same variable, and that variable is pretty much useless because
cardbus doesn't follow the PCI interrupt swizzling etc scheme.
Useless interrupt numbers were printed on cardbus device attach.
So as a first step to sanity, kill cardbus_intr_handle_t and poison
cardbus_intr_line_t to discourage printing it as a %d.
Use cardbus_intr_line_t consistently throughout the code.
Remove the "interrupting at foo" messages because the information
is misleading. We could come up with a better interrupt vector
information, but because cardbus interrupts are mediated by pccbb
it would still be misleading.
 1.170 24-Jun-2008  drochner clean up some useless code and variables in cardbus attachment
 1.169 27-May-2008  dyoung branches: 1.169.2;
Distinguish O2 Micro bridges from generic bridges. PCI Parity
Error reporting seems to be broken on O2 Micro bridges, so do not
activate it. Should fix kern/38698, reported by Andreas Gustafsson.
 1.168 22-May-2008  dyoung Use __arraycount().
 1.167 04-Mar-2008  dyoung branches: 1.167.2; 1.167.4; 1.167.6;
Check device_has_power() instead of device_is_active() in pccbbintr(),
since the driver must acknowledge some interrupts while it leaves
the suspended state. This protects against an interrupt storm that
will hang the system while I resume rtw0 at cardbus1.
 1.166 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.165 02-Feb-2008  dyoung branches: 1.165.2; 1.165.6;
Fix a two races between the initialization code and cbb(4) interrupts:
establish the interrupt handler before enabling interrupts, so that
we will not get an interrupt storm that keeps the system from making
any progress. (We may have only been susceptible to the storm if
cbb(4) shared an interrupt with, say, uhci(4)). Also, finish
setting up the pcic_handle before enabling interrupts, so that the
Pcic_read() call in pccbbintr() will not jump to address 0!

Now, pccbb_intrinit() encapsulates all of the interrupt initialization.

Explicitly enable card-status changed (CSTSCHG) events.

Paranoia: ensure that writes to the socket event register (interrupt
acknowledgements) are flushed to the h/w by reading the register
(gross). We really need something like
bus_space_sync(BUS_SPACE_BARRIER_WRITE_BEFORE_INTERRUPT).

More paranoia: in pccbbintr(), if the device is inactive, get out.
 1.164 01-Feb-2008  dyoung Use aprint_*_dev() and device_xname() instead of accessing dv_xname
directly.
 1.163 15-Jan-2008  christos Remove ricoh hack; FreeBSD does not seem to do it, and it was a remnant from
the branch. Things should work properly now.
 1.162 14-Jan-2008  dyoung Use device_t, device_private().
 1.161 14-Jan-2008  dyoung In pccbbdetach(), panic if interrupt handlers are still registered
after detaching children.

Use PCI_CB_MEMBASE0, PCI_CB_MEMLIMIT0, PCI_CB_IOBASE0, PCI_CB_IOLIMIT0
instead of magic numbers.
 1.160 02-Jan-2008  dyoung Introduce a struct cardbus_chipset_tag, and make cardbus_chipset_tag_t
a pointer to that struct, so that we cannot assign pointers of
arbitrary type to cardbus_chipset_tag_t. Tweak cbb(4) to accomodate
this change.

Make Cardbus_conf_read() and Carbus_conf_write() pass the right
arguments to cardbus_functions->cardbus_conf_{read,write}() for a
change.

Let's hope this stops the crash in cardbus_function_enable() that
macallan@ reported to me.
 1.159 20-Dec-2007  dyoung Use LIST_FOREACH().
 1.158 16-Dec-2007  dyoung Improve pci, cbb, cardslot, cardbus, and pcmcia to support detachment
of this entire device tree:

pci0 at mainbus0
elansc0 at pci0
gpio0 at elansc0
cbb0 at pci0
cardslot0 at cbb0
cardbus0 at cardslot0
pcmcia0 at cardslot0
cbb1 at pci0
cardslot1 at cbb1
cardbus1 at cardslot1
rtw0 at cardbus1
pcmcia1 at cardslot1
sip0 at pci0
nsphyter0 at sip0
sip1 at pci0
nsphyter1 at sip1

Whew!
 1.157 11-Dec-2007  martin As a stopgap fix: disable a pci_conf_ access at offset 0x82 on archs
that would mind ;-) IMHO this access violates the PCI spec, so this
should be solved differently.
 1.156 09-Dec-2007  jmcneill branches: 1.156.2;
Merge jmcneill-pm branch.
 1.155 01-Dec-2007  jmcneill branches: 1.155.2; 1.155.4;
aprintify
 1.154 24-Nov-2007  dyoung Use TAILQ_FOREACH() to search window lists. Do not insert/remove
windows inside the loop.
 1.153 24-Nov-2007  dyoung Use the PCI #define for the secondary bridge reset instead of using
the duplicate Cardbus #define. Write a note to self: pccbb interrupts
need more work. No functional change intended.
 1.152 21-Nov-2007  dyoung Sometimes a change of CSTSCHG# accompanies the first interrupt from
an Atheros WLAN. That generates a CB_SOCKET_EVENT_CSTS event on
the bridge. The event isn't interesting to pccbb(4), so we used
to ignore the interrupt. Now, let the child devices try to handle
the interrupt, instead. The Atheros NIC produces interrupts more
reliably, now: used to be that it would only interrupt if the driver
avoided powering down the NIC's cardslot, and then the NIC would
only work after it was reset a second time.
 1.151 16-Nov-2007  dyoung Improve Cardbus performance, error handling, and error reporting.

Let the TI1420 PCI-Cardbus bridge do burst reads from the primary
(PCI) bus. This ought to improve Tx performance on Cardbus NICs.
This optimization may apply to other TI bridges, but I only have
a datasheet for the TI1420. :-/

Activate PCI Parity Error and System Error reporting on PCI-Cardbus
bridges.

To avoid data destruction, set the Master Abort mode to 1. Stops
the bridge from silently discarding writes from the secondary bus
to the primary bus (Cardbus writes to PCI). Also, stops the bridge
from fulfilling a read by a bus master on the secondary bus that
failed on the primary bus with 0xffffffff (Cardbus reads from PCI).
Now the bus will indicate an error condition (SERR) instead of
silently destroying/corrupting data.

Forward system error indications from the secondary to the primary
bus. Detect parity errors on the secondary.

Set a Cardbus card's Latency Timer to something reasonable, according
to the Cardbus card's Minimum Grant and the bandwidth available on
the PCI bus. Restore the Latency Timer when re-enabling a card
(e.g., after power reactivation).
 1.150 25-Oct-2007  joerg branches: 1.150.2;
Remove a completely bogus check if cbb has a valid PCI interrupt routed.
If you have a system where it doesn't get one and you still want pcic,
you can just disable cbb. This check is invalid as soon as the PCI
interrupt register is not used and broke on my Dell Latitude for that
reason.
 1.149 22-Oct-2007  joerg Correctly initialise sc_insert_ch and switch to
callout_setfunc/callout_schedule.
 1.148 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.147 11-Aug-2007  dyoung branches: 1.147.2; 1.147.6;
Read the PCI latency timer from the right register, using the right
macro.
 1.146 11-Aug-2007  dyoung Make pccbb(4) use more PCI configuration register definitions,
especially the Bridge Control Register definition, instead of
rolling its own.

As we read/modify/write configuration registers, use a variable
that is named for the register we're r/m/w'ing, instead of using
the variable 'reg' over and over. This helps both a human reader
verify that we're not reading register X, modifying it, and writing
back to register Y (oops); the compiler can help a little by warning
that a variable is used before it is initialized.
 1.145 16-Jul-2007  christos branches: 1.145.2; 1.145.6;
PR/36652: Dave Barnes: cbb0: Bad Vcc status once set will not clear
-ThinkPad 570 / PC: Don't write to SOCKET_STAT, which is read-only,
instead write to SOCKET_FORCE.
 1.144 04-Feb-2007  dyoung branches: 1.144.6;
Fix a bug in Cardbus power activation.

Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'. TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt. When pccbb_power() powered-up a
cardslot, it did wait for the interrupt. If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0: power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete. After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up. An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

/*
* Wait as long as 200ms for a power-cycle interrupt. If
* interrupts are enabled, but the socket has already
* changed to the desired status, keep waiting for the
* interrupt. "Consuming" the interrupt in this way keeps
* the interrupt from prematurely waking some subsequent
* pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

* XXX Not every bridge interrupts on the ->OFF transition.
* XXX That's ok, we will time-out after 200ms.
*
* XXX The power cycle event will never happen when attaching
* XXX a 16-bit card. That's ok, we will time-out after
* XXX 200ms.
*/

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
 1.143 04-Feb-2007  dyoung Cosmetic: KNF indentation, curly braces, and argument declarations.
 1.142 04-Feb-2007  dyoung Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().
 1.141 04-Feb-2007  dyoung Use the right subroutine name for the debug message.
 1.140 26-Jan-2007  dyoung Fix grammar in comment. From Patrick Welche.
 1.139 26-Jan-2007  dyoung Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR.
 1.138 21-Dec-2006  yamt merge yamt-splraiseipl branch.

- finish implementing splraiseipl (and makeiplcookie).
http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
- complete workqueue(9) and fix its ipl problem, which is reported
to cause audio skipping.
- fix netbt (at least compilation problems) for some ports.
- fix PR/33218.
 1.137 16-Nov-2006  christos branches: 1.137.2; 1.137.4;
__unused removal on arguments; approved by core.
 1.136 24-Oct-2006  itohy 3c575CT Ethernet card requires a little more time during reset
and after reset, or the card won't be detected on some machines.
Change the time from 40ms to 50ms.

XXX The card doesn't work correctly yet.
 1.135 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.134 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.133 08-Jul-2006  christos branches: 1.133.4; 1.133.6;
- Tidy up some debugging/diagnostic messages.
- Add a delay for the topic95b after we power on. It makes things work without
CBB_DEBUG on!
 1.132 08-Jul-2006  christos - all the polling code is stale and broken. Mention it.
- the topic95B bridge does not set CB_SOCKET_STAT_PWRCYCLE
- put back the delay code that was removed *again*.
This makes my libretto 100CT work again.
 1.131 04-Jul-2006  christos fix typo
 1.130 04-Jul-2006  christos Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.129 17-Jun-2006  jmcneill For Ricoh 5c47x class controllers, restore the "misc control" PCI config
register on resume.
 1.128 05-Apr-2006  dyoung branches: 1.128.2; 1.128.4;
Fix typo in comment, s/will be never/will never/.
 1.127 18-Dec-2005  sekiya branches: 1.127.4; 1.127.6; 1.127.8; 1.127.10; 1.127.12;
Use aprint_debug() instead of printf() for obvious debug statement.
 1.126 11-Dec-2005  christos merge ktrace-lwp.
 1.125 09-Sep-2005  drochner remove the useless (always 0) device number from cardbus driver state,
autoconf attach structures and configuration cycle functions
(just leave the kernel configuration attribute for now to avoid breaking
config(1) files)
 1.124 23-Jun-2005  wiz branches: 1.124.2;
s/PCIBIOS_FIXUP/PCI_FIXUP/ in printf, from Patrick Welche in PR 30583.
 1.123 22-Jun-2005  sekiya Oops, a unilateral DEBUG define crept in with my last commit.
 1.122 20-Jun-2005  sekiya Don't abort the attach if we are routing interrupts through the ioapic, there
 1.121 01-Jun-2005  sekiya Fix compilation problem when CBB_DEBUG is defined.
 1.120 01-Jun-2005  sekiya "resister" -> "register"
 1.119 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.118 23-Mar-2005  christos PR/29600: YAMAMOTO Takashi: cbb hangs on boot. From the PR:
It seems that we never get a power interrupt for 16 bit cards. The tsleep
has been changed to wait for 200ms maximum, before giving up instead of
waiting forever. XXX: Maybe that is too small for some laptops?
 1.117 27-Feb-2005  perry branches: 1.117.2;
nuke trailing whitespace
 1.116 04-Feb-2005  perry de-__P
 1.115 27-Jan-2005  jmcneill Fix typo.
 1.114 27-Jan-2005  jmcneill Don't restore PCI configuration state if the chip isn't in D0, from
Kentaro A. Kurahone.
 1.113 27-Jan-2005  jmcneill Capture PCI configuration state on suspend and restore it on resume, from
Kentaro A. Kurahone.
 1.112 16-Jan-2005  mycroft branches: 1.112.2; 1.112.4;
Just to be absolutely correct, wait an additional 1ms after the "power cycle"
event, to cover the RESET Width (Tw (RESET)).
 1.111 16-Jan-2005  mycroft Christos's crappy Libretto 100CT has an extremely long ramp for socket Vcc
(violating the PC Card spec), so... use the "power cycle" socket event to
determine when we've reached Vcc before proceeding, rather than using a fixed
amount of time. This has the double advantage that it makes the card attach
time even shorter on sane systems -- the minimum is now ~38ms on my i8500
rather than 222ms.

Probably a similar change should be made to pcic, but it was hard enough
figuring out whether it would work with pccbb. The chip specs suck.

For now, I'm leaving in a couple of additional printf()s in the hope that I
will get some interesting data from them.
 1.110 16-Aug-2004  mrg fix a wrong variable name in a debug message.
 1.109 16-Aug-2004  mycroft Simplify some manipulation of PCIC_INTR.
Further attempt to mitigate "bad Vcc" errors.
 1.108 16-Aug-2004  mycroft Some tweaks, per the PC Card spec:
* Assert RESET before powering off a socket.
* Turn on the output enable bit earlier so the interface actually drives CEn
and RESET.
* Tighten up the power-on timing a bit.
* Mention the specific timing values named in the spec.

For pccbb, be careful to always power off before zeroing PWRCTL.
 1.107 16-Aug-2004  mycroft Do not attempt to fiddle with the power-control bits in PWRCTL; just read them
back after touching the PCI registers.

This shouldn't be necessary, but somehow the controller detects the need for
VPP2=12V and automatically applies it, and gives us a "bad Vcc" error if we
turn it off accidentally.
 1.106 15-Aug-2004  mycroft And the reason we had to call pccbb_power() twice in the enable routine is...
we were writing to PCIC_PWRCTL in between and causing the socket to power off.
D'oh.
 1.105 12-Aug-2004  mycroft I can't actually use the FORCE register this way. Just try turning the socket
power off.
 1.104 12-Aug-2004  mycroft A bunch of random cleanup:
* Like the i82365 code, add a "delay" function that uses tsleep() to wait, and
use this in the socket enable/disable paths. This gets rid of the annoying
system pauses during card insertion and removal. (There are still some
issues related to this in various drivers -- notably big delay()s in wi and
xi.)
* Move the power-change delay out of pccbb_power() and into the PCMCIA backend
code -- specifically, once in the disable path and once in the enable path.
We were being pretty schizo about this before. Make these use tsleep().
(Note: This should be safe because card insertion/removal is handled by a
kernel process, not in an interrupt handler. It works for me with
DIAGNOSTIC.)
* If we get a "bad Vcc" error, attempt to force the socket to power off, and
return an error. If we don't do this, we will get "bad Vcc" errors forever
and never be able to use another card without rebooting, which is dumb.
XXX I haven't been able to test this very well, because it doesn't fail for
me in the first place. :-)
* Clean up the socket mappings earlier in the enable path.
* Try to be consistent about clearing PWRCTL (which contains OE) before turning
off power.
 1.103 11-Aug-2004  mycroft Oops; fix a compile error.
 1.102 11-Aug-2004  mycroft Be more liberal in torching the old state in the disable and settype routines.
 1.101 11-Aug-2004  mycroft Rather than having a call up from the low-level driver to get the card type,
instead have a call down from the PCMCIA mid-layer to set it. Use this from
pcmcia_function_enable(). (Currently the policy is the same, but this would
allow for more flexibility in deciding which mode to use.)

Now it is safe to hold the socket enabled during attach, so do that. Only
one enable/disable cycle to attach a card now!
 1.100 06-Aug-2004  mycroft Rework the power sequencing so that I stop getting unrecoverable "bad Vcc"
errors with PCMCIA cards.

I've been using this change for almost a year, but accidentally blew it away
recently, and boy did that suck.
 1.99 28-Jul-2004  he Add entries for TI CardBus bridges 1520 and 4520Yenta, as found in
IBM ThinkPad 40p and 41p respectively, so that the CardBus probes and
works on those machines. Fixes PR#26380.
 1.98 22-Jul-2004  mycroft If the bus number has not been initialized, do not attach a cardslot, and
output a diagnostic:
pccbbN: secondary bus number uninitialized; try PCIBIOS_BUS_FIXUP
 1.97 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.96 28-Mar-2004  nakayama branches: 1.96.2;
Add some initialization code for TI bridges.
Mostly from FreeBSD, and tested on i386 w/ PCI1250 and sparc64 w/ PCI1410.
 1.95 19-Dec-2003  christos More unsigned long casts to make this work on ppc. Fix formatting of debug
statements to 0x when there are hex numbers printed.
 1.94 19-Dec-2003  christos PR/23802: KIYOHARA Takashi: Bad printf format with CBB_DEBUG. While I am
there, make all printfs consistent 0x%lx and (unsigned long) cast.
 1.93 10-Dec-2003  briggs Power up the card without OE enabled to avoid letting SanDisks enter
True IDE mode. Hinted at by Charles Hannum a while back. This lets
my PCI-Cardbus adapter read SanDisk CF cards much more reliably.

Also bring in a few defines from FreeBSD for some more TI registers and such.
 1.92 25-Oct-2003  christos Fix uninitialized variable warnings
 1.91 23-Oct-2003  briggs Try to deal better with card removal during the card enabling process.
 1.90 19-Jun-2003  msaitoh branches: 1.90.2;
regard as the card is removed if one of CCD1# and CCD2# is deasserted.
This fixes the porblem that the cbb misses a remove event.
 1.89 16-Jun-2003  thorpej Rename IPL_IMP -> IPL_VM.
 1.88 22-Mar-2003  nakayama PCI-CardBus bridge support for sparc64:
- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.
 1.87 20-Jan-2003  simonb Remove unreachable "break"s after "return"s.
 1.86 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.85 23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.84 09-Nov-2002  martin Add TI PCI4410 PCI-CardBus Bridge w/ OHCI IEEE 1394,
from FUKAUMI Naoki in PR 18989.
 1.83 19-Oct-2002  atatat Don't print messages about pccbb_intr_disestablish() unless debugging
is actually enabled.
 1.82 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.81 01-Oct-2002  onoe make it compilable with CBB_DEBUG.
 1.80 01-Oct-2002  haya Use LIST in sys/queue. Add some comments.
 1.79 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.78 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.77 31-May-2002  mycroft Patch the CLKRUN enable bit on ToPIC chips.
 1.76 31-May-2002  haya Add comment.
 1.75 05-Mar-2002  haya branches: 1.75.2; 1.75.6;
Enforce 10-bit width for I/O addresses of 16-bit PC Cards when I/O
start address is assigned by a driver.
 1.74 10-Jan-2002  haya Bug fix: correct chattering suppressor. Card insertion will be
detected properly by this fix.
 1.73 24-Dec-2001  christos change if defined foo to ifdef foo and change a c++ comment into a c comment.
 1.72 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.71 13-Nov-2001  lukem add RCSID
 1.70 02-Nov-2001  haya Add PCI power management control. If the power state of a bridge is
not D0 at device attaching or resuming, set the bridge D0 mode.
 1.69 17-Oct-2001  haya branches: 1.69.2;
Move some chip initialise code into pccbb_chipinit() function.
 1.68 30-Sep-2001  yamt force 0x1000 align for memory base before
calling rbus_space_alloc().
resource management may be inconsistent without it.
 1.67 30-Aug-2001  haya branches: 1.67.2;
Add some register definitions for TI PCI12XX and Toshiba ToPIC.
Add ToPIC97 and ToPIC100 chip initialisation routine.
Add more TI PCI12XX chip initialisation.
 1.66 24-Aug-2001  haya Buf fix: use PWAIT priority and do not set PCATCH.
 1.65 06-Jul-2001  mcr branches: 1.65.2;
split pccbb_intr_route() into seperate function.
 1.64 19-May-2001  soren Add TI 1410 to yc_chipsets[].
 1.63 30-Apr-2001  jmc Cast args correctly to match format strings.
 1.62 12-Apr-2001  thorpej splimp -> splvm (use IPL_IMP needs to be revisited).
 1.61 22-Feb-2001  enami branches: 1.61.2;
- Initialize auto variable (win[{0,1}].win_flags).
- If PCCBB_MEM_CACHABLE isn't set, clear CB_BCR_PREFETCH_MEMWIN[01].
 1.60 21-Feb-2001  jdolecek make some more constant arrays 'const'
 1.59 21-Feb-2001  minoura Correct the 1st argument for pci_conf_{read,write}.
On non-i386 platforms the previous revision could not be compiled.
Pointed out by mjl.
 1.58 20-Feb-2001  minoura Re-initialize more registers after resuming from suspend.
Some APM BIOSes do not restore them.
Reviewd by haya.
 1.57 09-Feb-2001  haya BUG FIX: calculate address line mask in pccbb_pcmcia_io_alloc() when
start address is not set.
 1.56 30-Jan-2001  itohy Fix problem where tsleep() is used not on the cardbus thread.
This change makes PCMCIA cards work again on my machine.

Unfortunately, some of the DELAY_MS() are called when the current
process is not the cardbus thread, that is, on interrupt contexts.
I confirmed these are actually used in interrupt context and replaced
them with delay()s. However, I haven't confirmed other DELAY_MS()s
are always on the cardbus thread.

This shall be a temporary fix. The driver needs being rewritten
not to use such delay()s, of course.
 1.55 24-Jan-2001  haya IMPROVEMENT: use tsleep() instead of delay(). Kernel do not stop
during card insertion, deletion and power change.
 1.54 22-Jan-2001  augustss Add a comment.
 1.53 17-Jan-2001  haya Fix comment.
 1.52 30-Dec-2000  augustss Be less talkative in attach.
 1.51 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.50 08-Dec-2000  mycroft Turn off the damned TI `VCC protection' bit.
 1.49 08-Dec-2000  haya WORKAROUND: CardBus bridge avoids turning off the power of channel in
shutdown hook when the bridge chip is TI113X. Because PowerBook 2400
hangs here.
 1.48 28-Nov-2000  haya BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.
 1.47 27-Nov-2000  haya BUG FIX: pccbb turns off PC Cards' power on the bus in shutdown hook.
Some machines cannot reboot without this fix.
 1.46 25-Oct-2000  haya Bugfix: reset 16-bit pcmcia in chip initialisation sequence.
 1.45 28-Aug-2000  haya Correct PCI interrput setup routine for Texas Instruments PCI113X.
Now PCI113X is able to handle hot insertion and deletion properly.
 1.44 09-Jul-2000  jhawk Clarify that the RX5C47X requires writes to the PCI_LEGACY to
disable and not PCI_BCR_INTR; this is what rev 1.9 did under
the label of "Maintenance."
 1.43 09-Jul-2000  jhawk Move legacy pcic-mode disabling code from pccbb_chipinit() to
pccbbattach(). This is necessary as pccbb_chipinit() is deferred, and
may not run until after the pcic is already attached.

Now pcics are properly disabled on Sony VAIO, f'rinstance.
 1.42 16-Jun-2000  cgd branches: 1.42.2;
beat back the undead: __BROKEN_INDIRECT_CONFIG had risen, and was
terrorizing innocent hackers...
 1.41 08-Jun-2000  haya Change IPL when bridge's interrupt handler calls child device's
interrupt handler (This solution is not very good).
 1.40 07-Jun-2000  haya Add CB_BCR_RESET_ENABLE in bridge control resister's bit definition.
 1.39 08-May-2000  kleink branches: 1.39.2;
Fix a inverted logic botch introduced in rev. 1.35, typically causing
cb_chipset() to return the wrong chipset type.
 1.38 06-Apr-2000  haya Add CardBus interrupt enable flag. When this flag is asserted, a
CardBus interrupt is routed to the child devices and vice versa. This
flag is negated when a pccbb receives a suspend or stanby event.
 1.37 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.36 22-Mar-2000  haya 1. Do not apply 5 V on a CardBus card.
2. Do not avoid ISA hole when a device requires more than
256-byte io space.
3. Remove sending CardBus bridge's function number to
cardbus stack. This number is not needed for anyone.
 1.35 14-Mar-2000  enami Simplify the code a bit.
 1.34 14-Mar-2000  enami Don't think that a card is inserted if there is a card already in the slot.
Note that powerdown hook calls pccbbintr so that it detect card insertion or
removal during suspension.
 1.33 14-Mar-2000  enami Cosmetic change.
 1.32 14-Mar-2000  enami Fix typos in comments.
 1.31 12-Mar-2000  mycroft A few things:
* Initialize PCIC_INTR and PCIC_CSC_INTR on all chips, not just TI.
* Leave card detect interrupts enabled in PCIC_CSC_INTR. (This requires
reading PCIC_CSC in the interrupt handler on some chips, so do that too.)
* Leave PCIC_INTR_ENABLE set, as some chips require this to post card detect
interrupts while in PCMCIA mode.
* Leave PCIC_INTR_RESET (which is inverted) set at all times *except* when
powering up a socket, as some chips will use it to drive RESET# low even
while a CardBus card is in the slot.

This makes PCMCIA and CardBus cards works with some TI chips. Cross-checked
with a Toshiba ToPIC 95B.
 1.30 12-Mar-2000  mycroft Do *not* fiddle with the serial/parallel IRQ mode selection on TI chips.
Without extensive probing, we cannot possibly know that we're doing the right
thing.

Also some stylistic changes.
 1.29 12-Mar-2000  mycroft Revert the previous change. It does not match the commit message *and* was
incomplete (and probably quite broken).
 1.28 10-Mar-2000  haya Only apply power on 3.3 V CardBus card (there are no 5 V CardBus card.)
 1.27 01-Mar-2000  thorpej Simplify the winlist code.
 1.26 23-Feb-2000  haya Pccbb maintains the interrupt handlers for 16-bit PC Cards
by itself.
Add some comments.
 1.25 22-Feb-2000  enami Establish a powerhook and make sure the card detect interrupt is enabled
after resume from suspend, as i82365.c does.
This is a workaround for newer Sony VAIO notebook.
Patch is submitted by Atsushi Onoe (onoe@sm.sony.co.jp) in PR#9463.
 1.24 21-Feb-2000  thorpej Sync PCMCIA memory mapping with a change from rev 1.47 of i82365.c:
always map attr memory 8 bit, since its defined that way. (chopps)
 1.23 06-Feb-2000  cgd clean up some printfs
 1.22 05-Feb-2000  chopps run this through indent with some comment cleanup -- more knfing needed.
 1.21 26-Jan-2000  haya Pccbb manages interrupt handlers by itself for its child device.
 1.20 25-Jan-2000  joda get the device name from pcidevs instead of having a list here
 1.19 25-Jan-2000  haya Do pccbb_chipinit() after YENTA register space allocation.
Add TI PCI 1451 PCI-CardBus entry.
 1.18 25-Jan-2000  chopps Don't enable the interrupt until after we cycle the power, disable
interrupt at disable, and make this code look more like the std pcic
code. From Mycroft and I.
 1.17 24-Jan-2000  joda The TI 2030 is a PCI-PCI bridge and doesn't belong here
 1.16 23-Jan-2000  mycroft Remove code that should not have been added.
 1.15 23-Jan-2000  augustss Add parens so a ?: expression binds correctly.
 1.14 17-Jan-2000  joda add shutdown hook
 1.13 13-Jan-2000  joda remove stale comment
 1.12 13-Jan-2000  joda (pccbb_pcmcia_do_mem_map): handle 8-bit memory
 1.11 13-Jan-2000  joda make this slightly more inline with other code; and while at it, fix
some oddities in pccbb_winset
 1.10 12-Jan-2000  haya Add an entry for Toshiba ToPIC100 CardBus-PCI bridge.
Maintainance for 3Com multi-function, 16-bit pcmcia card.
 1.9 20-Dec-1999  haya branches: 1.9.2;
Maintanance for Ricoh RL5C475. VAIO 505TX uses this chip.
 1.8 15-Nov-1999  joda (pccbb_pci_callback): no point in reading the bus number register
twice
 1.7 01-Nov-1999  haya Maintainance the name of Ricoh PCI-CardBus bridges.
 1.6 30-Oct-1999  augustss Make this file compile again by using the same names as in pcidevs.
 1.5 27-Oct-1999  haya Do not stop no matter when pci_mapreg_map fails to map bridge socket
registers. When it fails, reset Socket Base Address register and map
registers using rbus.
 1.4 19-Oct-1999  haya branches: 1.4.2;
Disable legacy io port before the bridge is probed as a pcic on isa.
Comments ware changed to comply the KNF.
Add PCCBB_PCMCIA_16BITONLY to support TI PCI103X series.
 1.3 15-Oct-1999  augustss branches: 1.3.2;
Comment out some debug settings.
Change attach printing so it looks more standard.
 1.2 15-Oct-1999  haya add NetBSD ID tag.
 1.1 15-Oct-1999  haya This is the first check-in of CardBus driver. CardBus driver contains
CardBus bus stub, YENTA PCI-CardBus bridge (cbb), 3Com 3C575TX driver
(ex) and Intel fxp driver.

TODO:
o Conform to the KNF more strictly.
o Be unified with pcmcia code as much as possible.
o Add more drivers for CardBus card, such as APA-1480 or USB card.

The affected files are listed below.

sys/arch/i386/conf/files.i386
sys/arch/macppc/conf/files.macppc
sys/conf/files
sys/dev/ic/elinkxl.c
sys/dev/ic/elinkxlvar.h
sys/dev/ic/i82365.c
sys/dev/ic/i82365var.h
sys/dev/isa/i82365_isasubr.c
sys/dev/pci/files.pci
sys/dev/pcmcia/pcmcia.c
sys/dev/pcmcia/pcmciachip.h

The added files are listed below.

sys/arch/i386/conf/CARDBUS
sys/arch/i386/include/rbus_machdep.h
sys/arch/i386/i386/rbus_machdep.c
sys/arch/macppc/include/rbus_machdep.h
sys/arch/macppc/macppc/rbus_machdep.c
sys/dev/cardbus/if_ex_cardbus.c
sys/dev/cardbus/Makefile.cardbusdevs
sys/dev/cardbus/cardbus.c
sys/dev/cardbus/cardbus_map.c
sys/dev/cardbus/cardbusdevs
sys/dev/cardbus/cardbusdevs.h
sys/dev/cardbus/cardbusdevs_data.h
sys/dev/cardbus/cardbusvar.h
sys/dev/cardbus/cardslot.c
sys/dev/cardbus/cardslotvar.h
sys/dev/cardbus/devlist2h.awk
sys/dev/cardbus/files.cardbus
sys/dev/cardbus/if_fxp_cardbus.c
sys/dev/cardbus/pccardcis.h
sys/dev/cardbus/rbus.c
sys/dev/cardbus/rbus.h
sys/dev/pci/pccbb.c
sys/dev/pci/pccbbreg.h
sys/dev/pci/pccbbvar.h
 1.3.2.10 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.9 12-Mar-2001  bouyer Sync with HEAD.
 1.3.2.8 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.7 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.2.6 05-Jan-2001  bouyer Sync with HEAD
 1.3.2.5 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.3.2.4 08-Dec-2000  bouyer Sync with HEAD.
 1.3.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 20-Oct-1999  thorpej Sync w/ trunk.
 1.4.2.2 15-Nov-1999  fvdl Sync with -current
 1.4.2.1 19-Oct-1999  fvdl file pccbb.c was added on branch fvdl-softdep on 1999-11-15 00:41:06 +0000
 1.9.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.39.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.42.2.7 09-Feb-2002  he Pull up revision 1.74 (requested by haya):
Correct chattering suppressor. This makes card insertion detection
work properly.
 1.42.2.6 22-Jan-2002  he Pull up revision 1.57 (requested by haya):
Calculate address mask appropriately for 16-bit PC-cards.
 1.42.2.5 24-Dec-2001  he Pull up revision 1.70 (partial, via patch, requested by haya):
Add PCI power management control to the PCI-CardBus bridge.
Fixes PR#14149.
 1.42.2.4 01-May-2001  he Pull up revisions 1.46,1.48 (requested by fvdl):
Deal correctly with 16-bit pcmcia cards. Fixes PR#12736 and
PR#12737.
 1.42.2.3 15-Dec-2000  he Pull up revisions 1.47,1.49 (requested by haya):
Turn off power on shutdown, except on ToPIC (TI 113X) bridges on
shutdown to avoid hangs on some systems.
 1.42.2.2 08-Sep-2000  haya Pull up rev 1.45: bugfix for Texas Instruments PCI113X. This pullup
fixes that the bridge does not propagate any interrupt signals when a
card is inserted or removed.

This pullup is approved by <thorpej@netbsd.org>.
 1.42.2.1 12-Jul-2000  jhawk Pullup rev 1.43-1.44, approved by thorpej:
1.43:
Move legacy pcic-mode disabling code from pccbb_chipinit() to
pccbbattach(). This is necessary as pccbb_chipinit() is deferred, and
may not run until after the pcic is already attached.

Now pcics are properly disabled on Sony VAIO, f'rinstance.
rev 1.44:
Clarify that the RX5C47X requires writes to the PCI_LEGACY to
disable and not PCI_BCR_INTR; this is what rev 1.9 did under
the label of "Maintenance."
 1.61.2.15 03-Jan-2003  thorpej Sync with HEAD.
 1.61.2.14 29-Dec-2002  thorpej Sync with HEAD.
 1.61.2.13 11-Nov-2002  nathanw Catch up to -current
 1.61.2.12 18-Oct-2002  nathanw Catch up to -current.
 1.61.2.11 20-Jun-2002  nathanw Catch up to -current.
 1.61.2.10 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.61.2.9 28-Feb-2002  nathanw Catch up to -current.
 1.61.2.8 11-Jan-2002  nathanw More catchup.
 1.61.2.7 08-Jan-2002  nathanw Catch up to -current.
 1.61.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.61.2.5 22-Oct-2001  nathanw Catch up to -current.
 1.61.2.4 08-Oct-2001  nathanw Catch up to -current.
 1.61.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.61.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.61.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.65.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.65.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.65.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.65.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.65.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.65.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.65.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.67.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.69.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.75.6.1 20-Jun-2002  gehenna catch up with -current.
 1.75.2.1 17-Mar-2002  thorpej IPL_IMP -> IPL_VM
 1.90.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.90.2.7 01-Apr-2005  skrll Sync with HEAD.
 1.90.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.90.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.90.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.90.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.90.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.90.2.1 03-Aug-2004  skrll Sync with HEAD
 1.96.2.2 28-Jul-2004  jmc Pullup rev 1.99 (requested by he in ticket #724)

Add entries for TI CardBus bridges 1520 and 4520Yenta, as found in
IBM ThinkPad 40p and 41p respectively, so that the CardBus probes and
works on those machines. PR#26380.
 1.96.2.1 23-Jul-2004  he Pull up revision 1.98 (requested by mycroft in ticket #692):
If the bus number has not been initialized, do not attach
a cardslot, and instead output a diagnostic pointing the
administrator towards the PCIBIOS_BUS_FIXUP option.
 1.112.4.3 26-Mar-2005  yamt sync with head.
 1.112.4.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.112.4.1 12-Feb-2005  yamt sync with head.
 1.112.2.2 29-Apr-2005  kent sync with -current
 1.112.2.1 16-Jan-2005  kent file pccbb.c was added on branch kent-audio2 on 2005-04-29 11:29:07 +0000
 1.117.2.2 21-Jan-2006  snj Pull up following revision(s) (requested by uwe in ticket #1120):
sys/dev/pci/pccbb.c: revision 1.127
Use aprint_debug() instead of printf() for obvious debug statement.
 1.117.2.1 27-Mar-2005  tron Pull up revision 1.118 (requested by christos in ticket #64):
PR/29600: YAMAMOTO Takashi: cbb hangs on boot. From the PR:
It seems that we never get a power interrupt for 16 bit cards. The tsleep
has been changed to wait for 200ms maximum, before giving up instead of
waiting forever. XXX: Maybe that is too small for some laptops?
 1.124.2.9 17-Mar-2008  yamt sync with head.
 1.124.2.8 04-Feb-2008  yamt sync with head.
 1.124.2.7 21-Jan-2008  yamt sync with head
 1.124.2.6 07-Dec-2007  yamt sync with head
 1.124.2.5 27-Oct-2007  yamt sync with head.
 1.124.2.4 03-Sep-2007  yamt sync with head.
 1.124.2.3 26-Feb-2007  yamt sync with head.
 1.124.2.2 30-Dec-2006  yamt sync with head.
 1.124.2.1 21-Jun-2006  yamt sync with head.
 1.127.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.127.10.1 19-Apr-2006  elad sync with head.
 1.127.8.3 11-Aug-2006  yamt sync with head
 1.127.8.2 26-Jun-2006  yamt sync with head.
 1.127.8.1 11-Apr-2006  yamt sync with head
 1.127.6.1 22-Apr-2006  simonb Sync with head.
 1.127.4.1 09-Sep-2006  rpaulo sync with head
 1.128.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.128.2.1 19-Jun-2006  chap Sync with head.
 1.133.6.3 10-Dec-2006  yamt sync with head.
 1.133.6.2 02-Nov-2006  yamt use splraiseipl.
 1.133.6.1 22-Oct-2006  yamt sync with head
 1.133.4.4 09-Feb-2007  ad Sync with HEAD.
 1.133.4.3 01-Feb-2007  ad Sync with head.
 1.133.4.2 12-Jan-2007  ad Sync with head.
 1.133.4.1 18-Nov-2006  ad Sync with head.
 1.137.4.2 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.137.4.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.137.2.3 26-Oct-2007  xtraeme Pull up following revision(s) (requested by joerg in ticket #949):
sys/dev/pci/pccbb.c: revision 1.150
Remove a completely bogus check if cbb has a valid PCI interrupt routed.
If you have a system where it doesn't get one and you still want pcic,
you can just disable cbb. This check is invalid as soon as the PCI
interrupt register is not used and broke on my Dell Latitude for that
reason.
 1.137.2.2 26-Oct-2007  xtraeme Pull up following revision(s) (requested by joerg in ticket #942):
sys/dev/pci/pccbb.c: revision 1.149

Correctly initialise sc_insert_ch and switch to
callout_setfunc/callout_schedule.
 1.137.2.1 30-Jul-2007  liamjfoy Pull up following revision(s) (requested by dyoung in ticket #739):
sys/dev/pci/pccbb.c: revision 1.140
sys/dev/pci/pccbb.c: revision 1.141
sys/dev/pci/pccbb.c: revision 1.142
sys/dev/pci/pccbb.c: revision 1.143
sys/dev/pci/pccbb.c: revision 1.144
sys/dev/pci/pccbbvar.h: revision 1.28
sys/dev/pci/pcireg.h: revision 1.53
sys/dev/pci/pccbb.c: revision 1.139
Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR.

Fix grammar in comment. From Patrick Welche.

Use the right subroutine name for the debug message.

Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().

Cosmetic: KNF indentation, curly braces, and argument declarations.

sc_pwrcycle is shared between the interrupt handler and Cardbus
event thread, so make it volatile.

Fix a bug in Cardbus power activation.

Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'. TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt. When pccbb_power() powered-up a
cardslot, it did wait for the interrupt. If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0: power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete. After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up. An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

/*
* Wait as long as 200ms for a power-cycle interrupt. If
* interrupts are enabled, but the socket has already
* changed to the desired status, keep waiting for the
* interrupt. "Consuming" the interrupt in this way keeps
* the interrupt from prematurely waking some subsequent
* pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

* XXX Not every bridge interrupts on the ->OFF transition.
* XXX That's ok, we will time-out after 200ms.
*
* XXX The power cycle event will never happen when attaching
* XXX a 16-bit card. That's ok, we will time-out after
* XXX 200ms.
*/

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
 1.144.6.2 23-Oct-2007  ad Sync with head.
 1.144.6.1 20-Aug-2007  ad Sync with HEAD.
 1.145.6.8 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.145.6.7 01-Dec-2007  jmcneill Sync with HEAD.
 1.145.6.6 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.145.6.5 21-Nov-2007  joerg Sync with HEAD.
 1.145.6.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.145.6.3 28-Oct-2007  joerg Sync with HEAD.
 1.145.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.145.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.145.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.147.6.4 21-Nov-2007  bouyer Sync with HEAD
 1.147.6.3 18-Nov-2007  bouyer Sync with HEAD
 1.147.6.2 13-Nov-2007  bouyer Sync with HEAD
 1.147.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.147.2.3 23-Mar-2008  matt sync with HEAD
 1.147.2.2 09-Jan-2008  matt sync with HEAD
 1.147.2.1 06-Nov-2007  matt sync with HEAD
 1.150.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.150.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.150.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.150.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.155.4.1 11-Dec-2007  yamt sync with head.
 1.155.2.1 26-Dec-2007  ad Sync with head.
 1.156.2.4 19-Jan-2008  bouyer Sync with HEAD
 1.156.2.3 08-Jan-2008  bouyer Sync with HEAD
 1.156.2.2 02-Jan-2008  bouyer Sync with HEAD
 1.156.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.165.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.165.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.165.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.165.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.165.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.165.2.1 24-Mar-2008  keiichi sync with head.
 1.167.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.167.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.167.4.6 11-Aug-2010  yamt sync with head.
 1.167.4.5 11-Mar-2010  yamt sync with head
 1.167.4.4 19-Aug-2009  yamt sync with head.
 1.167.4.3 20-Jun-2009  yamt sync with head
 1.167.4.2 16-May-2009  yamt sync with head
 1.167.4.1 04-May-2009  yamt sync with head.
 1.167.2.1 04-Jun-2008  yamt sync with head
 1.169.2.2 03-Jul-2008  simonb Sync with head.
 1.169.2.1 27-Jun-2008  simonb Sync with head.
 1.178.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.178.2.1 19-Oct-2008  haad Sync with HEAD.
 1.180.12.1 21-Apr-2010  matt sync to netbsd-5
 1.180.8.2 04-Jan-2009  christos fix time_t format.
 1.180.8.1 25-Oct-2008  christos file pccbb.c was added on branch christos-time_t on 2009-01-04 02:16:41 +0000
 1.180.4.1 30-Sep-2009  snj Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/dev/isa/if_lc_isa.c: revision 1.30
sys/dev/pci/pccbb.c: revision 1.183
Fix bus_addr_t/bus_size_t confusion
 1.180.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.180.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.180.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.182.2.2 23-Jul-2009  jym Sync with HEAD.
 1.182.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.193.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.196.2.2 05-Mar-2011  rmind sync with head
 1.196.2.1 30-May-2010  rmind sync with head
 1.203.6.1 18-Feb-2012  mrg merge to -current.
 1.203.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.203.2.1 17-Apr-2012  yamt sync with head
 1.204.10.1 18-May-2014  rmind sync with head
 1.204.6.2 03-Dec-2017  jdolecek update from HEAD
 1.204.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.204.2.1 07-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #1201):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111-1.112 (patch)
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23 (patch)
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28 (patch)

Replace callout_stop with callout_halt and ensure the callout
is not running before destroying it.
 1.206.4.1 01-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #279):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.112
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
Discussed with martin@ and riastradh@.
Make it clear that we should use not callout_stop but callout_halt
before callout_destroy
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete.
Reviewed by riastradh@.
Kill sme_callout_mtx and use sme_mtx instead
We can use sme_mtx for the callout as well. Actually we should do so
because sme_events_list and some other data that are touched in the
callout should be protected by sme_mtx, not sme_callout_mtx.
Discussed with riastradh@ in
http://mail-index.netbsd.org/tech-kern/2014/11/11/msg017956.html
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete. And also we make sure that SME_CALLOUT_INITIALIZED
is unset before calling callout_halt to prevent the callout from calling
callout_schedule. This is the same as what we did in sys/netinet6/mld6.c@1.61.
Reviewed by riastradh@.
 1.207.2.4 28-Aug-2017  skrll Sync with HEAD
 1.207.2.3 09-Jul-2016  skrll Sync with HEAD
 1.207.2.2 19-Mar-2016  skrll Sync with HEAD
 1.207.2.1 06-Apr-2015  skrll Sync with HEAD
 1.210.8.1 11-May-2017  pgoyette Sync with HEAD
 1.211.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.211.10.1 10-Jun-2019  christos Sync with HEAD
 1.211.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.215.10.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.216.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.17 06-May-2023  andvar few more typos in the word "register", mainly s/resister/register/.
In one comment I assume that it was meant to be pull-up resistor.
 1.16 15-Oct-2019  msaitoh Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.15 15-Dec-2009  snj branches: 1.15.64; 1.15.70;
Move to 2-clause license. Approved by HAYAKAWA Koichi (copyright holder).
 1.14 03-Jul-2008  drochner On cardbus configuration reads, check for a master abort in the cbb
and return all-ones explicitely.
Since pccbb.c rev. 1.151 the cbb is set to translate cardbus master
aborts which makes that the PCI configuration read on the primary bus
returns random junk. This can cause the probing code to get confused.
The issue was reported by KIYOHARA Takashi and Jonathan A. Kollasch,
the patch was tested by KIYOHARA Takashi.
 1.13 16-Nov-2007  dyoung branches: 1.13.14; 1.13.18; 1.13.20; 1.13.22;
Improve Cardbus performance, error handling, and error reporting.

Let the TI1420 PCI-Cardbus bridge do burst reads from the primary
(PCI) bus. This ought to improve Tx performance on Cardbus NICs.
This optimization may apply to other TI bridges, but I only have
a datasheet for the TI1420. :-/

Activate PCI Parity Error and System Error reporting on PCI-Cardbus
bridges.

To avoid data destruction, set the Master Abort mode to 1. Stops
the bridge from silently discarding writes from the secondary bus
to the primary bus (Cardbus writes to PCI). Also, stops the bridge
from fulfilling a read by a bus master on the secondary bus that
failed on the primary bus with 0xffffffff (Cardbus reads from PCI).
Now the bus will indicate an error condition (SERR) instead of
silently destroying/corrupting data.

Forward system error indications from the secondary to the primary
bus. Detect parity errors on the secondary.

Set a Cardbus card's Latency Timer to something reasonable, according
to the Cardbus card's Minimum Grant and the bandwidth available on
the PCI bus. Restore the Latency Timer when re-enabling a card
(e.g., after power reactivation).
 1.12 11-Aug-2007  dyoung branches: 1.12.2; 1.12.6; 1.12.8;
Make pccbb(4) use more PCI configuration register definitions,
especially the Bridge Control Register definition, instead of
rolling its own.

As we read/modify/write configuration registers, use a variable
that is named for the register we're r/m/w'ing, instead of using
the variable 'reg' over and over. This helps both a human reader
verify that we're not reading register X, modifying it, and writing
back to register Y (oops); the compiler can help a little by warning
that a variable is used before it is initialized.
 1.11 17-Jun-2006  jmcneill branches: 1.11.14; 1.11.24; 1.11.28;
For Ricoh 5c47x class controllers, restore the "misc control" PCI config
register on resume.
 1.10 25-Apr-2006  dyoung branches: 1.10.2; 1.10.4;
Fix a typo in register definitions: looks like somebody copied the
CB_SOCKET_STAT_3VSOCK definition to CB_SOCKET_STAT_XVSOCK and
CB_SOCKET_STAT_YVSOCK definitions without updating the numbers.

It doesn't look like CB_SOCKET_STAT_XVSOCK and CB_SOCKET_STAT_YVSOCK
are used anywhere, so this will not make any functional difference.
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10; 1.9.12;
merge ktrace-lwp.
 1.8 10-Dec-2003  briggs branches: 1.8.16;
Power up the card without OE enabled to avoid letting SanDisks enter
True IDE mode. Hinted at by Charles Hannum a while back. This lets
my PCI-Cardbus adapter read SanDisk CF cards much more reliably.

Also bring in a few defines from FreeBSD for some more TI registers and such.
 1.7 30-Aug-2001  haya branches: 1.7.20;
Add some register definitions for TI PCI12XX and Toshiba ToPIC.
Add ToPIC97 and ToPIC100 chip initialisation routine.
Add more TI PCI12XX chip initialisation.
 1.6 08-Dec-2000  mycroft branches: 1.6.2; 1.6.4;
Turn off the damned TI `VCC protection' bit.
 1.5 07-Jun-2000  haya Add CB_BCR_RESET_ENABLE in bridge control resister's bit definition.
 1.4 13-Jan-2000  joda branches: 1.4.2;
add %b strings for sockevent and sockstate registers
 1.3 01-Nov-1999  haya branches: 1.3.4;
Maintainance the name of Ricoh PCI-CardBus bridges.
 1.2 15-Oct-1999  haya branches: 1.2.2; 1.2.4;
add NetBSD ID tag.
 1.1 15-Oct-1999  haya This is the first check-in of CardBus driver. CardBus driver contains
CardBus bus stub, YENTA PCI-CardBus bridge (cbb), 3Com 3C575TX driver
(ex) and Intel fxp driver.

TODO:
o Conform to the KNF more strictly.
o Be unified with pcmcia code as much as possible.
o Add more drivers for CardBus card, such as APA-1480 or USB card.

The affected files are listed below.

sys/arch/i386/conf/files.i386
sys/arch/macppc/conf/files.macppc
sys/conf/files
sys/dev/ic/elinkxl.c
sys/dev/ic/elinkxlvar.h
sys/dev/ic/i82365.c
sys/dev/ic/i82365var.h
sys/dev/isa/i82365_isasubr.c
sys/dev/pci/files.pci
sys/dev/pcmcia/pcmcia.c
sys/dev/pcmcia/pcmciachip.h

The added files are listed below.

sys/arch/i386/conf/CARDBUS
sys/arch/i386/include/rbus_machdep.h
sys/arch/i386/i386/rbus_machdep.c
sys/arch/macppc/include/rbus_machdep.h
sys/arch/macppc/macppc/rbus_machdep.c
sys/dev/cardbus/if_ex_cardbus.c
sys/dev/cardbus/Makefile.cardbusdevs
sys/dev/cardbus/cardbus.c
sys/dev/cardbus/cardbus_map.c
sys/dev/cardbus/cardbusdevs
sys/dev/cardbus/cardbusdevs.h
sys/dev/cardbus/cardbusdevs_data.h
sys/dev/cardbus/cardbusvar.h
sys/dev/cardbus/cardslot.c
sys/dev/cardbus/cardslotvar.h
sys/dev/cardbus/devlist2h.awk
sys/dev/cardbus/files.cardbus
sys/dev/cardbus/if_fxp_cardbus.c
sys/dev/cardbus/pccardcis.h
sys/dev/cardbus/rbus.c
sys/dev/cardbus/rbus.h
sys/dev/pci/pccbb.c
sys/dev/pci/pccbbreg.h
sys/dev/pci/pccbbvar.h
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.6.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.6.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.7.20.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.20.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.20.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.3 07-Dec-2007  yamt sync with head
 1.8.16.2 03-Sep-2007  yamt sync with head.
 1.8.16.1 21-Jun-2006  yamt sync with head.
 1.9.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.10.1 11-May-2006  elad sync with head
 1.9.8.2 26-Jun-2006  yamt sync with head.
 1.9.8.1 24-May-2006  yamt sync with head.
 1.9.6.1 01-Jun-2006  kardel Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.10.2.1 19-Jun-2006  chap Sync with head.
 1.11.28.2 21-Nov-2007  joerg Sync with HEAD.
 1.11.28.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.11.24.1 15-Aug-2007  skrll Sync with HEAD.
 1.11.14.1 20-Aug-2007  ad Sync with HEAD.
 1.12.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.12.6.1 18-Nov-2007  bouyer Sync with HEAD
 1.12.2.1 09-Jan-2008  matt sync with HEAD
 1.13.22.1 03-Jul-2008  simonb Sync with head.
 1.13.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.18.2 11-Mar-2010  yamt sync with head
 1.13.18.1 04-May-2009  yamt sync with head.
 1.13.14.1 28-Sep-2008  mjf Sync with HEAD.
 1.15.70.1 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #671):

sys/dev/pci/if_bce.c: revision 1.53
sys/dev/pci/pccbbreg.h: revision 1.16
sys/dev/ic/rt2860.c: revision 1.34
sys/dev/pci/if_alc.c: revision 1.45
sys/dev/pci/if_mcx.c: revision 1.5
sys/dev/pci/if_pcn.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.37
sys/dev/pci/if_age.c: revision 1.65
sys/dev/ieee1394/fwohcireg.h: revision 1.20
sys/dev/ieee1394/fwohci.c: revision 1.143
sys/dev/ieee1394/firewire.c: revision 1.49
sys/dev/ic/am79900reg.h: revision 1.10

Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.15.64.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.41 20-Apr-2010  dyoung Change sc_pil_intr_enable from an int to a bool. No functional change
intended.
 1.40 15-Mar-2010  dyoung rbus is always #defined as 1, so unifdef -D rbus=1.
 1.39 15-Dec-2009  snj branches: 1.39.2; 1.39.4;
Move to 2-clause license. Approved by HAYAKAWA Koichi (copyright holder).
 1.38 23-Jul-2009  dyoung Use kpause(9), cv_timedwait(9), and cv_signal(9) instead of tsleep(9)
and wakeup(9).

Use mstohz(9).

XXX Protection against spurious wakeups is still needed, but this patch
XXX makes the code no worse than before in this regard.
 1.37 26-Jun-2008  drochner delete more dead code, remove use of pcic_handle except of some local
uses in pcmcia ressource management which is copied from ISA pcic,
so use our softc as handle exported to generic pcmcia code and kill
the ph_parent backpointer - this makes the code simpler and smaller
 1.36 25-Jun-2008  drochner Avoid the use of i82365var.h - we don't use any functions from there.
Extract some data structures for ressource management into our private
header instead. This allows to use a typed pointer instead of a
generic one which saves a lot of typecasts.
Also remove something marked as "dirty hack" which I admittedly don't
understand, but it doesn't look useful...
 1.35 25-Jun-2008  drochner split device/softc for pccbb, the cardbus half of cardslot and cardbus
(not yet pcmcia, there is a lot of md code involved)
 1.34 27-May-2008  dyoung branches: 1.34.2;
Distinguish O2 Micro bridges from generic bridges. PCI Parity
Error reporting seems to be broken on O2 Micro bridges, so do not
activate it. Should fix kern/38698, reported by Andreas Gustafsson.
 1.33 15-Jan-2008  christos branches: 1.33.6; 1.33.8; 1.33.10; 1.33.12;
Remove ricoh hack; FreeBSD does not seem to do it, and it was a remnant from
the branch. Things should work properly now.
 1.32 14-Jan-2008  dyoung Use device_t, device_private().
 1.31 16-Dec-2007  dyoung Improve pci, cbb, cardslot, cardbus, and pcmcia to support detachment
of this entire device tree:

pci0 at mainbus0
elansc0 at pci0
gpio0 at elansc0
cbb0 at pci0
cardslot0 at cbb0
cardbus0 at cardslot0
pcmcia0 at cardslot0
cbb1 at pci0
cardslot1 at cbb1
cardbus1 at cardslot1
rtw0 at cardbus1
pcmcia1 at cardslot1
sip0 at pci0
nsphyter0 at sip0
sip1 at pci0
nsphyter1 at sip1

Whew!
 1.30 09-Dec-2007  jmcneill branches: 1.30.2;
Merge jmcneill-pm branch.
 1.29 10-Aug-2007  dyoung branches: 1.29.2; 1.29.8; 1.29.10; 1.29.12;
Remove unused definitions CB_CHIPS_LAST and cb_chipset_name. Add
a type code for the Texas Instruments PCI1420 PCI-CardBus bridge,
CB_TI1420, which I will use in the near future.
 1.28 04-Feb-2007  dyoung branches: 1.28.6; 1.28.14; 1.28.18;
sc_pwrcycle is shared between the interrupt handler and Cardbus
event thread, so make it volatile.
 1.27 21-Dec-2006  yamt merge yamt-splraiseipl branch.

- finish implementing splraiseipl (and makeiplcookie).
http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
- complete workqueue(9) and fix its ipl problem, which is reported
to cause audio skipping.
- fix netbt (at least compilation problems) for some ports.
- fix PR/33218.
 1.26 17-Jun-2006  jmcneill branches: 1.26.4; 1.26.6; 1.26.8; 1.26.10;
For Ricoh 5c47x class controllers, restore the "misc control" PCI config
register on resume.
 1.25 11-Dec-2005  christos branches: 1.25.4; 1.25.8; 1.25.14; 1.25.16;
merge ktrace-lwp.
 1.24 04-Feb-2005  perry branches: 1.24.6;
de-__P
 1.23 27-Jan-2005  jmcneill Capture PCI configuration state on suspend and restore it on resume, from
Kentaro A. Kurahone.
 1.22 16-Jan-2005  mycroft branches: 1.22.2; 1.22.4;
Christos's crappy Libretto 100CT has an extremely long ramp for socket Vcc
(violating the PC Card spec), so... use the "power cycle" socket event to
determine when we've reached Vcc before proceeding, rather than using a fixed
amount of time. This has the double advantage that it makes the card attach
time even shorter on sane systems -- the minimum is now ~38ms on my i8500
rather than 222ms.

Probably a similar change should be made to pcic, but it was hard enough
figuring out whether it would work with pccbb. The chip specs suck.

For now, I'm leaving in a couple of additional printf()s in the hope that I
will get some interesting data from them.
 1.21 22-Jul-2004  mycroft If the bus number has not been initialized, do not attach a cardslot, and
output a diagnostic:
pccbbN: secondary bus number uninitialized; try PCIBIOS_BUS_FIXUP
 1.20 10-Dec-2003  briggs branches: 1.20.2;
Power up the card without OE enabled to avoid letting SanDisks enter
True IDE mode. Hinted at by Charles Hannum a while back. This lets
my PCI-Cardbus adapter read SanDisk CF cards much more reliably.

Also bring in a few defines from FreeBSD for some more TI registers and such.
 1.19 22-Mar-2003  nakayama branches: 1.19.2;
PCI-CardBus bridge support for sparc64:
- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.
 1.18 01-Oct-2002  haya Use LIST in sys/queue. Add some comments.
 1.17 02-Nov-2001  haya Add PCI power management control. If the power state of a bridge is
not D0 at device attaching or resuming, set the bridge D0 mode.
 1.16 06-Jul-2001  mcr branches: 1.16.2; 1.16.6;
split pccbb_intr_route() into seperate function.
 1.15 20-Feb-2001  minoura branches: 1.15.2;
Re-initialize more registers after resuming from suspend.
Some APM BIOSes do not restore them.
Reviewd by haya.
 1.14 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.13 08-Jun-2000  haya Change IPL when bridge's interrupt handler calls child device's
interrupt handler (This solution is not very good).
 1.12 23-Mar-2000  thorpej branches: 1.12.2;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.11 22-Mar-2000  haya 1. Do not apply 5 V on a CardBus card.
2. Do not avoid ISA hole when a device requires more than
256-byte io space.
3. Remove sending CardBus bridge's function number to
cardbus stack. This number is not needed for anyone.
 1.10 15-Mar-2000  haya Remove ancient code.
 1.9 12-Mar-2000  mycroft Revert the previous change.
 1.8 12-Mar-2000  thorpej Add missing sc_pil_intr_enable member to pccbb_softc.

XXX Double check this, please. The code appears to only use it as a
boolean, but...
 1.7 01-Mar-2000  thorpej Simplify the winlist code.
 1.6 05-Feb-2000  chopps indent this file
 1.5 26-Jan-2000  haya Pccbb manages interrupt handlers by itself for its child device.
 1.4 01-Nov-1999  haya branches: 1.4.4;
Maintainance the name of Ricoh PCI-CardBus bridges.
 1.3 19-Oct-1999  haya branches: 1.3.2;
Disable legacy io port before the bridge is probed as a pcic on isa.
Comments ware changed to comply the KNF.
Add PCCBB_PCMCIA_16BITONLY to support TI PCI103X series.
 1.2 15-Oct-1999  haya branches: 1.2.2;
add NetBSD ID tag.
 1.1 15-Oct-1999  haya This is the first check-in of CardBus driver. CardBus driver contains
CardBus bus stub, YENTA PCI-CardBus bridge (cbb), 3Com 3C575TX driver
(ex) and Intel fxp driver.

TODO:
o Conform to the KNF more strictly.
o Be unified with pcmcia code as much as possible.
o Add more drivers for CardBus card, such as APA-1480 or USB card.

The affected files are listed below.

sys/arch/i386/conf/files.i386
sys/arch/macppc/conf/files.macppc
sys/conf/files
sys/dev/ic/elinkxl.c
sys/dev/ic/elinkxlvar.h
sys/dev/ic/i82365.c
sys/dev/ic/i82365var.h
sys/dev/isa/i82365_isasubr.c
sys/dev/pci/files.pci
sys/dev/pcmcia/pcmcia.c
sys/dev/pcmcia/pcmciachip.h

The added files are listed below.

sys/arch/i386/conf/CARDBUS
sys/arch/i386/include/rbus_machdep.h
sys/arch/i386/i386/rbus_machdep.c
sys/arch/macppc/include/rbus_machdep.h
sys/arch/macppc/macppc/rbus_machdep.c
sys/dev/cardbus/if_ex_cardbus.c
sys/dev/cardbus/Makefile.cardbusdevs
sys/dev/cardbus/cardbus.c
sys/dev/cardbus/cardbus_map.c
sys/dev/cardbus/cardbusdevs
sys/dev/cardbus/cardbusdevs.h
sys/dev/cardbus/cardbusdevs_data.h
sys/dev/cardbus/cardbusvar.h
sys/dev/cardbus/cardslot.c
sys/dev/cardbus/cardslotvar.h
sys/dev/cardbus/devlist2h.awk
sys/dev/cardbus/files.cardbus
sys/dev/cardbus/if_fxp_cardbus.c
sys/dev/cardbus/pccardcis.h
sys/dev/cardbus/rbus.c
sys/dev/cardbus/rbus.h
sys/dev/pci/pccbb.c
sys/dev/pci/pccbbreg.h
sys/dev/pci/pccbbvar.h
 1.2.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 20-Oct-1999  thorpej Sync w/ trunk.
 1.3.2.2 15-Nov-1999  fvdl Sync with -current
 1.3.2.1 19-Oct-1999  fvdl file pccbbvar.h was added on branch fvdl-softdep on 1999-11-15 00:41:06 +0000
 1.4.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.15.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.15.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.16.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.16.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.16.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.2.3 04-Feb-2005  skrll Sync with HEAD.
 1.19.2.2 17-Jan-2005  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.2.1 23-Jul-2004  he Pull up revision 1.21 (requested by mycroft in ticket #692):
If the bus number has not been initialized, do not attach
a cardslot, and instead output a diagnostic pointing the
administrator towards the PCIBIOS_BUS_FIXUP option.
 1.22.4.1 12-Feb-2005  yamt sync with head.
 1.22.2.2 29-Apr-2005  kent sync with -current
 1.22.2.1 16-Jan-2005  kent file pccbbvar.h was added on branch kent-audio2 on 2005-04-29 11:29:07 +0000
 1.24.6.5 21-Jan-2008  yamt sync with head
 1.24.6.4 03-Sep-2007  yamt sync with head.
 1.24.6.3 26-Feb-2007  yamt sync with head.
 1.24.6.2 30-Dec-2006  yamt sync with head.
 1.24.6.1 21-Jun-2006  yamt sync with head.
 1.25.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.25.14.1 19-Jun-2006  chap Sync with head.
 1.25.8.1 26-Jun-2006  yamt sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.10.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.26.8.1 30-Jul-2007  liamjfoy Pull up following revision(s) (requested by dyoung in ticket #739):
sys/dev/pci/pccbb.c: revision 1.140
sys/dev/pci/pccbb.c: revision 1.141
sys/dev/pci/pccbb.c: revision 1.142
sys/dev/pci/pccbb.c: revision 1.143
sys/dev/pci/pccbb.c: revision 1.144
sys/dev/pci/pccbbvar.h: revision 1.28
sys/dev/pci/pcireg.h: revision 1.53
sys/dev/pci/pccbb.c: revision 1.139
Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR.

Fix grammar in comment. From Patrick Welche.

Use the right subroutine name for the debug message.

Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().

Cosmetic: KNF indentation, curly braces, and argument declarations.

sc_pwrcycle is shared between the interrupt handler and Cardbus
event thread, so make it volatile.

Fix a bug in Cardbus power activation.

Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'. TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt. When pccbb_power() powered-up a
cardslot, it did wait for the interrupt. If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0: power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete. After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up. An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

/*
* Wait as long as 200ms for a power-cycle interrupt. If
* interrupts are enabled, but the socket has already
* changed to the desired status, keep waiting for the
* interrupt. "Consuming" the interrupt in this way keeps
* the interrupt from prematurely waking some subsequent
* pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

* XXX Not every bridge interrupts on the ->OFF transition.
* XXX That's ok, we will time-out after 200ms.
*
* XXX The power cycle event will never happen when attaching
* XXX a 16-bit card. That's ok, we will time-out after
* XXX 200ms.
*/

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
 1.26.6.1 02-Nov-2006  yamt use splraiseipl.
 1.26.4.2 09-Feb-2007  ad Sync with HEAD.
 1.26.4.1 12-Jan-2007  ad Sync with head.
 1.28.18.2 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.28.18.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.28.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.28.6.1 20-Aug-2007  ad Sync with HEAD.
 1.29.12.1 11-Dec-2007  yamt sync with head.
 1.29.10.1 26-Dec-2007  ad Sync with head.
 1.29.8.1 18-Feb-2008  mjf Sync with HEAD.
 1.29.2.2 23-Mar-2008  matt sync with HEAD
 1.29.2.1 09-Jan-2008  matt sync with HEAD
 1.30.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.30.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.33.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.10.4 11-Aug-2010  yamt sync with head.
 1.33.10.3 11-Mar-2010  yamt sync with head
 1.33.10.2 19-Aug-2009  yamt sync with head.
 1.33.10.1 04-May-2009  yamt sync with head.
 1.33.8.1 04-Jun-2008  yamt sync with head
 1.33.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.33.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.34.2.1 27-Jun-2008  simonb Sync with head.
 1.39.4.1 30-May-2010  rmind sync with head
 1.39.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.168 23-Jun-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).

This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.

Take 2: Make sure to handle NULL match function.
 1.167 20-May-2024  riastradh Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.
 1.166 20-May-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
 1.165 24-Aug-2022  riastradh branches: 1.165.4;
pmf(9): *_child_register never fails. Make it return void.

No kernel bump because this isn't documented or used in any modules,
only in dev/pci/pci.c and dev/cardbus/cardbus.c which are as far as I
know always statically linked into the kernel.

The next change, however, will require a revbump -- to make
pmf_device_register return void so we can prune vast swaths of dead
error branches.
 1.164 21-Jan-2022  thorpej Replace devhandle_invalidate(), which invalidates a devhandle, with
devhandle_invalid(), which returns an invalid devhandle.
 1.163 10-Oct-2021  msaitoh Use PCI-SIG official acronyms:

- RP stands for Root Port.
- RC stands for Root Complex.
- RCIEP stands for Root Complex Integrated End Point.
 1.162 15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.161 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.160 12-May-2021  thorpej branches: 1.160.4;
- Define a device call for PCI bus instances to fetch a direct child's
device handle given the device's device/function #s (extracted from
a pcitag_t). Use it to associate the handle with the child device
at config_found() time.
- Implement this device call for ACPI and OpenFirmware.
- Enable the OpenFirmware variant for evbarm FDT, macppc, ofppc, sparc64.
- Obsolete acpi_device_register(); it is no longer needed.
- Obsolete setting the OpenFirmware handle in PCI devices in the
sparc64 device_register(); it is no longer needed.
 1.159 24-Apr-2021  thorpej branches: 1.159.2; 1.159.4;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.158 29-Jan-2021  skrll branches: 1.158.2;
Trailing whitespace
 1.157 02-Feb-2020  jmcneill branches: 1.157.6;
pci_probe_device: make sure PCI_ID_REG returns valid data before touching
any other registers
 1.156 15-Oct-2019  jmcneill branches: 1.156.2;
PCIe downstream ports only have a single child device, so limit probing to
dev 0.
 1.155 14-Oct-2019  jmcneill The PCI Local Bus Specification says that we should probe devices by
reading PCI_ID_REG. pci_enumerate_bus was incorrectly reading PCI_BHLC_REG
first, which surprisingly has worked for the past 16 years. Unfortunately,
this undefined behavior does the wrong thing on Amazon's Annapurna Labs
PCIe host controller.
 1.154 15-Dec-2018  msaitoh branches: 1.154.4;
Clearing PCI_PMCSR_PME_STS(W1C) bit is required to stop asserting PME#.
This change would prevent unexpected rebooting from shutdown -p or
unexpected resuming from suspend.
 1.153 01-Dec-2018  msaitoh Save control registers in PCI-X, PCIe, MSI and MSI-X capability area when
suspend and restore them when resume. For PCIe cababilities register, it's
required to check the existence of each register to not to write the next area.

This chagnge fixes a stability of suspend/resume.
 1.152 05-Apr-2017  msaitoh branches: 1.152.6; 1.152.12; 1.152.14;
IF PCIe's Alternative Routing-ID Interpretation (ARI) is enabled in a bridge,
all area under the bus should be checked in pci_enumerate_bus() to enumerate
all existing devices.

The similar code also be required for "pcictl pciN list". (not yet)
 1.151 23-Jan-2016  macallan branches: 1.151.2; 1.151.4;
add another special case so SM50x's framebuffer gets mapped with prefetching /
write combining enabled.
This needs to be generalized somewhere...
 1.150 02-Nov-2015  knakahara Add verbose messages when the kernel disables MSI/MSI-X.
 1.149 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.148 24-Aug-2015  pooka add some _KERNEL_OPT as the finishing touch
 1.147 13-Aug-2015  msaitoh - Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
 1.146 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.145 05-Sep-2014  matt branches: 1.145.2;
Don't use class or typename as a variable name.
 1.144 15-Sep-2013  martin Comment out a currently unused variable, but leave it around for debug/
documentation purposes.
 1.143 20-Oct-2012  matt branches: 1.143.2;
Add a __PCI_DEV_FUNCORDER hook.
 1.142 29-Aug-2011  jmcneill branches: 1.142.2; 1.142.12;
have pci register itself as a module, and make PCI driver modules depend on it
 1.141 24-Aug-2011  dyoung Add to pci_bus_devorder() an argument that tells the number of slots
available in the devs array. Change the type of the devs array from
char to uint8_t. Treat the return value of pci_bus_devorder() as the
number of slots that it filled.

Don't use the __PCI_BUS_DEVORDER #definition to configure the kernel
but let the linker do it. Make pci_bus_devorder() available on all
architectures by adding a default implementation that will DTRT on
all architectures but hpcmips, the only architecture to #define
__PCI_BUS_DEVORDER. On hpcmips, adapt the implementation to the new
calling convention.

XXX I can compile an hpcmips GENERIC kernel, but I don't have a
XXX hpcmips box to test it on.
 1.140 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.139 10-May-2011  dyoung Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.138 05-Apr-2011  dyoung Lightly KNF. Changes to the generated assembly language appeared to
correspond to line numbers in KASSERT() statements.
 1.137 05-Apr-2011  macallan fix a typo
 1.136 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.135 02-Mar-2011  matt When probing the PCI bars, make sure to only probe BARS (PPBs and PCB has
fewer bars than type 0 devices).
 1.134 27-Feb-2011  jmcneill follow the lead of genfb_pci and call pci_mapreg_probe before pci_mapreg_info
 1.133 24-Feb-2011  macallan add a hack to allow mapping the video memory portions of a mach64's aperture
with BUS_SPACE_MAP_PREFETCHABLE
This probably needs to go in its own function to avoid more clutter when adding
more hacks.
tested on macppc
 1.132 10-Feb-2011  jmcneill pcimmap: if the requested page is marked prefetchable in a child device's
BAR, pass the BUS_SPACE_MAP_PREFETCHABLE flag down to bus_space_mmap
 1.131 01-Feb-2011  dyoung During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.130 13-Nov-2010  uebayasi branches: 1.130.2; 1.130.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.129 06-Jun-2010  pgoyette Update pciverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.128 24-May-2010  pgoyette Extract the vendor/product tables and related access routines into a
separate kernel module. Update pci bus attach routine to load the
module (if available) when we're about to start scanning the bus, and
unload the module after the scan is finished.

On architectures which support loading of modules by the boot loader,
the 'pciverbose' module can be loaded and executed without needing to
rebuild the kernel. On all architectures, using 'options PCIVERBOSE'
in the kernel configuration file will create a 'builtin' module which
is functionally equivalent to previous behavior.

XXX Although not nearly as large as the vendor and product tables,
XXX the PCI class and subclass tables might also be offloaded into
XXX the module at a future time.

XXX Cardbus (and possibly other) drivers should also be modified to
XXX load the module before scanning/attaching devices.
 1.127 24-Feb-2010  dyoung branches: 1.127.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.126 23-Feb-2010  dyoung Remove unused functions pci_disable_retry() and cardbus_disable_retry().
 1.125 08-Jan-2010  dyoung branches: 1.125.2;
Expand PMF_FN_* macros.
 1.124 19-Aug-2009  dyoung Since the intention in capturing a device's PCI Configuration Space
in pci_probe_device() is for pcidevdetached() to restore the device's
original PCI Configuration Space after it is detached, let's capture
a device's PCI configuration before attaching a driver to it instead
of after. Capturing the configuration after attaching is too late,
because a driver such as ath(4) may put a device to sleep promptly
after attaching it, and putting a PCI device to sleep often entails
changing PCI configuration from defaults.
 1.123 04-Jul-2009  cegger remove useless parenthesis
 1.122 02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.121 16-Dec-2008  christos branches: 1.121.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.120 16-Nov-2008  bouyer Do not depend on physmem for pci_dma64_available(). On some systems (e.g. Xen,
or any system with non-contigous physical memory), physmem may not represent
the hightest physical address available.
Discussed on tech-kern@ some weeks ago.
 1.119 19-Sep-2008  joerg branches: 1.119.2; 1.119.4;
Complain about devices with misaligned PCI capability pointers instead
of panicing. Christoph Schug reported that such a device is made by
Nvidia.
 1.118 12-Jun-2008  cegger branches: 1.118.2;
use device_lookup_private to get softc
 1.117 05-May-2008  dyoung branches: 1.117.2; 1.117.4;
Restore PCI devices to a state that is closer to the state that
NetBSD finds them in: save and restore power management state
(D0..D3) and PCI Configuration Registers 0x0 through 0x40 during
device attachment and detachment, respectively. Among other things,
this will fix sip(4) detachment and re-attachment.
 1.116 09-Apr-2008  dyoung branches: 1.116.2; 1.116.4;
Export some PCI autoconf routines for use by elansc(4), for example.
 1.115 23-Mar-2008  cube Split device_t and softc for pci(4).
 1.114 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.113 28-Feb-2008  drochner Extend the pmf suspend/resume hooks by a shutdown method, so drivers
can register a shutdown handler explicitely.
Install a pci bus shutdown handler which disables bus master accesses
for all childs, so the drivers don't need to care.
This will hopefully be sufficient to replace the shutdownhooks
(together with the powerhooks). (It has been suggested to use some
general event notification framework for shutdown handlers, but there
might be cases where shutdown handlers must be run in an order following
the device hierarchy, which wouldn't be easy with event handlers
not tied to drivers.)
approved by David Young
 1.112 23-Feb-2008  dyoung Simplify the switch-statement in pci_set_powerstate_int(), and fix
a couple of typos so that it will work as I think that it was
intended to: delay for 10000us or 200us on transitions to/from D3
or D2 state, respectively. Discussed this with jmcneill@.
 1.111 21-Feb-2008  drochner -fix the delay logics in "set powerstate" for the cases that D2 or D3
are switched to (was harmless because we don't do D2 yet and also
don't (hmm - shouldn't) access devices in D3 (which would only make
sense if we'd support D3hot)
-zero the io/mem/master enable bits before entering D3
(The special handling of PCI_CLASS_DISPLAY devices is questionable
here -- we can't care about the console if we are seriously follow
the spec, and upstream bridges aren't considered anyway.)
-add exact references to the PCI PM spec
 1.110 28-Jan-2008  jmcneill branches: 1.110.2; 1.110.6;
PCI Power Management 1.2 says that system software should wait 10ms after
transitioning a device to or from D3hot, 200us to or from D2, and no wait
for D1 transitions. Update pci_set_powerstate_int to match the spec,
rather than naively waiting 1ms after every state transition.
 1.109 03-Jan-2008  dyoung Disable pci_disable_retry() and cardbus_disable_retry(), with a
long comment on pci_disable_retry() (cross-referenced at
cardbus_disable_retry()) that explains why.
 1.108 16-Dec-2007  dyoung Improve pci, cbb, cardslot, cardbus, and pcmcia to support detachment
of this entire device tree:

pci0 at mainbus0
elansc0 at pci0
gpio0 at elansc0
cbb0 at pci0
cardslot0 at cbb0
cardbus0 at cardslot0
pcmcia0 at cardslot0
cbb1 at pci0
cardslot1 at cbb1
cardbus1 at cardslot1
rtw0 at cardbus1
pcmcia1 at cardslot1
sip0 at pci0
nsphyter0 at sip0
sip1 at pci0
nsphyter1 at sip1

Whew!
 1.107 09-Dec-2007  jmcneill branches: 1.107.2;
Merge jmcneill-pm branch.
 1.106 01-Dec-2007  ad branches: 1.106.2; 1.106.4;
Empty vessels make the most noise
 1.105 12-Nov-2007  joerg Merge pci_disable_retry function from jmcneill-pm as it is found in
various drivers.
 1.104 16-Oct-2007  joerg branches: 1.104.2; 1.104.4;
Merge 1.103.22.4 from jmcneill-pm:
Decode capabilities for PCI-PCI bridges as well.
 1.103 16-Nov-2006  christos branches: 1.103.8; 1.103.22; 1.103.24; 1.103.26;
__unused removal on arguments; approved by core.
 1.102 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.101 02-Oct-2006  jmcneill Print error on powerhook_establish failure, not success. PR# 34698.
 1.100 25-Sep-2006  jmcneill Create a PCI bus powerhook to handle setting PCI D# power state transitions
on suspend/standby/resume.
 1.99 17-Jun-2006  christos branches: 1.99.4; 1.99.6;
re-factor the pci powestate api. reviewed by gimpy
 1.98 29-Mar-2006  thorpej branches: 1.98.2; 1.98.4;
Replace device_locators() with device_locator(), and use it.
 1.97 11-Dec-2005  christos branches: 1.97.4; 1.97.6; 1.97.8; 1.97.10; 1.97.12;
merge ktrace-lwp.
 1.96 26-Aug-2005  drochner use XXXCF_NLOCS constants instead of magic numbers
 1.95 25-Aug-2005  drochner kill a number of autoconf submatch functions which follow the
standard scheme:
if (<configured> != <wildcard> && <configured> != <real>)
then fail
else
ask device match function

This is handled by config_stdsubmatch() now.
 1.94 25-Aug-2005  drochner replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
 1.93 28-Jun-2005  thorpej branches: 1.93.2;
Use ANSI function decls and static.
 1.92 27-Feb-2005  perry nuke trailing whitespace
 1.91 04-Feb-2005  perry de-__P
 1.90 26-Jan-2005  jmcneill Add support functions for capturing and restoring PCI configuration
registers for power management code.
 1.89 13-Sep-2004  drochner branches: 1.89.4; 1.89.6;
remove macros which just hide cfdata internals
(and are used at one place only)
 1.88 30-Aug-2004  drochner Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.87 17-Aug-2004  drochner make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)
 1.86 29-Jul-2004  drochner make the "generic" PCI bus enumeration code the standard case which
gets used if nothing else is defined in MD headers,
introduce a "PCI_MACHDEP_ENUMERATE_BUS" CPP definition which can
be used by MD headers (just 1 port atm) to plug in special code
 1.85 17-May-2004  kochi Fix typo (func8 -> func7)
 1.84 08-May-2004  christos GC pci_{g,s}et_powerstate into pci_powerstate(). Idea from mycroft and gimpy.
Nothing uses them yet.
 1.83 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.82 18-Aug-2003  itojun support new quirk bits on debug output
 1.81 15-Aug-2003  itojun - check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.80 15-Jun-2003  fvdl branches: 1.80.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.79 03-May-2003  thorpej Fix inverted logic in pci_vpd_write(). From Jachym Holecek, PR kern/21440.
 1.78 29-Apr-2003  thorpej Use aprint*().
 1.77 25-Mar-2003  thorpej Add PCI VPD access routines. From psi.cz!freza, PR kern/20889.
 1.76 19-Mar-2003  christos It is not appropriate for pcivar.h to include "locators.h"
The two files that need it, should include it themselves.
 1.75 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.74 23-Oct-2002  perry fix lint warnings about things being stringified under cpp -traditional
 1.73 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.72 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.71 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.70 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.69 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.68 05-Jul-2002  thorpej Return 0, not NULL, when we mean 0.
 1.67 20-Jun-2002  itojun minor KNF
 1.66 18-Jun-2002  tshiozak add support for the per-device power management capability.

int pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int newstate)
set power state of the device to newstate.
int pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
get current power state of the device.

In the future, these functions will be used for ACPI support.
 1.65 18-May-2002  sommerfeld branches: 1.65.2;
Add "pa_rawintrpin" containing unswizzled interrupt pin to pci_attach_args.
 1.64 18-May-2002  sommerfeld In pci_probe_device(), correct test for whether the device is behind a
pci-pci bridge (and thus needs its interrupts "swizzled").

Formerly, pci_probe_device() assumed pci busses other than bus zero
were bridged; however, much recent x86 hardware supports multiple
primary pci busses differently -- there is a system-wide bus numbering
scheme. Now, we instead look at the (newly introduced) sc_bridgetag
value in the parent bus to figure out if there's a ppb or equivalent
in the way.

This fixed at least one case where the i386 MP branch gets interrupt
mapping wrong.
 1.63 16-May-2002  thorpej branches: 1.63.2;
Make sure pa.pa_bus is initialized. (Thanks, uwe!)
 1.62 16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.61 15-May-2002  thorpej Let machine-dependent code specify how to enumerate the bus.
Currently, everyone uses pci_enumerate_bus_generic().
 1.60 15-May-2002  thorpej Put back __PCI_BUS_DEVORDER for now.
 1.59 15-May-2002  thorpej Split the code that enumerates the PCI bus and that actually probes
for a device into two functions:

* pci_probe_device() actually probes/attaches the device specified
by the provide pcitag_t.

* pci_enumerate_bus() enumerates the bus, and calls pci_probe_device()
for each device on the bus. A pci_enumerate_bus_generic() is provided
which implements the old method of doing this: If something found at
dev0/func0, determine number of functions and probe each one.

Machine-dependent code will be able to specify the bus enumeration
routine in the future.
 1.58 13-Nov-2001  lukem add RCSID
 1.57 17-Oct-2001  thorpej Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)
 1.56 13-Sep-2001  thorpej Add an ioctl interface to the PCI bus. Add ioctls to read/write
PCI configuration space registers, and to fetch bus info.
 1.55 10-Sep-2001  fvdl Add a pci_find_device function, to find a PCI device using a match
function on all (probed) PCI buses:

int pci_find_device(struct pci_attach_args *pa,
int (*match)(struct pci_attach_args *));

The pci_attach_args structure pointed to by pa is filled in if the
device is found, and 1 is returned. Otherwise 0 is returned.

This function is, unfortunately, needed by the i810 agp code. It's
also of use for LKMs.

Also frob pci_probe_bus to take 2 extra args when used by pci_find_device.
 1.54 11-Jul-2001  mrg branches: 1.54.2;
don't try to print pcitag_t values; these are opaque values that should not
be interpreted by MI code.
 1.53 22-May-2001  thorpej branches: 1.53.2;
If the cache line size in the BHLC register is not configured,
then clear the MRL/MRM/MWI command-ok flags when attaching a
device.
 1.52 04-May-2001  bouyer Add pci bus number to pci_attach_args, as suggested by Jason on tech-kern
(needed for pciide)
 1.51 02-Mar-2001  mrg branches: 1.51.2;
allow pci_bus_maxdevs() to be replaced with pci_bus_devorder() and
pci_dev_funcorder() that have the following signatures:

int pci_bus_devorder(pci_chipset_tag_t pc, int bus, char list[32]);
int pci_dev_funcorder(pci_chipset_tag_t pc, int bus, int device, char list[8]);

they control the order of PCI bus probe at the device and function level,
by filling in a value from 0 to 31 for pci_bus_devorder() or 0 to 7 for
pci_dev_funcorder, with a value of -1 to signify no more entries.


when device properties arrive, these will be replaced with some facility
based on properties (design/implementation unknown currently.)
 1.50 12-Feb-2001  mrg backout the parts of the previous change (7 months ago) that were *not* part
of the sys/vm removal, but some (fortunately disabled) work-in-progress.
 1.49 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.48 10-May-2000  kleink branches: 1.48.4;
Add a comment describing the previous change.
 1.47 08-May-2000  kleink Make pci_get_capability() work correctly on both header type 0 and type 2
devices; both have different Capability List Pointer registers.
 1.46 30-Mar-2000  augustss Remove register declarations.
 1.45 22-Mar-2000  cgd if the PCI_CONFIG_DUMP option is defined, set the patchable
pci_config_dump variable to 1. otherwise, it gets set to 0. If
that's set, when configuring PCI devices spew the very verbose
configuration space header dump that was previously "#if 0"'d.
If you use this option, or patch the variable to 1, it's strongly
encouraged that you have used the MSGBUFSIZE option to enlarge the
kernel message buffer.
 1.44 04-Nov-1999  thorpej Make sure devices are told they can use rd/line, rd/mult, and wr/inval.
 1.43 04-Nov-1999  thorpej Print out if the read {line,multiple} and write/invalidate commands are
okay to use.
 1.42 06-May-1999  thorpej branches: 1.42.2; 1.42.4; 1.42.8;
Back out previous. Thanks to cgd for pointing out another way to do this.
 1.41 06-May-1999  thorpej Add a `bus' member to the pci_attach_args. This is not normally used,
but some child drivers might need to know this information.
 1.40 07-Nov-1998  drochner branches: 1.40.6; 1.40.8;
add support for "extended capabilities" (new in PCI spec 2.2)
 1.39 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.38 09-Jun-1998  thorpej Remove the PCI-ISA bridge callback mechanism; it's no longer needed.
 1.37 31-May-1998  cgd use the new PCI 'quirks' mechanism to help determine the number
of functions on a given device. Also, clean up the #if 0'd
major-debugging-spew code so that it's all one piece, so that
it's a bit prettier, and so that it prints out quirk information.
 1.36 18-May-1998  cgd add an #if 0'd chunk which will pci_conf_print() every device (spews
lots of data, e.g. ~18k on a PCI system with few add-in devices; use
with MSGBUFSIZE=...). Useful to have here so that people who want as
much data about the PCI configuration in a machine can get it without
having to craft their own code. Also, clean up a few of the other
#if 0'd printfs.
 1.35 05-May-1998  mjacob more info (in heavy debugging cases) to print
 1.34 17-Apr-1998  drochner Keep all relevant state information in a "pci_softc" so that it is
accessible at runtime (for LKMs in particular).
Remove BROKEN_INDIRECT_CONFIG.
 1.33 28-Mar-1998  cgd check vendor against PCI_VENDOR_INVALID instead of 0xffff.
Suggested by Soren S. Jorvang.
 1.32 20-Mar-1998  cgd check only the Vendor ID (rather than both the Vendor ID and the Product
ID) when determining if the Vendor ID is invalid. The spec says that
Vendor ID of 0xffff is invalid, so, it doesn't _matter_ what the product
ID is in that case. Treat Vendor ID 0 as invalid because we always have.
 1.31 31-Jan-1998  thorpej branches: 1.31.2;
When a PCI bus is attached, print out which bus spaces were enabled
by the parent.
 1.30 12-Jan-1998  thorpej branches: 1.30.2;
Update for config changes.
 1.29 30-Aug-1997  mycroft branches: 1.29.2;
Pass down bus_dma_tag_t's as appropriate (per Jason's bus_dma code).
 1.28 30-Aug-1997  mycroft Remove pci_*_find() from here.
 1.27 10-Apr-1997  cgd pass memory- and i/o-enabled flags down via the PCI bus and device attach
arguments, so that a device can tell if its memory and I/O spaces are
enabled. The flags are cleared, depending on the contents of devices CSR
registers, in the machine-independent PCI bus code.
 1.26 05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.25 23-Nov-1996  cgd Provide a routine so that ISA/EISA bridges can set up a callback so
that their child busses can be attached after the PCI bus
autoconfiguration for their parent bus is done.

This works because:
(1) there can be at most one ISA/EISA bridge per PCI bus, and
(2) any ISA/EISA bridges must be attached to primary PCI
busses (i.e. bus zero).

That boils down to: there can only be one of these outstanding
at a time, it is cleared when configuring PCI bus 0 before any
subdevices have been found, and it is run after all subdevices
of PCI bus 0 have been found.

This (or something like it) is needed because there are some (legacy)
PCI devices which can show up as ISA/EISA devices as well (the prime
example of which are VGA controllers). If you attach ISA from a
PCI-ISA/EISA bridge, and the bridge is seen before the video board is,
the board can show up as an ISA device, and that can (bogusly)
complicate the PCI device's attach code, or make the PCI device not be
properly attached at all.

This could be done with machine-dependent code, but as more ports
add support for PCI (and PCI-ISA/EISA bridges) more will need it.
The i386 port could (perhaps should) be converted to use it as well.
 1.24 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.23 13-Oct-1996  christos backout kprintf changes
 1.22 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.21 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.20 26-Jul-1996  mycroft Add PCI_MAPREG_{IO,MEM}_SIZE(), and use them.
 1.19 03-May-1996  christos branches: 1.19.4;
remove unused variables
 1.18 27-Mar-1996  cgd modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.17 27-Mar-1996  cgd add definitions for the BIST/Header Type/Latency Timer/Cache Line Size
configuration space register, and use it to determine whether or not
a given PCI device uses multiple functions.
 1.16 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.15 14-Mar-1996  cgd These devices don't actually need softc's that are supersets of 'struct
device.' No point in adding that complexity + space if they're not needed,
so axe them.
 1.14 14-Mar-1996  cgd (1) provide #defines for cf_loc[] entries for devices that attach to
pcibus and pci.
(2) remove the #ifdef i386 from pci.c, and provide a machine-dependent
hook (pci_md_attach_hook()) to do any machine-dependent attachment
gunk, e.g. on the i386 printing out the configuration mode (if bus 0)
(3) don't pass max device number for a given bus in, use
PCI_MAX_DEVICE_NUMBER, which can be defined on a per-machine basis.
(defaults to 32. on i386, it's 32 if pci conf mode == 1, 16 if 2.)
 1.13 08-Mar-1996  cgd remember the bus_chipset_tag_t given by our parent, and pass it on to
children.
 1.12 04-Mar-1996  cgd the i386 port no longer attaches isa, eisa, and pci at root.
 1.11 02-Mar-1996  cgd fix uninitialized variable; it shouldn't have been a variable at all.
(when probing to see if a device is there, always probe function 0.)
 1.10 28-Feb-1996  cgd make PCI bus match/attach and sub-device attachment machine-independent.
 1.9 17-Jun-1995  cgd oops; forgot this in last commit
 1.8 23-May-1995  cgd split single-subdevice lookup & attachment into a subroutine
(pci_attach_subdev()). remove pciattach() function and the pcicd cfdriver
struct, the former because thre are a lot of attachment actions which really
are machine-dependent (perhaps even "most"), and the latter because now that
both pcimatch() and pciattach() are machine-dependent it's bad style to
declare them here and it gains nothing.
 1.7 27-Jan-1995  cgd include files from the correct places.
 1.6 04-Nov-1994  mycroft Make a wrapper match function to check the bus and device numbers, rather
than insisting that every driver do it.
 1.5 03-Nov-1994  mycroft Rename pciprobe() to pcimatch(), and move it to pci_machdep.c.
 1.4 03-Nov-1994  mycroft Always use direct configuration.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 10-Aug-1994  mycroft Update some comments.
 1.1 09-Aug-1994  mycroft branches: 1.1.2;
Add PCI autoconfiguration support.
 1.1.2.1 10-Aug-1994  mycroft update from trunk
 1.19.4.1 10-Dec-1996  mycroft From trunk:
Deal with devices that do not allow allow of the I/O address bits to be set.
 1.29.2.2 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.29.2.1 30-Aug-1997  thorpej file pci.c was added on branch marc-pcmcia on 1997-09-01 20:29:42 +0000
 1.30.2.2 12-Jan-1998  thorpej Update for config changes.
 1.30.2.1 12-Jan-1998  thorpej file pci.c was added on branch thorpej-bus-dma on 1998-01-12 09:40:12 +0000
 1.31.2.2 31-Jan-1998  thorpej When a PCI bus is attached, print out which bus spaces were enabled
by the parent.
 1.31.2.1 31-Jan-1998  thorpej file pci.c was added on branch bouyer-scsipi on 1998-01-31 00:37:40 +0000
 1.40.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.40.6.1 27-Jun-2000  he Pull up revision 1.45 (via patch, requested by cgd):
If the 'PCI_CONFIG_DUMP' option is defined, print a verbose dump
of all PCI devices' configuration space.
 1.42.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.42.4.1 15-Nov-1999  fvdl Sync with -current
 1.42.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.42.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.48.4.1 15-May-2001  he Pull up revision 1.52 (requested by bouyer):
Add a pa_bus member to pci_attach_args, so that the PCI bus number
can be used in pci device drivers.
 1.51.2.10 03-Jan-2003  thorpej Sync with HEAD.
 1.51.2.9 11-Nov-2002  nathanw Catch up to -current
 1.51.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.51.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.51.2.6 20-Jun-2002  nathanw Catch up to -current.
 1.51.2.5 14-Nov-2001  nathanw Catch up to -current.
 1.51.2.4 22-Oct-2001  nathanw Catch up to -current.
 1.51.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.51.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.51.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.53.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.53.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.53.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.53.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.53.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.53.2.1 03-Aug-2001  lukem update to -current
 1.54.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.63.2.3 15-Jul-2002  gehenna catch up with -current.
 1.63.2.2 30-May-2002  gehenna Catch up with -current.
 1.63.2.1 16-May-2002  gehenna file pci.c was added on branch gehenna-devsw on 2002-05-30 14:46:11 +0000
 1.65.2.1 15-Aug-2003  tron Pull up revision 1.81 (requested by itojun in ticket #1412):
- check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.80.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.80.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.80.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.80.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.80.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.80.2.3 03-Sep-2004  skrll Sync with HEAD
 1.80.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.80.2.1 03-Aug-2004  skrll Sync with HEAD
 1.89.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.89.6.1 12-Feb-2005  yamt sync with head.
 1.89.4.1 29-Apr-2005  kent sync with -current
 1.93.2.10 24-Mar-2008  yamt sync with head.
 1.93.2.9 17-Mar-2008  yamt sync with head.
 1.93.2.8 27-Feb-2008  yamt sync with head.
 1.93.2.7 04-Feb-2008  yamt sync with head.
 1.93.2.6 21-Jan-2008  yamt sync with head
 1.93.2.5 07-Dec-2007  yamt sync with head
 1.93.2.4 15-Nov-2007  yamt sync with head.
 1.93.2.3 27-Oct-2007  yamt sync with head.
 1.93.2.2 30-Dec-2006  yamt sync with head.
 1.93.2.1 21-Jun-2006  yamt sync with head.
 1.97.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.97.10.1 19-Apr-2006  elad sync with head.
 1.97.8.2 26-Jun-2006  yamt sync with head.
 1.97.8.1 01-Apr-2006  yamt sync with head.
 1.97.6.1 22-Apr-2006  simonb Sync with head.
 1.97.4.1 09-Sep-2006  rpaulo sync with head
 1.98.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.98.2.1 19-Jun-2006  chap Sync with head.
 1.99.6.2 10-Dec-2006  yamt sync with head.
 1.99.6.1 22-Oct-2006  yamt sync with head
 1.99.4.1 18-Nov-2006  ad Sync with head.
 1.103.26.1 18-Oct-2007  yamt sync with head.
 1.103.24.3 23-Mar-2008  matt sync with HEAD
 1.103.24.2 09-Jan-2008  matt sync with HEAD
 1.103.24.1 06-Nov-2007  matt sync with HEAD
 1.103.22.13 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.103.22.12 04-Dec-2007  jmcneill Don't neglect to install a power handler in the event of no spaces being
available.
 1.103.22.11 03-Dec-2007  joerg Sync with HEAD.
 1.103.22.10 01-Dec-2007  jmcneill It seems that a hack to force PCI bridges to enable i/o and mem space
snuck in with the previous commit. Revert that piece.
 1.103.22.9 01-Dec-2007  jmcneill Don't actually power off vga in the PCI pnp bus handler, as it may be the
console device and it's nice to be able to figure out why we have crashed
if we fail to sleep.
 1.103.22.8 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.103.22.7 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.103.22.6 11-Sep-2007  jmcneill Missing break after PNP_REQUEST_SET_STATE.
 1.103.22.5 23-Aug-2007  joerg Introduce pci_net_generic_power, which should be enough for most
network drivers and be a good foundation for C&P for the rest.

For iwi(4), don't reset the PCI retry register again, pci_conf_restore
should take care of that already.

For bge(4), add a NetBSD style if_stop.
 1.103.22.4 21-Aug-2007  joerg Decode capabilities for PCI-PCI bridges as well.
 1.103.22.3 06-Aug-2007  jmcneill Fix compilation with DIAGNOSTIC.
 1.103.22.2 05-Aug-2007  jmcneill In pci_conf_restore, don't bother updating a register if the current value
matches the new value.
 1.103.22.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.103.8.1 23-Oct-2007  ad Sync with head.
 1.104.4.4 18-Feb-2008  mjf Sync with HEAD.
 1.104.4.3 27-Dec-2007  mjf Sync with HEAD.
 1.104.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.104.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.104.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.106.4.1 11-Dec-2007  yamt sync with head.
 1.106.2.1 26-Dec-2007  ad Sync with head.
 1.107.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.107.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.110.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.110.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.110.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.110.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.110.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.110.2.1 24-Mar-2008  keiichi sync with head.
 1.116.4.6 11-Aug-2010  yamt sync with head.
 1.116.4.5 11-Mar-2010  yamt sync with head
 1.116.4.4 16-Sep-2009  yamt sync with head
 1.116.4.3 18-Jul-2009  yamt sync with head.
 1.116.4.2 04-May-2009  yamt sync with head.
 1.116.4.1 16-May-2008  yamt sync with head.
 1.116.2.2 17-Jun-2008  yamt sync with head.
 1.116.2.1 18-May-2008  yamt sync with head.
 1.117.4.1 18-Jun-2008  simonb Sync with head.
 1.117.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.117.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.118.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.118.2.1 19-Oct-2008  haad Sync with HEAD.
 1.119.4.2 16-Feb-2011  bouyer Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.119.4.1 20-Nov-2008  snj branches: 1.119.4.1.2; 1.119.4.1.4; 1.119.4.1.6;
Pull up following revision(s) (requested by bouyer in ticket #66):
sys/dev/pci/pci.c: revision 1.120
Do not depend on physmem for pci_dma64_available(). On some systems (e.g. Xen,
or any system with non-contigous physical memory), physmem may not represent
the hightest physical address available.
Discussed on tech-kern@ some weeks ago.
 1.119.4.1.6.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.119.4.1.4.1 24-Dec-2011  matt Add support for __PCI_DEV_FUNCORDER
 1.119.4.1.2.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by dyoung in ticket #1540):
sys/dev/pci/pci.c: revision 1.131
During shutdown, restore the each PCI device's bus-mastering enable to
the state that we found it in before attaching a driver to it.
 1.119.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.119.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.121.2.2 23-Jul-2009  jym Sync with HEAD.
 1.121.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.125.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.125.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.127.2.5 31-May-2011  rmind sync with head
 1.127.2.4 21-Apr-2011  rmind sync with head
 1.127.2.3 05-Mar-2011  rmind sync with head
 1.127.2.2 03-Jul-2010  rmind sync with head
 1.127.2.1 30-May-2010  rmind sync with head
 1.130.4.3 05-Mar-2011  bouyer Sync with HEAD
 1.130.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.130.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.130.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.142.12.4 03-Dec-2017  jdolecek update from HEAD
 1.142.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.142.12.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.142.12.1 12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.142.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.142.2.1 30-Oct-2012  yamt sync with head
 1.143.2.1 18-May-2014  rmind sync with head
 1.145.2.5 28-Aug-2017  skrll Sync with HEAD
 1.145.2.4 19-Mar-2016  skrll Sync with HEAD
 1.145.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.145.2.2 22-Sep-2015  skrll Sync with HEAD
 1.145.2.1 06-Jun-2015  skrll Sync with HEAD
 1.151.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.151.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.152.14.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.152.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.152.14.1 10-Jun-2019  christos Sync with HEAD
 1.152.12.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.152.6.2 31-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1178):

sys/dev/pci/pci.c: revision 1.154

Clearing PCI_PMCSR_PME_STS(W1C) bit is required to stop asserting PME#.

This change would prevent unexpected rebooting from shutdown -p or
unexpected resuming from suspend.
 1.152.6.1 07-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1128):

sys/dev/pci/pcivar.h: revision 1.113
sys/dev/pci/pci.c: revision 1.153

Save control registers in PCI-X, PCIe, MSI and MSI-X capability area when
suspend and restore them when resume. For PCIe capabilities register, it's
required to check the existence of each register to not to write the next area.

This change fixes a stability of suspend/resume.
 1.154.4.3 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1384:

sys/dev/pci/pcireg.h 1.152-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.222, 1.227-1.232 via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158, 1.163
sys/dev/pci/ppb.c 1.74

- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.154.4.2 06-Nov-2019  martin Pull up following revision(s) (requested by mrg in ticket #401):

sys/dev/pci/pci.c: revision 1.156

PCIe downstream ports only have a single child device, so limit probing to
dev 0.
 1.154.4.1 15-Oct-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #331):

sys/dev/pci/pci.c: revision 1.155

The PCI Local Bus Specification says that we should probe devices by
reading PCI_ID_REG. pci_enumerate_bus was incorrectly reading PCI_BHLC_REG
first, which surprisingly has worked for the past 16 years. Unfortunately,
this undefined behavior does the wrong thing on Amazon's Annapurna Labs
PCIe host controller.
 1.156.2.1 29-Feb-2020  ad Sync with head.
 1.157.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.158.2.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.158.2.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.159.4.1 31-May-2021  cjep sync with head
 1.159.2.1 13-May-2021  thorpej Sync with HEAD.
 1.160.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.165.4.1 04-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #928):

sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.25
sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c: revision 1.4
sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h: revision 1.6
sys/external/bsd/drm2/dist/drm/i915/i915_drv.h: revision 1.49
sys/external/bsd/drm2/include/linux/mxm-wmi.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c: revision 1.13
sys/external/bsd/common/include/linux/bitops.h: revision 1.17
sys/external/bsd/drm2/nouveau/files.nouveau: revision 1.40
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.30
sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.12
sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_sorgm200.c: revision 1.3
sys/external/bsd/common/include/linux/printk.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_gk20a.c: revision 1.10
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c: revision 1.4
sys/external/bsd/drm2/include/linux/acpi.h: revision 1.11
sys/external/bsd/drm2/drm/drm_cdevsw.c: revision 1.31
sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h: revision 1.5
sys/external/bsd/drm2/include/acpi/video.h: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h: revision 1.4
sys/arch/sparc64/include/pci_machdep.h: revision 1.31
sys/arch/sparc64/dev/pci_machdep.c: revision 1.83
sys/external/bsd/drm2/include/linux/kref.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c: revision 1.12
sys/external/bsd/drm2/linux/linux_dma_buf.c: revision 1.17
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c: revision 1.4
sys/external/bsd/drm2/drm/drm_module.c: revision 1.32
sys/external/bsd/drm2/dist/drm/i915/i915_gem.h: revision 1.8
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c: revision 1.7
sys/external/bsd/drm2/include/linux/smp.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.20
sys/arch/x86/x86/bus_dma.c: revision 1.91
sys/external/bsd/drm2/radeon/files.radeon: revision 1.40
sys/external/bsd/drm2/include/acpi/acpi_bus.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.21
sys/external/bsd/common/include/asm/barrier.h: revision 1.20
sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h: revision 1.2
sys/external/bsd/common/include/asm/barrier.h: revision 1.21
sys/modules/drmkms/drmkms_pci.h: revision 1.1
sys/external/bsd/drm2/dist/drm/drm_dp_helper.c: revision 1.17
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.23
sys/external/bsd/drm2/linux/linux_xa.c: revision 1.4
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.23
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.25
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.26
sys/dev/pci/pcivar.h: revision 1.120
sys/arch/xen/include/pci_machdep.h: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.26
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.27
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.27
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.28
sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c: revision 1.8
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.28
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.29
sys/external/bsd/drm2/include/linux/pci.h: revision 1.57
sys/external/bsd/drm2/include/linux/pci.h: revision 1.58
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c: revision 1.6
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c: revision 1.3
sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c: revision 1.3
share/man/man9/bus_dma.9: revision 1.69
sys/external/bsd/drm2/drm/drm_gem_cma_helper.c: revision 1.15
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon.h: revision 1.12
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c: revision 1.7
sys/dev/acpi/acpi_mcfg.c: revision 1.29
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c: revision 1.7
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.13
sys/modules/amdgpu/Makefile: revision 1.9
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.14
sys/external/bsd/common/linux/linux_tasklet.c: revision 1.12
sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h: revision 1.10
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.23
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h: revision 1.9
sys/external/bsd/drm2/include/linux/interval_tree.h: revision 1.14
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.26
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c: revision 1.5
sys/dev/pci/pci.c: revision 1.168
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.27
sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c: revision 1.9
sys/external/bsd/drm2/pci/files.drmkms_pci: revision 1.18
sys/external/bsd/drm2/linux/linux_sync_file.c: revision 1.3
sys/external/bsd/drm2/amdgpu/files.amdgpu: revision 1.31
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c: revision 1.4
sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.24
sys/arch/xen/xen/xpci_xenbus.c: revision 1.29

drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html

linux asm/barrier.h: Fix !MULTIPROCESSOR build.

remove "nouveau" from a comment. noted by jmcneill.

drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
comment a function that has a clear overbounds read but it isn't used.
found by GCC 12.

nix the NetBSD specific GEM_BUG_ON().
avoids GCC 12 warnings, and matches upstream closer.
avoid uninitialised variable usage in drm_gem_cma_create_internal().
in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.
found by GCC 12.

avoid a GCC 12 warning.
there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical. as these indexes will always both
be 0, the only valid index, the condition is always false. GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.
amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
470 | stream->writeback_info[j] = stream->writeback_info[i];

convert a KASSERT() into an if () panic() sequence to appease GCC 12.
OK riastradh@.

drm: Fix conditionals around drmkms_pci and agp.
Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled. (Might not be very useful, but it'll
build. Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)

drmkms: Fix module build.
avoid an unlikely array bounds issue picked up by GCC 12.
nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.

drm: enable almost all PCIe functionality
linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.
this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed". for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus. add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)
tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].
this still does not quite work on nvidia cards. there are two problems
that remain:
- the call to set the link speed is skipped because the speed is set
to the default value of "-1". nvkm_pcie_set_link() will actually
determine the right value for this and for some cards, calling this
function if the current speed is -1 helps set the link speed. it
may be that on linux other paths we don't have enabled properly
would set this (there's one via debugfs, and a jetson specific one,
though perhaps setting either AC or DC speed values as boot options
(after hooking up these for netbsd) would currently work.
- worse, cards newer than kepler - geforce 900, 1000, and newer, are
all lacking the backing support to set pcie link speed. the GT 1030
card i have been testing with remains at pcie 1.0.

radeon: fix and enable ACPI methods for getting ROM BIOS
The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)
XXX amdgpu should get the same treatment.

drm: put_cpu() should enable preemption, not disable it again

drm(4): make pr_debug equivalent to aprint_debug
significantly reduces the default spam from amdgpu(4).

drm: Set CONFIG_ACPI in linux/acpi.h and make it build.

Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.
Should help with failures of the forms:
- unable to locate a BIOS ROM
- bios: unable to locate usable image
on various machines.

radeon_acpi.c: ifdef out unused function on NetBSD.
Should fix syzkaller build.

drm(4): Fix st_rdev in stat.
dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.
PR kern/58180

linux_sync_file: Fix missing init/fini steps.
Noted by rjs@.
PR kern/58210

ttm: Sync ttm_bo_uvm_fault_idle better with Linux.
PR xsrc/58133
ttm: Undo mistake in previous.

PR xsrc/58133
linux: Add a few more cases to pci_get_class.
Should fix crash on boot with amdgpu now that the ACPI business is
enabled.

i915: Fix dmabuf mmap object.

drm: Fix missing bounds checks in dma buf mmap.

drm_gem.c: Fix sense of assertion.
This is the opposite of WARN_ON.
Noted by rjs@.

drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.
linux_xa: Delete and replace collision in xa_store as intended.
Don't free the colliding node that's still in the tree.
Noted by rjs@.

i915_gem_mman.c: Apply mmap types via pmap flags.
This way, userland gets buffers mapped write-combining or uncached as
needed.
PR xsrc/58307

x86: Teach bus_dmamem_map about BUS_DMA_PREFETCHABLE.
PR port-amd64/58308

bus_dma(9): Document BUS_DMA_PREFETCHABLE.
Like BUS_DMA_NOCACHE. Doesn't absolve you of the need for
bus_dmamap_sync, but if you later pass the vaddr to bus_dmamap_load,
the DMA map might notice the mapping is write-combining and use this
to make bus_dmamap_sync cheaper.
PR kern/58309

nouveau_nvkm_subdev_instmem_gk20a.c: Use BUS_DMA_PREFETCHABLE.
Matches Linux's pgprot_writecombine.
Unclear where the appropriate bus_dmamap_sync happens, or is supposed
to happen -- not using it would be wrong, but asking for a
prefetchable mapping may paper over symptoms, at least!

ttm: Sync more with Linux.
Add the original copyright and attribution since this is now,
intentionally, a modified copy of the original and not just roughly
the same algorithm.

ttm: Respect PGO_ALLPAGES.
Not sure this is useful but it reduces XXX's and makes this match
udv_fault better so it's easier to understand.

ttm: Sync cacheability flag logic with Linux.

ttm: Add XXX about readahead fault failures.

pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.
New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.
This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).
This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
Take 2: Make sure to handle NULL match function.
linux_pci: Nix pci enumeration kludges.
Now that we can pass a cookie through, this stuff will be a little
less fragile.

i915: Omit needless i915_gem_object_pin/unpin_pages cycle in fault.
vm_fault_cpu and vm_fault_gtt, called by i915_gem_fault, already do
the pinning and unpinning internally, so there is no need for
i915_gem_fault to do it.
No functional change intended, except that the transient pin count
will be one lower than before during the fault routine (but it will
still be positive).

i915: Match Linux fault routine return code actions.
Omit needless EINTR interception -- this is now handled by
i915_error_to_vmf_fault.
Earlier revert was over a false alarm -- bisection shows the new
warnings arose from linux_pci.c 1.29 here:
https://mail-index.netbsd.org/source-changes/2024/06/23/msg151929.html

linux_pci: Fix shifto in pci_get_class.
It looks like Linux's pci_get_class also matches the interface part
of the PCI class register (but not the revision part), and I hadn't
noticed that in the previous shim structured differently.

With GCC12 kernel ALL/amd64 triggers "'sor' may be used uninitialized".
If "sublinks & 3" is zero GCC is right and sor[1] may be returned unitialized.
Fix by initializing "sor" to zero to return -1 instead of uninitialized value.
Ok: Taylor R Campbell <riastradh@>

amdgpu: Map BAR 2, not BAR 5, on pre-bonaire chips.
PR kern/58384

amdgpu: Map consecutive pages, not the same one over and over again.
PR kern/58385

linux/bitops: Fix overestimate for BITS_TO_LONGS(9)
Fortunately, this seems harmless except for allocating
excessive buffer memory.
Pointed out by nonaka@, OK riastradh@.
 1.1 15-Sep-2021  thorpej Device call interface definition files for the "device" and "pci"
subsystems.
 1.1 15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.4 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.3 11-Jan-2001  martin Move interrupt mapping before initialization of the card (which might
cause interrupts). This works around a problem on sparc64, where
interrupts without installed handler seem to cause heavy lossage (and
interrupts are already enabled at this stage of autoconfiguration).
 1.2 09-Jan-2001  martin Ifdef some routines only needed for ELSA Quickstep cards when compiling
without support for those.
 1.1 05-Jan-2001  martin branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jan-2001  martin branches: 1.1.1.1.2;
Initial import of ISDN4BSD release 0.96
 1.1.1.1.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.1.1.1.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.1.1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.1.1.2.1 05-Jan-2001  bouyer file pci_isic.c was added on branch thorpej_scsipi on 2001-01-05 17:36:12 +0000
 1.2 18-Feb-2001  martin Filename cleanup police (per discussion with Soren S. Jorvang):
remove all (legacy) "i4b_" prefixes outside of sys/netisdn.
Prefix all card specific driver support files with the basename
of the driver bus attachement file.

Renamed here:
pci_isic.h -> isic_pci.h
pci_isic.c -> isic_pci.c
i4b_avm_fritz_pci.c -> isic_pci_avm_fritz_pci.c
i4b_elsa_qs1p.c -> isic_pci_elsa_qs1p.c
 1.1 05-Jan-2001  martin branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jan-2001  martin branches: 1.1.1.1.2;
Initial import of ISDN4BSD release 0.96
 1.1.1.1.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.1.1.2.1 05-Jan-2001  bouyer file pci_isic.h was added on branch thorpej_scsipi on 2001-01-05 17:36:12 +0000
 1.44 29-Dec-2020  skrll KNF a comment
 1.43 29-Dec-2020  skrll More of the patch that adds support for Enhanced Allocations as seen in
the Cavium ThunderX based GIGABYTE MT30-GS2-00

From thorpej@. Thanks!

(botched the copying of this from a branch previously)
 1.42 29-Dec-2020  skrll Add support for Enhanced Allocations as seen in the Cavium ThunderX based
GIGABYTE MT30-GS2-00

From thorpej@. Thanks!
 1.41 28-Dec-2020  skrll Trailing whitespace
 1.40 05-May-2020  bouyer branches: 1.40.2;
disable I/O or mem decode before probing BAR size.
Bar size is probed writing 0xffffffff to the BAR and reading back; but while
doing this the decoding address is not guaranteed to be valid and could have
side effect.

Xen PVH enforces disabling decoding before writing to a BAR.

Proposed on tech-kern@, got positive comments
 1.39 02-Dec-2019  riastradh Leave it entirely up to the driver whether to map prefetchable.

We have only a few drivers that pass BUS_SPACE_MAP_PREFETCHABLE to
pci_mapreg_map -- dev/pci/if_hme_pci.c, dev/pci/igma.c,
dev/pci/radeonfb.c, dev/pci/wcfb.c -- and they all do it for ROM or
framebuffers.

Based on a subthread from macallan@ in the earlier discussion:

https://mail-index.NetBSD.org/tech-kern/2017/03/23/msg021685.html

The thrust is that:
- a driver not asking for prefetchable mappings shouldn't get it
- some devices are correctly used with prefetchable mappings, but for
some reason fail to set the prefetchable bit in the BAR
- nobody could identify any classes of device for which
(a) the driver asks for prefetchable mappings, but
(b) certain matching devices can't actually be used with
prefetchable mappings

This brings pci_mapreg_map in line with what the documentation says;
the documentation never advertised that the prefetchable bit in the
BAR could cause the bus_space mapping to be prefetchable.
 1.38 02-Dec-2019  riastradh Use BUS_SPACE_MAP_PREFETCHABLE only if BAR and driver agree on it.

- A driver that expects prefetchable memory and knows to issue the
needed bus_space_barrier calls can pass BUS_SPACE_MAP_PREFETCHABLE
to indicate a desire to map the memory prefetchable if the BAR
allows it.

(A driver that _really wants_ BUS_SPACE_MAP_PREFETCHABLE even if
the BAR claims _not_ to be prefetchable can use pci_mapreg_info and
bus_space_map explicitly -- this is not different from what we have
today.)

- For a driver that _does not_ expect prefetchable memory, the
appearance of the prefetchable bit in the BAR shouldn't cause it to
use BUS_SPACE_MAP_PREFETCHABLE, because the driver will not issue
the needed bus_space_barrier calls to get sensible results.

Note: `Prefetchable' here, sometimes called `write-combining', means
reads have no side effects, and writes are idempotent, so it is safe
to issue reads out of order and safe to combine writes.

Mappings with BUS_SPACE_MAP_PREFETCHABLE are often more weakly
ordered than normal memory -- e.g., on x86, in WC-type memory
regions, loads can be reordered with loads, stores can be reordered
with stores, which is not possible with any other type of memory
regions.

Discussed on tech-kern a while ago:

https://mail-index.NetBSD.org/tech-kern/2017/03/22/msg021678.html

This is option A, which received the most support. This should help
unconfuse drivers that do not expect prefetchable mappings, like
Yamaguchi-san tripped over recently:

https://mail-index.NetBSD.org/tech-kern/2019/12/02/msg025785.html
 1.37 01-Mar-2019  msaitoh No functional change:
- u_int* -> uint*
- KNF.
 1.36 19-May-2018  jakllsch branches: 1.36.2;
Re-enable PCI window decode enable in PCI Command Register upon
successful pci_mapreg_map().

Loosely related to PR #53286.
 1.35 19-May-2018  jakllsch Refine previous change to enable PCI window decoding in Command
Register upon mapping; conditionalize on a global variable, that is set
to true on x86 machines booting under EFI.

For now, initialize the global variable at compile time to false. This
is intended to limit potential problems for other NetBSD ports, should
this changeset be pulled up to netbsd-8.

Related to PR #53286.
 1.34 16-May-2018  jakllsch Enable the appropriate memory or I/O space decode in the PCI
Command/Status Register upon mapping a BAR.

This should fix PR #53286. It's also possible there are other similar
PRs that might be fixed by this.
 1.33 17-Mar-2017  msaitoh branches: 1.33.6; 1.33.12;
Modify some variables to make code more understandable.
 1.32 26-Dec-2014  msaitoh branches: 1.32.2; 1.32.4;
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fix ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.31 16-Oct-2014  riastradh branches: 1.31.2;
Generalize pci_find_rom and use it to locate x86 video ROM in drm2.

- Make pci_find_rom take the ROM `BAR' size as a parameter, instead
of using pci_find_mem with the ROM `BAR' to detect the size.

- Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2,
when nothing else reports that location.

- Adapt the one other caller in radeonfb, which already has the
maximum ROM size handy (romsz).

XXX pullup to netbsd-7
 1.30 20-Oct-2012  matt branches: 1.30.12;
Only probe the upper BAR of a mem64 BAR if bit 31 is readonly
 1.29 17-May-2011  dyoung branches: 1.29.4; 1.29.10; 1.29.14;
PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.28 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.27 27-Feb-2011  jmcneill revert previous; instead of commenting out the error message how about fixing
the code that causes it to be printed in the first place
 1.26 27-Feb-2011  jruoho Remove the following aprint_debug(9): "pci_mem_find: void region". I have
a system where this is printed about a hundred times. No functional change.
 1.25 11-May-2010  dyoung branches: 1.25.2;
Cosmetic: remove superfluous parentheses from return statements. Don't
test truth of pointers, or compare with 0, but compare with NULL,
instead.

The compiler generated the same assembly language before & after this
change.
 1.24 22-Jul-2008  bjs branches: 1.24.4; 1.24.12; 1.24.14; 1.24.16;
Add pci_mapreg_submap(): This function is pci_mapreg_map() with two
additional arguments, offset and maxsize. This new functionality
eases handling certain tasks within the direct rendering manager, though
I hope others will also find it useful.

pci_mapreg_map() is now merely a wrapper around pci_mapreg_submap();
the latter contains all of the code from the former.

ok christos@
 1.23 28-Apr-2008  martin branches: 1.23.2; 1.23.4; 1.23.6;
Remove clause 3 and 4 from TNF licenses
 1.22 01-Dec-2007  jmcneill branches: 1.22.14; 1.22.16; 1.22.18;
aprintify
 1.21 20-Nov-2007  joerg Merge from jmcneill-pm: XXX allow pci_find_mem to map a 64-bit BAR.
 1.20 10-Apr-2007  macallan branches: 1.20.8; 1.20.10; 1.20.14; 1.20.16;
turn the other 'void region' message into aprint_debug() as well
 1.19 10-Apr-2007  macallan demote 'pci_io_find: void region' to aprint_debug()
 1.18 16-Nov-2006  christos branches: 1.18.2; 1.18.4; 1.18.8; 1.18.10; 1.18.14;
__unused removal on arguments; approved by core.
 1.17 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16 01-Mar-2006  gdamore branches: 1.16.14; 1.16.16;
Add pci_find_rom() API as discussed on tech-kern.
 1.15 27-Feb-2006  gdamore Add PCI_MAPREG_TYPE_ROM and allow it to be used with pci_mapreg_map().
Fix to configure (but do not enable) BARs for expansion ROMs.
Reviewed by briggs@
 1.14 11-Dec-2005  christos branches: 1.14.2; 1.14.4; 1.14.6;
merge ktrace-lwp.
 1.13 27-Feb-2005  perry branches: 1.13.4;
nuke trailing whitespace
 1.12 30-May-2002  drochner branches: 1.12.6; 1.12.14; 1.12.16;
implement a check whether a BAR is present at all at a given configuration
space address and use it where the mappings of the VGA card are registered
before descenting too deep into "memory" type specific code
(pci_mem_find() gets noisy if it doesn't like the register)
 1.11 29-May-2002  bouyer When testing for a void region, use PCI_MAPREG_MEM_SIZE() for 32bit memaddr.
If the 32bit mask read is 0, wmask will be 0xffffffff00000000, and
PCI_MAPREG_MEM64_SIZE() won't make this 0.
 1.10 13-Nov-2001  lukem branches: 1.10.8; 1.10.10;
add RCSID
 1.9 29-Nov-2000  thorpej branches: 1.9.2; 1.9.4;
ANSI'ify.
 1.8 28-Jun-2000  thorpej Don't check for a BAR address past PCI_MAPREG_END; some devices
have BARs way out in left field.
 1.7 10-May-2000  thorpej branches: 1.7.4;
Add support for mapping 64-bit PCI memory space. If the region
is mapped in a way that is inaccessible by a 32-bit bus_addr_t, then
print a message to that effect and return failure.

Original patches by Bill Studenmund, with a few small changes by me.
 1.6 25-Jan-2000  drochner use BUS_SPACE_MAP_PREFETCHABLE instead BUS_SPACE_MAP_CACHEABLE where the
PCI BAR bit is referred to
 1.5 15-Aug-1998  mycroft branches: 1.5.12;
Assign my copyrights to TNF.
 1.4 06-Oct-1997  thorpej Back out last change. (Partially my fault, for not reviewing it close
enough.)
 1.3 03-Oct-1997  lonhyn pci_mapreg_info() has been changed to take arguments like pci_mapreg_map()
 1.2 23-Sep-1997  mycroft If the region size turns out to be 0, return an error. This is what will
happen if we try to use a mapping register that's not actually defined.
 1.1 30-Aug-1997  mycroft branches: 1.1.2;
* Rewrite pci_io_find() and pci_mem_find() using my original pci_map_io() and
pci_map_mem(), with appropriate changes for bus_space.
* Add extra arguments for use by pci_mapreg_*(), and make the functions
static.
* Rewrite pci_mapreg_info() and pci_mapreg_map() as wrappers around
pci_*_find(), using the documented interface.
 1.1.2.3 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.2 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 30-Aug-1997  thorpej file pci_map.c was added on branch marc-pcmcia on 1997-09-01 20:29:44 +0000
 1.5.12.2 08-Dec-2000  bouyer Sync with HEAD.
 1.5.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.4.1 28-Jun-2000  thorpej Pull up rev. 1.8:
Don't check for a BAR address past PCI_MAPREG_END; some devices
have BARs way out in left field.
 1.9.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.9.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.10.10.1 10-Oct-2003  tron Pull up revision 1.11 (requested by kleink in ticket #1513):
When testing for a void region, use PCI_MAPREG_MEM_SIZE() for 32bit memaddr.
If the 32bit mask read is 0, wmask will be 0xffffffff00000000, and
PCI_MAPREG_MEM64_SIZE() won't make this 0.
 1.10.8.2 20-Jun-2002  gehenna catch up with -current.
 1.10.8.1 30-May-2002  gehenna Catch up with -current.
 1.12.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.14.1 29-Apr-2005  kent sync with -current
 1.12.6.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.4.3 07-Dec-2007  yamt sync with head
 1.13.4.2 03-Sep-2007  yamt sync with head.
 1.13.4.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 01-Mar-2006  yamt sync with head.
 1.16.16.2 10-Dec-2006  yamt sync with head.
 1.16.16.1 22-Oct-2006  yamt sync with head
 1.16.14.1 18-Nov-2006  ad Sync with head.
 1.18.14.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.18.10.1 11-Jul-2007  mjf Sync with head.
 1.18.8.1 10-Apr-2007  ad Sync with head.
 1.18.4.1 15-Apr-2007  yamt sync with head.
 1.18.2.1 17-May-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1142):
sys/dev/pci/pci_map.c: revision 1.21
allow pci_find_mem to map a 64-bit BAR.
 1.20.16.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.14.1 21-Nov-2007  bouyer Sync with HEAD
 1.20.10.1 09-Jan-2008  matt sync with HEAD
 1.20.8.3 01-Dec-2007  jmcneill Sync with HEAD.
 1.20.8.2 20-Nov-2007  joerg Change the XXX to actually explain what it is doing.
 1.20.8.1 27-Aug-2007  jmcneill XXX allow pci_find_mem to map a 64-bit BAR, needs revisiting.
 1.22.18.3 11-Aug-2010  yamt sync with head.
 1.22.18.2 04-May-2009  yamt sync with head.
 1.22.18.1 16-May-2008  yamt sync with head.
 1.22.16.1 18-May-2008  yamt sync with head.
 1.22.14.2 28-Sep-2008  mjf Sync with HEAD.
 1.22.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.6.1 19-Oct-2008  haad Sync with HEAD.
 1.23.4.1 28-Jul-2008  simonb Sync with head.
 1.23.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.24.16.3 31-May-2011  rmind sync with head
 1.24.16.2 21-Apr-2011  rmind sync with head
 1.24.16.1 30-May-2010  rmind sync with head
 1.24.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.24.12.1 03-Jan-2012  matt Only probe the upper BAR of a mem64 if the bit31 of the lower BAR isn't
writable.
 1.24.4.1 23-Jan-2015  martin Pull up the following changes, requested by msaitoh in ticket #1942:

sys/arch/x86/pci/ichlpcib.c 1.40, 1.45 via patch
sys/dev/ic/i82801lpcreg.h 1.12
sys/dev/pci/pci_map.c 1.32 via patch

- Fix a bug that ichlpcib(4) maps I/O area incorrectly. It might also
fixes ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR
but not completely compatible with it. It's ok because the
registers' addresses are out of BAR0-BAR5(0x10-0x24) and are
located in the device-dependent header. The PMBASE and GPIO
registers define the base address and the type but not describe
the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Fix the calculation of the map size in pci_mapreg_submap().
- Use '\n' at the end of aprint_error_dev() format strings.
 1.25.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.14.2 03-Dec-2017  jdolecek update from HEAD
 1.29.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.10.1 16-Jan-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1229):
sys/arch/x86/pci/ichlpcib.c: revision 1.40, 1.45
sys/dev/pci/pcivar.h: revision 1.101
sys/dev/pci/pci_map.c: revision 1.32
sys/dev/ic/i82801lpcreg.h: revision 1.12
Use '\n' at the end of all aprint_error_dev() format strings.
--
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fixes ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.29.4.1 30-Oct-2012  yamt sync with head
 1.30.12.2 08-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #394):
sys/dev/pci/pcivar.h: revision 1.101
sys/dev/pci/pci_map.c: revision 1.32
sys/dev/ic/i82801lpcreg.h: revision 1.12
sys/arch/x86/pci/ichlpcib.c: revision 1.45
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fix ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.30.12.1 17-Oct-2014  martin Pull up following revision(s) (requested by riastradh in ticket #144):
sys/dev/pci/radeonfb.c: revision 1.85
sys/dev/pci/pcivar.h: revision 1.100
sys/dev/pci/pci_map.c: revision 1.31
sys/external/bsd/drm2/include/linux/pci.h: revision 1.9
Generalize pci_find_rom and use it to locate x86 video ROM in drm2.
- Make pci_find_rom take the ROM `BAR' size as a parameter, instead
of using pci_find_mem with the ROM `BAR' to detect the size.
- Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2,
when nothing else reports that location.
- Adapt the one other caller in radeonfb, which already has the
maximum ROM size handy (romsz).
XXX pullup to netbsd-7
 1.31.2.2 28-Aug-2017  skrll Sync with HEAD
 1.31.2.1 06-Apr-2015  skrll Sync with HEAD
 1.32.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.32.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.33.12.1 21-May-2018  pgoyette Sync with HEAD
 1.33.6.1 07-Jun-2018  martin Pull up following revision(s) (requested by jakllsch in ticket #832):

sys/dev/pci/pcivar.h: revision 1.112
sys/dev/pci/pci_map.c: revision 1.34,1.35
sys/arch/x86/x86/efi.c: revision 1.15

Enable the appropriate memory or I/O space decode in the PCI
Command/Status Register upon mapping a BAR.

This should fix PR #53286. It's also possible there are other similar
PRs that might be fixed by this.
-
Refine previous change to enable PCI window decoding in Command
Register upon mapping; conditionalize on a global variable, that is set
to true on x86 machines booting under EFI.

For now, initialize the global variable at compile time to false. This
is intended to limit potential problems for other NetBSD ports, should
this changeset be pulled up to netbsd-8.

Related to PR #53286.
 1.36.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.36.2.1 10-Jun-2019  christos Sync with HEAD
 1.40.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.12 17-Oct-2018  jmcneill PCI_QUIRK_HASEXTCNF is no longer required for AMD Seattle PCHB
 1.11 16-Oct-2018  jmcneill Set PCI_QUIRK_HASEXTCNF flag for AMD Seattle PCI host bridges
 1.10 28-Feb-2018  msaitoh branches: 1.10.2; 1.10.4;
- Add new PCI quirk PCI_QUIRK_HASEXTCNF and PCI_QUIRK_NOEXTCNF. Some devices'
extended configuration area may be broken or violate spec. If an extended
configuration space is strange but it really exist, use PCI_QUIRK_HASEXTCNF.
If an extended configuration space is plausible to exist but it really
doesn't exist, use PCI_QUIRK_NOEXTCNF.
- Add PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_1(0x6fa8) and
PCI_PRODUCT_INTEL_COREI76K_IMC_0(0x6f68) with PCI_QUIRK_HASEXTCNF. The
document clearly states they violate spec and it support the extended
configuration space.
 1.9 19-Aug-2009  pgoyette Use __arraycount() for readability
 1.8 06-Jan-2007  jmcneill branches: 1.8.44;
Sync with Xbox Host-PCI bridge name change.
 1.7 04-Jan-2007  jmcneill Add quirk for Xbox nForce, from Andrew Gillham.
 1.6 11-Dec-2005  christos branches: 1.6.20;
merge ktrace-lwp.
 1.5 28-Jun-2005  thorpej branches: 1.5.2;
Use ANSI function decls and static.
 1.4 10-Jul-2004  nathanw Remove SKIP_FUNCn quirks for SC1100 companion chip; the fix to SMM in
i386/identcpu.c renders it counterproductive.

(this was the only use and the reason for the invention of the
SKIP_FUNCn quirk; it should probably be removed entirely).
 1.3 15-Aug-2003  itojun - check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.2 13-Nov-2001  lukem branches: 1.2.10; 1.2.16;
add RCSID
 1.1 31-May-1998  cgd branches: 1.1.26; 1.1.28;
dd a PCI 'quirks' mechanism, meant to be used as the mechanism
of last resort when trying to communicate information about
bogus behaviour of PCI devices to the MI autoconfiguration code.
In general, bogus behaviour should be handled by drivers, but there
are some types of bogons which can't be addressed that way. The
only quirk currently defined is one which indicates that the device
is multi-function even though the device's header says otherwise.
(Mmm, Intel 82371FB PCI-to-ISA Bridge (PIIX); you'd think that at least
Intel would have gotten it right...)
 1.1.28.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.26.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.16.1 03-Aug-2004  skrll Sync with HEAD
 1.2.10.1 15-Aug-2003  tron Pull up revision 1.3 (requested by itojun in ticket #1412):
- check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.5.2.1 26-Feb-2007  yamt sync with head.
 1.6.20.1 12-Jan-2007  ad Sync with head.
 1.8.44.1 16-Sep-2009  yamt sync with head
 1.10.4.1 10-Jun-2019  christos Sync with HEAD
 1.10.2.1 20-Oct-2018  pgoyette Sync with head
 1.7 03-Mar-2025  riastradh pci_resource(9): Handle multiple bus ranges too.

Seen on orion o6.

Prompted by:

PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
 1.6 03-Mar-2025  riastradh pci_resource(9): Handle multiple ranges of the same type.

Rather than having the caller fill in an array indexed by range type
of a single start/end pair for each type, the caller will now do:

struct pci_resource_info info;

memset(&info, 0, sizeof(info));

pci_resource_add_range(&info, PCI_RANGE_MEM, mstart1, mend1);
pci_resource_add_range(&info, PCI_RANGE_MEM, mstart2, mend2);
pci_resource_add_range(&info, PCI_RANGE_MEM, mstart3, mend3);
pci_resource_add_range(&info, PCI_RANGE_PMEM, pstart1, pend1);
pci_resource_add_range(&info, PCI_RANGE_IO, iostart1, ioend1);
...

While here, fix a format string -- 0x% or %# is enough to say that
the output is hexadecimal; we don't need to belabour the point by
printing a `0x0x' prefix!

XXX While this handles multiple io/mem/prefetchable-mem ranges, it
doesn't yet handle multiple bus ranges, which we have seen in
practice, e.g. on orion o6. TBD.

ok jmcneill@

PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
 1.5 30-Jun-2024  jmcneill pci_resource: Make unexpected bus numbers in bridges non-fatal.

Firmware bugs happen. Log a warning and continue instead of panicing.
 1.4 12-Nov-2023  jmcneill branches: 1.4.2;
pci: Improve resource allocation for non-prefetchable BARs.

When allocating resources for PCI devices, use the following criteria:
- Prefetchable memory must be allocated from the prefetchable range
of the parent bridge.
- For 64-bit MMIO, try the prefetchable range first, and fallback to
the non-prefetchable range. The idea here is to preserve 32-bit resources
for 32-bit BARs.
- For 32-bit MMIO, try the non-prefetchable range first. If that fails,
make one last attempt at allocating from the prefetchable range, in the
event that it has resources below 4GB.
 1.3 15-Oct-2022  riastradh branches: 1.3.2;
pci_resource(9): Fix whitespace.
 1.2 15-Oct-2022  riastradh pci_resource(9): vmem_create and vmem_add never fail with VM_SLEEP.

Prune dead error branches.
 1.1 14-Oct-2022  jmcneill Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.3.2.2 03-Jul-2024  martin Pull up following revision(s) (requested by jmcneill in ticket #735):

sys/dev/pci/pci_resource.c: revision 1.5
sys/arch/arm/pci/pci_msi_machdep.c: revision 1.10
sys/arch/aarch64/include/vmparam.h: revision 1.21
sys/dev/acpi/acpi_resource.c: revision 1.43

pci_resource: Make unexpected bus numbers in bridges non-fatal.

Firmware bugs happen. Log a warning and continue instead of panicing.
acpi: Ignore producer/consumer bit for fixed memory resources.

The requirement to honour the producer/consumer bit in fixed memory
resource descriptors was dropped at some point in a revision to the ACPI
2.0 specification because too many firmware implementations got it wrong.

aarch64: Bump VM_PHYSSEG_MAX to match DRAM_BANKS / FDT_MEMORY_RANGES.

On aarch64 there is a single free list, so VM_PHYSSEG_MAX needs to be
the same as FDT_MEMORY_RANGES (which needs to be the same as DRAM_BANKS).

Future cleanup should be done to fold these into a single define.

arm: pci: Fix ITS ID lookup for MSIs.
pci_get_frameid expects a BDF requestor ID as input, not a Device ID.

Fixes MSI/MSI-X support on Ampere Altra systems.
 1.3.2.1 29-Nov-2023  martin Pull up following revision(s) (requested by jmcneill in ticket #483):

sys/dev/pci/pci_resource.c: revision 1.4

pci: Improve resource allocation for non-prefetchable BARs.

When allocating resources for PCI devices, use the following criteria:
- Prefetchable memory must be allocated from the prefetchable range
of the parent bridge.
- For 64-bit MMIO, try the prefetchable range first, and fallback to
the non-prefetchable range. The idea here is to preserve 32-bit resources
for 32-bit BARs.
- For 32-bit MMIO, try the non-prefetchable range first. If that fails,
make one last attempt at allocating from the prefetchable range, in the
event that it has resources below 4GB.
 1.4.2.2 02-Aug-2025  perseant Sync with HEAD
 1.4.2.1 01-Jul-2024  perseant Sync with HEAD.
 1.2 03-Mar-2025  riastradh pci_resource(9): Handle multiple ranges of the same type.

Rather than having the caller fill in an array indexed by range type
of a single start/end pair for each type, the caller will now do:

struct pci_resource_info info;

memset(&info, 0, sizeof(info));

pci_resource_add_range(&info, PCI_RANGE_MEM, mstart1, mend1);
pci_resource_add_range(&info, PCI_RANGE_MEM, mstart2, mend2);
pci_resource_add_range(&info, PCI_RANGE_MEM, mstart3, mend3);
pci_resource_add_range(&info, PCI_RANGE_PMEM, pstart1, pend1);
pci_resource_add_range(&info, PCI_RANGE_IO, iostart1, ioend1);
...

While here, fix a format string -- 0x% or %# is enough to say that
the output is hexadecimal; we don't need to belabour the point by
printing a `0x0x' prefix!

XXX While this handles multiple io/mem/prefetchable-mem ranges, it
doesn't yet handle multiple bus ranges, which we have seen in
practice, e.g. on orion o6. TBD.

ok jmcneill@

PR port-amd64/59118: Thinkpad T495s - iwm PCI BAR is zero
 1.1 14-Oct-2022  jmcneill branches: 1.1.8;
Add a PCI resource manager and use it on Arm ACPI platforms.

The Arm ACPI code relied on PCI_NETBSD_CONFIGURE to configure devices that
were not enabled by system firmware. This is not safe to do unless the
firmware explicitly permits it using a device specific method defined in
the PCI firmware spec.

Introduce a new PCI resource manager that discovers what has already been
configured by firmware and allocates from the remaining space. This will
ensure that devices setup by firmware are untouched and only will program
BARs of devices that are not enabled at boot time.

The current implementation assumes that the parent PCI-PCI bridge's
are already configured. A worthwhile improvement in the future would be
to support programming windows for bridges that are not fully configured.
 1.1.8.1 02-Aug-2025  perseant Sync with HEAD
 1.8 24-Jun-2018  jdolecek provide pci_intr_establish_xname() on x86 independantly from MSI,
so it's available on XEN too; change also the stub to use weak
symbol instead #ifdef
 1.7 01-Jun-2017  chs branches: 1.7.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.6 25-Nov-2016  knakahara provide all PCI MSI/MSI-X manipulation stub functions.

"#ifdef __HAVE_PCI_MSI_MSIX" workaround such as nvme_pci(4) is not required
any more.
http://mail-index.netbsd.org/source-changes/2016/09/17/msg077799.html
 1.5 11-Jul-2016  knakahara branches: 1.5.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.4 22-Oct-2015  knakahara add pci_intr_alloc related stubs to reduce ifdef from device drivers.
 1.3 24-Aug-2015  pooka add some _KERNEL_OPT as the finishing touch
 1.2 17-Aug-2015  knakahara Add kernel code to support intrctl(8).
 1.1 24-Aug-2011  dyoung branches: 1.1.12; 1.1.30;
Add to pci_bus_devorder() an argument that tells the number of slots
available in the devs array. Change the type of the devs array from
char to uint8_t. Treat the return value of pci_bus_devorder() as the
number of slots that it filled.

Don't use the __PCI_BUS_DEVORDER #definition to configure the kernel
but let the linker do it. Make pci_bus_devorder() available on all
architectures by adding a default implementation that will DTRT on
all architectures but hpcmips, the only architecture to #define
__PCI_BUS_DEVORDER. On hpcmips, adapt the implementation to the new
calling convention.

XXX I can compile an hpcmips GENERIC kernel, but I don't have a
XXX hpcmips box to test it on.
 1.1.30.5 28-Aug-2017  skrll Sync with HEAD
 1.1.30.4 05-Dec-2016  skrll Sync with HEAD
 1.1.30.3 05-Oct-2016  skrll Sync with HEAD
 1.1.30.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.30.1 22-Sep-2015  skrll Sync with HEAD
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.8.1 25-Jun-2018  pgoyette Sync with HEAD
 1.244 19-Apr-2024  andvar s/Resorce/Resource/ in comment and log message.
 1.243 10-Aug-2023  andvar fix typos in comments.
 1.242 01-Feb-2022  msaitoh Fix typo. Found by rillig. s/vendor specific/vendor-specific/
 1.241 31-Jan-2022  msaitoh Decode SCSI programming interface. Whitespace fix.
 1.240 31-Jan-2022  msaitoh Add three new extended capabilities:

- Physical Layer 32.0 GT/s
- Alternate Protocol
- System Firmware Intermediary
 1.239 08-Jan-2022  tnn place additional parens around multiline string constant to appease clang
 1.238 07-Jan-2022  msaitoh Two fixes:

- Fix previous again. The missing comma is intended to split the long line.
- Add missing right parenthesis.
 1.237 07-Jan-2022  msaitoh Add missing comma. Found by tnn@.
 1.236 01-Jan-2022  msaitoh Print Physical Layer 16.0 GT/s and Lane Margining at the Receiver extended cap.

- Decode Physical Layer 16.0 GT/s extended capability.
- Decode Lane Margining at the Receiver extended capability.
- Rename pcie_link_compliance_preset_deemphasis to
pcie_link_preset_preshoot_deemphasis because the table is referenced from
multiple places.
- Print "reserved" instead of "unknown" when printing equalization preset.
One of them is known to be the default value.
- Rename PCI_EXTCAP_PYSLAY_16GT to PCI_EXTCAP_PL16G.
 1.235 28-Dec-2021  msaitoh %hhx -> %x
 1.234 28-Dec-2021  msaitoh Decode link control2's Compliance Preset/De-emphasis more. Fix typo.
 1.233 03-Dec-2021  andvar fix various typos in comments, log messages and documentation.
 1.232 10-Oct-2021  msaitoh Use PCI-SIG official acronyms:

- RP stands for Root Port.
- RC stands for Root Complex.
- RCIEP stands for Root Complex Integrated End Point.
 1.231 10-Oct-2021  msaitoh Add Some PCI config information:

- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
 1.230 11-Sep-2021  mrg add 32.0GT/s to the list of pcie speeds (PCIe 5.x.)
 1.229 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.228 17-Aug-2021  andvar s/Windw/Window/ in log message.
 1.227 12-Jul-2021  msaitoh s/Precision Time Management/Precision Time Measurement/
 1.226 29-Jun-2021  pgoyette Rework the xxxVERBOSE option to share the common module-hook-based
verbose mechanism with MIIVERBOSE. This reduces some duplicated code
and allows us to once again permit auto-unload of MIIVERBOSE.

Change details:
* Update dev/devlist2h.awk to accomodate miidevs, including generation
of MII_STR_oui_model definitions and use of oui and model rather than
vendor and product. This also changes the compressed data in the
xxxdevs_data.h files to uint32_t (since mii oui's are up to 6 hex
digits long)
* Update a couple of phy drivers to use new calls to get verbose data
* Regen all of the xxxdevs{,_data}.h files (separate commit, coming
very soon)
* Update mii/mii_verbose.[ch] and mii/mii_physubr.c to use the various
DEV_VERBOSE_xxx macros
* Update the pci, usb, and hdaudio code as needed, to #include the
xxxdevs.h files (in order to get the proper printf format strings)
* Since dev/dev_verbose.c now uses non-literal printf format strings,
(to deal with the vendor/product vs oui/model issue), we need to
make sure it gets compiled with -Wno-error=format-nonliteral, even
in userland's libpci and librumpdev!
* Bump kernel version for the change in module interfaces

Welcome to 9.99.86!

XXX It might be useful in the future to extend the MII_STR_oui_model
XXX definitions to PCI as well (and perhaps USB and HDAUDIO). This
XXX would allow for a single centralized location for the products'
XXX descriptions, rather than being dispersed among individual
XXX drivers' xxx_match tables.
 1.225 27-Jan-2021  thorpej branches: 1.225.4;
Introduce autoconfiguration helpers based around device_compatible_entry:
- pci_compatible_match(): matches against the PCI ID.
- pci_compatible_match_subsys(): matches against PCI SUBSYS ID.
- pci_compatible_lookup(): look up entry by PCI ID.
- pci_compatible_lookup_subsys(): look up entry by PCI SUBSYS ID.
- pci_compatible_lookup_id(): look up entry by an arbitrary ID using the
PCI ID code conventions.

- Define PCI_COMPAT_EOL as a compat data array sentinel.
 1.224 30-May-2020  jdolecek branches: 1.224.2;
change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack
 1.223 10-Apr-2020  christos Fix all the random __SHIFTOUT casts by introducing an intermediate macho,
and then deleting and fixing the rest.
 1.222 21-Mar-2020  thorpej branches: 1.222.2;
When parsing Enhanced Allocation entries, use the correct calulation for
finding the next entry.
 1.221 25-Jan-2020  msaitoh Add PCIe 4.0 stuff a little:

- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.
 1.220 25-Jan-2020  msaitoh - Print Bridge Config Retry Enable bit and Retimer Presence Detect Supported
bit.
- Avoid using magic number.
 1.219 17-Jan-2020  msaitoh Fix a bug that the virtual channel extended configuraton's arbitration phase
register can't be decoded correcty. Found by jmcneill.
 1.218 11-Dec-2019  msaitoh branches: 1.218.2;
s/enalbe/enable/
 1.217 20-Sep-2019  msaitoh Print some DPC register values not with %04x but with %08x because those
are 32bit.
 1.216 21-Aug-2019  msaitoh Whitespace fixes. No functional change.
 1.215 18-Jul-2019  msaitoh branches: 1.215.2;
Remove whitespace for consistency.
 1.214 09-Jul-2019  msaitoh Print extend capability from 0x25 to 0x29 correctly.
 1.213 09-Jul-2019  msaitoh Identify 16GT/s.
 1.212 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.211 28-Feb-2019  khorben Typo (s/vaule/value/)
 1.210 30-Nov-2018  msaitoh Add new PCIE_HAS_LINKREGS(pcie_devtype) and use it. No functional change.
 1.209 30-Nov-2018  msaitoh Add new macro PCIE_HAS_ROOTREGS(pcie_devtype) and use it. No functional
change.
 1.208 30-Nov-2018  msaitoh The downstream port of PCIe switch is not a root port, so don't print
root port related register. For example, Intel 63xxESB controller's
downstream port device was printed by pcictl(8) with this bug:
 1.207 05-Nov-2018  msaitoh Decode PCI Enhanced Allocation.
 1.206 04-Oct-2018  msaitoh Don't print extra newline if the PCI extended configuration space doesn't exist.
 1.205 03-Oct-2018  msaitoh - Don't print TPH requester's ST Table Size if the ST table location field
is not PCI_TPH_REQ_STTBLLOC_TPHREQ because the size field is only applicaple
for PCI_TPH_REQ_STTBLLOC_TPHREQ case.
- Add comment.
 1.204 27-Sep-2018  msaitoh Root Complex Event Collector Bus Number Association ECN.
- If capability version is 2 (or greater), decode RCEC Associated Bus Numbers
register.
 1.203 12-Sep-2018  msaitoh Add ATS Relaxed Ordering supported bit described in Address Translation
Relaxed Ordering ECN.
 1.202 03-Jul-2018  msaitoh - Print Power Management Control/status register in 32bit.
- Simplify.
 1.201 09-May-2018  msaitoh branches: 1.201.2;
Fix typo. s/TPL/TLP/
 1.200 01-Feb-2018  msaitoh branches: 1.200.2;
- Add PCie Link Activation ECN.
- Use macro.
- KNF.
 1.199 01-Feb-2018  msaitoh Cleanup:
- Don't pass a capability pointer as a argument of pci_conf_find_cap() and
determine the first pointer in the pci_conf_find_cap() function.
- Don't pass a capability pointer as a argument of pci_conf_find_extcap()
because it's not used.
- Remove unsed code.
 1.198 01-Feb-2018  msaitoh "s/above 300W/greater than 300W/" in pci_conf_print_pcie_power(). From
PCIe Base Spec 3.1a Errata 2017-12-13.
 1.197 18-Dec-2017  msaitoh Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.

NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.
 1.196 25-Oct-2017  msaitoh Whitespace fix.
 1.195 24-Oct-2017  msaitoh Print Error Source Identification register correctly.
 1.194 19-Oct-2017  msaitoh Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.
 1.193 12-Oct-2017  msaitoh IOMMU cap dump fixes:
- Print Capability Register's value.
- Indent output correctly.
- s/cahced/cached/
- Print MSI Message number with 0x%02x
 1.192 10-Oct-2017  msaitoh Decode IOMMU capability of PCI secure device capability. From "AMD I/O
Virtualization Technology(IOMMU) Specification (#48882) Revision 3.00".
 1.191 05-Oct-2017  msaitoh - Add PCI_MAPREG_ROM_ADDR_MASK macro and PCI_MAPREG_ROM_ADDR() macro.
- print PCI_MAPREG_ROM_ENABLE bit.
- Decode Expansion ROM Validation ECN.
- Add Native PCIe Enclosure Management ECN's extended capability type.
Not decoded yet.
 1.190 13-Jul-2017  msaitoh - Official shortname of LN Requester is LNR, so change PCI_EXTCAP_LN_REQ
to PCI_EXTCAP_LNR
- Use macro.
 1.189 15-Jun-2017  flxd Fix printf format/argument.
 1.188 15-Jun-2017  msaitoh Fix a bug that LTR's latency in L1 PM Substates capability and Latency
Tolerance Reporting capability isn't printed correctly.
 1.187 15-Jun-2017  msaitoh For Attention Indicator Control bit and Power Indicator Control bit, it's
allowed to be a read only value 0 if corresponding capability register bit
is 0.
 1.186 08-Jun-2017  msaitoh For the Target Link Speed in LCSR2, 0 is allowed for a device which supports
2.5GT/s only (and this check also works for devices which compliant to
versions of the base specification prior to 3.0.

Tested with BCM5709:
- Target Link Speed: unknown value (0)
+ Target Link Speed: 2.5GT/s
 1.185 07-Jun-2017  msaitoh Fix to print the following bit fields correctly.
- Supported Link Speeds Vector in LCAP2
- Lower SKP OS Generation Supported Speed Vector in LCAP2
- Lower SKP OS Reception Supported Speed Vector in LCAP2
- Enable Lower SKP OS Generation Vector in LCTL3

Note that the above bitfields start from 0 and the follwing bitfields start
from 1:
- Maximum Link Speed in LCAP
- Current Link Speed in LCSR
- Target Link Speed in LCSR2
 1.184 05-Jun-2017  msaitoh Add missing return to print the Slot Power Limit Value correctly.
 1.183 29-May-2017  msaitoh branches: 1.183.2;
Print MSI Message data in 32bits when the Extended Message Data Capable bit
is set.
 1.182 24-May-2017  msaitoh Decode TPH Requester Control register.
 1.181 22-May-2017  msaitoh - The Captured Slot Power Limit value is only for device which has upsteam
port.
- The following three registers are the same encoding, so use the same
function:
- the Captured Slot Power Limit in the Device Capability register of PICe
capability.
- the Slot Power Limit in Slot Capability register of PCIe capability.
- the Base Power and Data Scale in the Data Register of Power Budgeting
capability.
- Fix the alternative encoding check of power limit as document. Add check if
scale equals to 0.
 1.180 09-May-2017  msaitoh A device except Root Complex integrated has a link, so print link related
registers on device except Root Complex Integrated Endpoint and Root Complex
Event Collector.
 1.179 27-Apr-2017  msaitoh Check slot registers if a device is PCI/PCI-X to PCI Express Bridge. Tested
with Pericom Semiconductors(Diodes) PI7C9X111SL PCIe to PCI Reverse Bridge.
 1.178 21-Apr-2017  kre branches: 1.178.2;

For want of a comma, the compiler was lost.
 1.177 21-Apr-2017  msaitoh Add Flattening Portal Bridge capability ID and Hierarchy ID extended
capability ID.
 1.176 20-Apr-2017  msaitoh Add Downstream Port Containment (DPC) ECN and Enhanced DPC(eDPC) ECN.
 1.175 20-Apr-2017  msaitoh Add 0x for register output.
 1.174 18-Apr-2017  msaitoh Add missing ':'
 1.173 17-Apr-2017  msaitoh Use macro. No functional change.
 1.172 06-Apr-2017  msaitoh Fix typos:
- s/Readness/Readiness/
- s/Presense/Presence/
- s/supportted/supported/
- s/Rquester/Requester/
- s/Check Enab/Check Enable/
 1.171 30-Mar-2017  msaitoh Fix a bug that SR-IOV's system page size was doubled. ffs()'s bit are
numbered starting from 1.
 1.170 28-Mar-2017  msaitoh Use macro. No functional change.
 1.169 28-Mar-2017  msaitoh Use correct macro "PCI_SATA_REV" instead of PCI_MSIX_CTL for SATA revision
register. This is not a real bug because PCI_SATA_REV and PCI_MSIX_CTL have
the same value.
 1.168 17-Mar-2017  msaitoh Don't print BAR's window size on pcictl pciN dump again
because there is no way to know it's correct value from
userland now.
 1.167 17-Mar-2017  msaitoh - Don't try to sizing a BAR not if a device is host bridge but a device's
PCI_COMMAND_MEM_ENABLE is set.
- Fix 17 years old bug that all effective BARs are marked "not sized" on
pcictl pciN dump.
- Print BAR's window size on pcictl pciN dump.
- remove extra "(?)"
 1.166 14-Mar-2017  msaitoh ECN: Change Root Complex Event Collector Class Code
- Old RCEC has subclass 0x06. It's the same as IOMMU. Read the type in PCIe
extend capability to know whether it's RCEC or IOMMU.
 1.165 14-Mar-2017  msaitoh Pint PCI Interface name if available.
 1.164 14-Mar-2017  msaitoh Add two new PCI classes:
- processing accelerators
- non-essential instrumentation
 1.163 14-Mar-2017  msaitoh No functional change:
- modify variable names
- KNF
 1.162 27-Feb-2017  christos fix printf formats (clang build)
 1.161 27-Feb-2017  msaitoh Decode AGP capability.
 1.160 26-Feb-2017  msaitoh - Fix the base power's value in the power budget capability.
- Fix typo (s/Maximun/Maximum/)
 1.159 24-Feb-2017  msaitoh Use macro. KNF. No functional change.
 1.158 24-Feb-2017  msaitoh Fix 0x%u...
 1.157 15-Feb-2017  msaitoh - Print Data Select and Data Scale in pci_conf_print_pcipm_cap().
- The Message Data register of MSI cap is not 32bit but 16bit.
- When the PCIE_LCAP_MAX_SPEED bitfiled is 0, it means it supports 2.5GT/s only.
- Print link de-emphasis value by "-X dB".
- Print Completion Timeout Ranges Supported filed with alphabets.
- Print TPH Completer Supported fileld's meaning.
- Print PCIE_DCAP2_MAX_EETLP correctly. 0 means 4 End-End TLP Prefixes.
- If the Supported Link Speed Vector is 0, the Link Capability 2 register is not
implemented. Don't decode LCAP2 when the vector is 0.
- The ACS's Egress Control Vector is 32bit, so print with 0x%08x.
- Print SR-IOV's device ID.
- Use __SHIFTOUT() to avoid using magic number.
- Prefix "0x" for hexadecimal value.
 1.156 28-Dec-2016  msaitoh branches: 1.156.2;
The Power Controller Control bit (PCIE_SLCSR_PCC) in the Slot Control & Status
Register is 0 on power on. Print "Power <on|off>" instead of "<on|off>".
 1.155 02-Nov-2016  pgoyette Protect against buffer overflow.
 1.154 31-Oct-2016  martin Stopgap fix for in-kernel compilation (differences between humanize_number(3)
and humanize_number(9)), ok: msaitoh
 1.153 31-Oct-2016  msaitoh Decode Resizable BAR.
 1.152 20-Oct-2016  msaitoh - pci_conf_print_pwrbdgt_base_power(): From 0xf3 to 0xff of the Base power are
reserved above 300W (PCI 3.0 Errata).
- Emergency Power Reduction mechanism with PWRBRK signal ECN.
- Extended Message Data for MSI ECN.
- Fix typo in comment.
 1.151 19-Oct-2016  msaitoh Add VF Resizable BARs ECN.
 1.150 22-Aug-2016  msaitoh Don't follow an incorrect pointer in an extended capability header. Tested
with Super Micro X10SDV-8C-TLN4F bus 255, device 12, function 0 (BIOS 1.1b).
 1.149 17-Aug-2016  msaitoh Add Dynamic Power Allocation (DPA) ECN support.
 1.148 20-Jun-2016  msaitoh branches: 1.148.2;
B260 "Slot Power Limit" ECN. PCIe 3.1 ECN. September 18, 2015.
 1.147 11-May-2016  msaitoh Add Precision Time Management (PTM) ECN.
 1.146 18-Nov-2015  msaitoh - Add the Auto Slot Power Limit Disable bit in Slot Control register and
the Completion Timeout Prefix/Header Log Capable bit in the AER capability
and control register (ECN: Downstream Port Containment (DPC)).
- Add the Poisoned TLP Egress Block bit (ECN: Enhanced DPC).
- Update Link Capabilities 2 register and Link Control 3 register (ECN:
Separate Refclk Independent SSC Architecture (SRIS))
- ECN: Readiness Notifications (RN)
- Add the Retimer Presence Detect Supported bit in the Link Capabilities 2
register and the Retimer Presence Detected bit in the Link Status 2 register
(ECN: Extension Devices)
 1.145 17-Nov-2015  msaitoh - ARI's function group is not bit 32-24 but 22-20.
- Add the Structure Length field in AF capability register.
- Add Enhanced Allocation extended capability ID (ECN: Enhanced Allocation (EA)
for Memory and I/O Resources).
- Add LN System CLS (ECN: Lightweight Notification (LN) Protocol).
- Add ST Upper and Lower bit definitions (ECN: TLP Processiong Hints).
- Add the Global Invalidate bit in the ATS capability register and the PRG
Response PASID Required bit in the Page Request status register (ECN: PASID
Translation)
- Decode ASPM support bit more (ECN: ASPM Optionally)
- Use __BITS()
 1.144 17-Nov-2015  msaitoh No functional change:
- Add comments.
- Remove obsolete comment.
- Move definitions to better location.
- Rename bit definition.
- KNF.
- Indent.
 1.143 16-Nov-2015  msaitoh Define PCIE_XCAP_{VER,TYPE}(x) and use them.
 1.142 13-Nov-2015  msaitoh Fix register offset to print HyperTransport registers correctly.
 1.141 12-Nov-2015  msaitoh - Restore pci_subr.c rev. 1.135's change in pci_conf_print_caplist().
As wrote in the comment, HyperTransport capability appears multiple times.
pci_conf_cap() reruns only the first entry, so it can't be used here.
- Try to decode HyperTransport capability. Currently, the capability type
of each HyperTransport capability is printed and only the MSI Mapping
capability is decoded.
- Style change.
 1.140 30-Oct-2015  msaitoh - Move PCI_INTRSTR_LEN from pcireg.h to pcivar.h.
- In PCI-X cap, print 2nd bus's PCI-X mode, error protection type, Max clock
frequency and Max clock period.
- In SATA cap, print register location correctly.
- In Virtual Channel cap, print reference clock with "ns".
- In Root Complex Link Declaration, print Link Entry number.
 1.139 21-Oct-2015  msaitoh Fix compile error...
 1.138 21-Oct-2015  msaitoh Decode SATA Capability and Multicast Extendeded Capability.
 1.137 03-Oct-2015  joerg Fix format string.
 1.136 02-Oct-2015  msaitoh Fix a bug that the TPH ST Table is wrongly decoded. Found by llvm.
 1.135 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.134 27-Jul-2015  msaitoh Add NVMe.
 1.133 24-Nov-2014  msaitoh branches: 1.133.2;
Add PCIe CRS Software Visibility bit.
 1.132 23-Oct-2014  msaitoh - Cleanup pci_conf_print_caplist. Use table. The reason why it loops twice
is that some capabilities appear multiple times (e.g. HyperTransport cap).
- Print the specification revision of Power Management and AGP not in
the capability list part but in the detail part.
 1.131 23-Oct-2014  msaitoh Fix a bug that the specification revision of the Power Management function
was incorrectly printed in the output of capability "list".
The value is also printed in the detail output and it has no bug.
 1.130 23-Oct-2014  msaitoh Fix typo in comment.
 1.129 06-Oct-2014  msaitoh s/genric/generic/
 1.128 06-Oct-2014  msaitoh - Add some PCI subclass and interfaces.
- The interface of PCI_SUBCLASS_BRIDGE_RACEWAY is not decoded yet.
- Fix typo in a message.
- Add comment.
- Modify comment.
 1.127 22-Sep-2014  msaitoh Always print the Slot implemented bit in the PCIe Capabilities
Register using with onoff().
 1.126 21-Sep-2014  christos Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.125 05-Sep-2014  matt Don't use class or typename as a variable name.
 1.124 09-Jun-2014  msaitoh branches: 1.124.2;
Add IOMMU and the Root Complex Event Collector.
 1.123 30-May-2014  msaitoh - Remove some obsoleted comments.
- KNF.
 1.122 30-May-2014  msaitoh - Add PCI-X capability stuff.
- remove extra ':' in pci_conf_print_pcie_cap()
- Add comments.
 1.121 27-May-2014  msaitoh Print "range: not set" if the decode window isn't set.
 1.120 27-May-2014  msaitoh - Add some register definition for MSI and MSI-X
- print MSI-X capability
 1.119 25-May-2014  njoly Do not crash if subclassp == NULL, seen while attaching rstx(4) which
match PCI_CLASS_UNDEFINED class.
 1.118 24-May-2014  msaitoh Print some PCI Capabilities:
- Vendor specific (ID:0x09)
- Debugport (ID:0x0a)
- Subsystem (ID:0x0d)
- PCI Advanced Features (ID:0x13)
 1.117 24-May-2014  msaitoh - Decode the programming interface field in the Class Code register and print
it.
- Print the cache line size in bytes.
- Print the Link Status 2 register itself.
- Some bits were not printed if the bit is 0. Always print them using with
onoff() macro.
- Print more bits.
- KNF.
- Use macro.
- Add comments.
 1.116 24-May-2014  msaitoh - Fix calculation of supported max payload size in PCIe device capability
register.
- Fix for PCIE_SLCSR_DLLSCE flag.
- invert PCIE_SLCSR_PCC
 1.115 23-May-2014  msaitoh No functional change:
- KNF
- Sort in PCI capability ID order.
- Add comments.
 1.114 23-May-2014  msaitoh - Add some register definitions (subclass, power management, etc.)
- Print some information (subclass, power management)
- Use macro.
 1.113 23-May-2014  msaitoh PME# clock is not bit 2 but bit 3. Use the macro!
 1.112 15-May-2014  msaitoh Use onoff() macro.
 1.111 13-May-2014  msaitoh Print 32bit I/O region flag and 64bit memory region flag.
 1.110 12-May-2014  msaitoh Print the range of I/O, non-prefechable memory and prefechable memory.
 1.109 12-May-2014  msaitoh Use macro.
 1.108 12-May-2014  msaitoh Fix newline problem which was added in previous commit.
 1.107 09-May-2014  msaitoh Print the CRS Software Visibility Enable bit and the Crosslink Supported bit.
 1.106 05-Aug-2013  msaitoh branches: 1.106.2;
One more Gb/s -> GT/s fix.
 1.105 21-Apr-2013  msaitoh branches: 1.105.4;
- Print PCIe 2.0 or higher capability registers.
- Print Link related registers only if the device is PCI Express Endpoint,
Legacy PCI Express Endpoint or Root Port of PCI Express Root Complex.
- Don't print Root related registers if the device is Root Complex
Integrated Endpoint and print if the device is Root Complex Event Collector.
- Not Gb/s but GT/s.
 1.104 21-Apr-2013  msaitoh - Add some PCIe 2.0 or higher capability register definitions.
- Rename some registers.
- Add comments.
- Indent.
 1.103 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.102 17-Apr-2013  msaitoh Don't check whether PCIe Slot Control Register is all 0 or not.
For example, 82801I PCI Express Port #1 (devid 0x2940) is really
Root Port and it has the Root Control Register and the default
value is 0 (the document say so and really 0 (Tested with my
machine)).
 1.101 17-Apr-2013  msaitoh - Add slot related registers
- Add root port related registers
- Fix the definition of PCI_PCIE_SLCAP_PSN
- Cleanup
 1.100 17-Apr-2013  msaitoh Add PCI_CAP_SUBVENDOR (= 0x0d).
 1.99 16-Apr-2013  msaitoh Decode some PCIe capability register bits.
 1.98 16-Apr-2013  msaitoh Use macro.
 1.97 16-Apr-2013  msaitoh Fix a bug that IRQ(MSI) bits in PCIe capability register is incorrectly
decoded. The bit field is not 0x4e000000 but 0x3e000000.
 1.96 15-Apr-2013  msaitoh Print some PCIE device type.
 1.95 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.94 20-Oct-2012  matt Add NVM to the pci mass storage subclass
 1.93 23-Sep-2012  chs add an entry for subclass HD audio.
 1.92 24-Apr-2012  drochner branches: 1.92.2;
print correct link speed for PCIexpress Gen2+
(the decoding code needs to be rewritten, sorry for only adding to
the mess)
 1.91 21-Mar-2012  matt Use an unsigned value to hold the pci_class
 1.90 29-Jan-2012  drochner branches: 1.90.2;
extend the pci_aprint_devinfo slightly to cover the cases commonly
used by drivers: a short name for the quiet/naive case and a string
to override the "pcidevs" based name by one provided by the driver,
ride on yesterday's kernel minor version bump
 1.89 26-Jan-2012  drochner put printing of the pci_devinfo into its own function (not inlined
by purpose) - this is a stack hog, and with this change my uTCA amd64
system boots again
a lot of similar code can be eliminated from pci device drivers this way,
but before doing so (and making the new function part of the module API)
I'd like to consider a modification to make it work with drivers which
prefer to print names from other sources (like pciide)
 1.88 17-Aug-2011  dyoung branches: 1.88.2; 1.88.6;
Redefine PCI_MSI_* and PCI_PCIE_* constants in terms of bits(3).

Use named constants and more conventional variable names in
pci_msi_establish() and pci_msi_disestablish(). Fix a couple of bugs:
pci_msi_establish() returned a pointer to the struct intrhand instead of
to the struct msi_hdl as it was intended to, and pci_msi_disestablish()
did not free(9) the msi_hdl.
 1.87 06-Jun-2011  msaitoh Add two new capabilities(PCI_CAP_SATA and PCI_CAP_PCIAF).
 1.86 11-Dec-2010  matt branches: 1.86.6;
Add code to display MSI capabilities.
 1.85 21-Aug-2010  pgoyette Update the various xxx_verbose modules to conform to the module subsystem's
new locking protocol.
 1.84 25-Jul-2010  pgoyette Move setting of pci_verbose_loaded flag into the module's init routine.
This ensures that the flag is set even if the module was manually loaded
by the user rather than just auto-loaded.
 1.83 06-Jun-2010  pgoyette Update pciverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.82 26-May-2010  martin Do not try to unload the pciverbose module if it had never been loaded.
 1.81 25-May-2010  pgoyette Rework the pciverbose module dispatch vectors to avoid renaming the
externally-visible entrypoint name. Also this avoids a potential
need to bump kernel version.

Requested by dyoung@ and mrg@
 1.80 24-May-2010  pgoyette Extract the vendor/product tables and related access routines into a
separate kernel module. Update pci bus attach routine to load the
module (if available) when we're about to start scanning the bus, and
unload the module after the scan is finished.

On architectures which support loading of modules by the boot loader,
the 'pciverbose' module can be loaded and executed without needing to
rebuild the kernel. On all architectures, using 'options PCIVERBOSE'
in the kernel configuration file will create a 'builtin' module which
is functionally equivalent to previous behavior.

XXX Although not nearly as large as the vendor and product tables,
XXX the PCI class and subclass tables might also be offloaded into
XXX the module at a future time.

XXX Cardbus (and possibly other) drivers should also be modified to
XXX load the module before scanning/attaching devices.
 1.79 04-Mar-2010  dyoung branches: 1.79.2;
Extract both instances of the code that prints the PCI Secondary Status
Register into a subroutine. Use terminology similar to that which
PCI System Architecture (4th Edition) uses. For comparison with PCI
reference books, specify flags and fields with __BIT(n) and __BITS(m, n)
instead of hexadecimal constants.
 1.78 13-Jan-2010  drochner branches: 1.78.2;
fix some bitmask in PCI Express capabilities decoding
being here, fix some typos and add a comma for clarity
 1.77 20-Jan-2009  jmcneill Decode and display PCI Power Management registers when available.
 1.76 17-Nov-2008  matt Store pcidevs in a more compact manner. Instead of many string with duplicate
words, store each word individual in a long string and then store offsets
in the string to that word. This reduces the space needed by half.
 1.75 29-Apr-2008  jmcneill branches: 1.75.6; 1.75.8; 1.75.10;
Oh, so that's how you spell Legacy -- thanks spellcheck!
 1.74 10-Apr-2008  cegger branches: 1.74.2; 1.74.4;
use aprint_*_dev and device_xname
 1.73 19-Oct-2007  ad branches: 1.73.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.72 07-Oct-2007  joerg branches: 1.72.2;
Add some basic parsing of the PCI Express capabilities register.
This is enough to help detect the source of interrupt storms at least
for my Thinkpad.
 1.71 16-Nov-2006  christos branches: 1.71.8; 1.71.22; 1.71.24; 1.71.26;
__unused removal on arguments; approved by core.
 1.70 08-Nov-2006  drochner while we are here, also print the interrupt disable bit
in VERBOSE/pcictl
 1.69 17-Oct-2006  dogcow now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
 1.68 13-Oct-2006  christos more __unused
 1.67 13-Oct-2006  dogcow more unused variable fallout.
 1.66 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.65 03-Sep-2006  christos branches: 1.65.2; 1.65.4;
add missing initializers
 1.64 31-May-2006  drochner -add 2 subclasses new in rev. 3.0 of the spec, and fix a pasto in another
-get power management rev printing right
 1.63 11-Dec-2005  christos branches: 1.63.4; 1.63.6; 1.63.8; 1.63.14;
merge ktrace-lwp.
 1.62 30-Oct-2005  simonb Only include <sys/systm.h> if _KERNEL is defined.
 1.61 28-Jun-2005  thorpej branches: 1.61.2; 1.61.4;
Use ANSI function decls and static.
 1.60 27-Feb-2005  perry nuke trailing whitespace
 1.59 02-Aug-2004  mycroft branches: 1.59.4; 1.59.6;
For the PCIVERBOSE case, separate vendors and products into separate tables.
Eliminating redundant pointers in the tables saves nearly 20K (20% of the table
size). In the process, add a pci_findproduct() and make that and
pci_findvendor() return a "const char *".
 1.58 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.57 04-Feb-2004  soren Use the right bits for the AGP version.
 1.56 29-Jun-2003  fvdl branches: 1.56.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.55 29-Jun-2003  jdolecek fix typo in comment
 1.54 24-Nov-2002  scw Quell an uninitialised variable warning.
 1.53 21-Sep-2002  drochner call the capability list ptr by its name
 1.52 21-Sep-2002  drochner correct caplist head for Cardbus bridges
 1.51 21-Sep-2002  drochner -corrected "MSI" capability
-added some new subclasses and capabilities
-move capability list printing into a separate function and call it
for each header type (not type 0 only)
 1.50 19-May-2002  sommerfeld Fortunately for us, all interrupt controllers are not 8259's
 1.49 03-May-2002  nathanw branches: 1.49.2;
Make pci_conf_print() dump the device-dependent header in userspace, too.
 1.48 22-Mar-2002  drochner iadd subclass codes from the 2.3 spec
 1.47 13-Nov-2001  lukem add RCSID
 1.46 13-Nov-2001  enami Include stdio.h when compiled in userland to pull in declaration of printf etc.
 1.45 13-Sep-2001  thorpej Allow this file to be used in userspace, as well.
 1.44 13-Sep-2001  thorpej ANSI'ify.
 1.43 09-Sep-2001  enami Fix sample code in comment; pci_conf_print() takes three arguments.
 1.42 18-Jan-2001  jdolecek branches: 1.42.2; 1.42.4; 1.42.6;
adapt to pci_knowndevs[] being const, make local constant arrays const
 1.41 21-Nov-2000  soren s/iRDA/IrDA/
 1.40 07-Oct-2000  cgd Update for current PCI device class/subclass and capability codes.
(also, tweak the I2O subclass string to be "standard" -- the removal
of version info didn't extend that far.)
 1.39 02-Oct-2000  ad I2O subclasses currently have nothing to do with the protocol version.
 1.38 02-Sep-2000  cgd don't attempt to size Host Bridge BARs. (it's a good way to die.)
provide a clue about 16-bit vs. 32-bit I/O BARs.
 1.37 03-Aug-2000  nathanw When performing pci_config_dump:
- Display the full value of 64-bit BARs.
- Avoid displaying the upper 32 bits of 64-bit BARs as a separate 32-bit BAR.
 1.36 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.35 22-Mar-2000  cgd branches: 1.35.4;
opt_pciverbose.h -> opt_pci.h (it's gonna be used by more things, soon)
 1.34 25-Jan-2000  drochner use BUS_SPACE_MAP_PREFETCHABLE instead BUS_SPACE_MAP_CACHEABLE where the
PCI BAR bit is referred to
 1.33 15-Dec-1999  kleink Report the Capability List support bit of the SR and, if set, print the
the Capability list pointer register as such as well as the capabilities
implemented in the list.
 1.32 27-Sep-1999  cgd branches: 1.32.2; 1.32.8;
add classes/subclasses new in PCI 2.2. Needs a bit of cleanup, but then,
so does everything involving configuration space headers and if i don't
get this out of my source tree i'll go insane.
 1.31 21-Dec-1998  drochner use a symbolic definition for the PCI subsystem ID
 1.30 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.29 12-Jul-1998  augustss Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers
 1.28 26-Jun-1998  cgd factor out some common code, and enhance functionality slightly: allow
the BAR-printing function to print a name for the register, factor out
a common register-bits function which can handle the fact that type 2
headers have a different size than is usual, and actually do something
useful with the rest of the bits in the type 2 header.
 1.27 28-May-1998  cgd Clean up slightly, abstract pci_conf_print family's base address register
printing into a function, add a bit more pretty-printing of existing stuff.
Implement pretty-printers for type 1 and type 2 headers. (Right now,
these are just quick stabs based on some on-line bridge docs that I have
handy on my laptop. Mmmm, meetings. I'll check the bits when I get
back within reach of my official docs.)
 1.26 18-May-1998  cgd largely reimplement pci_conf_print():
* print all configuration space registers. Then, where possible,
interpret them. (That is, PRESENT ALL THE DATA, then interpret it --
don't hide data behind interpretation. Also, when interpreting
fields, try to print out the specific value that's being interpreted.)
* handle different header types.
* allow caller to specify a function which can interpret the
device-dependent header and is responsible for pretty-printing it.

It spews (use 'options MSGBUFSIZE=...' 8-), but when you want the data,
you really want _all_ of it.

Still needs some cleanup and additional code (e.g. interepretation
of PCI-PCI (type 1) and PCI-Cardbus (type 2(?)) bridge headers).
 1.25 03-May-1998  thorpej In pci_conf_print(), don't print a mapping register if the size is 0.
 1.24 03-May-1998  thorpej Properly compute the region sizes in pci_conf_print(). Bug pointed out
by Chris Demetriou.
 1.23 20-Apr-1998  drochner Avoid "unused variable" warning without PCIVERBOSE.
From mynhier@cs.utk.edu (PR kern/5328).
 1.22 14-Apr-1998  thorpej Add pci_conf_print(), a function to dump the PCI configuration space, useful
in driver debugging. From Zubin D. Dittia <zubin@clouseau.arl.wustl.edu>,
PR #4249.
 1.21 13-Sep-1997  enami Declare PCIVERBOSE by defopt in files.pci. Include opt_pciverbose.h
in pci_subr.c.
 1.20 19-Mar-1997  cgd branches: 1.20.4;
fix multi-function device support, add new known classes/subclasses,
and clean up class/subclass printing. From brb@brig.com via PR 3359.
 1.19 13-Oct-1996  christos backout kprintf changes
 1.18 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.17 02-Mar-1996  cgd remove some colons to be slightly more friendly to things trying to
parse autoconfiguration output.
 1.16 02-Mar-1996  cgd oops; spaces -> tabs
 1.15 02-Mar-1996  cgd if not PCIVERBOSE, don't say that vendor/product is "unknown," just say
what it is.
 1.14 28-Feb-1996  cgd make PCI bus match/attach and sub-device attachment machine-independent.
 1.13 22-Jan-1996  cgd update PCIVERBOSE code in various ways:
(1) remove the 'UNSUPP' keyword from the device list,
because it can't be reasonably used (becuase different
devices may be supported on different machines, for
good reason).
(2) enhance pci_devinfo so that class/subclass information
is optional (so pci_devinfo can be used by drivers that
match classes of devices, and want to look up the
devices' names easily).
(3) more known vendors and devices.
 1.12 16-Aug-1995  cgd check for null subclass pointer. From Todd Mummert
 1.11 21-Jun-1995  cgd fix reference to incorrect struct (paste-o)
 1.10 18-Jun-1995  cgd define and call "pci_devinfo()", which creates a string from the
vendor & product IDs and class information, which is printed if device
isn't found. Optionally (via "PCIVERBOSE" option) does table lookup
to try to see if it knows what the device really is (informational only...).
 1.9 17-Jun-1995  cgd more appropriate name, as this only has PCI support subroutines.
 1.8 23-May-1995  cgd split single-subdevice lookup & attachment into a subroutine
(pci_attach_subdev()). remove pciattach() function and the pcicd cfdriver
struct, the former because thre are a lot of attachment actions which really
are machine-dependent (perhaps even "most"), and the latter because now that
both pcimatch() and pciattach() are machine-dependent it's bad style to
declare them here and it gains nothing.
 1.7 27-Jan-1995  cgd include files from the correct places.
 1.6 04-Nov-1994  mycroft Make a wrapper match function to check the bus and device numbers, rather
than insisting that every driver do it.
 1.5 03-Nov-1994  mycroft Rename pciprobe() to pcimatch(), and move it to pci_machdep.c.
 1.4 03-Nov-1994  mycroft Always use direct configuration.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 10-Aug-1994  mycroft Update some comments.
 1.1 09-Aug-1994  mycroft branches: 1.1.2;
Add PCI autoconfiguration support.
 1.1.2.1 10-Aug-1994  mycroft update from trunk
 1.20.4.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.32.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.32.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.32.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.32.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.35.4.2 25-Oct-2001  he Pull up revisions 1.39-1.40 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.35.4.1 10-Aug-2000  soda Pull up to netbsd-1-5 branch
Approved by: thorpej

When performing pci_config_dump:
Display the full value of 64-bit BARs.
Avoid displaying the upper 32 bits of 64-bit BARs as a separate 32-bit BAR.
by Nathan J Williams <nathanw@netbsd.org>

Revisions pulled up:
> cvs rdiff -r1.36 -r1.37 syssrc/sys/dev/pci/pci_subr.c
 1.42.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.42.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.42.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.42.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.42.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.42.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.42.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.42.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.42.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.42.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.42.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.49.2.1 30-May-2002  gehenna Catch up with -current.
 1.56.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.56.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.56.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.56.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.56.2.1 03-Aug-2004  skrll Sync with HEAD
 1.59.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.59.4.1 29-Apr-2005  kent sync with -current
 1.61.4.1 02-Nov-2005  yamt sync with head.
 1.61.2.3 27-Oct-2007  yamt sync with head.
 1.61.2.2 30-Dec-2006  yamt sync with head.
 1.61.2.1 21-Jun-2006  yamt sync with head.
 1.63.14.1 19-Jun-2006  chap Sync with head.
 1.63.8.2 03-Sep-2006  yamt sync with head.
 1.63.8.1 26-Jun-2006  yamt sync with head.
 1.63.6.1 01-Jun-2006  kardel Sync with head.
 1.63.4.1 09-Sep-2006  rpaulo sync with head
 1.65.4.2 10-Dec-2006  yamt sync with head.
 1.65.4.1 22-Oct-2006  yamt sync with head
 1.65.2.1 18-Nov-2006  ad Sync with head.
 1.71.26.1 14-Oct-2007  yamt sync with head.
 1.71.24.1 06-Nov-2007  matt sync with HEAD
 1.71.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.71.8.2 23-Oct-2007  ad Sync with head.
 1.71.8.1 09-Oct-2007  ad Sync with head.
 1.72.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.73.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.73.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.74.4.5 09-Oct-2010  yamt sync with head
 1.74.4.4 11-Aug-2010  yamt sync with head.
 1.74.4.3 11-Mar-2010  yamt sync with head
 1.74.4.2 04-May-2009  yamt sync with head.
 1.74.4.1 16-May-2008  yamt sync with head.
 1.74.2.1 18-May-2008  yamt sync with head.
 1.75.10.1 24-Feb-2009  snj branches: 1.75.10.1.4; 1.75.10.1.8;
Pull up following revision(s) (requested by jmcneill in ticket #485):
sys/dev/pci/pci_subr.c: revision 1.77
Decode and display PCI Power Management registers when available.
 1.75.10.1.8.1 07-Jan-2011  matt Add/define some MSI support
 1.75.10.1.4.2 05-Nov-2013  matt Pull in support for pci_aprint_devinfo_fancy
 1.75.10.1.4.1 26-Dec-2011  matt Merge -HEAD changes (except for PCIVERBOSE chagnes).
 1.75.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.75.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.75.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.78.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.78.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.78.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.79.2.4 12-Jun-2011  rmind sync with head
 1.79.2.3 05-Mar-2011  rmind sync with head
 1.79.2.2 03-Jul-2010  rmind sync with head
 1.79.2.1 30-May-2010  rmind sync with head
 1.86.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.88.6.3 29-Apr-2012  mrg sync to latest -current.
 1.88.6.2 05-Apr-2012  mrg sync to latest -current.
 1.88.6.1 18-Feb-2012  mrg merge to -current.
 1.88.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.88.2.3 30-Oct-2012  yamt sync with head
 1.88.2.2 23-May-2012  yamt sync with head.
 1.88.2.1 17-Apr-2012  yamt sync with head
 1.90.2.1 05-Aug-2013  martin Pullup

sys/dev/pci/pcireg.h 1.74-1.82 and 1.84 via patch
sys/dev/pci/pci_subr.c 1.92-1.102, 1.104-1.105 via patch

Add some PCI(e) register and bit definitions in pcireg.h.
Fix the definition of PCI_PCIE_SLCAP_PSN.
Fix a bug that IRQ(MSI) bits in PCIe capability register is incorrectly
decoded.
Print more registers in "pcictl dump".
Fix bug in comment.

Requested by msaitoh in ticket #928
 1.92.2.4 03-Dec-2017  jdolecek update from HEAD
 1.92.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.92.2.2 23-Jun-2013  tls resync from head
 1.92.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.105.4.2 18-May-2014  rmind sync with head
 1.105.4.1 28-Aug-2013  rmind sync with head
 1.106.2.1 10-Aug-2014  tls Rebase.
 1.124.2.3 09-Dec-2016  snj Pull up following revision(s) (requested by pgoyette in ticket #1296):
sys/dev/pci/pci_subr.c: revision 1.155 via patch
Protect against buffer overflow.
 1.124.2.2 14-Dec-2014  martin branches: 1.124.2.2.4;
Pull up following revision(s) (requested by msaitoh in ticket #325):
sys/dev/pci/pcireg.h: revision 1.100
sys/dev/pci/pci_subr.c: revision 1.133
Add PCIe CRS Software Visibility bit.
 1.124.2.1 12-Dec-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #312):
sys/dev/pci/pci_subr.c: revision 1.130
sys/dev/pci/pci_subr.c: revision 1.131
sys/dev/pci/pci_subr.c: revision 1.132
sys/dev/pci/pcireg.h: revision 1.97
sys/dev/pci/pcireg.h: revision 1.98
sys/dev/pci/pcireg.h: revision 1.99
sys/dev/pci/pci_subr.c: revision 1.127
sys/dev/pci/pci_subr.c: revision 1.128
sys/dev/pci/pci_subr.c: revision 1.129
Always print the Slot implemented bit in the PCIe Capabilities
Register using with onoff().
- Add some PCI subclass and interfaces.
- The interface of PCI_SUBCLASS_BRIDGE_RACEWAY is not decoded yet.
- Fix typo in a message.
- Add comment.
- Modify comment.
s/genric/generic/
Add comment.
Fix typo in comment.
Fix a bug that the specification revision of the Power Management function
was incorrectly printed in the output of capability "list".
The value is also printed in the detail output and it has no bug.
- Cleanup pci_conf_print_caplist. Use table. The reason why it loops twice
is that some capabilities appear multiple times (e.g. HyperTransport cap).
- Print the specification revision of Power Management and AGP not in
the capability list part but in the detail part.
Add some HyperTransport related defines. It's required for the MSI.
 1.124.2.2.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.133.2.8 28-Aug-2017  skrll Sync with HEAD
 1.133.2.7 05-Feb-2017  skrll Sync with HEAD
 1.133.2.6 05-Dec-2016  skrll Sync with HEAD
 1.133.2.5 05-Oct-2016  skrll Sync with HEAD
 1.133.2.4 09-Jul-2016  skrll Sync with HEAD
 1.133.2.3 29-May-2016  skrll Sync with HEAD
 1.133.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.133.2.1 22-Sep-2015  skrll Sync with HEAD
 1.148.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.148.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.148.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.148.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.156.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.178.2.2 11-May-2017  pgoyette Sync with HEAD
 1.178.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.183.2.14 29-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1728:

sys/dev/pci/pci_subr.c 1.232-1.239 via patch
sys/dev/pci/pcireg.h 1.62-1.63

- Decode link control2's Compliance Preset/De-emphasis more.
- Decode Physical Layer 16.0 GT/s extended capability.
- Decode Lane Margining at the Receiver extended capability.
- Print "reserved" instead of "unknown" when printing equalization
preset. One of them is known to be the default value.
- Fix typo.
 1.183.2.13 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1714:

sys/dev/pci/pcireg.h 1.148-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.217-1.222, 1.224, 1.227-1.232
via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158
sys/dev/pci/ppb.c 1.74

- Print Bridge Config Retry Enable bit and Retimer Presence Detect
Supported bit.
- Add PCIe 4.0 stuff a little:
- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.
- Change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack.
- Print some DPC register values not with %04x but with %08x because
those are 32bit.
- Fix a bug that the virtual channel extended configuration's
arbitration phase register can't be decoded correctly.
- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Remove unused shift and mask definitions.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.183.2.12 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1388:

sys/dev/pci/pcireg.h 1.147 via patch
sys/dev/pci/pci_subr.c 1.212, 1.215-1.217 via patch

- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard
Timer Status and Discard Timer SERR# Enable bit in pci_subr.c.
- Print some DPC register values not with %04x but with %08x because
those are 32bit.
- Remove whitespace for consistency.
- Use macro.
- Whitespace fixes.
 1.183.2.11 17-Jul-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1295):

sys/dev/pci/pci_subr.c: revision 1.213
sys/dev/pci/ppb.c: revision 1.69

Identify 16GT/s.
 1.183.2.10 17-Jul-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1292):

sys/dev/pci/pci_subr.c: revision 1.211
sys/dev/pci/pci_subr.c: revision 1.214

Typo (s/vaule/value/)
Print extend capability from 0x25 to 0x29 correctly.
 1.183.2.9 04-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1118):

sys/dev/pci/pci_subr.c: revision 1.210
sys/dev/pci/pci_subr.c: revision 1.207
sys/dev/pci/pcireg.h: revision 1.143
sys/dev/pci/pci_subr.c: revision 1.208
sys/dev/pci/pcireg.h: revision 1.144
sys/dev/pci/pci_subr.c: revision 1.209
sys/dev/pci/pcireg.h: revision 1.145
sys/dev/pci/pcireg.h: revision 1.146

Decode PCI Enhanced Allocation.

The register offset of the mask and pending register is depend on the 64bit
address capable bit, so fix the definition of PCI MSI vector mask and pending
register. This problem was not a real bug because PCI_MSI{MASK,PENDING} were
not used from anywhere.

The downstream port of PCIe switch is not a root port, so don't print
root port related register. For example, Intel 63xxESB controller's
downstream port device was printed by pcictl(8) with this bug:
 1.183.2.8 30-Oct-2018  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1074):
sys/dev/pci/pci_subr.c: revision 1.204-1.206
sys/dev/pci/pcireg.h: revision 1.141-1.142

Root Complex Event Collector Bus Number Association ECN.
- If capability version is 2 (or greater), decode RCEC Associated Bus Numbers
register.
- Don't print TPH requester's ST Table Size if the ST table location field
is not PCI_TPH_REQ_STTBLLOC_TPHREQ because the size field is only applicable
for PCI_TPH_REQ_STTBLLOC_TPHREQ case.
- Add comment.
 1.183.2.7 23-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1028):

sys/dev/pci/pci_subr.c: revision 1.203
sys/dev/pci/pcireg.h: revision 1.140

Add ATS Relaxed Ordering supported bit described in Address Translation
Relaxed Ordering ECN.
 1.183.2.6 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #933):
sys/dev/pci/pci_subr.c: revision 1.202
sys/dev/pci/pcireg.h: revision 1.139
sys/dev/pci/ppbreg.h: revision 1.9
VGA 16 bit decode bit is not bit 3 but bit 4.
--
- Print Power Management Control/status register in 32bit.
- Simplify.
 1.183.2.5 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #930):
sys/dev/pci/pci_subr.c: revision 1.201
sys/dev/pci/pcireg.h: revision 1.138
Fix typo. s/TPL/TLP/
 1.183.2.4 26-Feb-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #576):
sys/dev/pci/pci_subr.c: 1.197-1.200
sys/dev/pci/pcireg.h: 1.136-1.137
sys/dev/pci/ppbreg.h: 1.8
Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.
NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.
"s/above 300W/greater than 300W/" in pci_conf_print_pcie_power(). From
PCIe Base Spec 3.1a Errata 2017-12-13.
Cleanup:
- Don't pass a capability pointer as a argument of pci_conf_find_cap() and
determine the first pointer in the pci_conf_find_cap() function.
- Don't pass a capability pointer as a argument of pci_conf_find_extcap()
because it's not used.
- Remove unsed code.
- Add PCie Link Activation ECN.
- Use macro.
- KNF.
 1.183.2.3 22-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #371):
sys/dev/pci/pci_subr.c: revision 1.195
sys/dev/pci/pci_subr.c: revision 1.196
Print Error Source Identification register correctly.
Whitespace fix.
 1.183.2.2 21-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #362):
sys/dev/pci/pcireg.h: revision 1.133
sys/dev/pci/pcireg.h: revision 1.134
sys/dev/pci/pcireg.h: revision 1.135
sys/dev/pci/pci_subr.c: revision 1.190
sys/dev/pci/pci_subr.c: revision 1.191
sys/dev/pci/pci_subr.c: revision 1.192
sys/dev/pci/pci_subr.c: revision 1.193
sys/dev/pci/pci_subr.c: revision 1.194
sys/dev/pci/pcireg.h: revision 1.132
- Official shortname of LN Requester is LNR, so change PCI_EXTCAP_LN_REQ
to PCI_EXTCAP_LNR
- Use macro.
- Add PCI_MAPREG_ROM_ADDR_MASK macro and PCI_MAPREG_ROM_ADDR() macro.
- print PCI_MAPREG_ROM_ENABLE bit.
- Decode Expansion ROM Validation ECN.
- Add Native PCIe Enclosure Management ECN's extended capability type.
Not decoded yet.
Decode IOMMU capability of PCI secure device capability. From "AMD I/O
Virtualization Technology(IOMMU) Specification (#48882) Revision 3.00".
IOMMU cap dump fixes:
- Print Capability Register's value.
- Indent output correctly.
- s/cahced/cached/
- Print MSI Message number with 0x%02x
Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.
 1.183.2.1 04-Jul-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #80):
sys/dev/pci/pci_subr.c: revision 1.184
sys/dev/pci/pci_subr.c: revision 1.185
sys/dev/pci/pci_subr.c: revision 1.186
sys/dev/pci/pci_subr.c: revision 1.187
sys/dev/pci/pci_subr.c: revision 1.188
sys/dev/pci/pci_subr.c: revision 1.189
sys/dev/pci/pcireg.h: revision 1.131
Add missing return to print the Slot Power Limit Value correctly.
Fix to print the following bit fields correctly.
- Supported Link Speeds Vector in LCAP2
- Lower SKP OS Generation Supported Speed Vector in LCAP2
- Lower SKP OS Reception Supported Speed Vector in LCAP2
- Enable Lower SKP OS Generation Vector in LCTL3
Note that the above bitfields start from 0 and the follwing bitfields start
from 1:
- Maximum Link Speed in LCAP
- Current Link Speed in LCSR
- Target Link Speed in LCSR2
For the Target Link Speed in LCSR2, 0 is allowed for a device which supports
2.5GT/s only (and this check also works for devices which compliant to
versions of the base specification prior to 3.0.
Tested with BCM5709:
- Target Link Speed: unknown value (0)
+ Target Link Speed: 2.5GT/s
For Attention Indicator Control bit and Power Indicator Control bit, it's
allowed to be a read only value 0 if corresponding capability register bit
is 0.
Fix a bug that LTR's latency in L1 PM Substates capability and Latency
Tolerance Reporting capability isn't printed correctly.
Fix printf format/argument.
 1.200.2.6 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.200.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.200.2.4 20-Oct-2018  pgoyette Sync with head
 1.200.2.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.200.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.200.2.1 21-May-2018  pgoyette Sync with HEAD
 1.201.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.201.2.1 10-Jun-2019  christos Sync with HEAD
 1.215.2.6 29-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1412:

sys/dev/pci/pci_subr.c 1.232-1.239 via patch
sys/dev/pci/pcireg.h 1.62-1.63

- Decode link control2's Compliance Preset/De-emphasis more.
- Decode Physical Layer 16.0 GT/s extended capability.
- Decode Lane Margining at the Receiver extended capability.
- Print "reserved" instead of "unknown" when printing equalization
preset. One of them is known to be the default value.
- Fix typo.
 1.215.2.5 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1384:

sys/dev/pci/pcireg.h 1.152-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.222, 1.227-1.232 via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158, 1.163
sys/dev/pci/ppb.c 1.74

- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.215.2.4 26-Jul-2020  martin Pull up following revision(s) (requested by jdolecek in ticket #1024):

sys/dev/pci/pci_subr.c: revision 1.224

change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack
 1.215.2.3 19-Mar-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #782):

sys/dev/pci/pcireg.h: revision 1.150
sys/dev/pci/pcireg.h: revision 1.151
sys/dev/pci/pci_subr.c: revision 1.220
sys/dev/pci/pci_subr.c: revision 1.221
sys/dev/pci/pcireg.h: revision 1.149

- Print Bridge Config Retry Enable bit and Retimer Presence Detect Supported
bit.
- Avoid using magic number.

Add PCIe 4.0 stuff a little:
- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.

Remove unused shift and mask definitions.

Add comment.
 1.215.2.2 21-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #629:

sys/dev/pci/pcireg.h 1.148
sys/dev/pci/pci_subr.c 1.218-1.219

- Fix a bug that the virtual channel extended configuration's
arbitration phase register can't be decoded correctly.
- Fix typo.
 1.215.2.1 26-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #243):

sys/dev/pci/pci_subr.c: revision 1.216
sys/dev/pci/pci_subr.c: revision 1.217

Whitespace fixes. No functional change.

-

Print some DPC register values not with %04x but with %08x because those
are 32bit.
 1.218.2.2 25-Jan-2020  ad Sync with head.
 1.218.2.1 17-Jan-2020  ad Sync with head.
 1.222.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.224.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.225.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.31 05-Sep-2021  mrg make sure PCI_IOC_DRVNAMEONBUS doesn't access NULL pointers.

hopefully fixes PR#55744. it's not entirely clear why this does
not affect most systems, as there's usually some PCI devices that
do not have attached drivers, eg:

006:00:0: AMD Family17h/7xh Reserved SPP (non-essential instrumentation, subclass 0x00)

on my system i'm testing on.


XXX: pullup-8, pullup-9.
 1.30 24-Sep-2016  mrg branches: 1.30.6;
introduce a better pci_drvname() and PCI_IOC_DRVNAME as pciio_drvnameonbus()
and PCI_IOC_DRVNAMEONBUS. the new ones also take a (autoconf) PCI bus
number, which allows lookups for any device on any pci bus node. use this
in pcictl which current reports the wrong values sometimes.

up next: use these in libpciaccess.
 1.29 24-Aug-2015  pooka branches: 1.29.2;
add some _KERNEL_OPT as the finishing touch
 1.28 25-Jul-2014  dholland branches: 1.28.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.27 25-Jul-2014  mrg introduce a new pci_drvname(3) to libpci. implement it in the backend
via PCI_IOC_DRVNAME.

update manual and set lists (and remove a couple of doubled entries.)o

this will be used in libpciaccess() to implement the has_kernel_driver()
method.
 1.26 28-May-2014  riastradh Reject unaligned PCI config register ioctl requests before we kassert.
 1.25 16-Mar-2014  dholland branches: 1.25.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.24 13-Mar-2012  elad branches: 1.24.2; 1.24.4;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.23 10-Feb-2011  jmcneill branches: 1.23.4; 1.23.8; 1.23.10; 1.23.14; 1.23.16;
pcimmap: if the requested page is marked prefetchable in a child device's
BAR, pass the BUS_SPACE_MAP_PREFETCHABLE flag down to bus_space_mmap
 1.22 30-Jul-2009  macallan branches: 1.22.4; 1.22.6; 1.22.8;
do as elad suggested and call kauth instead of using INSECURE in pcimmap()
 1.21 14-Jul-2009  macallan nuke PCI_ALLOW_MMAP, instead allow mmap(/dev/pci*) with options INSECURE
now the x86 camp should be happy again
 1.20 09-Jul-2009  macallan enable mmap() support for /dev/pci* with options PCI_ALLOW_MMAP
 1.19 07-Jul-2009  christos simplify previous.
 1.18 04-Jul-2009  cegger pciioctl(), pci_devioctl():
simplify implementations of PCI_IOC_BDF_CFGREAD, PCI_IOC_BDF_CFGWRITE,
PCI_IOC_CFGREAD, PCI_IOC_CFGWRITE
No functional changes.
 1.17 04-Jul-2009  cegger remove useless parenthesis
 1.16 11-Jun-2008  cegger branches: 1.16.6; 1.16.10; 1.16.14;
remove unused variable
 1.15 23-Mar-2008  cube branches: 1.15.2; 1.15.4; 1.15.6; 1.15.8;
Split device_t and softc for pci(4).
 1.14 04-Mar-2007  christos branches: 1.14.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 16-Nov-2006  christos branches: 1.13.4;
__unused removal on arguments; approved by core.
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 03-Sep-2006  christos branches: 1.11.2; 1.11.4;
add missing initializers
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.8;
merge ktrace-lwp.
 1.9 28-Jun-2005  thorpej branches: 1.9.2;
Use ANSI function decls and static.
 1.8 29-Jun-2003  fvdl branches: 1.8.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.7 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.6 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.5 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.4 17-Mar-2002  atatat branches: 1.4.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.3 13-Nov-2001  lukem branches: 1.3.2;
add RCSID
 1.2 13-Sep-2001  thorpej branches: 1.2.2; 1.2.4;
Oops, didn't intend to enable pcimmap() yet.
 1.1 13-Sep-2001  thorpej Add an ioctl interface to the PCI bus. Add ioctls to read/write
PCI configuration space registers, and to fetch bus info.
 1.2.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.1 13-Sep-2001  fvdl file pci_usrreq.c was added on branch thorpej-devvp on 2001-10-01 12:45:58 +0000
 1.2.2.6 11-Nov-2002  nathanw Catch up to -current
 1.2.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.2.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 13-Sep-2001  nathanw file pci_usrreq.c was added on branch nathanw_sa on 2001-09-21 22:35:59 +0000
 1.3.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 13-Nov-2001  thorpej file pci_usrreq.c was added on branch kqueue on 2002-01-10 19:56:55 +0000
 1.4.4.1 16-May-2002  gehenna Add the character device switch.
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.9.2.4 24-Mar-2008  yamt sync with head.
 1.9.2.3 03-Sep-2007  yamt sync with head.
 1.9.2.2 30-Dec-2006  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.8.1 03-Sep-2006  yamt sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.4.2 10-Dec-2006  yamt sync with head.
 1.11.4.1 22-Oct-2006  yamt sync with head
 1.11.2.1 18-Nov-2006  ad Sync with head.
 1.13.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.36.2 29-Jun-2008  mjf Sync with HEAD.
 1.14.36.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.8.1 18-Jun-2008  simonb Sync with head.
 1.15.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.4.3 19-Aug-2009  yamt sync with head.
 1.15.4.2 18-Jul-2009  yamt sync with head.
 1.15.4.1 04-May-2009  yamt sync with head.
 1.15.2.1 17-Jun-2008  yamt sync with head.
 1.16.14.1 21-Apr-2010  matt sync to netbsd-5
 1.16.10.1 23-Jul-2009  jym Sync with HEAD.
 1.16.6.4 27-Aug-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1922):
sys/dev/pci/pci_usrreq.c 1.26 via patch

Fix to make pci(4) reject unaligned configuration register reads and writes
before feeding them to a kassert in pci_conf_read/write or to a trap in the
hardware itself.
 1.16.6.3 15-Sep-2009  snj branches: 1.16.6.3.2; 1.16.6.3.6;
Pull up following revision(s) (requested by mrg in ticket #952):
sys/dev/pci/pci_usrreq.c: revision 1.22 via patch
do as elad suggested and call kauth instead of using INSECURE in pcimmap()
 1.16.6.2 15-Sep-2009  snj Pull up following revision(s) (requested by mrg in ticket #952):
sys/dev/pci/pci_usrreq.c: revision 1.21 via patch
nuke PCI_ALLOW_MMAP, instead allow mmap(/dev/pci*) with options INSECURE
now the x86 camp should be happy again
 1.16.6.1 15-Sep-2009  snj Pull up following revision(s) (requested by mrg in ticket #952):
sys/dev/pci/pci_usrreq.c: revision 1.20 via patch
enable mmap() support for /dev/pci* with options PCI_ALLOW_MMAP
 1.16.6.3.6.1 27-Aug-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1922):
sys/dev/pci/pci_usrreq.c 1.26 via patch

Fix to make pci(4) reject unaligned configuration register reads and writes
before feeding them to a kassert in pci_conf_read/write or to a trap in the
hardware itself.
 1.16.6.3.2.1 27-Aug-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1922):
sys/dev/pci/pci_usrreq.c 1.26 via patch

Fix to make pci(4) reject unaligned configuration register reads and writes
before feeding them to a kassert in pci_conf_read/write or to a trap in the
hardware itself.
 1.22.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.22.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.22.4.1 05-Mar-2011  rmind sync with head
 1.23.16.1 13-Sep-2014  snj Pull up following revision(s) (requested by riastradh in ticket #1124):
sys/dev/pci/pci_usrreq.c: revision 1.26
Reject unaligned PCI config register ioctl requests before we kassert.
 1.23.14.1 13-Sep-2014  snj Pull up following revision(s) (requested by riastradh in ticket #1124):
sys/dev/pci/pci_usrreq.c: revision 1.26
Reject unaligned PCI config register ioctl requests before we kassert.
 1.23.10.1 13-Sep-2014  snj Pull up following revision(s) (requested by riastradh in ticket #1124):
sys/dev/pci/pci_usrreq.c: revision 1.26
Reject unaligned PCI config register ioctl requests before we kassert.
 1.23.8.1 05-Apr-2012  mrg sync to latest -current.
 1.23.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.4.1 17-Apr-2012  yamt sync with head
 1.24.4.1 18-May-2014  rmind sync with head
 1.24.2.2 03-Dec-2017  jdolecek update from HEAD
 1.24.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.2.1 10-Aug-2014  tls Rebase.
 1.28.4.2 05-Oct-2016  skrll Sync with HEAD
 1.28.4.1 22-Sep-2015  skrll Sync with HEAD
 1.29.2.4 04-Nov-2016  pgoyette Sync with HEAD
 1.29.2.3 26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.29.2.2 19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.29.2.1 18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.30.6.2 29-Apr-2017  pgoyette Remove more unnecessary #include for sys/localcount.h
 1.30.6.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.9 21-Sep-2014  christos Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.8 29-Aug-2011  jmcneill branches: 1.8.12;
have pci register itself as a module, and make PCI driver modules depend on it
 1.7 25-Jul-2010  pgoyette branches: 1.7.2; 1.7.4;
Move setting of pci_verbose_loaded flag into the module's init routine.
This ensures that the flag is set even if the module was manually loaded
by the user rather than just auto-loaded.
 1.6 06-Jun-2010  pgoyette Update pciverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.5 28-May-2010  pgoyette branches: 1.5.2;
Remove opt_pci.h - it's not needed for anything.
 1.4 27-May-2010  pgoyette Remove a left-over debugging call to aprint_normal()

Thanks njoly@
 1.3 27-May-2010  pgoyette Extract pci_verbose interface definitions into their own header file so
we don't need to include pcivar.h in the module. pcivar.h tries to pull
in machine/pci_machdep.h which doesn't exist on all machine/architecture
combos. Keeping track and building the module only for those that work
would have been a maintenance headache; this change allows us to build
the module on all systems, regardless of whether the system has pci
support or not.
 1.2 25-May-2010  pgoyette Rework the pciverbose module dispatch vectors to avoid renaming the
externally-visible entrypoint name. Also this avoids a potential
need to bump kernel version.

Requested by dyoung@ and mrg@
 1.1 24-May-2010  pgoyette Extract the vendor/product tables and related access routines into a
separate kernel module. Update pci bus attach routine to load the
module (if available) when we're about to start scanning the bus, and
unload the module after the scan is finished.

On architectures which support loading of modules by the boot loader,
the 'pciverbose' module can be loaded and executed without needing to
rebuild the kernel. On all architectures, using 'options PCIVERBOSE'
in the kernel configuration file will create a 'builtin' module which
is functionally equivalent to previous behavior.

XXX Although not nearly as large as the vendor and product tables,
XXX the PCI class and subclass tables might also be offloaded into
XXX the module at a future time.

XXX Cardbus (and possibly other) drivers should also be modified to
XXX load the module before scanning/attaching devices.
 1.5.2.4 05-Mar-2011  rmind sync with head
 1.5.2.3 03-Jul-2010  rmind sync with head
 1.5.2.2 30-May-2010  rmind sync with head
 1.5.2.1 28-May-2010  rmind file pci_verbose.c was added on branch rmind-uvmplock on 2010-05-30 05:17:36 +0000
 1.7.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.7.4.1 25-Jul-2010  uebayasi file pci_verbose.c was added on branch uebayasi-xip on 2010-08-17 06:46:28 +0000
 1.7.2.2 11-Aug-2010  yamt sync with head.
 1.7.2.1 25-Jul-2010  yamt file pci_verbose.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:51 +0000
 1.8.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5 25-Oct-2016  pgoyette Increase max string length for PCI Product names. Affects only kernels
with PCIVERBOSE (or corresponding module).

We currently have a few product names that exceed the old limit, and
this is triggering an SSP check in pci_devinfo(). This commit doesn't
directly address the SSP issue, but pushes the can down the road...
 1.4 21-Sep-2014  christos branches: 1.4.2; 1.4.4;
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.3 06-Jun-2010  pgoyette branches: 1.3.2; 1.3.4; 1.3.22;
Update pciverbose module to use module_autoload() rather than module_load().
Load the module right before each attempt to use its features, and let the
module subsystem handle unloading.
 1.2 28-May-2010  pgoyette branches: 1.2.2;
Fix symbol name in multiple-inclusion protection. (missing trailing '_')
 1.1 27-May-2010  pgoyette Extract pci_verbose interface definitions into their own header file so
we don't need to include pcivar.h in the module. pcivar.h tries to pull
in machine/pci_machdep.h which doesn't exist on all machine/architecture
combos. Keeping track and building the module only for those that work
would have been a maintenance headache; this change allows us to build
the module on all systems, regardless of whether the system has pci
support or not.
 1.2.2.3 03-Jul-2010  rmind sync with head
 1.2.2.2 30-May-2010  rmind sync with head
 1.2.2.1 28-May-2010  rmind file pci_verbose.h was added on branch rmind-uvmplock on 2010-05-30 05:17:36 +0000
 1.3.22.1 03-Dec-2017  jdolecek update from HEAD
 1.3.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.4.1 06-Jun-2010  uebayasi file pci_verbose.h was added on branch uebayasi-xip on 2010-08-17 06:46:28 +0000
 1.3.2.2 11-Aug-2010  yamt sync with head.
 1.3.2.1 06-Jun-2010  yamt file pci_verbose.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:51 +0000
 1.4.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.2.1 05-Dec-2016  skrll Sync with HEAD
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 24-May-2005  lukem branches: 1.2.2;
add __KERNEL_RCSID
 1.1 30-Aug-2004  drochner branches: 1.1.2;
add centralized {eisa,isa,pci,agp,mca}busprint() functions which do
what tens of the bus' parents foo{...}bridge_print()s scattered around do
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Sep-2004  skrll Sync with HEAD
 1.1.2.1 30-Aug-2004  skrll file pcibusprint.c was added on branch ktrace-lwp on 2004-09-03 12:45:28 +0000
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.55 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.54 13-Aug-2022  jmcneill pciconf: Skip callbacks for reserved ranges if resource allocation fails.

In the event that a BAR write is ignored, no need to notify the callback
of any changes.
 1.53 30-Aug-2021  jmcneill If an allocation cannot be satisfied by the prefetchable range, retry with
the non-prefetchable range.
 1.52 03-Jan-2021  skrll Misc whitespace
 1.51 29-Dec-2020  skrll Add support for Enhanced Allocations as seen in the Cavium ThunderX based
GIGABYTE MT30-GS2-00

From thorpej@. Thanks!
 1.50 20-Oct-2020  jmcneill branches: 1.50.2;
Instead of trying to prevent pciconf from reconfiguring the firmware's
framebuffer, instead allow MD code to register callbacks. If a resource is
changed, the driver can unmap the old resource and remap the new. Do this
with simplefb so the console doesn't explode when the VGA device is
(potentially) reconfigured at boot.
 1.49 10-Oct-2020  jmcneill Add pciconf_resource_reserve. This allows MD code to mark specific memory
and I/O regions as in use. When pciconf finds a device already configured
to use one of these regions, the device config is left as-is.
 1.48 08-Jul-2020  thorpej Turn off pci_conf_debug -- it was enabled by mistake in previous
commit.
 1.47 07-Jul-2020  thorpej Overhaul the interface to pci_configure_bus():
- Don't expose how PCI bus configuration resource management is implemented.
Provide a new resource provider API:

==> pciconf_resource_init() -- Initialize a PCI configuration resources
container.
==> pciconf_resource_add() -- Add a PCI configuration resource to the
container (I/O, MEM, or prefetchable MEM). Multiple resources of
each type may be added.
==> pciconf_resource_fini() -- Tear down the PCI configurtation resources
container once the bus has been configured.

This is much easier to use than the previous method of providing an
extent map for each kind of resource, and works better for e.g. ACPI
platforms that provide potentially multiple PCI resources in tables
provided by firmware.

- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
 1.46 02-Feb-2020  jmcneill Fix null deref for busses with no IO port resources.
 1.45 20-Jan-2020  skrll don't attempt to extent_alloc_subregion outside the parent extent ranges
 1.44 18-Jan-2020  thorpej Fix several problems with pci_configure_bus():
- Track the 64-bit range capability of prefetchable and non-prefetchable
memory separately. Probe the extent maps provided by the caller to
initialize these values. Without this, we never get 64-bit range
capablity on the root bus, and thus are never able to forward it along
to downstream busses.
- Always prefer allocating space for a 64-bit memory BAR > 4GB. We will
fall back on a 32-bit range if no space above 4GB is available.
- Constrain allocation of 32-bit memory BARs (including expansion ROM BARs)
to be below 4GB, even if the window has a larger range available.
- When allocating non-prefetchable memory space for a PCI-PCI bridge, ensure
it falls below 4GB, since a bridge cannot forward a 64-bit non-prefetchable
range.
- Account for expansion ROMs as non-prefetchable memory rather than
prefetchable memory; expansion ROMs have 32-bit BARs, and if a device
with an expansion ROM is downstream of a brige, a 32-bit prefetchable
range might not be available.

Tested by jmcneill@ on an Arm Neoverse N1 SDP, where the previous
code failed to configure all devices correctly.
 1.43 05-Dec-2019  msaitoh branches: 1.43.2;
KNF. No functional change.
 1.42 01-Oct-2019  chs in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.41 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.40 01-Mar-2019  msaitoh KNF. No functional change.
 1.39 01-Mar-2019  msaitoh No functional change:
- u_int* -> uint*
- KNF.
 1.38 29-Jan-2019  msaitoh Fix a bug that PCI bridge's prefetchable memory area's configuration
didn't work correctly in pciconf.c::configure_bridge(). Note that this function
is only for "options PCI_NETBSD_CONFIGURE" machines.
 1.37 05-Sep-2014  matt branches: 1.37.20;
Don't use class or typename as a variable name.
 1.36 20-Oct-2012  matt Enforce alignments for buses.
 1.35 20-Oct-2012  matt If exceeding io/mem windows, show the number that got exceeded.
 1.34 27-Jan-2012  para branches: 1.34.6;
converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.33 24-Aug-2011  dyoung branches: 1.33.2; 1.33.6;
Add to pci_bus_devorder() an argument that tells the number of slots
available in the devs array. Change the type of the devs array from
char to uint8_t. Treat the return value of pci_bus_devorder() as the
number of slots that it filled.

Don't use the __PCI_BUS_DEVORDER #definition to configure the kernel
but let the linker do it. Make pci_bus_devorder() available on all
architectures by adding a default implementation that will DTRT on
all architectures but hpcmips, the only architecture to #define
__PCI_BUS_DEVORDER. On hpcmips, adapt the implementation to the new
calling convention.

XXX I can compile an hpcmips GENERIC kernel, but I don't have a
XXX hpcmips box to test it on.
 1.32 11-Dec-2010  matt Switch to kmem from malloc.
Don't actually set the PREFETCH64 base/limit registers unless they really are
in use.
 1.31 02-Aug-2009  gavan branches: 1.31.4;
If we're going to complain about exceeding the PCI bandwidth, we may as
well say how much we think we're using.
 1.30 24-May-2007  briggs branches: 1.30.32; 1.30.52; 1.30.56;
The number of max_lat units in 1 sec is 4000000 instead of 40000000 (an
extra 0 snuck into the code).
Found when looking at this with dyoung.
 1.29 27-Feb-2006  gdamore branches: 1.29.24; 1.29.26;
Add PCI_MAPREG_TYPE_ROM and allow it to be used with pci_mapreg_map().
Fix to configure (but do not enable) BARs for expansion ROMs.
Reviewed by briggs@
 1.28 10-Feb-2006  gdamore PCI_NETBSD_CONFIGURE should allocate (but not map) address space expansion
ROMS by default. Full discussion at
http://mail-index.netbsd.org/tech-kern/2005/12/16/0023.html
Closes PR kern/32467
Reviewed by briggs@
 1.27 11-Dec-2005  christos branches: 1.27.2; 1.27.4; 1.27.6;
merge ktrace-lwp.
 1.26 25-Mar-2005  tsutsui branches: 1.26.2;
Allow MD PCI code to specify or disable PCI_COMMAND_PARITY_ENABLE
and PCI_CMMAND_SERR_ENABLE in MI pci_configure_bus(9).
Patch from PR kern/27423 by KIYOHARA Takashi with some changes by me,
approved by Allen Briggs.
 1.25 27-Feb-2005  perry branches: 1.25.2;
nuke trailing whitespace
 1.24 11-Feb-2005  simonb White space nit- don't put a space before/after increment/decrement
operators.
 1.23 17-Mar-2004  scw branches: 1.23.8; 1.23.10;
Use PRIu64 and PRIx64 in place of %llu and %llx format strings for
printing variables of type u_int64_t.
 1.22 02-Dec-2003  briggs Configure PCI-Cardbus bridges, too.
Patch from KIYOHARA Takashi on current-users.
 1.21 31-Mar-2003  augustss branches: 1.21.2;
Add an option to disable fast back-to-back transfers since this
breaks certain hardware combinations.
 1.20 27-Nov-2002  simonb In configure_bus() return early if there are no devices on the bus to
configure.
 1.19 25-Nov-2002  thorpej Avoid some "comparison always false" warnings by only compiling
the code in question if ULONG_MAX > 0xffffffff.
 1.18 08-Nov-2002  simonb Add a prototype for set_busreg(), fix a couple of white space nits.
 1.17 30-Jul-2002  augustss Number PCI busses using a simple pre-order numbering instead of
some strange binary split numbering that doesn't work with multiple
bridges on the same bus, nor with deeply nested bridges.
 1.16 27-Jun-2002  briggs Change a 'continue' to a 'break' in switch configuring 64-bit devices.
Add a little more debugging code.
 1.15 21-Feb-2002  kleink branches: 1.15.8; 1.15.10;
As discussed with Jason Thorpe: while the `cacheline_size\' argument is
a byte-size quantity, the CacheLine Size configuration register specifies
the system cacheline size in units of 32-bit words; per PCI Local Bus
Specification, rev. 2.1, section 6.2.4.
 1.14 28-Nov-2001  thorpej Add a "cacheline_size" argument to pci_configure_bus(). It is used
to set the cacheline size in the BHLC register. This should be the
size of the largest D-cache line on a system.
 1.13 13-Nov-2001  lukem add RCSID
 1.12 09-Nov-2001  thorpej Add a "firstbus" argument to pci_configure_bus(), indicating the
first bus number to use, rather than always assuming that we should
start at bus #0.
 1.11 09-Nov-2001  thorpej In query_bus(), use the parent pciconf_bus_t's PCI chipset tag,
not the new bus's (which is potentially uninitialized when some
calls are made).
 1.10 03-Sep-2001  thorpej branches: 1.10.4;
Bump MAX_CONF_DEV to 32, add some missing newlines in error
messages, and add a TODO item (allocate all metadata dynamically).
 1.9 31-Aug-2001  briggs Fix use of uninitialized variable. Missed by gcc, spotted by enami.
 1.8 30-Aug-2001  briggs Respect __PCI_BUS_DEVORDER.
If all devices can handle 66MHz, then use 66MHz.
Triple the number of configured I/O ranges that we can handle on a bus
(8 was insufficient--originally didn't consider multifunction devices)
Allow one to specify which types of memory to configure, I/O, ROM, or
MEM--for example, one could configure only ROM or only non-ROM.
Ensure that the ROM is disabled if we're not configuring it.
Only set PCI_COMMAND_IO_ENABLE/PCI_COMMAND_MEM_ENABLE if there are valid
memory ranges configured.
 1.7 28-Aug-2001  thorpej Add a TODO item: Do this in 2 passes. One pass that configures the
bus (and optionally maps expansion ROMs), and an optional second
pass to disable expansion ROMs that are mapped. This would allow
MD code to possibly execute the expansion ROMs (possibly in an x86
emulator) to configure a device (e.g. a VGA card, which pretty much
needs to be configured by its ROM).
 1.6 28-Aug-2001  thorpej If MD code doesn't provide pci_conf_hook(), then default to not mapping
the expansion ROMs on cards, since address decoders may be shared between
the ROM and PCI memory space on some cards (i.e. "only map the ROM if you're
going to use it, and then unmap it when you're done" is the intended
usage).
 1.5 14-Jun-2001  thorpej branches: 1.5.2;
It's pretty questionable to printf a PCI tag, but if we're going to
do so, at least make the printf compile across the board.
 1.4 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.3 27-May-2001  thorpej Handle non-contiguous BARs. Needed to be able to configure e.g.
IDE and USB on a PIIX3.
 1.2 12-Feb-2001  briggs branches: 1.2.2;
Deal with a lack of the proper type of memory. For example, if a bridge
only supports 16-bit I/O addresses, do not configure it with addresses
having the upper 16-bits non-zero.
 1.1 09-Feb-2001  briggs branches: 1.1.2;
Add an option (defopt) PCI_NETBSD_CONFIGURE that provides PCI bus
configuration (assignment of bus numbers, BARs, timer values,
interrupt lines, etc.).
The interface must be called from m.d. code prior to probing the bus.
It is meant to be called once for each primary (bus == 0) PCI bus in
the system. It will configure any busses behind PCI-PCI bridges.
Section 9 man page for pci_configure_bus() will come soon.
In the meantime, sample usage is in arch/sandpoint/sandpoint/mainbus.c.
[ Reviewed by thorpej ]
 1.1.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 09-Feb-2001  bouyer file pciconf.c was added on branch thorpej_scsipi on 2001-02-11 19:15:59 +0000
 1.2.2.8 11-Dec-2002  thorpej Sync with HEAD.
 1.2.2.7 11-Nov-2002  nathanw Catch up to -current
 1.2.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.2.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.5.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.10.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.15.10.1 27-Jun-2002  lukem Pull up revision 1.16 (requested by briggs in ticket #382):
Change a 'continue' to a 'break' in switch configuring 64-bit devices.
Add a little more debugging code.
 1.15.8.2 29-Aug-2002  gehenna catch up with -current.
 1.15.8.1 15-Jul-2002  gehenna catch up with -current.
 1.21.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.21.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.4 15-Feb-2005  skrll Sync with HEAD.
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.10.3 26-Mar-2005  yamt sync with head.
 1.23.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.10.1 12-Feb-2005  yamt sync with head.
 1.23.8.1 29-Apr-2005  kent sync with -current
 1.25.2.1 27-Mar-2005  tron Pull up revision 1.26 (requested by tsutsui in ticket #67):
Allow MD PCI code to specify or disable PCI_COMMAND_PARITY_ENABLE
and PCI_CMMAND_SERR_ENABLE in MI pci_configure_bus(9).
Patch from PR kern/27423 by KIYOHARA Takashi with some changes by me,
approved by Allen Briggs.
 1.26.2.2 03-Sep-2007  yamt sync with head.
 1.26.2.1 21-Jun-2006  yamt sync with head.
 1.27.6.1 22-Apr-2006  simonb Sync with head.
 1.27.4.1 09-Sep-2006  rpaulo sync with head
 1.27.2.2 01-Mar-2006  yamt sync with head.
 1.27.2.1 18-Feb-2006  yamt sync with head.
 1.29.26.1 11-Jul-2007  mjf Sync with head.
 1.29.24.1 27-May-2007  ad Sync with head.
 1.30.56.1 07-Jan-2011  matt Use kmem. Fix prefetchable setting.
 1.30.52.1 24-Dec-2011  matt Fix problem when alignment of a device is > then the alignment of the bus
bus spaces provided.
 1.30.32.1 19-Aug-2009  yamt sync with head.
 1.31.4.1 05-Mar-2011  rmind sync with head
 1.33.6.1 18-Feb-2012  mrg merge to -current.
 1.33.2.2 30-Oct-2012  yamt sync with head
 1.33.2.1 17-Apr-2012  yamt sync with head
 1.34.6.2 03-Dec-2017  jdolecek update from HEAD
 1.34.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.20.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.20.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.37.20.1 10-Jun-2019  christos Sync with HEAD
 1.43.2.2 29-Feb-2020  ad Sync with head.
 1.43.2.1 25-Jan-2020  ad Sync with head.
 1.50.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.16 20-Oct-2020  jmcneill Instead of trying to prevent pciconf from reconfiguring the firmware's
framebuffer, instead allow MD code to register callbacks. If a resource is
changed, the driver can unmap the old resource and remap the new. Do this
with simplefb so the console doesn't explode when the VGA device is
(potentially) reconfigured at boot.
 1.15 10-Oct-2020  jmcneill Add pciconf_resource_reserve. This allows MD code to mark specific memory
and I/O regions as in use. When pciconf finds a device already configured
to use one of these regions, the device config is left as-is.
 1.14 07-Jul-2020  thorpej Overhaul the interface to pci_configure_bus():
- Don't expose how PCI bus configuration resource management is implemented.
Provide a new resource provider API:

==> pciconf_resource_init() -- Initialize a PCI configuration resources
container.
==> pciconf_resource_add() -- Add a PCI configuration resource to the
container (I/O, MEM, or prefetchable MEM). Multiple resources of
each type may be added.
==> pciconf_resource_fini() -- Tear down the PCI configurtation resources
container once the bus has been configured.

This is much easier to use than the previous method of providing an
extent map for each kind of resource, and works better for e.g. ACPI
platforms that provide potentially multiple PCI resources in tables
provided by firmware.

- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
 1.13 17-Jun-2020  thorpej Explcitly include <sys/extent.h> here.
 1.12 08-Sep-2012  matt Fix comment
 1.11 10-Feb-2006  gdamore branches: 1.11.104;
PCI_NETBSD_CONFIGURE should allocate (but not map) address space expansion
ROMS by default. Full discussion at
http://mail-index.netbsd.org/tech-kern/2005/12/16/0023.html
Closes PR kern/32467
Reviewed by briggs@
 1.10 11-Dec-2005  christos branches: 1.10.2; 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 25-Mar-2005  tsutsui branches: 1.9.2;
Allow MD PCI code to specify or disable PCI_COMMAND_PARITY_ENABLE
and PCI_CMMAND_SERR_ENABLE in MI pci_configure_bus(9).
Patch from PR kern/27423 by KIYOHARA Takashi with some changes by me,
approved by Allen Briggs.
 1.8 04-Feb-2005  perry branches: 1.8.4;
de-__P
 1.7 28-Sep-2002  scw branches: 1.7.6; 1.7.14; 1.7.16;
Before declaring pci_conf_interrupt(), check to see if it's
already defined as a CPP macro, which is the case for SH5 at least.
 1.6 11-Feb-2002  kleink Move the declaration of pci_conf_hook down to <machine/pci_machdep.h>;
a port may choose to implement it not as a function but i.e. as a
pci_chipset_tag_t function vector.
 1.5 28-Nov-2001  thorpej Add a "cacheline_size" argument to pci_configure_bus(). It is used
to set the cacheline size in the BHLC register. This should be the
size of the largest D-cache line on a system.
 1.4 09-Nov-2001  thorpej Add a "firstbus" argument to pci_configure_bus(), indicating the
first bus number to use, rather than always assuming that we should
start at bus #0.
 1.3 30-Aug-2001  briggs branches: 1.3.4;
Respect __PCI_BUS_DEVORDER.
If all devices can handle 66MHz, then use 66MHz.
Triple the number of configured I/O ranges that we can handle on a bus
(8 was insufficient--originally didn't consider multifunction devices)
Allow one to specify which types of memory to configure, I/O, ROM, or
MEM--for example, one could configure only ROM or only non-ROM.
Ensure that the ROM is disabled if we're not configuring it.
Only set PCI_COMMAND_IO_ENABLE/PCI_COMMAND_MEM_ENABLE if there are valid
memory ranges configured.
 1.2 13-Jun-2001  simonb branches: 1.2.2;
Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.1 09-Feb-2001  briggs branches: 1.1.2; 1.1.4;
Add an option (defopt) PCI_NETBSD_CONFIGURE that provides PCI bus
configuration (assignment of bus numbers, BARs, timer values,
interrupt lines, etc.).
The interface must be called from m.d. code prior to probing the bus.
It is meant to be called once for each primary (bus == 0) PCI bus in
the system. It will configure any busses behind PCI-PCI bridges.
Section 9 man page for pci_configure_bus() will come soon.
In the meantime, sample usage is in arch/sandpoint/sandpoint/mainbus.c.
[ Reviewed by thorpej ]
 1.1.4.6 18-Oct-2002  nathanw Catch up to -current.
 1.1.4.5 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.4 08-Jan-2002  nathanw Catch up to -current.
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 09-Feb-2001  bouyer file pciconf.h was added on branch thorpej_scsipi on 2001-02-11 19:16:00 +0000
 1.2.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.2.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.3.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.7.16.2 26-Mar-2005  yamt sync with head.
 1.7.16.1 12-Feb-2005  yamt sync with head.
 1.7.14.1 29-Apr-2005  kent sync with -current
 1.7.6.2 01-Apr-2005  skrll Sync with HEAD.
 1.7.6.1 04-Feb-2005  skrll Sync with HEAD.
 1.8.4.1 27-Mar-2005  tron Pull up revision 1.9 (requested by tsutsui in ticket #67):
Allow MD PCI code to specify or disable PCI_COMMAND_PARITY_ENABLE
and PCI_CMMAND_SERR_ENABLE in MI pci_configure_bus(9).
Patch from PR kern/27423 by KIYOHARA Takashi with some changes by me,
approved by Allen Briggs.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.1 18-Feb-2006  yamt sync with head.
 1.11.104.1 30-Oct-2012  yamt sync with head
 1.1531 27-Oct-2025  andvar Add IDs for one more VT82C596B PM Controller and VX11 PCI-ISA bridge.
Will be needed later to add SMBus support.
 1.1530 21-Oct-2025  pgoyette add MediaTek MT7927
 1.1529 21-Oct-2025  pgoyette Add MediaTek
 1.1528 17-Oct-2025  andvar Add VIA VT8233C PCI-ISA Bridge.
 1.1527 03-May-2025  rin branches: 1.1527.2;
pcidevs: Add EXAR XR17V358 -- octal-channel Universal PCIe UART
 1.1526 01-May-2025  andvar make whitespace and tab usage more consistent, at least for the same vendor.
remove trailing whitspaces.
remove leading whitespace before tabs.
fix typo s/MIS/MSI/ for MSI 3090 description.

No definition changes expected.
 1.1525 01-May-2025  andvar Add Etron vendor and its xHCI controllers (used in some AMD/Intel boards).
Add various VIA devices, either documented in publicly available datasheets
or some from dmesg in personally owned devices.
 1.1524 28-Apr-2025  andvar fix typo in previous commit s/FHC/FCH/ for AMD RAID mode SATA controller.
 1.1523 28-Apr-2025  andvar Add AMD X370/X399/A320/A520/600 Series SATA/xHCI devices, 600 Series and Navi
PCIe Switch Upstream/Downstream Ports, Raven Ridge Vega GPUs and GeForce 6200A.
 1.1522 20-Apr-2025  andvar viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.

Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).

Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.

Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.

For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html

Should fix and close PR kern/37517.

Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.

Reviewed by bad.
 1.1521 05-Apr-2025  andvar viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.

The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.

Tested on ECS VX900-I.

Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
 1.1520 03-Apr-2025  andvar viaide(4): Add support for VIA VT6415/VT6330 single-channel IDE controllers.

Beyond adding the usual identification code, several adjustments were required:

1) Introduced 'single_channel` to set 'nchannels` to 1 for this controller.

2) Added 'APO_IDECONF_ALWAYS_EN` definition and the 'no_ideconf` flag to mimic
enabled channel bits, as this controller's enable chip register is unset.
Applied the same to VT6410, following OpenBSD and Linux, since some
controllers are known to not set this register as well.

3) Combined all VIA controllers identified by PCI ID (not ISA bus) using switch
fallthrough, as they currently share the same UDMA setting. Consequently,
the VX900 name printing was moved to the device description and adjusted
to better reflect the device.

4) Moved setting interface bits for RAID controllers under the RAID capability
check, enabling the above fallthrough and paving the way for support of other
RAID-capable controllers in upcoming changes.

5) The VT6330 is a combo FireWire/IDE controller. Added its FireWire controller
PCI ID to pcidevs.

Tested on ASRock P5B-DE.

Reviewed by jak and bad.

Addresses PR kern/45917
 1.1519 03-Mar-2025  andvar Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.

These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
 1.1518 23-Jan-2025  andvar Add VIA VT8261 southbridge SATA controller IDs and PCIB.
 1.1517 23-Jan-2025  mrg add several more intel meteor lake and crucial ssd ids
 1.1516 18-Jan-2025  mrg add a bunch of intel arrow lake devices, and several more NPU devices
 1.1515 03-Jan-2025  mrg add a bunch of missing nvidia gpu ids.

these are between 0xf00 and 0xfff, and mostly are the GT
400/500/600/700 series, and their variants.
 1.1514 12-Dec-2024  msaitoh pcidevs: Add some Oxford Semiconductor devices from FreeBSD.
 1.1513 11-Nov-2024  msaitoh Add many Brainboxes devices. Repoted in PR/kern 55824 by Cameron Williams.
 1.1512 19-Oct-2024  mlelstv Add Raspberry Pi5 Ethernet.
 1.1511 16-Oct-2024  msaitoh pcidevs: Add some AMD devies.
 1.1510 20-Aug-2024  dogcow Add Areca ARC-1224
 1.1509 17-Jul-2024  mrg add the intel "arc" a-series of cards.
 1.1508 11-Jul-2024  msaitoh Add Realtek RTL8126.
 1.1507 23-Jun-2024  jakllsch branches: 1.1507.2;
Add Brainboxes and devices

From Cameron Williams in PR 58358.
 1.1506 12-May-2024  msaitoh Add some Intel Rapotr Lake graphics.
 1.1505 12-May-2024  msaitoh Add Phison PS5021 and PS5026.
 1.1504 06-Apr-2024  andvar Add Zhaoxin devices, mainly from my TVS-675 NAS device, and some additional
to fill the gaps from pci-ids database.
 1.1503 28-Feb-2024  jakllsch Add (Realtek/)Killer E2600 Ethernet
 1.1502 18-Jan-2024  msaitoh Add Intel I219-{LM,V}(20,21)
 1.1501 28-Dec-2023  msaitoh Update Intel Raptor Lake devices.
 1.1500 28-Dec-2023  msaitoh Add Intel C26[26] eSPI.
 1.1499 13-Nov-2023  jnemeth add some newer Areca boards in prep for updating driver
 1.1498 26-Oct-2023  msaitoh pcidevs: Add Mellanox ConnectX-6 Lx.
 1.1497 11-Oct-2023  msaitoh pcidevs: Add Intel I219{V,LM}({22,23})
 1.1496 10-Oct-2023  abs Add entry for ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier
 1.1495 08-Oct-2023  msaitoh Add Pericom(Diodes) PCIe switches.
 1.1494 04-Oct-2023  rin pcidevs: Add missing I225/I226 series devices
 1.1493 04-Oct-2023  msaitoh Add Intel 82599 LS.
 1.1492 10-Aug-2023  andvar rename PCI to PCIE for naming consistency.
 1.1491 09-Aug-2023  msaitoh Simplify descriptions of Snow Ridge internal Ethernet devices.
 1.1490 09-Aug-2023  msaitoh Add some Intel Xeon D-2100 devices. Fix description of Intel 0x37d0.
 1.1489 05-Aug-2023  andvar fix duplicate definition.
 1.1488 05-Aug-2023  andvar Add device ids of the VX800 chipset and s3 chrome 500 series GPU.
Descriptions mainly aligned with VX800/820 Series System Programming Manual.
 1.1487 04-Aug-2023  msaitoh Add Intel I226 devices.
 1.1486 04-Aug-2023  msaitoh Fix some descriptions of Intel Snow Ridge.
 1.1485 04-Aug-2023  msaitoh Add Intel Snow Ridge devices.
 1.1484 31-Jul-2023  tnn pcidevs: add ASMedia ASM106x
 1.1483 28-Jul-2023  msaitoh Add AMD 19h/7xh Root Complex.
 1.1482 23-Jul-2023  msaitoh Add Intel 700 series chipset devices.
 1.1481 22-Jul-2023  msaitoh Add Alder Lake-N and Raptor Lake devices.
 1.1480 06-Apr-2023  msaitoh The SAATA device ID for Apollo Lake is not 0x5ae0 but 0x5ae3.
 1.1479 14-Feb-2023  msaitoh Add devices from PPR for AMD Family 19h Model 61h Revision B1 processors.
 1.1478 03-Feb-2023  msaitoh Add Samsung SM990.
 1.1477 29-Jan-2023  thorpej Add ID for the EXAR XR17V354 PCIe UART.

From HÃ¥kan Engvall.
PR kern/57202
 1.1476 18-Jan-2023  msaitoh Add AMD Family 19h/1xh devices.
 1.1475 14-Jan-2023  ryo add Aquantia (Marvell) AQC113 ethernet devices and the variants
 1.1474 04-Jan-2023  msaitoh Fix typo. s/SSC/SCC/.
 1.1473 30-Dec-2022  msaitoh Add Elkhart Lake Shared SRAM.
 1.1472 28-Dec-2022  msaitoh Update Intel Elkhart Lake devices.
 1.1471 22-Nov-2022  msaitoh branches: 1.1471.2;
Add some Xeon Scalable devices from OpenBSD.
 1.1470 26-Oct-2022  msaitoh Add AMD F17/Axh devices.
 1.1469 26-Oct-2022  msaitoh Add some AMD 17h/9xh devices from OpenBSD.
 1.1468 07-Oct-2022  snj add NVIDIA GeForce GTX 770
 1.1467 02-Oct-2022  martin Add AMD FCH SATA Controller D
 1.1466 01-Oct-2022  msaitoh Add AMD 19h/6xh Root Complex.
 1.1465 28-Sep-2022  msaitoh Sort by number. No functional change.
 1.1464 28-Sep-2022  msaitoh Add Intel Core 8G (8core, H, Halo) Host Bridge, DRAM.
 1.1463 28-Sep-2022  msaitoh Jasper Lake Intel Trace Hub on Compute Die is not 0x4da6 but 0x4e29.
 1.1462 13-Sep-2022  msaitoh Add more Alder Lake devices.
 1.1461 11-Sep-2022  mrg add several samsung nvme entries
 1.1460 27-Jun-2022  msaitoh Add some MegaRAID devices.
 1.1459 17-Jun-2022  msaitoh Update some descriptions of Intel 700 series Ethernet devices.
 1.1458 02-Jun-2022  mrg add some AMD zen2/3 devices.
 1.1457 11-May-2022  markd Add some Broadcom / LSI RAID cards.
 1.1456 04-May-2022  martin Rename one of the XEONSC_RAS entries slightly to avoid conflicts
 1.1455 04-May-2022  nia More Xeon Scalable / Skylake-E devices
 1.1454 27-Apr-2022  msaitoh Update some AMD devices:

- Rename AMD 15h/6xh devices.
- Add some devices.
- Use OHCI for OHCI device.
- Use EHCI for EHCI device.
- and some minor changes.
 1.1453 22-Apr-2022  skrll Add some Broadcom devices. From OpenBSD.
 1.1452 24-Mar-2022  yamaguchi Added Intel V710 for 5000BaseT
 1.1451 24-Mar-2022  yamaguchi Change description about Intel X710 10GBaseT device
 1.1450 16-Mar-2022  yamaguchi Added Intel X710 devices and rename X710_10G_T to X710_10G_T_1
 1.1449 15-Feb-2022  msaitoh Add VMware AHCI and NVMe.
 1.1448 02-Feb-2022  msaitoh Add some devices from AMD BKDG.
 1.1447 02-Feb-2022  msaitoh Fix AMD F16_HB from 0x1568 to 0x1538.

AMD BKDG says the host bridge's device ID is 0x1538. Before pcidevs
rev. 1.1261, F16_HB was located next to 0x1537, so I suspect 0x1568 was typo
of 0x1538.
 1.1446 25-Jan-2022  msaitoh Add Alder Lake devices and Intel 600 Series PCH devices.
 1.1445 01-Jan-2022  msaitoh s/sytem/system/
 1.1444 30-Nov-2021  msaitoh Add Intel Rocket Lake devices.
 1.1443 03-Nov-2021  msaitoh - Rename EHL_TRACE* macros
- Update Jasper Lake's Processor Transaction Routers.
 1.1442 27-Oct-2021  msaitoh Add Intel Elkhart Lake devices.
 1.1441 27-Oct-2021  msaitoh Add Intel Gemini Lake TXE HECI 1.
 1.1440 13-Oct-2021  msaitoh Add Intel I219V 15-19 and I219LM 16-19.
 1.1439 13-Oct-2021  msaitoh Add Intel I219's version number.
 1.1438 12-Oct-2021  msaitoh Add Intel 400 Series PCH-V devices.
 1.1437 11-Oct-2021  msaitoh Add Intel 500 Series PCH-H devices.
 1.1436 11-Oct-2021  msaitoh Remove duplicated entries.
 1.1435 02-Oct-2021  mrg add intel 660p ssd, and expand the 760p description.
 1.1434 23-Sep-2021  msaitoh Add some Intel devices:

- Tiger Lake
- I225V and I225LM
- WiFi 6 AX201
 1.1433 06-Sep-2021  mrg the CPU ident and AMD both say this is "R2 Graphics", not R3.
 1.1432 03-Sep-2021  mrg add a whole bunch of radeon devices.

now all the radeons i have are here (and dozens i don't :)
 1.1431 30-Aug-2021  andvar add RDC R6022 PCI-Host bridge.
 1.1430 30-Aug-2021  mrg add a bunch of nvidia devices.
 1.1429 30-Aug-2021  mrg add radeon x1550.
 1.1428 17-Jul-2021  mrg add current generation NVIDIA graphics cards (3050-3090 etc.)
 1.1427 12-Jul-2021  msaitoh Add Intel Jasper Lake devices and Reealtek RTL8821CE.
 1.1426 21-Apr-2021  jakllsch branches: 1.1426.2;
Fix Realtek RTL8125 description
 1.1425 02-Apr-2021  rin PDC20265 is Ultra/100, not 66.
 1.1424 30-Jan-2021  jmcneill branches: 1.1424.2;
Add some more product IDs for mcx(4)
 1.1423 29-Dec-2020  skrll Sort Cavium devices
 1.1422 29-Dec-2020  skrll Trailing whitespace
 1.1421 20-Nov-2020  msaitoh Add newer Intel PCH internal devices.
 1.1420 19-Nov-2020  reinoud Add modern QUMRANET/Red Hat VIRTIO range PCI devices
 1.1419 14-Jul-2020  jdolecek branches: 1.1419.2;
add newer ciss(4) devices, list obtained from FreeBSD
 1.1418 09-Jul-2020  msaitoh Remove duplicated entry.
 1.1417 24-Jun-2020  thorpej Add a couple of additional device IDs for the AMD Cryptographic Coprocessor.
 1.1416 13-Jun-2020  ryo add ASIX AX99100 Multi I/O (Serial,Parallel,I2C,SPI,LocalBus,GPIO) Controller
 1.1415 11-Jun-2020  jdolecek add Intel XMM 7360 LTE Modem
 1.1414 26-May-2020  martin Add RTL8192EE Wireless LAN 802.11n PCI-E NIC
 1.1413 01-May-2020  jmcneill Add IDs for Ampere eMAG PCIe Root Ports
 1.1412 23-Apr-2020  msaitoh Remove duplicated entry.
 1.1411 22-Apr-2020  christos Add AQUANTIA AQC100 from Andrius V.
 1.1410 22-Apr-2020  prlw1 Add an eclectic mix of
GeForce GTX 680, RTS522A PCI-E Card Reader, intel wifi 9560
+ whitespace
 1.1409 22-Apr-2020  msaitoh Add Intel Whiskey Lake U and Amber Lake Y devices.
 1.1408 22-Apr-2020  msaitoh Add Aquantia AQC100, AQC100S and D100.
 1.1407 18-Apr-2020  simonb Add ATI Radeon R5/R6/R7 Graphics.
 1.1406 16-Apr-2020  msaitoh - Add some Intel UHD Graphics devices. Mainly taken from OpenBSD.
- Add Comet Lake devices.
- Modify description of Intel 0x591e from HD Graphics to UHD Graphics.
- Add Western Digital WD Blue SN550 NVMe SSD
 1.1405 10-Apr-2020  christos Fix typo
 1.1404 07-Apr-2020  christos branches: 1.1404.2;
Add more RDC products (Andrius V)
 1.1403 01-Apr-2020  msaitoh Add NVIDIA Quadro NVS 295.
 1.1402 11-Mar-2020  msaitoh Add some GeForce devices.
 1.1401 11-Mar-2020  fcambus Add device IDs of the VIA VX900 chipset.
 1.1400 08-Mar-2020  msaitoh NVIDIA 0x036[0-7] are nForce MCP55 LPC Bridge.
 1.1399 05-Mar-2020  msaitoh Add Farallon PN9000SX Ethernet.
 1.1398 19-Feb-2020  mrg add a couple of GPUs i have:

product ATI RADEON_HD4290 0x9714 Radeon HD4290 Graphics
product NVIDIA GF_440 0x0de0 GeForce GT 440
 1.1397 28-Jan-2020  msaitoh Remove duplicated entries.
 1.1396 21-Jan-2020  msaitoh Add Intel I219 LM10-LM15 and V10-V14 from OpenBSD.
 1.1395 01-Jan-2020  ryo branches: 1.1395.2;
add Aquantia AQC 10G network adapters
 1.1394 29-Dec-2019  sevan Killer E3000
from OpenBSD
 1.1393 18-Dec-2019  msaitoh Add AMD Family14h PCIe.
 1.1392 27-Nov-2019  msaitoh - Add Xeon D-1500 NTB-secondary
- Add Xeon D NS QuickData DMA channel 0-7
 1.1391 14-Nov-2019  msaitoh Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.
 1.1390 08-Nov-2019  msaitoh - Update Intel's NVMe SSDs.
- Modify 0x0953's description to "750 or DC P3[567]00 SSD"
- Add DC P4[56]00
- Add Apollo Lake TXE HECI.
 1.1389 29-Oct-2019  msaitoh Add Realtek RTL8125.
 1.1388 12-Oct-2019  skrll Spell controller correctly
 1.1387 21-Sep-2019  msaitoh Add Killer E2400 and E2500.
 1.1386 21-Sep-2019  msaitoh Modify Attansic Ethernet devices' description to clarify.
 1.1385 24-Aug-2019  jmcneill Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex
 1.1384 21-Aug-2019  mrg add micron/crucial SM2263 nvme.
add some device found on asus x570-p with ryzen 3200G cpu.
spell it "PCIe' when using the name.
 1.1383 28-Jul-2019  mlelstv branches: 1.1383.2;
Add BCM2711 PCIe Host bridge for RPI4
 1.1382 24-Jul-2019  msaitoh - Add some AMD devices mainly taken from OpenBSD.
- Rename some device names for consistency.
- Use _HDA for HD Audio.
 1.1381 18-Jul-2019  msaitoh - Intel C620 Virtual Switch Port for Termal Sensor is not 0x37c6 but 0x37c7.
- Add Some AMD Ryzen 3xxx's devices.
 1.1380 12-Jul-2019  msaitoh Fix previous (s/1000/1100/).
 1.1379 12-Jul-2019  msaitoh Add some ServerWorks HT1100 devices from OpenBSD.
 1.1378 09-Jul-2019  msaitoh Add Phison PS5000 and PS5016 NVMe.
 1.1377 05-Jul-2019  msaitoh Add some Intel Whisky Lake devices.
 1.1376 02-Jul-2019  msaitoh Modify some descriptions of Virtio devices from OpenBSD to identify the
functions.
 1.1375 04-Jun-2019  msaitoh Update some Intel ixgbe devices:
- Add Xeon D XFI.
- Add "(Hyper-V)" to 0x15a9's description.
- Add C3000 QSFP devices.
 1.1374 01-Jun-2019  jdolecek rename VT8237S_SATA_2 to VT8237S_SATA_RAID and update description to have
different one to VT8237S_SATA

part of PR kern/43309
 1.1373 30-May-2019  mlelstv add IDs for SATA controllers VT8237S and VX855
 1.1372 15-Apr-2019  msaitoh Avoid duplication.
 1.1371 15-Apr-2019  msaitoh - Add some Intel Xeon Scalable processor's devices.
- Add Some Qlogic devices from OpenBSD.
- Rename Qlogic 0x3022's name from ISP3022 to ISP4022.
 1.1370 12-Apr-2019  msaitoh - Add some new C620 LPC devices.
- Remove extra white spaces.
 1.1369 11-Apr-2019  mrg fix a couple of errors in the previous.
 1.1368 11-Apr-2019  mrg add a bunch of PCI devices on my systems, and a bunch of similar
ones found in the same sources online (mostly, Intel, AMD, Nvidia
and ASMedia web sites.) this includes:

- bunch of xeon e5 v3 devices
- bunch of radeon chipsets
- bunch of nvidia chipsets
- bunch of marvell chipsets
- bunch of asmedia chipsets

be more consistent with device naming within some groups.
 1.1367 08-Mar-2019  msaitoh - Add other two Core 8G host bridges.
- Add Intel Xeon E devices.
 1.1366 05-Mar-2019  msaitoh Add Intel I219 variations for Cannon Lake.
 1.1365 20-Feb-2019  msaitoh Add SK-NET SK-9Mxx Gigabit Ethernet.
 1.1364 20-Feb-2019  msaitoh Add some Broadcom Ethernet devices from {Open,Free}BSD.
 1.1363 14-Feb-2019  msaitoh Add Tundra (now IDT) TSI381 and PEB383 from OpenBSD.
 1.1362 08-Feb-2019  msaitoh - Add Some Freescale MPC834x devices from OpenBSD.
- Add Intel I210 SGMII Flash-less device from the spec update document.
 1.1361 06-Feb-2019  msaitoh From OpenBSD:
- Add NetXen's vendor ID and devices.
- Add Sun Neptune.
 1.1360 28-Jan-2019  msaitoh Add AMD Family 17h devices from OpenBSD.
 1.1359 26-Jan-2019  msaitoh Add some RADEON devices. Mainly taken from OpenBSD.
 1.1358 21-Jan-2019  msaitoh Marvell 0x4365 is 88E8070.
 1.1357 26-Dec-2018  msaitoh Add yet another Intel Core QuickPath Generic Non-Core Register.
 1.1356 03-Dec-2018  bouyer Add 2 Symbios products, from OpenBSD
 1.1355 29-Nov-2018  jmcneill Add Amazon.com UART, NVMe, and ENA PCI IDs.
 1.1354 24-Nov-2018  skrll Add Rockchip vendor ID and a device. Requested by jak@

From OpenBSD
 1.1353 24-Nov-2018  skrll Add a whole bunch of Cavium ThunderX devices
 1.1352 12-Nov-2018  msaitoh Add some Intel 100 series and C230 series devices.
 1.1351 08-Nov-2018  msaitoh "s/ are are / are /" in comment. No functional change.
 1.1350 08-Nov-2018  msaitoh Add two otehr I2C devices of Intel.
 1.1349 16-Oct-2018  jmcneill Add AMD Seattle Host Bridge and PCIE root port devices
 1.1348 15-Oct-2018  uwe Adaptec RAID 2445 and 2805
 1.1347 23-Aug-2018  msaitoh - Add C62x to the descriptions of Intel C620 series devices.
- Add 0xa1ca for Intel C629 LPC or eSPI.
 1.1346 30-Jul-2018  msaitoh Add Toshiba's XG4 and XG5 NVMe SSD.
 1.1345 30-Jul-2018  msaitoh Add some Intel devices. Some of them are found in Core i7-8550U.
 1.1344 06-Jul-2018  prlw1 Add Western Digital (Sandisk) WD Black NVMe SSD as per suggestion
from thorpej@
 1.1343 20-Jun-2018  msaitoh branches: 1.1343.2;
Add nSYS Technologies.
 1.1342 14-Jun-2018  msaitoh Add Mobility Radeon HD 4300(0x9552) and Mobility Radeon HD 4500(0x9553)
from OpenBSD.
 1.1341 12-Jun-2018  jdolecek add two more Yukon variants (from OpenBSD)
 1.1340 09-Jun-2018  jdolecek small sync of Marvell Yukon PCI product ids with OpenBSD - add 8048 variant, rename
YUKON_1 to YUKON_8070

also adjust description for YUKON_8055_2 to have "88E8055-2" just so that it shows
up differently
 1.1339 31-May-2018  mrg add a bunch of nvidia devices from various generations.
 1.1338 31-May-2018  msaitoh - Add some Intel 82965 devices.
- Change Intel 0x2a06 from IDE to IDER
 1.1337 28-May-2018  msaitoh Add some Intel 4 series chipset devices.
 1.1336 26-May-2018  jakllsch Add Intel 82Q45 IDER
 1.1335 24-May-2018  msaitoh Add some Marvell Yukon devices.
 1.1334 21-May-2018  jnemeth add Oxford Semiconductor OXPCIe954 PCIe 4-port serial card
 1.1333 03-May-2018  maya Add some broadcom 802.11ac wifi devices
 1.1332 28-Apr-2018  mlelstv Add Symbios/LSI RAID and SAS controllers.
 1.1331 24-Apr-2018  maya add realtek RT525A PCI-E card reader

found in my Dell XPS 15 9550.
 1.1330 17-Apr-2018  nonaka Added some NVMe devices.
 1.1329 16-Apr-2018  msaitoh Add Intel SSD 760p.
 1.1328 16-Apr-2018  msaitoh Add some 8th Generation Intel Core Processor devices.
 1.1327 09-Apr-2018  msaitoh Add new I219 devices (using with 300 series chipset).
 1.1326 09-Apr-2018  msaitoh Add Intel 300 series devices.
 1.1325 04-Apr-2018  msaitoh Add Intel Coffee Lake internal graphics devices. From ark.intel.com.
 1.1324 02-Apr-2018  msaitoh Add Intel X299 and Z370 LPC.
 1.1323 31-Mar-2018  sevan What we have listed as the PowerBook G3 Firwire device is actually the UniNorth
Firwire interface which is not exclusive to the PowerBook G3.
It can be found in the G3 iMac DV for example
http://dmesgd.nycbug.org/index.cgi?do=view&id=1124

Rename the PBG3_FW device UNINORTH_FW & set the previously listed UNINORTH_FW to
UNINORTH2_FW which is what the device actually is.

Verified using https://pci-ids.ucw.cz/read/PC/106b
 1.1322 26-Mar-2018  msaitoh Add two VIA xHCI devices from OpenBSD.
 1.1321 20-Mar-2018  nonaka Add Intel Wireless AC 9260.
 1.1320 16-Mar-2018  msaitoh Intel 0x15c4 is SFI based and 0x15ce is KR based.
 1.1319 04-Mar-2018  jdolecek branches: 1.1319.2;
according to VT82C686A chip specs, the VIA Technologies device 0x3057
is more a Power Management controller, rename the pcidevs entry and device
macro

PR kern/31963 by Nicolas Joly
 1.1318 04-Mar-2018  jdolecek apply some updates and recommended corrections to pcidevs descriptions

PR kern/45733 by Greg A.Woods
 1.1317 02-Mar-2018  msaitoh Add Intel Gemini Lake devices.
 1.1316 24-Feb-2018  mlelstv Add AMD KERNCZ chipset for Zen processors.
 1.1315 22-Feb-2018  msaitoh Add some Xeon E5 (v1) and E5 v2 devices.
 1.1314 22-Feb-2018  msaitoh s/C62x9/C62x/
 1.1313 22-Feb-2018  msaitoh Fix C62x9 sSATA Controller (RAID) device ID.
 1.1312 22-Feb-2018  msaitoh Add C620 devices.
 1.1311 21-Feb-2018  msaitoh Add some Intel Ethernet devices.
 1.1310 21-Feb-2018  msaitoh Add some ServerEngines (Emulex) products from OpenBSD.
 1.1309 17-Feb-2018  sevan grammar
 1.1308 16-Feb-2018  sevan Add Nvidia GeForce 9400M as found in the late 2009 13" MacBook (MacBook6,1)
 1.1307 25-Jan-2018  sborrill Add Marvell Yukon 88E8040T
 1.1306 24-Jan-2018  sevan Add Nvidia GeForce FX Go5200, as found in the PowerBook6,4
 1.1305 21-Jan-2018  sevan Add the GeForce4 MX440 Go, as found on the 17" flat panel G4 iMac (PowerMac4,5).

Thanks to Jasper Wallace <jasper AT pointless DOT net> for the loan of the hardware.
 1.1304 09-Jan-2018  msaitoh Add Intel Apollo Lake devices.
 1.1303 09-Jan-2018  msaitoh - s/MMC/eMMC/ for Intel 0x0f14 (Bay Trail)
- Add Atom E3800 (Bay Trail) eMMC 4.5
 1.1302 18-Dec-2017  msaitoh Add some Chelsio devices.
 1.1301 09-Nov-2017  msaitoh Add PEX 8605 4port 4lane PCIe Gen 2 switch.
 1.1300 30-Oct-2017  sevan Add Areca ARC1214 & ARC1880.
From OpenBSD.
 1.1299 20-Oct-2017  christos update entry for Marvel Yukon 8058, and fix URL for pci ids (Rocky Hotas)
 1.1298 15-Sep-2017  hikaru Add Intel QuickAssist devices.
 1.1297 17-Aug-2017  msaitoh Add C3000 devices.
 1.1296 02-Aug-2017  msaitoh PCI device ID of Atom x5-Z8350's video is 0x22b0. ark.intel.com says 0x22b0 is
Intel HD Graphics 400.
 1.1295 26-Jul-2017  msaitoh Add Intel 5520/X58 QuickPath from OpenBSD.
 1.1294 22-Jul-2017  msaitoh - Add some AMD devices.
- Add Broadcom BCM5762.
 1.1293 07-Jul-2017  msaitoh Add Atom Z8000 devices from "Intel Atom Z8000 Processor Series Datasheet
(Volume 2 of 2)".
 1.1292 04-Jul-2017  msaitoh Add Intel 82Q965 HECI.
 1.1291 17-Jun-2017  jdolecek add entry for Adaptec 1220SA
 1.1290 06-Jun-2017  msaitoh - Change VMware's 0x0770 from "Virtual USB" to "Virtual EHCI"
- Add VMware's 0x0774(UHCI) and 0x0778(xHCI)
 1.1289 23-May-2017  nonaka branches: 1.1289.2;
Add some AMD entries.
 1.1288 08-May-2017  msaitoh - Add RICOH R5C576 SD Card Controller.
- Add some SiS devices. Taken from OpenBSD.
- Change SiS 0x6325 from 6325 AGP VGA to 650 AGP VGA.
 1.1287 27-Apr-2017  msaitoh - Add some Pericom (Diodes) devices.
- s/P17C9/PI7C9/
 1.1286 19-Apr-2017  msaitoh branches: 1.1286.2;
Add BCM4401 B0 step. Old BCM4401 B0 entry is changed to B1. From OpenBSD.
 1.1285 13-Apr-2017  msaitoh Add Broadcom BCM577x5 SDMMC, Memstic and xD.
 1.1284 31-Mar-2017  skrll Fix BCM4727 entry
 1.1283 31-Mar-2017  msaitoh - Add BROADCOM BCM4313 802.11b/g/n
- Add Intel's another Pineview Integrated Graphics Device
- Add Realtek RTS5208 PCI-E Card Reader
 1.1282 23-Mar-2017  msaitoh Add Huawei Hi1710 BMC
 1.1281 14-Mar-2017  nonaka Added Intel Wireless 3168 entry.
 1.1280 27-Feb-2017  msaitoh Add some NVIDIA devices.
 1.1279 16-Jan-2017  msaitoh Add Intel SSD DC P3520.
 1.1278 15-Jan-2017  msaitoh branches: 1.1278.2;
Add Intel 200 series chipset devices from "Table 2-2. PCH-H Device and
Revision ID Table, Intel 200 Series Chipset Family Platform Controller
Hub(PCI) Datasheet Volume 1 of 2 (335192-001)".
 1.1277 15-Jan-2017  msaitoh Add Core 7G devices from "7th Generation Intel Processor Families for
{S, U/Y, H} Platforms Datasheel Volume 2 of 2" (S: 335196-001, U/Y: 334662-002,
H: 335191-001). For 0x5906 (U processor, HD Graphics 610), it's taken from
ark.inte.com.
 1.1276 10-Jan-2017  nonaka Add Intel Dual Band Wireless 8265 entry.
 1.1275 27-Dec-2016  msaitoh Add some Radeon devices. Mainly taken from OpenBSD.
 1.1274 26-Dec-2016  msaitoh 0x10cb is not 82801H(ICH8) but 82801I(ICH9).
 1.1273 01-Dec-2016  msaitoh - Add more Intel 10G devices
- indent
 1.1272 23-Nov-2016  christos one more atheros device
 1.1271 28-Oct-2016  msaitoh - Add some Core i7-800 and i5-700 devices from "Intel Core i7-800 and i5-700
Desktop Processor Series Datasheet - Volume 2" (Document Number 322910-003).
- Change some descriptions of Core i5-600 and i3-500 devices.
 1.1270 26-Oct-2016  msaitoh i82567V-3 is not ICH9 but ICH8.
 1.1269 24-Oct-2016  msaitoh Add Xeon E7 v4 devices from "Intel Xeon Processor E7 v4 Product Famliy
Datasheet Volume 2: Registers".
 1.1268 20-Oct-2016  msaitoh Add newer I219 devices.
 1.1267 19-Oct-2016  msaitoh Add Xeon 5[56]00 devices from
"Intel Xeon Processor 5500 Series Datasheet, Volume 2" and
"Intel Xeon Processor 5600 Series Datasheet, Volume 2"
 1.1266 04-Oct-2016  kiyohara Add Marvell 88AP510.
 1.1265 16-Sep-2016  msaitoh - Add ASMEDIA ASM1083/1085/1142
- Add AMD RADEON 34xx HD Audio
- Add some Intel Core i7-6xxxK devices from "Intel Core i7 Processor Family
for LGA2011-v3 Socket Datasheet - Volume 2 of 2: Registers"
- Add "Core i7-6xxxK" to some Intel devices' description.
 1.1264 01-Sep-2016  msaitoh Add some 1st gen Core PCI devices. Mainly taken from "Intel Core, Pentium
Desktop Processor Series: Datasheet, Vol. 2"
 1.1263 23-Aug-2016  msaitoh Fix:
- ATI 0x4394 is AHCI SATA.
- ATI 0x4395 is Storage mode SATA.
 1.1262 23-Aug-2016  msaitoh Fix XE5_V3_IMC1_DDRIO_[34]'s values.
 1.1261 23-Aug-2016  msaitoh - Fix entries. The following problems were found while sorting entries:
- Remove the following entries because the value is duplicated:

CMDTECH_240 (CMDTECH_AAR_1210SA has the same value)
INTEL_C610_SATA_RAID (INTEL_82801H_SATA_RAID has the same vaule)
INTEL_C610_PCIE_1_3 (82801BA_HPB has the same value)
GEFORCE_610M3 (GEFORCE_610M2 has the same value)

- RADEON_RV350_NQ is not 0x4e41 but 0x4e51
- 82801JD_SATA_RAID is not 0x3a02 but 0x3a05.

- The following two entries have the same number. Fix one of them:

DH89XXCL_USB_2 to 0x23b5 (was 0x23b4 (== DH89XXCL_USB_1))
5500_HB to 0x3404 and change the desc (was 0x3403 (== 3400_HB))
82X58_PCIE_0_1 to 0x3421 (was 0x3420 (== 82X58_PCIE_0_0))
82801JI_THERMAL to 0x3a32 (was 0x3a30 (== 82801JI_SMB))

- Sort entries in device ID's order.
 1.1260 19-Aug-2016  msaitoh Add more Xeon D devices.
 1.1259 17-Aug-2016  msaitoh Update Skylake devices.
 1.1258 17-Aug-2016  msaitoh Add Xeon D devices.
 1.1257 08-Aug-2016  msaitoh Add some Xeon E5 v3 devices.
 1.1256 29-Jul-2016  nonaka Add MegaRAID SAS3008
 1.1255 28-Jul-2016  nonaka Add Super Micro Computer Inc
 1.1254 28-Jul-2016  nonaka sort by vendor id.
 1.1253 06-Jul-2016  christos branches: 1.1253.2;
more ral products
 1.1252 27-Jun-2016  pgoyette Add a couple more devices, from PR kern/40987
 1.1251 01-Jun-2016  pgoyette Add Intel 82597EX_SR, from PR kern/47750
 1.1250 30-May-2016  nonaka Added some Intel wireless devices from OpenBSD.
 1.1249 27-Apr-2016  christos more ral devices from OpenBSD
 1.1248 26-Apr-2016  msaitoh Add devices from "6th Generation Intel Processor Families I/O Platform
Datasheet (U/Y-Processor platform) Volume 1 of 2"
 1.1247 12-Feb-2016  mrg add several NVIDIA geforce and NVS cards.
 1.1246 01-Feb-2016  msaitoh - s/82081/82801/ from OpenBSD.
- 0x2829 is SATA. 0x282a is RAID.
 1.1245 22-Jan-2016  msaitoh Add anoter new I219-LM.
 1.1244 01-Dec-2015  msaitoh Add Intel 100 series chipset devices from "Table 2-1. PCH-H Device and
Revision ID Table, Intel 100 Series Chipset Family Platform Controller
Hub(PCI) Datasheet".
 1.1243 01-Dec-2015  msaitoh Add Intel Core 6G devices from datasheets.
 1.1242 16-Nov-2015  msaitoh Change macro name of Braswell PCU SMBus.
 1.1241 16-Nov-2015  msaitoh Add Braswell devices from "Table 23-4 PCI Devices and Functions,
N-Series Intel Pentium Processorts and Intel Celeron Processors Datasheet
(Document Number: 332093-001)"
 1.1240 06-Nov-2015  nonaka Add some ATI/AMD devices.
 1.1239 22-Oct-2015  msaitoh Add some entries from Intel 965 Express Chipset Family Datasheet.
 1.1238 21-Oct-2015  nonaka Add Samsung SM951 M.2 NVMe SSD.
 1.1237 19-Oct-2015  tnn fix I219_LM2 entry
 1.1236 19-Oct-2015  tnn add I219 family Ethernet devices
 1.1235 28-Aug-2015  nonaka Add Intel Dual Band Wireless AC 3165.
 1.1234 27-Aug-2015  nonaka Added Realtek RTL8192CE.
 1.1233 26-Aug-2015  msaitoh Add Intel PCIe NVMe SSD.
 1.1232 23-Aug-2015  jakllsch Add another ID for Intel 82Q45 KT
 1.1231 14-Aug-2015  nonaka Added ASMedia ASM1042A USB 3.0 Host Controller.
 1.1230 14-Aug-2015  knakahara Add Marvell Armada38x.
 1.1229 13-Aug-2015  msaitoh Add some Red Hat devices.
 1.1228 26-Jun-2015  msaitoh Add PLX Technology PEX 8111.
 1.1227 02-Jun-2015  nonaka fix typo. s/Wirelsss/Wireless/
 1.1226 16-May-2015  msaitoh Add some Intel Core 5G devices and Realtek RTL8188EE.
 1.1225 13-May-2015  nonaka Added Qualcomm Atheros QCA986x/988x.
 1.1224 11-May-2015  msaitoh Add Samsung SM951.
 1.1223 09-May-2015  christos PR/49889: Maxim Tsyplakov: support for D-Link DFE520TX
 1.1222 04-May-2015  ryo add SystemBase SB16C1050 UARTs
 1.1221 03-May-2015  msaitoh Add some NVIDIA devices.
 1.1220 02-Apr-2015  tnn Mobile 5th Generation Intel Core devices, from intel doc #330837-004
 1.1219 20-Mar-2015  msaitoh Add MegaRAID SAS3108
 1.1218 20-Mar-2015  msaitoh Add Xeon E5 v3 and C61x devices.
 1.1217 18-Mar-2015  msaitoh Add some Intel 9 series devices.
 1.1216 04-Mar-2015  knakahara add nForce Host Bridges.
 1.1215 15-Feb-2015  msaitoh Add some devices:
- Radeon HD 54xx Audio
- Dell DARC 4 devices
- Some Intel IOP332 devices
- Intel 63xxESB AC'97 Audio Controller
- Some Intel E7520 devices
 1.1214 25-Jan-2015  msaitoh - Add another HP vendor ID (was 3PAR)
- Add two PLX PCI Bridges.
 1.1213 18-Jan-2015  christos PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets
 1.1212 16-Jan-2015  msaitoh Add some devices
- Add COMPAQ iLOs.
- Add HP IPMI device.
- Add some Intel devices.
- Fix product ID of INTEL 5000_PCIE_4.
- Add some VIATECH devices.
 1.1211 14-Jan-2015  msaitoh Sort VIATECH's entries in the device ID's order.
 1.1210 31-Dec-2014  veego Add two Intel 9 Series devices
 1.1209 23-Dec-2014  msaitoh Add some Intel 10/40G devices.
 1.1208 17-Dec-2014  hikaru Add QuickAssist Virtual Function Device IDs
 1.1207 15-Dec-2014  msaitoh - Rename DH89xxCC's names from DH89XX_ to DH89XXCC_.
- Add some DH89xxCC's devices.
- Add DH89XXCL's devices.
 1.1206 15-Dec-2014  msaitoh Change Intel 0x0434 entry:
- Rename DH89XX_QA to DH89XXCC_IQIA
- Modify the description to DH89xxCC PCIe Endpoint and QuickAssist
(include typo fix)
 1.1205 30-Oct-2014  nonaka branches: 1.1205.2;
Add some Intel Wi-Fi devices.
 1.1204 29-Oct-2014  nonaka Add Realtek RTL8402 PCI-E Card Reader.
 1.1203 01-Oct-2014  msaitoh Add Intel Atom Z36xx and Z37xx devices from the datasheet.
 1.1202 25-Sep-2014  msaitoh - Add some Intel gigabit Ethernet devices.
- Remove trailing white spaces.
 1.1201 16-Sep-2014  msaitoh Add some new Intel I218 devices.
 1.1200 01-Sep-2014  msaitoh Add Samsung Electronics XP941 M.2 SSD
 1.1199 30-Jul-2014  msaitoh branches: 1.1199.2;
Add Intel Xeon E3-1200 v3 Host Bridge, DRAM.
 1.1198 25-Jul-2014  msaitoh Add some Intel Core internal devices.
 1.1197 08-Jul-2014  msaitoh Add some RDC devices.
 1.1196 03-Jul-2014  msaitoh Add some Intel X38 devices.
 1.1195 02-Jul-2014  msaitoh Add Intel DH89xx devices.
 1.1194 23-Jun-2014  msaitoh Add some HP iLO devices.
Add Matrox MGA G200eH.
 1.1193 09-Jun-2014  msaitoh Add some devices:
- Add Intel Bay Trail devices from the document.
- Add Intel EP80579 devices from OpenBSD.
- Add Intel DH89xx's SMBus controller.
- Add ASPEED AST1150 PCIe-to-PCI bridge.
 1.1192 30-May-2014  msaitoh Add Intel 3200 Host and PCIe.
 1.1191 28-May-2014  msaitoh - Add some Intel devices (Sandy Bridge, 6702PXH, X38 and Pineview)
- Add ITE IT8213
 1.1190 28-May-2014  msaitoh Add Intel X540-AT2.
 1.1189 25-May-2014  njoly Add GeForce GT 640M.
 1.1188 26-Apr-2014  mrg add some new Attansic ethernet devices (but no driver)
 1.1187 09-Apr-2014  msaitoh Add yet another 82599 device
 1.1186 09-Apr-2014  msaitoh - Add some Ivy Bridge devices from the document.
- sort by device ID.
 1.1185 07-Apr-2014  njoly Add Intel Ivy Bridge PCI Express Root Port
 1.1184 15-Mar-2014  kiyohara branches: 1.1184.2;
Add some Armada 370 IDs.
 1.1183 14-Feb-2014  njoly Add GeForce 210 High Definition Audio Controller.
 1.1182 26-Jan-2014  msaitoh Add some OXPCIe952 devices.
 1.1181 21-Jan-2014  msaitoh Rename MARVELL2's 0x91a3 entry to 88SE91XX.
 1.1180 10-Jan-2014  msaitoh Rework for Marvell 88SE9128. Change the description of 0x9123 to
88SE912[38]. For 0x91a3, add '(unclear)' into the description.
FreeBSD, Linux and http://pci-ids.ucw.cz have no such device.
 1.1179 09-Jan-2014  christos revert unintended changes
 1.1178 09-Jan-2014  msaitoh Remove 88SE9128(0x913a) entry. At least one of 88SE9128 chip's
product ID is 0x9123. I have this one. Add new 88SE912X entry
with 0x9123. OK'ed by jakllsch.
 1.1177 04-Jan-2014  msaitoh Add Intel Z68 LPC
 1.1176 01-Jan-2014  msaitoh Change description from ASPEED2000 to ASPEED Graphics Family because
the IP is used on AST1000,2050 and 2100, too.
 1.1175 30-Dec-2013  msaitoh Add ASPEED AST2000.
 1.1174 27-Dec-2013  msaitoh Add some Marvell 88SE9xxx devices.
 1.1173 25-Dec-2013  msaitoh Add DIGI Neo 8-port serial(PCIe) and OXFORD OXPCIe952 Parallel.
 1.1172 23-Dec-2013  msaitoh Add Intel C2000 devices.
 1.1171 22-Dec-2013  nonaka Added some Realtek devices.
 1.1170 21-Dec-2013  msaitoh Add some Intel E600 and EG20T devices.
 1.1169 15-Dec-2013  pgoyette Add ASMedia ASM1042 xHCI USB3 controller
 1.1168 13-Dec-2013  pedro Add entries for Atheros AR9462 and a new flavour of Intel Haswell
Integrated Graphics Device; OK rmind@ mbalmer@
 1.1167 12-Dec-2013  nonaka Added Radeon HD6320 Graphics.
 1.1166 08-Dec-2013  msaitoh Add devices of Atom S1200 series from the datasheet
(Table 2-1 Local PCI Hierarchy, datasheet Volume 2 of 2).
 1.1165 13-Nov-2013  msaitoh Add Intel I347-AT4
 1.1164 07-Nov-2013  msaitoh Add Quark X1000 devices.
 1.1163 07-Nov-2013  msaitoh Add some Intel devices. Mainly taken from "Mobile 4th Generation Intel Core
Processor Family I/O" datasheet (Document number: 329003)
 1.1162 14-Sep-2013  soren Update some AMD/ATI chipset names.
Add Renesas USB 3.0 controllers.
 1.1161 04-Sep-2013  christos PR/48180: Christian Groessler: Support for Oxford Semi OXuPCI952 dual serial
PCI card
 1.1160 23-Aug-2013  christos PR/48150: Noriyuki Koizumi: Add support for Intel Centrino Advanced-N 6235
Wi-Fi controller
 1.1159 17-Jul-2013  soren Extend support for Nanjing QinHeng Electronics puc(4) devices.
 1.1158 13-Jun-2013  matt branches: 1.1158.2; 1.1158.4;
Add ATI RADEON_HD7340
 1.1157 05-Jun-2013  msaitoh Add some Intel devices from the following datasheets:
- Desktop 4th Generation Intel Core Processor Family Datasheet Volume 2 of 2
- Mobile 4th Generation Intel Core Processor Family Datasheet Volume 2 of 2
- Intel Xeon Processor E3-1200 v3 Product Family Datasheet Volume 2 of 2
 1.1156 04-Jun-2013  msaitoh Add some Intel devices from document (Intel 8 Series / C220 Chipset
Family Platform Controller Hub (PCH) Datasheet)
 1.1155 03-Jun-2013  msaitoh Add Intel 8 Series KT.
 1.1154 20-Apr-2013  rkujawa Add IDs for Marvell Armada XP.

Obtained from Marvell, Semihalf.
 1.1153 18-Apr-2013  msaitoh Fix cut & paste bug in some I210 series.
 1.1152 18-Apr-2013  msaitoh Add Intel I21[0178] Ethernet.
 1.1151 06-Mar-2013  msaitoh Add ALTIMA AC1003, BROADCOM BCM57782 and BCM57786.
 1.1150 03-Mar-2013  msaitoh BCM5785F is not gigabit Ethernet.
 1.1149 27-Feb-2013  msaitoh - Add APPLE BCM5701
- Add BROADCOM BCM57766
- BCM5719 is not 10G but 1G
 1.1148 20-Feb-2013  msaitoh - Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and BCM5719.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for the
pre-product and not released to public.
 1.1147 30-Jan-2013  msaitoh Change from "3400 USB" to "3400 USB EHCI" for EHCI devices.
 1.1146 06-Dec-2012  msaitoh Update some Intel LPC devices
- Add 82801E LPC
- Add 82801GH LPC
- Update Intel 5 series and 3400 series LPC from document
(5-and-3400-chipset-specification-update)
- 0x3b14 is not 3400 but 3420
 1.1145 05-Dec-2012  christos Intel Atom E600 PCI-LPC bridge, adds a watchdog + HPET support. Tested
on a Soekris net6501. (jmcneill)
 1.1144 29-Nov-2012  msaitoh Update SMBus devices from Document(c600-series-chipset-spec-update and
x79-express-chipset-specification-update)
 1.1143 21-Oct-2012  matt Add more ASMEDIA 1061 variants.
 1.1142 20-Oct-2012  msaitoh Add SB600_USB_OHCI0 again. This was (accidentally) removed in rev. 1.1105
 1.1141 20-Oct-2012  matt Pull in changes from matt-nb5-mips64 (RMI & NETLOGIC).
 1.1140 19-Oct-2012  prlw1 Add Intel Centrino Wireless-N 2230
 1.1139 29-Sep-2012  gsutre Add Intel Ivy Bridge host bridge and integrated graphics device IDs,
from the Linux Intel AGP driver.
 1.1138 25-Sep-2012  gson Add Lava Computers SSERIAL-PCI single serial port adapter.
 1.1137 23-Sep-2012  chs add a bunch of devices.
 1.1136 18-Sep-2012  matt Fix tpyo.
 1.1135 17-Sep-2012  matt Add ASMEDIA ASM1061
 1.1134 17-Sep-2012  tsutsui Add Broadcom BCM57762 Gigabit Ethernet, per PR kern/46961.
 1.1133 13-Sep-2012  nonaka Added ALTERA EP4CGX15BF14C8N entry.
 1.1132 10-Aug-2012  bouyer branches: 1.1132.2;
Add some PCI AHCI controllers, from linux
 1.1131 07-Aug-2012  msaitoh Add some Intel's KT (Serial over LAN) devices.
 1.1130 06-Aug-2012  msaitoh Add 82GM45_KT for puc(4)
 1.1129 05-Aug-2012  msaitoh Add entries for puc(4) devices.
 1.1128 05-Aug-2012  bouyer Add LSI MegaRAID SAS2208
 1.1127 27-Jul-2012  matt Add EG20T PCH. Closes PR/45567.
 1.1126 26-Jul-2012  uwe Add VirtualBox ids.
 1.1125 25-Jul-2012  msaitoh Add some Intel devices from document (Intel 7 Series / C216 Chipset
Family Platform Controller Hub (PCH) Family Specification Update)

Modify some devices to clarify
 1.1124 23-Jul-2012  msaitoh Add some ATI and SIS devices.
Fixes PR#39580
 1.1123 23-Jul-2012  msaitoh Add some Intel 7 series devices.
 1.1122 22-Jul-2012  matt Add more FREESCALE devices
Fix RICOH RU5230 description
 1.1121 20-Jul-2012  msaitoh Add some Intel's devices.
 1.1120 19-Jul-2012  msaitoh Add XGI Technology's devices.
 1.1119 12-Jul-2012  kiyohara Add Marvell SoC 88F6282.
 1.1118 26-Jun-2012  drochner fix pci id for the Intel H61 LPC bridge to fit actual hardware (and
the chipset's documentation), and add some PCI-to-legacy bridges
found on recent boards
 1.1117 25-May-2012  msaitoh Add some Intel I350 Ethernet products.
 1.1116 18-Apr-2012  bouyer Add various newer LSI RAID/SAS controllers, from OpenBSD.
 1.1115 13-Apr-2012  cegger Add AMD Family15h ids
 1.1114 09-Apr-2012  mlelstv Add Intel Sandybridge integrated graphics
 1.1113 08-Apr-2012  jakllsch Make the RS690 entries more closely match the terminology of the RS690
RRG/RPR/BDG documents.
 1.1112 08-Apr-2012  jakllsch - NEC uPD720100A is USB2.
- Add NEC uPD720200, a USB3 Host Controller
 1.1111 08-Apr-2012  jakllsch Add IDs for Fresco Logic and their FL1000 and FL1009 xHCI chips.
Derived from OpenBSD.
 1.1110 07-Apr-2012  christos more broadcom stuff
 1.1109 04-Apr-2012  uwe Add Marvell Yukon 88e8040 ethernet.
 1.1108 28-Mar-2012  pgoyette Add JMB 362 (as found on ASUS M5A99X motherboard)
 1.1107 21-Mar-2012  sborrill Add some Symbios SAS2108 devices. Add new Symbios SAS2008 device (as used by
IBM ServeRAID M1015).
 1.1106 18-Mar-2012  tsutsui Add VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
 1.1105 03-Mar-2012  nonaka Added some AMD/ATI devices.
 1.1104 02-Mar-2012  nonaka Added Ricoh 5U822.
Rename Ricoh 5CE823 to 5U823.
 1.1103 02-Mar-2012  nonaka Added Ricoh 5CE823.
 1.1102 15-Feb-2012  tsutsui branches: 1.1102.2;
Add VIA VX900 Host Bridge, to handle its quirk. PR/46018
Ok releng@
 1.1101 18-Oct-2011  jmcneill branches: 1.1101.2; 1.1101.6;
add a couple vmware product IDs
 1.1100 06-Oct-2011  jmcneill add GeForce GTX 550 Ti
 1.1099 04-Oct-2011  njoly Add 3WARE 9750 Series RAID.
 1.1098 23-Sep-2011  njoly Add NVIDIA GeForce 210.
 1.1097 05-Sep-2011  msaitoh Change Intel 0x1229 product name from 82557 to 8255x
 1.1096 02-Sep-2011  msaitoh Add some fxp devices.
 1.1095 15-Aug-2011  msaitoh Sort lines.
 1.1094 11-Aug-2011  bouyer Add SiS 315 Pro VGA
 1.1093 09-Aug-2011  mbalmer Add the QUANCOM PWDOG1.
 1.1092 06-Aug-2011  jakllsch Add Marvell 88SE9128.
 1.1091 06-Aug-2011  jakllsch Adjust inconsistent whitespace in MARVELL products.
 1.1090 06-Aug-2011  mbalmer It's QUANCOM Electronic GmbH, not Quancm.
 1.1089 04-Aug-2011  jakllsch Add Conexant CX23885
 1.1088 23-Jul-2011  matt Add MARVELL2 vendor and 88SE9123 device.
 1.1087 28-Jun-2011  sborrill Add Nvidia GeForce 8500 GT
 1.1086 27-Jun-2011  nonaka Added some JMicron PCI-E SD/MMC/MS/xD Host Contollers.
 1.1085 07-Jun-2011  cegger add ATI Radeon Cypress and Lucent IEEE 1394b Controller
 1.1084 06-Jun-2011  msaitoh Rename 82801DB LPC Interface Bridge for consisitency.
 1.1083 28-May-2011  phx branches: 1.1083.2;
Renamed VT6410 to VT6410_RAID.
 1.1082 28-May-2011  phx Add VIA VT6410 ATA RAID controller.
 1.1081 28-May-2011  ryo add SystemBase SB16C1058 8 port serial cards
 1.1080 27-May-2011  matt Add ALI M5288 SATA/Raid Controller
 1.1079 22-May-2011  mrg add some fujitsu ethernet id's and a new vendor id. partly from
Michael Moll <kvedulv@kvedulv.de>, taken from openbsd.

XXX: move the #if 0'd usage of PCI_VENDOR_CITICORP inside the #if 0 code
XXX: region, as this id conflits with the (4th) fijutsi id.
 1.1078 21-May-2011  msaitoh Add some iwn(4) devices.
 1.1077 20-May-2011  msaitoh Add Intel 82567V, 82580 Quad-1000BaseX and Hanksvill with ICH10.
 1.1076 15-May-2011  msaitoh Add entries for Intel 6 series' devices.
 1.1075 14-May-2011  martin Add Nanjing QinHeng Electronics, from PR kern/44956.
 1.1074 13-May-2011  msaitoh add entries for 82579LM and 82579V
 1.1073 02-May-2011  manu Don't conflict SUNIX new vendor Id with the previous one
 1.1072 02-May-2011  manu Add new PCI vendor Id for Sunix, and the corresponding device Id.
 1.1071 13-Apr-2011  wiz + ATI Radeon HD4650.
 1.1070 04-Apr-2011  bouyer Add RDC PCI-ISA bridge
 1.1069 04-Apr-2011  bouyer Add rdcide(4), a driver for the IDE controller found in RDC's
vortex86/PMX-1000 system-on-chip.
 1.1068 16-Mar-2011  matt Add Freescale P2020/P2010 device ids
 1.1067 05-Mar-2011  matt Add ATHEROS AR2427 and AR9287
 1.1066 25-Feb-2011  jmcneill add AMD (ATI) Radeon HD 6310 Graphics ID
 1.1065 25-Feb-2011  jmcneill add AMD Family14h host bridge IDs
 1.1064 24-Feb-2011  matt Update desc for RT3090. Add Intel NM10_LPC
 1.1063 24-Feb-2011  matt Add RT3090
 1.1062 23-Feb-2011  jmcneill add Realtek RTL8188CE Wireless LAN 802.11n PCI-E NIC
 1.1061 22-Feb-2011  jmcneill Add Atheros AR8132, AR8151, AR8151 v2.0, AR8152 v1.1, and AR8152 v2.0
 1.1060 21-Feb-2011  njoly Add two more Intel 82Q45 devices.
 1.1059 20-Feb-2011  msaitoh Add MosChip(Netmos) 9904 and 9922.
Add MosChip(Netmos) 9865 (already supported by puc(4))
 1.1058 18-Feb-2011  jmcneill add Adaptec RAID 3405
 1.1057 03-Feb-2011  njoly Add a few Nvidia devices.
 1.1056 26-Jan-2011  bouyer Add RDC Semiconductor R6040 10/100 Ethernet
 1.1055 11-Jan-2011  dyoung branches: 1.1055.2; 1.1055.4;
Add Intel 82599 product IDs.
 1.1054 16-Dec-2010  cegger Brdige -> Bridge
 1.1053 11-Dec-2010  matt Add some more devices that I've encountered.
 1.1052 11-Nov-2010  cegger add AMD RD880, ATI Radeon HD5600, ATI Radeon HD4200 and Atheros AR9285
 1.1051 06-Nov-2010  jakllsch Add Intel SCH IDE Controller, from OpenBSD via Tomokazu HARADA in PR#42310.
 1.1050 14-Oct-2010  taca Remove duplicate entries:

* "vendor SYBATECH" exists as vendor SYBA.
* "product INTEL 82915G_IGD" simply duplicated.
 1.1049 26-Aug-2010  dogcow Add several Broadcom BCM43xx devices.
 1.1048 01-Aug-2010  msaitoh Add VScom PCI-200Li
 1.1047 30-Jul-2010  njoly Update ICH10 devices, from Intel I/O Controller Hub 10 datasheet
errata.
 1.1046 29-Jul-2010  njoly Adjust ICH10 watchdog timer entries which are really LPC interface
bridges. While here consistently use `xxx LPC Interface Bridge' for
Intel products.
 1.1045 29-Jul-2010  njoly Add Matrox MGA G200eW. From OpenBSD.
 1.1044 27-Jul-2010  msaitoh Add Quatech, System Base, Pcre Systems and Syba Tech.
 1.1043 13-Jul-2010  msaitoh Add Advantech PCI-1604
 1.1042 13-Jul-2010  kiyohara Add Marvell MV78100/MV78200 SoC. (Discovery Innovation)
 1.1041 08-Jul-2010  msaitoh - Add "vendor SYBA" and two cards.
- Add two Avlab cards.
- Add two Moxa cards.
- Add some VScom cards.
 1.1040 08-Jul-2010  msaitoh Add Advantech PCI-1610 and PCI-1612
 1.1039 07-Jul-2010  msaitoh 0x1409 is SUNIX
 1.1038 06-Jul-2010  msaitoh Fix the name of PCI-1620A-AE.
 1.1037 06-Jul-2010  msaitoh Add Advantech and Decision Computer's vendor IDs and their products.
 1.1036 02-Jul-2010  mrg add NetMOS 9901 PCI-E uart
 1.1035 16-Jun-2010  riz Add a bunch of Intel host bridge and integrated graphics device IDs,
from the Linux Intel AGP driver and PR#42906 from Henry Bent.
 1.1034 08-Jun-2010  pgoyette Add a couple entries for ATI Radeon 4250 HD
 1.1033 08-Jun-2010  mrg add two pciids for the satalink driver, from the linux driver, for PR#32577.
 1.1032 15-May-2010  jakllsch Add NetChip (now PLX) vendor ID, as well as NET228[02] device IDs.
 1.1031 12-May-2010  christos Use device names from the OpenBSD iwn driver, adding and modifying device
names as needed. From Sverre Froyen
 1.1030 10-May-2010  matt Add MARVELL 88SB2211 PCIe-PCI bridge
 1.1029 08-May-2010  pgoyette Add a couple more SMBus controllers. From FreeBSD.
 1.1028 07-May-2010  kiyohara Add Marvell MV64460.
Rename Marvell GT64360 to MV64360.
 1.1027 17-Apr-2010  christos add support for the 6000. From sverre froyen
 1.1026 02-Apr-2010  jakllsch Add Intel 82855GM Host-AGP Bridge.
 1.1025 14-Mar-2010  mrg branches: 1.1025.2;
add several core i7 devices, and some more ricoh card reader controllers.
 1.1024 25-Feb-2010  macallan add 3Dlabs Wildcat 5110, also known as Sun XVR-500
 1.1023 16-Feb-2010  msaitoh Add entries for 82576 and 82580
 1.1022 09-Feb-2010  hubertf Add entry for Juniper Networks Experimental Clock Version 0
Fixes PR kern/42742
 1.1021 09-Feb-2010  msaitoh Make some bge's name close to the real product names.
 1.1020 08-Feb-2010  msaitoh Add some MegaRAID Entries
 1.1019 03-Feb-2010  macallan branches: 1.1019.2;
add Apple PowerBook G3 Firewire controllers
 1.1018 30-Jan-2010  jakllsch Add Qumranet vendor and Virtio device IDs.
Also, sort some vendor entries.
 1.1017 24-Jan-2010  msaitoh Add BCM5717,5718,5723,5724,5787F,5761,5761E,5764,5761S,5761SE,5760,57788,
57780,57790,5784M,5785F,5785G,57761,57781,57791,57765,57785 and 57795.
 1.1016 21-Jan-2010  hubertf add/improve a few devices
 1.1015 19-Jan-2010  mbalmer Add two IBM RSS devices.
 1.1014 14-Jan-2010  sborrill Fix typo in (unused) vendor name
 1.1013 12-Jan-2010  msaitoh add i82567LM-2 i82567LM-4 i82567V-3 LAN controller
 1.1012 12-Jan-2010  msaitoh rename some wm devices to know PHY type
 1.1011 12-Jan-2010  nonaka Added RENESAS SH7780/SH7785 PCI Controller.
 1.1010 11-Jan-2010  msaitoh fix for i82577
 1.1009 07-Jan-2010  msaitoh Add PCH LAN and i82575
 1.1008 07-Jan-2010  jdc Add Sun Cassini/NS Saturn devices.
 1.1007 03-Jan-2010  jnemeth PR/42558 - Ryo ONODERA -- add entry for IO-DATA TV tuner card
 1.1006 29-Dec-2009  msaitoh add entry for i82583V
 1.1005 13-Dec-2009  matt Add RMI (NetLogic)
 1.1004 05-Dec-2009  dsl Correct what are clearly typos leading to duplicate vendor:product pairs.
Where possible values have been checked against the pcidatabase and x.org.
In some cases I've only commented on some dubious entries!
Values will be picked up by the next update.
Info from PR/36487
 1.1003 30-Nov-2009  sborrill Add Intel 3400 devices
 1.1002 21-Nov-2009  jakllsch Add CX700 and VX800/VX820 LPC bridge IDs.
 1.1001 18-Nov-2009  bouyer Complete BROADCOM BCM5709 family, and add BCM5716 family.
 1.1000 18-Nov-2009  jakllsch Drop unused/duplicate VIATECH VT8237_PCIB entry.
While here, drop "(Apollo KT600)" from VIATECH VT8237, and s/ISA/LPC/.
Additionally, add LPC Bridge ID for VT8251 from PR/37517.
 1.999 13-Oct-2009  cegger - replace 'Advanced Micro Devices' with 'AMD'.
Requested by jmcneill@
- remove duplicate printing of 'AMD' with the AMD HUDSON-2 chipset.
 1.998 13-Oct-2009  cegger AMD SB900 renamed to AMD HUDSON-2
 1.997 05-Oct-2009  cegger add SB900 IDE/SATA ids
 1.996 20-Sep-2009  christos PR/42100: Dave J. Barnes: Support for old toshiba PICCOLO IDE controllers.
 1.995 01-Aug-2009  matt Add Silicon Motion SM502
 1.994 07-Jul-2009  cegger correct product ids for RD890 chipset
 1.993 29-Jun-2009  hubertf add a few sdhc(4) devices
 1.992 12-Jun-2009  rjs Add some more Marvell devices.
 1.991 11-Jun-2009  cegger add ADP2, Marvell and Triones devices.
Taken from mvsata diff from Kiyohara Takashi, resolved apply conflicts.
 1.990 29-May-2009  skrll Add a bunch of HP stuff. From OpenBSD.
 1.989 18-May-2009  skrll Add more devices in my c3700.
 1.988 13-May-2009  cegger add RX780/RX790 chipset host bridge and Radeon X1600
 1.987 09-May-2009  sborrill Add alternative product ID for VIA VT8237A Integrated SATA Controller
 1.986 30-Apr-2009  skrll Add another NS product found in hppa machines.
 1.985 30-Apr-2009  skrll Add the National Semiconductor PC87560 Legacy IO chip on systems with
PA-8500 and later 64-bit CPUs.
 1.984 28-Apr-2009  ginsbach Add Mellanox Technologies Infiniband devices.
 1.983 25-Apr-2009  tsutsui Tweak some Realtek re(4) device names.
 1.982 07-Apr-2009  msaitoh add 82801J_D_BM_LF (ICH10)
 1.981 10-Mar-2009  msaitoh add i82567LF-3 LAN Controller
 1.980 28-Feb-2009  schwarz correct entry for Lucent 0x5802 into 2-port USB Host Controller
 1.979 26-Feb-2009  mjf Add Initio INIC-1622 SATA Controller.
 1.978 19-Feb-2009  sborrill Add Intel i82574L 1000baseT Ethernet as used in Pro/1000 CT Desktop adapter
 1.977 11-Feb-2009  markd Add more ICH9 SATA controller variants
 1.976 06-Feb-2009  jakllsch branches: 1.976.2;
Add TI PCIxx12-series product IDs.
 1.975 27-Jan-2009  markd Add Intel 82567LM_3 ethernet
 1.974 21-Jan-2009  jnemeth add a comment explaining how to regenerate pcidevs.h and pcidevs_data.h
 1.973 19-Jan-2009  jmcneill Attansic L1E Gigabit Ethernet Adapter
 1.972 07-Jan-2009  jnemeth fix typo in LUCENT ET1301
 1.971 27-Dec-2008  tsutsui Fix tyop in previous.
 1.970 27-Dec-2008  jnemeth PR/39094 - Kaspar Brand -- Add et (Agere ET1310/ET1301) netowrk driver
 1.969 21-Dec-2008  nonaka Add VIA VT8237S Integrated SATA Controller ID.
 1.968 16-Dec-2008  christos add more intel iwn devices
 1.967 29-Nov-2008  christos Add support for the Intel G45 AGP. From Arnaud Lacombe
 1.966 18-Nov-2008  matt Make more consistent (change capitalization) etc. Shrinks by 33 tokens
and 300 bytes.
 1.965 08-Nov-2008  christos Support for Intel G35 as found on Asus P5E-VM HDMI motherboard from
Milos Negovanovic
 1.964 04-Nov-2008  cegger fix typo in previous: prodcut -> product
 1.963 04-Nov-2008  cegger add ATI RD790 and RD890 chipset ids
 1.962 15-Oct-2008  bouyer branches: 1.962.2; 1.962.4;
Fix entry description.
 1.961 15-Oct-2008  bouyer Add support for more ethenet ICH9 devices. Tested by Pouya D. Tafti
on a 82801I_IGP_M_AMT.
 1.960 01-Oct-2008  christos ICH10 support from Brad du Plessis
 1.959 28-Sep-2008  bouyer Add JMicron JMC250 Gigabit Etheret and JMC260 Fast Ethernet Controllers.
While here, fix other JMicron device IDs (product ID is 4 digits, not five).
 1.958 18-Sep-2008  cegger correct C51 host bridge numbers. Spotted by njoly@
 1.957 18-Sep-2008  cegger add NVIDIA C51 products
 1.956 13-Sep-2008  njoly Add Nvidia GeForce 6150 devices.
 1.955 08-Sep-2008  cegger Serverworks: correct product id for LPC, add XIOAPIC and Watchdog Timer
 1.954 08-Sep-2008  cegger correct product id for serverworks usb controllers
 1.953 06-Sep-2008  rmind PR/39119: Jan Thorsson: Support for VIA CX700M2 IDE controller.
 1.952 06-Sep-2008  rmind PR/38012: David Dudley: Support for B&B Electronics MIPort serial cards.
 1.951 05-Sep-2008  cegger Add some ServerWorks products
 1.950 27-Aug-2008  christos Add one more cardbus bridge
 1.949 23-Aug-2008  tsutsui - add a Realtek 8139D variant (from FreeBSD)
- remove a duplicated entry of Realtek 0x8138
 1.948 22-Aug-2008  tnn Add Intel 82945GME Host Bridge
Intel 82945GME Integrated Graphics Device
 1.947 19-Aug-2008  matthias Typo
 1.946 19-Aug-2008  matthias Add pci ids for intel 82946GZ_{HB,IG} (used in my AcerPower 2000)
 1.945 06-Aug-2008  dyoung Define O2 Micro OZ711E0. From OpenBSD.
 1.944 29-Jul-2008  tron Add nVidia GeForce 7300 LE.
 1.943 15-Jul-2008  tonnerre Add some PCI IDs from the Thinkpad T61/X61/R61 series as observed in
PR 37988 and on my own T61.
 1.942 25-May-2008  chs branches: 1.942.2; 1.942.4;
add devices found in the last model of powermac G5. from openbsd.
 1.941 20-May-2008  cegger add some ATI products (SB600 modem, RD790 and RS690)
 1.940 13-May-2008  rjs Add SIS 756 Host Bridge.
 1.939 08-May-2008  sborrill Add support for IBM ServeRAID 8k (and 8k-l)
 1.938 30-Apr-2008  joerg branches: 1.938.2;
+ 3ware 9690
 1.937 17-Apr-2008  christos branches: 1.937.2; 1.937.4;
sync with openbsd; fixes observed corruption issues.
 1.936 15-Apr-2008  cegger add devices found on HP Pavilion dv9700 Notebook
 1.935 09-Apr-2008  joerg Add PCI ID of 3Ware 9650 family.
 1.934 03-Apr-2008  riz Digi International Neo 4 and 8 port serial boards.
 1.933 01-Apr-2008  cegger add XenSource and its virtual product - only found on Xen HVM guests
 1.932 26-Mar-2008  jmcneill PR#38301: Add support for SMBus controllers for ATI SB600, SB700, SB800
chipsets, from Christoph Egger
 1.931 24-Feb-2008  xtraeme + Dell PERC 6.
 1.930 22-Feb-2008  tsutsui Add I-O DATA RSA-PCI 2 port serial board.
 1.929 13-Feb-2008  tron branches: 1.929.2; 1.929.6;
Import PCI ids for the Matrox MGA G200e and the Intel E7230 and 82975X
chipsets from OpenBSD.
 1.928 10-Feb-2008  ichiro add few devices
PM965 interface
 1.927 05-Feb-2008  ichiro added some devices of "PCI-Cardbus bridge"
 1.926 11-Jan-2008  tnn Add ServeRAID 6/7
 1.925 11-Jan-2008  ragge Add Intel quad 1000baseT copper PCI express card.
 1.924 03-Jan-2008  jnemeth Symbios Logic 0x0030 is used for both 53c1020/53c1030 from Dave Huang
 1.923 30-Dec-2007  jdc Add Apple Shasta GMAC (From FreeBSD).
 1.922 28-Dec-2007  dholland typo fix: brige -> bridge
 1.921 24-Dec-2007  hamajima Add Intel 82801GB Ethernet Controller
 1.920 26-Nov-2007  bjs branches: 1.920.2; 1.920.6;
Add PCI IDs for the ATI Radeon X800 GTO (R430). Most sources I have
consulted indicated that this ID is an R430 (including xf86-video-ati).

PCI_PRODUCT_ATI_RADEON_R430_554F (primary)
PCI_PRODUCT_ATI_RADEON_R430_556F (secondary)

vga0 at pci1 dev 0 function 0: ATI Technologies product 0x554f (rev. 0x00)
ATI Technologies product 0x556f (miscellaneous display) at pci1 dev 0 function 1 not configured
 1.919 24-Nov-2007  markd Add INTEL Q33 and Q35 chipsets
 1.918 24-Nov-2007  markd s/product\tINTEL/product INTEL/
 1.917 23-Nov-2007  xtraeme Add some Intel 5000 Series Chipset devices.
 1.916 19-Nov-2007  ad Add a few more pcibs
 1.915 15-Nov-2007  manu It's 88C055, not 88CO55.
 1.914 14-Nov-2007  xtraeme Add NVIDIA MCP7[37] devices, from OpenBSD.
 1.913 12-Nov-2007  joerg Merge a PCI IDs of Intel 82G33 and 82965PM from jmcneill-pm.
 1.912 30-Oct-2007  xtraeme branches: 1.912.2;
Erm fix previous, it's Intel IOP333 not 332.
 1.911 30-Oct-2007  xtraeme Add Intel IOP332 A/B Segments.
 1.910 30-Oct-2007  xtraeme Areca ARC SATA RAID Controllers, from OpenBSD.
 1.909 30-Oct-2007  jnemeth PR/37201 - Yasushi Oshima -- Intel 82965G chipset support
 1.908 24-Oct-2007  xtraeme - Add support for the ServerWorks HT-1000 IDE Controller in rccide.
- Add support for another ServerWorks HT-1000 SATA Controller.

From OpenBSD.
 1.907 22-Oct-2007  manu Add support for Marvell 88CO55. Newer iMacs come with that chip.
 1.906 22-Oct-2007  nisimura PCI ID 10b5.9030 and 10b5.5201 are for PLX I/O accelerator product
model 9030 and 9050/9052. They work a functional bridge to host
any kind of I/O devices. The exact product type can be identified
via VPD (vital product ID) PCI configuration registers if they are
programmed by the particular PLX I/O accelerator applications.
Otherwise, it's not possible to distinguish which kind of function
is implemented inside.
 1.905 14-Oct-2007  xtraeme branches: 1.905.2;
IC Plus Corp IP100A support for ste(4), submitted by
Pedro Alejandro Lopez-Valencia in PR kern/36605.
 1.904 09-Oct-2007  garbled Add a bunch of IBM PCI dev id's for graphics cards and PCI bridges
 1.903 20-Sep-2007  xtraeme branches: 1.903.2;
+ ATI Radeon HD2600 XT
 1.902 17-Sep-2007  msaitoh addd SYMBIOS SAS1068_2, SAS1064E_2 and SAS1068E_2
 1.901 11-Sep-2007  jnemeth sort CMDTECH and add CMDTECH SiI3531 SATALink
 1.900 09-Sep-2007  xtraeme Another ICH8M SATA Controller found in jmcneill's laptop.
 1.899 08-Sep-2007  ober Add definitions for Intel 4965AGN.
 1.898 07-Sep-2007  cube Add EVE.
 1.897 02-Sep-2007  ober Add Intel LPC 82801HEM and 82801IO entries
 1.896 01-Sep-2007  ober ICH8M LPC Interface bridge. ok xtraeme
 1.895 31-Aug-2007  xtraeme + VIA CX700 IDE Controller
 1.894 30-Aug-2007  xtraeme + Intel 82801HBM IDE Controller
 1.893 28-Aug-2007  msaitoh add ICH9's Ethers
 1.892 26-Aug-2007  xtraeme branches: 1.892.2;
Add two ICH8 LPC Interface Bridges.
 1.891 19-Aug-2007  riz Add 27 Intel ICH9 device IDs, from:
http://download.intel.com/design/chipsets/specupdt/31697301.pdf
 1.890 14-Aug-2007  jnemeth PR/36759 - Christoph Egger -- add some MARVELL devices
 1.889 11-Aug-2007  jnemeth PR/36759 - Christoph Egger -- AMD product updates
 1.888 08-Aug-2007  tron Add some Attansis and VIA devices, correct order.

Patch provided by Christoph Egger on "tech-kern" mailing list.
 1.887 06-Aug-2007  martin branches: 1.887.2;
Add a serverworks south bridge
 1.886 04-Aug-2007  kiyohara Add support agp_amd64. Imported from FreeBSD.
 1.885 07-Jul-2007  jklos branches: 1.885.2; 1.885.6;
Added Chelsio vendor plus 10 gig hardware (and friends).
 1.884 06-Jul-2007  hpeyerl ATI updates from Christoph Egger
 1.883 27-Jun-2007  xtraeme Improve the NS CS5535 entries and remove the NS part, it's redundant.
 1.882 26-Jun-2007  xtraeme Add National Semiconductor CS5535 devices, found in the decTOP.
 1.881 28-May-2007  mrg add ALi M5261 ethernet (tulip clone)
 1.880 19-May-2007  tsutsui Add IBM GXT250P video.
 1.879 16-May-2007  mrg add Nvidia MPC04 SMBus
 1.878 02-May-2007  bouyer Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.
 1.877 29-Apr-2007  bouyer Remove extra "Intel" from previous commit
 1.876 29-Apr-2007  bouyer Add:
Intel i82801H IFE (GT) LAN Controller
Intel i82801H IFE (G) LAN Controller
from FreeBSD
 1.875 27-Mar-2007  pooka add GeForce Go 7600
 1.874 25-Mar-2007  isaki Add ATI ES1000.
 1.873 17-Mar-2007  dyoung Add Infineon ADM5120 PCI host bridge.
 1.872 10-Mar-2007  christos branches: 1.872.2; 1.872.4;
PR/35970: Todd Kover: Add support for HP ML110 G2 / Adaptec 2610SA
 1.871 09-Mar-2007  xtraeme branches: 1.871.2;
+ATI Radeon X1300
 1.870 03-Mar-2007  jmcneill Add pcHDTV HD-5500 HDTV video capture
 1.869 01-Mar-2007  jmcneill Add Conexant CX2388X Audio/Video Decoder
 1.868 16-Feb-2007  markd branches: 1.868.2;
Add i965Q
 1.867 10-Feb-2007  mlelstv Add support for VT8237A/VT82C586A PCI-ISA-Bridge
Fixes PR kern/35314
 1.866 30-Jan-2007  msaitoh add some msk devices
 1.865 28-Jan-2007  chs add another Realtek wifi, some SIIG serial cards and another nForce chipset.
remove some duplicate entries.
 1.864 27-Jan-2007  isaki Fix typo. s/Seria ATA/Serial ATA/
 1.863 21-Jan-2007  isaki Add AMD Geode LX and CS5536.
Reviewed by tsutsui@ on port-i386.
 1.862 14-Jan-2007  rpaulo Add new Parallels video id.
 1.861 06-Jan-2007  jmcneill Add Xbox SMBus controller, and rename "Xbox nForce" to accurately reflect
that it is the Host-PCI controller.
 1.860 04-Jan-2007  jmcneill It's nForce Ethernet, not Ethetnet
 1.859 04-Jan-2007  jmcneill Add Xbox nForce video, from Andrew Gillham.
 1.858 31-Dec-2006  ichiro add RCF-CBA2 CF-Adapter
(WORKBIT-CF32A)
 1.857 10-Dec-2006  bouyer Add another PCI ID for Dell PERC 5 (from OpenBSD)
 1.856 09-Dec-2006  manu Add support for 4 and 8 ports modem boards from Perle systems
 1.855 26-Nov-2006  tsutsui branches: 1.855.2;
- add more Broadcom product IDs, and fix two alternative IDs
(from FreeBSD and OpenBSD)
- sort by product ID
 1.854 26-Nov-2006  enami Add product id of yet another i82557 variant.
 1.853 18-Nov-2006  tsutsui Add an ID of Broadcom BCM5752M. From Matt Kolb on tech-kern.
 1.852 18-Nov-2006  tsutsui - add Realtek RTL8100 (from FreeBSD)
- fix entry of RTL8169SC
- remove vague comment in Realtek entry
 1.851 17-Nov-2006  tsutsui Add and note more Realtek Ethernet chips.
 1.850 13-Nov-2006  xtraeme Fix typo in previous (hi bouyer).
 1.849 13-Nov-2006  bouyer Add NetMos 9855 Quad UART and 1284 Printer port
 1.848 08-Nov-2006  rpaulo Add AMD PCI-X IOAPIC.
 1.847 08-Nov-2006  martti Fix aligment.
 1.846 08-Nov-2006  martti List MEGARAID_SAS and MEGARAID_VERDE_ZCR as SYMBIOS products.
 1.845 07-Nov-2006  martti Added some MegaRAID SAS controllers.
 1.844 03-Nov-2006  abs Add Broadcom BCM5754 (0x167a)
 1.843 31-Oct-2006  manu Add support for Perle systems PCI-RAS 4 modem ports
See http://www.perle.com/products/Multimodem-Cards.shtml for product details
 1.842 25-Oct-2006  bouyer Add VIA VT8237A Integrated SATA Controller, from FreeBSD.
 1.841 23-Oct-2006  rjs Add Motorola MPC5200B host bridge.
 1.840 21-Oct-2006  bouyer Add support for the Intel 80003 Gigabit Ethernet controller (found e.g. in
newer server chipsets) to wm(4), from the FreeBSD em(4) driver.
While there, add a few other Intel Ethernet controller that should work as
is.
Properly update the RX error and TX collision counters.
Add ikphy(4), a driver for the Intel i82563 Kumeran 10/100/1000 Ethernet PHYs
 1.839 09-Oct-2006  cube Add one puc device by Moschip (formerly NetMos). Not the one I have, but
as I went through the datasheets...
 1.838 02-Oct-2006  cube Oops, pasto.
 1.837 02-Oct-2006  cube Add an NVIDIA MCP55 device I forgot (ISA bridge).
 1.836 29-Sep-2006  cube Add ids of devices found in the nForce 570 chipset.
Add GeForce 6200LE.
 1.835 27-Sep-2006  cube Add the Intel PRO/100 variant found on the D946GZIS motherboard.
 1.834 27-Sep-2006  sketch Add TI ACX100B and rename existing (unused) TI ACX100 to ACX100A.
 1.833 25-Sep-2006  heas Add entries for Datum Inc. (Bancomm) & the BC635PCI_U card.
 1.832 24-Sep-2006  briggs Add IDs for the devices in the last-generation PowerBook G4.
 1.831 07-Sep-2006  riz branches: 1.831.2;
Add the SK-9Sxx Gigabit Ethernet, from OpenBSD.
 1.830 07-Sep-2006  itohy branches: 1.830.2;
Add Workbit NinjaATA-32Bi and NPATA-32 busmastering PIO IDE controllers.
 1.829 03-Sep-2006  xtraeme Add missing PDC20265 device... removed accidentally in previous.
 1.828 03-Sep-2006  xtraeme Add some missing devices from Promise and sort them.
 1.827 03-Sep-2006  xtraeme Add some ICH8 devices... from obsd.
 1.826 03-Sep-2006  xtraeme Erm forgot to add MCP61/65 SATA Controllers and sort them.
 1.825 03-Sep-2006  xtraeme - Add all pciids for nvidia MCP61/65 controllers, from obsd.
- Improve description in all them.
 1.824 03-Sep-2006  xtraeme - Add nForce MCP61/65 LAN controllers... from obsd.
- Improve description in some nForce controllers as well.
 1.823 27-Aug-2006  christos PR/34289: St�phane Witzmann: Add some missing PCI devices in pcidevs
 1.822 24-Aug-2006  riz Add a bunch of Marvell product IDs, from OpenBSD.
 1.821 23-Aug-2006  cube Add Broadcom NetXtreme II devices.
 1.820 22-Aug-2006  riz Rename vendor GALILEO -> vendor MARVELL . Marvell bought Galileo years
ago, we have little existing stuff in the tree, and this will make it
easier to keep certain network drivers in sync with other OSes.

OK matt@, uwe@
 1.819 13-Aug-2006  dsainty Add the Promise PDC20771, present on the Promise FastTrak TX2300
 1.818 10-Aug-2006  simonb Fix typo in 3945 Intel wireless card name.
Pointed out in private mail by Jean-Baptiste Campesato.
 1.817 09-Aug-2006  jnemeth add some Token Ring devices
 1.816 08-Aug-2006  cube Add device IDs for Intel's 631xESB/632xESB southbridges, and start the list
for the 5000X northbridge. I'll add the rest later, the spec is currently
unavailable so I'll collect them from another source.
 1.815 06-Aug-2006  jmcneill branches: 1.815.2;
Add entry for IBM ThinkPad audio. From Stephane Witzmann.
 1.814 03-Aug-2006  bsh Device 10de:026c is not AC-97 controller but nForce430 HD Audio controller.

Pointed out by Brad. Thanks.
 1.813 01-Aug-2006  xtraeme Add nForce3 250 SATA2.
 1.812 01-Aug-2006  bsh add an another device ID for AC-97 controller in nForce430 (MCP51).

XXX: I found this ID on MSI K8NGM-V, which has nForce410. Maybe 0x26b is
for 410 and 0x26c for 430?
 1.811 30-Jul-2006  jmcneill Add VIA VT3314 (CN900) UniChrome integrated graphics
 1.810 30-Jul-2006  oster Recognize another Intel PRO/100 VM Network Controller.
 1.809 30-Jul-2006  simonb Add 82945P_IGD.
Should this be "82945G_IGD", and other 945 device IDs have G instead of P
suffix?
 1.808 21-Jul-2006  gdamore Update ADMtek pci device ids to match data sheets. While here, add the 9513
device (although I've never seen one, I have a datasheet for it. :-)
 1.807 18-Jul-2006  itohy Identify vendor 0x1317, product 0x9511 as ADMtek AN983B,
since OpenSolaris says it is "ADMTek Comet 983b".
 1.806 13-Jul-2006  kent - add VIA VT8237A/8251 High Definition Audio Controller
- add some tabs
 1.805 07-Jul-2006  simonb Add another Intel 3945 wireless minipci device id.
Small part of kern/33778 by Jean-Baptiste Campesato.
 1.804 30-Jun-2006  nisimura Add kse(4) driver for Micrel KSZ8842/8841 Ethernet controller.
 1.803 30-Jun-2006  xtraeme Add ITE IT8211 IDE Controller.
 1.802 30-Jun-2006  xtraeme Add some missing ATI devices.
 1.801 27-Jun-2006  kent improve the description of NVIDIA MCP55_HDA
 1.800 26-Jun-2006  xtraeme Add SIS 660, 760, 761 IDE Controllers and SIS 181/182 SATA controllers
(from obsd).
 1.799 26-Jun-2006  xtraeme Add PROMISE PDC20775 and PDC40718 SATA controllers (from obsd).
 1.798 25-Jun-2006  soren Add quirk for the not quite standard PCI bus in Parallels Desktop for Mac.
 1.797 18-Jun-2006  christos PR/33761: dieter roelants: NetBSD doesn't recognize a RealTek 8168B nic
 1.796 18-Jun-2006  xtraeme Add ALI M1533 PCI-ISA Bridge
 1.795 15-Jun-2006  heinz Added information about LSI's SAS, parallel SCSI and FC adapters (from LSI's
Linux driver package and http://pciids.sourceforge.net/).
 1.794 14-Jun-2006  grant branches: 1.794.2;
QLogic is the correct writing, not "Q Logic".
 1.793 14-Jun-2006  grant add QLogic QLA200 fibre channel card.
 1.792 08-Jun-2006  kent add 23 ICH8 devices.
http://download.intel.com/design/chipsets/specupdt/31305701.pdf

No regen follows because no one refers them.
 1.791 06-Jun-2006  rpaulo Attachment framework for the rt2561.c and rt2661.c drivers.

From OpenBSD.
 1.790 05-Jun-2006  martin Add D-Link Air DWL-610
 1.789 05-Jun-2006  msaitoh add 82541ER_LOM, 82547EI_MOBILE, 82546GB_PCIE(PRO/100MT),
82546GB_QUAD_COPPER(PRO/1000MT QP) and 82572EI(PRO/1000PT).
 1.788 31-May-2006  riz Add a couple DLINK product IDs, from OpenBSD.
 1.787 19-May-2006  markd branches: 1.787.2;
Add some devices found on a Dell Latitude D620.
 1.786 30-Apr-2006  xtraeme PR kern/32849: pcidevs update for Intel 82801CA AC'97 Modem Controller.
Apply patch from Nicolas Joly.
 1.785 30-Apr-2006  xtraeme PR port-amd64/33393: viaide driver patch for VT8237R SATA.
 1.784 29-Apr-2006  gdamore Add Audigy4 device id.
 1.783 25-Apr-2006  wrstuden Tweak 3ware 9500 ID, and add 3ware 9550 ID.
 1.782 20-Apr-2006  gdamore Add a bunch of additional Radeon entries, and correct/cleanup a few of them
for consistency and to match Xorg. I am assuming that Xorg contains the
correct information, since it actually makes use of this information.
 1.781 15-Apr-2006  jmcneill Add entry for Turtle Beach Santa Cruz, and Cirrus Logic CS4615 while we're
here.
 1.780 06-Apr-2006  simonb Sort some Intel GigE nics by product ID.
 1.779 05-Apr-2006  nonaka Added "Faraday Technology" in vendor list.
 1.778 26-Mar-2006  jonathan Fix cut-and-paste typo in human-readable description of bcm5780S
(used to say bcm5782s, should be bcm5780s; make it so).
 1.777 25-Mar-2006  rpaulo Add Conexant LANfinity. From Frank Wille <frank@phoenix.owl.de> on
port-i386.
 1.776 21-Mar-2006  he Add a bunch of IDs for Compaq/HP Smart Array controllers supported
by the soon to be added ciss(4) driver.
 1.775 12-Mar-2006  chs branches: 1.775.2;
fix name of Radeon 9000 Pro.
add Radeon 9200 Secondary ID.
add Comtrol, Magma and SIIG multi-port serial cards.
add more Dolphin SCI cards.
add IBM ServeRAID 4/5.
add Mitsubishi Tornado 3000.
add or rename various NVIDIA IDs to match openbsd.
add SafeNet SafeXcel.
 1.774 09-Mar-2006  he Add vendor code for Nortel and Baystack 21 id. Part of info
submitted in PR#33044.
 1.773 09-Mar-2006  hamajima Add EXAR devices.
Fix duplicated NVIDIA product id 0x0057.
 1.772 07-Mar-2006  bouyer Also support Serverwork Frodo4, Frodo8 and HT-1000 in svwsata.
From OpenBSD.
 1.771 06-Mar-2006  bouyer branches: 1.771.2;
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.770 06-Mar-2006  martin Add MOXA devices, from Olivier Cherrier
 1.769 01-Mar-2006  dogcow branches: 1.769.2;
add a bunch of Nvidia nForce ethernet IDs (via OpenBSD.)
 1.768 28-Feb-2006  gdamore Add Radeon 7000/VE (QZ).
 1.767 21-Feb-2006  chuck add entry for LINKSYS PCM200 10/100 ethernet card
 1.766 16-Feb-2006  kochi add two more ICH7-M LPC device ids from intel document
(Intel I/O Controller Hub 7 (ICH7) Family Specification Update)
 1.765 12-Feb-2006  tron Fix inconsistencies in names for components for recent Intel chipsets.
 1.764 12-Feb-2006  tron Correct cut and paste error in last change.
 1.763 12-Feb-2006  tron Add entries for Intel i955X chipset.
 1.762 07-Feb-2006  cube I wonder how the leading junk arrive there...
 1.761 07-Feb-2006  cube Add PLX's 9054 I/O Accelerator.
 1.760 06-Feb-2006  abs Add SIS 190 Ethernet, as found in ASUS T2-AE1
 1.759 02-Feb-2006  christos branches: 1.759.2;
PR/32695: Chuck Tuffli: incorrect PCI device id for CMD Technology (0x1095)
SiI3132 SATALink (0x3132)
 1.758 26-Jan-2006  bouyer branches: 1.758.2;
Add Promise PDC2057x SATA/150 controllers, from FreeBSD.
 1.757 16-Jan-2006  christos PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.756 10-Jan-2006  cdi PR/32494: Add ID 0x1068 for Intel PRO/100 VE (LOM) found on Sony Vaio
S4HRP laptops.
 1.755 02-Jan-2006  manu Add support for nForce430 ATA133 and SATA controllers. My disks now run
at a decent speed.
 1.754 02-Jan-2006  tron Fix cut and paste error. Noted by Bernhard Moellemann.
 1.753 02-Jan-2006  tron - Spell NVIDIA as "NVIDIA" instead of "Nvidia". This matches their
website and viaide(4).
- Add entry for builtin ethernet of NVIDIA nForce4 chipset.
Information provided by Bernhard Moellemann.
 1.752 01-Jan-2006  xtraeme Fix VIA VT8231 product: it's a PCI-ISA Bridge not an IDE Controller.
 1.751 29-Dec-2005  jonathan branches: 1.751.2;
Add pcidevs entry for the (Serverworks?) PCI-Express to PCI-X bridge
chip integral to Broadcom bcm5714 and bcm5715 PCI-Express dual-port
gigabit Ethernet chips.
 1.750 19-Dec-2005  jonathan Add an entry for S&K (Schneider&koch, also SysKonnect) PCI-Express
gigabit ethernet boards (SK-9E21D single-port, SK-9E22 dual-port)
based on the Marvell Yukon-2 chipset.
 1.749 19-Dec-2005  jonathan Add ID 0x3132 for Silicon Image, PCI-Express dual-port SATA-II version
of SiI 3124 (PCI-X quad SATA).
 1.748 18-Dec-2005  sekiya Add device information for Linksys IPN2200. From ndiswrapper list.
 1.747 11-Dec-2005  jonathan Remove extraneous //// markers of potential conflict in last commit.
 1.746 11-Dec-2005  jonathan Add pcidevs entries and support to amr(4) for newer LSI MegaRAID devices,
including the LSI MegaRAID SCSI 320-0x, 320-2x, 320-4x, 320-1E, 320-2E,
the LSI MegaRAID SATA 300-6x and 300-8x.

Tested on an LSI MegaRAID SATA 300-8x, which confirms private advice
that after PCI-IDs to our amr(4) driver, the newer LSI MegaRAID cards
will Just Work

The Linux megaraid2 driver accepts various Intel cards with the same
pci-device IDs as the LSI MegaRAID cards, treating them exaclty as the
above-listed LSI cards. Rework our amr(4) driver to also match and
attach those device-ID if seen with an Intel vendor-ID. Add the
Intel-vendor PCI decice-ids to pcidevs, so that PCI_VERBOSE will
correctly identify the Intel cards.

Update src/share/man/man4/amr.4 to list the newly-supported cards.

(NB: I don't have the LSI SCSI or any Intel cards to test, just the
LSI SATA, which works fine for me.)
 1.745 10-Dec-2005  jonathan Add PCI device entries for Broadcom Ethernet devices: PCI-Express
gigabit bcm5714 (copper), bcm5714S (serdes), bcm5715 (copper),
bcm5715S (SERDES), also bcm5780 (copper) and bcm5780S (SERDES).

Extracted from Broadcom-supplied Linux driver and from prerelease patches
for Linux-2.6.15.
 1.744 09-Dec-2005  xtraeme Add two VMware SVGA device ids.
 1.743 08-Dec-2005  xtraeme Add three Rhine ethernet adapters.
 1.742 07-Dec-2005  jonathan Add PCI device-ids to sys/dev/pci/pcidevs for newer Broadcom gigabit
ethernet devices: bcm5714, bcm5752 (previously the 5789, but fvdl
committed that whilst I was musing).

Add definitions to sys/dev/pci/if_bgereg.h for the Broadcom 57xx-family
ASIC revisions on these newer chips.

Add entries to the PCI-device-version and bge-internal-asic-revision
tables in sys/dev/pci/if_bge.c to use these new devices. Pending
further information, follow the lead of FreeBSD's if_bge.c driver and,
pending further info, treat these new chips as we do the 5750.
 1.741 06-Dec-2005  fvdl Add ID for yet another 57xx-compatible Broadcom chip, the 5789.
 1.740 04-Dec-2005  christos PR/32181: Matthias-Christian Ott: Add support for the Belkin F5D6001 pci device
 1.739 04-Dec-2005  christos PR/32238: Ryo Shimizu: Add support for Promise SATA300TX4 SATA Controller
(PDC40718)
 1.738 27-Nov-2005  jdolecek change the description of the 3ware raid controllers to 'ATA RAID Controller'
rather then 'IDE RAID'

fix the ID of the 9xxx series controller and rename to ATARAID_9k, since
3ware doesn't refer to it using the 'Escalade' family name
 1.737 22-Nov-2005  rpaulo Fix entry for TI FlashMedia Controller.
 1.736 18-Nov-2005  rpaulo It's really PCI7x21/7x11 Cardbus Controller.
 1.735 18-Nov-2005  rpaulo Add a bunch of devices:
o Intel 82801FBM ICH6M LPC Interface Bridge
o Intel 82801FB/FR PCI Express Port #2
o TI PCIxx21/x515 Cardbus Controller
o TI PCI7x21/7x11 IEEE 1394 Host Controller
o TI PCIxx11/21 Integrated FlashMedia Controller
 1.734 01-Nov-2005  abs branches: 1.734.2;
Add Radeon 9000 PCI (0x4966)
 1.733 05-Oct-2005  jonathan branches: 1.733.2;
Add PCI ids for Intel Pro/1000 PT PCI-Express gigabit ethernet controllers:
82571EB 2-port, 82572EI single-port, both in copper, fibre, and SERDES versions,
and 82573 embedded chip.
 1.732 04-Sep-2005  tron Add PCI ids for ATI Radeon 9600 LE.
 1.731 21-Aug-2005  chs add nvidia devices found on an ASUS K8N-DL motherboard,
plus various other cards.
 1.730 21-Aug-2005  gavan Add BCM5751M
 1.729 30-Jul-2005  grant use same form for secondary display as other ATI devices
 1.728 30-Jul-2005  grant add some device ids for the ATI Radeon 9200 Pro.
 1.727 29-Jul-2005  cube New Dell day: add missing device IDs, and order one correctly.
 1.726 25-Jul-2005  christos PR/29925: Mihai CHELARU: Fix for stge 1023.
 1.725 01-Jul-2005  drochner branches: 1.725.2;
add ralink dev IDs, from FUKAUMI Naoki per PR kern/30449
 1.724 01-Jul-2005  augustss Add the ATI SB400 chip set and the Radeon X850 XT graphics card.
 1.723 26-Jun-2005  seb Add ATI Radeon Mobility X600.
Add Mobile Intel 915PM/GM/GMS and 910GML Express Chipset.
 1.722 24-Jun-2005  seb Add Texas Instruments PCI6515A Cardbus Controller with Smart Card Controller.

Approved by gimpy@
 1.721 20-Jun-2005  briggs Add Intel 6300ESB SATA RAID Controller.
 1.720 19-Jun-2005  chs add some misc cards and merge the two mylex sections.
 1.719 15-Jun-2005  bouyer Add Intel 82801FBM Serial ATA Controller. From Kurt Schreiner on tech-kern@
 1.718 14-Jun-2005  bouyer Add SIS 965 bridge. From FreeBSD.
 1.717 13-Jun-2005  tron Add support for the LinkSys PCMPC200 Cardbus ethernet card.
 1.716 13-Jun-2005  nonaka Add PCI ids for HITACHI SH7751{,R} PCI Controller
 1.715 13-Jun-2005  nonaka Add PCI id for "ATI Mobility Radeon 9700".
 1.714 07-Jun-2005  skrll Add some Intel 802.11 cards.

From OpenBSD.
 1.713 28-May-2005  kent Add the followings:
- 6300ESB AC'97 Audio
- 6300ESB AC'97 Modem
- ICH6 HD-Audio
- ICH6 AC'97 Modem
- All of ICH7 devices
 1.712 27-May-2005  augustss Add the TM8000 integrated northbridge.
 1.711 18-May-2005  riz Add support for the 82801FB (ICH6) 10/100 ethernet appearing
on new Intel motherboards. From Brian Buhrow in PR#30025.
Approved by jmcneill.
 1.710 12-May-2005  cube Two re(4) candidates. From Francois Romieu in private mail.
 1.709 09-May-2005  martin PR kern/30173: add Corega CG-LAPCIGT
 1.708 04-May-2005  cube Add a few devices seen on a Dell PowerEdge SC1420, and while there make the
ordering of devices proper.
 1.707 02-May-2005  rh Add IC Ensemble / VIA Technologies Envy24 Multichannel Audio controllers.
 1.706 20-Apr-2005  bouyer Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.705 06-Apr-2005  martti Added support for Dell CERC SATA RAID 1.5/6ch
 1.704 24-Mar-2005  tron Add ids for ATI Radeon 9700 Pro and 9800 Pro.
 1.703 19-Mar-2005  tron Add PCI id for Intel PRO/1000 GT.
 1.702 19-Mar-2005  tron Add missing PCI id for Adaptec ASR-2410SA.
 1.701 16-Mar-2005  xtraeme branches: 1.701.2;
Add VIATECH KT880 CPU to PCI Bridges.
 1.700 16-Mar-2005  uwe ATI Radeon 9100 IGP chipset.
 1.699 15-Mar-2005  xtraeme Add entries for VIA Apollo KM400 chipsets, provided by
Thilo Manske in PR kern/29549.
 1.698 15-Mar-2005  xtraeme Add entry for "S3 Prosavage KM133", provided by Nicolas Joly in PR
kern/20572.
 1.697 15-Mar-2005  uwe Fix product ids of ENE CB710 and CB720 CardBus controllers.
 1.696 07-Mar-2005  christos PR/29614: Andrzej Kukula: Missing PCI IDs of ATI IXP 300 and 400 ATA controller
 1.695 27-Feb-2005  perry nuke trailing whitespace
 1.694 20-Feb-2005  jdolecek change the VIATECH VT61XX to VT612X
 1.693 02-Feb-2005  christos PR/29196: Robert Elz: Add support for Broadcom BCM4401-B0 ethernet
 1.692 02-Feb-2005  abs Reminder not to trust cheap no-name packaging. VIA product 0x3249 is
a VT642*1* not VT642. Also add to list in viaide manpage and note
that drives need to be configured into RAID/JOBS sets via its BIOS.
http://www.via.com.tw/en/products/peripherals/serial-ata_raid/vt6421/
 1.691 01-Feb-2005  abs Add 'VT642 SATA RAID Controller'. It looks like a viaide, it smells
like a viaide... but you can only address the drives once you have
put two or more of them into a RAID or JBOD.
 1.690 27-Jan-2005  jdolecek add id for nForce2 Ultra 400 audio
 1.689 27-Jan-2005  kent add some nForce 4 devices
 1.688 25-Jan-2005  matt branches: 1.688.2;
Add additional PCI Device IDs for ATI Radeon 9200
 1.687 23-Jan-2005  fredb Recognize Belkin Gigabit Desktop Network PCI card.
 1.686 18-Jan-2005  tsubai Add some Apple devices.
 1.685 15-Jan-2005  skrll branches: 1.685.2;
Add Intel PRO/Wireless LAN 2915ABG Mini-PCI Adapter
 1.684 15-Jan-2005  jdolecek Fix Geforce 6800GT entry
 1.683 15-Jan-2005  jdolecek add bunch of GeForce 6800 entries, from Andrew Gillham
 1.682 15-Jan-2005  jdolecek use full 'nForce2 Ultra 400' tag for the NFORCE2_400* enties
 1.681 13-Jan-2005  jdolecek add bunch of NVIDIA nForce2 Ultra 400 chipset devices
 1.680 13-Jan-2005  jdolecek add VIA Velocity ID
 1.679 08-Jan-2005  fredb Recognize the Broadcom 5721 Gigabit Ethernet, as found on SuperMicro P8SCi
motherboards.
 1.678 08-Jan-2005  ginsbach Use the more common name, Radeon U1, for the IGP 320M.
 1.677 06-Jan-2005  he Add entry for LSI Logic FC919X, as found on LSI Logic LSI7102XP-LC
controllers.
 1.676 27-Dec-2004  reinoud Addition of description for :

/* ENE Technology products */
product ENE MCR510 0x510 MCR510 PCI Memory Card Reader Controller
 1.675 18-Dec-2004  xtraeme + ATI Technologies Radeon 9600 XT
 1.674 16-Dec-2004  heas Add entry for the Radeon Mobility T2.
 1.673 11-Dec-2004  reinoud Add ATI IXP audio controllers
 1.672 07-Dec-2004  jdarrow Add a new vendor and product ID for a cardbus NIC I've got
Belkin 0x1799
F5D6020v3 0x6020
 1.671 06-Dec-2004  cube Add ATI IXP IDE Controller.
 1.670 05-Dec-2004  bouyer Cleanup in VIA chipset names. From Lloyd Parkes in kern/15466.
 1.669 30-Nov-2004  grant add ITE 8212 IDE controller.
 1.668 22-Nov-2004  rumble kern/28384: VT3606 -> VT6306 typo
 1.667 19-Nov-2004  tacha add Broadcom BCM5705K.
 1.666 17-Nov-2004  jdarrow Add PCI IDs for two wireless cards I've got.
Ralink Technologies (vendor 0x1814) RT2460 (product 0x0101).
Texas Instruments (vendor 0x104c) ACX111 (product 0x9066).
 1.665 17-Nov-2004  junyoung Revert ATI to ATI Technologies.
Remove trailing Corp., Inc., Ltd., and etc. for consistency.
 1.664 16-Nov-2004  skrll Add Intel PRO/Wireless LAN 2200BG Mini-PCI Adapter
 1.663 14-Nov-2004  soren Add Mylex ExtremeRAID 1100.
Shorten ATI Technologies to ATI.
Simplify names of Intel mobile USB controllers.
 1.662 06-Nov-2004  xtraeme Add Nvidia nForce3 250 chipset products, from Kouichirou Hiratsuka
in PR 27843.
 1.661 28-Oct-2004  martti Align all SYMBIOS entries
 1.660 28-Oct-2004  martti Added Dell PERC 4/SC
 1.659 26-Oct-2004  augustss Add a vendor and some products.
 1.658 22-Oct-2004  cube Add two Broadcom devices (575x chips), correct and add a few Intel entries.
 1.657 20-Oct-2004  martti Added support for DELL PERC 4e/Si RAID controller
 1.656 13-Oct-2004  augustss Add ALi M1563 bridge.
 1.655 13-Oct-2004  drochner recognize ADDI-DATA APCI-7800 8-port serial adapter
 1.654 11-Oct-2004  jmmv Add ATI Technologies Radeon 9200SE Secondary identifier.
 1.653 05-Oct-2004  augustss Add some ALI devices.
 1.652 30-Sep-2004  cube Add a bunch of devices found on the SuperMicro P4SCi motherboard.
 1.651 18-Sep-2004  martin Add LSI FC929 (aka FC929X); from PR kern/26836.
 1.650 17-Sep-2004  xtraeme Add GeForceFX 5700 LE and regen.
 1.649 16-Sep-2004  ragge Add S2io 10 Gigabit ethernet adapter.
 1.648 10-Sep-2004  darrenr Add Sierra Wireless AirCard 580 (1xEV-DO)
 1.647 26-Aug-2004  itohy Add Workbit NinjaSCSI-32 PCI/CardBus products.
 1.646 05-Aug-2004  mycroft Fix an Aironet product name, and normalize the usage of "Mini-PCI".
 1.645 05-Aug-2004  cube Add the GeForce 5900XT. Totally not related to Doom3 release. Honest.
 1.644 05-Aug-2004  lukem consistently use "product<SPACE>"
 1.643 04-Aug-2004  mycroft Normalize more names.
 1.642 04-Aug-2004  mycroft Normalize some product names.
 1.641 04-Aug-2004  mycroft Remove vendor names from product strings.
 1.640 02-Aug-2004  mycroft Add a device I missed.
 1.639 02-Aug-2004  mycroft Merge in data from cardbusdevs.
 1.638 02-Aug-2004  mycroft Mmmm, Microsoft products.
 1.637 29-Jul-2004  cube Add a bunch of devices that are in the Dell Dimension 8400 sitting on my
desk: ATI Radeon X300, Broadcom BMC5751, Intel 915 chipset family (ICH6).
 1.636 27-Jul-2004  christos add compaq advanced systems management controller.
 1.635 27-Jul-2004  rumble Fix typos in the SC1100 IDE and AUDIO ids.
 1.634 25-Jul-2004  christos Add viatech's VT8231 Power controller. (Sergio Jimenez)
 1.633 21-Jul-2004  mycroft Add SIS 741.
 1.632 17-Jul-2004  mycroft Fix Intersil product names.
 1.631 15-Jul-2004  junyoung Add 3Com 3c920B-EMB-WNM Integrated Fast Ethernet.
 1.630 05-Jul-2004  mycroft Add the CSB5 LPC bridge.
 1.629 04-Jul-2004  mycroft Update Serverworks chip IDs, per:
http://www.plasma-online.de/english/identify/picture/serverworks.html
This seems remarkably more sane.
 1.628 15-Jun-2004  bouyer Apply patch from kern/25936 by Michael Blake: Add support for the
Netelligent 10/100 TX variant found on the Compaq Proliant Professional
Workstation 5100.
 1.627 27-May-2004  christos PR/25731: Adam K kirchhoff: Audigy support with the emuxki driver.
 1.626 27-May-2004  abs Add ALI 'M5257 PCI Software Modem'
 1.625 12-May-2004  tron Add support for Broadcom BCM5788 GbE. Patches supplied by FUKAUMI Naoki
in PR kern/25166.
 1.624 11-May-2004  thorpej Add i6300ESB IDE / SATA controller PCI IDs.
 1.623 10-May-2004  lukem add Nvidia GeForce4 Ti 4200 Go AGP 8x (0x286)
 1.622 10-May-2004  gendalia Add support for Adaptec AAR 2810SA raid controller.
 1.621 07-May-2004  sekiya Add support for Silicon Image 3512 chip to satalink driver -- treat it as
a 3112 variant (without RAID support), which does the right thing with the
controller on my K8NNXP.
 1.620 22-Apr-2004  skd Added support for new sis south bridge and 180 sata controller.
 1.619 17-Apr-2004  matt Add devid of Marvell MV6436x System Controller
 1.618 03-Apr-2004  martti Added another SB Live! 5.1 soundcard and joystick version
 1.617 03-Apr-2004  mycroft Add RealTek RT8180.
 1.616 01-Apr-2004  tron Correct entry for PCI vendor id 0x11af. It is assigned to Avid Technology
Inc. and not to Pro-Log Corporation. Problem reported by Chris Tribo
in PR kern/25004 and verified at http://www.pcidatabase.com/.
 1.615 26-Mar-2004  gendalia branches: 1.615.2;
Add Adaptec 2200S Vulcan 2M / Dell PERC 320/DC
 1.614 25-Mar-2004  drochner recognize both parts of the AMD8151 AGP tunnel (see PR kern/24838 by
Nicolas Joly), and improve AMD8131
 1.613 12-Mar-2004  drochner add ICH5 builtin ethernet
 1.612 03-Mar-2004  gavan Add Creative Labs SB Audigy LS
 1.611 26-Feb-2004  drochner add intel e7501 host bridge
 1.610 28-Jan-2004  chs add some JNI and Emulex fibre-channel cards.
add all the built-in stuff from my Asus A7N8X-E Deluxe motherboard.
add some other misc cards.
update the URL at the top.
 1.609 26-Jan-2004  blymn Added note for correct update procedure for pcidevs.
 1.608 26-Jan-2004  blymn Add amd8151 agp bridge id.
 1.607 19-Jan-2004  ragge Add "Intel PRO/10GbE LR Server Adapter". Regen.
 1.606 06-Jan-2004  matt Add HP Tachyon TL and TS device IDs.
 1.605 05-Jan-2004  matt Add Agilent Technologies vendor ID
Add Agilent Tachyon_DX2 product ID
Add HP Tachyon_XL2 product ID
 1.604 20-Dec-2003  thorpej Add product ID for the SiI 3124 SATALink.
 1.603 19-Dec-2003  thorpej Add product ID for the Silicon Image 3114 SATALink.
 1.602 17-Dec-2003  tls Add support for some more Marvell-based adapters to the sk driver:

D-Link DGE-530T
Linksys EG1032v2
Linksys EG1064v2

The Linux driver treats all of these the same. Tested with a DGE-530T;
it works, though performance on at least one of my systems is atrocious.

Fix setting of ethernet capabilities into interface capabilites word in
attach routine.

Manual page: note that jumbo support doesn't work and checksum support
doesn't exist.
 1.601 14-Dec-2003  tsutsui Add ATI Radeon 9200SE.
 1.600 09-Dec-2003  ad Add second ID for Intel i960 RM.
 1.599 08-Dec-2003  pooka Broadcom 5703 A3
 1.598 08-Dec-2003  scw Add an entry for Intersil's Prism-54 (ISL3890) WLAN mini-PCI card.
 1.597 06-Dec-2003  jdolecek add NetMos NM9805 and NM9815
 1.596 05-Dec-2003  grant add Adaptec AAR-1210SA Serial ATA RAID controller.
 1.595 28-Nov-2003  chs add Tandem ServerNet II and various HPT IDE controllers.
 1.594 28-Nov-2003  cube Add 3c910 OfficeConnect 10/100B Ethernet.
 1.593 26-Nov-2003  matt Add pcHDTV HD-2000 HDTV video capture card.
 1.592 22-Nov-2003  fvdl Clean up the Promise IDE controller defines.
 1.591 03-Nov-2003  cube Add some IDs for the EPIA-M 10000 motherboard.
 1.590 25-Oct-2003  chs add some misc cards I've got.
 1.589 23-Oct-2003  fvdl Add a few more broadcom 57xx ids. From FreeBSD.
 1.588 23-Oct-2003  briggs Add some ENE Cardbus bridges from FreeBSD.
 1.587 22-Oct-2003  fvdl Add:
* an id for the Promise FastTrak 378
* several ids for NVidia nForce3 devices
 1.586 18-Oct-2003  matt Add Philips SAA7146AH
 1.585 18-Oct-2003  lukem Remove http://members.hyperlink.net.au/~chart/pci.htm link; it doesn't
exist anymore.

Add some more ServerWorks devices
 1.584 15-Oct-2003  itojun add Atheros product IDs from athhal_devid.h
 1.583 14-Oct-2003  martti Added another Dell Perc 4/DI
 1.582 10-Oct-2003  thorpej Add several more Intel Gig-E product IDs.
 1.581 08-Oct-2003  jonathan Add Hifn 7954/7955 and 7956. Put adjacent to the very similar hifn 7951.
From Rajesh Vaidyanath <RVaidyanath@hifn.com>, as submitted to FreeBSD.
 1.580 26-Sep-2003  matt Add Dell Perc 4/DI
 1.579 25-Sep-2003  joda more nvidia devices
 1.578 21-Sep-2003  nisimura Redo, again.
 1.577 21-Sep-2003  nisimura Redo the previous fix.
 1.576 21-Sep-2003  nisimura Fix the company name. It seems these days the company calls itself
"STMicroelectronics" anyway.
 1.575 15-Sep-2003  bouyer Rename VT8237_RAID to VT8237_SATA, as this is really what it is.
Suggested by Stephen Degler in kern/22727.
 1.574 13-Sep-2003  jdolecek fix description of Intel PRO/100 VM Network Controller with 82562ET/EZ PHY
don't activate any quirks for VM_6 variant
problem reported by Lars Heidieker on current-users

also don't activate any quirks for VM_3 - VM_5 variants, neither
VE_2 - VE_4, in anticipation that the more modern variants don't need
the quirks
 1.573 28-Aug-2003  thorpej Hi/Fn is now spelled Hifn. Add some more Hifn products (from openbsd).
 1.572 27-Aug-2003  kleink While here, add the AMD8111's ACPI controller.
 1.571 27-Aug-2003  kleink Add AMD8111 USB and SMBus controller IDs; from Nicolas Joly in kern/22617.
 1.570 26-Aug-2003  jdolecek add SysKonnect SK9821
 1.569 26-Aug-2003  tron Add entry for Intel i865G Integrated Graphics Device.
 1.568 23-Aug-2003  dogcow add VT6105 support to vr(4)
 1.567 20-Aug-2003  jonathan Fix typo (s/5822/5823/) in line for bcm5823 device.
 1.566 17-Aug-2003  chs add the uninorth ATA found in the latest G4s, and a highpoint IDE.
 1.565 17-Aug-2003  bouyer Add 3com 3c940 Gigabit Ethernet, and VIA KT600 PCI devices. From Stephen Degler
in PR port-i386/22453
 1.564 14-Aug-2003  itojun s,PCI/ISA,PCI-ISA,
 1.563 14-Aug-2003  itojun add National Semiconductors SC1100 (GEODE) PCI devices.
 1.562 07-Aug-2003  wiz Fix ID of Radeon 9100 Secondary; noted by Quentin Garnier.
 1.561 01-Aug-2003  wiz Avoid duplicate definitions. From Quentin Garnier in PR 22331.
 1.560 01-Aug-2003  jonathan Add product IDs for Sun's bcm582x-compatible crypto accelerators
 1.559 29-Jul-2003  thorpej Add the product ID used for the i82546EB chips present on the
Intel PRO/1000 MT Quad Port Server Adapter.
 1.558 29-Jul-2003  martin Add Ricoh 5C551 CardBus + FireWire product ID.
From FUKAUMI Naoki in PR 22292.
 1.557 29-Jul-2003  martin Intel 8255GM is GM, not PM (obviously a copy&pasto).
From FUKAUMI Naoki in PR 22293.
 1.556 27-Jul-2003  jonathan Add PCI vendor Cavium and product code for their Nitrox XL crypto device.
 1.555 27-Jul-2003  jonathan Add PCI vendor code for BlueSteel Networks (now part of Broadcom),
and PCI product codes for the Bluesteel/Broadcom family of security processors.
 1.554 23-Jul-2003  kleink Add a couple of Philips A/V broadcast decoder device IDs.
 1.553 17-Jul-2003  hannken Add support for the BCM5705:
- Only BCM5705M asic rev A1 was tested.

Thanks to Bill Paul (wpaul@freebsd.org) for help and support.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.552 14-Jul-2003  jmmv Add ATI Radeon 9200 chip.
 1.551 14-Jul-2003  wiz Add MGA G550, from Kouichirou Hiratsuka in PR 22133.
 1.550 12-Jul-2003  hubertf Recognize Toshiba Smart Media and Secure Digital cards
 1.549 06-Jul-2003  dyoung Add driver atw for PCI/Mini-PCI/Cardbus 802.11b NICs based on the
ADMtek ADM8211. Read the man page for bugs and other outstanding
issues.
 1.548 06-Jul-2003  simonb Trailing white-space and TABs nits.
 1.547 06-Jul-2003  simonb Fill out E7505 devices.
Fix E7500 HI_D descriptions.
 1.546 06-Jul-2003  tron Add Intel 82547EI gigabit chip.
 1.545 06-Jul-2003  simonb Add an entry for the Intel E7505 Chipset Memory Controller Hub.
 1.544 06-Jul-2003  tron Correct names and descriptions for i875 entries to be consistent with
other Intel chipsets.
 1.543 06-Jul-2003  tron Add entries for Intel 865PE chipset.
 1.542 28-Jun-2003  bouyer branches: 1.542.2;
Add some intel devices, from Quentin Garnier in private mail.
 1.541 27-Jun-2003  christos PR/21498: URA Hiroshi: Add S3 Savage/IXC
 1.540 27-Jun-2003  drochner add some missing 3c990 variants
 1.539 26-Jun-2003  ichiro add product
Aironet 350 miniPCI Wireless LAN Adapter
 1.538 14-Jun-2003  ichiro delete duplicate line
 1.537 13-Jun-2003  kent Add some ICH5/ICH5R device IDs.
 1.536 08-Jun-2003  ichiro add product ID
PRO/Wireless LAN 2100 3B Mini PCI Adapter
 1.535 07-Jun-2003  wiz Add some Brooktree device IDs.
 1.534 07-Jun-2003  wiz Add ATI Radeon 9100, 9600TX, 9500/9700.
 1.533 07-Jun-2003  ichiro add productID of ATI
 1.532 07-Jun-2003  ichiro Upps, mistaken
fixed sufix
 1.531 07-Jun-2003  ichiro add deviceID - Intel 82855PM/GM chipset
 1.530 28-Apr-2003  haya Add some Texas Instruments' CardBus bridges. Device ID are taken from
data sheets provided by TI web site and 'PCI Vendor and Device list'
web page <http://www.yourvote.com/pci>.
 1.529 28-Apr-2003  haya Add some O2Micro CardBus bridges regarding PR/20084. Device ID are
taken from FreeBSD and cross-checked by the web page 'PCI Vendor and
Device list' <http://www.yourvote.com/pci>
 1.528 24-Apr-2003  nathanw Add a few Opteron and AMD8000 chipset device IDs.
 1.527 22-Apr-2003  fvdl Add AMD 8131 PCI-X tunnel and IO apic.
 1.526 15-Apr-2003  augustss Another VIA device.
 1.525 15-Apr-2003  augustss Add another VIA CPU-AGP bridge.
 1.524 15-Apr-2003  rjs Add ID for ITE IT8152 companion chip.
 1.523 13-Apr-2003  explorer typo, s/TX4/TX2/
 1.522 12-Apr-2003  explorer add an older pci id for SATA150TX2PLUS, too
 1.521 12-Apr-2003  christos PR/8754: Andreas Wrede: Add SIIG devices
 1.520 11-Apr-2003  explorer add Promise ATA/150 TX4 id
 1.519 05-Apr-2003  lha add Radeon Mobility M7 LW (AGP)
 1.518 03-Apr-2003  kent - Forte Media PCI joystick
- Intel 82540EP chips
- Intel ICH4M IDE controller
- Modify descriptions of some ICH4 devices which ICH4M also has:
82801DB xxx -> 82801DB/DBM xxx
 1.517 29-Mar-2003  jdc Add support for USRobotics Wireless Access PCI adapter (model 132415).
From Sergio Jimenez in PR kern/20642.
 1.516 25-Mar-2003  tsubai Add new Apple devices.
 1.515 20-Mar-2003  thorpej Add some more LSI MPT IDs.
 1.514 18-Mar-2003  thorpej Add Silicon Image SATALink 3112.
 1.513 13-Mar-2003  joda more nvidia devices
 1.512 06-Mar-2003  bouyer Remove duplicate in previous.
 1.511 06-Mar-2003  bouyer Add several SiS host bridges, from FreeBSD.
 1.510 03-Mar-2003  soren Add ATI Radeon M9.
 1.509 02-Mar-2003  salo Actually, there is no space in Silicon Motion Lynx* names (e.g. Lynx EM ->
LynxEM), the already existing records misguided me.
 1.508 28-Feb-2003  enami Add product id of ServerWorks CSB6 IDE controller.
 1.507 26-Feb-2003  salo Add few more Silicon Motion, Inc. cards (Lynx EM, Lynx 3DM, Lynx 3D, Lynx)

Print various [company], Inc. consistently as (surprise) [company], Inc.
 1.506 18-Feb-2003  grant add Intel PRO/100M.
 1.505 03-Feb-2003  pooka add GeForce2 Go
 1.504 03-Feb-2003  joda correct previous, and add some more devices found in the Shuttle
SS51G.
 1.503 02-Feb-2003  bouyer Add SiS 651 host bridge.
 1.502 01-Feb-2003  matt Add Tundra (Newbridge) PowerSpan/PowerSpanII/QSpanII PCI bridges
 1.501 24-Jan-2003  thorpej Tweak a Promise description.
 1.500 24-Jan-2003  thorpej Add some more Promise products.
 1.499 24-Jan-2003  thorpej Sort the Promise entries.
 1.498 24-Jan-2003  thorpej Add Nvidia nForce2 ATA133 IDE product ID, and shuffle some
Nvidia entries around a little.
 1.497 17-Jan-2003  jonathan Add pcidevs entries for more Broadcom 570x family variants.
 1.496 16-Jan-2003  gendalia Add 3com 3c905CX-TX and Nvidia nForce2 MCP-T ac-97, on the ASUS A7N8X Deluxe
motherboard, Chipset: NVIDIA nForce2 MCP-T
 1.495 10-Jan-2003  augustss Add two Intel PCI-PCI bridges.
 1.494 30-Dec-2002  explorer add atheros communications, Inc. AR5001 reference goop. This is what the 2.4 Ghz / 5 Ghz linksys cardbus card has inside.
 1.493 26-Dec-2002  matt Add Promise Serial ATA/150 TX2plus
 1.492 26-Dec-2002  matt Add some more BCM570x variants.
 1.491 11-Dec-2002  jdolecek add Madge Smart 16/4 PCI Ringnode Mk2 entry
 1.490 03-Dec-2002  explorer add Ricoh 5C552 Cardbus + Firewire product ID
 1.489 26-Nov-2002  thorpej Add IBM 133 PCI-X Bridge.
 1.488 26-Nov-2002  thorpej Add Intel i80321 I/O processor.
 1.487 19-Nov-2002  bsh Two more vendor IDs for Samsung Electronics Co. Ltd.
 1.486 15-Nov-2002  tsutsui Remove an entry for AMD PCNETS_PCI.

AMD Am79C974 PCnet-SCSI Ethernet and SCSI conrtoller is
a multi-function PCI device which has two device IDs
of Am53C974(PCscsi-PCI) and Am79C970(PCnet-PCI),
and there is no its own ID.
 1.485 15-Nov-2002  ad Remove dup product.
 1.484 09-Nov-2002  grant add ATI Rage Mobility M1.

from FUKAUMI Naoki in kern/18987.
 1.483 08-Nov-2002  msaitoh add Adaptec 200[05]S (DPT)
 1.482 07-Nov-2002  thorpej Add Intel i31244 Serial ATA controller.
 1.481 07-Nov-2002  martin Add Myson MTD803 3-in-1 Fast Ethernet Controller.
 1.480 04-Nov-2002  wiz Fix typo reported by Nicolas Joly in PR 18921.
 1.479 25-Oct-2002  kent Correct a typo in the previous change.
 1.478 25-Oct-2002  kent Add vender IDs and product IDs:
- ENE CB1410 (http://mail-index.netbsd.org/tech-kern/2002/10/24/0038.html)
- iCompression iTVC15

Correct ID of AMD PBC8111_AC.
 1.477 24-Oct-2002  grant COREGA are OEM NDC products.
add NDC NCP130 rev A2 wireless NIC.

From T. M. Pederson in kern/18609.
 1.476 21-Oct-2002  soren Correct name of TI 802.11 chip.
 1.475 21-Oct-2002  grant add D-Link 520+ wireless ethernet.
 1.474 18-Oct-2002  yamt fix typos; "wiseman" is 82542, not 82452.
 1.473 16-Oct-2002  leo Add Fritz!PCI v2.0 ISDN Interface
 1.472 05-Oct-2002  kent - Broadcom BCM4401
- VIA VT8235
- Modify description of VT8233_AC97: "VT8233 AC-97 ..." -> "VT8233/VT8235 AC-97 ..."
 1.471 24-Sep-2002  pooka Fix Asus ISDN card ID to be the actual device ID instead of the vendor ID
 1.470 20-Sep-2002  pooka Add vendor Dynalink and a few devices by other manufacturers for use
in the iwic ISDN driver.
 1.469 19-Sep-2002  nathanw Add AMD 761 system controller and ppb.
 1.468 11-Sep-2002  bouyer Add 2 accard pciide controllers. From linux.
 1.467 06-Sep-2002  uwe Add product ids for Integraphics Systems CyberPro 2000 and 2010.
 1.466 23-Aug-2002  bouyer Add Promise Ultra133TX2 and Ultra133TX2v2 PCI ID.
 1.465 16-Aug-2002  heinz Add Lucent/Agere FW322/323 IEEE 1394 controller
 1.464 10-Aug-2002  toshii Add SiS745 host bridge.
 1.463 08-Aug-2002  drochner addanother ppb
 1.462 04-Aug-2002  thorpej Add product ID for the ADI i80200 Big Endian Companion Chip.
 1.461 03-Aug-2002  kent Add the following:
- SiS 7012 AC-97 (kern/17716)
- NVIDIA nForce MCP AC-97
- AMD 8111 AC-97
 1.460 02-Aug-2002  soren Add O2 Micro Cardbus bridge ID from PR kern/17469 by Nicolas Joly.
 1.459 02-Aug-2002  ad PR 17719 from Mark Davies: Additional Adaptec RAID controller types.
 1.458 31-Jul-2002  bouyer Ops, remove duplicate entry for 82801DB_LPC, pointed out by geoff wing.
 1.457 30-Jul-2002  bouyer Add Intel 845G PCI IDs, from kern/17743 by Andreas Wrede <andreas@planix.com>
 1.456 29-Jul-2002  augustss Add a couple of bridge devices.
 1.455 26-Jul-2002  onoe Add Silicon Image (CMDTECH) 0680
 1.454 22-Jul-2002  msaitoh Add Intel 82801E Communications I/O Controller Hub (C-ICH)
 1.453 12-Jul-2002  enami Add product id of Altima AC1001.
 1.452 09-Jul-2002  matt Add Apple Xserve PCI devices (more UniNorth) stuff.
 1.451 09-Jul-2002  thorpej Clean up Intel i8254x product names, and add i82540, i82545, and i82546
product IDs.
 1.450 07-Jul-2002  augustss Add some Sandburst products.
 1.449 05-Jul-2002  enami Add vendor id of Avlab technology, Inc. and product id of Low Profile PCI
4 Serial (but not used actually).
 1.448 04-Jul-2002  rjs Add Peak System Technik CAN Controller.
 1.447 03-Jul-2002  msaitoh add ServerWorks CMIC LE, CMIC SL and CIOB-X2
 1.446 27-Jun-2002  pooka two AVM isdn interfaces
 1.445 26-Jun-2002  cjs Add Altima AC9100 Gigabit Ethernet ID. This may not be the correct name.
However, it's the chip on the NetGear GA302T card.
 1.444 26-Jun-2002  cjs Add a couple more TI IEEE 1394 host controllers.
 1.443 22-Jun-2002  fvdl Add Altima PCI Ids.
 1.442 22-Jun-2002  cjs For new Intel network controllers, update descriptions and fix numbering.
 1.441 22-Jun-2002  cjs Add new Intel Ethernet cards.
 1.440 21-Jun-2002  thorpej Add product ID for Intel 82452KX/GX PCI-Host bridge.

PR 17353, from MOCHIDA Shuji.
 1.439 17-Jun-2002  jdolecek add VIA Technologies VT8653 and VT8633 entries
move VT82C686A_MC97 entry to where it numerically belongs
 1.438 10-Jun-2002  cjs Add Viatech VT8233A PCI-ISA Bridge.
 1.437 09-Jun-2002  taca Add VIA Technologies's VT8231 IDE Controller.
 1.436 04-Jun-2002  fvdl Add AMD 8111 IDE id.
 1.435 03-Jun-2002  briggs Add Motorola's MPC8245 (Kahlua II) host bridge.
 1.434 02-Jun-2002  seb Add product Titan PCI-800L aka VSCom PCI-800L, a 8 serial puc card, from PR
17140.
Reviewed/approved by veego@ and martin@.
 1.433 28-May-2002  christos add action tec
 1.432 28-May-2002  tron Add entries for Intel i850 and i860 chipsets.
 1.431 27-May-2002  drochner add one more of our own products
 1.430 25-May-2002  ichiro add 21555 Non-Transparent PCI-PCI Bridge
 1.429 24-May-2002  lukem add NetMos Quad UART and 1284 Printer port
 1.428 19-May-2002  bouyer branches: 1.428.2;
Add HPT372 and 74 PCI IDE controllers.
 1.427 19-May-2002  sommerfeld Some E7500 device ids
 1.426 18-May-2002  sommerfeld Some P64H2 device ids
 1.425 18-May-2002  matt Add SYMBIOS FC9[12]9 and 1030R
 1.424 15-May-2002  augustss branches: 1.424.2;
Give a more suitable name to the DEC 21554 bridge.
 1.423 14-May-2002  augustss Add a Heuricon host bridge.
 1.422 03-May-2002  augustss Add Sandburst.
 1.421 29-Apr-2002  nonaka Added two IBM devices.
 1.420 26-Apr-2002  ad Oops, add more IDs used by aac_pci.c.
 1.419 18-Apr-2002  thorpej Add Symbios 53c875A product ID.
 1.418 18-Apr-2002  tshiozak add PCI/USB vendor ID for Kurusugawa Electronics, Inc.
PCI-ID: 0x6809, USB-ID: 0x0b7e.
 1.417 16-Apr-2002  drochner add some C&T VGA chip
 1.416 15-Apr-2002  mycroft Use chip numbers for most of the new Adaptec IDs, not board numbers.
 1.415 15-Apr-2002  ad Add a bunch of Adaptec, Dell and HP products. From OpenBSD.
 1.414 05-Apr-2002  mycroft Update some ServerWorks and VIA IDs. Add the ServerWorks CSB5 southbridge and
the Apollo ProMedia 133 chipset.
 1.413 27-Mar-2002  abs Add 'CONEXANT 56KFAXMODEM 0x1085 HW 56K Fax Modem'
 1.412 19-Mar-2002  bouyer Add AMD768 devices, from
http://members.hyperlink.net.au/~chart/download/pcidevs.txt
 1.411 11-Mar-2002  joda some devices found in a dell machine
 1.410 01-Mar-2002  kleink Add Motorola Raven, Falcon and Hawk product IDs.
 1.409 28-Feb-2002  junyoung Oops, readd an ID for Rage XL which was removed in previous commit.
 1.408 28-Feb-2002  junyoung Better fix of duplicate ATI Rage Pro IDs. `_B' and `_P' mean BGA and
PQFP, respectively.
 1.407 27-Feb-2002  martin Avoid duplicate define for ATI Rage Pro PCI
 1.406 27-Feb-2002  junyoung Fully revise product IDs for ATI Mach64 and Rage graphics cards.

XXX Rage 128 not revised.
 1.405 24-Feb-2002  kleink Add IBM 82660 PowerPC to PCI Bridge and Memory Controller.
 1.404 20-Feb-2002  simonb Use BCM prefix instead of SB prefix in previous.
 1.403 20-Feb-2002  simonb Add the SiByte/Broadcom SB1250 PCI and LDT bridge IDs.
 1.402 20-Feb-2002  simonb Rename the SIBYTE entry to "Broadcom Corp. (SiByte)".
 1.401 16-Feb-2002  thorpej Add the AMD Elan SC520 System Controller.
 1.400 04-Feb-2002  junyoung Add some more product ID's for ATI Mach64 graphics cards.
 1.399 02-Feb-2002  tsutsui Add Initio INIC-850/1060 SCSI and variants.
 1.398 02-Feb-2002  tsutsui Add HiNT Corp. HB1 PCI-PCI bridge.
 1.397 30-Jan-2002  tron Fix vendor entry for "Rendition Inc.". This patch was supplied by
Paul Shupak in PR kern/15367.
 1.396 29-Jan-2002  junyoung - s/INTERGRAPHICS/INTEGRAPHICS/
- Add two product IDs for Integraphics Systems graphics cards.
 1.395 28-Jan-2002  thorpej Add product ID for the Intel i82544GC 64-bit variant.
 1.394 26-Jan-2002  tron Add missing names for devices supported by puc(4).
This patch was supplied by Paul Shupak in PR kern/15368.
 1.393 26-Jan-2002  ichiro OCHI -> OHCI
 1.392 22-Jan-2002  junyoung Rename RAGEXL to MACH64_GR.
 1.391 22-Jan-2002  junyoung Add ATI Mach64 GS.
 1.390 21-Jan-2002  ichiro fixed some products name
 1.389 21-Jan-2002  eeh Add the device id for something that claims to be an ATI Rage XL.
 1.388 21-Jan-2002  thorpej * Add Broadcom Corporation vendor ID.
* Add 3Com 3c996 product ID.
* Add Alteon "Tigon 3" (Broadcom BCM570x) product IDs.
* Add Broadcom Corporation BCM570x product IDs.
 1.387 15-Jan-2002  thorpej Add the Intel i82544GC Gig-E.
 1.386 14-Jan-2002  augustss Fix typo.
 1.385 14-Jan-2002  augustss Change some names that I added earlier.
 1.384 13-Jan-2002  augustss Add 3Com 3crwe777a AirConnect.
 1.383 09-Jan-2002  augustss Add Intel 82801 and 82830.
 1.382 05-Jan-2002  junyoung Remove Mach64 B that conflicts with Mach64 GP.
 1.381 04-Jan-2002  augustss Add a bunch of PCI-wireless PCMCIA adapters. They are probably all based
on a PLX chip. (For which we have no driver yet.)
 1.380 03-Jan-2002  rafal Add Rainbow Technologies vendor ID & Rainbow CryptoSwift 200 PKI accelerator
(CS200/PCI).
 1.379 01-Jan-2002  augustss Add a radio card.
 1.378 30-Dec-2001  ichiro add
TSB43AA22 OHCI IEEE 1394 Host Controller
 1.377 29-Dec-2001  ichiro add products
VT6305 OCHI IEEE 1394 Controller
VT3606 OCHI IEEE 1394 Controller
 1.376 20-Dec-2001  thorpej Add the product ID for the SiS 630 PCI-Host bridge.
 1.375 16-Dec-2001  thorpej Add Middle Digital, Inc. vendor ID. Add product IDs for the
Middle Digital PCI-Weasel Virtual VGA, Serial Port, and Control
registers.
 1.374 15-Dec-2001  soren Add Cologne Chip Designs ISDN controller.
 1.373 13-Dec-2001  bouyer Add some promise controllers, from FreeBSD
 1.372 11-Dec-2001  ad Add some Intel/ICP-Vortex/Compaq products.
 1.371 11-Dec-2001  kleink Add product ID for the Motorola MPC107.
 1.370 07-Dec-2001  onoe Add HPB and LPC functions of 82801BAM.
 1.369 07-Nov-2001  thorpej Correct i80312 description.
 1.368 07-Nov-2001  thorpej Add product ID for the Cyclone PCI-700 (IQ80310).
 1.367 25-Oct-2001  augustss Add some VIA KT266 numbers.
 1.366 24-Oct-2001  thorpej Add product IDs for the Powerhouse Systems PowerPro and PowerTop
PowerPC system controllers.
 1.365 24-Oct-2001  thorpej More Intel Gig-E ID fixups, and add Intel i82544 Gig-E IDs.
 1.364 16-Oct-2001  tron branches: 1.364.2;
Add host bridges of SiS 645, 650 and 730 chipsets.
 1.363 13-Oct-2001  ichiro add vendor & product ID
Intersil PRISM2.5 Mini-PCI WLAN
 1.362 11-Oct-2001  tron Add host bridge of the SiS 735 chipset.
 1.361 03-Oct-2001  simonb Minor correction to the name of the 405GP PCI bridge.
 1.360 01-Oct-2001  thorpej Add product ID for the RealTek 8139[BC].
 1.359 28-Sep-2001  thorpej More corrections to Intel Gig-e product IDs.
 1.358 27-Sep-2001  itojun add 4DWAVE and SiS sound devices.
 1.357 15-Sep-2001  chris Add voodoo 4/5 entry for 3DFX.
 1.356 10-Sep-2001  eeh Add Sun GEM gigabit network card.
 1.355 05-Sep-2001  drochner branches: 1.355.2;
we (research center Juelich) are a PCISIG member now - add the vendor ID
and some products
 1.354 04-Sep-2001  thorpej Add product ID for the Intel IXP1200 Network Processor.
 1.353 04-Sep-2001  pooka add Allegro-1 ID

also from Jared D. McNeill
 1.352 04-Sep-2001  pooka add another device ID for the ESS Maestro3

from Jared D. McNeill
 1.351 30-Aug-2001  soren Add some more Hifn chips.
 1.350 28-Aug-2001  tsubai Add more Apple devices.
 1.349 27-Aug-2001  enami Sort Intel products by id and kill duplicated entries.
 1.348 27-Aug-2001  ad Add a DPT PCI-PCI bridge.
 1.347 23-Aug-2001  thorpej Take part numbers out of the PCnet-PCI product descriptions.
 1.346 23-Aug-2001  thorpej Add Promise ATA/100 TX2 device ID.
 1.345 20-Aug-2001  fvdl Add some entries for the AMD 76x chipset for completeness.
 1.344 20-Aug-2001  gehenna Add NEC USB2.0 Host Controller
 1.343 18-Aug-2001  thorpej Add Avance Logic ALS4000 Audio.
 1.342 17-Aug-2001  matt Add Apple Uni-N (as used in QuickSilver) product IDs.
 1.341 13-Aug-2001  cjs Add Transmeta and products, and an ALI integrated sound/modem device.
 1.340 31-Jul-2001  matt Add pci ids for the Intel 80312 I/O companion chip for the
Intel 80200 XScale processor.
 1.339 28-Jul-2001  pooka 3c556 V.90 MiniPCI modem
 1.338 25-Jul-2001  thorpej Add the Antares Microsystems, Inc. vendor ID, and the product ID
for their Gigabit Ethernet board (a TC9021 board targeted at the
Sun market).
 1.337 23-Jul-2001  bouyer Add TITAN PCI100H.
 1.336 30-Jun-2001  thorpej branches: 1.336.2;
Change the DLINK ST-201 entry, add more Sundance/DLINK Gig-E
products.
 1.335 28-Jun-2001  thorpej Add Tamarack Microelectronics, Inc. vendor ID, and product ID for
Tamarack TC9021 Gigabit Ethernet.
 1.334 27-Jun-2001  mcr added Solidum PAX.ware 1100 and Lucent ORCA PCI targets
 1.333 20-Jun-2001  thorpej Add more/update existing 3Com 3CR990 product IDs.
 1.332 20-Jun-2001  thorpej Add SysKonnect SKNET-GE (GEnesis Gigabit Ethernet).
 1.331 20-Jun-2001  imp Add O2Micro PCI-{CardBus,PCMCIA} bridges:
OZ6729, OZ6730, OZ6832/OZ6833, OZ6860 and OZ6812/OZ6872
 1.330 18-Jun-2001  onoe Add Cisco/Aironet 350
 1.329 17-Jun-2001  tsubai Add device IDs on the new iBook.
 1.328 13-Jun-2001  simonb Add a port to IBM's PPC405GP Reference Board (the "walnut")
by Eduardo Horvath and Simon Burge of Wasabi Systems.

IBM 4xx series CPU features:
- New pmap and revised trap handler.
- Support on-chip timers, PCI controller, UARTs
- Framework for on-chip ethernet and watchdog timer.
General PowerPC features:
- Add in-kernel PPC floating point emulation
- New in{,4}_cksum that is between 1.5 and 5 times faster than the
old version depending on CPU type.
General changes:
- Kernel support for generic dbsym-style symbols.
 1.327 11-Jun-2001  thorpej Add Level One product ID, and LXT-1001 10/100/1000 Ethernet
product ID.
 1.326 11-Jun-2001  tron Add support for the D-Link DFE-530TX+. Patch supplied by
Gabriel Rosenkoetter in PR kern/13161.
 1.325 31-May-2001  nisimura Add product IDs for IDT RC32234 and RC32334 system controllers.
 1.324 21-May-2001  thorpej Add ICH3 network controller IDs.
 1.323 18-May-2001  enami Add product IDs of internal devices found in NEC VRC4173 and vendor/product
ID of MediaQ MQ200.
 1.322 17-May-2001  drochner add some stuff I got between my fingers
 1.321 14-May-2001  thorpej Add product ID for the National Semiconductor DP83820 Gigabit Ethernet
chip.
 1.320 06-May-2001  fvdl Add some IDs for the AMD760 chipset, as specified in the datasheet.
 1.319 25-Apr-2001  simonb Spell "portege" correctly - it's a computer, not a car.
 1.318 21-Apr-2001  tsutsui Correct an entry for Acard UDMA IDE controller.
The chip is actually marked as ATP860-A, not ATP860R.
 1.317 13-Apr-2001  hubertf Move the Trident CyberClade entry where it belongs.
 1.316 12-Apr-2001  itojun change symbol for LMC T1 card. part of PR 12331.
 1.315 12-Apr-2001  matt Add UltraSparc IIe PCI interface.
 1.314 09-Apr-2001  ad Add Tekram DC-315/DC-395.
 1.313 31-Mar-2001  minoura Add Cyrix products (MediaGX).
 1.312 21-Mar-2001  soren Lower-case a few hex digits for easier searching.
 1.311 21-Mar-2001  hubertf Add Trident CyberBlade as found in Toshiba Satellite Pro 4600
 1.310 20-Mar-2001  mrg add sun device ids found on sunblade1000 systems.
 1.309 17-Mar-2001  thorpej Fixup some Intel Gig-E entries.
 1.308 13-Mar-2001  bouyer Add Titan Electronics Inc vendor ID (from linux) and Titan VS-800H
product.
 1.307 07-Mar-2001  matt Add Galileo GT-64260.
 1.306 05-Mar-2001  matt branches: 1.306.2;
Add Winbond W83C533F functions.
 1.305 04-Mar-2001  msaitoh Add an entry for NetMos
 1.304 02-Mar-2001  thorpej Add Mylex AcceleRAID and eXtremeRAID product and sybsystem IDs.
 1.303 02-Mar-2001  thorpej Add product ID for Xircom WinGlobal modem.
 1.302 18-Feb-2001  bouyer Add Intel 82801BAM IDE controller, found in laptops. From OpenBSD
 1.301 18-Feb-2001  matt Add Symbios FC909
 1.300 12-Feb-2001  tshiozak add CMI8738B.
 1.299 11-Feb-2001  ad Add another 3ware product.
 1.298 04-Feb-2001  briggs Add the MPC8240 (Kahlua) Host Bridge
 1.297 02-Feb-2001  hubertf Add M5243 PCI-AGP Bridge
Fixes PR 11466 by Jared D. McNeill <jmcneill@invisible.yi.org>
 1.296 31-Jan-2001  thorpej Add the SEGA Dreamcast Broadband Adapter.
 1.295 26-Jan-2001  rh Add Toshiba Protege product code
 1.294 26-Jan-2001  rh Add product code for the Compaq Armada M700 Notebook
 1.293 22-Jan-2001  jdolecek add US Robotics (3Com) 56K Voice Internal PCI Modem (WinModem) entry
I wish I'd been less foolish and not bought this device ...
 1.292 22-Jan-2001  mjl Add stallion products.
 1.291 17-Jan-2001  thorpej Update the Intel Gigabit Ethernet entries.
 1.290 15-Jan-2001  thorpej Add the 66MHz version of the Symbios 53c1010.
 1.289 12-Jan-2001  itojun add product ID for LMC T1 card. from freebsd.
 1.288 09-Jan-2001  rh Add COMPAL vendor and COMPAL 38W2 product (OEM for Dell Inspiron 5000e)
 1.287 09-Jan-2001  thorpej Add Symbios 53c1510D.
 1.286 08-Jan-2001  thorpej Add product ID for the Accton EN2242 10/100 Ethernet (an ADMtek AN985).
 1.285 08-Jan-2001  thorpej Add product ID for DEC SWXCR RAID (a Mylex v5 controller).
 1.284 08-Jan-2001  rh Add IDs for the NEC Versa LX and Versa Pro LX
 1.283 03-Jan-2001  mycroft Add Chrysalis-ITS LunaVPN card.
 1.282 31-Dec-2000  ad Fix Mylex products.
 1.281 30-Dec-2000  eeh Fix typo.
 1.280 30-Dec-2000  eeh Add Sun psycho bus controller.
 1.279 27-Dec-2000  tsutsui Fix entries of Acard UDMA IDE controllers.
 1.278 27-Dec-2000  augustss Add a VIA chipset and Nvidia GeForce2 MX.
 1.277 23-Dec-2000  tsutsui Add Acard UDMA IDE controllers.
 1.276 14-Dec-2000  onoe add Aironet 4500/4800
 1.275 05-Dec-2000  drochner add some chips I met in the last weeks
 1.274 20-Nov-2000  onoe CXD32222 -> CXD3222 (Sony OHCI Controller)
 1.273 18-Nov-2000  thorpej Add some 3D Labs products, from XFree86, via groo@netbsd.org
 1.272 14-Nov-2000  bouyer Add Alteon and netgear 1000baseT variants of the gigabit ethernet adapter.

From FreeBSD
 1.271 04-Nov-2000  thorpej Add a couple NeoMagic products. From OpenBSD.
 1.270 03-Nov-2000  ad Oops
 1.269 03-Nov-2000  ad Pequr Technology is now called ServerWorks.
 1.268 27-Oct-2000  thorpej Add a bunch of Intel PCI chipsets. From OpenBSD.
 1.267 27-Oct-2000  thorpej Add a bunch of Pequr (ServerWorks) products. From OpenBSD.
 1.266 19-Oct-2000  thorpej Add the ICS Advent PCI-WDT500/501 watchdog timer boards.
 1.265 14-Oct-2000  simonb Add ATI Mobility M3 (both PCI and AGP).
 1.264 12-Oct-2000  itojun pci device ID for hifn 7751-based crypto cards. from openbsd.
 1.263 03-Oct-2000  thorpej Add ADMtek AN985 10/100 Ethernet.
 1.262 27-Sep-2000  augustss Add some ATI Rage cards and some Intel chips.
 1.261 20-Sep-2000  thorpej Add National Semiconductor DP83815 10/100 Ethernet.
 1.260 19-Sep-2000  fvdl Add IDs for the 3c555, 556 and 556B 3Com MinPCI Ethernet cards.
 1.259 13-Sep-2000  ad Add product IDs for AMI MegaRAID boards.
 1.258 13-Sep-2000  tron Remove incomplete (and incorrect) entry for D-Link 530.
 1.257 13-Sep-2000  tron Use "VT6102 (Rhine II) 10/100 Ethernet" as description to be consistent
with existing entry for "VT86C100A (Rhine-II) 10/100 Ethernet".
 1.256 13-Sep-2000  tron Add VT6102 Rhine II 10/100BaseTX ethernet chip used on e.g. the
D-Link 530TX NIC.
 1.255 07-Sep-2000  soren s/AT&T Microelectronics/Lucent Technologies/
 1.254 04-Sep-2000  soren Add Intel 440GX host bridge.
 1.253 04-Sep-2000  itojun Brooktree Bt8474 Multichannel Synchronous Communictaions Controller (MUSYCC)
 1.252 02-Sep-2000  cgd after discussion with veego, rename constant for 3D Labs Permedia 2 from
PERMEDI2 to PERMEDIA2. (substance over style. 8-) Also, fix a typo
I noticed in a comment.
 1.251 29-Aug-2000  wiz add vendors HAUPPAUGE, ASKEY, AVERMEDIA
 1.250 21-Aug-2000  enami Add a product id for the promise ata-100 controller found on
MS-6321 (694D Pro). Reported in the PR#10756 by Kazuki Sakamoto.
 1.249 21-Aug-2000  haya Add several Texas Instrument's PCI-CardBus bridges.
 1.248 10-Aug-2000  soren s/Toshiba America Info Systems/Toshiba/ since they are the main PCI issuer.
Add new version of the Oboe FIR device.
 1.247 07-Aug-2000  billc Added PCI IDs for 3Com's Home Connect (3c450) and Office Connect (3cSOHO100).
They both are register compat with later versions of the 3c905 (tornado/
vortex) series.
 1.246 04-Aug-2000  ad Vortex Computer Systems changes, from OpenBSD:
- Add product ID for GDT6518RS.
- Fix bogus product IDs.
 1.245 23-Jul-2000  jonathan * Add entries for older Yamaha YMF chips (724, 740) plus the
newer steppings (740C, 724F) which use the same microcode as the
DS-1S/DS-1E
 1.244 20-Jul-2000  ad Add what is apparently ESS's old vendor ID and corresponding product ID for
the Maestro 1.
 1.243 10-Jul-2000  ad Add ICP Vortex RAID controllers.
 1.242 09-Jul-2000  mycroft Add ID for i82559ER.
 1.241 08-Jul-2000  mrg add microSPARC IIep PCI controller
 1.240 04-Jul-2000  enami Add device ID of promise ultra100/ata controller.
 1.239 03-Jul-2000  gmcgarry Devices found in NEC Versa Note VX
 1.238 24-Jun-2000  joda add Intel 82801BA devices
 1.237 21-Jun-2000  bouyer Add CMD PCI0649 product ID.
 1.236 16-Jun-2000  soren branches: 1.236.2;
Add some S3 chips.
 1.235 13-Jun-2000  tron Add CMD PCI0648.
 1.234 12-Jun-2000  nathanw Add AMD 79c978 PCnet-PCI Home.
 1.233 12-Jun-2000  bouyer Shorter description for the HPT366
 1.232 12-Jun-2000  bouyer Add HPT366/370 device ID.
XXX Is 'TRIONES' the rigth vendor name ?
 1.231 09-Jun-2000  augustss Add some PCI devices found in the IOpener (commited from the IOpener itself :).
 1.230 07-Jun-2000  ad Add vendor/device ID for 3ware Escalade IDE RAID controller.
 1.229 07-Jun-2000  mrg fix a couple of the sun entries.
 1.228 07-Jun-2000  soren Add Trident 9397DVD.
 1.227 06-Jun-2000  kleink Add the product ID for the ESS Maestro 3 modem function as well.
 1.226 05-Jun-2000  kleink Add the ESS Maestro 3 product ID as well.
 1.225 05-Jun-2000  kleink ESSTECH:
* add what's allegedly the Maestro 1's product ID.
* align product names with data sheets.
 1.224 30-May-2000  matt Add the TI 1394 controllers. Makes all the 1394 controller descriptions
similar.
 1.223 28-May-2000  drochner -correct description for 3c905b-FX (100 Mb only)
-add Neomagic 256ZX
 1.222 27-May-2000  scw Add entries for a couple of OPTi PCI-IDE controllers.
 1.221 27-May-2000  nathanw Whitespace police.
 1.220 27-May-2000  soren branches: 1.220.2;
Add a few devices.
 1.219 26-May-2000  matt Add NEC 1394 OHCI chips
 1.218 18-May-2000  drochner fix typo in last commit
 1.217 18-May-2000  garbled Add the device ID for the IBM MPIC-II.
 1.216 14-May-2000  soren Add SGI IOC3.
 1.215 12-May-2000  thorpej Add product ID for 3Com 3c980C-TXM 10/100 Ethernet. From Paul J. Lavoie,
kern/10037.
 1.214 07-May-2000  jonathan Product codes for Yamaha YMF744B (DS-1S) YMF754 (DS-1E) audio chips.
 1.213 30-Apr-2000  dante Add ASB-3940U3W host adpeter (AdvanSys)
 1.212 28-Apr-2000  augustss Add 2 more eap audio devices.
 1.211 26-Apr-2000  thorpej Add product ID for the PLX Technology 9060ES PCI bus controller. Note this
ID isn't normally seen, as just about every device with a PLX on it loads
a different ID from an EEPROM, but there's no harm in documenting it.
 1.210 22-Apr-2000  augustss Add some CMedia audio devices. From T.SHIOZAKI <AoiMoe@imou.to>
 1.209 19-Apr-2000  bouyer Add some Symbios devices.
 1.208 18-Apr-2000  cgd SiByte, Inc. is vendor 0x166d.
 1.207 17-Apr-2000  thorpej Add product ID for the S3 Trio3D/2X AGP graphics adapter.
 1.206 03-Apr-2000  joda add some NVIDIA chipsets
 1.205 31-Mar-2000  tsarna Add auvia, a driver for the integrated AC'97 audio on the VIA VT82C686A
southbridge.

Tested on a ASUS K7M (w/ AD1881 codec). Please report any problems.
 1.204 30-Mar-2000  joda add the device id for the VIA 686A modem controller, continuing the
trend of mislabelling VIA's south bridges
 1.203 27-Mar-2000  ad Add a couple of DPT devices.
 1.202 23-Mar-2000  joda add two Intel 82810E devices (from IWAMOTO Toshihiro)
 1.201 23-Mar-2000  ad Back out rev 1.197.
 1.200 21-Mar-2000  joda add two VIA VT8371 devices
 1.199 16-Mar-2000  thorpej Add product ID for the Intel InBusiness 10/100 Ethernet adapter (which
is an i82559 with a different product ID).
 1.198 14-Mar-2000  tsarna Add product ids for some VIA Technologies VT82C686A southbridge devices.
 1.197 13-Mar-2000  ad Add a bunch of Compaq array controllers.
 1.196 11-Mar-2000  jdolecek Add id for Alliance AT25, as sent by Dave Sainty in kern/9596.
 1.195 09-Mar-2000  jdolecek Add Conexant SoftK56 PCI Software Modem, Sony CXD3222 OHCI i.LINK(IEEE 1394)
PCI controller, Sony Memory Stick I/F Controller
Ids send by John Hawkinson in kern/9588
 1.194 06-Mar-2000  mark Add SYMPHONY 83C553 PCI-ISA bridge.
Add alternative ID for Winbond W89C940F.
 1.193 04-Mar-2000  tron Add AMD Athlon chipset related devices. Patch supplied by Dave Sainty in
PR kern/9533.
 1.192 16-Feb-2000  soren Add Toshiba ISA bridge.
 1.191 08-Feb-2000  bouyer Add US Robotics vendor ID, and USR 3CP5609 PCI 16550 Modem product ID.
From Kent Polk.
 1.190 03-Feb-2000  dante Add AdvanSys U2W boards
 1.189 03-Feb-2000  joda 2 Micro -> O2 Micro
 1.188 31-Jan-2000  thorpej Add SiS 7016 10/100 Ethernet.
 1.187 25-Jan-2000  haya Add TI PCI 1451 PCI-CardBus bridge.
 1.186 24-Jan-2000  joda TI PCI2030 is a PCI-PCI bridge
 1.185 23-Jan-2000  tsubai Add Apple KeyLargo and UniNorth.
 1.184 12-Jan-2000  haya Add an entry for Toshiba ToPIC100 CardBus-PCI bridge.
 1.183 11-Jan-2000  matt Add CompuModules DVB receiver and transmitter boards.
 1.182 09-Jan-2000  soren Add MPC105.
 1.181 05-Jan-2000  drochner add some stuff which was mentioned on the mailing lists recently
 1.180 30-Dec-1999  hubertf Add an entry for the Trident Microsystems CYBER 9525
(as found in an Toshiba Satellite 2650 XDVD).
 1.179 17-Dec-1999  drochner add Intel 450NX stuff
 1.178 17-Dec-1999  augustss Change the Galileo entries so the generated code can be compiled.
 1.177 17-Dec-1999  soren Fix comment.
 1.176 17-Dec-1999  soren Add Galileo Technology system controllers.
Remove obsolete ID database URL.
 1.175 15-Dec-1999  kleink * Add ESS Maestro2 product ID.
* Add TerraTec vendor ID.
 1.174 04-Dec-1999  castor Add vendor ID for Lava Semiconductor (http://www.lavalink.com)
 1.173 04-Dec-1999  thorpej Add some of the Compaq RAID controller IDs.
 1.172 01-Dec-1999  drochner add Cyclades 4Y and 8Y
 1.171 30-Nov-1999  drochner add 3c905B-COMBO
 1.170 17-Nov-1999  augustss Add the SBLive! joystick device.
 1.169 12-Nov-1999  is Identification of DOMEX PCI-SCSI board, by Thilo Manske, PR 8772.
 1.168 07-Nov-1999  cgd back out rev 1.166:
(1) the list added isnt' complete and i'd call it incorrect. (There are
other devices with these names, where were omitted. I've never seen
the devices with these IDs, I _have_ seen the other devices that go
by these names.)
(2) the PR (8754) had not been updated to note that the problem was
fixed, and i'd preiously asked the submitter for more information and/or
a corrected list.
 1.167 06-Nov-1999  rh Add vendor/product entry for Auravision VxP524 PCI Video Processor.
 1.166 06-Nov-1999  augustss Add SIIG devices. Closes PR kern/8754 from Andreas Wrede <andreas@planix.com>
 1.165 04-Nov-1999  tsarna Add Aureal AU8820
 1.164 04-Nov-1999  augustss Add SBLive!
 1.163 04-Nov-1999  joda add Xircom X3201-3 Fast Ethernet Controller
 1.162 01-Nov-1999  augustss Add FM801 audio device driver. From Witold J. Wnuk ww181302@zodiac.mimuw.edu.pl
Closes PR kern/8729.
 1.161 29-Oct-1999  matt Add AHA-1480 (adaptec cardbus scsi)
 1.160 29-Oct-1999  haya Maintainance the name of Ricoh PCI-CardBus bridges.
 1.159 11-Oct-1999  hannken branches: 1.159.2; 1.159.4;
Add an entry for the Adaptec 2940UW Pro Scsi adapter.
 1.158 29-Sep-1999  thorpej branches: 1.158.2;
- Add Sundance Technolgy vendor ID.
- Add Sundance Technolgy ST201 10/100 Ethernet product ID.
- Add D-Link DFE-550TX product ID (uses ST201 chip).
 1.157 29-Sep-1999  thorpej Add adaptec AIC-6915 10/100 Ethernet.
 1.156 27-Sep-1999  ad s@SmartCache/Raid@SmartCache/SmartRAID@
 1.155 11-Sep-1999  soren Add ENI SpeedStream.
 1.154 10-Sep-1999  augustss Add more TI CardBus bridges. Taken from the CardBus patches.
 1.153 08-Sep-1999  thorpej Add some more Tulip clones.
 1.152 08-Sep-1999  thorpej Add Davicom Semiconductor vendor ID, and Davicom DM9102 10/100 Etherent
product ID (Yet Another Tulip Clone).
 1.151 08-Sep-1999  thorpej LITEON_PNIC -> LITEON_82C168
 1.150 01-Sep-1999  drochner -add some incarnations of the Alteon gigabit Ethernet adapter
-sort some entries which were put in by legasthenics
 1.149 28-Aug-1999  augustss Add a bunch of i810 devices. From Paul Shupak <paul@plectere.com>.
 1.148 27-Aug-1999  thorpej Add Samsung Semiconductor KS8920 10/100 Ethernet.
 1.147 24-Aug-1999  soren Add Intel i740.
 1.146 17-Aug-1999  drochner -mention a location where the old PCI database can still be found
-add Alteon Gigabit Ethernet
 1.145 16-Aug-1999  mcr Added Solidum Systems PCI vendor ID and Device IDs
 1.144 12-Aug-1999  bouyer Add Promise Ultra66, change entry of Ultra33 to reflect the fact that can
"only" do ultra/33.
 1.143 01-Aug-1999  veego Add an entry for the TI PCI1211 PCI-CardBus Bridge.
From the cardbus patches.
 1.142 29-Jul-1999  thorpej Add some Initio SCSI controller IDs.
 1.141 28-Jul-1999  soren Correct Acard device names.
Add and update a few IBM devices.
Add Toshiba and NEC devices in Portege 3K's.
 1.140 27-Jul-1999  castor Add vendor ID for Geocast
 1.139 27-Jul-1999  thorpej Add product ID for the SMC 83c175 Fast Ethernet chip. This is a cousin
of the SMC 83c170 which also supports CardBus.
 1.138 20-Jul-1999  drochner add TI TVP4020 Permedia 2
 1.137 15-Jul-1999  ross product 3COM 3C905CTX 0x9200
 1.136 15-Jul-1999  augustss Add Cinemaster C 3.0 DVD Decoder.
 1.135 14-Jul-1999  fvdl Add/change a few Adaptec controller IDs.
 1.134 12-Jul-1999  kleink Change the ESS Solo-1 description string to match the data sheet.
 1.133 30-Jun-1999  fair A reference to http://members.hyperlink.net.au/~chart/pci.htm in comments;
this new effort at collecting PCI data outside the PCI SIG replaces the
one that was referenced in here before.

No regeneration required.
 1.132 27-Jun-1999  drochner add some realtek 8139 clones
 1.131 19-Jun-1999  augustss Add Sony CXD 1947A FireWrire Controller and Neomagic 128XD.
 1.130 18-Jun-1999  tsubai Add some Apple and MOT products.
 1.129 05-Jun-1999  tron Add Matrox MGA 400, 3Dfx Banshee and Voodoo 3.
 1.128 05-Jun-1999  tron Add entry for Riva TNT and correct entry for Riva 128.
Fixes first half of PR kern/7699 by Bjoern Labitzke.
 1.127 02-Jun-1999  drochner add SIS 6326 low-end AGP graphics
fix CL_PD6832 device id, PR kern/7691 from Paul Dokas
 1.126 29-May-1999  mrg fix error in previous.
 1.125 29-May-1999  mrg s/bus/bridge/ for the sun pci bridges. my bad.
 1.124 29-May-1999  fvdl Add 3c900B-TPC product ID. From Robert Elz.
 1.123 27-May-1999  mrg add the UltraSPARC IIi PCI interface
 1.122 23-May-1999  veego Add several entries.
 1.121 20-May-1999  augustss Change vendor id 0x11c1 to Lucent since that seems to be what it is now.
Add a Lucent USB controller.
 1.120 17-May-1999  drochner add NeoMagic 256AV Video/Audio chip
 1.119 07-May-1999  hwr Added CIRRUS CL_PD6832 from "Johnny C. Lam" <lamj@stat.cmu.edu> in kern/7119.
 1.118 07-May-1999  hwr Added TI PCI1251 from joda@pdc.kth.se (Johan Danielsson) in kern/6873.
 1.117 07-May-1999  drochner add another AGP graphics chip and a PCI-VME interface
 1.116 07-May-1999  matt Add TI LYNX FireWire Controller (as used in the Apple B&W G3)
 1.115 06-May-1999  mrg add pci devices found in U5's:
- ati weird mach64
- ebus bus
- `network' hme compatible ethernet
- `simba' PCI bus
 1.114 12-Apr-1999  jonathan Add entries for TI, Ricoh, Toshiba PCI-to-cardbus bridge chips, so
we can identify them as cardbus chips supported by the cardbus patches.

Add entry for OPTI chipsets whose interrupts arent properly set up by
some BIOSes.

From cardbus patches<ftp://nandra.iri.co.jp/pub/NetBSD/CardBus by
HAYAKAWA Koichi <haya@tcad.ulsi.sony.co.jp>.
 1.113 25-Mar-1999  explorer branches: 1.113.2;
Add LAN Media Corporation info
 1.112 19-Mar-1999  mycroft Add AudioPCI 97 (a.k.a. Creative Ensoniq AudioPCI).
 1.111 17-Mar-1999  thorpej Add Silicon Integrated Systems SiS900 10/100 Ethernet.
 1.110 16-Mar-1999  mjacob add Qlogic 1080 && 1240 product IDs
 1.109 11-Mar-1999  sakamoto Add several VIA Technologies chipsets.
 1.108 09-Mar-1999  drochner add 2 ISDN cards, from Martin Husemann per PR kern/7110
 1.107 19-Feb-1999  thorpej Improve descriptions for DEC Ethernet chips.
 1.106 19-Feb-1999  thorpej Improve the descriptions of 3Com Ethernet cards, and add the 3c905B-FX
and 3c980 Server Adapter products.
 1.105 19-Feb-1999  thorpej Add several Tulip clone chips.
 1.104 14-Feb-1999  tron Add 3Dfx's Voodoo II. Fixes PR kern/7000 by Brett Lymn.
 1.103 05-Feb-1999  thorpej Add some Olicom Ethernet device IDs, from FreeBSD's tl driver.
 1.102 28-Jan-1999  augustss Add S3 86C365 Trio3D.
 1.101 16-Jan-1999  drochner add another NCR chip, from Dave Sainty <dave@dtsp.co.nz> per PR kern/6819
 1.100 30-Dec-1998  hwr Add NeoMagic MagicGraph 128ZV graphic chip.
 1.99 21-Dec-1998  drochner change name of 82443BX according to Intel's data sheet
correct "no AGP" case to real topology of the chip
clarification: s/AGP Device/AGP Interface/
 1.98 20-Dec-1998  drochner add a Zoran multimedia controller chip
 1.97 18-Dec-1998  thorpej Add product ID for the Yamaha 724 Audio device. PR #6605, Dave Sainty.
 1.96 09-Dec-1998  thorpej Some more touchup on the VIA Rhine chip model number, and so some
sorting.
 1.95 05-Dec-1998  matt Add Sigma Designs REALmagic Hollywood Plus MPEG-2 decoder
 1.94 30-Nov-1998  jtk Per PR/6172 (Johnny Lam, lamj@stat.cmu.edu), fix pcidevs identification
of CL-PD6729. See <http://www.cirrus.com/products/overviews/pd6729.html>.
 1.93 29-Nov-1998  thorpej Fix the original Rhine's part number (thanks to Greg Oster).
 1.92 29-Nov-1998  thorpej Garbage-collect some bogus RealTek entries.
 1.91 29-Nov-1998  thorpej Add product IDs for the VIA Rhine and Rhine-II 10/100 Ethernet chips.
(XXX What is the original Rhine's part number?!)
 1.90 27-Nov-1998  drochner add Powerstorm 4D50T graphics found in some Alphas
 1.89 23-Nov-1998  mcr added 82443BX_AGP_NOT as per kern/5847
 1.88 20-Oct-1998  thorpej Add RealTek 8129 and 8139 10/100Mb Ethernet IDs.
 1.87 19-Oct-1998  bouyer Yet another attemp at getting the VIA tech. product name/ID's rigth.
It seems that different products have the same name (sigh).
 1.86 05-Oct-1998  tron Correct vendor 0x1191 to "ACARD", add missing Matrox boards.
Fixes PR kern/6251 by Soren S. Jorvang.
 1.85 04-Oct-1998  tron Add S3 Virge/DX, fixes PR kern/6245 by Steve Allen.
 1.84 01-Oct-1998  fvdl Fix typo in 905BT4 product name.
 1.83 26-Sep-1998  dante Change product ADVSYS 2300 to ADVSYS WIDE
 1.82 22-Sep-1998  mark Add ALI M1531 Host-PCI bridge.
Add Cirrus Logic CS4610 and CS4280 Audio chips.
Add Cirrus Logic CS4400 communications controller.
 1.81 18-Sep-1998  drochner Add PCI-VME interfaces: Tundra Universe and Bit3 2706
Note that Newbridge is now Tundra
Add Adaptec 7890 & Co.
 1.80 18-Sep-1998  mark Add yet another vendor ID for Fujitsu.
Add vendor ID for ESS Technology Inc.
Add product ID for ESS Technology ES1938 SOLO-1 AudioDrive
Add product ID for Fujitsu K56flex LTMODEM
Add product ID for TI PCI1250 PC Card bridge
Add product ID for Trident Cyber 9397 Video controller.
 1.79 06-Sep-1998  veego Add the Brooktree 878 and 879 id's and fix the comment of the 849 entry.
 1.78 26-Aug-1998  drochner add the SIS 5597/5598 all-in-one PCI chipset
 1.77 26-Aug-1998  dante Changed ADVSYSPROD to ADVSYS vendor ID
Added 1200A, 1200B, ULTRA, 2300 AdvanSys products ID
 1.76 07-Aug-1998  thorpej Add product IDs for the 3Com Cyclone-based PCI Ethernet devices,
the 3c90xB DMA-only cards.
 1.75 28-Jul-1998  thorpej Add the IMS TwinTurbo 128M graphics board.
 1.74 27-Jul-1998  tron "Brooktree Brooktree Bt848" -> "Brooktree Bt848"
 1.73 27-Jul-1998  tron Add Brooktree Bt848 and BT849 video capture chips.
 1.72 27-Jul-1998  augustss Add S3 SonicVibes.
 1.71 25-Jul-1998  explorer define RISCom and RISCom N2 product
 1.70 22-Jul-1998  drochner add IDs for ACC Micro 2051 "PCI Single Chip Solution"
 1.69 19-Jul-1998  tron Fix product ID for Matrox Mystique, add NEC PowerVR PCX2.
 1.68 13-Jul-1998  mark Add ID for ALI M1541 Host-PCI bridge.
 1.67 10-Jul-1998  tron Add Intel's BX chipset, 3Dfx Interactive and their Voodoo board.
 1.66 30-Jun-1998  augustss Add a 2 Micro CardBus controller.
 1.65 15-Jun-1998  bouyer Argh, comments have to be in /* */, not # !
Sorry for the one-in-tree commit.
 1.64 15-Jun-1998  bouyer Hum the "VT82C595 (Apollo VP2) Host-PCI Bridge" has 2 devices entries
(in FreeBSD too). Make it VT82C595 and VT82C595_2.
 1.63 15-Jun-1998  bouyer Add some VIA tech. products.
 1.62 25-May-1998  mark Added TriTech Microelectronics vendor ID.
Added TriTech Pyramid3D 25202 product ID.
Added Promise Ultra33 UltraDMA IDE controller product ID.
Added ALI product ID's for M1543 'Southbridge' PCI devices.
 1.61 14-May-1998  augustss Add another USB controller.
 1.60 13-May-1998  augustss Add OPTi OHCI USB host controller.
 1.59 05-May-1998  thorpej Add a few more NE-2000 compatible PCI Ethernet interfaces. XXX Some of
these may need further revision to get vendor and product names exactly
right.
 1.58 04-May-1998  thorpej Add STB Systems' second PCI vendor ID, and their Velocity128 AGP product.
kern/5362, Paul Goyette <paul@whooppee.com>
 1.57 30-Apr-1998  mycroft Add the Apple Bandit chip.
 1.56 16-Apr-1998  drochner add 2 ATM chips, correct entry for Toshiba MIPS bridge
 1.55 28-Mar-1998  thorpej Add the Contaq/Cypress 82C693 PCI-ISA bridge.
 1.54 28-Mar-1998  cgd fix bogus produce name tags for 82371FB_ISA and 82371FB_IDE (were 82471FB_*).
Pointed out by Soren S. Jorvang. Rename "BAD" vendor id to "INVALID".
 1.53 07-Mar-1998  augustss Add Matrox Millenium II AGP.
 1.52 04-Mar-1998  cgd fix comment bogon in last commit
 1.51 04-Mar-1998  cgd add CMD PCI0643, PCI0647, USB0670, USB0673. Remove the 'A' from the 640A
entry (because the same product id is used for the 640B, as well). Note
that a few of the entries (PCI0642, PCI0650A) no longer have data to
be found on the CMD web site, and note that PCI0650A should probably have
its "A" trimmed as well.
 1.50 27-Feb-1998  mycroft Add Macronix MX98713.
 1.49 07-Feb-1998  augustss Fix typo, and commit in the right order.
 1.48 07-Feb-1998  augustss Add the AGP device in the 82443LX.
 1.47 27-Jan-1998  thorpej Add product ID for the Packet Engines G-NIC gigabit Ethernet interface.
 1.46 22-Jan-1998  mycroft Add the Millenium II.
 1.45 16-Nov-1997  christos PR/4510: William Coldwell: Add TI thunderlan support.
 1.44 27-Oct-1997  thorpej Fix the description of the Winbond NE2000-compatible Ethernet ASIC.
It's a W89C940F.
 1.43 14-Oct-1997  thorpej branches: 1.43.2;
Pull down from marc-pcmcia branch.
 1.42 08-Oct-1997  mycroft Correct spelling of Millennium.
 1.41 06-Oct-1997  lonhyn Added entries for GLINT 3D chips.
 1.40 01-Oct-1997  drochner Correct a number of Intel PCI devices, sync with names used in data sheet.
Add newer Intel / VIA i386 chipsets.
Correct one S3 chip, add one.
Mostly from Carl Shapiro <css@samsara.dialup.access.net> per PR kern/4169
and kern/4170 (identical).
 1.39 23-Sep-1997  mycroft Add the Ensoniq AudioPCI.
 1.38 15-Sep-1997  bouyer Add some of Compaq's network products.
 1.37 12-Sep-1997  drochner another graphics chip...
 1.36 28-Aug-1997  thorpej Add an entry for the SMC 83C170 "EPIC/100" Fast Ethernet chip.
 1.35 23-Aug-1997  drochner Add one more graphics chip.
 1.34 16-Aug-1997  mjacob Add in PCI_PRODUCT_QLOGIC_ISP2100.
 1.33 14-Aug-1997  drochner Include some more stuff.
 1.32 03-Aug-1997  fvdl Add a few VIA Apollo chipset IDs
 1.31 19-Jul-1997  cgd branches: 1.31.2;
clean up a few entries, fix the entry for the TI PCI1130 so the device
is properly named, add entries for the TI PCI1131 and PCI2030. also note
that you shouldn't always believe everything you read.
 1.30 24-Jun-1997  thorpej Correct Intel Triton MX PCI IDs, from Tom Yu <tlyu@mit.edu>, PR #3478.
 1.29 24-Jun-1997  kml Added definitions for Essential Communications RoadRunner HIPPI and
Gigabit Ethernet interfaces.
 1.28 13-May-1997  jtk correct the identification of Intel Orion PCIset chips
 1.27 04-Apr-1997  augustss Two more PCI devices.
 1.26 20-Mar-1997  chuck - add Adaptec ATM ID's (0x5900, 0x5905). still trying to find out how they
correspond to the ANA numbers... certainly includes ANA-5940.
- add Efficient Nets product 0x0000. according to linux pci.h
the 0x0000 is an FPGA version of the midway card and the 0x0002
is the ASIC version.
 1.25 16-Feb-1997  veego Fix errors in the last commit.
 1.24 15-Feb-1997  tls greatly expanded pcidevs file courtesy of Carl Shapiro <cshapiro@sparky.ic.sunysb.edu>.
 1.23 01-Jan-1997  veego branches: 1.23.4;
Add the Matrox Millenium and regen the header files.
 1.22 28-Nov-1996  jtk add Cirrus CL-7541, 7543 and ACC 2188; regen .h files
 1.21 28-Nov-1996  thorpej Fill out the Intel section of this a bit, and note the URL of a
periodically updated list of PCI vendor/product codes.
 1.20 19-Oct-1996  jonathan Add productId for RealTek 8029 PCI ethernet board.
 1.19 15-Oct-1996  christos Use the official 3com part names; from Curt Sampson
 1.18 13-Oct-1996  christos Apply PR/2840: Recognize more 3com models...
 1.17 08-Oct-1996  gibbs dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.

Regen microcode header file.

dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.

Fix a problem with handing the QUEUE FULL condition.

Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.

Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.

dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.

dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.

Regen data file.

scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.

Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
 1.16 24-Sep-1996  christos New cyclades driver from Timo Rossi.
 1.15 29-Aug-1996  cgd add entry for the IBM 82351 PCI-PCI Bridge
 1.14 26-Aug-1996  cgd add ids for the PGXGB (TGA2), and DGLPB (OPPO).
 1.13 23-Aug-1996  cgd add an entry for the FORE PCA-200e
 1.12 15-Jul-1996  cgd clean up, sort a few entries. Add many new entries, based on information
gleaned from the XFree86 3.1.2E release.
 1.11 22-Jun-1996  chuck add product code for efficient networks eni155p atm card and regenerate
 1.10 16-May-1996  mycroft branches: 1.10.4;
Add another ID for BusLogic cards.
 1.9 13-May-1996  thorpej Add an LSI Logic vendor id, and an S3 product id. Provide more detail
on a couple of S3 and UMC product ids. From Shelby Noonan <shelby@og.org>
 1.8 07-May-1996  thorpej Add ID for AMD PCnet-PCI Ethernet.
 1.7 04-Apr-1996  mycroft Add some NCR chips.
 1.6 19-Feb-1996  christos Add 3c595 id
 1.5 31-Jan-1996  cgd update/clean entries for Adaptec PCI scsi chips/boards.
 1.4 22-Jan-1996  cgd update PCIVERBOSE code in various ways:
(1) remove the 'UNSUPP' keyword from the device list,
because it can't be reasonably used (becuase different
devices may be supported on different machines, for
good reason).
(2) enhance pci_devinfo so that class/subclass information
is optional (so pci_devinfo can be used by drivers that
match classes of devices, and want to look up the
devices' names easily).
(3) more known vendors and devices.
 1.3 10-Nov-1995  christos - pcidevs: add 3c590 and adaptec ultra
- aic7xxx.c: fix the probe routines to use pcidevs.h
 1.2 20-Jun-1995  cgd vendor IDs for Acer and SIS
 1.1 18-Jun-1995  cgd learn about some PCI vendor and product numbers. not yet used
 1.10.4.1 04-Mar-1997  mycroft Pull up from -current.
 1.23.4.1 12-Mar-1997  is Merge in changes from The Trunk
 1.31.2.9 14-Oct-1997  thorpej Sync w/ trunk.
 1.31.2.8 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.7 14-Oct-1997  thorpej Add the Winbond NE2000-compatible Ethernet interfaces. XXX A better
description of this card is needed.
 1.31.2.6 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.5 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.4 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.3 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.43.2.2 17-Nov-1997  thorpej Sync w/ trunk.
 1.43.2.1 27-Oct-1997  thorpej Pull up from trunk:

Fix the description of the Winbond NE2000-compatible Ethernet ASIC.
It's a W89C940F.
 1.113.2.12 11-Sep-2000  he Pull up revision 1.247 (requested by billc):
Recognize 3Com's Home Connect (3c450) and Office Connect (3cSOHO100)
Ethernet cards.
 1.113.2.11 23-Jul-2000  he Pull up revisions 1.214,1.245 (requested by jonathan):
Add product codes for various Yamaha audio chips.
 1.113.2.10 07-Jul-2000  he Apply patch (requested by bouyer):
Add Intel i810 PCI ID, and a few PCI IDE controllers.
 1.113.2.9 03-Jun-2000  he Pull up revision 1.172 (requested by tsubai):
Add support for PCI variants of Cyclom-4Y and -8Y cards.
Also fixes PR#7175 (new serial controller).
 1.113.2.8 22-May-2000  he Pull up revision 1.198 (requested by bouyer):
Add product IDs for some VIA Technologies devices.
 1.113.2.7 10-Feb-2000  he Pull up revision 1.191 (via patch, requested by bouyer):
Add support for US Robotics 3CP5609 PCI 16550 Modem.
 1.113.2.6 15-Jan-2000  he Pull up revision 1.156 (requested by ad):
Fix description of DPT SCSI boards.
 1.113.2.5 20-Oct-1999  he Pull up via patch (requested by bouyer):
Back-port of the Realtek ethernet driver.
 1.113.2.4 05-Oct-1999  he Pull up revision 1.150 (via patch, requested by drochner):
Back-port of driver for Alteon Gigabit Ethernet driver, originally
from FreeBSD.
 1.113.2.3 29-Aug-1999  he Pull up revision 1.137:
Recognize 3c905C-TX card. (bouyer)
 1.113.2.2 22-Jun-1999  perry pullup 1.123->1.124 (fvdl): recognize another 390xB card
 1.113.2.1 13-Apr-1999  jonathan branches: 1.113.2.1.2; 1.113.2.1.4;
Pull up sys/dev/pci/pcidevs 1.113->1.114 (CardBus bridge chips) to 1.4.
pcidevs.h, pcidevs_data.h: regen.
 1.113.2.1.4.2 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.113.2.1.4.1 28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.113.2.1.2.3 02-Aug-1999  thorpej Update from trunk.
 1.113.2.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.113.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.158.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.159.4.1 15-Nov-1999  fvdl Sync with -current
 1.159.2.10 23-Apr-2001  bouyer Sync with HEAD.
 1.159.2.9 21-Apr-2001  bouyer Sync with HEAD
 1.159.2.8 27-Mar-2001  bouyer Sync with HEAD.
 1.159.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.159.2.6 11-Feb-2001  bouyer Sync with HEAD.
 1.159.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.159.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.159.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.159.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.159.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.220.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.236.2.27 07-Apr-2004  jmc Pullup rev 1.563-1.564 (requested by itojun in ticket #71)

Add National Semiconductors SC1100 (GEODE) PCI devices
 1.236.2.26 06-Jun-2002  he Pull up revision 1.324 (via patch, requested by mycroft):
Add Intel ICH3 network controller IDs. Part of fix to fxp driver to
work around a bug which can cause some machines to randomly hang, and to
drag along performance improvements and improved hardware support.
 1.236.2.25 25-Mar-2002  he Pull up revision 1.412 (via patch, requested by bouyer):
Add support for the pciide part of the AMD-768 chipset.
 1.236.2.24 06-Feb-2002  he Pull up revisions 1.277,1.279,1.318 (requested by tsutsui):
Add support for Acard ATP-850/860 pciide controllers.
 1.236.2.23 29-Jan-2002  he Pull up revision 1.287 (requested by bouyer):
Add support for the 53c1010-33, and bring documentation up to
date.
 1.236.2.22 24-Jan-2002  he Pull up revisions 1.352-1.353 (requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.236.2.21 25-Oct-2001  he Pull up revisions 1.282,1.285,1.299 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.236.2.20 18-Jun-2001  jhawk Pull up revision 1.329 (requested by tsubai):
Support the new dual USB iBook.
 1.236.2.19 11-Jun-2001  he Pull up revision 1.326 (requested by tron):
Support the D-Link DFE-530TX+. Fixes PR#13161.
 1.236.2.18 15-May-2001  he Pull up revision 1.320 (via patch, requested by bouyer):
Add support for newer VIA pciide controllers.
Add support for the AMD 766 pciide controller.
Properly distinguish between HPT366 and HPT370 controllers.
 1.236.2.17 06-May-2001  he Pull up revision 1.275 (via patch, requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.236.2.16 03-May-2001  he Pull up revisions 1.244,1.284,1.288,1.294-1.295,1.319
(via patch, requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.236.2.15 23-Apr-2001  he Pull up revisions 1.263,1.286 (requested by hubertf):
Support Accton EN2242 and other AmdTek AN985 compatible cards
with the tlp(4) driver.
 1.236.2.14 22-Mar-2001  he Pull up revision 1.11 (requested by hubertf):
Make the Intel Pro/100 as e.g. found on Toshiba Satellite Pro
4600s work.
 1.236.2.13 20-Mar-2001  he Pull up revision 1.260 (via patch, requested by chuck):
Add support for the 3Com 3c555, 3c556 and 3c556B MiniPCI Ethernet
cards.
 1.236.2.12 26-Feb-2001  he Pull up revision 1.302 (requested by bouyer):
Add support for the Intel 82801BAM IDE controller.
 1.236.2.11 31-Dec-2000  jhawk Pull up revision 1.272 via patch (requested by bouyer):
For the ti driver, add hardware 802.1Q support, update firmware
to 12.4.13+wpaul, and support the Netgear GA620T copper gigabit card,
and the Alteon ACEnic 100baseSX and 1000baseT gigabit cards. Various
small changes from FreeBSD.
 1.236.2.10 30-Oct-2000  tv Pullup 1.267 [thorpej]:
Add a bunch of Pequr (ServerWorks) products. From OpenBSD.
 1.236.2.9 19-Oct-2000  he Pull up revision 1.247 (requested by billc):
Add PCI IDs for 3Com Home Connect (3c450) and Office Connect
(3cSOHO100), register compatible with later versions of 3c905.
 1.236.2.8 21-Sep-2000  thorpej Pull up rev. 1.261:
Add National Semiconductor DP83815 10/100 Ethernet.
 1.236.2.7 13-Sep-2000  tron Pull up from current (approved by thorpej):

Add support VIA VT6102 chip found e.g on the D-Link DFE530TX NIC.

syssrc/sys/dev/pci/if_vr.c 1.36-1.37
syssrc/sys/dev/pci/pcidevs 1.256-1.258
 1.236.2.6 22-Aug-2000  enami Pullup rev. 1.250 (approved by jhawk and thorpej):
Add a product id for the promise ata-100 controller found on
MS-6321 (694D Pro). Reported in the PR#10756 by Kazuki Sakamoto.
 1.236.2.5 23-Jul-2000  jonathan Pull up rev 1.245 (Yamaha YMF 7xx audio product codes) to 1.5 branch.
 1.236.2.4 16-Jul-2000  jhawk Pullup pcidevs rev 1.242 and regen pcidevs_data.h, pcidevs.h, approved by
jhawk:
Add ID for i82559ER.
 1.236.2.3 06-Jul-2000  enami Pull up rev. 1.240 (approved by releng-1-5):
Add device ID of promise ultra100/ata controller.
 1.236.2.2 27-Jun-2000  thorpej Pull up rev. 1.238:
add Intel 82801BA devices (and a few others)
 1.236.2.1 26-Jun-2000  bouyer Pull up rev 1.237, approved by thorpej:
Add product ID for the CMD PCI0649 PCIIDE controller
 1.306.2.28 17-Jan-2003  thorpej Sync with HEAD.
 1.306.2.27 15-Jan-2003  thorpej Sync with HEAD.
 1.306.2.26 03-Jan-2003  thorpej Sync with HEAD.
 1.306.2.25 29-Dec-2002  thorpej Sync with HEAD.
 1.306.2.24 19-Dec-2002  thorpej Sync with HEAD.
 1.306.2.23 11-Dec-2002  thorpej Sync with HEAD.
 1.306.2.22 26-Nov-2002  thorpej Sync with HEAD.
 1.306.2.21 11-Nov-2002  nathanw Catch up to -current
 1.306.2.20 18-Oct-2002  nathanw Catch up to -current.
 1.306.2.19 17-Sep-2002  nathanw Catch up to -current.
 1.306.2.18 27-Aug-2002  nathanw Catch up to -current.
 1.306.2.17 13-Aug-2002  nathanw Catch up to -current.
 1.306.2.16 01-Aug-2002  nathanw Catch up to -current.
 1.306.2.15 20-Jun-2002  nathanw Catch up to -current.
 1.306.2.14 17-Apr-2002  nathanw Catch up to -current.
 1.306.2.13 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.306.2.12 28-Feb-2002  nathanw Catch up again (ATI lossage).
 1.306.2.11 28-Feb-2002  nathanw Catch up to -current.
 1.306.2.10 11-Jan-2002  nathanw More catchup.
 1.306.2.9 08-Jan-2002  nathanw Catch up to -current.
 1.306.2.8 14-Nov-2001  nathanw Catch up to -current.
 1.306.2.7 22-Oct-2001  nathanw Catch up to -current.
 1.306.2.6 08-Oct-2001  nathanw Catch up to -current.
 1.306.2.5 21-Sep-2001  nathanw Catch up to -current.
 1.306.2.4 24-Aug-2001  nathanw Catch up with -current.
 1.306.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.306.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.306.2.1 05-Mar-2001  nathanw file pcidevs was added on branch nathanw_sa on 2001-04-09 01:57:04 +0000
 1.336.2.9 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.336.2.8 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.336.2.7 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.336.2.6 16-Mar-2002  jdolecek Catch up with -current.
 1.336.2.5 11-Feb-2002  jdolecek Sync w/ -current.
 1.336.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.336.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.336.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.336.2.1 03-Aug-2001  lukem update to -current
 1.355.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.355.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.364.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.424.2.4 29-Aug-2002  gehenna catch up with -current.
 1.424.2.3 15-Jul-2002  gehenna catch up with -current.
 1.424.2.2 20-Jun-2002  gehenna catch up with -current.
 1.424.2.1 30-May-2002  gehenna Catch up with -current.
 1.428.2.40 26-Oct-2005  jmc Pullup (via patch) requested by riz in ticket #5773)
Add support for 82801FB 10/100 ethernet
 1.428.2.39 01-Jun-2005  riz Pull up revision 1.702 (requested by tron in ticket #5721):
Add missing PCI id for Adaptec ASR-2410SA.
 1.428.2.38 01-May-2005  tron Pull up revision 1.706 (requested by bouyer in ticket #5756):
Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.428.2.37 19-Mar-2005  tron Apply patch (requested by he in ticket #1755):
Add support for Adaptec 2200S Vulcan 2M, Dell PERC
320/DC, Adaptec 2410SA and Adaptec 2810SA controllers.
 1.428.2.36 11-Nov-2004  he Pull up revision 1.647 (via patch, requested by itohy):
Add support for the Workbit NinjaSCSI-32 PCI/Cardbus
SCSI driver, njs(4).
 1.428.2.35 12-Jul-2004  he Pull up revision 1.514 (via patch, requested by grant in ticket #1720):
Add support for SATALink 3112.
 1.428.2.34 22-Jun-2004  tron Pull up revision 1.628 (requested by bouyer in ticket #1718):
Apply patch from kern/25936 by Michael Blake: Add support for the
Netelligent 10/100 TX variant found on the Compaq Proliant Professional
Workstation 5100.
 1.428.2.33 06-Apr-2004  jmc Pullup patch (requested by briggs in ticket #1648)

Pull in changes to support the Intel 82801EB/ER (ICH5) Controller. PR#25002
 1.428.2.32 28-Mar-2004  jmc Pullup rev 1.565 via patch (requested by bouyer in ticket #1631)

Add 3com 3c940 Gigabit Ethernet, and VIA KT600 PCI devices. PR#22453
 1.428.2.31 15-Mar-2004  jmc Pullup patch (requested by kent in ticket #1612)

Add support for ICH3, ICH4, ICH5, SiS 7012, nForce MCP, nForce2 MCP-T, and
nForce3 MCP-T to auich driver
 1.428.2.30 20-Oct-2003  cyber Pull up revision 1.569 (requested by tron in ticket #1440):
Add entry for Intel i865G Integrated Graphics Device.
 1.428.2.29 10-Sep-2003  grant Pull up revision 1.544 (requested by tron in ticket #1417):

Correct names and descriptions for i875 entries to be consistent with
other Intel chipsets.
 1.428.2.28 10-Sep-2003  grant Pull up revision 1.543 (requested by tron in ticket #1416):

Add entries for Intel 865PE chipset.
 1.428.2.27 15-Aug-2003  tron Pull up revision 1.564 (requested by itojun in ticket #1414):
s,PCI/ISA,PCI-ISA,
 1.428.2.26 15-Aug-2003  tron Pull up revision 1.563 (requested by itojun in ticket #1414):
add National Semiconductors SC1100 (GEODE) PCI devices.
 1.428.2.25 10-Jul-2003  tron Pull up revision 1.542 (requested by bouyer in ticket #1365):
Add some intel devices, from Quentin Garnier in private mail.
 1.428.2.24 30-Jun-2003  grant Apply patch (requested by drochner in ticket #1343):

add Intel PRO/100M.
 1.428.2.23 19-Jun-2003  grant Pull up revision 1.516 (requested by hamajima in ticket #1323):

Add new Apple devices.
 1.428.2.22 16-Jun-2003  grant Pull up revision 1.511 (requested by bouyer in ticket #1234):

Add several SiS host bridges, from FreeBSD.

Remove duplicate in previous.
 1.428.2.21 02-Jun-2003  tron Pull up revision 1.503 (requested by bouyer):
Add SiS 651 host bridge.
 1.428.2.20 28-Jan-2003  jmc Pullup revisions
1.442-1.443,1.444-1.445,1.452-1.453,1.491-1.492,1.496-1.497
(requested by fvdl in ticket #1126)
Pullup support for bge device. (Broadcom Gigabit Ethernet)
 1.428.2.19 27-Jan-2003  jmc Pullup revisions 1.453-1.454 (required hand patching)
(requested by masanobu in ticket #1109)
Add Intel 82801E Communications I/O Controller Hub (C-ICH)
 1.428.2.18 12-Dec-2002  he Pull up revisions 1.483,1.485 (requested by ad in ticket #1030):
Add support for Adaptec 2005S.
Handle DPT ioctls() from native binaries.
Fix SCSI probe problem.
 1.428.2.17 28-Nov-2002  tron Pull up revision 1.472 (requested by kent in ticket #1019):
- Broadcom BCM4401
- VIA VT8235
- Modify description of VT8233_AC97: "VT8233 AC-97 ..." -> "VT8233/VT8235 AC-97 ..."
 1.428.2.16 26-Nov-2002  tron Pull up revision 1.489 (requested by thorpej in ticket #1018):
Add IBM 133 PCI-X Bridge.
 1.428.2.15 26-Nov-2002  tron Pull up revision 1.488 (requested by thorpej in ticket #1017):
Add Intel i80321 I/O processor.
 1.428.2.14 21-Nov-2002  tron Pull up revision 1.474 (requested by yamt in ticket #925):
fix typos; "wiseman" is 82542, not 82452.
 1.428.2.13 16-Nov-2002  he Pull up revision 1.459 (requested by ad in ticket #646):
Add additional Adaptec RAID controller types.
Fixes PR#17719.
 1.428.2.12 07-Nov-2002  tron Pull up revision 1.451 (requested by thorpej in ticket #452):
Clean up Intel i8254x product names, and add i82540, i82545, and i82546
product IDs.
 1.428.2.11 01-Nov-2002  tron Pull up revision 1.466 (requested by bouyer in ticket #724):
Add Promise Ultra133TX2 and Ultra133TX2v2 PCI ID.
 1.428.2.10 02-Aug-2002  lukem pullup rev 1.438 (requested by bouyer in ticket #603):
PCI_PRODUCT_VIATECH_VT8233A
 1.428.2.9 01-Aug-2002  lukem Pull up revision 1.458 (requested by bouyer in ticket #589):
Ops, remove duplicate entry for 82801DB_LPC, pointed out by geoff wing.
 1.428.2.8 01-Aug-2002  lukem Pull up revision 1.457 (requested by bouyer in ticket #589):
Add Intel 845G PCI IDs, from kern/17743 by Andreas Wrede <andreas@planix.com>
 1.428.2.7 12-Jul-2002  thorpej pullup-1-6 ticket #488 (matt).

Original log message:
Add Apple Xserve PCI devices (more UniNorth) stuff.
 1.428.2.6 25-Jun-2002  lukem Pull up revisions 1.441-1.442 (requested by cjs in ticket #362):
revision 1.442
For new Intel network controllers, update descriptions and fix
numbering.
revision 1.441
Add new Intel Ethernet cards.
 1.428.2.5 21-Jun-2002  lukem Pull up revision 1.440 (requested by thorpej in ticket #344):
Add product ID for Intel 82452KX/GX PCI-Host bridge.
PR 17353, from MOCHIDA Shuji.
 1.428.2.4 11-Jun-2002  lukem Pull up revision 1.434 (requested by seb in ticket #249):
Add product Titan PCI-800L aka VSCom PCI-800L, a 8 serial puc card, from PR
17140.
Reviewed/approved by veego@ and martin@.
 1.428.2.3 11-Jun-2002  lukem Pull up revision 1.429 (requested by lukem in ticket #165):
add NetMos Quad UART and 1284 Printer port
 1.428.2.2 11-Jun-2002  lukem Pull up revision 1.432 (requested by tron in ticket #139):
Add entries for Intel i850 and i860 chipsets.
 1.428.2.1 10-Jun-2002  tv Pull up revision 1.437 (requested by taca in ticket #228):
Add VIA Technologies's VT8231 IDE Controller.
 1.542.2.18 11-Dec-2005  christos Sync with head.
 1.542.2.17 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.542.2.16 01-Apr-2005  skrll Sync with HEAD.
 1.542.2.15 08-Mar-2005  skrll Sync with HEAD.
 1.542.2.14 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.542.2.13 04-Feb-2005  skrll Sync with HEAD.
 1.542.2.12 24-Jan-2005  skrll Sync with HEAD.
 1.542.2.11 17-Jan-2005  skrll Sync with HEAD.
 1.542.2.10 18-Dec-2004  skrll Sync with HEAD.
 1.542.2.9 29-Nov-2004  skrll Sync with HEAD.
 1.542.2.8 14-Nov-2004  skrll Sync with HEAD.
 1.542.2.7 02-Nov-2004  skrll Sync with HEAD.
 1.542.2.6 19-Oct-2004  skrll Sync with HEAD
 1.542.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.542.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.542.2.3 03-Sep-2004  skrll Sync with HEAD
 1.542.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.542.2.1 03-Aug-2004  skrll Sync with HEAD
 1.615.2.17 12-Nov-2004  jmc branches: 1.615.2.17.2;
Pullup rev 1.660-1.661 (requested by martti in ticket #953)

Added Dell PERC 4/SC
 1.615.2.16 12-Nov-2004  jmc Pullup rev 1.657 (requested by martti in ticket #947)

Added support for DELL PERC 4e/Si RAID controller
 1.615.2.15 08-Oct-2004  jmc Pullup rev 1.622 (requested by he in ticket #896)

Add support for Adaptec AAR 2810SA raid controller.
 1.615.2.14 18-Sep-2004  he Pull up revision 1.651 (requested by martin in ticket #856):
Add support for PCI-X version of LSI FC929, from PR#26836.
 1.615.2.13 30-Aug-2004  tron Backout previous two overeager pullups and apply patch (requested by itohy
in ticket #800):
Add Workbit NinjaSCSI-32 PCI/CardBus products.
 1.615.2.12 30-Aug-2004  tron Pull up revision 1.647 (requested by itohy in ticket #800):
Add Workbit NinjaSCSI-32 PCI/CardBus products.
 1.615.2.11 30-Aug-2004  tron Pull up revision 1.639 (requested by itohy in ticket #800):
Merge in data from cardbusdevs.
 1.615.2.10 22-Aug-2004  tron Pull up revision 1.631 (requested by junyoung in ticket #781):
Add 3Com 3c920B-EMB-WNM Integrated Fast Ethernet.
 1.615.2.9 28-Jul-2004  tron Pull up revision 1.624 (requested by joda in ticket #721):
Add i6300ESB IDE / SATA controller PCI IDs.
 1.615.2.8 28-Jul-2004  tron Pull up revision 1.635 (requested by rumble in ticket #718):
Fix typos in the SC1100 IDE and AUDIO ids.
 1.615.2.7 23-Jul-2004  he Pull up revision 1.633 (requested by mycroft in ticket #691):
Add support for SiS 741. Fixes PR#26394.
 1.615.2.6 05-Jul-2004  he Pull up revision 1.629 (requested by mycroft in ticket #606):
Update ServerWorks chip IDs, per
http://www.plasma-online.de/english/identify/picture/serverworks.html
Seems remarkably more sane.
 1.615.2.5 22-Jun-2004  tron Pull up revision 1.628 (requested by bouyer in ticket #537):
Apply patch from kern/25936 by Michael Blake: Add support for the
Netelligent 10/100 TX variant found on the Compaq Proliant Professional
Workstation 5100.
 1.615.2.4 13-May-2004  jdc Pull up revision 1.625 (requested by tron in ticket #316)

Add support for Broadcom BCM5788 GbE. Patches supplied by FUKAUMI Naoki
in PR kern/25166.
 1.615.2.3 11-May-2004  tron Pull up revision 1.621 (requested by sekiya in ticket #284):
Add support for Silicon Image 3512 chip to satalink driver -- treat it as
a 3112 variant (without RAID support), which does the right thing with the
controller on my K8NNXP.
 1.615.2.2 05-Apr-2004  tron Pull up revision 1.618 (requested by martti in ticket #54):
Added another SB Live! 5.1 soundcard and joystick version
 1.615.2.1 01-Apr-2004  jmc Pullup rev 1.616 (requested by tron in ticket #38)

Correct entry for PCI vendor id 0x11af. It is assigned to Avid Technology
Inc. and not to Pro-Log Corporation. PR#25004
 1.615.2.17.2.19 21-Nov-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #10749):
sys/dev/pci/pucdata.c: revision 1.49
sys/dev/pci/pcidevs: revision 1.849
sys/dev/pci/pcidevs: revision 1.850
Add NetMos 9855 Quad UART and 1284 Printer port
Fix typo in previous (hi bouyer).
 1.615.2.17.2.18 11-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #10693):
sys/dev/pci/pcidevs: revision 1.820 via patch
Rename vendor GALILEO -> vendor MARVELL . Marvell bought Galileo years
ago, we have little existing stuff in the tree, and this will make it
easier to keep certain network drivers in sync with other OSes.
OK matt@, uwe@
 1.615.2.17.2.17 04-Jun-2006  tron Pull up following revision(s) (requested by riz in ticket #10635):
sys/dev/pci/pcidevs: revision 1.788
Add a couple DLINK product IDs, from OpenBSD.
 1.615.2.17.2.16 11-Apr-2006  riz Pull up following revision(s) (requested by he in ticket #10409):
sys/dev/pci/pcidevs: revision 1.776 via patch
Add a bunch of IDs for Compaq/HP Smart Array controllers supported
by the soon to be added ciss(4) driver.
 1.615.2.17.2.15 17-Mar-2006  riz Pull up following revision(s) (requested by hw in ticket #10364):
sys/dev/pci/pcidevs: revision 1.774
Add vendor code for Nortel and Baystack 21 id. Part of info
submitted in PR#33044.
 1.615.2.17.2.14 01-Dec-2005  tron Pull up following revision(s) (requested by riz in ticket #10158):
sys/dev/pci/pcidevs: revision 1.710
Two re(4) candidates. From Francois Romieu in private mail.
 1.615.2.17.2.13 01-Dec-2005  riz Pull up following revision(s) (requested by cube in ticket #5990):
sys/dev/pci/pcidevs: revision 1.727 via patch
New Dell day: add missing device IDs, and order one correctly.
 1.615.2.17.2.12 21-Jul-2005  snj Pull up revision 1.703 (requested by tron in ticket #5507):
Add PCI id for Intel PRO/1000 GT.
 1.615.2.17.2.11 05-Jul-2005  riz Pull up patch (requested by bouyer in ticket #2029):
Add the SIS 964 and 965 host bridges
 1.615.2.17.2.10 21-Jun-2005  riz Pull up revision 1.719 via patch (requested by bouyer in ticket #2007):
Add Intel 82801FBM Serial ATA Controller. From Kurt Schreiner on tech-kern@
 1.615.2.17.2.9 19-May-2005  tron Pull up revision 1.711 (requested by riz in ticket #1532):
Add support for the 82801FB (ICH6) 10/100 ethernet appearing
on new Intel motherboards. From Brian Buhrow in PR#30025.
Approved by jmcneill.
 1.615.2.17.2.8 19-May-2005  tron Pull up revision 1.658 via patch (requested by riz in ticket #1531):
Add two Broadcom devices (575x chips), correct and add a few Intel entries.
 1.615.2.17.2.7 19-May-2005  tron Pull up revision 1.637 (requested by riz in ticket #1531):
Add a bunch of devices that are in the Dell Dimension 8400 sitting on my
desk: ATI Radeon X300, Broadcom BMC5751, Intel 915 chipset family (ICH6).
 1.615.2.17.2.6 11-May-2005  riz Pull up revision 1.705 (requested by martti in ticket #1402):
Added support for Dell CERC SATA RAID 1.5/6ch
 1.615.2.17.2.5 10-May-2005  riz Pull up revision 1.702 (requested by tron in ticket #1341):
Add missing PCI id for Adaptec ASR-2410SA.
 1.615.2.17.2.4 05-May-2005  riz Pull up revisions 1.691-1.692 (requested by abs in ticket #1153):
Add 'VT642 SATA RAID Controller'. It looks like a viaide, it smells
like a viaide... but you can only address the drives once you have
put two or more of them into a RAID or JBOD.
 1.615.2.17.2.3 01-May-2005  tron Pull up revision 1.706 (requested by bouyer in ticket #1438):
Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.615.2.17.2.2 17-Apr-2005  tron Pull up revision 1.687 (requested by fredb in ticket #1120):
Recognize Belkin Gigabit Desktop Network PCI card.
 1.615.2.17.2.1 07-Apr-2005  tron Pull up revision 1.662 (requested by hira in ticket #1103):
Add Nvidia nForce3 250 chipset products, from Kouichirou Hiratsuka
in PR 27843.
 1.685.2.1 29-Apr-2005  kent sync with -current
 1.688.2.4 26-Mar-2005  yamt sync with head.
 1.688.2.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.688.2.2 12-Feb-2005  yamt sync with head.
 1.688.2.1 25-Jan-2005  yamt file pcidevs was added on branch yamt-km on 2005-02-12 18:17:48 +0000
 1.701.2.50 10-Nov-2008  snj Pull up following revision(s) (requested by bouyer in ticket #1976):
sys/dev/pci/if_wm.c: revision 1.162
sys/dev/pci/pcidevs: revision 1.961, 1.962 via patch
Add support for more ethenet ICH9 devices. Tested by Pouya D. Tafti
on a 82801I_IGP_M_AMT.
 1.701.2.49 08-Apr-2008  jdc Pull up revisions:
src/sys/dev/pci/pcidevs 1.816
src/sys/dev/pci/piixide.c 1.28
(requested by bouyer in ticket #1909).

Add device IDs for Intel's 631xESB/632xESB southbridges, and start the list
for the 5000X northbridge. I'll add the rest later, the spec is currently
unavailable so I'll collect them from another source.

Add support for the 631xESB/632xESB.
 1.701.2.48 19-Nov-2007  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1863):
sys/dev/pci/if_wm.c 1.137-1.138,1.141,1.144-1.146
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893 via patch
share/man/man4/wm.4 1.18-1.19
Fix typo.
Fix EEPROM reload sequence.
Add ICH9 support.
Workaround for 82541 Errata 29 and 82547 Errata 28:
These devices have to reset the PHY before reset the MAC.
Reported and tested by salo.
 1.701.2.47 19-Nov-2007  bouyer Pull up following revision(s) via patch (requested by msaitoh in ticket #1862):
sys/dev/pci/if_bge.c 1.89,1.95,1.97,1.101,1.103,
1.105,1.107,1.117-1.122,
1.128-1.131,1.133-1.135,1.139
via patch
sys/dev/pci/if_bgereg.h 1.31,1.34-1.39,1.42-1.43
sys/dev/pci/pcidevs patch

Some cleanups(typo, whitespace, debug message).
Add TSO support to bge(4)
Add support for BCM5715, BCM5752M, BCM5754, BCM5755, BCM5786 and 5787.
Add support for BCM5789. Fixes PR/33828 from Pawel Chwalowskibg.
Add support for BCM5753 and BCM5753M Fixes PR kern/36139 from Mustafa Dogan.
Add and fix some BGE_CHIPIDs. From FreeBSD and OpenBSD.
In bge_ioctl(), don't call bge_init() if the interface is already up
(Makes ifwatchd work on this interface).
BCM5701 B2 requires BGE_QUIRK_ONLY_PHY_1 quirk. From Brian Baird in kern/23778.
Move TX ring full sanity check further up and check the number of DMA
segments from the DMA map, instead of counting the DMA segments in the
for loop and breaking out later.
Unload the DMA map if encountering an error condition.
Fix a NULL reference on failing mbuf allocation.
In bge_start return if IFF_OACTIVE is set in combination with
IFF_RUNNING, drop obscure check for length of interface queue.
Remove message about failing bge_encap, it can happen just too easily
because of full descriptor rings.
Fix some watchdog timeout and "block failed to stop" problems on
some cards.
Fix "pcistate failed to revert" problem on many cards.
 1.701.2.46 14-Oct-2007  riz Pull up following revision(s) (requested by bouyer in ticket #1770):
share/man/man4/wm.4: revision 1.17
sys/dev/pci/if_wmreg.h: revision 1.22
sys/dev/pci/if_wm.c: revision 1.139 via patch
sys/dev/pci/if_wm.c: revision 1.140 via patch
sys/dev/pci/pcidevs: patch
Add support for ICH8 (i82801H) LAN, from FreeBSD.
Should work on:
i82801H IFE (GT) LAN Controller
i82801H IFE (G) LAN Controller
i82801H (M_AMT) LAN Controller
i82801H (AMT) LAN Controller
i82801H LAN Controller
i82801H (IFE) LAN Controller
i82801H (M) LAN Controller
tested with: Intel i82801H (AMT) LAN Controller, rev. 2
Restore $NetBSD$ tag.
Note ICH8 LAN support.
 1.701.2.45 14-Oct-2007  riz Pull up following revision(s) (requested by bouyer in ticket #1769):
sys/dev/pci/pcidevs: revision 1.876
sys/dev/pci/pcidevs: revision 1.877
Add:
Intel i82801H IFE (GT) LAN Controller
Intel i82801H IFE (G) LAN Controller
from FreeBSD
Remove extra "Intel" from previous commit
 1.701.2.44 13-Sep-2007  bouyer Regen for ticket #1822
 1.701.2.43 31-Mar-2007  bouyer pullup the following revisions (requested by msaitoh in ticket 1681):
sys/dev/pci/if_wm.c 1.104-1.105, 1.116-1.121,
1.127,1.133-1.134 via patch
sys/dev/pci/if_wmreg.h 1.17-1.20
sys/dev/pci/pcidevs patch
sys/dev/mii/igphy.c 1.11
sys/dev/mii/makphy.c 1.20, 1.23
sys/dev/mii/ikphy.c patch
sys/dev/mii/ikphyreg.h patch
sys/dev/mii/miidevs 1.68
sys/dev/mii/files.mii 1.39
sys/arch/i386/conf/GENERIC 1.788-1.789 via patch
sys/arch/i386/conf/GENERIC.MPACPI patch
sys/arch/i386/conf/GENERIC_LAPTOP 1.209 via patch
sys/arch/i386/conf/INSTALL 1.291 via patch
sys/arch/i386/conf/INSTALL_LAPTOP 1.104 via patch
sys/arch/i386/conf/XEN2_DOM0 1.13 via patch
share/man/man4/wm.4 1.14-1.16
Add support for many cards (include PCI-express based chips).
Many bug fixes about auto negotiations (PR#30078, PR#30490,
PR#30906, PR#33429 and PR#35386).
Fix media link issues with fiber-based card (PR#35797).
 1.701.2.42 03-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1673):
distrib/sets/lists/man/mi 1.844, 1.871
share/man/man4/Makefile 1.372, 1.379 via patch
share/man/man4/re.4 1.8, 1.9, 1.11, 1.12
share/man/man4/rgephy.4 1.1
share/man/man4/rlphy.4 1.1, 1.2
sys/arch/amd64/conf/GENERIC 1.79, 1.89
sys/arch/amd64/conf/INSTALL 1.45, 1.49
sys/arch/i386/conf/GENERIC 1.717, 1.747
sys/arch/i386/conf/GENERIC_LAPTOP 1.164
sys/arch/i386/conf/INSTALL 1.277, 1.283
sys/arch/i386/conf/INSTALL_LAPTOP 1.96, 1.98
sys/arch/i386/conf/XEN2_DOM0 1.22 via patch
sys/arch/macppc/conf/GENERIC 1.220, 1.246
sys/arch/macppc/conf/INSTALL 1.96, 1.100
sys/dev/cardbus/if_re_cardbus.c 1.10
sys/dev/cardbus/if_rtk_cardbus.c 1.29-1.31
sys/dev/ic/rtl8169.c 1.14, 1.20, 1.24, 1.25, 1.28-1.61, 1.63, 1.64-1.81 via patch
sys/dev/ic/rtl81x9.c 1.52, 1.54-1.63, 1.65, 1.67-1.70
sys/dev/ic/rtl81x9reg.h 1.15-1.26
sys/dev/ic/rtl81x9var.h 1.19, 1.21-1.37
sys/dev/mii/files.mii 1.38
sys/dev/mii/miidevs 1.62, 1.64
sys/dev/mii/rgephy.c 1.10, 1.13-1.16
sys/dev/mii/rlphy.c 1.1, 1.6, 1.7, 1.11 via patch
sys/dev/pci/if_re_pci.c 1.13, 1.15-1.17, 1.19-1.23
sys/dev/pci/if_rtk_pci.c 1.25, 1.28, 1.29, 1.31
sys/dev/pci/pcidevs 1.851, 1.852

on re(4):
- improve stability (I believe ;-)
- add a workaround for hardware ip4csum-tx bug
- support newer chips (8169SB/SC, PCIe based 8168 etc.)
- fix 8139C+ support
- enable hardware VLAN
- misc bus_dma(9) fix (which makes re(4) work on mips ports)

on rtk(4):
- fix kern/31348
- fix possible panic on dreamcast
 1.701.2.41 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1609):
sys/arch/i386/conf/INSTALL: revision 1.298
sys/arch/i386/conf/GENERIC: revision 1.802
sys/dev/pci/files.pci: revision 1.274
sys/arch/amd64/conf/GENERIC: revision 1.122
sys/dev/pci/mfi_pci.c: revision 1.1 via patch
distrib/sets/lists/man/mi: revision 1.958
sys/arch/amd64/conf/INSTALL: revision 1.61
sys/dev/ic/mfireg.h: revision 1.1
share/man/man4/Makefile: revision 1.416 via patch
sys/dev/ic/mfi.c: revision 1.1
sys/arch/i386/conf/XEN2_DOM0: revision 1.19
sys/dev/ic/mfivar.h: revision 1.1
sys/conf/files: revision 1.821
share/man/man4/mfi.4: revision 1.1
share/man/man4/mfi.4: revision 1.2
sys/dev/pci/pcidevs via patch
Add mfi(4), a driver for LSI Logic & Dell MegaRAID SAS RAID controller.
Ported from OpenBSD, tested on i386 and amd64.
Punctuation issues.
 1.701.2.40 23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1608):
sys/arch/i386/conf/INSTALL: revision 1.299 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.20 via patch
sys/arch/i386/conf/GENERIC: revision 1.803 via patch
sys/dev/pci/files.pci: revision 1.275 via patch
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218 via patch
sys/arch/amd64/conf/GENERIC: revision 1.123 via patch
sys/dev/pci/if_bnx.c: revision 1.1 via patch
share/man/man4/bnx.4: revision 1.1-1.2 via patch
distrib/sets/lists/man/mi: revision 1.959 via patch
sys/arch/amd64/conf/INSTALL: revision 1.62 via patch
sys/dev/microcode/bnx/bnxfw.h: revision 1.1-1.2 via patch
sys/dev/pci/if_bnxreg.h: revision 1.1 via patch
share/man/man4/Makefile: revision 1.417 via patch
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112 via patch
sys/dev/pci/pcidevs: patch
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
Add a NetBSD RCS tag.
Nx -> Ox; remove trailing whitespace.
 1.701.2.39 20-Nov-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1584):
sys/dev/pci/pucdata.c: revision 1.49
sys/dev/pci/pcidevs: revision 1.849
sys/dev/pci/pcidevs: revision 1.850
Add NetMos 9855 Quad UART and 1284 Printer port
Fix typo in previous (hi bouyer).
 1.701.2.38 27-Aug-2006  ghen branches: 1.701.2.38.2;
Pull up following revision(s) (requested by oster in ticket #1479):
sys/dev/pci/pcidevs: revision 1.810
sys/dev/pci/if_fxp_pci.c: revision 1.44
sys/dev/pci/if_fxp_pci.c: revision 1.47
sys/dev/pci/pcidevs: revision 1.756
PR/32494: Add ID 0x1068 for Intel PRO/100 VE (LOM) found on Sony Vaio
S4HRP laptops.
PR/32494: Dennis Chernoivanov: Intel PRO/100 VE (LOM) not detected on Sony Vaio
Recognize another Intel PRO/100 VM Network Controller.
 1.701.2.37 15-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1466):
sys/dev/pci/pcidevs: revision 1.798, 1.819
sys/dev/pci/pdcsata.c: revision 1.8, 1.10
Add support for PDC20775 and PDC40518.

Add the Promise PDC20771, present on the Promise FastTrak TX2300
Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.
This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.
The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.
The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.701.2.36 03-Aug-2006  tron Pull up following revision(s) (requested by xtraeme in ticket #1446):
sys/dev/pci/pcidevs: revision 1.813
Add nForce3 250 SATA2.
 1.701.2.35 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.701.2.34 30-Jul-2006  tron Pull up following revision(s) (requested by kent in ticket #1432):
sys/dev/pci/pcidevs: revision 1.806 via patch
- add VIA VT8237A/8251 High Definition Audio Controller
- add some tabs
 1.701.2.33 04-Jun-2006  tron Apply patch (requested by jonathan in ticket #1351):
Add support to bge(4) for bcm5714, bcm5715, bcm5780/HT-2000 and
bcm5752 chip variants.
 1.701.2.32 04-Jun-2006  tron Pull up following revision(s) (requested by riz in ticket #1349):
sys/dev/pci/pcidevs: revision 1.788
Add a couple DLINK product IDs, from OpenBSD.
 1.701.2.31 04-May-2006  tron Pull up following revision(s) (requested by jonathan in ticket #1298):
share/man/man4/pciide.4: revision 1.60
share/man/man4/Makefile: revision 1.376 via patch
sys/dev/pci/svwsata.c: revision 1.1
sys/dev/pci/files.pci: revision 1.243
sys/arch/i386/conf/INSTALL: revision 1.281
sys/dev/pci/pcidevs: revision 1.771 via patch
sys/dev/pci/pciidevar.h: revision 1.33
sys/arch/i386/conf/XEN0: revision 1.34
sys/arch/i386/conf/GENERIC: revision 1.732
sys/dev/pci/pciide_svwsata_reg.h: revision 1.1
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.701.2.30 30-Apr-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #1295):
sys/dev/pci/pcidevs: revision 1.785
sys/dev/pci/viaide.c: revision 1.29
PR port-amd64/33393: viaide driver patch for VT8237R SATA.
 1.701.2.29 20-Apr-2006  snj Pull up following revision(s) (requested by tron in ticket #1266):
sys/dev/pci/pcidevs: revision 1.775 via patch
fix name of Radeon 9000 Pro.
add Radeon 9200 Secondary ID.
add Comtrol, Magma and SIIG multi-port serial cards.
add more Dolphin SCI cards.
add IBM ServeRAID 4/5.
add Mitsubishi Tornado 3000.
add or rename various NVIDIA IDs to match openbsd.
add SafeNet SafeXcel.
 1.701.2.28 08-Apr-2006  tron Pull up following revision(s) (requested by he in ticket #1247):
sys/dev/pci/pcidevs: revision 1.776
Add a bunch of IDs for Compaq/HP Smart Array controllers supported
by the soon to be added ciss(4) driver.
 1.701.2.27 17-Mar-2006  tron Pull up following revision(s) (requested by he in ticket #1203):
sys/dev/pci/pcidevs: revision 1.774
Add vendor code for Nortel and Baystack 21 id. Part of info
submitted in PR#33044.
 1.701.2.26 15-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1169):
sys/dev/pci/pcidevs: revision 1.765
Fix inconsistencies in names for components for recent Intel chipsets.
 1.701.2.25 15-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1169):
sys/dev/pci/pcidevs: revision 1.763
Add entries for Intel i955X chipset.
 1.701.2.24 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/agp_i810.c: revision 1.28
sys/arch/i386/pci/pchb.c: revision 1.57
sys/dev/pci/agpvar.h: revision 1.11
sys/dev/pci/agp_via.c: revision 1.9
sys/dev/pci/agp.c: revision 1.37
sys/dev/pci/agpreg.h: revision 1.10
sys/dev/pci/pcidevs: revision 1.757
sys/dev/pci/agp_amd.c: revision 1.14
sys/dev/pci/agp_intel.c: revision 1.17
sys/dev/pci/agp_sis.c: revision 1.8
sys/dev/pci/agp_ali.c: revision 1.9
sys/arch/i386/pci/pchb_rnd.c: revision 1.16
PR/32550: Michael Eriksson: No agp(4) support for i915 integrated graphics
 1.701.2.23 14-Feb-2006  riz Pull up following revision(s) (requested by tron in ticket #1168):
sys/dev/pci/pcidevs: revision 1.723
Add ATI Radeon Mobility X600.
Add Mobile Intel 915PM/GM/GMS and 910GML Express Chipset.
 1.701.2.22 05-Feb-2006  riz Pull up following revision(s) (requested by bouyer in ticket #1156):
sys/dev/pci/pcidevs: revision 1.758
Add Promise PDC2057x SATA/150 controllers, from FreeBSD.
 1.701.2.21 21-Jan-2006  snj Pull up following revision(s) (requested by simonb in ticket #1126):
sys/dev/pci/pcidevs: revision 1.739
sys/dev/pci/pdcsata.c: revision 1.4
PR/32238: Ryo Shimizu: Add support for Promise SATA300TX4 SATA Controller
(PDC40718)
 1.701.2.20 10-Jan-2006  snj Pull up following revision(s) (requested by tron in ticket #1112):
sys/dev/pci/pcidevs: revision 1.754
Fix cut and paste error. Noted by Bernhard Moellemann.
 1.701.2.19 10-Jan-2006  snj Pull up following revision(s) (requested by tron in ticket #1112):
sys/dev/pci/pcidevs: revision 1.753
- Spell NVIDIA as "NVIDIA" instead of "Nvidia". This matches their
website and viaide(4).
- Add entry for builtin ethernet of NVIDIA nForce4 chipset.
Information provided by Bernhard Moellemann.
 1.701.2.18 05-Jan-2006  riz Pull up following revision(s) (requested by manu in ticket #1086):
sys/dev/pci/pcidevs: revision 1.755
sys/dev/pci/viaide.c: revision 1.27
Add support for nForce430 ATA133 and SATA controllers. My disks now run
at a decent speed.
 1.701.2.17 15-Dec-2005  tron branches: 1.701.2.17.2;
Pull up following revision(s) (requested by jonathan in ticket #1047):
share/man/man4/amr.4: revision 1.11
sys/dev/pci/amr.c: revision 1.31
sys/dev/pci/pcidevs: revision 1.746 via patch
Add pcidevs entries and support to amr(4) for newer LSI MegaRAID devices,
including the LSI MegaRAID SCSI 320-0x, 320-2x, 320-4x, 320-1E, 320-2E,
the LSI MegaRAID SATA 300-6x and 300-8x.
Tested on an LSI MegaRAID SATA 300-8x, which confirms private advice
that after PCI-IDs to our amr(4) driver, the newer LSI MegaRAID cards
will Just Work
The Linux megaraid2 driver accepts various Intel cards with the same
pci-device IDs as the LSI MegaRAID cards, treating them exaclty as the
above-listed LSI cards. Rework our amr(4) driver to also match and
attach those device-ID if seen with an Intel vendor-ID. Add the
Intel-vendor PCI decice-ids to pcidevs, so that PCI_VERBOSE will
correctly identify the Intel cards.
Update src/share/man/man4/amr.4 to list the newly-supported cards.
(NB: I don't have the LSI SCSI or any Intel cards to test, just the
LSI SATA, which works fine for me.)
 1.701.2.16 24-Nov-2005  tron Pull up following revision(s) (requested by riz in ticket #994):
sys/dev/pci/pcidevs: revision 1.710
Two re(4) candidates. From Francois Romieu in private mail.
 1.701.2.15 21-Nov-2005  tron Pull up following revision(s) (requested by cube in ticket #957):
sys/dev/pci/pcidevs: revision 1.727
New Dell day: add missing device IDs, and order one correctly.
 1.701.2.14 08-Sep-2005  tron Pull up following revision(s) (requested by gavan in ticket #752):
sys/dev/pci/pcidevs: revision 1.730
Add BCM5751M
 1.701.2.13 06-Sep-2005  riz Pull up following revision(s) (requested by tron in ticket #748):
sys/dev/pci/pcidevs: revision 1.732
Add PCI ids for ATI Radeon 9600 LE.
 1.701.2.12 24-Jul-2005  riz Pull up revision 1.713 (requested by tron in ticket #617):
Add the followings:
- 6300ESB AC'97 Audio
- 6300ESB AC'97 Modem
- ICH6 HD-Audio
- ICH6 AC'97 Modem
- All of ICH7 devices
 1.701.2.11 28-Jun-2005  tron Pull up revision 1.721 (requested by briggs in ticket #485):
Add Intel 6300ESB SATA RAID Controller.
 1.701.2.10 22-Jun-2005  tron Pull up revision 1.718 (requested by bouyer in ticket #478):
Add SIS 965 bridge. From FreeBSD.
 1.701.2.9 21-Jun-2005  tron Pull up revision 1.719 (requested by bouyer in ticket #476):
Add Intel 82801FBM Serial ATA Controller. From Kurt Schreiner on tech-kern@
 1.701.2.8 18-Jun-2005  riz Pull up revision 1.717 (requested by tron in ticket #450):
Add support for the LinkSys PCMPC200 Cardbus ethernet card.
 1.701.2.7 28-May-2005  snj Pull up revision 1.711 (requested by riz in ticket #323):
Add support for the 82801FB (ICH6) 10/100 ethernet appearing
on new Intel motherboards. From Brian Buhrow in PR#30025.
Approved by jmcneill.
 1.701.2.6 10-May-2005  tron Pull up revision 1.709 (requested by martin in ticket #272):
PR kern/30173: add Corega CG-LAPCIGT
 1.701.2.5 21-Apr-2005  tron Pull up revision 1.706 (requested by bouyer in ticket #180):
Add "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller". Fix kern/29218
by A L Meyers.
 1.701.2.4 07-Apr-2005  jmc Pullup rev 1.704 (requested by tron in ticket #59)

Add ids for ATI Radeon 9700 Pro and 9800 Pro.
 1.701.2.3 07-Apr-2005  jmc Pullup rev 1.703 (requested by tron in ticket #16)

Add support for Intel PRO/1000 GT.
 1.701.2.2 07-Apr-2005  jmc Pullup rev 1.702 (requested by tron in ticket #15)

Add missing PCI id for Adaptec ASR-2410SA.
 1.701.2.1 07-Apr-2005  tron Pull up revision 1.705 (requested by martti in ticket #116):
Added support for Dell CERC SATA RAID 1.5/6ch
 1.701.2.38.2.1 04-Oct-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1822):
sys/dev/ic/mpt_netbsd.c: revision 1.12 via patch
sys/dev/ic/mpt_netbsd.h: revision 1.6 via patch
sys/dev/ic/mpt_mpilib.h: revision 1.3 via patch
sys/dev/ic/mpt.h: revision 1.6 via patch
sys/dev/ic/mpt.c: revisions 1.9, 1.10 via patch
sys/dev/ic/mpt_debug.c: patch
sys/dev/pci/mpt_pci.c: revision 1.11 via patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/pcidevs_data.h: patch
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.701.2.17.2.1 04-Oct-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1822):
sys/dev/ic/mpt_netbsd.c: revision 1.12 via patch
sys/dev/ic/mpt_netbsd.h: revision 1.6 via patch
sys/dev/ic/mpt_mpilib.h: revision 1.3 via patch
sys/dev/ic/mpt.h: revision 1.6 via patch
sys/dev/ic/mpt.c: revisions 1.9, 1.10 via patch
sys/dev/ic/mpt_debug.c: patch
sys/dev/pci/mpt_pci.c: revision 1.11 via patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/pcidevs_data.h: patch
Add support for newer SAS and similar devices to mpt(4). Tested with
the LSI SAS1064 in a Sun x4200 server.
These enhancements were developed by Garrett D'Amore and contributed
to NetBSD by the TELES AG.
 1.725.2.10 27-Feb-2008  yamt sync with head.
 1.725.2.9 11-Feb-2008  yamt sync with head.
 1.725.2.8 21-Jan-2008  yamt sync with head
 1.725.2.7 07-Dec-2007  yamt sync with head
 1.725.2.6 15-Nov-2007  yamt sync with head.
 1.725.2.5 27-Oct-2007  yamt sync with head.
 1.725.2.4 03-Sep-2007  yamt sync with head.
 1.725.2.3 26-Feb-2007  yamt sync with head.
 1.725.2.2 30-Dec-2006  yamt sync with head.
 1.725.2.1 21-Jun-2006  yamt sync with head.
 1.733.2.1 02-Nov-2005  yamt sync with head.
 1.734.2.2 29-Nov-2005  yamt sync with head.
 1.734.2.1 22-Nov-2005  yamt sync with head.
 1.751.2.4 01-Mar-2006  yamt sync with head.
 1.751.2.3 18-Feb-2006  yamt sync with head.
 1.751.2.2 01-Feb-2006  yamt sync with head.
 1.751.2.1 15-Jan-2006  yamt sync with head.
 1.758.2.1 09-Sep-2006  rpaulo sync with head
 1.759.2.3 07-Jun-2006  kardel Sync with head.
 1.759.2.2 01-Jun-2006  kardel Sync with head.
 1.759.2.1 22-Apr-2006  simonb Sync with head.
 1.769.2.8 14-Sep-2006  yamt sync with head.
 1.769.2.7 03-Sep-2006  yamt sync with head.
 1.769.2.6 11-Aug-2006  yamt sync with head
 1.769.2.5 26-Jun-2006  yamt sync with head.
 1.769.2.4 24-May-2006  yamt sync with head.
 1.769.2.3 11-Apr-2006  yamt sync with head
 1.769.2.2 01-Apr-2006  yamt sync with head.
 1.769.2.1 13-Mar-2006  yamt sync with head.
 1.771.2.2 11-May-2006  elad sync with head
 1.771.2.1 19-Apr-2006  elad sync with head.
 1.775.2.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.775.2.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.787.2.3 22-Jun-2006  chap Complete a sync sys/ with head.
 1.787.2.2 19-Jun-2006  chap Sync with head.
 1.787.2.1 19-May-2006  chap file pcidevs was added on branch chap-midi on 2006-06-19 04:01:36 +0000
 1.794.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.815.2.8 15-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #153):
sys/dev/pci/pcidevs: revision 1.831
Add the SK-9Sxx Gigabit Ethernet, from OpenBSD.
 1.815.2.7 15-Sep-2006  tron Pull up following revision(s) (requested by riz in ticket #153):
sys/dev/pci/pcidevs: revision 1.822
Add a bunch of Marvell product IDs, from OpenBSD.
 1.815.2.6 08-Sep-2006  rpaulo Pull up following revision(s) (requested by riz in ticket #139):
sys/arch/cobalt/pci/pchb.c: revision 1.9
sys/dev/pci/if_sk.c: revision 1.30
sys/arch/cobalt/pci/pci_machdep.c: revision 1.24
sys/dev/pci/pcidevs: revision 1.820
sys/arch/evbmips/malta/pci/pchb.c: revision 1.9
Rename vendor GALILEO -> vendor MARVELL . Marvell bought Galileo years
ago, we have little existing stuff in the tree, and this will make it
easier to keep certain network drivers in sync with other OSes.
OK matt@, uwe@
Vendor GALILEO is now MARVELL.
 1.815.2.5 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #115):
share/man/man4/pdcsata.4: revision 1.5
sys/dev/pci/pcidevs: revision 1.827
sys/dev/pci/pcidevs: revision 1.828
sys/dev/pci/pcidevs: revision 1.829
sys/dev/pci/pdcsata.c: revision 1.11
Add some ICH8 devices... from obsd.
Add some missing devices from Promise and sort them.
Add missing PDC20265 device... removed accidentally in previous.
Add support for PDC40519 and PDC40779... from obsd.
Mention PDC40519 and PDC40779... and bump date.
 1.815.2.4 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #113):
sys/dev/pci/viaide.c: revision 1.33
share/man/man4/viaide.4: revision 1.7
sys/dev/pci/pcidevs: revision 1.825
sys/dev/pci/pcidevs: revision 1.826
- Add all pciids for nvidia MCP61/65 controllers, from obsd.
- Improve description in all them.
Erm forgot to add MCP61/65 SATA Controllers and sort them.
Add support for nvidia MCP61/65 IDE/SATA Controllers.
Mention MCP61/65... and bump date.
 1.815.2.3 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #112):
sys/dev/pci/if_nfe.c: revision 1.4
sys/dev/pci/pcidevs: revision 1.824
- Add nForce MCP61/65 LAN controllers... from obsd.
- Improve description in some nForce controllers as well.
Add support for MCP61/65 controllers... from obsd.
 1.815.2.2 15-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #28):
sys/dev/pci/pcidevs: revision 1.819
sys/dev/pci/pcidevs.h: revision 1.819
sys/dev/pci/pcidevs_data.h: revision 1.818 (via patch)
sys/dev/pci/pdcsata.c: revision 1.10
Add the Promise PDC20771, present on the Promise FastTrak TX2300
Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.
This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.
The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.
The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.815.2.1 11-Aug-2006  riz Pull up following revision(s) (requested by cube in ticket #8):
sys/dev/pci/piixide.c: revision 1.28
sys/dev/pci/pcidevs: revision 1.816
Add device IDs for Intel's 631xESB/632xESB southbridges, and start the list
for the 5000X northbridge. I'll add the rest later, the spec is currently
unavailable so I'll collect them from another source.
Add support for the 631xESB/632xESB.
 1.830.2.3 01-Feb-2007  ad Sync with head.
 1.830.2.2 12-Jan-2007  ad Sync with head.
 1.830.2.1 18-Nov-2006  ad Sync with head.
 1.831.2.3 18-Dec-2006  yamt sync with head.
 1.831.2.2 10-Dec-2006  yamt sync with head.
 1.831.2.1 22-Oct-2006  yamt sync with head
 1.855.2.25 31-Oct-2008  snj Pull up following revision(s) (requested by bouyer in ticket #1215):
sys/dev/pci/if_wm.c: revision 1.162
sys/dev/pci/pcidevs: revision 1.961,1.962
Add support for more ethenet ICH9 devices. Tested by Pouya D. Tafti
on a 82801I_IGP_M_AMT.' sys/dev/pci/if_wm.c sys/dev/pci/pcidevs
 1.855.2.24 29-Sep-2008  jdc Pull up revision 1.902 (requested by bouyer in ticket #1192).

addd SYMBIOS SAS1068_2, SAS1064E_2 and SAS1068E_2
 1.855.2.23 17-May-2008  bouyer Pull up following revision(s) (requested by jdc in ticket #1145):
src/share/man/man4/gem.4 1.5,1.6 via patch
src/sys/arch/sparc64/conf/GENERIC 1.97 via patch
src/sys/dev/ic/gem.c 1.59,1.61-1.68,1.70-1.73 via patch
src/sys/dev/ic/gemreg.h 1.11 via patch
src/sys/dev/ic/gemvar.h 1.16,1.18 via patch
src/sys/dev/mii/bmtphy.c 1.24 via patch
src/sys/dev/pci/if_gem_pci.c 1.25,1.27 via patch
src/sys/dev/pci/pcidevs 1.12 via patch
src/sys/dev/pci/pcidevs.h regenerate
src/sys/dev/pci/pcidevs_data.h regenerate
Add support for Sun PCI X1141A (SX fibre) cards.
Add improvements to the driver.
Disable HW UDP4 and RX TCP4 checksums because they are buggy (PR#34799)
Add improvements to bmtphy.
 1.855.2.22 17-May-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1143):
sys/dev/pci/aac_pci.c: revision 1.25 via patch
share/man/man4/aac.4: revision 1.13 via patch
sys/dev/pci/pcidevs: revision 1.939 via patch
Add support for IBM ServeRAID 8k (and 8k-l)
 1.855.2.21 19-Apr-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1128):
sys/dev/pci/if_lii.c: revisions 1.1, 1.3 via patch
sys/arch/i386/conf/ALL: revision 1.161 via patch
share/man/man4/lii.4: revision 1.1 via patch
sys/dev/pci/files.pci: revision 1.303 via patch
sys/dev/DEVNAMES: revision 1.238 via patch
sys/arch/i386/conf/GENERIC: revision 1.885 via patch
distrib/sets/lists/man/mi: revisions 1.1062, 1.1063 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.43 via patch
share/man/man4/Makefile: revision 1.460 via patch
sys/arch/i386/conf/INSTALL: revision 1.323 via patch
sys/dev/pci/if_liireg.h: revision 1.1 via patch
sys/dev/pci/pcidevs: patch
Add a driver for the Atheros/Attansic L2 Fast-Ethernet chip found on a
series of hardware that includes Asus's famous EeePC.
 1.855.2.20 09-Mar-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1097):
sys/dev/pci/pucdata.c: revision 1.53
sys/dev/pci/pcidevs: revision 1.930
Add I-O DATA RSA-PCI 2 port serial board.
Add an entry for I-O DATA RSA-PCI 2-port serial board.
(works only on 16550A compatible mode)
 1.855.2.19 23-Feb-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1061):
sys/dev/pci/if_nfe.c: revision 1.22, 1.23, 1.25, 1.27
sys/dev/pci/pcidevs: revision 1.914
sys/dev/pci/if_nfereg.h: revision 1.5, 1.6
share/man/man4/nfe.4: revision 1.4
sys/dev/pci/if_nfevar.h: revision 1.5, 1.6
Add NVIDIA MCP7[37] devices, from OpenBSD.
Attach to NVIDIA MCP67/73 Ethernet controllers.
Add the MCP{67,73} products on nfe_attach().
Sync with reality.
Handle a quirk of newer MCP6x chips on reading MAC address.
Fix from Richy Kim in PR kern/36576.
Wakeup some newer chips from powerdown mode. From FreeBSD/Linux driver
via OpenBSD.
Tested by wiz@ in PR kern/37868.
 1.855.2.18 22-Feb-2008  bouyer Pull up following revision(s) (requested by tron in ticket #1074):
sys/dev/pci/pcidevs: revision 1.929
Import PCI ids for the Matrox MGA G200e and the Intel E7230 and 82975X
chipsets from OpenBSD.
 1.855.2.17 11-Jan-2008  xtraeme Pull up following revision(s) (requested by christos in ticket #1037):
sys/dev/pci/arcmsr.c: patch
sys/dev/pci/arcmsrvar.h: patch
sys/dev/pci/pcidevs: patch
sys/dev/pci/files.pci: patch
sys/arch/i386/conf/GENERIC: patch
sys/arch/i386/conf/XEN2_DOM0: patch
sys/arch/i386/conf/INSTALL_LARGE: patch
sys/arch/amd64/conf/GENERIC: patch
sys/arch/amd64/conf/INSTALL: patch
share/man/man4/Makefile: patch
share/man/man4/arcmsr.4: patch
distrib/sets/lists/man/mi: patch

Add the Areca Technology Corporation SATA RAID controller driver, ported
from OpenBSD.
 1.855.2.16 15-Nov-2007  pavel Backout accidental commit to the release branch.
 1.855.2.15 15-Nov-2007  manu It's not 88CO55, it's 88C055
 1.855.2.14 04-Nov-2007  xtraeme Pull up following revision(s) (requested by manu in ticket #954):
sys/dev/pci/pcidevs_data.h: patch
sys/dev/pci/pcidevs.h: patch
sys/dev/pci/if_msk.c: revision 1.11
sys/dev/pci/pcidevs: revision 1.907

Add support for Marvell 88CO55. Newer iMacs come with that chip.
 1.855.2.13 24-Oct-2007  pavel Pull up following revisions (requested by msaitoh in ticket #935):
sys/dev/pci/piixide.c: revision 1.38-1.41 via patch
sys/dev/pci/pcidevs: revision 1.900 via patch
Attach to the ICH9 SATA devices.
Attach to the ICH8M IDE Controller.
Proper ICH8M IDE Controller support (missed in previous).
Another ICH8M SATA Controller found in jmcneill's laptop.
 1.855.2.12 22-Oct-2007  pavel Pull up following revisions (requested by xtraeme in ticket #931):
sys/dev/pci/pcidevs: revision 1.905
sys/dev/pci/if_ste.c: revision 1.30
IC Plus Corp IP100A support for ste(4), submitted by
Pedro Alejandro Lopez-Valencia in PR kern/36605.
 1.855.2.11 07-Oct-2007  xtraeme Pull up following revision(s) (requested by christos in ticket #923):
sys/dev/pci/aac_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.872
PR/35970: Todd Kover: Add support for HP ML110 G2 / Adaptec 2610SA
 1.855.2.10 31-Aug-2007  pavel Pull up following revision(s) (requested by bouyer in ticket #678):
distrib/sets/lists/man/mi: revision 1.1001
doc/CHANGES: revision 1.853 via patch
share/man/man4/Makefile: revision 1.428
share/man/man4/jmide.4: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.143
sys/arch/amd64/conf/INSTALL: revision 1.69
sys/arch/i386/conf/GENERIC: revision 1.827
sys/arch/i386/conf/INSTALL_LARGE: revision 1.2 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.26
sys/conf/files: revision 1.844 via patch
sys/dev/ic/ahcisata_core.c: revision 1.1 via patch
sys/dev/ic/ahcisata_core.c: revision 1.3
sys/dev/ic/ahcisatareg.h: revision 1.1
sys/dev/ic/ahcisatavar.h: revision 1.1
sys/dev/pci/ahcisata.c: delete
sys/dev/pci/ahcisatareg.h: delete
sys/dev/pci/ahcisata_pci.c: revision 1.1
sys/dev/pci/files.pci: revision 1.287-1.288
sys/dev/pci/jmide.c: revision 1.1-1.2
sys/dev/pci/jmide_reg.h: revision 1.1
sys/dev/pci/pcidevs: revision 1.878
Add JMicron Technology vendor ID, and their current PCIe SATA/PATA
controllers.

Split the ahcisata driver in pci front-end and bus-independant back-end.
add jmide(4), a driver for the JMicron Technology JMB36x PCIe to SATA II/PATA
controllers. These controllers can be found on add-on PCIe cards, or
on some motherboards to provide the PATA connectivity (e.g. some intel
ICH8-based motherboards).
Thanks to JMicron Technology for providing me documentation and
different sample boards for this work.

Move mapping of AHCI register so that jmide knows if it fails, and avoids
calling ahci_intr() (which would cause a panic).
Try to use the pciide function for SATA drives if attaching ahci fails (this
doesn't seems to work though, it may be BIOS dependant).
Thanks to Gary Duzan for testing multiple pacthes.

We're not ready to handle ATAPI yet so just claim there's no drive to the
upper layer. This should work around a NULL pointer dereference when
an ATAPI device is detected on a AHCI device.
 1.855.2.9 29-Aug-2007  liamjfoy Pull up following (requested by xtraeme ticket #846):

Import i386/gcscide(4). A driver for the IDE Controller of the
AMD CS5535 Companion device found in the decTOP.

gcscide0 at pci0 dev 15 function 2
gcscide0: National Semiconductor/AMD CS5535 IDE Controller (rev. 0x00)

Supports Ultra DMA mode 4, Pio Mode 4 and MDMA mode 2.

"Go for it" jmcneill@.
 1.855.2.8 29-Aug-2007  liamjfoy Pull up following revision(s) (requested by masanobu in ticket #850):

sys/dev/pci/if_wm.c 1.137
sys/dev/pci/if_wm.c 1.138
sys/dev/pci/if_wm.c 1.141
sys/dev/pci/if_wm.c 1.144
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphy.c 1.12
sys/dev/mii/miidevs 1.72
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/wm.4 1.18

Fix for 82541 and 82547's reset bug.
Modify wm_reset() to make some device stable.
Add ICH9 support to wm.
Add I82566 support to igphy.

Pulled done via patch.
 1.855.2.7 26-Aug-2007  liamjfoy Pull up following revision(s) (requested by riz in ticket #816):
sys/dev/pci/if_skreg.h: revision 1.10
sys/dev/pci/if_skreg.h: revision 1.11
sys/dev/pci/pcidevs: revision 1.866
sys/dev/pci/if_skreg.h: revision 1.9
sys/dev/pci/if_sk.c: revision 1.36
sys/dev/pci/if_msk.c: revision 1.4
sys/dev/pci/if_msk.c: revision 1.5
sys/dev/pci/if_msk.c: revision 1.6
sys/dev/pci/if_msk.c: revision 1.7
sys/dev/pci/if_mskvar.h: revision 1.2
sys/dev/pci/if_mskvar.h: revision 1.3
Apply OpenBSD's rev. 1.33 to shut up "msk0: phy write timed out"
Original commit message:
> In msk_marv_miibus_writereg, wait for busy flag to clear instead of
> continuing when busy flag set.

add some msk devices

sync with OpenBSD-current (many bugfixes, add some devices)
if_msk.c: rev. 1.42
if_mskvar.h rev. 1.3
if_skreg.h rev. 1.41

sync with if_skreg.h rev. 1.41
need more work?

apply some patches from FreeBSD
o fix device timeout
o add some workaround
o TX underrun bug (grr...)
o and some bugs

fix bit definitions for the RX FIFO Flush mode

Apply OpenBSD's rev. 1.14 via patch:
> remove another Yukon Lite workaround.
 1.855.2.6 10-Jun-2007  bouyer Pull up following revision(s) (requested by hira in ticket #713):
sys/dev/pci/pcidevs: revision 1.863
sys/dev/pci/viaide.c: revision 1.38
share/man/man4/viaide.4: revision 1.8
Add PCI Ids for AMD Geode LX and CS5536.
Add support for CS5536 IDE.
 1.855.2.5 02-May-2007  snj branches: 1.855.2.5.2;
Pull up following revision(s) (requested by bouyer in ticket #597):
sys/dev/pci/pcidevs: revision 1.876
sys/dev/pci/pcidevs: revision 1.877
Add:
Intel i82801H IFE (GT) LAN Controller
Intel i82801H IFE (G) LAN Controller
from FreeBSD
Remove extra "Intel" from previous commit
 1.855.2.4 21-Feb-2007  tron Pull up following revision(s) (requested by markd in ticket #446):
sys/dev/pci/pcidevs: revision 1.868
Add i965Q
 1.855.2.3 17-Feb-2007  tron Pull up following revision(s) (requested by mlelstv in ticket #449):
sys/dev/pci/pcidevs: revision 1.867
sys/dev/pci/viaide.c: revision 1.40
Add support for VT8237A/VT82C586A PCI-ISA-Bridge
Fixes PR kern/35314
 1.855.2.2 17-Feb-2007  tron Pull up following revision(s) (requested by chs in ticket #423):
sys/dev/pci/pcidevs: revision 1.865
add another Realtek wifi, some SIIG serial cards and another nForce chipset.
remove some duplicate entries.
 1.855.2.1 12-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #267):
sys/dev/pci/pcidevs: revision 1.857
Add another PCI ID for Dell PERC 5 (from OpenBSD)
 1.855.2.5.2.4 03-Jun-2008  skrll Sync with netbsd-4.
 1.855.2.5.2.3 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.855.2.5.2.2 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.855.2.5.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.868.2.5 17-May-2007  yamt sync with head.
 1.868.2.4 07-May-2007  yamt sync with head.
 1.868.2.3 15-Apr-2007  yamt sync with head.
 1.868.2.2 24-Mar-2007  yamt sync with head.
 1.868.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.871.2.9 23-Oct-2007  ad Sync with head.
 1.871.2.8 12-Oct-2007  ad Sync with head.
 1.871.2.7 09-Oct-2007  ad Sync with head.
 1.871.2.6 20-Aug-2007  ad Sync with HEAD.
 1.871.2.5 15-Jul-2007  ad Sync with head.
 1.871.2.4 09-Jun-2007  ad Sync with head.
 1.871.2.3 27-May-2007  ad Sync with head.
 1.871.2.2 10-Apr-2007  ad Sync with head.
 1.871.2.1 13-Mar-2007  ad Sync with head.
 1.872.4.2 29-Mar-2007  reinoud Pullup to -current
 1.872.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.872.2.1 11-Jul-2007  mjf Sync with head.
 1.885.6.13 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.885.6.12 21-Nov-2007  joerg Sync with HEAD.
 1.885.6.11 14-Nov-2007  joerg Sync with HEAD.
 1.885.6.10 31-Oct-2007  joerg Sync with HEAD.
 1.885.6.9 28-Oct-2007  joerg Sync with HEAD.
 1.885.6.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.885.6.7 02-Oct-2007  joerg Sync with HEAD.
 1.885.6.6 06-Sep-2007  jmcneill Add Intel 82G33 definitions.
 1.885.6.5 03-Sep-2007  jmcneill Sync with HEAD.
 1.885.6.4 27-Aug-2007  jmcneill Add some more Intel 965 PCI IDs
 1.885.6.3 16-Aug-2007  jmcneill Sync with HEAD.
 1.885.6.2 09-Aug-2007  jmcneill Sync with HEAD.
 1.885.6.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.885.2.3 10-Sep-2007  skrll Sync with HEAD.
 1.885.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.885.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.887.2.2 06-Aug-2007  martin Add a serverworks south bridge
 1.887.2.1 06-Aug-2007  martin file pcidevs was added on branch matt-mips64 on 2007-08-06 22:39:32 +0000
 1.892.2.3 23-Mar-2008  matt sync with HEAD
 1.892.2.2 09-Jan-2008  matt sync with HEAD
 1.892.2.1 06-Nov-2007  matt sync with HEAD
 1.903.2.1 14-Oct-2007  yamt sync with head.
 1.905.2.4 21-Nov-2007  bouyer Sync with HEAD
 1.905.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.905.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.905.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.912.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.912.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.912.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.912.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.920.6.3 11-Jan-2008  bouyer Sync with HEAD
 1.920.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.920.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.920.2.1 26-Dec-2007  ad Sync with head.
 1.929.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.929.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.929.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.929.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.929.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.929.2.1 24-Mar-2008  keiichi sync with head.
 1.937.4.9 09-Oct-2010  yamt sync with head
 1.937.4.8 11-Aug-2010  yamt sync with head.
 1.937.4.7 11-Mar-2010  yamt sync with head
 1.937.4.6 19-Aug-2009  yamt sync with head.
 1.937.4.5 18-Jul-2009  yamt sync with head.
 1.937.4.4 20-Jun-2009  yamt sync with head
 1.937.4.3 16-May-2009  yamt sync with head
 1.937.4.2 04-May-2009  yamt sync with head.
 1.937.4.1 16-May-2008  yamt sync with head.
 1.937.2.2 04-Jun-2008  yamt sync with head
 1.937.2.1 18-May-2008  yamt sync with head.
 1.938.2.4 10-Oct-2008  skrll Sync with HEAD.
 1.938.2.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.938.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.938.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.942.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.942.4.1 19-Oct-2008  haad Sync with HEAD.
 1.942.2.2 31-Jul-2008  simonb Sync with head.
 1.942.2.1 18-Jul-2008  simonb Sync with head.
 1.962.4.21 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.962.4.20 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1962):
sys/dev/pci/if_wm.c: revisions 1.259-1.266, 1.269, 1.271, 1.273-1.274, 1.277-1.278, 1.282, 1.284-1.285, 1.287, 1.290, 1.294, 1.297-1.298, 1.300-1.301, 1.304-1.307, 1.310, 1.312-1.314, 1.316 via patch
sys/dev/pci/if_wmreg.c: revisions 1.54-1.57, 1.59-1.60, 1.62, 1.64-1.66 via patch
sys/dev/pci/if_wmvar.c: revisions 1.17, 1.20-1.21 via patch
sys/dev/pci/pcidevs: revisions 1.1172, 1.1195, 1.1201 via patch
- Fix "MDIC write error" bug for 82574 and 82583. For those chips, the
semaphore must be released after chip reset. Found and tested by
Mark Davies.
- Fix BMC related bugs.
- Fix yet another NVM bank detect problem in wm(4). Use bank 0 if the detect
function failed. It's the same as FreeBSD. Observed and tested with
Asus P8P67 Deluxe motherboard and tested by jnemeth.
- Add support for I354 DH89xxCC and some new I218 devices.
- Fix definition of CTRL_GIO_M_DIS bit.
- Insert completion barrier between register write and delay().
- Bump max TX DMA size to avoid pathological condition with TSO. From dyoung.
- Fix semaphore related bugs.
- Call wm_set_pcie_completion_timeout() on I350, I354, I210 and I211, too.
Same as FreeBSD and OpenBSD.
- Drop PHPM_GO_LINK_D bit in WMREG_PHPM on some chips. From FreeBSD.
- Fix fiber link problem (PR#44776 and PR#30880).
- WM_T_82545 is not 1000base-SX but 1000base-LX. Same as FreeBSD.
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and check
the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- It's not required to print "failed to detect NVM bank" with
aprint_error_dev(). Use DPRINTF(). Same as {Free,Open}BSD.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Initialize some hardware bits for 8257[1234], 82583, 80003, ICH* and PCH*.
Some of them are workaround code. From other *BSDs, Linux and documents.
- Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.
- Delete 82580ER related code. It was from FreeBSD and was removed
in r203049.
- Remove extra debug message.
- Remove unused variable.
- Remove a duplicated error message.
- Cleanup comments.
- Fix debug message.
 1.962.4.19 07-Sep-2013  bouyer sys/dev/pci/if_wm.c 1.246-1.247, 1.249-1.258
sys/dev/pci/if_wmreg.h 1.51, 1.53
sys/dev/pci/if_wmvar.h 1.15-1.16
sys/dev/pci/pcidevs 1.1152-1.1153
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add I21[0178] support.
Fix a bug that wm_attach() may fail on some PCH2 or newer system.
wm_valid_nvm_bank_detect_ich8lan() misunderstood the NVM's bank
number. Fixes PR#47878.
Fix a bug that the check of reset complete fails on Intel 8 series
with "wm_lan_init_done: lan_init_done failed to complete" message.
The broken code was used for ICH8, 9... and PCH2.
The wm_linkintr_gmii() function is called from interrupt. That's
not tick, so call mii_pollstat() instead of mii_tick().
Add ECC support for the packet buffer. Only 82571 and I21[78] support
ECC.
Fix a bug that wrong semaphore is used in wm_gmii_hv_{read,write}reg.
Add comments, fix some comments, use macros and remove trailing
whitespaces.
[msaitoh, ticket #1867]
 1.962.4.18 19-Jun-2013  bouyer Pullup the following revisions via patch, requested by msaitoh in ticket #1850:
sys/dev/pci/if_wm.c 1.201, 1.203-1.204,
1.207-1.212, 1.215,
1.217-1.218, 1.220-1.223,
1.228, 1.232-245
sys/dev/pci/if_wmreg.h 1.40-1.45, 1.47-1.48
sys/dev/pci/if_wmvar.h 1.11-1.13
sys/dev/pci/pcidevs 1.1074, 1.1077, 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.6
sys/dev/mii/ihphy.c 1.1-1.2
sys/dev/mii/ihphyreg.h 1.1
sys/dev/mii/inbmphyreg.h 1.3
sys/dev/mii/files.mii 1.47 via patch
sys/dev/mii/miidevs 1.97 and 1.100
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/arch/i386/conf/ALL 1.280
sys/arch/i386/conf/GENERIC 1.1001
sys/arch/i386/conf/INSTALL_FLOPPY 1.11
sys/arch/i386/conf/XEN2_DOM0 patch
sys/arch/amd64/conf/GENERIC 1.293
sys/arch/amd64/conf/XEN3_DOM0 1.61
share/man/man4/wm.4 1.21-1.24

Apply almost all fixes and improvements from netbsd-6 except for
the rev. 1.196's iqdrops' change.

- Add the detach code.
- Add code for WOL, ASF, IPMI and Intel AMT. WOL is disabled by default
- Add Yet another workaround for ICH8.
- 82576 is dual port, so check the FUNCID and increment the MAC address for
the 2nd port.
- Fix the names of 82577L[MC] LAN controllers (for mobile).
- Fix CTRL_EXT_SWDPIN() and CTRL_EXT_SWDPIO() macros. The bit order of the
SW definable pin is not 6543 but 3654!!!
- Rewrite the code to read MAC address from eeprom.
- Add 82580 support.
- 82571 quirk. Only 82571 shares port 0 of EEMNGCTL_CFGDONE.
- The document says that the TDH register must be set after
TCL.EN is set on 82575 and newer devices.
- Fix some register names. No functional change.
- Omit U+00AE "REGISTERED SIGN" in a product name due to its non-ASCII nature.
- Stop wm(4) from needlessly resetting when you add or delete a vlan(4).
- Fix MAC address check on 8257[156] and 80003 case. Some cards have non 0xffff
pointer but those don't use alternative MAC address in reality. So we check
whether the broadcast bit is set or not like Intel's e1000 driver.
Fixes PR kern/44072 reported by Jean-Yves Moulin.
- Add PCH2(and 82579) support. Fixes PR#46487
- Add yet another 82567V support.
- Add ICH10+HANKSVILL support.
- Add support Intel I350 Ethernet.
- Make vlan and all ip/ip6 checksum offload work for the I350.
- Fix compile error with WM_DEBUG.
- Fix a bug that PHY isn't set to low-power mode on PCH and PCH2.
- Add WM_DEBUG_NVM. If WM_DEBUG_NVM is enabled, dump the FLASH ROM data.
- Skip 64bit BAR correctly.
- Fix RAL_TABSIZE for ICH8, 82576, 82580 and I350.
- Use 82580(and I350) specific PHY read/write functions. Fixes PR#47542.
- Style fix. Fix typo in comment. Fix comments. Add comments.
 1.962.4.17 20-Jan-2013  bouyer Apply patch, requested by msaitoh in ticket #1842:
sys/dev/pci/pcidevs 1.969 via patch
sys/dev/pci/viaide.c 1.58

Add VT8237S Integrated SATA Controller support.
PR#47452.
 1.962.4.16 17-Mar-2012  bouyer Pull up following revision(s) (requested by sborrill in ticket #1739):
sys/dev/pci/piixide.c: revision 1.58
sys/dev/pci/pcidevs: patch
Add support for Intel 6 Series Serial ATA Controller
 1.962.4.15 22-Nov-2010  riz branches: 1.962.4.15.2;
Pull up following revision(s) (requested by macallan in ticket #1470):
sys/dev/pci/pcidevs: revision 1.1019
sys/dev/pci/fwohci_pci.c: revision 1.35
do not attach to Powrbook G3 onboard Firewire controllers until =20
someone with
access to the hardware can figure out why it deadlocks during device
discovery
add Apple PowerBook G3 Firewire controllers
 1.962.4.14 20-Nov-2010  riz Pull up following revision(s) (requested by jakllsch in ticket #1362):
sys/dev/pci/pcidevs: revision 1.1026
sys/dev/pci/agp_intel.c: revision 1.35
sys/dev/pci/agp_i810.c: revision 1.67
Add Intel 82855GM Host-AGP Bridge.
regen
Add (non-IGP) AGP port support for Intel 82855GM.
agp_intel tested with radeondrm(4). agp_i810 tested with i915drm(4).
 1.962.4.13 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1359):
sys/dev/pci/if_bge.c 1.170-1.181
sys/dev/pci/if_bgereg.h 1.53-1.56
sys/dev/pci/if_bgevar.h 1.2-1.5
sys/dev/pci/pcidevs 1.1017, 1.1021
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/miidevs 1.89, 1.93
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
sys/dev/mii/brgphy.c 1.49, 1.52

- Fix a bug of BGE_RDMA_MODE_FIFO_LONG_BURST definition.
- Fix the bug that both BGE_PCIE and BGE_PCIX are set on PCI-Express devices.
- Add support for BCM5705F,BCM5714,SBCM5715S,BCM5717,BCM5718,BCM5720,BCM5723,
BCM5724,BCM5751F,BCM5753F,BCM5756,BCM5761,BCM5761E,BCM5761S,BCM5761SE,
BCM5764,BCM5781,BCM5784M,BCM5903M,BCM57760,BCM57761,BCM57765,BCM57780,
BCM57781,BCM57785,BCM57788,BCM57790,BCM57791 and BCM57795. Fixes PR#41694.
- Fix misunderstanding the capability for TSO4 on some chips.
- Use proplib for no EEPROM systems (e.g. sparc64 with onboard bge).
- Add debug function to show some flags.
- (brgphy(4)) Add support for BCM5461, BCM5464, BCM5784 and BCM5761.
- (brgphy(4)) Enable brgphy_jumbo_settings().
- (brgphy(4)) Enable the Ethernet@Wirespeed function.
- Add support for device properties to override the mac address and set
the BGE_NO_EEPROM flag if we have an onboard device w/o SEEPROM.
- Introduce IPMI and ASF related code from FreeBSD. It fixes some problems
which occured in netboot on sparc64 and PR#32767
- move the code of disabling host interrput in bge_stop() like linux tg3
driver.
- fix the return value of bge_eeprom_getbyte().
- Fixes the bug that error bits arent cleard because these bit are W2C
(in other words W1C).
- Many other bugfixes from FreeBSD and OpenBSD.
- remove an unused structure.
- ANSI C, KNF and tabify
- fix typo in comment.
 1.962.4.12 19-Nov-2010  riz Pull up revisions (requested by msaitoh in ticket #1358):
sys/dev/pci/if_wm.c 1.196-1.199,1.202,1.205
sys/dev/pci/if_wmvar.h 1.9
sys/dev/pci/if_wmreg.h 1.36-1.39
sys/dev/pci/pcireg.h 1.61-1.64
sys/dev/pci/pcidevs 1.1023
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
mii/igphy.c 1.21
mii/igphyvar.h 1.1
mii/inbmphyreg.h 1.2

- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
- Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
- (pcireg.h) Add PCIe config register definitions.
- Note that the changes to count Missed packet (rx fifo overflow) and Receive
no buffers (rx ring full) into iqdrops in rev. 1.196 of if_wm.c is not
pulled up.
 1.962.4.11 28-Mar-2010  snj Apply patch (requested by msaitoh in ticket #1326):
Add support for MFI gen2 devices. Mention newer devices, RAID 6 and
RAID60 in mfi.4.
 1.962.4.10 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c 1.184-1.192, 1.194
sys/dev/pci/if_wmreg.h 1.29-1.35
sys/dev/pci/if_wmvar.h 1.5-1.8
sys/dev/pci/pcidevs 1.1006,1.1009-1.1010, 1.1012-1.1013 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.5
sys/dev/mii/inbmphyreg.h 1.1

- Add support for i82583V.
- Add some ICH9 and ICH10 devices.
- Add support for PCH.
- Fix the bug that ICH9 can't found a PHY. Fixes PR#42237
- Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
- Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
- Fix the checking of jumbo frame function
- Remove the extra macro definition for the offset 0x1a in EEPROM.
- Add missing break in wm_reset()...
- Fix the offset of WMREG_PBS...
- Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. It seems that we have to
do the same work for ICH9.
- Fixes the rx stall problem on 82578 by MANY workaround code. We need more
work for 82577.
 1.962.4.9 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1268):
sys/dev/mii/miidevs: revision 1.90
sys/dev/pci/pcidevs: revision 1.1001
sys/dev/mii/brgphy.c: revision 1.51
sys/dev/microcode/bnx/bnxfw.h: revision 1.3
sys/dev/pci/if_bnx.c: revision 1.29
sys/dev/pci/if_bnxreg.h: revision 1.9
sys/dev/pci/if_bnx.c: revision 1.30

Add support for the Broadcom BCM5709 and BCM5716 chips. Upgrade
the B06 firmware and add the B09 firmware required by the BCM5709.
Replace TX dmamap array with a dynamically-grown list.
Support associated BCM5709CAX and BCM5709C PHYs.
 1.962.4.8 23-Jan-2010  bouyer Pull up following revision(s) (requested by mbalmer in ticket #1254):
sys/dev/pci/pcidevs: revision 1.1015
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
Add two IBM RSS devices.
 1.962.4.7 18-Dec-2009  snj Pull up following revision(s) (requested by sborrill in ticket #1175):
sys/dev/pci/pcidevs: revision 1.1003
Add Intel 3400 devices
 1.962.4.6 28-Oct-2009  bouyer Pull up the following revisions, requested by sborrill in ticket #1114:
share/man/man4/sdhc.4 1.1-1.2
sys/dev/pci/sdhc_pci.c 1.1-1.3
distrib/sets/lists/man/mi patch
share/man/man4/Makefile patch
sys/arch/amd64/conf/GENERIC patch
sys/arch/i386/conf/ALL patch
sys/arch/i386/conf/GENERIC patch
sys/dev/pci/files.pci patch
sys/dev/pci/pcidevs patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add sdhc(4), a driver for SD controllers following the SD Host
Controller Standard Simplified Specification.
 1.962.4.5 26-Sep-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #1021):
sys/dev/pci/pcidevs: revision 1.987
Add alternative product ID for VIA VT8237A Integrated SATA Controller
 1.962.4.4 21-May-2009  snj Pull up following revision(s) (requested by bouyer in ticket #711):
sys/dev/pci/pcidevs: revisions 1.975, 1.981, 1.982 via patch
sys/dev/pci/if_wm.c: revisions 1.164, 1.167, 1.173, 1.174 via patch
sys/dev/pci/if_wmreg.h: revisions 1.25, 1.27 via patch
Add Intel 82567LM_3 ethernet
--
Add i82567LM-3
--
add i82567LF-3 LAN Controller
--
add an entry for 82567LF-3.
fix the register access for ICH10DO.
--
Fix about TBI mode. This fix doesn't influence MII mode.
--
- Fix panic in mediachange.
- Fix SWDPIN(1)'s polarity on some chips.
- Fix flow control stuff (includes PR#32009).
- Stop RXCFG storm. It ocours easily.
- And more fix about autonego.
--
add 82801J_D_BM_LF (ICH10)
--
Reload sc_ctrl in wm_reset().
Add an ICH10 entry.
Remove some obsolete comments.
 1.962.4.3 05-May-2009  bouyer Pull up following revision(s) (requested by snj in ticket #737):
sys/arch/x86/pci/pchb.c: revisions 1.15 - 1.17
sys/dev/pci/agp.c: revisions 1.63 - 1.65
sys/dev/pci/agp_i810.c: revisions 1.57 - 1.64
sys/dev/pci/pcidevs: revisions 1.965, 1.967 via patch
sys/dev/pci/agpreg.h: revision 1.20
Add AGP support for Intel G35, G45, and Q45.
 1.962.4.2 03-May-2009  snj Pull up following revision(s) (requested by sborrill in ticket #722):
sys/dev/pci/pcidevs: revision 1.973
Attansic L1E Gigabit Ethernet Adapter
 1.962.4.1 20-Mar-2009  msaitoh branches: 1.962.4.1.4;
Pull up following revision(s) (requested by sborrill in ticket #587):
sys/dev/pci/pcidevs: revision 1.978
sys/dev/pci/if_wm.c: revision 1.165
Add support for 82574L (as found on Desktop CT adaptor) based on 82573
support.
 1.962.4.15.2.2 14-Oct-2011  matt Add ALI M5288
 1.962.4.15.2.1 07-Jan-2011  matt Add some devices (not synced to HEAD).
 1.962.4.1.4.8 05-Nov-2013  matt Pull down xhci support from HEAD
 1.962.4.1.4.7 03-Jan-2012  matt Change XLP_RAID to XLP_DMA.
 1.962.4.1.4.6 31-Dec-2011  matt Add XLP RXE and SRIO product ids.
 1.962.4.1.4.5 24-Dec-2011  matt Add NetLogic(RMI) XLP devices
 1.962.4.1.4.4 10-May-2010  matt Add Marvell 88SB2211
 1.962.4.1.4.3 20-Apr-2010  matt sync with netbsd-5
 1.962.4.1.4.2 07-Apr-2010  cliff add RMI XLR PCI-X bridge
 1.962.4.1.4.1 09-Nov-2009  cliff in pcidevs:
- add vendor entry for RMI
- add product entry for RMI XLS integrated PCIe Interface
regenerate (make) pcidevs.h and pcidevs_data.h
 1.962.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.962.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.962.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.976.2.2 23-Jul-2009  jym Sync with HEAD.
 1.976.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1019.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1019.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1019.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1025.2.7 12-Jun-2011  rmind sync with head
 1.1025.2.6 31-May-2011  rmind sync with head
 1.1025.2.5 21-Apr-2011  rmind sync with head
 1.1025.2.4 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.1025.2.3 05-Mar-2011  rmind sync with head
 1.1025.2.2 03-Jul-2010  rmind sync with head
 1.1025.2.1 30-May-2010  rmind sync with head
 1.1055.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.1055.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.1055.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1083.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1101.6.7 02-Jun-2012  mrg sync to latest -current.
 1.1101.6.6 29-Apr-2012  mrg sync to latest -current.
 1.1101.6.5 05-Apr-2012  mrg sync to latest -current.
 1.1101.6.4 06-Mar-2012  mrg sync to -current
 1.1101.6.3 06-Mar-2012  mrg sync to -current
 1.1101.6.2 04-Mar-2012  mrg sync to latest -current.
 1.1101.6.1 18-Feb-2012  mrg merge to -current.
 1.1101.2.5 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1101.2.4 16-Jan-2013  yamt sync with (a bit old) head
 1.1101.2.3 30-Oct-2012  yamt sync with head
 1.1101.2.2 23-May-2012  yamt sync with head.
 1.1101.2.1 17-Apr-2012  yamt sync with head
 1.1102.2.18 30-Apr-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1296):
sys/dev/pci/pcidevs: revision 1.1195 via patch
sys/dev/pci/if_wm.c: revisions 1.290, 1.304 via patch
sys/dev/pci/if_wmvar.h: revision 1.20 via patch
- Set the WM_F_ATTACHED flag if wm_attach() finished succesfully and
check the flag in wm_detach(). It will avoid to panic in wm_detach().
Fixes PR#49102.
- Support DH89xxCC device.
- Add extra delay for 82580 and newer devices except DH89XXCC SGMII device.
Same as FreeBSD.
 1.1102.2.17 19-Apr-2015  riz sys/dev/pci/pcidevs 1.1208-1.1220 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

- Add Intel QuickAssist Virtual Function Device IDs
- Add some Intel 10/40G devices.
- Add Some Intel E7520 devices
- Add Some Intel IOP332 devices
- Add Xeon E5 v3 and C61x devices.
- Add Mobile 5th Generation Intel Core devices.
- Add Intel 63xxESB AC'97 Audio Controller
- Fix product ID of INTEL 5000_PCIE_4.
- Add some Intel devices.
- Sort VIATECH's entries in the device ID's order.
- Add some VIATECH devices.
- Add COMPAQ iLOs.
- Add HP IPMI device.
- Add another HP vendor ID (was 3PAR)
- Add AR816x/AR817x chips (part of PR/49584)
- Add two PLX PCI Bridges.
- Add Radeon HD 54xx Audio
- Add Dell DARC 4 devices
- Add nForce Host Bridges.
- Add MegaRAID SAS3108
[msaitoh, ticket #1293]
 1.1102.2.16 07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:
sys/dev/pci/pcidevs 1.1148-1.1149 via patch
 1.1102.2.15 04-Dec-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #1202):
sys/dev/pci/pcidevs: revisions 1.1160-1.1161, 1.1163-1.1171,
1.1173-1.1177, 1.1183-1.1194,
1.1196, 1.1198-1.1205 via patch
Add some PCI devices to pcidevs:
- PR/48180: Christian Groessler: Add Oxford Semi OXuPCI952 dual serial
PCI card.
- Add DIGI Neo 8-port serial(PCIe) and OXFORD OXPCIe952 Parallel.
- Add some Intel devices mainly taken from "Mobile 4th Generation Intel Core
Processor Family I/O" datasheet.
- Add some Intel Core internal devices.
- Add Intel Quark X1000 devices.
- Add devices of Intel Atom S1200 series from the datasheet.
- Add some Intel E600 and EG20T devices.
- Add some Intel X38 devices.
- Add some Intel devices (Sandy Bridge, 6702PXH, X38 and Pineview)
- Add some Intel Ivy Bridge devices.
- Add Intel 3200 Host and PCIe.
- Add Intel EP80579 devices from OpenBSD.
- Add Intel Bay Trail devices.
- Add Intel Atom Z36xx and Z37xx devices.
- Add Intel Xeon E3-1200 v3 Host Bridge, DRAM.
- Add Intel DH89xx's SMBus controller.
- Add Intel Z68 LPC.
- Add yet another Intel 82599 device.
- Add Intel X540-AT2.
- Add some Intel gigabit Ethernet devices.
- PR/48150: Noriyuki Koizumi: Add Intel Centrino Advanced-N 6235 Wi-Fi
controller.
- Add some Intel Wi-Fi devices.
- Add entries for Atheros AR9462 and a new flavour of Intel Haswell
Integrated Graphics Device.
- Add Radeon HD6320 Graphics.
- Add ASMedia ASM1042 xHCI USB3 controller.
- Add Realtek RTL8402 PCI-E Card Reader.
- Add some Realtek devices.
- Add DIGI Neo 8-port serial(PCIe) and OXFORD OXPCIe952 Parallel.
- Add ASPEED Graphics family.
- Add ASPEED AST1150 PCIe-to-PCI bridge.
- Add GeForce 210 High Definition Audio Controller.
- Add GeForce GT 640M.
- Add some Armada 370 IDs.
- Add some new Attansic ethernet devices.
- Add ITE IT8213.
- Add some HP iLO devices.
- Add Matrox MGA G200eH.
- Add Samsung Electronics XP941 M.2 SSD.
 1.1102.2.14 09-Nov-2014  martin Pullup the following revisions, requested by msaitoh in ticket #1188:
sys/dev/pci/pcidevs 1.1172
sys/dev/pci/if_wm.c 1.263-1.266 via patch
sys/dev/pci/if_wmreg.h 1.55-1.56
sys/dev/pci/if_wmvar.h 1.17
share/man/man4/wm.4 1.26-1.27 and 1.29 via patch

- Add I354 support.
- Insert completion barrier between register write and delay().
- Fix the definition of CTRL_GIO_M_DIS. This bit is not bit 3 but bit 2.
- Cleanup
 1.1102.2.13 07-Sep-2013  bouyer sys/dev/pci/if_bge.c 1.203-1.237, 1.239-1.241, 1.243-1.258 via patch
sys/dev/pci/if_bgereg.h 1.58-1.74, 1.76-1.83 via patch
sys/dev/pci/if_bgevar.h 1.10-1.16 via patch
sys/dev/pci/pcidevs 1.1149 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/brgphy.c 1.61-1.63, 1.65, 1.67 via patch
sys/dev/mii/miivar.h 1.61 via patch
sys/dev/mii/miidevs 1.112-1.113 via patch
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/bge.4 1.13-1.15 via patch

Add some device support, fix a lot of bugs and add some enahcements.
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F,
BCM5785G, BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- brgphy(4): Add BCM5756, BCM5717C, BCM5719C, BCM5720C and BCM57780.
- Add some bugfixes and enhancement from FreeBSD:
- Workaround for BCM5906 silicon bug. When auto-negotiation results in
half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292)
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.
(FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf.
(FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC.
(FreeBSD r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems
we have seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
From Linux tg3 driver.
- Sync with *BSD. No functional change:
- make bge_chipid() and use it.
- use switch() instead of a lot of if()s.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case.
Note that {tcp,udp}6csum flag is currently not added in the
capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking. FreeBSD has the same delay().
- Rename PHY related flags for the consistency. It's the same as
FreeBSD.
- Remove BGE_10_100_ONLY flag because this was not used.
For 10/100 devices, when calling mii_attach(), mask BMSR_EXTSTAT
flag to not to check Gigabit flags. It's the same as FreeBSD.
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this commit,
only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK calls MI
mii_phy_auto(). That was not intended.
- Sync with FreeBSD and OpenBSD. Almost the same as OpenBSD rev. 1.325:
- Sync the ring setup code closer to FreeBSD's driver
- Do not touch the jumbo replenish threshold register on chips that
do not have jumbo support
- Wait for the bootcode to complete initialization for 5717 and newer
devices. See BCM5718 programmer's guide's "step 13,
Device reset Procedure, Section7".
57781's document has the same note.
- 5718 and 57785 document say we should wait 100us.
- Change the order of register settings a little to match both
Broadcom's document and Linux tg3.
- Add detach function.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix a bug that the NVRAM lock timeout occured on sparc64 onboard bge.
- Check BGE_SGDIG_STS when the chip is NOT a 5717 A0, like freebsd
(OpenBSD rev. 1.327).
- Fix the setting of Tx Random Backoff Register.
- Add BGE_PCIMISCCTL_PCISTATE_RW in BGE_INIT. It's required to set the
PCISTATE register correctly.
- Update comments from 57XX-PG105-R.pdf and 5718-PG106-R.pdf.
- Add missing bus_dmamap_sync() in bge_intr(). The status word is
in DMAed area. Same as other *BSDs.
- Check the hardware config words and print them. This change only
read them and print the values.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind().
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- bge_init_tx_ring() uses BGE_RSLOTS (==256) but bge_free_tx_ring() uses
BGE_TX_RING_CNT (== 512). Delete BGE_RSLOTS and use BGE_TX_RING_CNT.
Same as OpenBSD's if_bge.c rev. 1.86.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Call bge_poll_fw() before writing BGE_MODE_CTL register like the
latest linux tg3 dirver.
- Set DMA watermark depend on the PCI max payload size.
- Add BGE_JUMBO_CAPABLE flag to some chips. With this commit, 5714,
5780, 5717, 5718, 5719 (exclude rev. A0), 5720, 57765 and 57766 are
added to support jumbo frame.
- Fix the setting of sc->bge_flags for 5717 and newer devices.
- Fix a link detect bug on non-autopoll systems. Same as OpenBSD
(rev.1.329 and 1.336) and FreeBSD (r213710).
- 57765 series is not based on 5717 series. 5717 series is based on
57765 series.
- Set the TX DMA segment size based on the MTU size.
- Change the TX ring size for 5717 series and 57764 series.
- For 57766, set BGE_RDMAMODE_JMB_2K_MMRR for non-jumbo frame.
Same as Linux tg3.
- For 57765 and newer devices, set BGE_MAX_RX_FRAME_LOWAT to 1.
This value is recommended by the document.
- Change sysctl related functions for consistency.
- Style change.
- Use macro. Remove duplicated macro. Remove unused variable.
- Fix comments. Add comments.
- Remove extra semicolon. Remove unused code.
[msaitoh, ticket #939]
 1.1102.2.12 14-Jul-2013  riz Apply changes from msaitoh in ticket #906:
sys/dev/pci/pcidevs 1.1145, 1.1147, 1.1150-1.1158
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Pull up pcidevs changes:
Intel Atom E600 PCI-LPC bridge, adds a watchdog + HPET support.
Update some Intel LPC devices.
Change from "3400 USB" to "3400 USB EHCI" for EHCI devices.
Fix BCM5785F entry. That is not gigabit Ethernet.
Add ALTIMA AC1003, BROADCOM BCM57782 and BCM57786.
Add Intel I21[0178] Ethernet.
Add IDs for Marvell Armada XP. Obtained from Marvell, Semihalf.
Add some Intel devices from document (Intel 8 Series / C220 Chipset
Family Platform Controller Hub (PCH) Datasheet).
Add some Intel devices from datasheets (4th Generation Intel Core
Processor, Intel Xeon Processor E3-1200 v3).
Add ATI RADEON_HD7340.
[msaitoh, ticket #906]
 1.1102.2.11 22-Nov-2012  riz Add some device IDs for ticket 691.
 1.1102.2.10 18-Nov-2012  msaitoh Pull up following revision(s) (requested by matt in ticket #658):
sys/dev/pci/pcidevs: revision 1.1143
Add more ASMEDIA 1061 variants.
 1.1102.2.9 31-Oct-2012  riz sys/dev/pci/pucdata.c 1.77-1.82
sys/dev/pci/pcidevs 1.1125, 1.1129 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
share/man/man4/puc.4 1.36-1.38

Add entries for puc(4) devices into pcidevs.
Add some Intel devices from document (Intel 7 Series / C216 Chipset
Family Platform Controller Hub (PCH) Family Specification Update)
into pcidevs.
Modify some devices in pcidevs to clarify.
Add Intel chipset internal serial over lan devices. Closes PR/45567.
Use PCI_VENDOR_* and PCI_PRODUCT_*. Fixes PR#46303.
Add EXSYS EX-41098-2 UARTs support. The clock frequency is different
from other card(s). Fixes PR#46362 reported by Wolfgang Stukenbrock.
Add Lava Computers SSERIAL-PCI single port serial PCI card.
Update the manual.
 1.1102.2.8 24-Oct-2012  riz Apply patch (requested by msaitoh in ticket #631):

This patch doesn't include any changes that rename ID.
 1.1102.2.7 24-Oct-2012  riz Pull up following revision(s) (requested by bouyer in ticket #628):
sys/dev/ic/mfi.c: revision 1.40
sys/dev/ic/mfi.c: revision 1.41
sys/dev/ic/mfi.c: revision 1.42
sys/dev/ic/mfi.c: revision 1.43
sys/dev/ic/mfi.c: revision 1.44
sys/dev/ic/mfi.c: revision 1.45
sys/dev/ic/mfi.c: revision 1.46
sys/dev/pci/pcidevs: revision 1.1128
sys/dev/pci/mfi_pci.c: revision 1.15
sys/dev/pci/mfi_pci.c: revision 1.16
sys/dev/ic/mfi.c: revision 1.39
sys/dev/ic/mfivar.h: revision 1.16
sys/dev/ic/mfireg.h: revision 1.6
sys/dev/ic/mfivar.h: revision 1.17
sys/dev/ic/mfireg.h: revision 1.7
sys/dev/ic/mfivar.h: revision 1.18
sys/dev/ic/mfivar.h: revision 1.19
Add some support for 64bit DMA but stick to 32bit DMA for now.
From OpenBSD mfi.c rev 1.119.
Add LSI MegaRAID SAS2208
MFI_IOP_SKINNY is an enum not a single bit value, so it can't be used as
a bit flag. As sc_flags is really used to hold an enum mfi_iop value,
change it to enum mfi_iop and rename to sc_ioptype. While there init it
in mfi_attach() instead of mfi_pci_attach().
sg64.len is 32bits, so use htole32()
Really init sc_ioptype in mfi_attach()
Add support newer LSI RAID controllers based on the SAS2208 chip,
codenamed "ThunderBolt". Add tagged queuing support for all adapters
supported by mfi(4).
Tested with a MegaRAID SAS 9265-8i adapter, and an older Dell PERC 5/i.
Avoid "unused variable" warning for non-DIAGNOSTIC kernels.
Pointed out by Havard Eidnes
After discussion on tech-kern@, fix performance issue related to
cache flush commands from WAPBL, by skipping the cache flush if the
BBU is present and considered good. Users which still want the write back
cache with a non-working BBU can set vfs.wapbl.flush_disk_cache to 0.
- add commands to monitor the BBU state. Add a boolean BBU sensor
to monitor the BBU state via sysmon_envsys(9).
- if the BBU is considered good, turn SCSI_SYNCHRONIZE_CACHE_10 and
SCSI_SYNCHRONIZE_CACHE_16 commands from upper layer into NOOPs.
While there, handle SCSI_SYNCHRONIZE_CACHE_16 in addition to
SCSI_SYNCHRONIZE_CACHE_10.
- Add a shutdown pmf(9) handler, which flushes the cache and shutdown the
firmware
- on detach, also flush cache and shutdown firmware.
- on attach, print the firmware-provided name, and the BBU state
Tested on a LSI MegaRAID SAS 9265-8i and a PERC 5/i Integrated
Make MFI_DEBUG build on i386.
Report BBU state changes with aprint_normal(), it seems that sysmon_envsys()
doens't report changes for ENVSYS_INDICATOR as it does for ENVSYS_DRIVE.
 1.1102.2.6 28-Jun-2012  riz branches: 1.1102.2.6.2;
Pull up following revision(s) (requested by msaitoh in ticket #362):
sys/dev/pci/if_wm.c 1.228
sys/dev/pci/if_wmreg.h 1.47
sys/dev/pci/if_wmvar.h 1.13
sys/dev/pci/pcidevs 1.1117
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
share/man/man4/wm.4 1.22-1.25

Add support for Intel I350 Ethernet.
Update document.
 1.1102.2.5 23-Apr-2012  riz Pull up following revision(s) (requested by bouyer in ticket #191):
sys/dev/pci/pcidevs: revision 1.1116
Add various newer LSI RAID/SAS controllers, from OpenBSD.
 1.1102.2.4 16-Apr-2012  riz Pull up following revision(s) (requested by cegger in ticket #180):
sys/arch/x86/pci/amdtemp.c: revision 1.14
sys/dev/pci/pcidevs: revision 1.1115
Add AMD Family15h ids
- support AMD Family15h
- deregister pmf on detach
 1.1102.2.3 03-Apr-2012  riz Pull up following revision(s) (requested by tsutsui in ticket #151):
sys/dev/pci/viaide.c: revision 1.78
sys/dev/pci/pcidevs: revision 1.1106
Add VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
Regen from pcidevs rev 1.1106:
Add VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
Add UDMA support for VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
This should be pulled up to netbsd-6, since ZOTAC ZBOX nano VD01
http://www.zotacusa.com/zbox-nano-vd01.html
exhibited at NetBSD booth in Open Source Conference 2012 Tokyo Spring
was favored by many people.
 1.1102.2.2 03-Apr-2012  riz Pull up following revision(s) (requested by pgoyette in ticket #149):
sys/dev/pci/pcidevs: revision 1.1108
sys/dev/pci/jmide.c: revision 1.13
Add JMB 362 (as found on ASUS M5A99X motherboard)
Add match for JMB362 (with two SATA ports).
 1.1102.2.1 22-Mar-2012  riz Pull up following revision(s) (requested by sborrill in ticket #137):
sys/dev/pci/pcidevs: revision 1.1107
Add some Symbios SAS2108 devices. Add new Symbios SAS2008 device (as used by
IBM ServeRAID M1015).
 1.1102.2.6.2.1 18-Nov-2012  matt Merge tickets 658 and 659.
 1.1132.2.5 03-Dec-2017  jdolecek update from HEAD
 1.1132.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1132.2.3 23-Jun-2013  tls resync from head
 1.1132.2.2 25-Feb-2013  tls resync with head
 1.1132.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1158.4.1 23-Jul-2013  riastradh sync with HEAD
 1.1158.2.2 18-May-2014  rmind sync with head
 1.1158.2.1 28-Aug-2013  rmind sync with head
 1.1184.2.1 10-Aug-2014  tls Rebase.
 1.1199.2.12 11-Aug-2018  martin Pull up the following, requested by msaitoh in ticket #1628:

share/man/man4/wm.4 1.40 via patch
sys/dev/mii/ihphyreg.h 1.2
sys/dev/mii/inbmphyreg.h 1.10
sys/dev/pci/if_wm.c 1.504, 1.506, 1.510-1.535, 1.539-1.540, 1.546, 1.548, 1.551-1.552, 1.558, 1.565-1.573, 1.575, 1.579, 1.582, 1.584 via patch
sys/dev/pci/if_wmreg.h 1.99-1.103, 1.106-1.107 via patch
sys/dev/pci/if_wmvar.h 1.34-1.39 via patch
sys/dev/pci/pcidevs 1.1327 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/pci/pcireg.h patch

Sync wm(4) up to 2018/08/08 except MSI/MSI-X and NET_MPSAFE:
- remove extra "+"
- Fix a bug that non-GMII devices don't send a routing message when
the link status is changed.
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset(). Same as
other OSes.
- If a interrupt is a spurious interrupt, don't print debug message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Print sc_flags with snprintb().
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Add CSR_WRITE_FLUSH() after writing WMREG_CTRL in
wm_gmii_mediachange().
- Add missing "else" in wm_nvm_release().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for wrokaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if
it's required.
- If TX is not required to flush, RX is also not required to flush
in wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset(). Some
flags and callback function are required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Use new nvm.{acquire,release}() for semaphore.
- Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required
for these functions to use the same API. So,
- Change return value as error code.
- Change register value from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally on I21[01]". PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
sc->sc_nvm_wordsize before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Print NVM offset and word count when EERD polling failed.
- On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
- 82583 supports jumbo frame. Fixes PR#52773 reported by
Shinichi Doyashiki.
- Fix typo in comment. Reported by Shinichi Doyashiki in PR#52885.
- Add ASPM workaround for 8257[1234] and 82583 to prevent device
timeout or hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
- CID-1427779: Fix uninitialized variables.
- Fix a bug that wm_pll_workaround_i210() is not called when
a) Chip is I211 or b) Chip is I210 and it uses iNVM (not FLASH).
- Do wm_reset_mdicnfg_82580() on 82580 only.
- Fix FLASH access on PCH_SPT and newer. Their FLASH access should be
done by 32bit. Especially for ICH_FLASH_HSFCTL register, it's located
at 0x0006, so it must be accessed via ICH_FLASH_HSFSTS(0x0004) and
use shift or mask.
- Make wm_nvm_valid_bank_detect_ich8lan() the same as other OSes.
- If the extended configuration size in the EXTCNFSIZE register is 0,
don't continue in wm_init_lcd_from_nvm().
- Add PCH_CNP support (I219 with Intel 300 series chipset).
- Enable I219 support.
- I354 uses an external PHY, so don't use wm_set_eee_i350().
- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber.
- Fix a bug that 82542 misunderstand fiber's signal detection.
- Add debug printf()s.
- Update comment.
- Rename functions and variables.
- Add diagnostic code.
- Sort registers.
- Lowercase hexadecimal values.
- KNF.
 1.1199.2.11 03-Jan-2018  snj Pull up following revision(s) (requested by maya in ticket #1547):
sys/dev/pci/pucdata.c: revision 1.99-1.100
sys/dev/pci/pcidevs: revision 1.1278
Add Intel 200 series chipset devices from "Table 2-2. PCH-H Device and
Revision ID Table, Intel 200 Series Chipset Family Platform Controller
Hub(PCI) Datasheet Volume 1 of 2 (335192-001)".
--
Add Intel 200 series devices.
--
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card
 1.1199.2.10 25-Jul-2017  snj Apply patch (requested by nonaka in ticket #1413):
iwm(4): Add a driver for Intel Wireless 726x, 316x, 826x and 416x series.
Ported from OpenBSD.
 1.1199.2.9 09-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1300):
sys/dev/pci/pcidevs: revision 1.1270
sys/dev/pci/if_wm.c: revision 1.426
i82567V-3 is not ICH9 but ICH8.
--
82567V-3 is not ICH9 but ICH8.
 1.1199.2.8 09-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1298):
sys/dev/pci/piixide.c: revision 1.65
sys/dev/pci/pcidevs: revision 1.1246
- s/82081/82801/ from OpenBSD.
- 0x2829 is SATA. 0x282a is RAID.
--
Rename macro (sync with pcidevs rev. 1.1246). No functional change.
 1.1199.2.7 08-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1291):
sys/dev/pci/pcidevs: revisions 1.1221-1.1245, 1.1247-1.1262, 1.1264-1.1269, 1.1271-1.1273
- Add SystemBase SB16C1050 UARTs.
- Add D-Link DFE520TX (part of PR#49889 reported by Maxim Tsyplakov).
- Add Realtek RTL8188EE and RTL8192CE
- Add PLX Technology PEX 8111.
- Add some Red Hat devices.
- Add Samsung SM951.
- Add several NVIDIA geforce and NVS cards.
- Add some ATI/AMD devices.
- Add Radeon HD 2400 and TSB82AA2 IEEE 1394 Host Controller.
Reported by T. M. Pederson (PR#40987).
- Add some Edimax, AWT, Fusion-io and Ralink devices of ral(4).
- Add MSI RT3090, Edimax RT3591, Ralink RT 536[02] and RT5390 of
ral(4).
- Add vendor ID of Super Micro.
- Add MegaRAID SAS3008.
- Fix entries. The following problems were found while sorting entries:
- Remove the following entries because the value is duplicated:
CMDTECH_240 (CMDTECH_AAR_1210SA has the same value)
INTEL_C610_SATA_RAID (INTEL_82801H_SATA_RAID has the same vaule)
INTEL_C610_PCIE_1_3 (82801BA_HPB has the same value)
GEFORCE_610M3 (GEFORCE_610M2 has the same value)
- RADEON_RV350_NQ is not 0x4e41 but 0x4e51
- 82801JD_SATA_RAID is not 0x3a02 but 0x3a05.
- The following two entries have the same number. Fix one of them:
DH89XXCL_USB_2 to 0x23b5 (was 0x23b4 (== DH89XXCL_USB_1))
5500_HB to 0x3404 and change the desc (was 0x3403 (== 3400_HB))
82X58_PCIE_0_1 to 0x3421 (was 0x3420 (== 82X58_PCIE_0_0))
82801JI_THERMAL to 0x3a32 (was 0x3a30 (== 82801JI_SMB))
- Add the following Intel entries:
- PCIe NVMe SSD.
- Dual Band Wireless AC 3165.
- I219 family Ethernet devices.
- Dual Band Wireless AC 3165, 4165 and 8260 devices.
- 82597EX_SR (part of PR#47750).
- Braswell devices.
- Core 6G devices.
- 100 series chipset devices.
- Xeon D devices.
- Xeon 5[56]00 devices.
- Xeon E7 v4 devices.
- Add "Core i7-6xxxK" to some Intel devices' description.
- Fix Intel XE5_V3_IMC1_DDRIO_[34]'s values.
- Add another ID for Intel 82Q45 KT.
- Add some entries of Intel 965 Express Chipset.
- Add some Intel Xeon E5 v3 devices.
- Add some Intel 1st gen Core PCI devices.
- Add some Intel Core 5G devices.
- Add some Intel Core i7-6xxxK devices.
- Add some Intel Core i7-800 and i5-700 devices.
- Add some Intel 10G devices.
- Add ASMedia ASM1042A USB 3.0 Host Controller.
- Add ASMEDIA ASM1083/1085/1142.
- Add Marvell Armada38x and 88AP510.
- Add Qualcomm Atheros QCA986x/988x.
- Add Atheros AR9565 Wireless LAN.
- Sort entries in device ID's order.
- Fix typo.
 1.1199.2.6 19-Apr-2015  riz branches: 1.1199.2.6.4;
Apply patch (requested by msaitoh in ticket #699):
sys/dev/pci/pcidevs 1.1200, 1.1203, 1.1208-1.1212, 1.1214-1.1220 via patch

Sync pcidevs with rev. 1.1220:
- Add Samsung Electronics XP941 M.2 SSD
- Add Intel Atom Z36xx and Z37xx devices from the datasheet.
- Add Intel QuickAssist Virtual Function Device IDs
- Add some Intel 10/40G devices.
- Add Some Intel E7520 devices
- Add Some Intel IOP332 devices
- Add Xeon E5 v3 and C61x devices.
- Add Mobile 5th Generation Intel Core devices.
- Add Intel 63xxESB AC'97 Audio Controller
- Fix product ID of INTEL 5000_PCIE_4.
- Add some Intel 9 Series devices
- Add some Intel devices.
- Sort VIATECH's entries in the device ID's order.
- Add some VIATECH devices.
- Add COMPAQ iLOs.
- Add HP IPMI device.
- Add another HP vendor ID (was 3PAR)
- Add two PLX PCI Bridges.
- Add Radeon HD 54xx Audio
- Add Dell DARC 4 devices
- Add nForce Host Bridges.
- Add MegaRAID SAS3108
[msaitoh, ticket #699]
 1.1199.2.5 17-Feb-2015  martin Pull up the following, requested by msaitoh in ticket 528:

sys/dev/pci/pcidevs: revision 1.1206-1.1207

- Rename DH89XX_QA to DH89XXCC_IQIA
- Modify the description to DH89xxCC PCIe Endpoint and QuickAssist
(include typo fix)
- Rename DH89xxCC'"'"'s names from DH89XX_ to DH89XXCC_.
- Add some DH89xxCC'"'"'s devices.
- Add DH89XXCL'"'"'s devices.
- Rename PCI_PRODUCT_INTEL_DH89XX_SMB to PCI_PRODUCT_INTEL_DH89XXCC_SMB
- Add PCI_PRODUCT_INTEL_DH89XXCL_SMB
 1.1199.2.4 04-Feb-2015  snj Pull up following revision(s) (requested by nonaka in ticket #473):
share/man/man4/lii.4: revision 1.3
sys/dev/pci/if_alc.c: revision 1.12
sys/dev/pci/pcidevs: revision 1.1213
sys/dev/pci/if_alcreg.h: revision 1.3
share/man/man4/atphy.4: revision 1.3
share/man/man4/alc.4: revision 1.4
PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets
 1.1199.2.3 28-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #467):
external/intel-fw-public/iwl2030/dist/iwlwifi-2030-6.ucode: revision 1.1
distrib/sets/lists/base/mi: revision 1.1091
share/man/man4/iwn.4: revision 1.13
external/intel-fw-public/iwl100/Makefile: revision 1.1
external/intel-fw-public/iwl2030/Makefile: revision 1.1
external/intel-fw-public/iwl135/Makefile: revision 1.1
sys/dev/pci/pcidevs: revision 1.1205
external/intel-fw-public/Makefile: revision 1.8
external/intel-fw-public/iwl135/dist/iwlwifi-135-6.ucode: revision 1.1
external/intel-fw-public/iwl2030/dist/LICENSE.iwlwifi-2030-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/LICENSE.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/LICENSE.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/iwlwifi-100-5.ucode: revision 1.1
external/intel-fw-public/iwl135/dist/LICENSE.iwlwifi-135-ucode: revision 1.1
external/intel-fw-public/iwl135/dist/README.iwlwifi-135-ucode: revision 1.1
sys/dev/pci/if_iwnvar.h: revision 1.16
external/intel-fw-public/iwl2000/dist/iwlwifi-2000-6.ucode: revision 1.1
external/intel-fw-public/iwl100/dist/README.iwlwifi-100-ucode: revision 1.1
sys/dev/pci/if_iwn.c: revision 1.72
sys/dev/pci/if_iwnreg.h: revision 1.14
external/intel-fw-public/iwl105/dist/README.iwlwifi-105-ucode: revision 1.1
external/intel-fw-public/iwl100/dist/LICENSE.iwlwifi-100-ucode: revision 1.1
external/intel-fw-public/iwl2000/dist/README.iwlwifi-2000-ucode: revision 1.1
external/intel-fw-public/iwl105/dist/iwlwifi-105-6.ucode: revision 1.1
external/intel-fw-public/iwl2000/Makefile: revision 1.1
external/intel-fw-public/iwl105/Makefile: revision 1.1
external/intel-fw-public/iwl2030/dist/README.iwlwifi-2030-ucode: revision 1.1
Add some Intel Wi-Fi devices.
Add support for Intel Centrino Wireless-N 100/105/130/135/2200/2230.
From OpenBSD.
 1.1199.2.2 17-Jan-2015  martin Pull up revision 1.1204 for ticket #432
 1.1199.2.1 07-Nov-2014  snj Pull up following revision(s) (requested by msaitoh in ticket #190):
sys/dev/pci/pcidevs 1.1201-1.1202 via patch
sys/dev/pci/if_wm.c 1.291-1.301, 1.304, 1.306-1.307 via patch
sys/dev/pci/if_wmreg.h 1.61-1.65 via patch
sys/dev/pci/if_wmvar.h 1.21 via patch
share/man/man4/wm.4 1.31 via patch
- Add Internal SERDES mode support newer than or equal to 82575.
- Add new I218 devices.
- Add DH89xxCC device.
- Add some old devices.
- Fix a bug that wm_get_swsm_semaphore() timed out when attaching device on
some machines.
- Fix a bug that the offset of alt MAC address is wrongly calculated to 0
when alt MAC address function is really used. This bug does not appear
as real bug if the same MAC address is written in the default location
and alt MAC address's location.
- Don't print "failed to detect NVM bank" message.
- Delete 82580ER related code.
- Fix typo in comment.
- Fix debug message.
- Cleanup
 1.1199.2.6.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.1205.2.11 28-Aug-2017  skrll Sync with HEAD
 1.1205.2.10 05-Feb-2017  skrll Sync with HEAD
 1.1205.2.9 05-Dec-2016  skrll Sync with HEAD
 1.1205.2.8 05-Oct-2016  skrll Sync with HEAD
 1.1205.2.7 09-Jul-2016  skrll Sync with HEAD
 1.1205.2.6 29-May-2016  skrll Sync with HEAD
 1.1205.2.5 19-Mar-2016  skrll Sync with HEAD
 1.1205.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1205.2.3 21-Sep-2015  skrll Sync with HEAD
 1.1205.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1205.2.1 06-Apr-2015  skrll Sync with HEAD
 1.1253.2.6 26-Apr-2017  pgoyette Somehow this got out of sync on the branch.
 1.1253.2.5 26-Apr-2017  pgoyette Sync with HEAD
 1.1253.2.4 20-Mar-2017  pgoyette Sync with HEAD
 1.1253.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1253.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.1253.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.1278.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.1286.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1286.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.1289.2.31 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #1931):

sys/dev/pci/pcidevs: revision 1.1477
sys/dev/pci/pcidevs: revision 1.1494
sys/dev/pci/pcidevs: revision 1.1498
sys/dev/pci/pcidevs: revision 1.1499
sys/dev/pci/pcidevs: revision 1.1500
sys/dev/pci/pcidevs: revision 1.1501
sys/dev/pci/pcidevs: revision 1.1502

Add ID for the EXAR XR17V354 PCIe UART.
From Hakan Engvall.
PR kern/57202

pcidevs: Add missing I225/I226 series devices

pcidevs: Add Mellanox ConnectX-6 Lx.

add some newer Areca boards in prep for updating driver

Add Intel C26[26] eSPI.

Update Intel Raptor Lake devices.

Add Intel I219-{LM,V}(20,21)
 1.1289.2.30 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1915:

sys/dev/pci/pcidevs 1.1497
sys/dev/pci/if_wm.c 1.689,1.790-1.791 via patch
sys/dev/pci/if_wmreg.h 1.120 via patch
sys/dev/pci/if_wmvar.h 1.51

- Use 12K for packet buffer for jumbo frame on PCH2 and newer.
- Add new workaround for Tiger Lake and newer to avoid packet loss.
- Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.1289.2.29 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1913):

sys/dev/pci/pcidevs: revision 1.1493
sys/dev/pci/pcidevs: revision 1.1495

Add Intel 82599 LS.
Add Pericom(Diodes) PCIe switches.
 1.1289.2.28 13-Oct-2023  martin Pull up following revision(s) (requested by abs in ticket #1911):

sys/dev/pci/pcidevs: revision 1.1496

Add entry for ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier
 1.1289.2.27 21-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1887):

sys/dev/pci/pcidevs: revision 1.1483-1.1492

Add AMD 19h/7xh Root Complex.
pcidevs: add ASMedia ASM106x

Add Intel Snow Ridge devices.

Fix some descriptions of Intel Snow Ridge.

Add Intel I226 devices.

Add device ids of the VX800 chipset and s3 chrome 500 series GPU.
Descriptions mainly aligned with VX800/820 Series System Programming Manual.
fix duplicate definition.

Add some Intel Xeon D-2100 devices. Fix description of Intel 0x37d0.

Simplify descriptions of Snow Ridge internal Ethernet devices.

Rename PCI to PCIE for naming consistency.
 1.1289.2.26 29-Jul-2023  martin Pull up the following revisions, via patch, requested by msaitoh in
ticket #1855:

sys/dev/pci/pcidevs 1.1481-1.1482

Add Intel Alder Lake-N, Raptor Lake and 700 series chipset devices.
 1.1289.2.25 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1846):

sys/dev/pci/pcidevs: revision 1.1478
sys/dev/pci/pcidevs: revision 1.1479
sys/dev/pci/pcidevs: revision 1.1480

Add Samsung SM990.

Add devices from PPR for AMD Family 19h Model 61h Revision B1 processors.

The SATA device ID for Apollo Lake is not 0x5ae0 but 0x5ae3.
 1.1289.2.24 18-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1783):

sys/dev/pci/sdhc_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.1469
sys/dev/pci/pcidevs: revision 1.1470
sys/dev/pci/pcidevs: revision 1.1471
sys/dev/pci/pcidevs: revision 1.1472
sys/dev/pci/pcidevs: revision 1.1473
sys/dev/pci/pcidevs: revision 1.1474
sys/dev/pci/pcidevs: revision 1.1475
sys/dev/pci/pcidevs: revision 1.1476

Add some AMD 17h/9xh devices from OpenBSD.
Add AMD F17/Axh devices.
Add some Xeon Scalable devices from OpenBSD.
Update Intel Elkhart Lake devices.
Add Elkhart Lake Shared SRAM.
Fix typo. s/SSC/SCC/.
Fix typo. No functional change.
add Aquantia (Marvell) AQC113 ethernet devices and the variants
Add AMD Family 19h/1xh devices.
 1.1289.2.23 11-Oct-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1771:

sys/dev/pci/pcidevs 1.1461-1.1468 via patch

- Add several samsung nvme entries.
- Add more Alder Lake devices.
- Jasper Lake Intel Trace Hub on Compute Die is not 0x4da6 but 0x4e29.
- Add Intel Core 8G (8core, H, Halo) Host Bridge, DRAM.
- Add AMD 19h/6xh Root Complex.
- Add AMD FCH SATA Controller D.
- Add NVIDIA GeForce GTX 770.
- Sort by number.
 1.1289.2.22 02-Aug-2022  snj Pull up following revision(s) (requested by msaitoh in ticket #1754):
sys/dev/pci/pcidevs: 1.1445-1.1460 via patch
Update pcidevs:
- Add Intel Alder Lake devices and Intel 600 Series PCH devices.
- Add some Intel Xeon Scalable / Skylake-E devices.
- Fix AMD F16_HB from 0x1568 to 0x1538.
- Add some devices for AMD and improve some descriptions to clarify.
- Add VMware AHCI and NVMe.
- Update Intel 700 series Ethernet devices.
- Add some Broadcom devices.
- Add some Broadcom / LSI RAID cards.
- Fix typos and whitespace.
 1.1289.2.21 03-Dec-2021  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1710:

sys/dev/pci/pcidevs 1.1441-1.1444

- Add Intel Gemini Lake TXE HECI 1.
- Add Intel Elkhart Lake and Rocket Lake devices.
- Update Jasper Lake's Processor Transaction Routers.
 1.1289.2.20 23-Oct-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1700:

sys/dev/pci/pcidevs 1.1420-1.1440

- Add modern QUMRANET/Red Hat VIRTIO range PCI devices.
- Add some more product IDs for mcx(4).
- Add current generation NVIDIA graphics cards (3050-3090 etc.).
- Add RDC R6022 PCI-Host bridge.
- Add a whole bunch of radeon devices.
- Add Realtek RTL8821CE.
- Add Intel 660p SSD, and expand the 760p description.
- Add Intel I219's version number.
- Add Intel I219V 15-19 and I219LM 16-19.
- Add Intel I225V, I225LM and WiFi 6 AX201.
- Add newer Intel PCH internal devices.
- Add Intel Jasper Lake devices.
- PDC20265 is Ultra/100, not 66.
- Fix Realtek RTL8125 description.
- Sort Cavium devices.
 1.1289.2.19 20-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/pcidevs 1.1392-1.1403, 1.1406-1.1419

- Add Intel Xeon D-1500 NTB-secondary and Xeon D NS QuickData DMA
channel 0-7.
- Add Intel I219 LM10-LM15 and V10-V14.
- Add AMD Family14h PCIe.
- Add Realtek Killer E3000.
- Add Aquantia AQC 10G network adapters.
- Add Radeon HD4290
- Add Farallon PN9000SX Ethernet.
- NVIDIA 0x036[0-7] are nForce MCP55 LPC Bridge.
- Add VIA VX900 chipset.
- Add some NVIDIA devices.
- Add some Intel UHD Graphics devices.
- Add Intel Comet Lake, Whiskey Lake U and Amber Lake Y devices.
- Modify description of Intel 0x591e from HD Graphics to UHD Graphics.
- Add Intel XMM 7360 LTE Modem.
- Add Western Digital WD Blue SN550 NVMe SSD.
- Add ATI Radeon R5/R6/R7 Graphics.
- Add IDs for Ampere eMAG PCIe Root Ports.
- Add RTL8192EE Wireless LAN 802.11n PCI-E NIC.
- Add ASIX AX99100 Multi I/O (Serial,Parallel,I2C,SPI,LocalBus,GPIO)
Controller.
- Add a couple of additional device IDs for the AMD Cryptographic
Coprocessor.
- Remove duplicated entries.
 1.1289.2.18 20-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1578):

sys/dev/pci/pcidevs: revision 1.1404
sys/dev/pci/pcidevs: revision 1.1405
sys/arch/x86/pci/rdcpcib.c: revision 1.3

Add more RDC products (Andrius V)

Recognize more rdc devices (Andrius V.)

Fix typo
 1.1289.2.17 19-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1448:

sys/dev/pci/pcidevs 1.1384-1.1391

- Add micron/crucial SM2263 NVMe.
- Add some device found on ASUS X570-P with Ryzen 3200G CPU.
- Spell it "PCIe' when using the name.
- Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex
- Modify Attansic Ethernet devices' description to clarify.
- Add Killer E2400 and E2500.
- Spell "controller" correctly.
- Add Realtek RTL8125.
- Update Intel's NVMe SSDs.
- Add Intel Apollo Lake TXE HECI.
- Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.
 1.1289.2.16 06-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1326):

sys/dev/pci/pcidevs: revision 1.1381
sys/dev/pci/pcidevs: revision 1.1382
sys/dev/pci/pcidevs: revision 1.1383

- Intel C620 Virtual Switch Port for Termal Sensor is not 0x37c6 but 0x37c7.
- Add Some AMD Ryzen 3xxx's devices.
- Add some AMD devices mainly taken from OpenBSD.
- Rename some device names for consistency.
- Use _HDA for HD Audio.
Add BCM2711 PCIe Host bridge for RPI4
 1.1289.2.15 17-Jul-2019  martin Pull up the foolowing revisions (via patch), requested by msaitoh
in ticket #1291:

sys/dev/pci/pcidevs 1.1367-1.1380

- Add other two Intel Core 8G host bridges.
- Add Intel Xeon E devices.
- Add some new Intel C620 LPC devices.
- Add some Intel Xeon Scalable processor's devices.
- Add some Intel Whisky Lake devices.
- Add Xeon D XFI.
- Add "(Hyper-V)" to Intel 0x15a9's description.
- Add Intel C3000 QSFP devices.
- Add Some Qlogic devices from OpenBSD.
- Rename Qlogic 0x3022's name from ISP3022 to ISP4022.
- Add IDs for SATA controllers VT8237S and VX855
- Modify some descriptions of Virtio devices from OpenBSD to identify
the functions.
- Add Phison PS5000 and PS5016 NVMe.
- Add some ServerWorks HT1100 devices from OpenBSD.
- Remove extra white spaces.
 1.1289.2.14 07-Mar-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1205):

sys/dev/pci/pcidevs: revision 1.1363
sys/dev/pci/pcidevs: revision 1.1364
sys/dev/pci/pcidevs: revision 1.1365
sys/dev/pci/pcidevs: revision 1.1366

Add Tundra (now IDT) TSI381 and PEB383 from OpenBSD.

Add some Broadcom Ethernet devices from {Open,Free}BSD.

Add SK-NET SK-9Mxx Gigabit Ethernet.

Add Intel I219 variations for Cannon Lake.
 1.1289.2.13 11-Feb-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1188):

sys/dev/pci/pcidevs: revision 1.1360
sys/dev/pci/pcidevs: revision 1.1361
sys/dev/pci/pcidevs: revision 1.1362
sys/dev/pci/pcidevs: revision 1.1357
sys/dev/pci/pcidevs: revision 1.1359

Add yet another Intel Core QuickPath Generic Non-Core Register.

Add some RADEON devices. Mainly taken from OpenBSD.

Add AMD Family 17h devices from OpenBSD.

From OpenBSD:
- Add NetXen's vendor ID and devices.
- Add Sun Neptune.

- Add Some Freescale MPC834x devices from OpenBSD.

- Add Intel I210 SGMII Flash-less device from the spec update document.
 1.1289.2.12 04-Dec-2018  martin Pull up following revision(s) (requested by bouyer in ticket #1123):

sys/dev/pci/pcidevs: revision 1.1356

Add 2 Symbios products, from OpenBSD
 1.1289.2.11 04-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1119):

sys/dev/pci/pcidevs: revision 1.1350
sys/dev/pci/pcidevs: revision 1.1351
sys/dev/pci/pcidevs: revision 1.1352
sys/dev/pci/pcidevs: revision 1.1353
sys/dev/pci/pcidevs: revision 1.1354
sys/dev/pci/pcidevs: revision 1.1355
sys/dev/pci/pcidevs: revision 1.1345
sys/dev/pci/pcidevs: revision 1.1346
sys/dev/pci/pcidevs: revision 1.1347
sys/dev/pci/pcidevs: revision 1.1349

Add some Intel devices. Some of them are found in Core i7-8550U.

Add Toshiba's XG4 and XG5 NVMe SSD.

- Add C62x to the descriptions of Intel C620 series devices.
- Add 0xa1ca for Intel C629 LPC or eSPI.

Add AMD Seattle Host Bridge and PCIE root port devices

Add two otehr I2C devices of Intel.

"s/ are are / are /" in comment. No functional change.

Add some Intel 100 series and C230 series devices.

Add a whole bunch of Cavium ThunderX devices

Add Rockchip vendor ID and a device. Requested by jak@
From OpenBSD

Add Amazon.com UART, NVMe, and ENA PCI IDs.
 1.1289.2.10 17-Oct-2018  martin Pull up following revision(s) (requested by uwe in ticket #1064):

sys/dev/pci/aac_pci.c: revision 1.39
sys/dev/pci/pcidevs: revision 1.1348

Add Adaptec RAID 2445 and 2805.
From Dima Veselov.
 1.1289.2.9 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #934):
sys/dev/pci/pcidevs: 1.1332-1333, 1335-1339, 1341-1344 via patch
- Add Symbios/LSI RAID and SAS controllers.
- Add some broadcom 802.11ac wifi devices.
- Add some Marvell Yukon devices.
- Add Intel 82Q45 IDER.
- Add some Intel 4 series chipset devices.
- Add some Intel 82965 devices.
- Change Intel 0x2a06 from IDE to IDER.
- Add a bunch of nvidia devices from various generations.
- Add two more Yukon variants (from OpenBSD).
- Add Mobility Radeon HD 4300(0x9552) and Mobility Radeon HD
4500(0x9553) from OpenBSD.
- Add nSYS Technologies.
- Add Western Digital (Sandisk) WD Black NVMe SSD as per suggestion
from thorpej@
 1.1289.2.8 14-Jun-2018  martin Pull up following revision(s) (requested by maya in ticket #878):

share/man/man4/rtsx.4: revision 1.5
sys/dev/pci/pcidevs: revision 1.1331
sys/dev/ic/rtsxreg.h: revision 1.3
sys/dev/ic/rtsxvar.h: revision 1.3
sys/dev/pci/rtsx_pci.c: revision 1.7
sys/dev/ic/rtsx.c: revision 1.3

add realtek RT525A PCI-E card reader
found in my Dell XPS 15 9550.

rtsx(4): Add support for RT525A, from openbsd.
ok rkujawa

Denote RTS525A, bump date
 1.1289.2.7 07-Jun-2018  martin Pull up following revision(s) (requested by jnemeth in ticket #846):

sys/dev/pci/pcidevs: revision 1.1334
sys/dev/pci/pucdata.c: revision 1.102

add Oxford Semiconductor OXPCIe954 PCIe 4-port serial card
 1.1289.2.6 18-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #780):

sys/dev/pci/pcidevs: revision 1.1328-1.1330

Add some 8th Generation Intel Core Processor devices.
Add Intel SSD 760p.
Added some NVMe devices.
 1.1289.2.5 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #751):

sys/dev/pci/pcidevs: revision 1.1308
sys/dev/pci/pcidevs: revision 1.1327

Add Nvidia GeForce 9400M as found in the late 2009 13" MacBook (MacBook6,1)

Add new I219 devices (using with 300 series chipset).
 1.1289.2.4 09-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #723):
sys/dev/pci/pcidevs: revision 1.1314
sys/dev/pci/pcidevs: revision 1.1315
sys/dev/pci/pcidevs: revision 1.1316
sys/dev/pci/pcidevs: revision 1.1317
sys/dev/pci/pcidevs: revision 1.1318
sys/dev/pci/pcidevs: revision 1.1302
sys/dev/pci/pcidevs: revision 1.1303
sys/dev/pci/pcidevs: revision 1.1304
sys/dev/pci/pcidevs: revision 1.1305
sys/dev/pci/pcidevs: revision 1.1306
sys/dev/pci/pcidevs: revision 1.1307
sys/dev/pci/pcidevs: revision 1.1309
sys/dev/pci/pcidevs: revision 1.1320
sys/dev/pci/pcidevs: revision 1.1321
sys/dev/pci/pcidevs: revision 1.1322
sys/dev/pci/pcidevs: revision 1.1324
sys/dev/pci/pcidevs: revision 1.1325
sys/dev/pci/pcidevs: revision 1.1326
sys/dev/pci/pcidevs: revision 1.1310
sys/dev/pci/pcidevs: revision 1.1311
sys/dev/pci/pcidevs: revision 1.1312
sys/dev/pci/pcidevs: revision 1.1313

Add some Chelsio devices.
- s/MMC/eMMC/ for Intel 0x0f14 (Bay Trail)
- Add Atom E3800 (Bay Trail) eMMC 4.5

Add Intel Apollo Lake devices.

Add the GeForce4 MX440 Go, as found on the 17" flat panel G4 iMac (PowerMac4,5).
Thanks to Jasper Wallace <jasper AT pointless DOT net> for the loan of the hardware.

Add Nvidia GeForce FX Go5200, as found in the PowerBook6,4

Add Marvell Yukon 88E8040T

grammar

Add some ServerEngines (Emulex) products from OpenBSD.
Add some Intel Ethernet devices.
Add C620 devices.
Fix C62x9 sSATA Controller (RAID) device ID.

s/C62x9/C62x/

Add some Xeon E5 (v1) and E5 v2 devices.

Add AMD KERNCZ chipset for Zen processors.

Add Intel Gemini Lake devices.
apply some updates and recommended corrections to pcidevs descriptions
PR kern/45733 by Greg A.Woods

Intel 0x15c4 is SFI based and 0x15ce is KR based.

Add Intel Wireless AC 9260.

Add two VIA xHCI devices from OpenBSD.

Add Intel X299 and Z370 LPC.

Add Intel Coffee Lake internal graphics devices. From ark.intel.com.

Add Intel 300 series devices.
 1.1289.2.3 08-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #616):
sys/dev/pci/if_msk.c: revision 1.55
sys/dev/pci/pcidevs: revision 1.1299
update entry for Marvel Yukon 8058, and fix URL for pci ids (Rocky Hotas)
 1.1289.2.2 21-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #364):
sys/dev/pci/pcidevs: revision 1.1300
sys/dev/pci/pcidevs: revision 1.1301
sys/dev/pci/pcidevs: revision 1.1290
sys/dev/pci/pcidevs: revision 1.1292
sys/dev/pci/pcidevs: revision 1.1293
sys/dev/pci/pcidevs: revision 1.1294
sys/dev/pci/pcidevs: revision 1.1295
sys/dev/pci/pcidevs: revision 1.1296
sys/dev/pci/pcidevs: revision 1.1297
sys/dev/pci/pcidevs: revision 1.1298
- Change VMware's 0x0770 from "Virtual USB" to "Virtual EHCI"
- Add VMware's 0x0774(UHCI) and 0x0778(xHCI)
Add Intel 82Q965 HECI.
Add Atom Z8000 devices from "Intel Atom Z8000 Processor Series Datasheet
(Volume 2 of 2)".
- Add some AMD devices.
- Add Broadcom BCM5762.
Add Intel 5520/X58 QuickPath from OpenBSD.
PCI device ID of Atom x5-Z8350's video is 0x22b0. ark.intel.com says 0x22b0 is
Intel HD Graphics 400.
Add C3000 devices.
Add Intel QuickAssist devices.
Add Areca ARC1214 & ARC1880.
From OpenBSD.
Add PEX 8605 4port 4lane PCIe Gen 2 switch.
 1.1289.2.1 25-Jun-2017  snj Pull up following revision(s) (requested by jdolecek in ticket #55):
share/man/man4/siisata.4: revision 1.6
sys/dev/pci/pcidevs: revision 1.1291
sys/dev/pci/siisata_pci.c: revision 1.15
add entry for Adaptec 1220SA
--
match Adaptec 1220SA; that card actually uses Silicon Image 3132, and works
well with the siisata(4) driver
--
add Adaptec 1220SA
 1.1319.2.15 26-Jan-2019  pgoyette Sync with HEAD
 1.1319.2.14 18-Jan-2019  pgoyette Synch with HEAD
 1.1319.2.13 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1319.2.12 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1319.2.11 20-Oct-2018  pgoyette Sync with head
 1.1319.2.10 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1319.2.9 28-Jul-2018  pgoyette Sync with HEAD
 1.1319.2.8 25-Jun-2018  pgoyette Sync with HEAD
 1.1319.2.7 21-May-2018  pgoyette Sync with HEAD
 1.1319.2.6 02-May-2018  pgoyette Synch with HEAD
 1.1319.2.5 22-Apr-2018  pgoyette Sync with HEAD
 1.1319.2.4 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1319.2.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1319.2.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.1319.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.1343.2.3 21-Apr-2020  martin Sync with HEAD
 1.1343.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1343.2.1 10-Jun-2019  christos Sync with HEAD
 1.1383.2.26 26-Oct-2025  martin Pull up following revision(s) (requested by andvar in ticket #1978):

sys/dev/pci/pcidevs: revision 1.1528

Add VIA VT8233C PCI-ISA Bridge.
 1.1383.2.25 08-May-2025  martin Additionally pull up

sys/dev/pci/pcidevs 1.1520

accidently missed in previous for ticket #1944
 1.1383.2.24 08-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1944):

sys/dev/pci/pcidevs: revision 1.1521
sys/dev/pci/pcidevs: revision 1.1522
sys/dev/pci/pcidevs: revision 1.1518
sys/dev/pci/pcidevs: revision 1.1519

Various VIA IDE controller related additions/changes.
 1.1383.2.23 03-Jul-2024  martin Pull up following revision(s) (requested by nia in ticket #1852):

sys/dev/pci/pcidevs: revision 1.1507

Add Brainboxes and devices
From Cameron Williams in PR 58358.
 1.1383.2.22 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #1790):

sys/dev/pci/pcidevs: revision 1.1494
sys/dev/pci/pcidevs: revision 1.1498
sys/dev/pci/pcidevs: revision 1.1499
sys/dev/pci/pcidevs: revision 1.1500
sys/dev/pci/pcidevs: revision 1.1501
sys/dev/pci/pcidevs: revision 1.1502

pcidevs: Add missing I225/I226 series devices
pcidevs: Add Mellanox ConnectX-6 Lx.
add some newer Areca boards in prep for updating driver
Add Intel C26[26] eSPI.
Update Intel Raptor Lake devices.
Add Intel I219-{LM,V}(20,21)
 1.1383.2.21 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1754):

sys/dev/pci/pcidevs: revision 1.1497
sys/dev/pci/if_wm.c: revision 1.790
sys/dev/pci/if_wm.c: revision 1.791
sys/dev/pci/if_wmvar.h: revision 1.51

pcidevs: Add Intel I219{V,LM}({22,23})

wm(4): Add a new workaround for Tiger Lake and newer.
- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.

wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.1383.2.20 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1750):

sys/dev/pci/pcidevs: revision 1.1493
sys/dev/pci/pcidevs: revision 1.1495

Add Intel 82599 LS.
Add Pericom(Diodes) PCIe switches.
 1.1383.2.19 13-Oct-2023  martin Pull up following revision(s) (requested by abs in ticket #1748):

sys/dev/pci/pcidevs: revision 1.1496

Add entry for ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier
 1.1383.2.18 21-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1719):

sys/dev/pci/pcidevs: revision 1.1483-1.1492

Add AMD 19h/7xh Root Complex.
pcidevs: add ASMedia ASM106x

Add Intel Snow Ridge devices.

Fix some descriptions of Intel Snow Ridge.

Add Intel I226 devices.

Add device ids of the VX800 chipset and s3 chrome 500 series GPU.
Descriptions mainly aligned with VX800/820 Series System Programming Manual.
fix duplicate definition.

Add some Intel Xeon D-2100 devices. Fix description of Intel 0x37d0.

Simplify descriptions of Snow Ridge internal Ethernet devices.

Rename PCI to PCIE for naming consistency.
 1.1383.2.17 29-Jul-2023  martin Pull up the following revisions, via patch, requested by msaitoh in
ticket #1671:

sys/dev/pci/pcidevs 1.1481-1.1482

Add Intel Alder Lake-N, Raptor Lake and 700 series chipset devices.
 1.1383.2.16 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1654):

sys/dev/pci/pcidevs: revision 1.1478
sys/dev/pci/pcidevs: revision 1.1479
sys/dev/pci/pcidevs: revision 1.1480

Add Samsung SM990.

Add devices from PPR for AMD Family 19h Model 61h Revision B1 processors.

The SATA device ID for Apollo Lake is not 0x5ae0 but 0x5ae3.
 1.1383.2.15 30-Jan-2023  martin Pull up following revision(s) (requested by thorpej in ticket #1580):

sys/dev/pci/pcidevs: revision 1.1477

Add ID for the EXAR XR17V354 PCIe UART.
PR kern/57202
 1.1383.2.14 18-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1566):

sys/dev/pci/sdhc_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.1469
sys/dev/pci/pcidevs: revision 1.1470
sys/dev/pci/pcidevs: revision 1.1471
sys/dev/pci/pcidevs: revision 1.1472
sys/dev/pci/pcidevs: revision 1.1473
sys/dev/pci/pcidevs: revision 1.1474
sys/dev/pci/pcidevs: revision 1.1475
sys/dev/pci/pcidevs: revision 1.1476

Add some AMD 17h/9xh devices from OpenBSD.
Add AMD F17/Axh devices.
Add some Xeon Scalable devices from OpenBSD.
Update Intel Elkhart Lake devices.
Add Elkhart Lake Shared SRAM.
Fix typo. s/SSC/SCC/.
Fix typo. No functional change.
add Aquantia (Marvell) AQC113 ethernet devices and the variants
Add AMD Family 19h/1xh devices.
 1.1383.2.13 11-Oct-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1537):

sys/arch/x86/pci/imcsmb/imc.c: revision 1.5
sys/dev/pci/pcidevs: revision 1.1461-1.1468

add several samsung nvme entries

Add more Alder Lake devices.

Jasper Lake Intel Trace Hub on Compute Die is not 0x4da6 but 0x4e29.

Add Intel Core 8G (8core, H, Halo) Host Bridge, DRAM.

Sort by number. No functional change.

Add AMD 19h/6xh Root Complex.

Add AMD FCH SATA Controller D

add NVIDIA GeForce GTX 770

Fix compile error.
 1.1383.2.12 27-Jul-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1482:

sys/dev/pci/pcidevs 1.1422,1.1445-1.1460
via patch
sys/arch/x86/pci/amdsmn.c 1.13

Update pcidevs:
- Add Intel Alder Lake devices and Intel 600 Series PCH devices.
- Add some Intel Xeon Scalable / Skylake-E devices.
- Fix AMD F16_HB from 0x1568 to 0x1538.
- Add some devices for AMD and improve some descriptions to clarify.
- Add VMware AHCI and NVMe.
- Update Intel 700 series Ethernet devices.
- Add some Broadcom devices.
- Add some Broadcom / LSI RAID cards.
- Fix typos and whitespace.
 1.1383.2.11 03-Dec-2021  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1380:

sys/dev/pci/pcidevs 1.1441-1.1444

- Add Intel Gemini Lake TXE HECI 1.
- Add Intel Elkhart Lake and Rocket Lake devices.
- Update Jasper Lake's Processor Transaction Routers.
 1.1383.2.10 21-Oct-2021  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1362:

sys/dev/pci/pcidevs 1.1419-1.1440

- Add newer ciss(4) devices.
- Add modern QUMRANET/Red Hat VIRTIO range PCI devices.
- Add some more product IDs for mcx(4).
- Add current generation NVIDIA graphics cards (3050-3090 etc.).
- Add RDC R6022 PCI-Host bridge.
- Add a whole bunch of radeon devices.
- Add Realtek RTL8821CE.
- Add Intel 660p SSD, and expand the 760p description.
- Add Intel I219's version number.
- Add Intel I219V 15-19 and I219LM 16-19.
- Add Intel I225V, I225LM and WiFi 6 AX201.
- Add newer Intel PCH internal devices.
- Add Intel Jasper Lake devices.
- PDC20265 is Ultra/100, not 66.
- Fix Realtek RTL8125 description.
- Sort Cavium devices.
 1.1383.2.9 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #991:

sys/dev/pci/pcidevs 1.1403-1.1407, 1.1409, 1.1412-1.1418 via patch

- Add NVIDIA Quadro NVS 295.
- Add more RDC products from Andrius V.
- Add some Intel UHD Graphics devices. Mainly taken from OpenBSD.
- Add Intel Comet Lake, Whiskey Lake U and Amber Lake Y devices.
- Modify description of Intel 0x591e from HD Graphics to UHD Graphics.
- Add Intel XMM 7360 LTE Modem.
- Add Western Digital WD Blue SN550 NVMe SSD.
- Add ATI Radeon R5/R6/R7 Graphics.
- Add IDs for Ampere eMAG PCIe Root Ports.
- Add RTL8192EE Wireless LAN 802.11n PCI-E NIC.
- Add ASIX AX99100 Multi I/O (Serial,Parallel,I2C,SPI,LocalBus,GPIO)
Controller.
- Add a couple of additional device IDs for the AMD Cryptographic
Coprocessor.
- Remove duplicated entries.
 1.1383.2.8 07-Jul-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #980):

sys/dev/pci/if_aq.c: revision 1.4
sys/dev/pci/if_aq.c: revision 1.5
sys/arch/amd64/conf/GENERIC: revision 1.553
sys/dev/pci/files.pci: revision 1.419
sys/arch/amd64/conf/XEN3_DOM0: revision 1.170
sys/dev/pci/if_aq.c: revision 1.9
share/man/man4/Makefile: revision 1.693
sys/dev/pci/pcidevs: revision 1.1411
share/man/man4/aq.4: revision 1.1
share/man/man4/aq.4: revision 1.3
sys/arch/i386/conf/ALL: revision 1.479
share/man/man4/aq.4: revision 1.4
sys/dev/pci/if_aq.c: revision 1.10
sys/dev/pci/files.pci: revision 1.421
sys/dev/pci/if_aq.c: revision 1.11
sys/dev/pci/if_aq.c: revision 1.12
sys/dev/pci/if_aq.c: revision 1.13
sys/dev/pci/if_aq.c: revision 1.14
sys/dev/pci/if_aq.c: revision 1.15
sys/dev/pci/if_aq.c: revision 1.16
sys/dev/pci/pcidevs: revision 1.1408
sys/arch/amd64/conf/ALL: revision 1.135
sys/net/ethertypes.h: revision 1.19
sys/arch/i386/conf/GENERIC: revision 1.1218
distrib/sets/lists/man/mi: revision 1.1668
sys/dev/pci/if_aq.c: revision 1.1
sys/dev/pci/if_aq.c: revision 1.2
sys/dev/pci/pcidevs: revision 1.1395
sys/dev/pci/if_aq.c: revision 1.3
sys/arch/evbarm/conf/GENERIC64: revision 1.125

Add the ETHERTYPE_QINQ for 802.1ad VLAN stacking

add Aquantia AQC 10G network adapters
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.

add aq(4)

Add Aquantia AQC100, AQC100S and D100.

add support VLAN HW filter

set/clear IFF_OACTIVE flag only on txring 0

make counters per queue

support internal PHY temperature sensor

Found by kUBSan:
- Use unsigned to avoid undefined behavior in aq_hw_init().
- Cast to unsigned to avoid undefined behavior in aq_set_mac_addr().

fix descriptions of register map in comment

return the ifmedia active status correctly even while the link is not up after attach.
pointed out by msaitoh@. thanks.

On FIBRE devices, there are times when linkstat interrupt doesn't occur?
reported from Andrius V. thanks.
- use polling instead of linkstat interrupt when FIBRE
- add AQ_FORCE_POLL_LINKSTAT options (not by default)

sort product table, and tabify

add support AQC100S and D100.
not tested, but they are probably the same as the AQC100.
 1.1383.2.7 28-Apr-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #864):

share/man/man4/rtsx.4: revision 1.6
sys/dev/pci/pcidevs: revision 1.1410
sys/dev/pci/rtsx_pci.c: revision 1.9

Add an eclectic mix of
GeForce GTX 680, RTS522A PCI-E Card Reader, intel wifi 9560
+ whitespace

Add support for Realtek RTS522A
 1.1383.2.6 19-Mar-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #784):

sys/dev/pci/pcidevs: revision 1.1398
sys/dev/pci/pcidevs: revision 1.1399
sys/dev/pci/pcidevs: revision 1.1400
sys/dev/pci/pcidevs: revision 1.1401
sys/dev/pci/pcidevs: revision 1.1402

add a couple of GPUs i have:
product ATI RADEON_HD4290 0x9714 Radeon HD4290 Graphics
product NVIDIA GF_440 0x0de0 GeForce GT 440

Add Farallon PN9000SX Ethernet.

NVIDIA 0x036[0-7] are nForce MCP55 LPC Bridge.

Add device IDs of the VIA VX900 chipset.

Add some GeForce devices.
 1.1383.2.5 31-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #670):

sys/dev/pci/pcidevs: revision 1.1396
sys/dev/pci/pcidevs: revision 1.1397
sys/dev/pci/pcidevs: revision 1.1392
sys/dev/pci/pcidevs: revision 1.1393
sys/dev/pci/pcidevs: revision 1.1394
sys/dev/pci/pcidevs: revision 1.1395

- Add Xeon D-1500 NTB-secondary

- Add Xeon D NS QuickData DMA channel 0-7

Add AMD Family14h PCIe.

Killer E3000
from OpenBSD

add Aquantia AQC 10G network adapters

Add Intel I219 LM10-LM15 and V10-V14 from OpenBSD.

Remove duplicated entries.
 1.1383.2.4 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #449):

sys/dev/pci/pcidevs: revision 1.1388
sys/dev/pci/pcidevs: revision 1.1389
sys/dev/pci/pcidevs: revision 1.1390
sys/dev/pci/pcidevs: revision 1.1391

Spell controller correctly
Add Realtek RTL8125.
- Update Intel's NVMe SSDs.
- Modify 0x0953's description to "750 or DC P3[567]00 SSD"
- Add DC P4[56]00
- Add Apollo Lake TXE HECI.
Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.
 1.1383.2.3 24-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #373):

sys/dev/pci/pcidevs: revision 1.1386
sys/dev/pci/pcidevs: revision 1.1387

Modify Attansic Ethernet devices' description to clarify.
Add Killer E2400 and E2500.
 1.1383.2.2 24-Sep-2019  martin Pull up following revision(s) (requested by jmcneill in ticket #237):

sys/dev/pci/pcidevs: revision 1.1385

Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex
 1.1383.2.1 26-Aug-2019  martin Pull up following revision(s) (requested by mrg in ticket #112):

sys/dev/pci/pcidevs: revision 1.1384

add micron/crucial SM2263 nvme.
add some device found on asus x570-p with ryzen 3200G cpu.
spell it "PCIe' when using the name.
 1.1395.2.2 29-Feb-2020  ad Sync with head.
 1.1395.2.1 25-Jan-2020  ad Sync with head.
 1.1404.2.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.1404.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.1419.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.1419.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.1419.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1424.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1426.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1471.2.17 26-Oct-2025  martin Pull up following revision(s) (requested by andvar in ticket #1184):

sys/dev/pci/pcidevs: revision 1.1528

Add VIA VT8233C PCI-ISA Bridge.
 1.1471.2.16 08-May-2025  martin Additionally pull up

sys/dev/pci/pcidevs 1.1520

accidently missed in previous for ticket #1101
 1.1471.2.15 08-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1101):

sys/dev/pci/pcidevs: revision 1.1521
sys/dev/pci/pcidevs: revision 1.1522
sys/dev/pci/pcidevs: revision 1.1518
sys/dev/pci/pcidevs: revision 1.1519

Various VIA IDE controller related additions/changes.
 1.1471.2.14 06-Dec-2024  snj Pull up following revision(s) (requested by msaitoh in ticket #1024):
sys/dev/pci/pcidevs: 1.504-1.506, 1.508-1.513
Update pcidevs:
- Add Zhaoxin devices, mainly from my TVS-675 NAS device, and some additional
to fill the gaps from pci-ids database.
- Add Phison PS5021 and PS5026.
- Add some Intel Rapotr Lake graphics.
- Add Realtek RTL8126.
- Add the intel "arc" a-series of cards.
- Add Areca ARC-1224.
- Add some AMD devices.
- Add Raspberry Pi5 Ethernet.
- Add many Brainboxes devices. Reported in PR kern/55824 by Cameron Williams.
 1.1471.2.13 24-Aug-2024  martin Pull up following revision(s) (requested by jakllsch in ticket #805):

sys/dev/pci/pcidevs: revision 1.1503
sys/dev/pci/if_re_pci.c: revision 1.53

Add (Realtek/)Killer E2600 Ethernet
Add Killer E2600, adapted from PR 57969
 1.1471.2.12 03-Jul-2024  martin Pull up following revision(s) (requested by nia in ticket #730):

sys/dev/pci/pcidevs: revision 1.1507

Add Brainboxes and devices
From Cameron Williams in PR 58358.
 1.1471.2.11 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #560):

sys/dev/pci/pcidevs: revision 1.1499
sys/dev/pci/pcidevs: revision 1.1500
sys/dev/pci/pcidevs: revision 1.1501
sys/dev/pci/pcidevs: revision 1.1502

add some newer Areca boards in prep for updating driver
Add Intel C26[26] eSPI.
Update Intel Raptor Lake devices.
Add Intel I219-{LM,V}(20,21)
add some newer Areca boards in prep for updating driver
Add Intel C26[26] eSPI.
Update Intel Raptor Lake devices.
Add Intel I219-{LM,V}(20,21)
 1.1471.2.10 03-Nov-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #447):

sys/dev/pci/pcidevs: revision 1.1498
sys/dev/pci/if_mcx.c: revision 1.26
share/man/man4/mcx.4: revision 1.3

pcidevs: Add Mellanox ConnectX-6 Lx.

mcx(4): Add Mellanox ConnectX-6 Lx from OpenBSD.
 1.1471.2.9 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #421):

sys/dev/pci/pcidevs: revision 1.1497
sys/dev/pci/if_wm.c: revision 1.790
sys/dev/pci/if_wm.c: revision 1.791
sys/dev/pci/if_wmvar.h: revision 1.51

pcidevs: Add Intel I219{V,LM}({22,23})

wm(4): Add a new workaround for Tiger Lake and newer.
- Define new WM_T_PCH_TGP and use it for Tiger Lake and newer.
Note that we don't define WM_T_PCH_ADP because we have no any
Alder Lake specific workaround yet.
- Add new workaround for Tiger Lake (and newer) in wm_init_locked()
to avoid packet loss.

wm(4): Add I219{V,LM}({22,23}) devices (Raptor Lake).
 1.1471.2.8 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #406):

sys/dev/pci/pcidevs: revision 1.1493
sys/dev/pci/pcidevs: revision 1.1495

Add Intel 82599 LS.
Add Pericom(Diodes) PCIe switches.
 1.1471.2.7 13-Oct-2023  martin Pull up following revision(s) (requested by abs in ticket #403):

sys/dev/pci/pcidevs: revision 1.1496

Add entry for ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier
 1.1471.2.6 08-Oct-2023  martin Pull up the following, requested by rin in ticket #393:

sys/dev/pci/pcidevs 1.1494 (via patch)

Add missing I225/I226 series devices
 1.1471.2.5 21-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #333):

sys/dev/pci/pcidevs: revision 1.1483-1.1492

Add AMD 19h/7xh Root Complex.
pcidevs: add ASMedia ASM106x

Add Intel Snow Ridge devices.

Fix some descriptions of Intel Snow Ridge.

Add Intel I226 devices.

Add device ids of the VX800 chipset and s3 chrome 500 series GPU.
Descriptions mainly aligned with VX800/820 Series System Programming Manual.
fix duplicate definition.

Add some Intel Xeon D-2100 devices. Fix description of Intel 0x37d0.

Simplify descriptions of Snow Ridge internal Ethernet devices.

Rename PCI to PCIE for naming consistency.
 1.1471.2.4 29-Jul-2023  martin Pull up the following revisions, via patch, requested by msaitoh
in ticket #252:

sys/dev/pci/pcidevs 1.1481-1.1482

Add Intel Alder Lake-N, Raptor Lake and 700 series chipset devices.
 1.1471.2.3 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #209):

sys/dev/pci/pcidevs: revision 1.1478
sys/dev/pci/pcidevs: revision 1.1479
sys/dev/pci/pcidevs: revision 1.1480

Add Samsung SM990.

Add devices from PPR for AMD Family 19h Model 61h Revision B1 processors.

The SATA device ID for Apollo Lake is not 0x5ae0 but 0x5ae3.
 1.1471.2.2 30-Jan-2023  martin Pull up following revision(s) (requested by thorpej in ticket #61):

sys/dev/pci/pcidevs: revision 1.1477

Add ID for the EXAR XR17V354 PCIe UART.
PR kern/57202
 1.1471.2.1 18-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #50):

sys/dev/pci/sdhc_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.1472
sys/dev/pci/pcidevs: revision 1.1473
sys/dev/pci/pcidevs: revision 1.1474
sys/dev/pci/pcidevs: revision 1.1475
sys/dev/pci/pcidevs: revision 1.1476

Update Intel Elkhart Lake devices.
Add Elkhart Lake Shared SRAM.
Fix typo. s/SSC/SCC/.
Fix typo. No functional change.
add Aquantia (Marvell) AQC113 ethernet devices and the variants
Add AMD Family 19h/1xh devices.
 1.1507.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1527.2.1 26-Oct-2025  martin Pull up following revision(s) (requested by andvar in ticket #71):

sys/dev/pci/pcidevs: revision 1.1528

Add VIA VT8233C PCI-ISA Bridge.
 1.1510 27-Oct-2025  andvar regen.
 1.1509 21-Oct-2025  pgoyette regen
 1.1508 21-Oct-2025  pgoyette Regen for vendor MediaTek
 1.1507 17-Oct-2025  andvar regen.
 1.1506 03-May-2025  rin branches: 1.1506.2;
pcidevs{,_data}.h: Regen for EXAR XR17V358
 1.1505 01-May-2025  andvar regen.
 1.1504 01-May-2025  andvar regen.
 1.1503 28-Apr-2025  andvar regen.
 1.1502 28-Apr-2025  andvar regen.
 1.1501 20-Apr-2025  andvar regen.
 1.1500 05-Apr-2025  andvar regen.
 1.1499 03-Apr-2025  andvar regen.
 1.1498 03-Mar-2025  andvar regen.
 1.1497 23-Jan-2025  andvar regen.
 1.1496 23-Jan-2025  mrg regen
 1.1495 18-Jan-2025  mrg regen.
 1.1494 03-Jan-2025  mrg regen.
 1.1493 12-Dec-2024  msaitoh regen.
 1.1492 11-Nov-2024  msaitoh Regen.
 1.1491 19-Oct-2024  mlelstv Regen
 1.1490 16-Oct-2024  msaitoh Regen.
 1.1489 20-Aug-2024  dogcow regen
 1.1488 17-Jul-2024  mrg regen after intel arc.
 1.1487 11-Jul-2024  msaitoh Regen.
 1.1486 23-Jun-2024  jakllsch branches: 1.1486.2;
Regen.

For PR 58358
 1.1485 12-May-2024  msaitoh Regen.
 1.1484 06-Apr-2024  andvar regen.
 1.1483 28-Feb-2024  jakllsch regen
 1.1482 18-Jan-2024  msaitoh regen.
 1.1481 28-Dec-2023  msaitoh pcidevs: Regen.
 1.1480 13-Nov-2023  jnemeth regen for newer Areca boards
 1.1479 26-Oct-2023  msaitoh pcidevs: regen.
 1.1478 11-Oct-2023  msaitoh Regen.
 1.1477 10-Oct-2023  abs Regenerate for ASMEDIA 0x0624
 1.1476 08-Oct-2023  msaitoh Regen.
 1.1475 04-Oct-2023  rin Regen for pcidevs rev 1.1494
 1.1474 04-Oct-2023  msaitoh Regen.
 1.1473 10-Aug-2023  andvar regen.
 1.1472 09-Aug-2023  msaitoh Regen.
 1.1471 09-Aug-2023  msaitoh Regen.
 1.1470 05-Aug-2023  andvar regen.
 1.1469 05-Aug-2023  andvar Regen.
 1.1468 04-Aug-2023  msaitoh Regen.
 1.1467 04-Aug-2023  msaitoh Regen.
 1.1466 31-Jul-2023  tnn pcidevs: regen
 1.1465 28-Jul-2023  msaitoh Regen.
 1.1464 23-Jul-2023  msaitoh Regen.
 1.1463 22-Jul-2023  msaitoh regen.
 1.1462 22-Jul-2023  msaitoh Add Alder Lake-N and Raptor Lake devices.
 1.1461 06-Apr-2023  msaitoh Regen.
 1.1460 14-Feb-2023  msaitoh Regen.
 1.1459 03-Feb-2023  msaitoh Regen.
 1.1458 29-Jan-2023  thorpej Regen for EXAR XR17V354.

PR kern/57202
 1.1457 18-Jan-2023  msaitoh Regen.
 1.1456 14-Jan-2023  ryo regen
 1.1455 04-Jan-2023  msaitoh Regen.
 1.1454 30-Dec-2022  msaitoh Regen.
 1.1453 28-Dec-2022  msaitoh Regen.
 1.1452 22-Nov-2022  msaitoh branches: 1.1452.2;
Regen.
 1.1451 26-Oct-2022  msaitoh Regen.
 1.1450 26-Oct-2022  msaitoh Regen.
 1.1449 07-Oct-2022  snj regen
 1.1448 02-Oct-2022  martin regen (AMD FCH SATA D added)
 1.1447 01-Oct-2022  msaitoh Regen.
 1.1446 28-Sep-2022  msaitoh Regen.
 1.1445 13-Sep-2022  msaitoh Regen.
 1.1444 11-Sep-2022  mrg regen
 1.1443 27-Jun-2022  msaitoh Regen.
 1.1442 17-Jun-2022  msaitoh Regen.
 1.1441 02-Jun-2022  mrg regen.
 1.1440 11-May-2022  markd Regen
 1.1439 04-May-2022  martin Regen
 1.1438 04-May-2022  nia regen
 1.1437 27-Apr-2022  msaitoh Regen.
 1.1436 22-Apr-2022  skrll Regen
 1.1435 24-Mar-2022  yamaguchi regen
 1.1434 16-Mar-2022  yamaguchi Regen.
 1.1433 15-Feb-2022  msaitoh Regen.
 1.1432 02-Feb-2022  msaitoh Regen.
 1.1431 25-Jan-2022  msaitoh Regen.
 1.1430 01-Jan-2022  msaitoh Regen.
 1.1429 30-Nov-2021  msaitoh Regen.
 1.1428 03-Nov-2021  msaitoh Regen.
 1.1427 27-Oct-2021  msaitoh Regen.
 1.1426 27-Oct-2021  msaitoh Regen.
 1.1425 13-Oct-2021  msaitoh Regen.
 1.1424 12-Oct-2021  msaitoh Regen.
 1.1423 11-Oct-2021  msaitoh Regen.
 1.1422 02-Oct-2021  mrg regen.
 1.1421 23-Sep-2021  msaitoh Regen.
 1.1420 06-Sep-2021  mrg regen.
 1.1419 03-Sep-2021  mrg regen.
 1.1418 30-Aug-2021  andvar regen.
 1.1417 30-Aug-2021  mrg regen.
 1.1416 30-Aug-2021  mrg regen.
 1.1415 17-Jul-2021  mrg regen.
 1.1414 12-Jul-2021  msaitoh Regen.
 1.1413 29-Jun-2021  pgoyette Regen for new sys/dev/devlist2h.awk
 1.1412 21-Apr-2021  jakllsch branches: 1.1412.2;
regenerate
 1.1411 02-Apr-2021  rin regen
 1.1410 30-Jan-2021  jmcneill branches: 1.1410.2;
regen
 1.1409 29-Dec-2020  skrll regen
 1.1408 20-Nov-2020  msaitoh Regen.
 1.1407 19-Nov-2020  reinoud Regenated from pcidevs
 1.1406 14-Jul-2020  jdolecek branches: 1.1406.2;
regen
 1.1405 09-Jul-2020  msaitoh Regen.
 1.1404 24-Jun-2020  thorpej Regen.
 1.1403 13-Jun-2020  ryo regen
 1.1402 11-Jun-2020  jdolecek regen
 1.1401 26-May-2020  martin regen
 1.1400 01-May-2020  jmcneill regen
 1.1399 23-Apr-2020  msaitoh Regen.
 1.1398 22-Apr-2020  christos regen
 1.1397 22-Apr-2020  prlw1 regen
 1.1396 22-Apr-2020  msaitoh Regen.
 1.1395 18-Apr-2020  simonb Regen.
 1.1394 16-Apr-2020  msaitoh Regen.
 1.1393 10-Apr-2020  christos regen
 1.1392 07-Apr-2020  christos branches: 1.1392.2;
regen
 1.1391 01-Apr-2020  msaitoh Regen.
 1.1390 11-Mar-2020  msaitoh Regen.
 1.1389 11-Mar-2020  fcambus Regen.
 1.1388 08-Mar-2020  msaitoh Regen.
 1.1387 05-Mar-2020  msaitoh Regen.
 1.1386 19-Feb-2020  mrg regen.
 1.1385 28-Jan-2020  msaitoh Regen.
 1.1384 21-Jan-2020  msaitoh Regen.
 1.1383 01-Jan-2020  ryo branches: 1.1383.2;
regen
 1.1382 29-Dec-2019  sevan regen
 1.1381 18-Dec-2019  msaitoh Regen.
 1.1380 27-Nov-2019  msaitoh Regen.
 1.1379 14-Nov-2019  msaitoh Regen.
 1.1378 08-Nov-2019  msaitoh Regen.
 1.1377 29-Oct-2019  msaitoh Regen.
 1.1376 12-Oct-2019  skrll regen
 1.1375 21-Sep-2019  msaitoh Regen.
 1.1374 21-Sep-2019  msaitoh Regen.
 1.1373 24-Aug-2019  jmcneill regen
 1.1372 21-Aug-2019  mrg regen for new micron/crucial/amd entries, and PCIe spelling.
 1.1371 28-Jul-2019  mlelstv branches: 1.1371.2;
regen
 1.1370 24-Jul-2019  msaitoh Regen.
 1.1369 18-Jul-2019  msaitoh Regen.
 1.1368 12-Jul-2019  msaitoh Regen.
 1.1367 12-Jul-2019  msaitoh Regen.
 1.1366 09-Jul-2019  msaitoh Regen.
 1.1365 05-Jul-2019  msaitoh Regen.
 1.1364 02-Jul-2019  msaitoh Regen.
 1.1363 04-Jun-2019  msaitoh Regen.
 1.1362 01-Jun-2019  jdolecek regen
 1.1361 30-May-2019  mlelstv regen
 1.1360 15-Apr-2019  msaitoh Regen.
 1.1359 15-Apr-2019  msaitoh Regen.
 1.1358 12-Apr-2019  msaitoh Regen.
 1.1357 11-Apr-2019  mrg regen.
 1.1356 08-Mar-2019  msaitoh Regen.
 1.1355 05-Mar-2019  msaitoh Regen.
 1.1354 20-Feb-2019  msaitoh Regen.
 1.1353 20-Feb-2019  msaitoh Regen.
 1.1352 14-Feb-2019  msaitoh Regen.
 1.1351 08-Feb-2019  msaitoh Regen.
 1.1350 06-Feb-2019  msaitoh Regen.
 1.1349 28-Jan-2019  msaitoh Regen.
 1.1348 26-Jan-2019  msaitoh Regen.
 1.1347 21-Jan-2019  msaitoh Regen.
 1.1346 26-Dec-2018  msaitoh Regen.
 1.1345 03-Dec-2018  bouyer Regen for new Symbios devices
 1.1344 29-Nov-2018  jmcneill regen
 1.1343 24-Nov-2018  skrll Regen
 1.1342 12-Nov-2018  msaitoh Regen.
 1.1341 08-Nov-2018  msaitoh Regen.
 1.1340 16-Oct-2018  jmcneill regen
 1.1339 15-Oct-2018  uwe Adaptec RAID 2445 and 2805
 1.1338 23-Aug-2018  msaitoh Regen.
 1.1337 30-Jul-2018  msaitoh Regen.
 1.1336 30-Jul-2018  msaitoh Regen.
 1.1335 06-Jul-2018  prlw1 regen
 1.1334 20-Jun-2018  msaitoh branches: 1.1334.2;
Regen.
 1.1333 14-Jun-2018  msaitoh Regen.
 1.1332 12-Jun-2018  jdolecek regen
 1.1331 09-Jun-2018  jdolecek regen
 1.1330 31-May-2018  mrg regen.
 1.1329 31-May-2018  msaitoh Regen.
 1.1328 28-May-2018  msaitoh Regen.
 1.1327 26-May-2018  jakllsch regen
 1.1326 24-May-2018  msaitoh Regen.
 1.1325 21-May-2018  jnemeth regen
 1.1324 03-May-2018  maya regen
 1.1323 28-Apr-2018  mlelstv regen
 1.1322 24-Apr-2018  maya regen
 1.1321 17-Apr-2018  nonaka regen
 1.1320 16-Apr-2018  msaitoh Regen.
 1.1319 09-Apr-2018  msaitoh Regen.
 1.1318 09-Apr-2018  msaitoh Regen.
 1.1317 04-Apr-2018  msaitoh Regen.
 1.1316 02-Apr-2018  msaitoh Regen.
 1.1315 31-Mar-2018  sevan regen
 1.1314 26-Mar-2018  msaitoh Regen.
 1.1313 20-Mar-2018  nonaka regen
 1.1312 16-Mar-2018  msaitoh Regen.
 1.1311 04-Mar-2018  jdolecek branches: 1.1311.2;
regen
 1.1310 04-Mar-2018  jdolecek regen
 1.1309 02-Mar-2018  msaitoh Regen.
 1.1308 24-Feb-2018  mlelstv Regen.
 1.1307 22-Feb-2018  msaitoh Regen.
 1.1306 22-Feb-2018  msaitoh Regen.
 1.1305 22-Feb-2018  msaitoh Regen.
 1.1304 22-Feb-2018  msaitoh Regen.
 1.1303 21-Feb-2018  msaitoh Regen.
 1.1302 17-Feb-2018  sevan regen
 1.1301 16-Feb-2018  sevan regen
 1.1300 25-Jan-2018  sborrill regen
 1.1299 24-Jan-2018  sevan regen
 1.1298 21-Jan-2018  sevan regen
 1.1297 09-Jan-2018  msaitoh Regen.
 1.1296 09-Jan-2018  msaitoh Regen.
 1.1295 18-Dec-2017  msaitoh Regen.
 1.1294 09-Nov-2017  msaitoh Regen.
 1.1293 30-Oct-2017  sevan regen
 1.1292 20-Oct-2017  christos regen
 1.1291 15-Sep-2017  hikaru Regen.
 1.1290 17-Aug-2017  msaitoh Regen.
 1.1289 02-Aug-2017  msaitoh regen.
 1.1288 26-Jul-2017  msaitoh Regen.
 1.1287 22-Jul-2017  msaitoh Regen.
 1.1286 07-Jul-2017  msaitoh Regen.
 1.1285 04-Jul-2017  msaitoh Regen.
 1.1284 27-Jun-2017  wiz regen (comment change only)
 1.1283 17-Jun-2017  jdolecek regen
 1.1282 06-Jun-2017  msaitoh Regen.
 1.1281 23-May-2017  nonaka branches: 1.1281.2;
regen
 1.1280 08-May-2017  msaitoh - Add RICOH R5C576 SD Card Controller.
- Add some SiS devices. Taken from OpenBSD.
- Change SiS 0x6325 from 6325 AGP VGA to 650 AGP VGA.
 1.1279 27-Apr-2017  msaitoh regen.
 1.1278 19-Apr-2017  msaitoh branches: 1.1278.2;
regen.
 1.1277 13-Apr-2017  msaitoh regen.
 1.1276 31-Mar-2017  skrll regen
 1.1275 31-Mar-2017  msaitoh regen.
 1.1274 23-Mar-2017  msaitoh regen.
 1.1273 14-Mar-2017  nonaka regen
 1.1272 27-Feb-2017  msaitoh regen.
 1.1271 16-Jan-2017  msaitoh regen.
 1.1270 15-Jan-2017  msaitoh branches: 1.1270.2;
regen.
 1.1269 15-Jan-2017  msaitoh regen.
 1.1268 10-Jan-2017  nonaka regen
 1.1267 27-Dec-2016  msaitoh Regen.
 1.1266 26-Dec-2016  msaitoh Regen.
 1.1265 01-Dec-2016  msaitoh Regen.
 1.1264 23-Nov-2016  christos regen
 1.1263 28-Oct-2016  msaitoh regen.
 1.1262 26-Oct-2016  msaitoh regen.
 1.1261 24-Oct-2016  msaitoh Regen.
 1.1260 20-Oct-2016  msaitoh regen.
 1.1259 19-Oct-2016  msaitoh regen.
 1.1258 04-Oct-2016  kiyohara Regen.
 1.1257 16-Sep-2016  msaitoh regen.
 1.1256 01-Sep-2016  msaitoh regen.
 1.1255 23-Aug-2016  msaitoh regen.
 1.1254 23-Aug-2016  msaitoh regen.
 1.1253 23-Aug-2016  msaitoh regen.
 1.1252 19-Aug-2016  msaitoh regen.
 1.1251 17-Aug-2016  msaitoh regen.
 1.1250 17-Aug-2016  msaitoh regen.
 1.1249 08-Aug-2016  msaitoh regen.
 1.1248 29-Jul-2016  nonaka regen
 1.1247 28-Jul-2016  nonaka regen
 1.1246 06-Jul-2016  christos branches: 1.1246.2;
regen
 1.1245 27-Jun-2016  pgoyette Regen
 1.1244 01-Jun-2016  pgoyette Regen
 1.1243 30-May-2016  nonaka regen
 1.1242 27-Apr-2016  christos regen
 1.1241 26-Apr-2016  msaitoh regen.
 1.1240 12-Feb-2016  mrg regen.
 1.1239 01-Feb-2016  msaitoh Regen.
 1.1238 22-Jan-2016  msaitoh Regen.
 1.1237 01-Dec-2015  msaitoh regen.
 1.1236 01-Dec-2015  msaitoh regen.
 1.1235 16-Nov-2015  msaitoh Regen.
 1.1234 16-Nov-2015  msaitoh Regen.
 1.1233 06-Nov-2015  nonaka regen
 1.1232 22-Oct-2015  msaitoh Regen.
 1.1231 21-Oct-2015  nonaka regen
 1.1230 19-Oct-2015  tnn regen
 1.1229 28-Aug-2015  nonaka regen
 1.1228 27-Aug-2015  nonaka regen
 1.1227 26-Aug-2015  msaitoh regen.
 1.1226 23-Aug-2015  jakllsch pcidevs .h regen
 1.1225 14-Aug-2015  nonaka regen
 1.1224 14-Aug-2015  knakahara regen
 1.1223 13-Aug-2015  msaitoh regen.
 1.1222 26-Jun-2015  msaitoh regen.
 1.1221 02-Jun-2015  nonaka regen
 1.1220 16-May-2015  msaitoh regen.
 1.1219 13-May-2015  nonaka regen
 1.1218 11-May-2015  msaitoh regen.
 1.1217 09-May-2015  christos regen
 1.1216 04-May-2015  ryo regen
 1.1215 03-May-2015  msaitoh regen.
 1.1214 02-Apr-2015  tnn regen
 1.1213 20-Mar-2015  msaitoh regen.
 1.1212 20-Mar-2015  msaitoh regen.
 1.1211 18-Mar-2015  msaitoh regen.
 1.1210 04-Mar-2015  knakahara regen.
 1.1209 15-Feb-2015  msaitoh regen.
 1.1208 25-Jan-2015  msaitoh Regen.
 1.1207 18-Jan-2015  christos regen
 1.1206 16-Jan-2015  msaitoh regen.
 1.1205 14-Jan-2015  msaitoh regen.
 1.1204 31-Dec-2014  veego Regen
 1.1203 23-Dec-2014  msaitoh Regen.
 1.1202 17-Dec-2014  hikaru Regen.
 1.1201 15-Dec-2014  msaitoh Regen.
 1.1200 15-Dec-2014  msaitoh regen.
 1.1199 30-Oct-2014  nonaka branches: 1.1199.2;
regen
 1.1198 29-Oct-2014  nonaka regen
 1.1197 02-Oct-2014  msaitoh Regen.
 1.1196 25-Sep-2014  msaitoh Regen.
 1.1195 21-Sep-2014  christos regen
 1.1194 16-Sep-2014  msaitoh Regen.
 1.1193 01-Sep-2014  msaitoh Regen.
 1.1192 30-Jul-2014  msaitoh branches: 1.1192.2;
regen.
 1.1191 25-Jul-2014  msaitoh Regen.
 1.1190 08-Jul-2014  msaitoh Regen.
 1.1189 03-Jul-2014  msaitoh Regen.
 1.1188 02-Jul-2014  msaitoh Regen.
 1.1187 23-Jun-2014  msaitoh Regen.
 1.1186 09-Jun-2014  msaitoh regen.
 1.1185 30-May-2014  msaitoh Regen.
 1.1184 28-May-2014  msaitoh Regen.
 1.1183 28-May-2014  msaitoh regen.
 1.1182 25-May-2014  njoly Regen for GeForce GT 640M.
 1.1181 26-Apr-2014  mrg regen.
 1.1180 09-Apr-2014  msaitoh regen
 1.1179 09-Apr-2014  msaitoh regen.
 1.1178 07-Apr-2014  njoly Regen for Intel Ivy Bridge PCI Express Root Port.
 1.1177 15-Mar-2014  kiyohara branches: 1.1177.2;
Regen.
 1.1176 14-Feb-2014  njoly Regen for GeForce 210 High Definition Audio Controller.
 1.1175 26-Jan-2014  msaitoh Regen.
 1.1174 21-Jan-2014  msaitoh Regen.
 1.1173 10-Jan-2014  msaitoh regen.
 1.1172 09-Jan-2014  christos regen
 1.1171 09-Jan-2014  msaitoh regen.
 1.1170 04-Jan-2014  msaitoh regen.
 1.1169 01-Jan-2014  msaitoh regen.
 1.1168 30-Dec-2013  msaitoh regen.
 1.1167 27-Dec-2013  msaitoh regen.
 1.1166 25-Dec-2013  msaitoh regen.
 1.1165 23-Dec-2013  msaitoh regen.
 1.1164 22-Dec-2013  nonaka regen
 1.1163 21-Dec-2013  msaitoh regen.
 1.1162 15-Dec-2013  pgoyette Regen
 1.1161 13-Dec-2013  pedro regen
 1.1160 12-Dec-2013  nonaka regen
 1.1159 08-Dec-2013  msaitoh regen.
 1.1158 13-Nov-2013  msaitoh regen.
 1.1157 07-Nov-2013  msaitoh Regen.
 1.1156 07-Nov-2013  msaitoh Add Quark X1000 devices.
 1.1155 07-Nov-2013  msaitoh Regen.
 1.1154 14-Sep-2013  soren Regen.
 1.1153 04-Sep-2013  christos regen
 1.1152 23-Aug-2013  christos regen
 1.1151 17-Jul-2013  soren Regen.
 1.1150 13-Jun-2013  matt branches: 1.1150.2; 1.1150.4;
Regen.
 1.1149 05-Jun-2013  msaitoh regen.
 1.1148 04-Jun-2013  msaitoh regen
 1.1147 03-Jun-2013  msaitoh Regen.
 1.1146 20-Apr-2013  rkujawa Regen PCI devs database.
 1.1145 18-Apr-2013  msaitoh regen.
 1.1144 18-Apr-2013  msaitoh regen.
 1.1143 06-Mar-2013  msaitoh regen.
 1.1142 03-Mar-2013  msaitoh regen.
 1.1141 27-Feb-2013  msaitoh regen.
 1.1140 20-Feb-2013  msaitoh regen.
 1.1139 30-Jan-2013  msaitoh regen.
 1.1138 06-Dec-2012  msaitoh Regen.
 1.1137 05-Dec-2012  christos Regen
 1.1136 29-Nov-2012  msaitoh regen.
 1.1135 21-Oct-2012  matt Regen.
 1.1134 20-Oct-2012  matt Regen.
 1.1133 19-Oct-2012  prlw1 regen
 1.1132 29-Sep-2012  gsutre regen
 1.1131 25-Sep-2012  gson regen
 1.1130 23-Sep-2012  chs regen
 1.1129 18-Sep-2012  matt Regen.
 1.1128 17-Sep-2012  matt Regen.
 1.1127 17-Sep-2012  tsutsui Regen from pcidevs rev 1.1134:
> Add Broadcom BCM57762 Gigabit Ethernet, per PR kern/46961.
 1.1126 13-Sep-2012  nonaka regen.
 1.1125 10-Aug-2012  bouyer branches: 1.1125.2;
Regen: add some PCI AHCI controllers.
 1.1124 07-Aug-2012  msaitoh regen.
 1.1123 06-Aug-2012  msaitoh regen.
 1.1122 05-Aug-2012  msaitoh regen.
 1.1121 05-Aug-2012  bouyer Regen: add MegaRAID SAS2208
 1.1120 27-Jul-2012  matt Regen.
 1.1119 26-Jul-2012  uwe Regen for VirtualBox ids.
 1.1118 25-Jul-2012  msaitoh regen.
 1.1117 23-Jul-2012  msaitoh regen.
 1.1116 22-Jul-2012  matt Regen.
 1.1115 20-Jul-2012  msaitoh regen.
 1.1114 19-Jul-2012  msaitoh regen.
 1.1113 12-Jul-2012  kiyohara Regen.
 1.1112 26-Jun-2012  drochner regen
 1.1111 25-May-2012  msaitoh regen for Intel I350 (wm)
 1.1110 18-Apr-2012  bouyer Regen: Add various newer LSI RAID/SAS controllers
 1.1109 13-Apr-2012  cegger regen.
 1.1108 09-Apr-2012  mlelstv regen
 1.1107 08-Apr-2012  jakllsch regen.
 1.1106 08-Apr-2012  jakllsch regen.
 1.1105 07-Apr-2012  christos regen
 1.1104 04-Apr-2012  uwe Regen for Marvell Yukon 88e8040 ethernet.
 1.1103 28-Mar-2012  pgoyette Regen for JMB362
 1.1102 21-Mar-2012  sborrill Regen
 1.1101 18-Mar-2012  tsutsui Regen from pcidevs rev 1.1106:
> Add VIA VX900 media system processor IDE controller.
> PR/46166 from Hiroshi Tokuda.
 1.1100 03-Mar-2012  nonaka regen.
 1.1099 02-Mar-2012  nonaka regen.
 1.1098 02-Mar-2012  nonaka regen.
 1.1097 15-Feb-2012  tsutsui branches: 1.1097.2;
Regen from pcidevs rev 1.1102:
> Add VIA VX900 Host Bridge, to handle its quirk. PR/46018
> Ok releng@
 1.1096 18-Oct-2011  jmcneill branches: 1.1096.2; 1.1096.6;
regen
 1.1095 06-Oct-2011  jmcneill regen
 1.1094 04-Oct-2011  njoly Regen for 3WARE 9750 Series RAID.
 1.1093 23-Sep-2011  njoly Regen for NVIDIA GeForce 210.
 1.1092 05-Sep-2011  msaitoh regen.
 1.1091 02-Sep-2011  msaitoh regen.
 1.1090 15-Aug-2011  msaitoh regen.
 1.1089 11-Aug-2011  bouyer Regen: add SiS 315 Pro VGA
 1.1088 09-Aug-2011  mbalmer re-gen after PWDOG1 addition.
 1.1087 06-Aug-2011  jakllsch regen
 1.1086 06-Aug-2011  mbalmer re-gen.
 1.1085 04-Aug-2011  jakllsch regen
 1.1084 23-Jul-2011  matt Regen.
 1.1083 28-Jun-2011  sborrill Regen
 1.1082 27-Jun-2011  nonaka regen.
 1.1081 07-Jun-2011  cegger regen.
 1.1080 06-Jun-2011  msaitoh regen.
 1.1079 28-May-2011  phx branches: 1.1079.2;
regen
 1.1078 28-May-2011  phx regen
 1.1077 28-May-2011  ryo Regen.
 1.1076 27-May-2011  matt Regen.
 1.1075 22-May-2011  mrg regenerate.
 1.1074 21-May-2011  msaitoh regen
 1.1073 20-May-2011  msaitoh regen.
 1.1072 15-May-2011  msaitoh regen.
 1.1071 14-May-2011  martin Regen
 1.1070 13-May-2011  msaitoh regen.
 1.1069 02-May-2011  manu Add support for new SUNIX PCI seriel and/or parallel adapters, with new
SUNIX vendor Id 0x1fd4 and product Id 0x1999. Constants were taken from
Linux open source driver distributed by SUNIX.

The following models should be supported now:
5008 1 parallel port
5016 16 serial ports, only 8 supported right now (PUC_MAX_PORTS limit)
5027 1 serial port
5037 2 serial ports
5056 4 serial ports
5066 8 serial ports, this model is the only one that was actually tested.
5069 1 serial port and 1 parallel port
5079 2 serial ports and 1 parallel port
5099 4 serial ports and 1 parallel port
 1.1068 13-Apr-2011  wiz regen (+ ATI Radeon HD4650)
 1.1067 04-Apr-2011  bouyer Regen: Add RDC PCI-ISA bridge
 1.1066 04-Apr-2011  dyoung Regen.
 1.1065 16-Mar-2011  matt regen.
 1.1064 05-Mar-2011  matt Regen.
 1.1063 25-Feb-2011  jmcneill regen
 1.1062 25-Feb-2011  jmcneill regen
 1.1061 24-Feb-2011  matt Regen.
 1.1060 24-Feb-2011  matt Regen.
 1.1059 23-Feb-2011  jmcneill regen
 1.1058 22-Feb-2011  jmcneill regen
 1.1057 21-Feb-2011  njoly Regen: Add two more Intel 82Q45 devices.
 1.1056 20-Feb-2011  msaitoh regen.
 1.1055 18-Feb-2011  jmcneill regen
 1.1054 03-Feb-2011  njoly Regen for Nvidia devices addition.
 1.1053 26-Jan-2011  bouyer Regen: Add RDC Semiconductor R6040 10/100 Ethernet
 1.1052 11-Jan-2011  dyoung branches: 1.1052.2; 1.1052.4;
Regen.
 1.1051 16-Dec-2010  wiz regen.
 1.1050 11-Dec-2010  matt Regen
 1.1049 11-Nov-2010  cegger regen.
 1.1048 06-Nov-2010  jakllsch regen.
 1.1047 14-Oct-2010  taca Regen.
 1.1046 26-Aug-2010  dogcow Regen for BCM43xx update.
 1.1045 01-Aug-2010  msaitoh regen.
 1.1044 30-Jul-2010  njoly Regen for ICH10 devices update.
 1.1043 29-Jul-2010  njoly Regen for Intel LPC updates.
 1.1042 29-Jul-2010  njoly Regen for Matrox MGA G200eW.
 1.1041 28-Jul-2010  msaitoh regen.
 1.1040 13-Jul-2010  msaitoh regen.
 1.1039 13-Jul-2010  kiyohara Regen.
 1.1038 08-Jul-2010  msaitoh regen.
 1.1037 08-Jul-2010  msaitoh regen
 1.1036 07-Jul-2010  msaitoh regen.
 1.1035 06-Jul-2010  msaitoh regen.
 1.1034 06-Jul-2010  msaitoh regen.
 1.1033 02-Jul-2010  mrg regen.
 1.1032 16-Jun-2010  riz Regen for added Intel IDs.
 1.1031 08-Jun-2010  pgoyette Regen
 1.1030 08-Jun-2010  mrg regenerate
 1.1029 15-May-2010  jakllsch Regen.
 1.1028 12-May-2010  christos regen
 1.1027 10-May-2010  matt Regen.
 1.1026 08-May-2010  pgoyette Regen
 1.1025 07-May-2010  kiyohara Regen.
 1.1024 17-Apr-2010  christos regen
 1.1023 02-Apr-2010  jakllsch regen
 1.1022 14-Mar-2010  mrg branches: 1.1022.2;
regenerate
 1.1021 25-Feb-2010  macallan regen
 1.1020 16-Feb-2010  msaitoh regen.
 1.1019 09-Feb-2010  hubertf regen
 1.1018 09-Feb-2010  msaitoh regen.
 1.1017 08-Feb-2010  msaitoh regen.
 1.1016 03-Feb-2010  macallan branches: 1.1016.2;
regen
 1.1015 30-Jan-2010  jakllsch regen.
 1.1014 24-Jan-2010  msaitoh regen.
 1.1013 22-Jan-2010  hubertf regen - thanks for the reminder @ veego
 1.1012 19-Jan-2010  mbalmer regenerate
 1.1011 14-Jan-2010  sborrill Regen
 1.1010 12-Jan-2010  msaitoh regen
 1.1009 12-Jan-2010  nonaka regen (Added RENESAS SH7780/SH7785 PCI Controller.)
 1.1008 11-Jan-2010  msaitoh regen
 1.1007 07-Jan-2010  msaitoh regen
 1.1006 07-Jan-2010  jdc Regenerate for:
Add Sun Cassini/NS Saturn devices.
 1.1005 03-Jan-2010  jnemeth regen
 1.1004 29-Dec-2009  msaitoh regen
 1.1003 30-Nov-2009  sborrill Regen
 1.1002 21-Nov-2009  jakllsch regen.
 1.1001 18-Nov-2009  bouyer Regen: Complete BROADCOM BCM5709 family, and add BCM5716 family.
 1.1000 18-Nov-2009  jakllsch regen.
 1.999 13-Oct-2009  cegger regen.
 1.998 13-Oct-2009  cegger regen.
 1.997 05-Oct-2009  cegger regen.
 1.996 20-Sep-2009  christos Regen
 1.995 01-Aug-2009  matt Regen.
 1.994 07-Jul-2009  cegger regen.
 1.993 29-Jun-2009  hubertf regen
 1.992 12-Jun-2009  rjs Regen.
 1.991 11-Jun-2009  cegger regen.
 1.990 29-May-2009  skrll Regen.
 1.989 18-May-2009  skrll Regen
 1.988 13-May-2009  cegger regen.
 1.987 09-May-2009  sborrill regen
 1.986 30-Apr-2009  skrll Regen (again)
 1.985 30-Apr-2009  skrll Regen.
 1.984 28-Apr-2009  ginsbach Regen for Mellanox additions.
 1.983 25-Apr-2009  tsutsui Regen from pcidevs rev 1.983:
> Tweak some Realtek re(4) device names.
 1.982 07-Apr-2009  msaitoh regen
 1.981 10-Mar-2009  msaitoh regen
 1.980 26-Feb-2009  mjf Regen.
 1.979 19-Feb-2009  sborrill Regen
 1.978 11-Feb-2009  markd regen
 1.977 06-Feb-2009  jakllsch branches: 1.977.2;
regen.
 1.976 27-Jan-2009  markd regen
 1.975 19-Jan-2009  jmcneill regen for Attansic L1E Gigabit Ethernet Adapter
 1.974 07-Jan-2009  jnemeth regen
 1.973 27-Dec-2008  tsutsui Regen from pcidevs rev 1.971:
> Fix tyop in previous.
 1.972 27-Dec-2008  jnemeth regen for et (Agere) driver
 1.971 21-Dec-2008  nonaka Regen.
 1.970 16-Dec-2008  christos regen
 1.969 29-Nov-2008  christos regen
 1.968 18-Nov-2008  matt Regen.
 1.967 17-Nov-2008  matt Regen.
 1.966 08-Nov-2008  christos regen.
 1.965 04-Nov-2008  cegger regen.
 1.964 04-Nov-2008  cegger regen.
 1.963 15-Oct-2008  bouyer branches: 1.963.2; 1.963.4;
Regen: fix entry description.
 1.962 15-Oct-2008  bouyer Regen: add more ICH9 ethernet devices.
 1.961 01-Oct-2008  christos regen
 1.960 01-Oct-2008  christos ICH10 support from Brad du Plessis
 1.959 28-Sep-2008  bouyer Regen for JMicron Ethernet Controllers.
 1.958 18-Sep-2008  cegger regen.
 1.957 18-Sep-2008  cegger regen.
 1.956 13-Sep-2008  njoly Regen for Nvidia GeForce 6150 devices addition.
 1.955 08-Sep-2008  cegger regen.
 1.954 08-Sep-2008  cegger regen.
 1.953 06-Sep-2008  rmind Regen.
 1.952 05-Sep-2008  cegger regen.
 1.951 27-Aug-2008  christos regen
 1.950 23-Aug-2008  tsutsui Regen from pcidevs rev 1.949:
> - add a Realtek 8139D variant (from FreeBSD)
> - remove a duplicated entry of Realtek 0x8138
 1.949 22-Aug-2008  tnn regen (Intel 945GME)
 1.948 19-Aug-2008  matthias Regen.
 1.947 19-Aug-2008  matthias Regen.
 1.946 06-Aug-2008  dyoung Regen.
 1.945 29-Jul-2008  tron Regen.
 1.944 15-Jul-2008  tonnerre Regen.
 1.943 25-May-2008  chs branches: 1.943.2; 1.943.4;
regen
 1.942 20-May-2008  cegger regen.
 1.941 13-May-2008  rjs Regen.
 1.940 08-May-2008  sborrill Regen
 1.939 30-Apr-2008  joerg branches: 1.939.2;
Regen.
 1.938 17-Apr-2008  christos branches: 1.938.2; 1.938.4;
regen
 1.937 15-Apr-2008  cegger regen.
 1.936 09-Apr-2008  joerg Regen.
 1.935 03-Apr-2008  riz Regen.
 1.934 01-Apr-2008  cegger regen.
 1.933 26-Mar-2008  jmcneill Regen for PR#38301
 1.932 24-Feb-2008  xtraeme regen
 1.931 22-Feb-2008  tsutsui Regen from pcidevs rev 1.930:
> Add I-O DATA RSA-PCI 2 port serial board.
 1.930 13-Feb-2008  tron branches: 1.930.2; 1.930.6;
Regen.
 1.929 10-Feb-2008  ichiro regen
 1.928 05-Feb-2008  ichiro regen
 1.927 11-Jan-2008  tnn regen (add ServeRAID 6/7)
 1.926 11-Jan-2008  ragge Regen
 1.925 03-Jan-2008  jnemeth regen -- Symbios Logic 0x0030 is used for both 53c1020/53c1030 from Dave Huang
 1.924 30-Dec-2007  jdc Regenerate for "Add Apple Shasta GMAC (From FreeBSD)".
 1.923 28-Dec-2007  dholland Regen.
 1.922 24-Dec-2007  hamajima regen.
 1.921 09-Dec-2007  jmcneill branches: 1.921.2;
Merge jmcneill-pm branch.
 1.920 26-Nov-2007  bjs branches: 1.920.2; 1.920.4;
Add PCI IDs for the ATI Radeon X800 GTO (R430). Most sources I have
consulted indicated that this ID is an R430 (including xf86-video-ati).

PCI_PRODUCT_ATI_RADEON_R430_554F (primary)
PCI_PRODUCT_ATI_RADEON_R430_556F (secondary)

vga0 at pci1 dev 0 function 0: ATI Technologies product 0x554f (rev. 0x00)
ATI Technologies product 0x556f (miscellaneous display) at pci1 dev 0 function 1 not configured
 1.919 24-Nov-2007  markd regen.
 1.918 23-Nov-2007  xtraeme regen
 1.917 19-Nov-2007  ad Regen.
 1.916 15-Nov-2007  manu Regen
 1.915 14-Nov-2007  xtraeme regen
 1.914 12-Nov-2007  joerg Regen.
 1.913 30-Oct-2007  xtraeme branches: 1.913.2;
regen
 1.912 30-Oct-2007  xtraeme regen
 1.911 30-Oct-2007  xtraeme regen
 1.910 30-Oct-2007  jnemeth regen
 1.909 24-Oct-2007  xtraeme regen
 1.908 22-Oct-2007  manu Regen
 1.907 22-Oct-2007  manu Add support for Marvell 88CO55. Newer iMacs come with that chip.
 1.906 22-Oct-2007  nisimura regen
 1.905 14-Oct-2007  xtraeme branches: 1.905.2;
regen
 1.904 09-Oct-2007  garbled Add a bunch of IBM PCI dev id's for graphics cards and PCI bridges
 1.903 20-Sep-2007  xtraeme branches: 1.903.2;
regen
 1.902 17-Sep-2007  msaitoh regen
 1.901 11-Sep-2007  jnemeth regen
 1.900 09-Sep-2007  xtraeme regen
 1.899 08-Sep-2007  ober regen. added Intel Pro/Wifi 4965AGN
 1.898 07-Sep-2007  cube Regen.
 1.897 02-Sep-2007  ober regen. added Intel LPC 82801HEM and 82801IO
 1.896 01-Sep-2007  ober *** empty log message ***
 1.895 31-Aug-2007  xtraeme regen
 1.894 30-Aug-2007  xtraeme regen
 1.893 28-Aug-2007  msaitoh regen
 1.892 26-Aug-2007  xtraeme branches: 1.892.2;
regen
 1.891 19-Aug-2007  riz Regen.
 1.890 14-Aug-2007  jnemeth regen
 1.889 11-Aug-2007  jnemeth regem
 1.888 08-Aug-2007  tron Regen.
 1.887 06-Aug-2007  martin branches: 1.887.2;
regen
 1.886 04-Aug-2007  kiyohara Regen.
 1.885 07-Jul-2007  jklos branches: 1.885.2; 1.885.6;
Added Chelsio vendor and various Chelsio hardware.
 1.884 06-Jul-2007  hpeyerl regen
 1.883 27-Jun-2007  xtraeme regen
 1.882 26-Jun-2007  xtraeme regen
 1.881 28-May-2007  mrg regenerate.
 1.880 19-May-2007  tsutsui Regen from pcidevs rev 1.880:
> Add IBM GXT250P video.
 1.879 16-May-2007  mrg regenerate
 1.878 02-May-2007  bouyer Regen: added JMicron Technology products
 1.877 29-Apr-2007  bouyer Regen: remove extra "Intel" from previous commit.
 1.876 29-Apr-2007  bouyer Regen: add Intel i82801H IFE G/GT LAN Controller
 1.875 27-Mar-2007  pooka regen
 1.874 25-Mar-2007  isaki Regen; ATI ES1000.
 1.873 17-Mar-2007  dyoung Regen.
 1.872 10-Mar-2007  christos branches: 1.872.2; 1.872.4;
regen
 1.871 09-Mar-2007  xtraeme branches: 1.871.2;
regen
 1.870 03-Mar-2007  jmcneill Regen.
 1.869 01-Mar-2007  jmcneill Regen.
 1.868 16-Feb-2007  markd branches: 1.868.2;
regen for i965Q
 1.867 10-Feb-2007  mlelstv Get the correct RCS-Id pulled in
 1.866 10-Feb-2007  mlelstv Add support for VT8237A/VT82C586A PCI-ISA-Bridge
Fixes PR kern/35314
 1.865 30-Jan-2007  msaitoh regen
 1.864 28-Jan-2007  chs regen
 1.863 27-Jan-2007  isaki Regen.
 1.862 21-Jan-2007  isaki Regen; AMD Geode LX and CS5536.
 1.861 14-Jan-2007  rpaulo regen
 1.860 06-Jan-2007  jmcneill Regen.
 1.859 04-Jan-2007  jmcneill Regen.
 1.858 04-Jan-2007  jmcneill Regen.
 1.857 31-Dec-2006  ichiro regen
 1.856 10-Dec-2006  bouyer Regen: another PCI id for Dell PERC 5
 1.855 09-Dec-2006  manu Add support for 4 and 8 ports modem boards from Perle systems
 1.854 26-Nov-2006  tsutsui branches: 1.854.2;
Regen from pcidevs rev 1.855:
> - add more Broadcom product IDs, and fix two alternative IDs
> (from FreeBSD and OpenBSD)
> - sort by product ID
 1.853 26-Nov-2006  enami Regen.
 1.852 18-Nov-2006  tsutsui Regen from pcidevs rev 1.853:
> Add an ID of Broadcom BCM5752M. From Matt Kolb on tech-kern.
 1.851 18-Nov-2006  tsutsui Regen from pcidevs rev 1.852:
> - add Realtek RTL8100 (from FreeBSD)
> - fix entry of RTL8169SC
> - remove vague comment in Realtek entry
 1.850 18-Nov-2006  tsutsui Regen from pcidevs rev 1.851:
> Add and note more Realtek Ethernet chips.
 1.849 13-Nov-2006  xtraeme regen
 1.848 13-Nov-2006  bouyer Regen: add NetMos 9855 Quad UART and 1284 Printer port
 1.847 08-Nov-2006  rpaulo regen
 1.846 08-Nov-2006  martti Regenerated.
 1.845 07-Nov-2006  martti Regenerated.
 1.844 03-Nov-2006  abs Regenerate after adding Broadcom BCM5754 (0x167a)
 1.843 31-Oct-2006  manu regen
 1.842 25-Oct-2006  bouyer Regen: Add VIA VT8237A Integrated SATA Controller
 1.841 23-Oct-2006  rjs Regen.
 1.840 21-Oct-2006  bouyer Regen: added some Intel gigabit ethernet products
 1.839 09-Oct-2006  cube Regen.
 1.838 02-Oct-2006  cube Regen (fix pasto).
 1.837 02-Oct-2006  cube Regen (MCP55 ISA brige).
 1.836 29-Sep-2006  cube Regen.
 1.835 27-Sep-2006  cube Regen (Intel/0x1094).
 1.834 27-Sep-2006  sketch Regenerate for TI ACX changes.
 1.833 26-Sep-2006  heas Regen for pcidevs 1.833
 1.832 24-Sep-2006  briggs Regen with new IDs for devices in the last-generation Apple PowerBook G4.
 1.831 07-Sep-2006  riz branches: 1.831.2;
Regen.
 1.830 07-Sep-2006  itohy branches: 1.830.2;
Regen from pcidevs rev 1.830.
 1.829 03-Sep-2006  xtraeme regen
 1.828 03-Sep-2006  xtraeme regen
 1.827 03-Sep-2006  xtraeme regen
 1.826 03-Sep-2006  xtraeme regen
 1.825 03-Sep-2006  xtraeme regen
 1.824 03-Sep-2006  xtraeme regen
 1.823 27-Aug-2006  christos Regen
 1.822 24-Aug-2006  riz Regen (Marvell product IDs)
 1.821 23-Aug-2006  cube Regen (Broadcom NetXtreme II).
 1.820 22-Aug-2006  riz Regen for GALILEO -> MARVELL
 1.819 13-Aug-2006  dsainty Regen: Add the Promise PDC20771, present on the Promise FastTrak TX2300
 1.818 10-Aug-2006  simonb Regen.
 1.817 09-Aug-2006  jnemeth regen for Token Ring additions
 1.816 08-Aug-2006  cube Regen (Intel 63xxESB devices).
 1.815 06-Aug-2006  jmcneill branches: 1.815.2;
Regen.
 1.814 03-Aug-2006  bsh regen
 1.813 01-Aug-2006  xtraeme regen
 1.812 01-Aug-2006  bsh regen
 1.811 30-Jul-2006  jmcneill regen
 1.810 30-Jul-2006  oster Regen
 1.809 30-Jul-2006  simonb Regen.
 1.808 21-Jul-2006  gdamore Regen.
 1.807 21-Jul-2006  gdamore Update ADMtek pci device ids to match data sheets. While here, add the 9513
device (although I've never seen one, I have a datasheet for it. :-)
 1.806 18-Jul-2006  itohy Regen from pcidevs rev 1.807.
 1.805 13-Jul-2006  kent regen for VT82xx HDA
 1.804 07-Jul-2006  simonb Regen.
 1.803 30-Jun-2006  nisimura Regen after Micrel KSZ8842/8841 product addtion.
 1.802 30-Jun-2006  xtraeme regen
 1.801 30-Jun-2006  xtraeme regen
 1.800 27-Jun-2006  kent regen for NVIDA MCP55_HDA
 1.799 26-Jun-2006  xtraeme regen
 1.798 26-Jun-2006  xtraeme regen
 1.797 25-Jun-2006  soren Regen.
 1.796 18-Jun-2006  christos Regen
 1.795 18-Jun-2006  xtraeme regen
 1.794 15-Jun-2006  heinz Regen (LSI SAS, parallel SCSI and FC devices).
 1.793 14-Jun-2006  grant branches: 1.793.2;
regen.
 1.792 06-Jun-2006  rpaulo regen
 1.791 05-Jun-2006  martin Regen (DWL-610 added)
 1.790 05-Jun-2006  msaitoh regen
 1.789 31-May-2006  riz Regen.
 1.788 19-May-2006  markd branches: 1.788.2;
regen
 1.787 30-Apr-2006  xtraeme regen
 1.786 30-Apr-2006  xtraeme regen
 1.785 29-Apr-2006  gdamore Regen.
 1.784 25-Apr-2006  wrstuden Regen to catch change for 3ware cards.
 1.783 20-Apr-2006  gdamore Regen.
 1.782 15-Apr-2006  jmcneill Regen.
 1.781 06-Apr-2006  simonb Regen.
 1.780 05-Apr-2006  nonaka Regen.
 1.779 26-Mar-2006  jonathan Regen pcidevs{,_data}.h from pcidevs rev 1.778 (fixes cut-and-paste typo
in description of bcm5780S).
 1.778 25-Mar-2006  rpaulo regen
 1.777 21-Mar-2006  he Regenerated files after adding IDs for HP/Compaq Smart Array controllers.
 1.776 12-Mar-2006  chs branches: 1.776.2;
regen
 1.775 09-Mar-2006  he Commit regenerated files after adding Nortel Baystack 21 info.
 1.774 09-Mar-2006  hamajima Regen: Add EXAR devices, and fix duplicated NVIDIA product id 0x0057.
 1.773 07-Mar-2006  bouyer Regen: added more serverwork SATA controllers.
 1.772 07-Mar-2006  bouyer branches: 1.772.2;
Regen for serverworks K2 SATA addition.
 1.771 06-Mar-2006  martin Regen (MOXA devices added)
 1.770 01-Mar-2006  dogcow branches: 1.770.2;
add a bunch of Nvidia nForce ethernet IDs (via OpenBSD.)
 1.769 28-Feb-2006  gdamore Regen.
 1.768 21-Feb-2006  chuck regen.
 1.767 16-Feb-2006  kochi regen.
 1.766 12-Feb-2006  tron Regen.
 1.765 12-Feb-2006  tron Regen.
 1.764 12-Feb-2006  tron Regen.
 1.763 07-Feb-2006  cube Regen, correctly this time. Sorry for the mess.
 1.762 07-Feb-2006  xtraeme regen
 1.761 06-Feb-2006  abs regen to add SIS 190 ethernet, as found in ASUS T2-AE1
 1.760 02-Feb-2006  christos branches: 1.760.2;
regen
 1.759 26-Jan-2006  bouyer branches: 1.759.2;
Regen: Add Promise PDC2057x
 1.758 16-Jan-2006  christos regen
 1.757 10-Jan-2006  christos Regen
 1.756 02-Jan-2006  manu regen
 1.755 02-Jan-2006  tron Regen.
 1.754 02-Jan-2006  tron Regen.
 1.753 01-Jan-2006  xtraeme regen
 1.752 29-Dec-2005  silke branches: 1.752.2;
Regen from revision 1.751 of pcidevs.
 1.751 19-Dec-2005  jonathan Regem from src/sys/dev/pci/pcidevs rev 1.750, adding an entry for SK
PCi-Express gigabit ethernet boards based on Marvell's Yukon-2 chipset.
 1.750 19-Dec-2005  jonathan regen after sys/dev/pci/pcidevs 1.749 (addition of SiI 3124)
 1.749 18-Dec-2005  sekiya Regen.
 1.748 11-Dec-2005  jonathan Regen after pcidevs rev 1.746, 1.747 (Add device IDs for LSI Megaraid,
and Intel IDs for software-compatible Intel RAID products).
 1.747 10-Dec-2005  jonathan regen from pcidevs rev.1.745 with IDs for broadcom bcm5714, bcm5715, bcm5780.
 1.746 09-Dec-2005  xtraeme regen
 1.745 08-Dec-2005  xtraeme regen
 1.744 07-Dec-2005  jonathan regen from sys/dev/pci/pcidevs rev 1.742 (add bcm5714 et al.).
 1.743 06-Dec-2005  fvdl Regen for BCM5789.
 1.742 04-Dec-2005  christos Regen.
 1.741 04-Dec-2005  christos Regen.
 1.740 27-Nov-2005  jdolecek regen - 3ware ATA RAID description/ID fixes
 1.739 22-Nov-2005  rpaulo regen
 1.738 18-Nov-2005  rpaulo regen
 1.737 18-Nov-2005  rpaulo regen
 1.736 01-Nov-2005  abs branches: 1.736.2;
Regen after adding Radeon 9000 PCI (0x4966)
 1.735 05-Oct-2005  jonathan branches: 1.735.2;
Regen with PCI ids for Intel pro/1000 PT pci-e gigabit ethernet.
 1.734 04-Sep-2005  tron Regen.
 1.733 21-Aug-2005  chs regen
 1.732 21-Aug-2005  gavan regen
 1.731 30-Jul-2005  grant regen
 1.730 30-Jul-2005  grant regen
 1.729 29-Jul-2005  cube Regen.
 1.728 25-Jul-2005  christos regen.
 1.727 01-Jul-2005  drochner branches: 1.727.2;
regen
 1.726 01-Jul-2005  augustss Regen.
 1.725 28-Jun-2005  thorpej Regen -- static'ify pci_vendors[] and pci_products[]
 1.724 26-Jun-2005  seb Regen.
 1.723 24-Jun-2005  seb Regen.
 1.722 20-Jun-2005  briggs Regen.
 1.721 19-Jun-2005  chs regen
 1.720 15-Jun-2005  bouyer Regen: add Intel 82801FBM Serial ATA Controller.
 1.719 14-Jun-2005  bouyer Regen: add SiS 965.
 1.718 13-Jun-2005  tron Regen.
 1.717 13-Jun-2005  nonaka Regen.
 1.716 13-Jun-2005  nonaka Regen.
 1.715 07-Jun-2005  skrll Regen.
 1.714 28-May-2005  kent regen
 1.713 27-May-2005  augustss Regen.
 1.712 18-May-2005  riz Regen.
 1.711 12-May-2005  cube Regen
 1.710 09-May-2005  martin Regen
 1.709 04-May-2005  cube Regen.
 1.708 02-May-2005  rh regen
 1.707 20-Apr-2005  bouyer Regen for "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller".
 1.706 06-Apr-2005  martti Regen for Dell CERC SATA RAID 1.5/6ch
 1.705 24-Mar-2005  tron Regen.
 1.704 19-Mar-2005  tron Regen.
 1.703 19-Mar-2005  tron Regen.
 1.702 16-Mar-2005  xtraeme branches: 1.702.2;
regen
 1.701 16-Mar-2005  uwe Regen for ATI Radeon 9100 IGP chipset.
 1.700 15-Mar-2005  xtraeme regen
 1.699 15-Mar-2005  xtraeme regen
 1.698 15-Mar-2005  uwe Regen for ENE CB710, CB720 CardBus controllers.
 1.697 07-Mar-2005  christos Regen
 1.696 27-Feb-2005  perry regen
 1.695 20-Feb-2005  jdolecek regen: change the VIATECH VT61XX to VT612X
 1.694 02-Feb-2005  christos Regen
 1.693 02-Feb-2005  abs Regen to pick up corrected code for VIA VT6421
 1.692 01-Feb-2005  abs regen to pick up the 'VT642 SATA RAID Controller'.
 1.691 27-Jan-2005  jdolecek regen: add id for nForce2 Ultra 400 audio
 1.690 27-Jan-2005  kent regenerate for nForce 4 devices
 1.689 25-Jan-2005  matt branches: 1.689.2;
Regen.
 1.688 23-Jan-2005  fredb Regen.
 1.687 18-Jan-2005  tsubai Regen.
 1.686 15-Jan-2005  skrll branches: 1.686.2;
Regen.
 1.685 15-Jan-2005  jdolecek regen: Fix Geforce 6800GT entry
 1.684 15-Jan-2005  jdolecek regen: add bunch of NVIDIA GeForce 6800 devices
 1.683 15-Jan-2005  jdolecek regen: use full 'nForce2 Ultra 400' tag for the NFORCE2_400* enties
 1.682 13-Jan-2005  jdolecek regen: add bunch of NVIDIA nForce2 Ultra 400 chipset devices
 1.681 13-Jan-2005  jdolecek regen: VIA Velocity
 1.680 08-Jan-2005  fredb Regen.
 1.679 08-Jan-2005  ginsbach regen
 1.678 06-Jan-2005  he Regen after adding entry for LSI Logic FC919X.
 1.677 27-Dec-2004  reinoud Update generated files from pcidevs (ENE update)
 1.676 18-Dec-2004  xtraeme regen
 1.675 16-Dec-2004  heas Add entry for the Radeon Mobility T2.
 1.674 11-Dec-2004  reinoud Add ATI IXP audio controllers
 1.673 07-Dec-2004  jdarrow Regen from pcidevs 1.672:
Add a new vendor and product ID for a cardbus NIC I've got
Belkin 0x1799
F5D6020v3 0x6020
 1.672 06-Dec-2004  cube Regen (ATI IXP IDE).
 1.671 05-Dec-2004  bouyer Regen: Cleanup in VIA chipset names. From Lloyd Parkes in kern/15466.
 1.670 30-Nov-2004  grant regen
 1.669 22-Nov-2004  rumble regen
 1.668 19-Nov-2004  tacha regen.
 1.667 17-Nov-2004  jdarrow Regen from pcidevs 1.666 (add two wireless cards)
 1.666 17-Nov-2004  junyoung Regen.
 1.665 16-Nov-2004  skrll Regen
 1.664 14-Nov-2004  soren Regen.
 1.663 06-Nov-2004  xtraeme Regen for:

Add Nvidia nForce3 250 chipset products, from Kouichirou Hiratsuka
in PR 27843.
 1.662 28-Oct-2004  martti Regen for Dell PERC 4/SC
 1.661 26-Oct-2004  augustss Regen.
 1.660 22-Oct-2004  cube Regen.
 1.659 20-Oct-2004  martti Regen for DELL PERC 4e/Si
 1.658 13-Oct-2004  augustss Regen.
 1.657 13-Oct-2004  drochner regen
 1.656 11-Oct-2004  jmmv Regen after addition of ATI Technologies Radeon 9200SE Secondary identifier.
 1.655 05-Oct-2004  augustss Regen.
 1.654 30-Sep-2004  cube Regen.
 1.653 18-Sep-2004  martin Regen (FC929X added)
 1.652 17-Sep-2004  xtraeme Regen for GeForce FX 5700 LE.
 1.651 17-Sep-2004  xtraeme Add GeForceFX 5700 LE and regen.
 1.650 16-Sep-2004  ragge Regen.
 1.649 10-Sep-2004  darrenr Regen'd to add Sierra Wireless AirCard 580
 1.648 26-Aug-2004  itohy Regen from pcidevs rev 1.647.
 1.647 05-Aug-2004  mycroft Regen.
 1.646 05-Aug-2004  cube Regen.
 1.645 04-Aug-2004  mycroft Regen.
 1.644 04-Aug-2004  mycroft Regen.
 1.643 04-Aug-2004  mycroft Regen.
 1.642 02-Aug-2004  mycroft Regen.
 1.641 02-Aug-2004  mycroft Regen.
 1.640 02-Aug-2004  mycroft Regen.
 1.639 02-Aug-2004  mycroft Regen.
 1.638 29-Jul-2004  cube Regen.
 1.637 27-Jul-2004  christos regen
 1.636 27-Jul-2004  rumble regen.
 1.635 25-Jul-2004  christos regen
 1.634 21-Jul-2004  mycroft Regen.
 1.633 17-Jul-2004  mycroft Regen.
 1.632 15-Jul-2004  junyoung Regen for 3c920B-EMB-WNM Integrated Fast Ethernet.
 1.631 05-Jul-2004  mycroft Regen.
 1.630 04-Jul-2004  wiz regen from pcidevs, so that this file has the correct CVS Id.
 1.629 04-Jul-2004  mycroft Update Serverworks chip IDs, per:
http://www.plasma-online.de/english/identify/picture/serverworks.html
This seems remarkably more sane.
 1.628 15-Jun-2004  bouyer Regen for pcidevs 1.628: Add the Netelligent 10/100 TX variant found on the
Compaq Proliant Professional Workstation 5100.
 1.627 27-May-2004  christos Regen
 1.626 27-May-2004  abs regen from pcidevs 1.626: Add ALI 'M5257 PCI Software Modem'
 1.625 12-May-2004  tron Regen for PR kern/25166.
 1.624 11-May-2004  thorpej Regen: Add i6300ESB IDE / SATA controller PCI IDs.
 1.623 10-May-2004  lukem regen for: add Nvidia GeForce4 Ti 4200 Go AGP 8x (0x286)
 1.622 10-May-2004  gendalia regen (Add support for Adaptec AAR 2810SA raid controller.)
 1.621 07-May-2004  sekiya regen.
 1.620 22-Apr-2004  skd regen.
 1.619 17-Apr-2004  matt Regen.
 1.618 03-Apr-2004  martti Added another SB Live! 5.1 soundcard and joystick version
 1.617 03-Apr-2004  mycroft Add RealTek RT8180.
 1.616 01-Apr-2004  tron Regen from "pcidevs".
 1.615 26-Mar-2004  gendalia branches: 1.615.2;
regen for Adaptect 2200S (Vulcan 2M) / Dell PERC 320/DC
 1.614 25-Mar-2004  drochner regen
 1.613 12-Mar-2004  drochner regen
 1.612 03-Mar-2004  gavan Add Creative Labs SB Audigy LS
 1.611 26-Feb-2004  drochner regen
 1.610 28-Jan-2004  chs regen
 1.609 26-Jan-2004  blymn Added note for updating these files.
 1.608 26-Jan-2004  blymn Regen with correct rcs id.
 1.607 26-Jan-2004  blymn Add amd8151 agp bridge id.
 1.606 19-Jan-2004  ragge Err, get correct RCS IDs. As Love said.
 1.605 19-Jan-2004  ragge Add "Intel PRO/10GbE LR Server Adapter". Regen.
 1.604 06-Jan-2004  matt Regen.
 1.603 05-Jan-2004  matt Regen.
 1.602 20-Dec-2003  thorpej Regen: Add product ID for the SiI 3124 SATALink.
 1.601 19-Dec-2003  thorpej Regen: Add product ID for the Silicon Image 3114 SATALink.
 1.600 17-Dec-2003  tls Add support for some more Marvell-based adapters to the sk driver:

D-Link DGE-530T
Linksys EG1032v2
Linksys EG1064v2

The Linux driver treats all of these the same. Tested with a DGE-530T;
it works, though performance on at least one of my systems is atrocious.

Fix setting of ethernet capabilities into interface capabilites word in
attach routine.

Manual page: note that jumbo support doesn't work and checksum support
doesn't exist.
 1.599 14-Dec-2003  tsutsui Regen: added ATI Radeon 9200SE.
 1.598 09-Dec-2003  ad Regen.
 1.597 08-Dec-2003  pooka regen for broadcom 5703a3
 1.596 08-Dec-2003  scw Regen
 1.595 06-Dec-2003  jdolecek regen:
add NetMos NM9805 and NM9815
 1.594 05-Dec-2003  grant regen
 1.593 28-Nov-2003  chs regen
 1.592 28-Nov-2003  cube Regen.
 1.591 26-Nov-2003  matt Regen.
 1.590 22-Nov-2003  fvdl Regenerate after rearranging the Promise ids.
 1.589 03-Nov-2003  cube Regen.
 1.588 25-Oct-2003  chs regen
 1.587 23-Oct-2003  fvdl Regen.
 1.586 23-Oct-2003  briggs Regenerate for ENE Cardbus product IDs.
 1.585 22-Oct-2003  fvdl Regen.
 1.584 18-Oct-2003  matt Regen.
 1.583 18-Oct-2003  lukem regen for more ServerWorks devices
 1.582 15-Oct-2003  itojun regen
 1.581 14-Oct-2003  martti Regen: Dell PERC 4/Di
 1.580 10-Oct-2003  thorpej Regen: Add several more Intel Gig-E product IDs.
 1.579 08-Oct-2003  jonathan Regen from pcidevs rev 1.581 with Hifn 7954/5 and 7956.
 1.578 26-Sep-2003  matt Regen.
 1.577 25-Sep-2003  joda regen
 1.576 21-Sep-2003  nisimura Regen.
 1.575 21-Sep-2003  nisimura Regen to fix the company name.
 1.574 15-Sep-2003  bouyer Regen: rename VT8237_RAID to VT8237_SATA
 1.573 13-Sep-2003  jdolecek regen - fix description of one Intel PRO/100 VM variant, as reported
by Lars Heidieker on current-users@
 1.572 28-Aug-2003  thorpej Regen; spell Hifn correctly, add more Hifn products.
 1.571 27-Aug-2003  kleink Regen.
 1.570 26-Aug-2003  jdolecek regen: add SysKonnect 9821
 1.569 26-Aug-2003  tron Regen.
 1.568 23-Aug-2003  dogcow regen (add VIA VT6105)
 1.567 20-Aug-2003  jonathan regen from pcidevs 1.567 with fix for typo in bcm5823 product-id.
 1.566 17-Aug-2003  chs regen
 1.565 17-Aug-2003  bouyer Regen: Add 3com 3c940 Gigabit Ethernet, and VIA KT600 PCI devices.
 1.564 14-Aug-2003  itojun regen
 1.563 07-Aug-2003  wiz regen (fix ID of Radeon 9100 Secondary)
 1.562 01-Aug-2003  wiz regen (avoid duplicate definition, PR 22331)
 1.561 01-Aug-2003  jonathan regen from pcidevs rev 560 (adding Sun's bcm582x-compatible crypto accelerators)
 1.560 29-Jul-2003  thorpej Regen: Add the product ID used for the i82546EB chips present on the
Intel PRO/1000 MT Quad Port Server Adapter.
 1.559 29-Jul-2003  martin Regen.
 1.558 27-Jul-2003  jonathan regen from pcidevs rev 1.556 with vendor Cavium and product Nitrox.
 1.557 27-Jul-2003  jonathan Regen from pcidevs 1.555 (Bluesteel,Broadcom security coprocessors)
 1.556 23-Jul-2003  kleink Regen from 1.554.
 1.555 17-Jul-2003  hannken Regen.
 1.554 17-Jul-2003  hannken Add support for the BCM5705:
- Only BCM5705M asic rev A1 was tested.

Thanks to Bill Paul (wpaul@freebsd.org) for help and support.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.553 14-Jul-2003  jmmv Regen (+ ATI Radeon 9200)
 1.552 14-Jul-2003  wiz regen (+MGA G550).
 1.551 12-Jul-2003  hubertf Regen for Toshiba SD and SM cards
 1.550 06-Jul-2003  dyoung Add driver atw for PCI/Mini-PCI/Cardbus 802.11b NICs based on the
ADMtek ADM8211. Read the man page for bugs and other outstanding
issues.
 1.549 06-Jul-2003  simonb Regen: Trailing white-space and TABs nits.
 1.548 06-Jul-2003  simonb Regen; E7500 and E7505 updates.
 1.547 06-Jul-2003  tron Regen.
 1.546 06-Jul-2003  simonb Regen: Add an entry for the Intel E7505 Chipset Memory Controller Hub.
 1.545 06-Jul-2003  tron Regen.
 1.544 06-Jul-2003  tron Regen.
 1.543 28-Jun-2003  bouyer branches: 1.543.2;
Regen: some more Intel devices.
 1.542 27-Jun-2003  christos Regen
 1.541 27-Jun-2003  drochner regen
 1.540 26-Jun-2003  ichiro regen.
 1.539 14-Jun-2003  ichiro regen.
 1.538 13-Jun-2003  kent Regen
 1.537 08-Jun-2003  ichiro regen.
 1.536 07-Jun-2003  wiz regen (Add some Brooktree device IDs).
 1.535 07-Jun-2003  wiz regen (+ATI 9100, 9600TX, 9500/9700)
 1.534 07-Jun-2003  ichiro regen.
 1.533 07-Jun-2003  ichiro regen.
 1.532 07-Jun-2003  ichiro regen.
 1.531 28-Apr-2003  haya Regenerate for pcidevs 1.529 and 1.530 changes.
 1.530 24-Apr-2003  nathanw Regen.
 1.529 22-Apr-2003  fvdl Regenerated after AMD 8131 additions.
 1.528 15-Apr-2003  augustss Regen.
 1.527 15-Apr-2003  rjs Regen.
 1.526 13-Apr-2003  explorer typo, s/TX4/TX2/
 1.525 12-Apr-2003  explorer add an older pci id for SATA150TX2PLUS, too
 1.524 12-Apr-2003  christos regen
 1.523 11-Apr-2003  explorer add Promise ATA/150 TX4 id
 1.522 05-Apr-2003  lha Regenerate.
(add Radeon Mobility M7 LW (AGP))
 1.521 03-Apr-2003  kent regen
 1.520 29-Mar-2003  jdc Regenerate.
(Add support for USRobotics Wireless Access PCI adapter (model 132415).)
 1.519 25-Mar-2003  tsubai Regen.
 1.518 20-Mar-2003  thorpej Regen; add more LSI MPT IDs.
 1.517 18-Mar-2003  thorpej Regen; added Silicon Image SATALink 3112.
 1.516 13-Mar-2003  joda regen: more nvidia devices
 1.515 06-Mar-2003  bouyer Regen: Remove duplicate in previous.
 1.514 06-Mar-2003  bouyer Regen: Add several SiS host bridges, from FreeBSD.
 1.513 03-Mar-2003  soren Regen.
 1.512 02-Mar-2003  salo Regen.
 1.511 28-Feb-2003  enami Regen.
 1.510 26-Feb-2003  salo Regen.
 1.509 18-Feb-2003  grant regen
 1.508 03-Feb-2003  pooka regen
 1.507 03-Feb-2003  joda regen
 1.506 02-Feb-2003  bouyer Regen: add SiS 651 host bridge.
 1.505 01-Feb-2003  matt Regen.
 1.504 24-Jan-2003  thorpej Regen; Tweak a Promise description.
 1.503 24-Jan-2003  thorpej Regen; add some more Promise products.
 1.502 24-Jan-2003  thorpej Regen; add Nvidia nForce2 ATA133 IDE.
 1.501 17-Jan-2003  jonathan regen from pcidevs rev 1.497:
Add pcidevs entries for more Broadcom 570x family variants.
 1.500 16-Jan-2003  gendalia regen after pcidevs is committed so the correct version number is embedded.
Thanks to wiz.
 1.499 16-Jan-2003  gendalia Add 3com 3c905CX-TX and Nvidia nForce2 MCP-T ac-97, on the ASUS A7N8X Deluxe
motherboard, Chipset: NVIDIA nForce2 MCP-T
 1.498 10-Jan-2003  augustss Regen.
 1.497 30-Dec-2002  explorer update
 1.496 26-Dec-2002  matt Regen.
 1.495 26-Dec-2002  matt Regen.
 1.494 11-Dec-2002  jdolecek regen: add Madge Networks Smart 16/4 PCI Ringnode Mk2 entry
 1.493 03-Dec-2002  explorer add Ricoh 5C552 Cardbus + Firewire product ID
 1.492 26-Nov-2002  thorpej Regen: Add IBM 133 PCI-X Bridge.
 1.491 26-Nov-2002  thorpej Regen: Add Intel i80321 I/O Processor.
 1.490 19-Nov-2002  bsh Regen. for additional vendor IDs for Samsung Electronics Co. Ltd.
 1.489 15-Nov-2002  tsutsui Regen from pcidevs rev 1.486:
> Remove an entry for AMD PCNETS_PCI.
>
> AMD Am79C974 PCnet-SCSI Ethernet and SCSI conrtoller is
> a multi-function PCI device which has two device IDs
> of Am53C974(PCscsi-PCI) and Am79C970(PCnet-PCI),
> and there is no its own ID.
 1.488 15-Nov-2002  ad Regen.
 1.487 09-Nov-2002  grant regen for ATI Rage Mobility M1.
 1.486 08-Nov-2002  msaitoh regen
 1.485 07-Nov-2002  thorpej Regen; add Intel i31244 Serial ATA controller.
 1.484 07-Nov-2002  martin Regen (Myson MTD804 added)
 1.483 04-Nov-2002  wiz regen (typo fix from PR 18921)
 1.482 25-Oct-2002  kent regen
 1.481 24-Oct-2002  grant regen
 1.480 21-Oct-2002  soren Regen.
 1.479 21-Oct-2002  grant regen
 1.478 18-Oct-2002  yamt regen; fix simple typos
 1.477 16-Oct-2002  leo Regen.
 1.476 05-Oct-2002  kent regen
 1.475 24-Sep-2002  pooka regen
 1.474 20-Sep-2002  pooka regen
 1.473 19-Sep-2002  nathanw Regen.
 1.472 11-Sep-2002  bouyer Regen: add 2 acard pciide controllers.
 1.471 06-Sep-2002  uwe Regen for Integraphics Systems CyberPro 2000 and 2010.
 1.470 23-Aug-2002  bouyer Regen: Add Promise Ultra133TX2 and Ultra133TX2v2 PCI ID
 1.469 16-Aug-2002  heinz regen
 1.468 10-Aug-2002  toshii Regen; added SiS745 host bridge.
 1.467 08-Aug-2002  drochner regen
 1.466 04-Aug-2002  thorpej Regen; added ADI BECC product ID.
 1.465 03-Aug-2002  kent regen
 1.464 02-Aug-2002  soren Regen.
 1.463 02-Aug-2002  ad Regen.
 1.462 31-Jul-2002  bouyer Regen: remove duplicate entry for 82801DB_LPC.
 1.461 30-Jul-2002  bouyer Regen: Add Intel 845G PCI IDs
 1.460 29-Jul-2002  augustss Regen.
 1.459 26-Jul-2002  onoe regen: Add Silicon Image (CMDTECH) 0680
 1.458 22-Jul-2002  msaitoh regen
 1.457 12-Jul-2002  enami Regen.
 1.456 09-Jul-2002  matt Regen.
 1.455 09-Jul-2002  thorpej Regen:
Clean up Intel i8254x product names, and add i82540, i82545, and i82546
product IDs.
 1.454 07-Jul-2002  augustss Regen.
 1.453 05-Jul-2002  enami Regen.
 1.452 04-Jul-2002  rjs Regenerate.
 1.451 03-Jul-2002  msaitoh regen
 1.450 27-Jun-2002  pooka regen
 1.449 26-Jun-2002  cjs Regenerate.
 1.448 26-Jun-2002  cjs Regenerate.
 1.447 22-Jun-2002  fvdl Regenerate.
 1.446 22-Jun-2002  cjs Regenerate.
 1.445 21-Jun-2002  thorpej Regenerate: Add product ID for Intel 82452KX/GX PCI-Host bridge.
 1.444 17-Jun-2002  jdolecek regen:
add VIA Technologies VT8653 and VT8633 entries
move VT82C686A_MC97 entry to where it numerically belongs
 1.443 10-Jun-2002  cjs Regenerate.
 1.442 09-Jun-2002  taca Regen.
 1.441 04-Jun-2002  fvdl Regen.
 1.440 03-Jun-2002  briggs Regen. for MPC8245 host bridge.
 1.439 02-Jun-2002  seb regen for Titan PCI-800L.
 1.438 28-May-2002  christos regen
 1.437 28-May-2002  tron Regen from "pcidevs".
 1.436 27-May-2002  drochner regen
 1.435 25-May-2002  ichiro regen
 1.434 24-May-2002  lukem regen for NetMos Quad UART and 1284 Printer port
 1.433 19-May-2002  bouyer branches: 1.433.2;
Regen: add HPT372 and 74 PCI IDE controllers.
 1.432 19-May-2002  sommerfeld Regen
 1.431 19-May-2002  sommerfeld Regen
 1.430 18-May-2002  matt Regen.
 1.429 15-May-2002  augustss branches: 1.429.2;
Regen.
 1.428 14-May-2002  augustss Regen.
 1.427 03-May-2002  augustss Regen.
 1.426 29-Apr-2002  nonaka Regen. (Added two IBM devices.)
 1.425 26-Apr-2002  ad Regen.
 1.424 18-Apr-2002  thorpej Regen: Added Symbios 53c875A product ID.
 1.423 18-Apr-2002  tshiozak add PCI/USB vendor ID for Kurusugawa Electronics, Inc.
PCI-ID: 0x6809, USB-ID: 0x0b7e.
 1.422 16-Apr-2002  drochner regen
 1.421 15-Apr-2002  mycroft Regen.
 1.420 15-Apr-2002  ad Regen.
 1.419 05-Apr-2002  mycroft Regen.
 1.418 27-Mar-2002  abs Regen for 'CONEXANT 56KFAXMODEM 0x1085 HW 56K Fax Modem'
 1.417 19-Mar-2002  bouyer Regen: add AMD768 devices
 1.416 11-Mar-2002  joda regen
 1.415 01-Mar-2002  kleink Regen: add Motorola Raven, Falcon and Hawk product IDs.
 1.414 28-Feb-2002  junyoung Regen.
 1.413 28-Feb-2002  junyoung Regen; fix for duplicate ATI Rage Pro.
 1.412 27-Feb-2002  martin regen
 1.411 27-Feb-2002  junyoung Regen.
 1.410 24-Feb-2002  kleink Regen: add IBM 82660 PowerPC to PCI Bridge and Memory Controller.
 1.409 21-Feb-2002  simonb regen: Use BCM prefix instead of SB prefix in previous.
 1.408 20-Feb-2002  simonb regen: Add the SiByte/Broadcom SB1250 PCI and LDT bridge IDs.
 1.407 20-Feb-2002  simonb regen: Rename the SIBYTE entry to "Broadcom Corp. (SiByte)".
 1.406 16-Feb-2002  thorpej Regen: Add the Elan SC520 System Controller.
 1.405 04-Feb-2002  junyoung Regen.
 1.404 02-Feb-2002  tsutsui Regen; add Initio INIC-850/1060 SCSI and variants.
 1.403 02-Feb-2002  tsutsui Regen; add HiNT Corp. HB1 PCI-PCI bridge.
 1.402 30-Jan-2002  tron Regen.
 1.401 29-Jan-2002  junyoung Regen.
 1.400 28-Jan-2002  thorpej Regen: Add product ID for the Intel i82544GC 64-bit variant.
 1.399 26-Jan-2002  tron Regen.
 1.398 26-Jan-2002  ichiro regen
 1.397 22-Jan-2002  junyoung Regen.
 1.396 22-Jan-2002  junyoung Regen. Add Mach64 GS.
 1.395 21-Jan-2002  ichiro regen
 1.394 21-Jan-2002  eeh Regen.
 1.393 21-Jan-2002  thorpej Regen; Broadcom BCM570x-related IDs.
 1.392 15-Jan-2002  thorpej Regen; add Intel i82544GC Gig-E.
 1.391 14-Jan-2002  augustss Regen.
 1.390 14-Jan-2002  augustss Regen.
 1.389 13-Jan-2002  augustss Regen.
 1.388 09-Jan-2002  augustss Regen.
 1.387 05-Jan-2002  junyoung Regen.
 1.386 05-Jan-2002  augustss Regen.
 1.385 03-Jan-2002  rafal Regen (added Rainbow Technologies & Rainbow's CryptoSwift 200).
 1.384 01-Jan-2002  augustss Regen.
 1.383 30-Dec-2001  ichiro regen
 1.382 29-Dec-2001  ichiro regen
 1.381 20-Dec-2001  thorpej Regen; added SiS 630 PCI-Host bridge.
 1.380 16-Dec-2001  thorpej Regen:

Add Middle Digital, Inc. vendor ID. Add product IDs for the
Middle Digital PCI-Weasel Virtual VGA, Serial Port, and Control
registers.
 1.379 15-Dec-2001  soren Regen.
 1.378 13-Dec-2001  bouyer Regen: Add some promise controllers, from FreeBSD
 1.377 11-Dec-2001  ad Regen.
 1.376 11-Dec-2001  kleink Regen: add product ID for the Motorola MPC107.
 1.375 07-Dec-2001  onoe Regen: Add HPB and LPC functions of 82801BAM.
 1.374 07-Nov-2001  thorpej Regen; correct i80312 description.
 1.373 07-Nov-2001  thorpej Regen; add Cyclone PCI-700 (IQ80310).
 1.372 25-Oct-2001  augustss Regen.
 1.371 24-Oct-2001  thorpej Regen; Add product IDs for the Powerhouse Systems PowerPro and PowerTop
PowerPC system controllers.
 1.370 24-Oct-2001  thorpej Regen; more Intel Gig-E fixup, and add Intel i82544 IDs.
 1.369 16-Oct-2001  tron branches: 1.369.2;
Regen.
 1.368 13-Oct-2001  ichiro regen.
 1.367 11-Oct-2001  tron Regen.
 1.366 03-Oct-2001  simonb Regen: Minor correction to the name of the 405GP PCI bridge.
 1.365 01-Oct-2001  thorpej Regen; added product ID for RealTek 8139[BC].
 1.364 28-Sep-2001  thorpej Regen; more corrections to Intel Gig-e product IDs.
 1.363 27-Sep-2001  itojun regen
 1.362 15-Sep-2001  chris Regen
 1.361 10-Sep-2001  eeh Regen.
 1.360 05-Sep-2001  drochner branches: 1.360.2;
regen
 1.359 04-Sep-2001  thorpej Regen; added Intel IXP1200 Network Processor.
 1.358 04-Sep-2001  pooka regen.. again.. *sigh*
 1.357 04-Sep-2001  pooka regen
 1.356 30-Aug-2001  soren Regen.
 1.355 28-Aug-2001  tsubai Regen.
 1.354 27-Aug-2001  enami Regen.
 1.353 27-Aug-2001  ad Regen.
 1.352 23-Aug-2001  thorpej Regen; take part numbers out of PCnet-PCI product descriptions.
 1.351 23-Aug-2001  thorpej Regen; Add Promise ATA/100 TX2.
 1.350 20-Aug-2001  fvdl Regen.
 1.349 20-Aug-2001  gehenna Regen
 1.348 18-Aug-2001  thorpej Regen; added Avance Logic ALS4000.
 1.347 17-Aug-2001  matt regen.
 1.346 31-Jul-2001  matt regen
 1.345 28-Jul-2001  pooka regen
 1.344 25-Jul-2001  thorpej Regen; Added Antares Gigabit Ethernet.
 1.343 23-Jul-2001  bouyer Regen for TITAN PCI100H.
 1.342 30-Jun-2001  thorpej branches: 1.342.2;
Regen.
 1.341 28-Jun-2001  thorpej Add Tamarack Microelectronics, Inc. vendor ID, and product ID for
Tamarack TC9021 Gigabit Ethernet.
 1.340 27-Jun-2001  mcr added Solidum PAX.ware 1100 and Lucent ORCA PCI targets
 1.339 20-Jun-2001  thorpej Regen; add/update 3Com 3CR990 products.
 1.338 20-Jun-2001  thorpej Regen; add SysKonnect SKNET-GE.
 1.337 20-Jun-2001  imp Regen.
 1.336 18-Jun-2001  onoe regen: Add Cisco/Aironet 350
 1.335 17-Jun-2001  tsubai Regen.
 1.334 13-Jun-2001  simonb Regen; add IBM 405GP PCI Bridge & ROB-in i960RP Microprocessor.
 1.333 11-Jun-2001  thorpej Regen; Add Level One vendor ID, and LXT-1001 10/100/1000 Ethernet
product ID.
 1.332 11-Jun-2001  tron Regen from "pcidevs".
 1.331 31-May-2001  nisimura Regen; product IDs for IDT RC32334 and RC32332 systeml controllers.
 1.330 21-May-2001  thorpej Regen; add ICH3 network controller IDs.
 1.329 18-May-2001  enami Regen.
 1.328 17-May-2001  drochner regen
 1.327 14-May-2001  thorpej Regen; added DP83820 Gigabit Ethernet chip.
 1.326 06-May-2001  fvdl Regen.
 1.325 25-Apr-2001  simonb Regen.
 1.324 21-Apr-2001  tsutsui Regen from pcidevs rev. 1.318:
> Correct an entry for Acard UDMA IDE controller.
> The chip is actually marked as ATP860-A, not ATP860R.
 1.323 13-Apr-2001  hubertf Regen for moved Trident CyberBlade entry
 1.322 12-Apr-2001  itojun regen.
 1.321 12-Apr-2001  matt Regen.
 1.320 09-Apr-2001  ad Regen.
 1.319 31-Mar-2001  minoura Regen.
 1.318 21-Mar-2001  soren Regen.
 1.317 21-Mar-2001  hubertf regen for trident cyberclade
 1.316 20-Mar-2001  mrg regen
 1.315 17-Mar-2001  thorpej Regen.
 1.314 13-Mar-2001  bouyer Regen.
 1.313 07-Mar-2001  matt Regen.
 1.312 05-Mar-2001  matt branches: 1.312.2;
Regen
 1.311 04-Mar-2001  msaitoh regen
 1.310 02-Mar-2001  thorpej Regen -- Add Mylex AcceleRAID and eXtremeRAID product and subsystem IDs.
 1.309 02-Mar-2001  thorpej Regen; added Xircom WinGlobal modem product ID.
 1.308 18-Feb-2001  bouyer Regen.
 1.307 18-Feb-2001  matt regen
 1.306 12-Feb-2001  tshiozak add CMI8738B.
 1.305 11-Feb-2001  ad Regen.
 1.304 04-Feb-2001  briggs Regen.
 1.303 02-Feb-2001  hubertf Regen: Add M5243 PCI-AGP Bridge
Fixes PR 11466 by Jared D. McNeill <jmcneill@invisible.yi.org>
 1.302 31-Jan-2001  thorpej Regen; add SEGA Dreamcast Broadband Adapter.
 1.301 26-Jan-2001  rh regen
 1.300 26-Jan-2001  rh regen
 1.299 22-Jan-2001  jdolecek regen: US Robotics (3Com) 56K Voice Internal PCI Modem (WinModem) entry added
 1.298 22-Jan-2001  mjl Regen for stallion.
 1.297 17-Jan-2001  thorpej Regen; Intel Gigabit Ethernet update.
 1.296 15-Jan-2001  thorpej Regen.
 1.295 12-Jan-2001  itojun regen
 1.294 09-Jan-2001  rh regen
 1.293 09-Jan-2001  thorpej Regen; added Symbios 53c1510D.
 1.292 08-Jan-2001  thorpej Regen; added Accton EN2242.
 1.291 08-Jan-2001  thorpej Regen; added DEC SWXCR RAID.
 1.290 08-Jan-2001  rh regen
 1.289 03-Jan-2001  mycroft Regen.
 1.288 31-Dec-2000  ad Regen.
 1.287 30-Dec-2000  eeh Regen.
 1.286 29-Dec-2000  eeh Add a bus type for psycho controllers.
 1.285 27-Dec-2000  tsutsui Regen. (Fix Acard UDMA IDE)
 1.284 27-Dec-2000  augustss Regen.
 1.283 23-Dec-2000  tsutsui Regen. (Adding Acard UDMA IDE controllers)
 1.282 14-Dec-2000  onoe regen
 1.281 05-Dec-2000  drochner regen
 1.280 20-Nov-2000  onoe regen.
CXD32222 -> CXD3222 (Sony OHCI Controller)
 1.279 18-Nov-2000  thorpej Regen.
 1.278 14-Nov-2000  bouyer Regen.
 1.277 04-Nov-2000  thorpej Regen.
 1.276 03-Nov-2000  ad regen.
 1.275 03-Nov-2000  ad Regen.
 1.274 27-Oct-2000  thorpej Regen.
 1.273 27-Oct-2000  thorpej Regen.
 1.272 19-Oct-2000  thorpej Regen.
 1.271 14-Oct-2000  simonb Regen
 1.270 12-Oct-2000  itojun regen
 1.269 03-Oct-2000  thorpej Regen: ADMtek AN985
 1.268 27-Sep-2000  augustss Regen.
 1.267 20-Sep-2000  thorpej Regen.
 1.266 19-Sep-2000  fvdl Regen.
 1.265 13-Sep-2000  ad Regen.
 1.264 13-Sep-2000  tron Regen.
 1.263 13-Sep-2000  tron Regen.
 1.262 13-Sep-2000  tron Regen.
 1.261 07-Sep-2000  soren Regen.
 1.260 04-Sep-2000  soren Regen.
 1.259 04-Sep-2000  itojun regen
 1.258 02-Sep-2000  cgd regen for changed pcidevs
 1.257 29-Aug-2000  wiz regen
 1.256 21-Aug-2000  enami Regen.
 1.255 21-Aug-2000  haya Regen.
 1.254 07-Aug-2000  billc Manually edit the headers to show which version of pcidevs this was
generated from.

XXX - this really should be automated
 1.253 07-Aug-2000  billc Added PCI IDs for 3Com's Home Connect (3c450) and Office Connect (3cSOHO100).
They both are register compat with later versions of the 3c905 (tornado/
vortex) series.
 1.252 04-Aug-2000  ad Regen.
 1.251 23-Jul-2000  jonathan * Add entries for older Yamaha YMF chips (724, 740) plus the
newer steppings (740C, 724F) which use the same microcode as the
DS-1S/DS-1E.
Regen.
 1.250 20-Jul-2000  ad Regen.
 1.249 10-Jul-2000  ad Regen.
 1.248 09-Jul-2000  mycroft Regen.
 1.247 08-Jul-2000  mrg regen
 1.246 04-Jul-2000  enami Regen.
 1.245 03-Jul-2000  gmcgarry Regen.
 1.244 24-Jun-2000  joda regen
 1.243 21-Jun-2000  tron Regen.
 1.242 16-Jun-2000  soren branches: 1.242.2;
Regen.
 1.241 13-Jun-2000  tron Regen.
 1.240 12-Jun-2000  nathanw Regen.
 1.239 12-Jun-2000  bouyer Regen.
 1.238 12-Jun-2000  bouyer Regen.
 1.237 09-Jun-2000  augustss Regen.
 1.236 07-Jun-2000  ad Regen.
 1.235 07-Jun-2000  mrg regen.
 1.234 07-Jun-2000  soren Regen.
 1.233 06-Jun-2000  kleink Regen.
 1.232 05-Jun-2000  kleink Regen.
 1.231 05-Jun-2000  kleink Regen.
 1.230 30-May-2000  matt Regen
 1.229 28-May-2000  drochner regen
 1.228 27-May-2000  scw Regen.
 1.227 27-May-2000  soren branches: 1.227.2;
Regen.
 1.226 26-May-2000  matt Regen.
 1.225 18-May-2000  drochner regen
 1.224 18-May-2000  garbled regen
 1.223 14-May-2000  soren Regen.
 1.222 12-May-2000  thorpej Regen.
 1.221 07-May-2000  jonathan PCI product codes for Yamaha YMF744B (DS-1S) YMF754 (DS-1E) audio chips.
 1.220 30-Apr-2000  dante Add ASB-3940U3W host adapters (AdvanSys)
 1.219 28-Apr-2000  augustss Regen.
 1.218 26-Apr-2000  thorpej Regen.
 1.217 22-Apr-2000  augustss Regen.
 1.216 19-Apr-2000  bouyer Regen
 1.215 18-Apr-2000  cgd regen for changed pcidevs
 1.214 17-Apr-2000  thorpej Regen.
 1.213 03-Apr-2000  joda regen
 1.212 31-Mar-2000  tsarna Add auvia, a driver for the integrated AC'97 audio on the VIA VT82C686A
southbridge.

Tested on a ASUS K7M (w/ AD1881 codec). Please report any problems.
 1.211 30-Mar-2000  joda regen
 1.210 27-Mar-2000  ad Regen.
 1.209 23-Mar-2000  joda regen
 1.208 23-Mar-2000  ad Regen.
 1.207 21-Mar-2000  joda regen
 1.206 16-Mar-2000  thorpej Regen.
 1.205 14-Mar-2000  tsarna Regen
 1.204 13-Mar-2000  ad Regen.
 1.203 11-Mar-2000  jdolecek regen
 1.202 09-Mar-2000  jdolecek regen
 1.201 06-Mar-2000  mark Regenerate from pcidevs.
 1.200 04-Mar-2000  tron Regen from "pcidevs".
 1.199 16-Feb-2000  soren Regen.
 1.198 08-Feb-2000  bouyer regen
 1.197 03-Feb-2000  dante Add AdvanSys U2W host adapters
 1.196 03-Feb-2000  joda regen
 1.195 31-Jan-2000  thorpej Regen.
 1.194 25-Jan-2000  haya Regen.
 1.193 24-Jan-2000  joda regen
 1.192 23-Jan-2000  tsubai Regen.
 1.191 12-Jan-2000  haya Regen.
 1.190 11-Jan-2000  matt Regen.
 1.189 09-Jan-2000  soren Regen.
 1.188 05-Jan-2000  drochner regen
 1.187 31-Dec-1999  hubertf Add an entry for the Trident Microsystems CYBER 9525
(as found in an Toshiba Satellite 2650 XDVD).
 1.186 17-Dec-1999  drochner regen
 1.185 17-Dec-1999  augustss Regen.
 1.184 17-Dec-1999  soren Regen.
 1.183 17-Dec-1999  soren Regen.
 1.182 15-Dec-1999  kleink Regen.
 1.181 04-Dec-1999  castor Regen
 1.180 04-Dec-1999  thorpej Regen.
 1.179 01-Dec-1999  drochner regen
 1.178 30-Nov-1999  drochner regen
 1.177 17-Nov-1999  augustss Regen.
 1.176 12-Nov-1999  is Identification of DOMEX PCI-SCSI board, by Thilo Manske, PR 8772.
 1.175 07-Nov-1999  cgd regen
 1.174 06-Nov-1999  rh regen.
 1.173 06-Nov-1999  augustss Regen.
 1.172 04-Nov-1999  tsarna regen
 1.171 04-Nov-1999  augustss Regen.
 1.170 04-Nov-1999  joda regen
 1.169 01-Nov-1999  augustss Regen.
 1.168 29-Oct-1999  matt Regen.
 1.167 29-Oct-1999  haya Maintainance the name of Ricoh PCI-CardBus bridges.
 1.166 11-Oct-1999  hannken branches: 1.166.2; 1.166.4;
Regen.
 1.165 29-Sep-1999  thorpej branches: 1.165.2;
Regen.
 1.164 29-Sep-1999  thorpej Regen.
 1.163 27-Sep-1999  ad Regen.
 1.162 11-Sep-1999  soren Regen.
 1.161 10-Sep-1999  augustss Regen.
 1.160 08-Sep-1999  thorpej Regen.
 1.159 08-Sep-1999  thorpej Regen.
 1.158 08-Sep-1999  thorpej Regen.
 1.157 01-Sep-1999  drochner regen
 1.156 28-Aug-1999  augustss Regen.
 1.155 27-Aug-1999  thorpej Regen.
 1.154 24-Aug-1999  soren Regenerate.
 1.153 17-Aug-1999  drochner regen
 1.152 16-Aug-1999  mcr Added Solidum Systems PCI vendor ID and Device IDs
 1.151 12-Aug-1999  bouyer Regen.
 1.150 01-Aug-1999  veego Regen.
 1.149 29-Jul-1999  thorpej Regen.
 1.148 28-Jul-1999  soren Regen.
 1.147 27-Jul-1999  castor regen
 1.146 27-Jul-1999  thorpej Regen.
 1.145 20-Jul-1999  drochner regen
 1.144 15-Jul-1999  ross Regen.
 1.143 15-Jul-1999  augustss Regen.
 1.142 14-Jul-1999  fvdl Regen.
 1.141 12-Jul-1999  kleink Regen.
 1.140 01-Jul-1999  itojun IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
 1.139 27-Jun-1999  drochner regen
 1.138 19-Jun-1999  augustss Regen.
 1.137 18-Jun-1999  tsubai Regen.
 1.136 05-Jun-1999  tron Regen.
 1.135 05-Jun-1999  tron Regen.
 1.134 02-Jun-1999  drochner regen
 1.133 29-May-1999  mrg regen.
 1.132 29-May-1999  mrg regen.
 1.131 29-May-1999  fvdl Regen.
 1.130 27-May-1999  mrg regen.
 1.129 23-May-1999  veego Regen.
 1.128 20-May-1999  augustss Regen.
 1.127 17-May-1999  drochner regen
 1.126 07-May-1999  hwr Regen.
 1.125 07-May-1999  hwr Regen.
 1.124 07-May-1999  drochner regen
 1.123 07-May-1999  matt Regen
 1.122 06-May-1999  mrg regen
 1.121 12-Apr-1999  jonathan Add entries for TI, Ricoh, Toshiba PCI-to-cardbus bridge chips, so
we can identify them as cardbus chips supported by the cardbus patches.

Add entry for OPTI chipsets whose interrupts arent properly set up by
some BIOSes.

From cardbus patches<ftp://nandra.iri.co.jp/pub/NetBSD/CardBus by
HAYAKAWA Koichi <haya@tcad.ulsi.sony.co.jp>.
 1.120 25-Mar-1999  explorer branches: 1.120.2;
Add LAN Media Corporation info
 1.119 19-Mar-1999  mycroft Regen.
 1.118 17-Mar-1999  thorpej Regen.
 1.117 16-Mar-1999  tron Regen from "pcidevs".
 1.116 16-Mar-1999  mjacob add Qlogic 1080 && 1240 product IDs
 1.115 11-Mar-1999  sakamoto Regen.
 1.114 09-Mar-1999  drochner regen
 1.113 19-Feb-1999  thorpej Regen.
 1.112 19-Feb-1999  thorpej Regen.
 1.111 19-Feb-1999  thorpej Regen.
 1.110 14-Feb-1999  tron Regen from pcidevs.
 1.109 05-Feb-1999  thorpej Regen.
 1.108 28-Jan-1999  augustss Regen.
 1.107 16-Jan-1999  drochner regen
 1.106 30-Dec-1998  hwr Regen
 1.105 21-Dec-1998  drochner regen
 1.104 20-Dec-1998  drochner regen
 1.103 18-Dec-1998  thorpej Regen.
 1.102 09-Dec-1998  thorpej Regen.
 1.101 05-Dec-1998  matt Add Sigma Designs REALmagic Hollywood Plus MPEG-2 decoder
 1.100 30-Nov-1998  jtk regen
 1.99 29-Nov-1998  thorpej Regen.
 1.98 29-Nov-1998  thorpej Regen.
 1.97 27-Nov-1998  drochner regen
 1.96 26-Nov-1998  mcr regenerated pcidevs.h and pcidevs_data.h due to kern/6280
(not kern/5847 as originally noted)
 1.95 20-Oct-1998  thorpej Regen.
 1.94 19-Oct-1998  bouyer Regen.
 1.93 05-Oct-1998  tron Regen.
 1.92 04-Oct-1998  tron Regen.
 1.91 01-Oct-1998  fvdl Regen.
 1.90 26-Sep-1998  dante Change product ADVSYS 2300 to ADVSYS WIDE
 1.89 22-Sep-1998  mark Regenerate from pcidevs.
 1.88 18-Sep-1998  drochner regen
 1.87 18-Sep-1998  mark Regen.
 1.86 06-Sep-1998  veego Regen.
 1.85 26-Aug-1998  drochner regen
 1.84 26-Aug-1998  dante Changed ADVSYSPROD to ADVSYS vendor ID
Added 1200A, 1200B, ULTRA, 2300 AdvanSys products ID
 1.83 07-Aug-1998  thorpej Regen.
 1.82 28-Jul-1998  thorpej Regen.
 1.81 27-Jul-1998  tron Regen from pcidevs.
 1.80 27-Jul-1998  tron Regen from pcidevs.
 1.79 27-Jul-1998  augustss Regen.
 1.78 25-Jul-1998  explorer commit this so it gets the right generated from tag
 1.77 25-Jul-1998  explorer define RISCom and RISCom N2 product
 1.76 22-Jul-1998  drochner regen
 1.75 19-Jul-1998  tron Regen from pcidevs.
 1.74 13-Jul-1998  mark Regen.
 1.73 10-Jul-1998  tron Regen from pcidevs.
 1.72 30-Jun-1998  augustss Regen.
 1.71 15-Jun-1998  bouyer Regen.
 1.70 15-Jun-1998  bouyer Regen.
 1.69 15-Jun-1998  bouyer Regen.
 1.68 25-May-1998  mark Regen from pcidevs.
 1.67 14-May-1998  augustss Regen.
 1.66 13-May-1998  augustss Regen.
 1.65 05-May-1998  thorpej Regen.
 1.64 04-May-1998  thorpej Regen.
 1.63 30-Apr-1998  mycroft Regen.
 1.62 16-Apr-1998  drochner regen
 1.61 28-Mar-1998  thorpej Regen.
 1.60 28-Mar-1998  cgd regen
 1.59 07-Mar-1998  augustss Regen.
 1.58 04-Mar-1998  cgd regen
 1.57 04-Mar-1998  cgd regen
 1.56 27-Feb-1998  mycroft Regen.
 1.55 07-Feb-1998  augustss Newly generated version.
 1.54 07-Feb-1998  augustss Add the AGP device in the 82443LX.
 1.53 27-Jan-1998  thorpej Regen: add Packet Engines G-NIC gigabit Ethernet.
 1.52 22-Jan-1998  mycroft Regen.
 1.51 09-Jan-1998  thorpej Regen.
 1.50 08-Jan-1998  thorpej Regen: back out RCS ID related changes.
 1.49 05-Jan-1998  perry regened with RCSIDs in place
 1.48 16-Nov-1997  christos Regen.
 1.47 27-Oct-1997  thorpej Regen.
 1.46 14-Oct-1997  thorpej branches: 1.46.2;
Regen.
 1.45 08-Oct-1997  mycroft Regen.
 1.44 06-Oct-1997  lonhyn pcidevs change regen.
 1.43 01-Oct-1997  drochner regen
 1.42 23-Sep-1997  mycroft Regen.
 1.41 15-Sep-1997  bouyer Regen.
 1.40 12-Sep-1997  drochner regen
 1.39 28-Aug-1997  thorpej Regen: added SMC83C170 entry.
 1.38 23-Aug-1997  drochner regen
 1.37 16-Aug-1997  mjacob Add in PCI_PRODUCT_QLOGIC_ISP2100.
 1.36 14-Aug-1997  drochner Regen with new RCS ID. (thanks, Bernd)
 1.35 14-Aug-1997  drochner Include some more stuff.
 1.34 03-Aug-1997  fvdl Regen.
 1.33 19-Jul-1997  cgd branches: 1.33.2;
regen for new pcidevs
 1.32 24-Jun-1997  thorpej Correct Intel Triton MX PCI IDs, from Tom Yu <tlyu@mit.edu>, PR #3478.
 1.31 24-Jun-1997  kml Added definitions for Essential Communications RoadRunner HIPPI and
Gigabit Ethernet interfaces.
 1.30 13-May-1997  jtk regen
 1.29 04-Apr-1997  augustss Regen.
 1.28 20-Mar-1997  chuck regen
 1.27 16-Feb-1997  veego regen.
 1.26 01-Jan-1997  veego branches: 1.26.4;
Add the Matrox Millenium and regen the header files.
 1.25 30-Nov-1996  jtk forgot to regenerate these after committing pcidevs for its NetBSD header tag
 1.24 28-Nov-1996  jtk add Cirrus CL-7541, 7543 and ACC 2188; regen .h files
 1.23 28-Nov-1996  thorpej Regen.
 1.22 19-Oct-1996  jonathan regen from pcidevs 1.20
 1.21 15-Oct-1996  christos regen
 1.20 13-Oct-1996  christos regen
 1.19 08-Oct-1996  gibbs dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.

Regen microcode header file.

dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.

Fix a problem with handing the QUEUE FULL condition.

Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.

Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.

dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.

dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.

Regen data file.

scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.

Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
 1.18 24-Sep-1996  christos New cyclades driver from Timo Rossi.
 1.17 29-Aug-1996  cgd regen for new pcidevs
 1.16 26-Aug-1996  cgd regen for new pcidevs
 1.15 23-Aug-1996  cgd regen for new pcidevs
 1.14 15-Jul-1996  cgd regen for updated pcidevs
 1.13 22-Jun-1996  chuck regenerate to fix "generated from" comment
(next commit pcidevs first, then regenerate)
 1.12 22-Jun-1996  chuck add product code for efficient networks eni155p atm card and regenerate
 1.11 16-May-1996  mycroft branches: 1.11.4;
Regen.
 1.10 13-May-1996  thorpej Regenerate.
 1.9 07-May-1996  thorpej Regenerate; pcidevs changed.
 1.8 04-Apr-1996  mycroft Regen.
 1.7 19-Feb-1996  christos pcidevs was changed.
 1.6 31-Jan-1996  cgd update for new version of 'pcidevs'
 1.5 22-Jan-1996  cgd update PCIVERBOSE code in various ways:
(1) remove the 'UNSUPP' keyword from the device list,
because it can't be reasonably used (becuase different
devices may be supported on different machines, for
good reason).
(2) enhance pci_devinfo so that class/subclass information
is optional (so pci_devinfo can be used by drivers that
match classes of devices, and want to look up the
devices' names easily).
(3) more known vendors and devices.
 1.4 10-Nov-1995  christos pcidevs was changed
 1.3 10-Nov-1995  christos - pcidevs: add 3c590 and adaptec ultra
- aic7xxx.c: fix the probe routines to use pcidevs.h
 1.2 20-Jun-1995  cgd vendor IDs for Acer and SIS
 1.1 18-Jun-1995  cgd built from pcidevs list
 1.11.4.1 04-Mar-1997  mycroft Regen.
 1.26.4.1 12-Mar-1997  is Merge in changes from The Trunk
 1.33.2.9 14-Oct-1997  thorpej Sync w/ trunk.
 1.33.2.8 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.7 14-Oct-1997  thorpej Regen.
 1.33.2.6 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.5 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.4 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.3 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.46.2.2 17-Nov-1997  thorpej Regen.
 1.46.2.1 27-Oct-1997  thorpej Regen.
 1.120.2.13 11-Sep-2000  he Pull up regenerated files (requested by billc):
Recognize 3Com's Home Connect (3c450) and Office Connect (3cSOHO100)
Ethernet cards.
 1.120.2.12 23-Jul-2000  he Pull up regenerated files (requested by jonathan):
Add product codes for various Yamaha audio chips.
 1.120.2.11 07-Jul-2000  he Pull up regenerated files (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
 1.120.2.10 03-Jun-2000  he Pull up regenerated files (requested by tsubai):
Add support for PCI variants of Cyclom-4Y and -8Y cards.
Also fixes PR#7175 (new serial controller).
 1.120.2.9 22-May-2000  he Pull up regenerated files (requested by bouyer):
Add product IDs for some VIA Technologies devices.
 1.120.2.8 10-Feb-2000  he Pull up regenerated file (requeste by bouyer):
Add support for US Robotics 3CP5609 PCI 16550 Modem.
 1.120.2.7 15-Jan-2000  he Regenerate after fixing DPT SCSI boards description.
 1.120.2.6 20-Oct-1999  he Regenerate these after adding Realtek to pcidevs.
 1.120.2.5 05-Oct-1999  he Regenerate these from recent pcidevs pullup.
 1.120.2.4 24-Sep-1999  cgd regenerate _after_ pcidevs is checked in
 1.120.2.3 29-Aug-1999  he Regenerated.
Recognize 3c905C-TX card. (bouyer)
 1.120.2.2 22-Jun-1999  perry regen (fvdl): recognize another 390xB card
 1.120.2.1 13-Apr-1999  jonathan branches: 1.120.2.1.2; 1.120.2.1.4;
Pull up sys/dev/pci/pcidevs 1.113->1.114 (CardBus bridge chips) to 1.4.
pcidevs.h, pcidevs_data.h: regen.
 1.120.2.1.4.2 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.120.2.1.4.1 28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.120.2.1.2.3 02-Aug-1999  thorpej Regen.
 1.120.2.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.120.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.165.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.166.4.1 15-Nov-1999  fvdl Sync with -current
 1.166.2.10 23-Apr-2001  bouyer Sync with HEAD.
 1.166.2.9 21-Apr-2001  bouyer Sync with HEAD
 1.166.2.8 27-Mar-2001  bouyer Sync with HEAD.
 1.166.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.166.2.6 11-Feb-2001  bouyer Sync with HEAD.
 1.166.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.166.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.166.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.166.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.166.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.227.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.242.2.27 07-Apr-2004  jmc Regen (requested by itojun in ticket #71)

Add National Semiconductors SC1100 (GEODE) PCI devices
 1.242.2.26 06-Jun-2002  he Pull up regenerated files (requested by mycroft):
Add Intel ICH3 network controller IDs. Part of fix to fxp driver to
work around a bug which can cause some machines to randomly hang, and to
drag along performance improvements and improved hardware support.
 1.242.2.25 25-Mar-2002  he Pull up regenerated files (requested by bouyer):
Add support for the pciide part of the AMD-768 chipset.
 1.242.2.24 06-Feb-2002  he Pull up regenerated files (requested by tsutsui):
Add support for Acard ATP-850/860 pciide controllers.
 1.242.2.23 29-Jan-2002  he Pull up regenerated files (requested by bouyer):
Add support for the 53c1010-33, and bring documentation up to
date.
 1.242.2.22 24-Jan-2002  he Pull up regenerated files (requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.242.2.21 25-Oct-2001  he Pull up regenerated files (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.242.2.20 18-Jun-2001  jhawk Pull up regenerated files (requested by tsubai):
Support the new dual USB iBook.
 1.242.2.19 11-Jun-2001  he Pull up regenerated files (requested by tron):
Support the D-Link DFE-530TX+. Fixes PR#13161.
 1.242.2.18 15-May-2001  he Pull up regenerated files (requested by bouyer):
Add support for newer VIA pciide controllers.
Add support for the AMD 766 pciide controller.
Properly distinguish between HPT366 and HPT370 controllers.
 1.242.2.17 06-May-2001  he Pull up regenerated files (requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.242.2.16 03-May-2001  he Pull up regenerated files (requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.242.2.15 23-Apr-2001  he Pull up regenerated files (requested by hubertf):
Support Accton EN2242 and other AmdTek AN985 compatible cards
with the tlp(4) driver.
 1.242.2.14 22-Mar-2001  he Pull up regenerated files (requested by hubertf):
Make the Intel Pro/100 as e.g. found on Toshiba Satellite Pro
4600s work.
 1.242.2.13 20-Mar-2001  he Pull up regenerated files (requested by chuck):
Add support for the 3Com 3c555, 3c556 and 3c556B MiniPCI Ethernet
cards.
 1.242.2.12 26-Feb-2001  he Pull up regenerated files (requested by bouyer):
Add support for the Intel 82801BAM IDE controller.
 1.242.2.11 31-Dec-2000  jhawk Regen.
 1.242.2.10 30-Oct-2000  tv Regen.
 1.242.2.9 19-Oct-2000  he Pull up regenerated files (requested by billc):
Add PCI IDs for 3Com Home Connect (3c450) and Office Connect
(3cSOHO100), register compatible with later versions of 3c905.
 1.242.2.8 21-Sep-2000  thorpej Regen: Add National Semiconductor DP83815 10/100 Ethernet.
 1.242.2.7 13-Sep-2000  tron Regen.
 1.242.2.6 22-Aug-2000  enami Regen.
 1.242.2.5 23-Jul-2000  jonathan Pull up pcidevs.h rev 1.251 and pcidevs_data.h rev 249, by pulling
up pcidevs rev 1.245 (YMF 7xx audio product codes), then regen.
 1.242.2.4 16-Jul-2000  jhawk Pullup pcidevs rev 1.242 and regen pcidevs_data.h, pcidevs.h, approved by
jhawk:
Add ID for i82559ER.
 1.242.2.3 06-Jul-2000  enami Regen.
 1.242.2.2 27-Jun-2000  thorpej Regen.
 1.242.2.1 26-Jun-2000  bouyer Regen.
 1.312.2.29 17-Jan-2003  thorpej Sync with HEAD.
 1.312.2.28 15-Jan-2003  thorpej Sync with HEAD.
 1.312.2.27 03-Jan-2003  thorpej Sync with HEAD.
 1.312.2.26 29-Dec-2002  thorpej Sync with HEAD.
 1.312.2.25 19-Dec-2002  thorpej Sync with HEAD.
 1.312.2.24 11-Dec-2002  thorpej Sync with HEAD.
 1.312.2.23 26-Nov-2002  thorpej Sync with HEAD.
 1.312.2.22 11-Nov-2002  nathanw Catch up to -current
 1.312.2.21 18-Oct-2002  nathanw Catch up to -current.
 1.312.2.20 17-Sep-2002  nathanw Catch up to -current.
 1.312.2.19 27-Aug-2002  nathanw Catch up to -current.
 1.312.2.18 13-Aug-2002  nathanw Catch up to -current.
 1.312.2.17 01-Aug-2002  nathanw Catch up to -current.
 1.312.2.16 20-Jun-2002  nathanw Catch up to -current.
 1.312.2.15 17-Apr-2002  nathanw Catch up to -current.
 1.312.2.14 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.312.2.13 28-Feb-2002  nathanw Regen.
 1.312.2.12 28-Feb-2002  nathanw Regen.
 1.312.2.11 28-Feb-2002  nathanw Catch up to -current.
 1.312.2.10 11-Jan-2002  nathanw More catchup.
 1.312.2.9 08-Jan-2002  nathanw Catch up to -current.
 1.312.2.8 14-Nov-2001  nathanw Catch up to -current.
 1.312.2.7 22-Oct-2001  nathanw Catch up to -current.
 1.312.2.6 08-Oct-2001  nathanw Catch up to -current.
 1.312.2.5 21-Sep-2001  nathanw Catch up to -current.
 1.312.2.4 24-Aug-2001  nathanw Catch up with -current.
 1.312.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.312.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.312.2.1 05-Mar-2001  nathanw file pcidevs.h was added on branch nathanw_sa on 2001-04-09 01:57:05 +0000
 1.342.2.9 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.342.2.8 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.342.2.7 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.342.2.6 16-Mar-2002  jdolecek Catch up with -current.
 1.342.2.5 11-Feb-2002  jdolecek Sync w/ -current.
 1.342.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.342.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.342.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.342.2.1 03-Aug-2001  lukem update to -current
 1.360.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.360.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.369.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.429.2.4 29-Aug-2002  gehenna catch up with -current.
 1.429.2.3 15-Jul-2002  gehenna catch up with -current.
 1.429.2.2 20-Jun-2002  gehenna catch up with -current.
 1.429.2.1 30-May-2002  gehenna Catch up with -current.
 1.433.2.36 26-Oct-2005  jmc regen
 1.433.2.35 01-Jun-2005  riz Regen for ticket 5721.
 1.433.2.34 01-May-2005  tron Regen for ticket 5756.
 1.433.2.33 19-Mar-2005  tron Regen for ticket 1755.
 1.433.2.32 11-Nov-2004  he Pull up regenerated files (requested by itohy in ticket #1741):
Add support for the Workbit NinjaSCSI-32 PCI/Cardbus
SCSI driver, njs(4).
 1.433.2.31 12-Jul-2004  he Pull up regenerated files (requested by grant in ticket #1720):
Add support for SATALink 3112.
 1.433.2.30 22-Jun-2004  tron Regen for ticket #1718.
 1.433.2.29 06-Apr-2004  jmc Regen (requested by briggs in ticket #1648)

Pull in changes to support the Intel 82801EB/ER (ICH5) Controller. PR#25002
 1.433.2.28 28-Mar-2004  jmc Regen for ticket #1631
 1.433.2.27 15-Mar-2004  jmc Regen for ticket #1612
 1.433.2.26 20-Oct-2003  cyber Pull up revision 1.569 (requested by tron in ticket #1440):
Add entry for Intel i865G Integrated Graphics Device.
 1.433.2.25 10-Sep-2003  grant Regenerate (requested by tron in ticket #1417):

Correct names and descriptions for i875 entries to be consistent with
other Intel chipsets.
 1.433.2.24 15-Aug-2003  tron Regen.
 1.433.2.23 10-Jul-2003  tron Regen for ticket #1365.
 1.433.2.22 30-Jun-2003  grant Regen (requested by drochner in ticket #1343):

add Intel PRO/100M.
 1.433.2.21 19-Jun-2003  grant Regen (requested by hamajima in ticket #1323):

Support the PowerBook G4 12-inch (and maybe 17-inch).
Kauai ATA, new obio chip, and Japanese keymap for WSDISPLAY_COMPAT_RAWKBD
 1.433.2.20 16-Jun-2003  grant Regenerate (requested by bouyer in ticket #1234):

Add several SiS host bridges, from FreeBSD.

Remove duplicate in previous.
 1.433.2.19 02-Jun-2003  tron Regen for ticket 1143.
 1.433.2.18 28-Jan-2003  jmc Regen (requested by fvdl in ticket #1126)
Pullup support for bge device. (Broadcom Gigabit Ethernet)
 1.433.2.17 27-Jan-2003  jmc Regen from pcidevs commits to
Add Intel 82801E Communications I/O Controller Hub (C-ICH)
 1.433.2.16 12-Dec-2002  he Pull up regenerated file (requested by ad in ticket #1030):
Add support for Adaptec 2005S.
Handle DPT ioctls() from native binaries.
Fix SCSI probe problem.
 1.433.2.15 28-Nov-2002  tron Regen for ticket #1019.
 1.433.2.14 26-Nov-2002  tron Regen for tickets #1017 and #1018.
 1.433.2.13 21-Nov-2002  tron Regen for ticket #925.
 1.433.2.12 16-Nov-2002  he Pull up regenerated files (requested by ad in ticket #646):
Add additional Adaptec RAID controller types.
Fixes PR#17719.
 1.433.2.11 07-Nov-2002  tron Regen for ticket #452.
 1.433.2.10 01-Nov-2002  tron Regen for ticket #724.
 1.433.2.9 02-Aug-2002  lukem regen (for ticket #603)
 1.433.2.8 01-Aug-2002  lukem regen (for ticket #589)
 1.433.2.7 12-Jul-2002  thorpej Regen. pullup-1-6 ticket #488 (matt).
 1.433.2.6 25-Jun-2002  lukem regen for ticket #362 from cjs
 1.433.2.5 21-Jun-2002  lukem regen for tickes #344 / #345
 1.433.2.4 11-Jun-2002  lukem regen for ticket #249
 1.433.2.3 11-Jun-2002  lukem regen for ticket #166
 1.433.2.2 11-Jun-2002  lukem regen for ticket #139
 1.433.2.1 10-Jun-2002  tv Regen.
 1.543.2.18 11-Dec-2005  christos Sync with head.
 1.543.2.17 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.543.2.16 01-Apr-2005  skrll Sync with HEAD.
 1.543.2.15 08-Mar-2005  skrll Sync with HEAD.
 1.543.2.14 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.543.2.13 04-Feb-2005  skrll Sync with HEAD.
 1.543.2.12 24-Jan-2005  skrll Sync with HEAD.
 1.543.2.11 17-Jan-2005  skrll Sync with HEAD.
 1.543.2.10 18-Dec-2004  skrll Sync with HEAD.
 1.543.2.9 29-Nov-2004  skrll Sync with HEAD.
 1.543.2.8 14-Nov-2004  skrll Sync with HEAD.
 1.543.2.7 02-Nov-2004  skrll Sync with HEAD.
 1.543.2.6 19-Oct-2004  skrll Sync with HEAD
 1.543.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.543.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.543.2.3 03-Sep-2004  skrll Sync with HEAD
 1.543.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.543.2.1 03-Aug-2004  skrll Sync with HEAD
 1.615.2.17 12-Nov-2004  jmc branches: 1.615.2.17.2;
Regen (requested by martti in ticket #953)

Regen
 1.615.2.16 12-Nov-2004  jmc Regen (requested by martti in ticket #947)

Regen
 1.615.2.15 08-Oct-2004  jmc Regen for ticket #896
 1.615.2.14 18-Sep-2004  he Pull up regenerated files (requested by martin in ticket #856):
Add support for PCI-X version of LSI FC929, from PR#26836.
 1.615.2.13 30-Aug-2004  tron Regen for ticket 800.
 1.615.2.12 30-Aug-2004  tron Regen for ticket 800.
 1.615.2.11 22-Aug-2004  tron Regen for ticket 781.
 1.615.2.10 28-Jul-2004  tron Regen for ticket #721.
 1.615.2.9 28-Jul-2004  tron Regen for ticket #718.
 1.615.2.8 23-Jul-2004  he Pull up regenerated files (requested by mycroft in ticket #691):
Add support for SiS 741. Fixes PR#26394.
 1.615.2.7 05-Jul-2004  he Pull up regenerated files (requested by mycroft in ticket #606):
Update ServerWorks chip IDs, per
http://www.plasma-online.de/english/identify/picture/serverworks.html
Seems remarkably more sane.
 1.615.2.6 22-Jun-2004  tron Regen for ticket #537.
 1.615.2.5 13-May-2004  jdc Regnerate (requested by tron in ticket #316)
 1.615.2.4 11-May-2004  tron Regen for ticket 284, this time with correct revision id for "pcidevs".
 1.615.2.3 11-May-2004  tron Regen for ticket 284.
 1.615.2.2 05-Apr-2004  tron Regen for ticket 54.
 1.615.2.1 01-Apr-2004  jmc Regen (requested by tron in ticket #38)

Correct entry for PCI vendor id 0x11af. It is assigned to Avid Technology
Inc. and not to Pro-Log Corporation. PR#25004
 1.615.2.17.2.19 21-Nov-2006  ghen Regen for ticket #10749.
 1.615.2.17.2.18 11-Sep-2006  tron Regen for ticket #10693.
 1.615.2.17.2.17 04-Jun-2006  tron Regen for ticket #10635.
 1.615.2.17.2.16 11-Apr-2006  riz Regen for ticket 10409.
 1.615.2.17.2.15 17-Mar-2006  riz Regen for ticket 10364.
 1.615.2.17.2.14 01-Dec-2005  tron Regen for ticket #10158.
 1.615.2.17.2.13 01-Dec-2005  riz Regen for ticket 5990.
 1.615.2.17.2.12 21-Jul-2005  snj Regen for ticket 5507.
 1.615.2.17.2.11 05-Jul-2005  riz Regen for ticket 2029.
 1.615.2.17.2.10 21-Jun-2005  riz Regen for ticket 2007.
 1.615.2.17.2.9 19-May-2005  tron Regen for ticket 1532.
 1.615.2.17.2.8 19-May-2005  tron Regen for ticket 1531.
 1.615.2.17.2.7 19-May-2005  tron Regen for ticket 1531.
 1.615.2.17.2.6 11-May-2005  riz Regen for ticket 1402.
 1.615.2.17.2.5 10-May-2005  riz Regen for ticket 1341.
 1.615.2.17.2.4 05-May-2005  riz Regen for ticket 1153.
 1.615.2.17.2.3 01-May-2005  tron Regen for ticket 1438.
 1.615.2.17.2.2 17-Apr-2005  tron Regen for ticket 1120.
 1.615.2.17.2.1 07-Apr-2005  tron Regen for ticket 1103.
 1.686.2.1 29-Apr-2005  kent sync with -current
 1.689.2.4 26-Mar-2005  yamt sync with head.
 1.689.2.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.689.2.2 12-Feb-2005  yamt sync with head.
 1.689.2.1 25-Jan-2005  yamt file pcidevs.h was added on branch yamt-km on 2005-02-12 18:17:48 +0000
 1.702.2.48 10-Nov-2008  snj Regen for ticket 1976.
 1.702.2.47 08-Apr-2008  jdc Regenerate for pcidevs 1.701.2.49.
(requested by bouyer in ticket #1909).
 1.702.2.46 19-Nov-2007  bouyer Regen for ticket #1863
 1.702.2.45 19-Nov-2007  bouyer Regen for ticket 1862
 1.702.2.44 14-Oct-2007  riz Regen for ticket 1770.
 1.702.2.43 14-Oct-2007  riz Regen for ticket 1769.
 1.702.2.42 13-Sep-2007  bouyer Regen for ticket #1822
 1.702.2.41 31-Mar-2007  bouyer regen for ticket 1681
 1.702.2.40 03-Mar-2007  bouyer regen for ticket #1673
 1.702.2.39 23-Dec-2006  ghen Regen for ticket #1609.
 1.702.2.38 23-Dec-2006  ghen Regen for ticket #1608.
 1.702.2.37 20-Nov-2006  ghen Regen for ticket #1584.
 1.702.2.36 27-Aug-2006  ghen branches: 1.702.2.36.2;
Regen for ticket #1479.
 1.702.2.35 15-Aug-2006  ghen Regen for ticket #1466.
 1.702.2.34 03-Aug-2006  tron Regenerate for ticket #1446.
 1.702.2.33 31-Jul-2006  tron Regenerate for ticket #1441.
 1.702.2.32 30-Jul-2006  tron Regen for ticket #1432.
 1.702.2.31 04-Jun-2006  tron Regen for ticket #1351.
 1.702.2.30 04-Jun-2006  tron Regen for ticket #1349.
 1.702.2.29 04-May-2006  tron Regen for ticket #1298.
 1.702.2.28 30-Apr-2006  riz Regen for ticket 1295.
 1.702.2.27 20-Apr-2006  snj Regen for ticket 1266.
 1.702.2.26 08-Apr-2006  tron Regen for ticket #1247.
 1.702.2.25 17-Mar-2006  tron Regen for ticket #1203.
 1.702.2.24 15-Feb-2006  riz Regen for ticket 1169.
 1.702.2.23 14-Feb-2006  riz Sigh. Regen _again_ for ticket 1168.
 1.702.2.22 14-Feb-2006  riz Regen for ticket 1168.
 1.702.2.21 05-Feb-2006  riz Regen for ticket 1156.
 1.702.2.20 21-Jan-2006  snj Regen for ticket 1126.
 1.702.2.19 10-Jan-2006  snj Regen for ticket 1112.
 1.702.2.18 05-Jan-2006  riz Regen for ticket 1086.
 1.702.2.17 15-Dec-2005  tron branches: 1.702.2.17.2;
Regen for ticket #1047.
 1.702.2.16 24-Nov-2005  tron Regen for ticket #994.
 1.702.2.15 21-Nov-2005  tron Regen for ticket #957.
 1.702.2.14 08-Sep-2005  tron Regen for ticket #752.
 1.702.2.13 06-Sep-2005  riz Regen for ticket 748.
 1.702.2.12 24-Jul-2005  riz Regen for ticket 617.
 1.702.2.11 28-Jun-2005  tron Regen for ticket 485.
 1.702.2.10 22-Jun-2005  tron Regen for ticket 478.
 1.702.2.9 21-Jun-2005  tron Regen for ticket 476.
 1.702.2.8 18-Jun-2005  riz Regen for ticket 450.
 1.702.2.7 28-May-2005  snj Regen for ticket 323.
 1.702.2.6 10-May-2005  tron Regen for ticket 272.
 1.702.2.5 21-Apr-2005  tron Regen for ticket 180.
 1.702.2.4 07-Apr-2005  jmc Regen for ticket #59
 1.702.2.3 07-Apr-2005  jmc Regen for ticket #16
 1.702.2.2 07-Apr-2005  jmc Regen for ticket #15
 1.702.2.1 07-Apr-2005  tron Regen for ticket 116.
 1.702.2.36.2.1 04-Oct-2007  bouyer regen for ticket #1822
 1.702.2.17.2.1 04-Oct-2007  bouyer regen for ticket #1822
 1.727.2.10 27-Feb-2008  yamt sync with head.
 1.727.2.9 11-Feb-2008  yamt sync with head.
 1.727.2.8 21-Jan-2008  yamt sync with head
 1.727.2.7 07-Dec-2007  yamt sync with head
 1.727.2.6 15-Nov-2007  yamt sync with head.
 1.727.2.5 27-Oct-2007  yamt sync with head.
 1.727.2.4 03-Sep-2007  yamt sync with head.
 1.727.2.3 26-Feb-2007  yamt sync with head.
 1.727.2.2 30-Dec-2006  yamt sync with head.
 1.727.2.1 21-Jun-2006  yamt sync with head.
 1.735.2.1 02-Nov-2005  yamt sync with head.
 1.736.2.2 29-Nov-2005  yamt sync with head.
 1.736.2.1 22-Nov-2005  yamt sync with head.
 1.752.2.4 01-Mar-2006  yamt sync with head.
 1.752.2.3 18-Feb-2006  yamt sync with head.
 1.752.2.2 01-Feb-2006  yamt sync with head.
 1.752.2.1 15-Jan-2006  yamt sync with head.
 1.759.2.1 09-Sep-2006  rpaulo sync with head
 1.760.2.3 07-Jun-2006  kardel Sync with head.
 1.760.2.2 01-Jun-2006  kardel Sync with head.
 1.760.2.1 22-Apr-2006  simonb Sync with head.
 1.770.2.8 14-Sep-2006  yamt sync with head.
 1.770.2.7 03-Sep-2006  yamt sync with head.
 1.770.2.6 11-Aug-2006  yamt sync with head
 1.770.2.5 26-Jun-2006  yamt sync with head.
 1.770.2.4 24-May-2006  yamt sync with head.
 1.770.2.3 11-Apr-2006  yamt sync with head
 1.770.2.2 01-Apr-2006  yamt sync with head.
 1.770.2.1 13-Mar-2006  yamt sync with head.
 1.772.2.3 11-May-2006  elad sync with head
 1.772.2.2 19-Apr-2006  elad sync with head.
 1.772.2.1 07-Mar-2006  elad file pcidevs.h was added on branch elad-kernelauth on 2006-04-19 03:25:36 +0000
 1.776.2.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.776.2.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.788.2.3 22-Jun-2006  chap Complete a sync sys/ with head.
 1.788.2.2 19-Jun-2006  chap Sync with head.
 1.788.2.1 19-May-2006  chap file pcidevs.h was added on branch chap-midi on 2006-06-19 04:01:36 +0000
 1.793.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.815.2.7 15-Sep-2006  tron Regen for ticket #153.
 1.815.2.6 09-Sep-2006  rpaulo Regen for ticket #139.
 1.815.2.5 07-Sep-2006  riz Regen for ticket #115.
 1.815.2.4 07-Sep-2006  riz Regen for ticket #113
 1.815.2.3 07-Sep-2006  riz Regen for ticket #112.
 1.815.2.2 15-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #28):
sys/dev/pci/pcidevs: revision 1.819
sys/dev/pci/pcidevs.h: revision 1.819
sys/dev/pci/pcidevs_data.h: revision 1.818 (via patch)
sys/dev/pci/pdcsata.c: revision 1.10
Add the Promise PDC20771, present on the Promise FastTrak TX2300
Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.
This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.
The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.
The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.815.2.1 11-Aug-2006  riz Regen for ticket #8.
 1.830.2.3 01-Feb-2007  ad Sync with head.
 1.830.2.2 12-Jan-2007  ad Sync with head.
 1.830.2.1 18-Nov-2006  ad Sync with head.
 1.831.2.3 18-Dec-2006  yamt sync with head.
 1.831.2.2 10-Dec-2006  yamt sync with head.
 1.831.2.1 22-Oct-2006  yamt sync with head
 1.854.2.25 31-Oct-2008  snj Regen for ticket 1215.
 1.854.2.24 29-Sep-2008  jdc Regenerate for pullup ticket #1192.
(addd SYMBIOS SAS1068_2, SAS1064E_2 and SAS1068E_2)
 1.854.2.23 17-May-2008  bouyer Regen for ticket 1145
 1.854.2.22 17-May-2008  bouyer Regen for ticket 1143
 1.854.2.21 19-Apr-2008  bouyer Regen for ticket 1128
 1.854.2.20 09-Mar-2008  bouyer Regen for ticket #1097
 1.854.2.19 23-Feb-2008  bouyer Regen for ticket #1061
 1.854.2.18 22-Feb-2008  bouyer Regen for ticket #1074
 1.854.2.17 11-Jan-2008  xtraeme Regen for ticket #1037.
 1.854.2.16 15-Nov-2007  pavel Backout accidental commit to the release branch.
 1.854.2.15 15-Nov-2007  manu regen
 1.854.2.14 04-Nov-2007  xtraeme Regen for ticket #954.
 1.854.2.13 24-Oct-2007  pavel regen for ticket #935.
 1.854.2.12 22-Oct-2007  pavel regen for ticket #931.
 1.854.2.11 07-Oct-2007  xtraeme Regen for ticket #923.
 1.854.2.10 31-Aug-2007  pavel regen for ticket #678
 1.854.2.9 29-Aug-2007  liamjfoy Regen for ticket #846
 1.854.2.8 29-Aug-2007  liamjfoy Pull up following revision(s) (requested by masanobu in ticket #850):

sys/dev/pci/if_wm.c 1.137
sys/dev/pci/if_wm.c 1.138
sys/dev/pci/if_wm.c 1.141
sys/dev/pci/if_wm.c 1.144
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphy.c 1.12
sys/dev/mii/miidevs 1.72
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/wm.4 1.18

Fix for 82541 and 82547's reset bug.
Modify wm_reset() to make some device stable.
Add ICH9 support to wm.
Add I82566 support to igphy.

Pulled done via patch.
 1.854.2.7 26-Aug-2007  liamjfoy Regen pcidevs.h pcidevs_data.h
 1.854.2.6 10-Jun-2007  bouyer Regen for ticket 713
 1.854.2.5 02-May-2007  snj branches: 1.854.2.5.2;
Regen for ticket 597.
 1.854.2.4 21-Feb-2007  tron Regenerate for ticket #446.
 1.854.2.3 17-Feb-2007  tron Regen for ticket #449.
 1.854.2.2 17-Feb-2007  tron Regen for ticket #423.
 1.854.2.1 12-Dec-2006  tron Regen for ticket for #267.
 1.854.2.5.2.4 03-Jun-2008  skrll Sync with netbsd-4.
 1.854.2.5.2.3 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.854.2.5.2.2 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.854.2.5.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.868.2.5 17-May-2007  yamt sync with head.
 1.868.2.4 07-May-2007  yamt sync with head.
 1.868.2.3 15-Apr-2007  yamt sync with head.
 1.868.2.2 24-Mar-2007  yamt sync with head.
 1.868.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.871.2.9 23-Oct-2007  ad Sync with head.
 1.871.2.8 12-Oct-2007  ad Sync with head.
 1.871.2.7 09-Oct-2007  ad Sync with head.
 1.871.2.6 20-Aug-2007  ad Sync with HEAD.
 1.871.2.5 15-Jul-2007  ad Sync with head.
 1.871.2.4 09-Jun-2007  ad Sync with head.
 1.871.2.3 27-May-2007  ad Sync with head.
 1.871.2.2 10-Apr-2007  ad Sync with head.
 1.871.2.1 13-Mar-2007  ad Sync with head.
 1.872.4.2 29-Mar-2007  reinoud Pullup to -current
 1.872.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.872.2.1 11-Jul-2007  mjf Sync with head.
 1.885.6.13 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.885.6.12 21-Nov-2007  joerg Sync with HEAD.
 1.885.6.11 14-Nov-2007  joerg Sync with HEAD.
 1.885.6.10 31-Oct-2007  joerg Sync with HEAD.
 1.885.6.9 28-Oct-2007  joerg Sync with HEAD.
 1.885.6.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.885.6.7 02-Oct-2007  joerg Sync with HEAD.
 1.885.6.6 06-Sep-2007  jmcneill Regen.
 1.885.6.5 03-Sep-2007  jmcneill Sync with HEAD.
 1.885.6.4 27-Aug-2007  jmcneill Regen.
 1.885.6.3 16-Aug-2007  jmcneill Sync with HEAD.
 1.885.6.2 09-Aug-2007  jmcneill Sync with HEAD.
 1.885.6.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.885.2.3 10-Sep-2007  skrll Sync with HEAD.
 1.885.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.885.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.887.2.2 06-Aug-2007  martin regen
 1.887.2.1 06-Aug-2007  martin file pcidevs.h was added on branch matt-mips64 on 2007-08-06 22:40:08 +0000
 1.892.2.3 23-Mar-2008  matt sync with HEAD
 1.892.2.2 09-Jan-2008  matt sync with HEAD
 1.892.2.1 06-Nov-2007  matt sync with HEAD
 1.903.2.1 14-Oct-2007  yamt sync with head.
 1.905.2.4 21-Nov-2007  bouyer Sync with HEAD
 1.905.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.905.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.905.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.913.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.913.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.913.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.913.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.920.4.1 11-Dec-2007  yamt sync with head.
 1.920.2.1 26-Dec-2007  ad Sync with head.
 1.921.2.3 11-Jan-2008  bouyer Sync with HEAD
 1.921.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.921.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.930.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.930.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.930.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.930.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.930.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.930.2.1 24-Mar-2008  keiichi sync with head.
 1.938.4.9 09-Oct-2010  yamt sync with head
 1.938.4.8 11-Aug-2010  yamt sync with head.
 1.938.4.7 11-Mar-2010  yamt sync with head
 1.938.4.6 19-Aug-2009  yamt sync with head.
 1.938.4.5 18-Jul-2009  yamt sync with head.
 1.938.4.4 20-Jun-2009  yamt sync with head
 1.938.4.3 16-May-2009  yamt sync with head
 1.938.4.2 04-May-2009  yamt sync with head.
 1.938.4.1 16-May-2008  yamt sync with head.
 1.938.2.2 04-Jun-2008  yamt sync with head
 1.938.2.1 18-May-2008  yamt sync with head.
 1.939.2.4 10-Oct-2008  skrll Sync with HEAD.
 1.939.2.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.939.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.939.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.943.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.943.4.1 19-Oct-2008  haad Sync with HEAD.
 1.943.2.2 31-Jul-2008  simonb Sync with head.
 1.943.2.1 18-Jul-2008  simonb Sync with head.
 1.963.4.21 09-Nov-2015  sborrill Regen
 1.963.4.20 30-Apr-2015  snj regen for ticket 1962
 1.963.4.19 07-Sep-2013  bouyer Regen for ticket 1867
 1.963.4.18 19-Jun-2013  bouyer regen for ticket #1850
 1.963.4.17 20-Jan-2013  bouyer regen for ticket #1842
 1.963.4.16 17-Mar-2012  bouyer Regen for ticket 1739
 1.963.4.15 22-Nov-2010  riz branches: 1.963.4.15.2;
Regen for ticket 1470.
 1.963.4.14 20-Nov-2010  riz Regen for ticket 1362.
 1.963.4.13 19-Nov-2010  riz Regen for ticket 1359.
 1.963.4.12 19-Nov-2010  riz Regen for ticket #1358.
 1.963.4.11 28-Mar-2010  snj Regen for ticket 1326.
 1.963.4.10 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c 1.184-1.192, 1.194
sys/dev/pci/if_wmreg.h 1.29-1.35
sys/dev/pci/if_wmvar.h 1.5-1.8
sys/dev/pci/pcidevs 1.1006,1.1009-1.1010, 1.1012-1.1013 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.5
sys/dev/mii/inbmphyreg.h 1.1

- Add support for i82583V.
- Add some ICH9 and ICH10 devices.
- Add support for PCH.
- Fix the bug that ICH9 can't found a PHY. Fixes PR#42237
- Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
- Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
- Fix the checking of jumbo frame function
- Remove the extra macro definition for the offset 0x1a in EEPROM.
- Add missing break in wm_reset()...
- Fix the offset of WMREG_PBS...
- Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. It seems that we have to
do the same work for ICH9.
- Fixes the rx stall problem on 82578 by MANY workaround code. We need more
work for 82577.
 1.963.4.9 27-Jan-2010  sborrill Regen
 1.963.4.8 23-Jan-2010  bouyer Regen for ticket 1254
 1.963.4.7 18-Dec-2009  snj Regen for ticket 1175.
 1.963.4.6 28-Oct-2009  bouyer Regen for ticket 1114
 1.963.4.5 26-Sep-2009  snj Regen for ticket 1021.
 1.963.4.4 21-May-2009  snj Regen for ticket 771.
 1.963.4.3 05-May-2009  bouyer Regen for ticket 737
 1.963.4.2 03-May-2009  snj Regen for ticket 722.
 1.963.4.1 20-Mar-2009  msaitoh branches: 1.963.4.1.4;
Regen for ticket 587.
 1.963.4.15.2.2 14-Oct-2011  matt Regen.
 1.963.4.15.2.1 07-Jan-2011  matt Regen.
 1.963.4.1.4.9 05-Nov-2013  matt Regen.
 1.963.4.1.4.8 05-Nov-2013  matt Pull down xhci support from HEAD
 1.963.4.1.4.7 03-Jan-2012  matt Regen.
 1.963.4.1.4.6 31-Dec-2011  matt Regen.
 1.963.4.1.4.5 24-Dec-2011  matt Regen.
 1.963.4.1.4.4 10-May-2010  matt Regen.
 1.963.4.1.4.3 21-Apr-2010  matt sync to netbsd-5
 1.963.4.1.4.2 07-Apr-2010  cliff add RMI XLR PCI-X bridge
 1.963.4.1.4.1 09-Nov-2009  cliff in pcidevs:
- add vendor entry for RMI
- add product entry for RMI XLS integrated PCIe Interface
regenerate (make) pcidevs.h and pcidevs_data.h
 1.963.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.963.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.963.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.977.2.2 23-Jul-2009  jym Sync with HEAD.
 1.977.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1016.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1016.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1016.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1022.2.7 12-Jun-2011  rmind sync with head
 1.1022.2.6 31-May-2011  rmind sync with head
 1.1022.2.5 21-Apr-2011  rmind sync with head
 1.1022.2.4 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.1022.2.3 05-Mar-2011  rmind sync with head
 1.1022.2.2 03-Jul-2010  rmind sync with head
 1.1022.2.1 30-May-2010  rmind sync with head
 1.1052.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.1052.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.1052.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1079.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1096.6.7 02-Jun-2012  mrg sync to latest -current.
 1.1096.6.6 29-Apr-2012  mrg sync to latest -current.
 1.1096.6.5 05-Apr-2012  mrg sync to latest -current.
 1.1096.6.4 06-Mar-2012  mrg sync to -current
 1.1096.6.3 06-Mar-2012  mrg sync to -current
 1.1096.6.2 04-Mar-2012  mrg sync to latest -current.
 1.1096.6.1 18-Feb-2012  mrg merge to -current.
 1.1096.2.5 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1096.2.4 16-Jan-2013  yamt sync with (a bit old) head
 1.1096.2.3 30-Oct-2012  yamt sync with head
 1.1096.2.2 23-May-2012  yamt sync with head.
 1.1096.2.1 17-Apr-2012  yamt sync with head
 1.1097.2.18 30-Apr-2015  snj regen for ticket 1296
 1.1097.2.17 19-Apr-2015  riz Regen for ticket 1293.
 1.1097.2.16 07-Dec-2014  martin regen
 1.1097.2.15 04-Dec-2014  snj regen for ticket 1202
 1.1097.2.14 09-Nov-2014  martin Regen for ticket #1188
 1.1097.2.13 07-Sep-2013  bouyer regen for ticket 939
 1.1097.2.12 14-Jul-2013  riz Regen for ticket #906.
 1.1097.2.11 22-Nov-2012  riz Regen for ticket 691.
 1.1097.2.10 18-Nov-2012  msaitoh Regen for ticket #658
 1.1097.2.9 31-Oct-2012  riz Regen for ticket 643.
 1.1097.2.8 24-Oct-2012  riz Regen for ticket #631
 1.1097.2.7 24-Oct-2012  riz Regen for ticket 628.
 1.1097.2.6 28-Jun-2012  riz branches: 1.1097.2.6.2;
Regen for ticket #362.
 1.1097.2.5 23-Apr-2012  riz Regen for ticket #191.
 1.1097.2.4 16-Apr-2012  riz Regen for ticket 180.
 1.1097.2.3 03-Apr-2012  riz Regen for ticket #151.
 1.1097.2.2 03-Apr-2012  riz Regen for ticket #149.
 1.1097.2.1 22-Mar-2012  riz Regen for ticket #137.
 1.1097.2.6.2.1 18-Nov-2012  matt Merge tickets 658 and 659.
 1.1125.2.5 03-Dec-2017  jdolecek update from HEAD
 1.1125.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1125.2.3 23-Jun-2013  tls resync from head
 1.1125.2.2 25-Feb-2013  tls resync with head
 1.1125.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1150.4.1 23-Jul-2013  riastradh sync with HEAD
 1.1150.2.2 18-May-2014  rmind sync with head
 1.1150.2.1 28-Aug-2013  rmind sync with head
 1.1177.2.1 10-Aug-2014  tls Rebase.
 1.1192.2.12 14-Aug-2018  martin Regen for ticket #1628
 1.1192.2.11 03-Jan-2018  snj regen for ticket 1547
 1.1192.2.10 25-Jul-2017  snj regen for ticket 1413
 1.1192.2.9 09-Dec-2016  snj regen for ticket 1300
 1.1192.2.8 09-Dec-2016  snj regen for ticket 1298
 1.1192.2.7 08-Dec-2016  snj regen for ticket 1291
 1.1192.2.6 19-Apr-2015  riz branches: 1.1192.2.6.4;
Regen for ticket #699
 1.1192.2.5 17-Feb-2015  martin Regen (ticket #528)
 1.1192.2.4 04-Feb-2015  snj regen for ticket 473
 1.1192.2.3 28-Jan-2015  snj regen for ticket 467
 1.1192.2.2 17-Jan-2015  martin regen (ticket #432)
 1.1192.2.1 07-Nov-2014  snj regen for ticket 190
 1.1192.2.6.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.1199.2.11 28-Aug-2017  skrll Sync with HEAD
 1.1199.2.10 05-Feb-2017  skrll Sync with HEAD
 1.1199.2.9 05-Dec-2016  skrll Sync with HEAD
 1.1199.2.8 05-Oct-2016  skrll Sync with HEAD
 1.1199.2.7 09-Jul-2016  skrll Sync with HEAD
 1.1199.2.6 29-May-2016  skrll Sync with HEAD
 1.1199.2.5 19-Mar-2016  skrll Sync with HEAD
 1.1199.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1199.2.3 21-Sep-2015  skrll Regen
 1.1199.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1199.2.1 06-Apr-2015  skrll Sync with HEAD
 1.1246.2.6 26-Apr-2017  pgoyette Regen
 1.1246.2.5 26-Apr-2017  pgoyette Sync with HEAD
 1.1246.2.4 20-Mar-2017  pgoyette Sync with HEAD
 1.1246.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1246.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.1246.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.1270.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.1278.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1278.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.1281.2.31 03-Feb-2024  martin regen (ticket #1931)
 1.1281.2.30 18-Oct-2023  martin regen (for ticket #1915)
 1.1281.2.29 13-Oct-2023  martin Regen for ticket #1913 (Intel 82599 LS and Pericom(Diodes) PCIe switches added)
 1.1281.2.28 13-Oct-2023  martin Regen for ticket #1911 (add ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier)
 1.1281.2.27 21-Aug-2023  martin regen (for ticket #1887)
 1.1281.2.26 29-Jul-2023  martin regen (ticket #1855)
 1.1281.2.25 21-Jun-2023  martin Regen for ticket #1846
 1.1281.2.24 18-Jan-2023  martin Regen for ticket #1783
 1.1281.2.23 11-Oct-2022  martin regen (Ticket #1771)
 1.1281.2.22 02-Aug-2022  snj regen for ticket 1754
 1.1281.2.21 03-Dec-2021  martin regen (ticket #1710)
 1.1281.2.20 23-Oct-2021  martin Regen for ticket #1700:

- Add modern QUMRANET/Red Hat VIRTIO range PCI devices.
- Add some more product IDs for mcx(4).
- Add current generation NVIDIA graphics cards (3050-3090 etc.).
- Add RDC R6022 PCI-Host bridge.
- Add a whole bunch of radeon devices.
- Add Realtek RTL8821CE.
- Add Intel 660p SSD, and expand the 760p description.
- Add Intel I219's version number.
- Add Intel I219V 15-19 and I219LM 16-19.
- Add Intel I225V, I225LM and WiFi 6 AX201.
- Add newer Intel PCH internal devices.
- Add Intel Jasper Lake devices.
- PDC20265 is Ultra/100, not 66.
- Fix Realtek RTL8125 description.
- Sort Cavium devices.
 1.1281.2.19 20-Jul-2020  martin Regen for ticket #1579
 1.1281.2.18 20-Jul-2020  martin regen for ticket #1578
 1.1281.2.17 19-Nov-2019  martin regen for ticket #1448
 1.1281.2.16 06-Aug-2019  martin regen (ticket #1326)
 1.1281.2.15 17-Jul-2019  martin regen
 1.1281.2.14 07-Mar-2019  martin Regen for ticket #1205
 1.1281.2.13 11-Feb-2019  martin Regen for ticket #1188
 1.1281.2.12 04-Dec-2018  martin Regen for ticket #1123
 1.1281.2.11 04-Dec-2018  martin Regen for #1119
 1.1281.2.10 17-Oct-2018  martin Regen for ticket #1064
 1.1281.2.9 26-Jul-2018  snj regen for ticket 934
 1.1281.2.8 15-Jun-2018  msaitoh Regen for ticket #878.
 1.1281.2.7 07-Jun-2018  martin Regen (ticket #846)
 1.1281.2.6 18-Apr-2018  martin regen for ticket #780
 1.1281.2.5 14-Apr-2018  martin regen (for ticket #751):

Add Nvidia GeForce 9400M as found in the late 2009 13" MacBook (MacBook6,1)
Add new I219 devices (using with 300 series chipset).
 1.1281.2.4 09-Apr-2018  martin Regen (ticket #723)
 1.1281.2.3 08-Mar-2018  martin Regen for ticket #616
 1.1281.2.2 21-Nov-2017  martin regen
 1.1281.2.1 25-Jun-2017  snj regen for ticket 55
 1.1311.2.15 26-Jan-2019  pgoyette Sync with HEAD
 1.1311.2.14 18-Jan-2019  pgoyette Synch with HEAD
 1.1311.2.13 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1311.2.12 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1311.2.11 20-Oct-2018  pgoyette Sync with head
 1.1311.2.10 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1311.2.9 28-Jul-2018  pgoyette Sync with HEAD
 1.1311.2.8 25-Jun-2018  pgoyette Sync with HEAD
 1.1311.2.7 21-May-2018  pgoyette Sync with HEAD
 1.1311.2.6 02-May-2018  pgoyette Synch with HEAD
 1.1311.2.5 22-Apr-2018  pgoyette Sync with HEAD
 1.1311.2.4 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1311.2.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1311.2.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.1311.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.1334.2.3 21-Apr-2020  martin Sync with HEAD
 1.1334.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1334.2.1 10-Jun-2019  christos Sync with HEAD
 1.1371.2.26 26-Oct-2025  martin Regen for ticket #1978
 1.1371.2.25 08-May-2025  martin regen for ticket #1944
 1.1371.2.24 08-May-2025  martin Regen for ticket #1944:
Various VIA IDE controller related additions/changes.
 1.1371.2.23 03-Jul-2024  martin Regen for ticket #1852 (Brainboxes devices)
 1.1371.2.22 03-Feb-2024  martin regen (ticket #1790)
 1.1371.2.21 18-Oct-2023  martin Regen for ticket #1915
 1.1371.2.20 13-Oct-2023  martin Regen for ticket #1750 (Intel 82599 LS and Pericom(Diodes) PCIe switches added)
 1.1371.2.19 13-Oct-2023  martin Regen for ticket #1748 (add ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier)
 1.1371.2.18 21-Aug-2023  martin regen (for ticket #1719)
 1.1371.2.17 29-Jul-2023  martin regen (ticket #1671)
 1.1371.2.16 21-Jun-2023  martin Regen for ticket #1654
 1.1371.2.15 30-Jan-2023  martin Regen for ticket #1580
 1.1371.2.14 18-Jan-2023  martin Regen for ticket #1566
 1.1371.2.13 11-Oct-2022  martin regen (Ticket #1537)
 1.1371.2.12 27-Jul-2022  martin regen for ticket #1482
 1.1371.2.11 03-Dec-2021  martin regen (ticket #1380)
 1.1371.2.10 21-Oct-2021  martin Regen (for ticket #1362)
 1.1371.2.9 10-Jul-2020  martin Regen for ticket #991
 1.1371.2.8 07-Jul-2020  martin regen
 1.1371.2.7 28-Apr-2020  martin Regen for ticket #864
 1.1371.2.6 19-Mar-2020  martin Regen (for ticket #784)
 1.1371.2.5 31-Jan-2020  martin regen (for ticket #670)
 1.1371.2.4 19-Nov-2019  martin Regen for ticket #449
 1.1371.2.3 24-Oct-2019  martin Regen for ticket #373
 1.1371.2.2 24-Sep-2019  martin regen for ticket #237 (Mellanox device IDs added)
 1.1371.2.1 26-Aug-2019  martin Regen for ticket #112
 1.1383.2.2 29-Feb-2020  ad Sync with head.
 1.1383.2.1 25-Jan-2020  ad Sync with head.
 1.1392.2.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.1392.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.1406.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.1406.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.1406.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1410.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1412.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1452.2.18 26-Oct-2025  martin Regen for ticket #1184
 1.1452.2.17 08-May-2025  martin regen for ticket #1101
 1.1452.2.16 08-May-2025  martin Regen for ticket #1101:
Various VIA IDE controller related additions/changes.
 1.1452.2.15 06-Dec-2024  snj regen for ticket 1024
 1.1452.2.14 24-Aug-2024  martin Regen for ticket #805
 1.1452.2.13 03-Jul-2024  martin Regen for ticket #730 (Brainboxes devices)
 1.1452.2.12 03-Feb-2024  martin regen (ticket #560)
 1.1452.2.11 03-Nov-2023  martin Regen for ticket #447 (Add Mellanox ConnectX-6 Lx)
 1.1452.2.10 18-Oct-2023  martin Regen for ticket #421
 1.1452.2.9 13-Oct-2023  martin Regen for ticket #406 (Intel 82599 LS and Pericom(Diodes) PCIe switches added)
 1.1452.2.8 13-Oct-2023  martin Regen for ticket #403 (add ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier)
 1.1452.2.7 08-Oct-2023  martin Regen for ticket #393 (Add missing I225/I226 series devices)
 1.1452.2.6 21-Aug-2023  martin regen (for ticket #333)
 1.1452.2.5 29-Jul-2023  martin regen (ticket #252)
 1.1452.2.4 21-Jun-2023  martin Regen for ticket #209
 1.1452.2.3 21-Jun-2023  martin Regen for ticket #209
 1.1452.2.2 30-Jan-2023  martin Regen for ticket #61
 1.1452.2.1 18-Jan-2023  martin Regen for ticket #50
 1.1486.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1506.2.1 26-Oct-2025  martin Regen for ticket #71
 1.1509 27-Oct-2025  andvar regen.
 1.1508 21-Oct-2025  pgoyette regen
 1.1507 21-Oct-2025  pgoyette Regen for vendor MediaTek
 1.1506 17-Oct-2025  andvar regen.
 1.1505 03-May-2025  rin branches: 1.1505.2;
pcidevs{,_data}.h: Regen for EXAR XR17V358
 1.1504 01-May-2025  andvar regen.
 1.1503 01-May-2025  andvar regen.
 1.1502 28-Apr-2025  andvar regen.
 1.1501 28-Apr-2025  andvar regen.
 1.1500 20-Apr-2025  andvar regen.
 1.1499 05-Apr-2025  andvar regen.
 1.1498 03-Apr-2025  andvar regen.
 1.1497 03-Mar-2025  andvar regen.
 1.1496 23-Jan-2025  andvar regen.
 1.1495 23-Jan-2025  mrg regen
 1.1494 18-Jan-2025  mrg regen.
 1.1493 03-Jan-2025  mrg regen.
 1.1492 12-Dec-2024  msaitoh regen.
 1.1491 11-Nov-2024  msaitoh Regen.
 1.1490 19-Oct-2024  mlelstv Regen
 1.1489 16-Oct-2024  msaitoh Regen.
 1.1488 20-Aug-2024  dogcow regen
 1.1487 17-Jul-2024  mrg regen after intel arc.
 1.1486 11-Jul-2024  msaitoh Regen.
 1.1485 23-Jun-2024  jakllsch branches: 1.1485.2;
Regen.

For PR 58358
 1.1484 12-May-2024  msaitoh Regen.
 1.1483 06-Apr-2024  andvar regen.
 1.1482 28-Feb-2024  jakllsch regen
 1.1481 18-Jan-2024  msaitoh regen.
 1.1480 28-Dec-2023  msaitoh pcidevs: Regen.
 1.1479 13-Nov-2023  jnemeth regen for newer Areca boards
 1.1478 26-Oct-2023  msaitoh pcidevs: regen.
 1.1477 11-Oct-2023  msaitoh Regen.
 1.1476 10-Oct-2023  abs Regenerate for ASMEDIA 0x0624
 1.1475 08-Oct-2023  msaitoh Regen.
 1.1474 04-Oct-2023  rin Regen for pcidevs rev 1.1494
 1.1473 04-Oct-2023  msaitoh Regen.
 1.1472 10-Aug-2023  andvar regen.
 1.1471 09-Aug-2023  msaitoh Regen.
 1.1470 09-Aug-2023  msaitoh Regen.
 1.1469 05-Aug-2023  andvar regen.
 1.1468 05-Aug-2023  andvar Regen.
 1.1467 04-Aug-2023  msaitoh Regen.
 1.1466 04-Aug-2023  msaitoh Regen.
 1.1465 31-Jul-2023  tnn pcidevs: regen
 1.1464 28-Jul-2023  msaitoh Regen.
 1.1463 23-Jul-2023  msaitoh Regen.
 1.1462 22-Jul-2023  msaitoh regen.
 1.1461 22-Jul-2023  msaitoh Add Alder Lake-N and Raptor Lake devices.
 1.1460 06-Apr-2023  msaitoh Regen.
 1.1459 14-Feb-2023  msaitoh Regen.
 1.1458 03-Feb-2023  msaitoh Regen.
 1.1457 29-Jan-2023  thorpej Regen for EXAR XR17V354.

PR kern/57202
 1.1456 18-Jan-2023  msaitoh Regen.
 1.1455 14-Jan-2023  ryo regen
 1.1454 04-Jan-2023  msaitoh Regen.
 1.1453 30-Dec-2022  msaitoh Regen.
 1.1452 28-Dec-2022  msaitoh Regen.
 1.1451 22-Nov-2022  msaitoh branches: 1.1451.2;
Regen.
 1.1450 26-Oct-2022  msaitoh Regen.
 1.1449 26-Oct-2022  msaitoh Regen.
 1.1448 07-Oct-2022  snj regen
 1.1447 02-Oct-2022  martin regen (AMD FCH SATA D added)
 1.1446 01-Oct-2022  msaitoh Regen.
 1.1445 28-Sep-2022  msaitoh Regen.
 1.1444 13-Sep-2022  msaitoh Regen.
 1.1443 11-Sep-2022  mrg regen
 1.1442 27-Jun-2022  msaitoh Regen.
 1.1441 17-Jun-2022  msaitoh Regen.
 1.1440 02-Jun-2022  mrg regen.
 1.1439 11-May-2022  markd Regen
 1.1438 04-May-2022  martin Regen
 1.1437 04-May-2022  nia regen
 1.1436 27-Apr-2022  msaitoh Regen.
 1.1435 22-Apr-2022  skrll Regen
 1.1434 24-Mar-2022  yamaguchi regen
 1.1433 16-Mar-2022  yamaguchi Regen.
 1.1432 15-Feb-2022  msaitoh Regen.
 1.1431 02-Feb-2022  msaitoh Regen.
 1.1430 25-Jan-2022  msaitoh Regen.
 1.1429 01-Jan-2022  msaitoh Regen.
 1.1428 30-Nov-2021  msaitoh Regen.
 1.1427 03-Nov-2021  msaitoh Regen.
 1.1426 27-Oct-2021  msaitoh Regen.
 1.1425 27-Oct-2021  msaitoh Regen.
 1.1424 13-Oct-2021  msaitoh Regen.
 1.1423 12-Oct-2021  msaitoh Regen.
 1.1422 11-Oct-2021  msaitoh Regen.
 1.1421 02-Oct-2021  mrg regen.
 1.1420 23-Sep-2021  msaitoh Regen.
 1.1419 06-Sep-2021  mrg regen.
 1.1418 03-Sep-2021  mrg regen.
 1.1417 30-Aug-2021  andvar regen.
 1.1416 30-Aug-2021  mrg regen.
 1.1415 30-Aug-2021  mrg regen.
 1.1414 17-Jul-2021  mrg regen.
 1.1413 12-Jul-2021  msaitoh Regen.
 1.1412 29-Jun-2021  pgoyette Regen for new sys/dev/devlist2h.awk
 1.1411 21-Apr-2021  jakllsch branches: 1.1411.2;
regenerate
 1.1410 02-Apr-2021  rin regen
 1.1409 30-Jan-2021  jmcneill branches: 1.1409.2;
regen
 1.1408 29-Dec-2020  skrll regen
 1.1407 20-Nov-2020  msaitoh Regen.
 1.1406 19-Nov-2020  reinoud Regenated from pcidevs
 1.1405 14-Jul-2020  jdolecek branches: 1.1405.2;
regen
 1.1404 09-Jul-2020  msaitoh Regen.
 1.1403 24-Jun-2020  thorpej Regen.
 1.1402 13-Jun-2020  ryo regen
 1.1401 11-Jun-2020  jdolecek regen
 1.1400 26-May-2020  martin regen
 1.1399 01-May-2020  jmcneill regen
 1.1398 23-Apr-2020  msaitoh Regen.
 1.1397 22-Apr-2020  christos regen
 1.1396 22-Apr-2020  prlw1 regen
 1.1395 22-Apr-2020  msaitoh Regen.
 1.1394 18-Apr-2020  simonb Regen.
 1.1393 16-Apr-2020  msaitoh Regen.
 1.1392 10-Apr-2020  christos regen
 1.1391 07-Apr-2020  christos branches: 1.1391.2;
regen
 1.1390 01-Apr-2020  msaitoh Regen.
 1.1389 11-Mar-2020  msaitoh Regen.
 1.1388 11-Mar-2020  fcambus Regen.
 1.1387 08-Mar-2020  msaitoh Regen.
 1.1386 05-Mar-2020  msaitoh Regen.
 1.1385 19-Feb-2020  mrg regen.
 1.1384 28-Jan-2020  msaitoh Regen.
 1.1383 21-Jan-2020  msaitoh Regen.
 1.1382 01-Jan-2020  ryo branches: 1.1382.2;
regen
 1.1381 29-Dec-2019  sevan regen
 1.1380 18-Dec-2019  msaitoh Regen.
 1.1379 27-Nov-2019  msaitoh Regen.
 1.1378 14-Nov-2019  msaitoh Regen.
 1.1377 08-Nov-2019  msaitoh Regen.
 1.1376 29-Oct-2019  msaitoh Regen.
 1.1375 12-Oct-2019  skrll regen
 1.1374 21-Sep-2019  msaitoh Regen.
 1.1373 21-Sep-2019  msaitoh Regen.
 1.1372 24-Aug-2019  jmcneill regen
 1.1371 21-Aug-2019  mrg regen for new micron/crucial/amd entries, and PCIe spelling.
 1.1370 28-Jul-2019  mlelstv branches: 1.1370.2;
regen
 1.1369 24-Jul-2019  msaitoh Regen.
 1.1368 18-Jul-2019  msaitoh Regen.
 1.1367 12-Jul-2019  msaitoh Regen.
 1.1366 12-Jul-2019  msaitoh Regen.
 1.1365 09-Jul-2019  msaitoh Regen.
 1.1364 05-Jul-2019  msaitoh Regen.
 1.1363 02-Jul-2019  msaitoh Regen.
 1.1362 04-Jun-2019  msaitoh Regen.
 1.1361 01-Jun-2019  jdolecek regen
 1.1360 30-May-2019  mlelstv regen
 1.1359 15-Apr-2019  msaitoh Regen.
 1.1358 15-Apr-2019  msaitoh Regen.
 1.1357 12-Apr-2019  msaitoh Regen.
 1.1356 11-Apr-2019  mrg regen.
 1.1355 08-Mar-2019  msaitoh Regen.
 1.1354 05-Mar-2019  msaitoh Regen.
 1.1353 20-Feb-2019  msaitoh Regen.
 1.1352 20-Feb-2019  msaitoh Regen.
 1.1351 14-Feb-2019  msaitoh Regen.
 1.1350 08-Feb-2019  msaitoh Regen.
 1.1349 06-Feb-2019  msaitoh Regen.
 1.1348 28-Jan-2019  msaitoh Regen.
 1.1347 26-Jan-2019  msaitoh Regen.
 1.1346 21-Jan-2019  msaitoh Regen.
 1.1345 26-Dec-2018  msaitoh Regen.
 1.1344 03-Dec-2018  bouyer Regen for new Symbios devices
 1.1343 29-Nov-2018  jmcneill regen
 1.1342 24-Nov-2018  skrll Regen
 1.1341 12-Nov-2018  msaitoh Regen.
 1.1340 08-Nov-2018  msaitoh Regen.
 1.1339 16-Oct-2018  jmcneill regen
 1.1338 15-Oct-2018  uwe Adaptec RAID 2445 and 2805
 1.1337 23-Aug-2018  msaitoh Regen.
 1.1336 30-Jul-2018  msaitoh Regen.
 1.1335 30-Jul-2018  msaitoh Regen.
 1.1334 06-Jul-2018  prlw1 regen
 1.1333 20-Jun-2018  msaitoh branches: 1.1333.2;
Regen.
 1.1332 14-Jun-2018  msaitoh Regen.
 1.1331 12-Jun-2018  jdolecek regen
 1.1330 09-Jun-2018  jdolecek regen
 1.1329 31-May-2018  mrg regen.
 1.1328 31-May-2018  msaitoh Regen.
 1.1327 28-May-2018  msaitoh Regen.
 1.1326 26-May-2018  jakllsch regen
 1.1325 24-May-2018  msaitoh Regen.
 1.1324 21-May-2018  jnemeth regen
 1.1323 03-May-2018  maya regen
 1.1322 28-Apr-2018  mlelstv regen
 1.1321 24-Apr-2018  maya regen
 1.1320 17-Apr-2018  nonaka regen
 1.1319 16-Apr-2018  msaitoh Regen.
 1.1318 09-Apr-2018  msaitoh Regen.
 1.1317 09-Apr-2018  msaitoh Regen.
 1.1316 04-Apr-2018  msaitoh Regen.
 1.1315 02-Apr-2018  msaitoh Regen.
 1.1314 31-Mar-2018  sevan regen
 1.1313 26-Mar-2018  msaitoh Regen.
 1.1312 20-Mar-2018  nonaka regen
 1.1311 16-Mar-2018  msaitoh Regen.
 1.1310 04-Mar-2018  jdolecek branches: 1.1310.2;
regen
 1.1309 04-Mar-2018  jdolecek regen
 1.1308 02-Mar-2018  msaitoh Regen.
 1.1307 24-Feb-2018  mlelstv Regen.
 1.1306 22-Feb-2018  msaitoh Regen.
 1.1305 22-Feb-2018  msaitoh Regen.
 1.1304 22-Feb-2018  msaitoh Regen.
 1.1303 22-Feb-2018  msaitoh Regen.
 1.1302 21-Feb-2018  msaitoh Regen.
 1.1301 17-Feb-2018  sevan regen
 1.1300 16-Feb-2018  sevan regen
 1.1299 25-Jan-2018  sborrill regen
 1.1298 24-Jan-2018  sevan regen
 1.1297 21-Jan-2018  sevan regen
 1.1296 09-Jan-2018  msaitoh Regen.
 1.1295 09-Jan-2018  msaitoh Regen.
 1.1294 18-Dec-2017  msaitoh Regen.
 1.1293 09-Nov-2017  msaitoh Regen.
 1.1292 30-Oct-2017  sevan regen
 1.1291 20-Oct-2017  christos regen
 1.1290 15-Sep-2017  hikaru Regen.
 1.1289 17-Aug-2017  msaitoh Regen.
 1.1288 02-Aug-2017  msaitoh regen.
 1.1287 26-Jul-2017  msaitoh Regen.
 1.1286 22-Jul-2017  msaitoh Regen.
 1.1285 07-Jul-2017  msaitoh Regen.
 1.1284 04-Jul-2017  msaitoh Regen.
 1.1283 27-Jun-2017  wiz regen (comment change only)
 1.1282 17-Jun-2017  jdolecek regen
 1.1281 06-Jun-2017  msaitoh Regen.
 1.1280 23-May-2017  nonaka branches: 1.1280.2;
regen
 1.1279 08-May-2017  msaitoh - Add RICOH R5C576 SD Card Controller.
- Add some SiS devices. Taken from OpenBSD.
- Change SiS 0x6325 from 6325 AGP VGA to 650 AGP VGA.
 1.1278 27-Apr-2017  msaitoh regen.
 1.1277 19-Apr-2017  msaitoh branches: 1.1277.2;
regen.
 1.1276 13-Apr-2017  msaitoh regen.
 1.1275 31-Mar-2017  skrll regen
 1.1274 31-Mar-2017  msaitoh regen.
 1.1273 23-Mar-2017  msaitoh regen.
 1.1272 14-Mar-2017  nonaka regen
 1.1271 27-Feb-2017  msaitoh regen.
 1.1270 16-Jan-2017  msaitoh regen.
 1.1269 15-Jan-2017  msaitoh branches: 1.1269.2;
regen.
 1.1268 15-Jan-2017  msaitoh regen.
 1.1267 10-Jan-2017  nonaka regen
 1.1266 27-Dec-2016  msaitoh Regen.
 1.1265 26-Dec-2016  msaitoh Regen.
 1.1264 01-Dec-2016  msaitoh Regen.
 1.1263 23-Nov-2016  christos regen
 1.1262 28-Oct-2016  msaitoh regen.
 1.1261 26-Oct-2016  msaitoh regen.
 1.1260 24-Oct-2016  msaitoh Regen.
 1.1259 20-Oct-2016  msaitoh regen.
 1.1258 19-Oct-2016  msaitoh regen.
 1.1257 04-Oct-2016  kiyohara Regen.
 1.1256 16-Sep-2016  msaitoh regen.
 1.1255 01-Sep-2016  msaitoh regen.
 1.1254 23-Aug-2016  msaitoh regen.
 1.1253 23-Aug-2016  msaitoh regen.
 1.1252 23-Aug-2016  msaitoh regen.
 1.1251 19-Aug-2016  msaitoh regen.
 1.1250 17-Aug-2016  msaitoh regen.
 1.1249 17-Aug-2016  msaitoh regen.
 1.1248 08-Aug-2016  msaitoh regen.
 1.1247 29-Jul-2016  nonaka regen
 1.1246 28-Jul-2016  nonaka regen
 1.1245 06-Jul-2016  christos branches: 1.1245.2;
regen
 1.1244 27-Jun-2016  pgoyette Regen
 1.1243 01-Jun-2016  pgoyette Regen
 1.1242 30-May-2016  nonaka regen
 1.1241 27-Apr-2016  christos regen
 1.1240 26-Apr-2016  msaitoh regen.
 1.1239 12-Feb-2016  mrg regen.
 1.1238 01-Feb-2016  msaitoh Regen.
 1.1237 22-Jan-2016  msaitoh Regen.
 1.1236 01-Dec-2015  msaitoh regen.
 1.1235 01-Dec-2015  msaitoh regen.
 1.1234 16-Nov-2015  msaitoh Regen.
 1.1233 16-Nov-2015  msaitoh Regen.
 1.1232 06-Nov-2015  nonaka regen
 1.1231 22-Oct-2015  msaitoh Regen.
 1.1230 21-Oct-2015  nonaka regen
 1.1229 19-Oct-2015  tnn regen
 1.1228 28-Aug-2015  nonaka regen
 1.1227 27-Aug-2015  nonaka regen
 1.1226 26-Aug-2015  msaitoh regen.
 1.1225 23-Aug-2015  jakllsch pcidevs .h regen
 1.1224 14-Aug-2015  nonaka regen
 1.1223 14-Aug-2015  knakahara regen
 1.1222 13-Aug-2015  msaitoh regen.
 1.1221 26-Jun-2015  msaitoh regen.
 1.1220 02-Jun-2015  nonaka regen
 1.1219 16-May-2015  msaitoh regen.
 1.1218 13-May-2015  nonaka regen
 1.1217 11-May-2015  msaitoh regen.
 1.1216 09-May-2015  christos regen
 1.1215 04-May-2015  ryo regen
 1.1214 03-May-2015  msaitoh regen.
 1.1213 02-Apr-2015  tnn regen
 1.1212 20-Mar-2015  msaitoh regen.
 1.1211 20-Mar-2015  msaitoh regen.
 1.1210 18-Mar-2015  msaitoh regen.
 1.1209 04-Mar-2015  knakahara regen.
 1.1208 15-Feb-2015  msaitoh regen.
 1.1207 25-Jan-2015  msaitoh Regen.
 1.1206 18-Jan-2015  christos regen
 1.1205 16-Jan-2015  msaitoh regen.
 1.1204 14-Jan-2015  msaitoh regen.
 1.1203 31-Dec-2014  veego Regen
 1.1202 23-Dec-2014  msaitoh Regen.
 1.1201 17-Dec-2014  hikaru Regen.
 1.1200 15-Dec-2014  msaitoh Regen.
 1.1199 15-Dec-2014  msaitoh regen.
 1.1198 30-Oct-2014  nonaka branches: 1.1198.2;
regen
 1.1197 29-Oct-2014  nonaka regen
 1.1196 02-Oct-2014  msaitoh Regen.
 1.1195 25-Sep-2014  msaitoh Regen.
 1.1194 21-Sep-2014  christos regen
 1.1193 16-Sep-2014  msaitoh Regen.
 1.1192 01-Sep-2014  msaitoh Regen.
 1.1191 30-Jul-2014  msaitoh branches: 1.1191.2;
regen.
 1.1190 25-Jul-2014  msaitoh Regen.
 1.1189 08-Jul-2014  msaitoh Regen.
 1.1188 03-Jul-2014  msaitoh Regen.
 1.1187 02-Jul-2014  msaitoh Regen.
 1.1186 23-Jun-2014  msaitoh Regen.
 1.1185 09-Jun-2014  msaitoh regen.
 1.1184 30-May-2014  msaitoh Regen.
 1.1183 28-May-2014  msaitoh Regen.
 1.1182 28-May-2014  msaitoh regen.
 1.1181 25-May-2014  njoly Regen for GeForce GT 640M.
 1.1180 26-Apr-2014  mrg regen.
 1.1179 09-Apr-2014  msaitoh regen
 1.1178 09-Apr-2014  msaitoh regen.
 1.1177 07-Apr-2014  njoly Regen for Intel Ivy Bridge PCI Express Root Port.
 1.1176 15-Mar-2014  kiyohara branches: 1.1176.2;
Regen.
 1.1175 14-Feb-2014  njoly Regen for GeForce 210 High Definition Audio Controller.
 1.1174 26-Jan-2014  msaitoh Regen.
 1.1173 21-Jan-2014  msaitoh Regen.
 1.1172 10-Jan-2014  msaitoh regen.
 1.1171 09-Jan-2014  christos regen
 1.1170 09-Jan-2014  msaitoh regen.
 1.1169 04-Jan-2014  msaitoh regen.
 1.1168 01-Jan-2014  msaitoh regen.
 1.1167 30-Dec-2013  msaitoh regen.
 1.1166 27-Dec-2013  msaitoh regen.
 1.1165 25-Dec-2013  msaitoh regen.
 1.1164 23-Dec-2013  msaitoh regen.
 1.1163 22-Dec-2013  nonaka regen
 1.1162 21-Dec-2013  msaitoh regen.
 1.1161 15-Dec-2013  pgoyette Regen
 1.1160 13-Dec-2013  pedro regen
 1.1159 12-Dec-2013  nonaka regen
 1.1158 08-Dec-2013  msaitoh regen.
 1.1157 13-Nov-2013  msaitoh regen.
 1.1156 07-Nov-2013  msaitoh Regen.
 1.1155 07-Nov-2013  msaitoh Add Quark X1000 devices.
 1.1154 07-Nov-2013  msaitoh Regen.
 1.1153 14-Sep-2013  soren Regen.
 1.1152 04-Sep-2013  christos regen
 1.1151 23-Aug-2013  christos regen
 1.1150 17-Jul-2013  soren Regen.
 1.1149 13-Jun-2013  matt branches: 1.1149.2; 1.1149.4;
Regen.
 1.1148 05-Jun-2013  msaitoh regen.
 1.1147 04-Jun-2013  msaitoh regen
 1.1146 03-Jun-2013  msaitoh Regen.
 1.1145 20-Apr-2013  rkujawa Regen PCI devs database.
 1.1144 18-Apr-2013  msaitoh regen.
 1.1143 18-Apr-2013  msaitoh regen.
 1.1142 06-Mar-2013  msaitoh regen.
 1.1141 03-Mar-2013  msaitoh regen.
 1.1140 27-Feb-2013  msaitoh regen.
 1.1139 20-Feb-2013  msaitoh regen.
 1.1138 30-Jan-2013  msaitoh regen.
 1.1137 06-Dec-2012  msaitoh Regen.
 1.1136 05-Dec-2012  christos Regen
 1.1135 29-Nov-2012  msaitoh regen.
 1.1134 21-Oct-2012  matt Regen.
 1.1133 20-Oct-2012  matt Regen.
 1.1132 19-Oct-2012  prlw1 regen
 1.1131 29-Sep-2012  gsutre regen
 1.1130 25-Sep-2012  gson regen
 1.1129 23-Sep-2012  chs regen
 1.1128 18-Sep-2012  matt Regen.
 1.1127 17-Sep-2012  matt Regen.
 1.1126 17-Sep-2012  tsutsui Regen from pcidevs rev 1.1134:
> Add Broadcom BCM57762 Gigabit Ethernet, per PR kern/46961.
 1.1125 13-Sep-2012  nonaka regen.
 1.1124 10-Aug-2012  bouyer branches: 1.1124.2;
Regen: add some PCI AHCI controllers.
 1.1123 07-Aug-2012  msaitoh regen.
 1.1122 06-Aug-2012  msaitoh regen.
 1.1121 05-Aug-2012  msaitoh regen.
 1.1120 05-Aug-2012  bouyer Regen: add MegaRAID SAS2208
 1.1119 27-Jul-2012  matt Regen.
 1.1118 26-Jul-2012  uwe Regen for VirtualBox ids.
 1.1117 25-Jul-2012  msaitoh regen.
 1.1116 23-Jul-2012  msaitoh regen.
 1.1115 22-Jul-2012  matt Regen.
 1.1114 20-Jul-2012  msaitoh regen.
 1.1113 19-Jul-2012  msaitoh regen.
 1.1112 12-Jul-2012  kiyohara Regen.
 1.1111 26-Jun-2012  drochner regen
 1.1110 25-May-2012  msaitoh regen for Intel I350 (wm)
 1.1109 18-Apr-2012  bouyer Regen: Add various newer LSI RAID/SAS controllers
 1.1108 13-Apr-2012  cegger regen.
 1.1107 09-Apr-2012  mlelstv regen
 1.1106 08-Apr-2012  jakllsch regen.
 1.1105 08-Apr-2012  jakllsch regen.
 1.1104 07-Apr-2012  christos regen
 1.1103 04-Apr-2012  uwe Regen for Marvell Yukon 88e8040 ethernet.
 1.1102 28-Mar-2012  pgoyette Regen for JMB362
 1.1101 21-Mar-2012  sborrill Regen
 1.1100 18-Mar-2012  tsutsui Regen from pcidevs rev 1.1106:
> Add VIA VX900 media system processor IDE controller.
> PR/46166 from Hiroshi Tokuda.
 1.1099 03-Mar-2012  nonaka regen.
 1.1098 02-Mar-2012  nonaka regen.
 1.1097 02-Mar-2012  nonaka regen.
 1.1096 15-Feb-2012  tsutsui branches: 1.1096.2;
Regen from pcidevs rev 1.1102:
> Add VIA VX900 Host Bridge, to handle its quirk. PR/46018
> Ok releng@
 1.1095 18-Oct-2011  jmcneill branches: 1.1095.2; 1.1095.6;
regen
 1.1094 06-Oct-2011  jmcneill regen
 1.1093 04-Oct-2011  njoly Regen for 3WARE 9750 Series RAID.
 1.1092 23-Sep-2011  njoly Regen for NVIDIA GeForce 210.
 1.1091 05-Sep-2011  msaitoh regen.
 1.1090 02-Sep-2011  msaitoh regen.
 1.1089 15-Aug-2011  msaitoh regen.
 1.1088 11-Aug-2011  bouyer Regen: add SiS 315 Pro VGA
 1.1087 09-Aug-2011  mbalmer re-gen after PWDOG1 addition.
 1.1086 06-Aug-2011  jakllsch regen
 1.1085 06-Aug-2011  mbalmer re-gen.
 1.1084 04-Aug-2011  jakllsch regen
 1.1083 23-Jul-2011  matt Regen.
 1.1082 28-Jun-2011  sborrill Regen
 1.1081 27-Jun-2011  nonaka regen.
 1.1080 07-Jun-2011  cegger regen.
 1.1079 06-Jun-2011  msaitoh regen.
 1.1078 28-May-2011  phx branches: 1.1078.2;
regen
 1.1077 28-May-2011  phx regen
 1.1076 28-May-2011  ryo Regen.
 1.1075 27-May-2011  matt Regen.
 1.1074 22-May-2011  mrg regenerate.
 1.1073 21-May-2011  msaitoh regen
 1.1072 20-May-2011  msaitoh regen.
 1.1071 15-May-2011  msaitoh regen.
 1.1070 14-May-2011  martin Regen
 1.1069 13-May-2011  msaitoh regen.
 1.1068 02-May-2011  manu Add support for new SUNIX PCI seriel and/or parallel adapters, with new
SUNIX vendor Id 0x1fd4 and product Id 0x1999. Constants were taken from
Linux open source driver distributed by SUNIX.

The following models should be supported now:
5008 1 parallel port
5016 16 serial ports, only 8 supported right now (PUC_MAX_PORTS limit)
5027 1 serial port
5037 2 serial ports
5056 4 serial ports
5066 8 serial ports, this model is the only one that was actually tested.
5069 1 serial port and 1 parallel port
5079 2 serial ports and 1 parallel port
5099 4 serial ports and 1 parallel port
 1.1067 13-Apr-2011  wiz regen (+ ATI Radeon HD4650)
 1.1066 04-Apr-2011  bouyer Regen: Add RDC PCI-ISA bridge
 1.1065 04-Apr-2011  dyoung Regen.
 1.1064 16-Mar-2011  matt regen.
 1.1063 05-Mar-2011  matt Regen.
 1.1062 25-Feb-2011  jmcneill regen
 1.1061 25-Feb-2011  jmcneill regen
 1.1060 24-Feb-2011  matt Regen.
 1.1059 24-Feb-2011  matt Regen.
 1.1058 23-Feb-2011  jmcneill regen
 1.1057 22-Feb-2011  jmcneill regen
 1.1056 21-Feb-2011  njoly Regen: Add two more Intel 82Q45 devices.
 1.1055 20-Feb-2011  msaitoh regen.
 1.1054 18-Feb-2011  jmcneill regen
 1.1053 03-Feb-2011  njoly Regen for Nvidia devices addition.
 1.1052 26-Jan-2011  bouyer Regen: Add RDC Semiconductor R6040 10/100 Ethernet
 1.1051 11-Jan-2011  dyoung branches: 1.1051.2; 1.1051.4;
Regen.
 1.1050 16-Dec-2010  wiz regen.
 1.1049 11-Dec-2010  matt Regen
 1.1048 11-Nov-2010  cegger regen.
 1.1047 06-Nov-2010  jakllsch regen.
 1.1046 14-Oct-2010  taca Regen.
 1.1045 26-Aug-2010  dogcow Regen for BCM43xx update.
 1.1044 01-Aug-2010  msaitoh regen.
 1.1043 30-Jul-2010  njoly Regen for ICH10 devices update.
 1.1042 29-Jul-2010  njoly Regen for Intel LPC updates.
 1.1041 29-Jul-2010  njoly Regen for Matrox MGA G200eW.
 1.1040 28-Jul-2010  msaitoh regen.
 1.1039 13-Jul-2010  msaitoh regen.
 1.1038 13-Jul-2010  kiyohara Regen.
 1.1037 08-Jul-2010  msaitoh regen.
 1.1036 08-Jul-2010  msaitoh regen
 1.1035 07-Jul-2010  msaitoh regen.
 1.1034 06-Jul-2010  msaitoh regen.
 1.1033 06-Jul-2010  msaitoh regen.
 1.1032 02-Jul-2010  mrg regen.
 1.1031 16-Jun-2010  riz Regen for added Intel IDs.
 1.1030 08-Jun-2010  pgoyette Regen
 1.1029 08-Jun-2010  mrg regenerate
 1.1028 15-May-2010  jakllsch Regen.
 1.1027 12-May-2010  christos regen
 1.1026 10-May-2010  matt Regen.
 1.1025 08-May-2010  pgoyette Regen
 1.1024 07-May-2010  kiyohara Regen.
 1.1023 17-Apr-2010  christos regen
 1.1022 02-Apr-2010  jakllsch regen
 1.1021 14-Mar-2010  mrg branches: 1.1021.2;
regenerate
 1.1020 25-Feb-2010  macallan regen
 1.1019 16-Feb-2010  msaitoh regen.
 1.1018 09-Feb-2010  hubertf regen
 1.1017 09-Feb-2010  msaitoh regen.
 1.1016 08-Feb-2010  msaitoh regen.
 1.1015 03-Feb-2010  macallan branches: 1.1015.2;
regen
 1.1014 30-Jan-2010  jakllsch regen.
 1.1013 24-Jan-2010  msaitoh regen.
 1.1012 22-Jan-2010  hubertf regen - thanks for the reminder @ veego
 1.1011 19-Jan-2010  mbalmer regenerate
 1.1010 14-Jan-2010  sborrill Regen
 1.1009 12-Jan-2010  msaitoh regen
 1.1008 12-Jan-2010  nonaka regen (Added RENESAS SH7780/SH7785 PCI Controller.)
 1.1007 11-Jan-2010  msaitoh regen
 1.1006 07-Jan-2010  msaitoh regen
 1.1005 07-Jan-2010  jdc Regenerate for:
Add Sun Cassini/NS Saturn devices.
 1.1004 03-Jan-2010  jnemeth regen
 1.1003 29-Dec-2009  msaitoh regen
 1.1002 30-Nov-2009  sborrill Regen
 1.1001 21-Nov-2009  jakllsch regen.
 1.1000 18-Nov-2009  bouyer Regen: Complete BROADCOM BCM5709 family, and add BCM5716 family.
 1.999 18-Nov-2009  jakllsch regen.
 1.998 13-Oct-2009  cegger regen.
 1.997 13-Oct-2009  cegger regen.
 1.996 05-Oct-2009  cegger regen.
 1.995 20-Sep-2009  christos Regen
 1.994 01-Aug-2009  matt Regen.
 1.993 07-Jul-2009  cegger regen.
 1.992 29-Jun-2009  hubertf regen
 1.991 12-Jun-2009  rjs Regen.
 1.990 11-Jun-2009  cegger regen.
 1.989 29-May-2009  skrll Regen.
 1.988 18-May-2009  skrll Regen
 1.987 13-May-2009  cegger regen.
 1.986 09-May-2009  sborrill regen
 1.985 30-Apr-2009  skrll Regen (again)
 1.984 30-Apr-2009  skrll Regen.
 1.983 28-Apr-2009  ginsbach Regen for Mellanox additions.
 1.982 25-Apr-2009  tsutsui Regen from pcidevs rev 1.983:
> Tweak some Realtek re(4) device names.
 1.981 07-Apr-2009  msaitoh regen
 1.980 10-Mar-2009  msaitoh regen
 1.979 26-Feb-2009  mjf Regen.
 1.978 19-Feb-2009  sborrill Regen
 1.977 11-Feb-2009  markd regen
 1.976 06-Feb-2009  jakllsch branches: 1.976.2;
regen.
 1.975 27-Jan-2009  markd regen
 1.974 19-Jan-2009  jmcneill regen for Attansic L1E Gigabit Ethernet Adapter
 1.973 07-Jan-2009  jnemeth regen
 1.972 27-Dec-2008  tsutsui Regen from pcidevs rev 1.971:
> Fix tyop in previous.
 1.971 27-Dec-2008  jnemeth regen for et (Agere) driver
 1.970 21-Dec-2008  nonaka Regen.
 1.969 16-Dec-2008  christos regen
 1.968 29-Nov-2008  christos regen
 1.967 18-Nov-2008  matt Regen.
 1.966 17-Nov-2008  matt Regen.
 1.965 08-Nov-2008  christos regen.
 1.964 04-Nov-2008  cegger regen.
 1.963 04-Nov-2008  cegger regen.
 1.962 15-Oct-2008  bouyer branches: 1.962.2; 1.962.4;
Regen: fix entry description.
 1.961 15-Oct-2008  bouyer Regen: add more ICH9 ethernet devices.
 1.960 01-Oct-2008  christos regen
 1.959 01-Oct-2008  christos ICH10 support from Brad du Plessis
 1.958 28-Sep-2008  bouyer Regen for JMicron Ethernet Controllers.
 1.957 18-Sep-2008  cegger regen.
 1.956 18-Sep-2008  cegger regen.
 1.955 13-Sep-2008  njoly Regen for Nvidia GeForce 6150 devices addition.
 1.954 08-Sep-2008  cegger regen.
 1.953 08-Sep-2008  cegger regen.
 1.952 06-Sep-2008  rmind Regen.
 1.951 05-Sep-2008  cegger regen.
 1.950 27-Aug-2008  christos regen
 1.949 23-Aug-2008  tsutsui Regen from pcidevs rev 1.949:
> - add a Realtek 8139D variant (from FreeBSD)
> - remove a duplicated entry of Realtek 0x8138
 1.948 22-Aug-2008  tnn regen (Intel 945GME)
 1.947 19-Aug-2008  matthias Regen.
 1.946 19-Aug-2008  matthias Regen.
 1.945 06-Aug-2008  dyoung Regen.
 1.944 29-Jul-2008  tron Regen.
 1.943 15-Jul-2008  tonnerre Regen.
 1.942 25-May-2008  chs branches: 1.942.2; 1.942.4;
regen
 1.941 20-May-2008  cegger regen.
 1.940 13-May-2008  rjs Regen.
 1.939 08-May-2008  sborrill Regen
 1.938 30-Apr-2008  joerg branches: 1.938.2;
Regen.
 1.937 17-Apr-2008  christos branches: 1.937.2; 1.937.4;
regen
 1.936 15-Apr-2008  cegger regen.
 1.935 09-Apr-2008  joerg Regen.
 1.934 03-Apr-2008  riz Regen.
 1.933 01-Apr-2008  cegger regen.
 1.932 26-Mar-2008  jmcneill Regen for PR#38301
 1.931 24-Feb-2008  xtraeme regen
 1.930 22-Feb-2008  tsutsui Regen from pcidevs rev 1.930:
> Add I-O DATA RSA-PCI 2 port serial board.
 1.929 13-Feb-2008  tron branches: 1.929.2; 1.929.6;
Regen.
 1.928 10-Feb-2008  ichiro regen
 1.927 05-Feb-2008  ichiro regen
 1.926 11-Jan-2008  tnn regen (add ServeRAID 6/7)
 1.925 11-Jan-2008  ragge Regen
 1.924 03-Jan-2008  jnemeth regen -- Symbios Logic 0x0030 is used for both 53c1020/53c1030 from Dave Huang
 1.923 30-Dec-2007  jdc Regenerate for "Add Apple Shasta GMAC (From FreeBSD)".
 1.922 28-Dec-2007  dholland Regen.
 1.921 24-Dec-2007  hamajima regen.
 1.920 09-Dec-2007  jmcneill branches: 1.920.2;
Merge jmcneill-pm branch.
 1.919 26-Nov-2007  bjs branches: 1.919.2; 1.919.4;
Add PCI IDs for the ATI Radeon X800 GTO (R430). Most sources I have
consulted indicated that this ID is an R430 (including xf86-video-ati).

PCI_PRODUCT_ATI_RADEON_R430_554F (primary)
PCI_PRODUCT_ATI_RADEON_R430_556F (secondary)

vga0 at pci1 dev 0 function 0: ATI Technologies product 0x554f (rev. 0x00)
ATI Technologies product 0x556f (miscellaneous display) at pci1 dev 0 function 1 not configured
 1.918 24-Nov-2007  markd regen.
 1.917 23-Nov-2007  xtraeme regen
 1.916 19-Nov-2007  ad Regen.
 1.915 15-Nov-2007  manu Regen
 1.914 14-Nov-2007  xtraeme regen
 1.913 12-Nov-2007  joerg Regen.
 1.912 30-Oct-2007  xtraeme branches: 1.912.2;
regen
 1.911 30-Oct-2007  xtraeme regen
 1.910 30-Oct-2007  xtraeme regen
 1.909 30-Oct-2007  jnemeth regen
 1.908 24-Oct-2007  xtraeme regen
 1.907 22-Oct-2007  manu Regen
 1.906 22-Oct-2007  manu Add support for Marvell 88CO55. Newer iMacs come with that chip.
 1.905 22-Oct-2007  nisimura regen
 1.904 14-Oct-2007  xtraeme branches: 1.904.2;
regen
 1.903 09-Oct-2007  garbled Add a bunch of IBM PCI dev id's for graphics cards and PCI bridges
 1.902 20-Sep-2007  xtraeme branches: 1.902.2;
regen
 1.901 17-Sep-2007  msaitoh regen
 1.900 11-Sep-2007  jnemeth regen
 1.899 09-Sep-2007  xtraeme regen
 1.898 08-Sep-2007  ober regen. added Intel Pro/Wifi 4965AGN
 1.897 07-Sep-2007  cube Regen.
 1.896 02-Sep-2007  ober regen. added Intel LPC 82801HEM and 82801IO
 1.895 01-Sep-2007  ober *** empty log message ***
 1.894 31-Aug-2007  xtraeme regen
 1.893 30-Aug-2007  xtraeme regen
 1.892 28-Aug-2007  msaitoh regen
 1.891 26-Aug-2007  xtraeme branches: 1.891.2;
regen
 1.890 19-Aug-2007  riz Regen.
 1.889 14-Aug-2007  jnemeth regen
 1.888 11-Aug-2007  jnemeth regem
 1.887 08-Aug-2007  tron Regen.
 1.886 06-Aug-2007  martin branches: 1.886.2;
regen
 1.885 04-Aug-2007  kiyohara Regen.
 1.884 07-Jul-2007  jklos branches: 1.884.2; 1.884.6;
Added Chelsio vendor and various Chelsio hardware.
 1.883 06-Jul-2007  hpeyerl regen
 1.882 27-Jun-2007  xtraeme regen
 1.881 26-Jun-2007  xtraeme regen
 1.880 28-May-2007  mrg regenerate.
 1.879 19-May-2007  tsutsui Regen from pcidevs rev 1.880:
> Add IBM GXT250P video.
 1.878 16-May-2007  mrg regenerate
 1.877 02-May-2007  bouyer Regen: added JMicron Technology products
 1.876 29-Apr-2007  bouyer Regen: remove extra "Intel" from previous commit.
 1.875 29-Apr-2007  bouyer Regen: add Intel i82801H IFE G/GT LAN Controller
 1.874 27-Mar-2007  pooka regen
 1.873 25-Mar-2007  isaki Regen; ATI ES1000.
 1.872 17-Mar-2007  dyoung Regen.
 1.871 10-Mar-2007  christos branches: 1.871.2; 1.871.4;
regen
 1.870 09-Mar-2007  xtraeme branches: 1.870.2;
regen
 1.869 03-Mar-2007  jmcneill Regen.
 1.868 01-Mar-2007  jmcneill Regen.
 1.867 16-Feb-2007  markd branches: 1.867.2;
regen for i965Q
 1.866 10-Feb-2007  mlelstv Get the correct RCS-Id pulled in
 1.865 10-Feb-2007  mlelstv Add support for VT8237A/VT82C586A PCI-ISA-Bridge
Fixes PR kern/35314
 1.864 30-Jan-2007  msaitoh regen
 1.863 28-Jan-2007  chs regen
 1.862 27-Jan-2007  isaki Regen.
 1.861 21-Jan-2007  isaki Regen; AMD Geode LX and CS5536.
 1.860 14-Jan-2007  rpaulo regen
 1.859 06-Jan-2007  jmcneill Regen.
 1.858 04-Jan-2007  jmcneill Regen.
 1.857 04-Jan-2007  jmcneill Regen.
 1.856 31-Dec-2006  ichiro regen
 1.855 10-Dec-2006  bouyer Regen: another PCI id for Dell PERC 5
 1.854 09-Dec-2006  manu Add support for 4 and 8 ports modem boards from Perle systems
 1.853 26-Nov-2006  tsutsui branches: 1.853.2;
Regen from pcidevs rev 1.855:
> - add more Broadcom product IDs, and fix two alternative IDs
> (from FreeBSD and OpenBSD)
> - sort by product ID
 1.852 26-Nov-2006  enami Regen.
 1.851 18-Nov-2006  tsutsui Regen from pcidevs rev 1.853:
> Add an ID of Broadcom BCM5752M. From Matt Kolb on tech-kern.
 1.850 18-Nov-2006  tsutsui Regen from pcidevs rev 1.852:
> - add Realtek RTL8100 (from FreeBSD)
> - fix entry of RTL8169SC
> - remove vague comment in Realtek entry
 1.849 18-Nov-2006  tsutsui Regen from pcidevs rev 1.851:
> Add and note more Realtek Ethernet chips.
 1.848 13-Nov-2006  xtraeme regen
 1.847 13-Nov-2006  bouyer Regen: add NetMos 9855 Quad UART and 1284 Printer port
 1.846 08-Nov-2006  rpaulo regen
 1.845 08-Nov-2006  martti Regenerated.
 1.844 07-Nov-2006  martti Regenerated.
 1.843 03-Nov-2006  abs Regenerate after adding Broadcom BCM5754 (0x167a)
 1.842 31-Oct-2006  manu regen
 1.841 25-Oct-2006  bouyer Regen: Add VIA VT8237A Integrated SATA Controller
 1.840 23-Oct-2006  rjs Regen.
 1.839 21-Oct-2006  bouyer Regen: added some Intel gigabit ethernet products
 1.838 09-Oct-2006  cube Regen.
 1.837 02-Oct-2006  cube Regen (fix pasto).
 1.836 02-Oct-2006  cube Regen (MCP55 ISA brige).
 1.835 29-Sep-2006  cube Regen.
 1.834 27-Sep-2006  cube Regen (Intel/0x1094).
 1.833 27-Sep-2006  sketch Regenerate for TI ACX changes.
 1.832 26-Sep-2006  heas Regen for pcidevs 1.833
 1.831 24-Sep-2006  briggs Regen with new IDs for devices in the last-generation Apple PowerBook G4.
 1.830 07-Sep-2006  riz branches: 1.830.2;
Regen.
 1.829 07-Sep-2006  itohy branches: 1.829.2;
Regen from pcidevs rev 1.830.
 1.828 03-Sep-2006  xtraeme regen
 1.827 03-Sep-2006  xtraeme regen
 1.826 03-Sep-2006  xtraeme regen
 1.825 03-Sep-2006  xtraeme regen
 1.824 03-Sep-2006  xtraeme regen
 1.823 03-Sep-2006  xtraeme regen
 1.822 27-Aug-2006  christos Regen
 1.821 24-Aug-2006  riz Regen (Marvell product IDs)
 1.820 23-Aug-2006  cube Regen (Broadcom NetXtreme II).
 1.819 22-Aug-2006  riz Regen for GALILEO -> MARVELL
 1.818 13-Aug-2006  dsainty Regen: Add the Promise PDC20771, present on the Promise FastTrak TX2300
 1.817 10-Aug-2006  simonb Regen.
 1.816 09-Aug-2006  jnemeth regen for Token Ring additions
 1.815 08-Aug-2006  cube Regen (Intel 63xxESB devices).
 1.814 06-Aug-2006  jmcneill branches: 1.814.2;
Regen.
 1.813 03-Aug-2006  bsh regen
 1.812 01-Aug-2006  xtraeme regen
 1.811 01-Aug-2006  bsh regen
 1.810 30-Jul-2006  jmcneill regen
 1.809 30-Jul-2006  oster Regen
 1.808 30-Jul-2006  simonb Regen.
 1.807 21-Jul-2006  gdamore Regen.
 1.806 21-Jul-2006  gdamore Update ADMtek pci device ids to match data sheets. While here, add the 9513
device (although I've never seen one, I have a datasheet for it. :-)
 1.805 18-Jul-2006  itohy Regen from pcidevs rev 1.807.
 1.804 13-Jul-2006  kent regen for VT82xx HDA
 1.803 07-Jul-2006  simonb Regen.
 1.802 30-Jun-2006  nisimura Regen after Micrel KSZ8842/8841 product addtion.
 1.801 30-Jun-2006  xtraeme regen
 1.800 30-Jun-2006  xtraeme regen
 1.799 27-Jun-2006  kent regen for NVIDA MCP55_HDA
 1.798 26-Jun-2006  xtraeme regen
 1.797 26-Jun-2006  xtraeme regen
 1.796 25-Jun-2006  soren Regen.
 1.795 18-Jun-2006  christos Regen
 1.794 18-Jun-2006  xtraeme regen
 1.793 15-Jun-2006  heinz Regen (LSI SAS, parallel SCSI and FC devices).
 1.792 14-Jun-2006  grant branches: 1.792.2;
regen.
 1.791 06-Jun-2006  rpaulo regen
 1.790 05-Jun-2006  martin Regen (DWL-610 added)
 1.789 05-Jun-2006  msaitoh regen
 1.788 31-May-2006  riz Regen.
 1.787 19-May-2006  markd branches: 1.787.2;
regen
 1.786 30-Apr-2006  xtraeme regen
 1.785 30-Apr-2006  xtraeme regen
 1.784 29-Apr-2006  gdamore Regen.
 1.783 25-Apr-2006  wrstuden Regen to catch change for 3ware cards.
 1.782 20-Apr-2006  gdamore Regen.
 1.781 15-Apr-2006  jmcneill Regen.
 1.780 06-Apr-2006  simonb Regen.
 1.779 05-Apr-2006  nonaka Regen.
 1.778 26-Mar-2006  jonathan Regen pcidevs{,_data}.h from pcidevs rev 1.778 (fixes cut-and-paste typo
in description of bcm5780S).
 1.777 25-Mar-2006  rpaulo regen
 1.776 21-Mar-2006  he Regenerated files after adding IDs for HP/Compaq Smart Array controllers.
 1.775 12-Mar-2006  chs branches: 1.775.2;
regen
 1.774 09-Mar-2006  he Commit regenerated files after adding Nortel Baystack 21 info.
 1.773 09-Mar-2006  hamajima Regen: Add EXAR devices, and fix duplicated NVIDIA product id 0x0057.
 1.772 07-Mar-2006  bouyer Regen: added more serverwork SATA controllers.
 1.771 07-Mar-2006  bouyer branches: 1.771.2;
Regen for serverworks K2 SATA addition.
 1.770 06-Mar-2006  martin Regen (MOXA devices added)
 1.769 01-Mar-2006  dogcow branches: 1.769.2;
add a bunch of Nvidia nForce ethernet IDs (via OpenBSD.)
 1.768 28-Feb-2006  gdamore Regen.
 1.767 21-Feb-2006  chuck regen.
 1.766 16-Feb-2006  kochi regen.
 1.765 12-Feb-2006  tron Regen.
 1.764 12-Feb-2006  tron Regen.
 1.763 12-Feb-2006  tron Regen.
 1.762 07-Feb-2006  cube Regen, correctly this time. Sorry for the mess.
 1.761 07-Feb-2006  xtraeme regen
 1.760 06-Feb-2006  abs regen to add SIS 190 ethernet, as found in ASUS T2-AE1
 1.759 02-Feb-2006  christos branches: 1.759.2;
regen
 1.758 26-Jan-2006  bouyer branches: 1.758.2;
Regen: Add Promise PDC2057x
 1.757 16-Jan-2006  christos regen
 1.756 10-Jan-2006  christos Regen
 1.755 02-Jan-2006  manu regen
 1.754 02-Jan-2006  tron Regen.
 1.753 02-Jan-2006  tron Regen.
 1.752 01-Jan-2006  xtraeme regen
 1.751 29-Dec-2005  silke branches: 1.751.2;
Regen from revision 1.751 of pcidevs.
 1.750 29-Dec-2005  jonathan Regen from src/sys/dev/pci/pcidevs rev 1.751, which adds an entry for
the integral PCIe-to-PCIX bridge found in broadcom 5714/5715
PCI-Express dual-port gigabit ethernet chips.
 1.749 19-Dec-2005  jonathan Regem from src/sys/dev/pci/pcidevs rev 1.750, adding an entry for SK
PCi-Express gigabit ethernet boards based on Marvell's Yukon-2 chipset.
 1.748 19-Dec-2005  jonathan regen after sys/dev/pci/pcidevs 1.749 (addition of SiI 3124)
 1.747 18-Dec-2005  sekiya Regen.
 1.746 11-Dec-2005  jonathan Regen after pcidevs rev 1.746, 1.747 (Add device IDs for LSI Megaraid,
and Intel IDs for software-compatible Intel RAID products).
 1.745 10-Dec-2005  jonathan regen from pcidevs rev.1.745 with IDs for broadcom bcm5714, bcm5715, bcm5780.
 1.744 09-Dec-2005  xtraeme regen
 1.743 08-Dec-2005  xtraeme regen
 1.742 07-Dec-2005  jonathan regen from sys/dev/pci/pcidevs rev 1.742 (add bcm5714 et al.).
 1.741 06-Dec-2005  fvdl Regen for BCM5789.
 1.740 04-Dec-2005  christos Regen.
 1.739 04-Dec-2005  christos Regen.
 1.738 27-Nov-2005  jdolecek regen - 3ware ATA RAID description/ID fixes
 1.737 22-Nov-2005  rpaulo regen
 1.736 18-Nov-2005  rpaulo regen
 1.735 18-Nov-2005  rpaulo regen
 1.734 01-Nov-2005  abs branches: 1.734.2;
Regen after adding Radeon 9000 PCI (0x4966)
 1.733 05-Oct-2005  jonathan branches: 1.733.2;
Regen with PCI ids for Intel pro/1000 PT pci-e gigabit ethernet.
 1.732 04-Sep-2005  tron Regen.
 1.731 21-Aug-2005  chs regen
 1.730 21-Aug-2005  gavan regen
 1.729 30-Jul-2005  grant regen
 1.728 30-Jul-2005  grant regen
 1.727 29-Jul-2005  cube Regen.
 1.726 25-Jul-2005  christos regen.
 1.725 01-Jul-2005  drochner branches: 1.725.2;
regen
 1.724 01-Jul-2005  augustss Regen.
 1.723 28-Jun-2005  thorpej Regen -- static'ify pci_vendors[] and pci_products[]
 1.722 26-Jun-2005  seb Regen.
 1.721 24-Jun-2005  seb Regen.
 1.720 20-Jun-2005  briggs Regen.
 1.719 19-Jun-2005  chs regen
 1.718 15-Jun-2005  bouyer Regen: add Intel 82801FBM Serial ATA Controller.
 1.717 14-Jun-2005  bouyer Regen: add SiS 965.
 1.716 13-Jun-2005  tron Regen.
 1.715 13-Jun-2005  nonaka Regen.
 1.714 13-Jun-2005  nonaka Regen.
 1.713 07-Jun-2005  skrll Regen.
 1.712 28-May-2005  kent regen
 1.711 27-May-2005  augustss Regen.
 1.710 18-May-2005  riz Regen.
 1.709 12-May-2005  cube Regen
 1.708 09-May-2005  martin Regen
 1.707 04-May-2005  cube Regen.
 1.706 02-May-2005  rh regen
 1.705 20-Apr-2005  bouyer Regen for "Compaq Netelligent 10 T/2 PCI UTP/Coax Controller".
 1.704 06-Apr-2005  martti Regen for Dell CERC SATA RAID 1.5/6ch
 1.703 24-Mar-2005  tron Regen.
 1.702 19-Mar-2005  tron Regen.
 1.701 19-Mar-2005  tron Regen.
 1.700 16-Mar-2005  xtraeme branches: 1.700.2;
regen
 1.699 16-Mar-2005  uwe Regen for ATI Radeon 9100 IGP chipset.
 1.698 15-Mar-2005  xtraeme regen
 1.697 15-Mar-2005  xtraeme regen
 1.696 15-Mar-2005  uwe Regen for ENE CB710, CB720 CardBus controllers.
 1.695 07-Mar-2005  christos Regen
 1.694 27-Feb-2005  perry regen
 1.693 20-Feb-2005  jdolecek regen: change the VIATECH VT61XX to VT612X
 1.692 02-Feb-2005  christos Regen
 1.691 02-Feb-2005  abs Regen to pick up corrected code for VIA VT6421
 1.690 01-Feb-2005  abs regen to pick up the 'VT642 SATA RAID Controller'.
 1.689 27-Jan-2005  jdolecek regen: add id for nForce2 Ultra 400 audio
 1.688 27-Jan-2005  kent regenerate for nForce 4 devices
 1.687 25-Jan-2005  matt branches: 1.687.2;
Regen.
 1.686 23-Jan-2005  fredb Regen.
 1.685 18-Jan-2005  tsubai Regen.
 1.684 15-Jan-2005  skrll branches: 1.684.2;
Regen.
 1.683 15-Jan-2005  jdolecek regen: Fix Geforce 6800GT entry
 1.682 15-Jan-2005  jdolecek regen: add bunch of NVIDIA GeForce 6800 devices
 1.681 15-Jan-2005  jdolecek regen: use full 'nForce2 Ultra 400' tag for the NFORCE2_400* enties
 1.680 13-Jan-2005  jdolecek regen: add bunch of NVIDIA nForce2 Ultra 400 chipset devices
 1.679 13-Jan-2005  jdolecek regen: VIA Velocity
 1.678 08-Jan-2005  fredb Regen.
 1.677 08-Jan-2005  ginsbach regen
 1.676 06-Jan-2005  he Regen after adding entry for LSI Logic FC919X.
 1.675 27-Dec-2004  reinoud Update generated files from pcidevs (ENE update)
 1.674 18-Dec-2004  xtraeme regen
 1.673 16-Dec-2004  heas Add entry for the Radeon Mobility T2.
 1.672 11-Dec-2004  reinoud Add ATI IXP audio controllers
 1.671 07-Dec-2004  jdarrow Regen from pcidevs 1.672:
Add a new vendor and product ID for a cardbus NIC I've got
Belkin 0x1799
F5D6020v3 0x6020
 1.670 06-Dec-2004  cube Regen (ATI IXP IDE).
 1.669 05-Dec-2004  bouyer Regen: Cleanup in VIA chipset names. From Lloyd Parkes in kern/15466.
 1.668 30-Nov-2004  grant regen
 1.667 22-Nov-2004  rumble regen
 1.666 19-Nov-2004  tacha regen.
 1.665 17-Nov-2004  jdarrow Regen from pcidevs 1.666 (add two wireless cards)
 1.664 17-Nov-2004  junyoung Regen.
 1.663 16-Nov-2004  skrll Regen
 1.662 14-Nov-2004  soren Regen.
 1.661 06-Nov-2004  xtraeme Regen for:

Add Nvidia nForce3 250 chipset products, from Kouichirou Hiratsuka
in PR 27843.
 1.660 28-Oct-2004  martti Regen for Dell PERC 4/SC
 1.659 26-Oct-2004  augustss Regen.
 1.658 22-Oct-2004  cube Regen.
 1.657 20-Oct-2004  martti Regen for DELL PERC 4e/Si
 1.656 13-Oct-2004  augustss Regen.
 1.655 13-Oct-2004  drochner regen
 1.654 11-Oct-2004  jmmv Regen after addition of ATI Technologies Radeon 9200SE Secondary identifier.
 1.653 05-Oct-2004  augustss Regen.
 1.652 30-Sep-2004  cube Regen.
 1.651 18-Sep-2004  martin Regen (FC929X added)
 1.650 17-Sep-2004  xtraeme Regen for GeForce FX 5700 LE.
 1.649 17-Sep-2004  xtraeme Add GeForceFX 5700 LE and regen.
 1.648 16-Sep-2004  ragge Regen.
 1.647 10-Sep-2004  darrenr Regen'd to add Sierra Wireless AirCard 580
 1.646 26-Aug-2004  itohy Regen from pcidevs rev 1.647.
 1.645 05-Aug-2004  mycroft Regen.
 1.644 05-Aug-2004  cube Regen.
 1.643 04-Aug-2004  mycroft Regen.
 1.642 04-Aug-2004  mycroft Regen.
 1.641 04-Aug-2004  mycroft Regen.
 1.640 02-Aug-2004  mycroft Regen.
 1.639 02-Aug-2004  mycroft Regen.
 1.638 02-Aug-2004  mycroft Regen.
 1.637 02-Aug-2004  mycroft Regen.
 1.636 29-Jul-2004  cube Regen.
 1.635 27-Jul-2004  christos regen
 1.634 27-Jul-2004  rumble regen.
 1.633 25-Jul-2004  christos regen
 1.632 21-Jul-2004  mycroft Regen.
 1.631 17-Jul-2004  mycroft Regen.
 1.630 15-Jul-2004  junyoung Regen for 3c920B-EMB-WNM Integrated Fast Ethernet.
 1.629 05-Jul-2004  mycroft Regen.
 1.628 04-Jul-2004  wiz regen from pcidevs, so that this file has the correct CVS Id.
 1.627 04-Jul-2004  mycroft Update Serverworks chip IDs, per:
http://www.plasma-online.de/english/identify/picture/serverworks.html
This seems remarkably more sane.
 1.626 15-Jun-2004  bouyer Regen for pcidevs 1.628: Add the Netelligent 10/100 TX variant found on the
Compaq Proliant Professional Workstation 5100.
 1.625 27-May-2004  christos Regen
 1.624 27-May-2004  abs regen from pcidevs 1.626: Add ALI 'M5257 PCI Software Modem'
 1.623 12-May-2004  tron Regen for PR kern/25166.
 1.622 11-May-2004  thorpej Regen: Add i6300ESB IDE / SATA controller PCI IDs.
 1.621 10-May-2004  lukem regen for: add Nvidia GeForce4 Ti 4200 Go AGP 8x (0x286)
 1.620 10-May-2004  gendalia regen (Add support for Adaptec AAR 2810SA raid controller.)
 1.619 07-May-2004  sekiya regen.
 1.618 22-Apr-2004  skd regen.
 1.617 17-Apr-2004  matt Regen.
 1.616 03-Apr-2004  martti Added another SB Live! 5.1 soundcard and joystick version
 1.615 03-Apr-2004  mycroft Add RealTek RT8180.
 1.614 01-Apr-2004  tron Regen from "pcidevs".
 1.613 26-Mar-2004  gendalia branches: 1.613.2;
regen for Adaptect 2200S (Vulcan 2M) / Dell PERC 320/DC
 1.612 25-Mar-2004  drochner regen
 1.611 12-Mar-2004  drochner regen
 1.610 03-Mar-2004  gavan Add Creative Labs SB Audigy LS
 1.609 26-Feb-2004  drochner regen
 1.608 28-Jan-2004  chs regen
 1.607 26-Jan-2004  blymn Added note for updating these files.
 1.606 26-Jan-2004  blymn Regen with correct rcs id.
 1.605 26-Jan-2004  blymn Add amd8151 agp bridge id.
 1.604 19-Jan-2004  ragge Err, get correct RCS IDs. As Love said.
 1.603 19-Jan-2004  ragge Add "Intel PRO/10GbE LR Server Adapter". Regen.
 1.602 06-Jan-2004  matt Regen.
 1.601 05-Jan-2004  matt Regen.
 1.600 20-Dec-2003  thorpej Regen: Add product ID for the SiI 3124 SATALink.
 1.599 19-Dec-2003  thorpej Regen: Add product ID for the Silicon Image 3114 SATALink.
 1.598 17-Dec-2003  tls Add support for some more Marvell-based adapters to the sk driver:

D-Link DGE-530T
Linksys EG1032v2
Linksys EG1064v2

The Linux driver treats all of these the same. Tested with a DGE-530T;
it works, though performance on at least one of my systems is atrocious.

Fix setting of ethernet capabilities into interface capabilites word in
attach routine.

Manual page: note that jumbo support doesn't work and checksum support
doesn't exist.
 1.597 14-Dec-2003  tsutsui Regen: added ATI Radeon 9200SE.
 1.596 09-Dec-2003  ad Regen.
 1.595 08-Dec-2003  pooka regen for broadcom 5703a3
 1.594 08-Dec-2003  scw Regen
 1.593 06-Dec-2003  jdolecek regen:
add NetMos NM9805 and NM9815
 1.592 05-Dec-2003  grant regen
 1.591 28-Nov-2003  chs regen
 1.590 28-Nov-2003  cube Regen.
 1.589 26-Nov-2003  matt Regen.
 1.588 22-Nov-2003  fvdl Regenerate after rearranging the Promise ids.
 1.587 03-Nov-2003  cube Regen.
 1.586 25-Oct-2003  chs regen
 1.585 23-Oct-2003  fvdl Regen.
 1.584 23-Oct-2003  briggs Regenerate for ENE Cardbus product IDs.
 1.583 22-Oct-2003  fvdl Regen.
 1.582 18-Oct-2003  matt Regen.
 1.581 18-Oct-2003  lukem regen for more ServerWorks devices
 1.580 15-Oct-2003  itojun regen
 1.579 14-Oct-2003  martti Regen: Dell PERC 4/Di
 1.578 10-Oct-2003  thorpej Regen: Add several more Intel Gig-E product IDs.
 1.577 08-Oct-2003  jonathan Regen from pcidevs rev 1.581 with Hifn 7954/5 and 7956.
 1.576 26-Sep-2003  matt Regen.
 1.575 25-Sep-2003  joda regen
 1.574 21-Sep-2003  nisimura Regen.
 1.573 21-Sep-2003  nisimura Regen to fix the company name.
 1.572 15-Sep-2003  bouyer Regen: rename VT8237_RAID to VT8237_SATA
 1.571 13-Sep-2003  jdolecek regen - fix description of one Intel PRO/100 VM variant, as reported
by Lars Heidieker on current-users@
 1.570 28-Aug-2003  thorpej Regen; spell Hifn correctly, add more Hifn products.
 1.569 27-Aug-2003  kleink Regen.
 1.568 26-Aug-2003  jdolecek regen: add SysKonnect 9821
 1.567 26-Aug-2003  tron Regen.
 1.566 23-Aug-2003  dogcow regen (add VIA VT6105)
 1.565 20-Aug-2003  jonathan regen from pcidevs 1.567 with fix for typo in bcm5823 product-id.
 1.564 17-Aug-2003  chs regen
 1.563 17-Aug-2003  bouyer Regen: Add 3com 3c940 Gigabit Ethernet, and VIA KT600 PCI devices.
 1.562 14-Aug-2003  itojun regen
 1.561 07-Aug-2003  wiz regen (fix ID of Radeon 9100 Secondary)
 1.560 01-Aug-2003  wiz regen (avoid duplicate definition, PR 22331)
 1.559 01-Aug-2003  jonathan regen from pcidevs rev 560 (adding Sun's bcm582x-compatible crypto accelerators)
 1.558 29-Jul-2003  thorpej Regen: Add the product ID used for the i82546EB chips present on the
Intel PRO/1000 MT Quad Port Server Adapter.
 1.557 29-Jul-2003  martin Regen.
 1.556 27-Jul-2003  jonathan regen from pcidevs rev 1.556 with vendor Cavium and product Nitrox.
 1.555 27-Jul-2003  jonathan Regen from pcidevs 1.555 (Bluesteel,Broadcom security coprocessors)
 1.554 23-Jul-2003  kleink Regen from 1.554.
 1.553 17-Jul-2003  hannken Regen.
 1.552 17-Jul-2003  hannken Add support for the BCM5705:
- Only BCM5705M asic rev A1 was tested.

Thanks to Bill Paul (wpaul@freebsd.org) for help and support.

Approved by: Frank van der Linden <fvdl@netbsd.org>
 1.551 14-Jul-2003  jmmv Regen (+ ATI Radeon 9200)
 1.550 14-Jul-2003  wiz regen (+MGA G550).
 1.549 12-Jul-2003  hubertf Regen for Toshiba SD and SM cards
 1.548 06-Jul-2003  dyoung Add driver atw for PCI/Mini-PCI/Cardbus 802.11b NICs based on the
ADMtek ADM8211. Read the man page for bugs and other outstanding
issues.
 1.547 06-Jul-2003  simonb Regen: Trailing white-space and TABs nits.
 1.546 06-Jul-2003  simonb Regen; E7500 and E7505 updates.
 1.545 06-Jul-2003  tron Regen.
 1.544 06-Jul-2003  simonb Regen: Add an entry for the Intel E7505 Chipset Memory Controller Hub.
 1.543 06-Jul-2003  tron Regen.
 1.542 06-Jul-2003  tron Regen.
 1.541 28-Jun-2003  bouyer branches: 1.541.2;
Regen: some more Intel devices.
 1.540 27-Jun-2003  christos Regen
 1.539 27-Jun-2003  drochner regen
 1.538 26-Jun-2003  ichiro regen.
 1.537 14-Jun-2003  ichiro regen.
 1.536 13-Jun-2003  kent Regen
 1.535 08-Jun-2003  ichiro regen.
 1.534 07-Jun-2003  wiz regen (Add some Brooktree device IDs).
 1.533 07-Jun-2003  wiz regen (+ATI 9100, 9600TX, 9500/9700)
 1.532 07-Jun-2003  ichiro regen.
 1.531 07-Jun-2003  ichiro regen.
 1.530 07-Jun-2003  ichiro regen.
 1.529 28-Apr-2003  haya Regenerate for pcidevs 1.529 and 1.530 changes.
 1.528 24-Apr-2003  nathanw Regen.
 1.527 22-Apr-2003  fvdl Regenerated after AMD 8131 additions.
 1.526 15-Apr-2003  augustss Regen.
 1.525 15-Apr-2003  rjs Regen.
 1.524 13-Apr-2003  explorer typo, s/TX4/TX2/
 1.523 12-Apr-2003  explorer add an older pci id for SATA150TX2PLUS, too
 1.522 12-Apr-2003  christos regen
 1.521 11-Apr-2003  explorer add Promise ATA/150 TX4 id
 1.520 05-Apr-2003  lha Regenerate.
(add Radeon Mobility M7 LW (AGP))
 1.519 03-Apr-2003  kent regen
 1.518 29-Mar-2003  jdc Regenerate.
(Add support for USRobotics Wireless Access PCI adapter (model 132415).)
 1.517 25-Mar-2003  tsubai Regen.
 1.516 20-Mar-2003  thorpej Regen; add more LSI MPT IDs.
 1.515 18-Mar-2003  thorpej Regen; added Silicon Image SATALink 3112.
 1.514 13-Mar-2003  joda regen: more nvidia devices
 1.513 06-Mar-2003  bouyer Regen: Remove duplicate in previous.
 1.512 06-Mar-2003  bouyer Regen: Add several SiS host bridges, from FreeBSD.
 1.511 03-Mar-2003  soren Regen.
 1.510 02-Mar-2003  salo Regen.
 1.509 28-Feb-2003  enami Regen.
 1.508 26-Feb-2003  salo Regen.
 1.507 18-Feb-2003  grant regen
 1.506 03-Feb-2003  pooka regen
 1.505 03-Feb-2003  joda regen
 1.504 02-Feb-2003  bouyer Regen: add SiS 651 host bridge.
 1.503 01-Feb-2003  matt Regen.
 1.502 24-Jan-2003  thorpej Regen; Tweak a Promise description.
 1.501 24-Jan-2003  thorpej Regen; add some more Promise products.
 1.500 24-Jan-2003  thorpej Regen; add Nvidia nForce2 ATA133 IDE.
 1.499 17-Jan-2003  jonathan regen from pcidevs rev 1.497:
Add pcidevs entries for more Broadcom 570x family variants.
 1.498 16-Jan-2003  gendalia regen after pcidevs is committed so the correct version number is embedded.
Thanks to wiz.
 1.497 16-Jan-2003  gendalia Add 3com 3c905CX-TX and Nvidia nForce2 MCP-T ac-97, on the ASUS A7N8X Deluxe
motherboard, Chipset: NVIDIA nForce2 MCP-T
 1.496 10-Jan-2003  augustss Regen.
 1.495 30-Dec-2002  explorer update
 1.494 26-Dec-2002  matt Regen.
 1.493 26-Dec-2002  matt Regen.
 1.492 11-Dec-2002  jdolecek regen: add Madge Networks Smart 16/4 PCI Ringnode Mk2 entry
 1.491 03-Dec-2002  explorer add Ricoh 5C552 Cardbus + Firewire product ID
 1.490 26-Nov-2002  thorpej Regen: Add IBM 133 PCI-X Bridge.
 1.489 26-Nov-2002  thorpej Regen: Add Intel i80321 I/O Processor.
 1.488 19-Nov-2002  bsh Regen. for additional vendor IDs for Samsung Electronics Co. Ltd.
 1.487 15-Nov-2002  tsutsui Regen from pcidevs rev 1.486:
> Remove an entry for AMD PCNETS_PCI.
>
> AMD Am79C974 PCnet-SCSI Ethernet and SCSI conrtoller is
> a multi-function PCI device which has two device IDs
> of Am53C974(PCscsi-PCI) and Am79C970(PCnet-PCI),
> and there is no its own ID.
 1.486 15-Nov-2002  ad Regen.
 1.485 09-Nov-2002  grant regen for ATI Rage Mobility M1.
 1.484 08-Nov-2002  msaitoh regen
 1.483 07-Nov-2002  thorpej Regen; add Intel i31244 Serial ATA controller.
 1.482 07-Nov-2002  martin Regen (Myson MTD804 added)
 1.481 04-Nov-2002  wiz regen (typo fix from PR 18921)
 1.480 25-Oct-2002  kent regen
 1.479 24-Oct-2002  grant regen
 1.478 21-Oct-2002  soren Regen.
 1.477 21-Oct-2002  grant regen
 1.476 18-Oct-2002  yamt regen; fix simple typos
 1.475 16-Oct-2002  leo Regen.
 1.474 05-Oct-2002  kent regen
 1.473 24-Sep-2002  pooka regen
 1.472 20-Sep-2002  pooka regen
 1.471 19-Sep-2002  nathanw Regen.
 1.470 11-Sep-2002  bouyer Regen: add 2 acard pciide controllers.
 1.469 06-Sep-2002  uwe Regen for Integraphics Systems CyberPro 2000 and 2010.
 1.468 23-Aug-2002  bouyer Regen: Add Promise Ultra133TX2 and Ultra133TX2v2 PCI ID
 1.467 16-Aug-2002  heinz regen
 1.466 10-Aug-2002  toshii Regen; added SiS745 host bridge.
 1.465 08-Aug-2002  drochner regen
 1.464 04-Aug-2002  thorpej Regen; added ADI BECC product ID.
 1.463 03-Aug-2002  kent regen
 1.462 02-Aug-2002  soren Regen.
 1.461 02-Aug-2002  ad Regen.
 1.460 31-Jul-2002  bouyer Regen: remove duplicate entry for 82801DB_LPC.
 1.459 30-Jul-2002  bouyer Regen: Add Intel 845G PCI IDs
 1.458 29-Jul-2002  augustss Regen.
 1.457 26-Jul-2002  onoe regen: Add Silicon Image (CMDTECH) 0680
 1.456 22-Jul-2002  msaitoh regen
 1.455 12-Jul-2002  enami Regen.
 1.454 09-Jul-2002  matt Regen.
 1.453 09-Jul-2002  thorpej Regen:
Clean up Intel i8254x product names, and add i82540, i82545, and i82546
product IDs.
 1.452 07-Jul-2002  augustss Regen.
 1.451 05-Jul-2002  enami Regen.
 1.450 04-Jul-2002  rjs Regenerate.
 1.449 03-Jul-2002  msaitoh regen
 1.448 27-Jun-2002  pooka regen
 1.447 26-Jun-2002  cjs Regenerate.
 1.446 26-Jun-2002  cjs Regenerate.
 1.445 22-Jun-2002  fvdl Regenerate.
 1.444 22-Jun-2002  cjs Regenerate.
 1.443 21-Jun-2002  thorpej Regenerate: Add product ID for Intel 82452KX/GX PCI-Host bridge.
 1.442 17-Jun-2002  jdolecek regen:
add VIA Technologies VT8653 and VT8633 entries
move VT82C686A_MC97 entry to where it numerically belongs
 1.441 10-Jun-2002  cjs Regenerate.
 1.440 09-Jun-2002  taca Regen.
 1.439 04-Jun-2002  fvdl Regen.
 1.438 03-Jun-2002  briggs Regen. for MPC8245 host bridge.
 1.437 02-Jun-2002  seb regen for Titan PCI-800L.
 1.436 28-May-2002  christos regen
 1.435 28-May-2002  tron Regen from "pcidevs".
 1.434 27-May-2002  drochner regen
 1.433 25-May-2002  ichiro regen
 1.432 24-May-2002  lukem regen for NetMos Quad UART and 1284 Printer port
 1.431 19-May-2002  bouyer branches: 1.431.2;
Regen: add HPT372 and 74 PCI IDE controllers.
 1.430 19-May-2002  sommerfeld Regen
 1.429 19-May-2002  sommerfeld Regen
 1.428 18-May-2002  matt Regen.
 1.427 15-May-2002  augustss branches: 1.427.2;
Regen.
 1.426 14-May-2002  augustss Regen.
 1.425 03-May-2002  augustss Regen.
 1.424 29-Apr-2002  nonaka Regen. (Added two IBM devices.)
 1.423 26-Apr-2002  ad Regen.
 1.422 18-Apr-2002  thorpej Regen: Added Symbios 53c875A product ID.
 1.421 18-Apr-2002  tshiozak add PCI/USB vendor ID for Kurusugawa Electronics, Inc.
PCI-ID: 0x6809, USB-ID: 0x0b7e.
 1.420 16-Apr-2002  drochner regen
 1.419 15-Apr-2002  mycroft Regen.
 1.418 15-Apr-2002  ad Regen.
 1.417 05-Apr-2002  mycroft Regen.
 1.416 27-Mar-2002  abs Regen for 'CONEXANT 56KFAXMODEM 0x1085 HW 56K Fax Modem'
 1.415 19-Mar-2002  bouyer Regen: add AMD768 devices
 1.414 11-Mar-2002  joda regen
 1.413 01-Mar-2002  kleink Regen: add Motorola Raven, Falcon and Hawk product IDs.
 1.412 28-Feb-2002  junyoung Regen.
 1.411 28-Feb-2002  junyoung Regen; fix for duplicate ATI Rage Pro.
 1.410 27-Feb-2002  martin regen
 1.409 27-Feb-2002  junyoung Regen.
 1.408 24-Feb-2002  kleink Regen: add IBM 82660 PowerPC to PCI Bridge and Memory Controller.
 1.407 21-Feb-2002  simonb regen: Use BCM prefix instead of SB prefix in previous.
 1.406 20-Feb-2002  simonb regen: Add the SiByte/Broadcom SB1250 PCI and LDT bridge IDs.
 1.405 20-Feb-2002  simonb regen: Rename the SIBYTE entry to "Broadcom Corp. (SiByte)".
 1.404 16-Feb-2002  thorpej Regen: Add the Elan SC520 System Controller.
 1.403 04-Feb-2002  junyoung Regen.
 1.402 02-Feb-2002  tsutsui Regen; add Initio INIC-850/1060 SCSI and variants.
 1.401 02-Feb-2002  tsutsui Regen; add HiNT Corp. HB1 PCI-PCI bridge.
 1.400 30-Jan-2002  tron Regen.
 1.399 29-Jan-2002  junyoung Regen.
 1.398 28-Jan-2002  thorpej Regen: Add product ID for the Intel i82544GC 64-bit variant.
 1.397 26-Jan-2002  tron Regen.
 1.396 26-Jan-2002  ichiro regen
 1.395 22-Jan-2002  junyoung Regen.
 1.394 22-Jan-2002  junyoung Regen. Add Mach64 GS.
 1.393 21-Jan-2002  ichiro regen
 1.392 21-Jan-2002  eeh Regen.
 1.391 21-Jan-2002  thorpej Regen; Broadcom BCM570x-related IDs.
 1.390 15-Jan-2002  thorpej Regen; add Intel i82544GC Gig-E.
 1.389 14-Jan-2002  augustss Regen.
 1.388 14-Jan-2002  augustss Regen.
 1.387 13-Jan-2002  augustss Regen.
 1.386 09-Jan-2002  augustss Regen.
 1.385 05-Jan-2002  junyoung Regen.
 1.384 05-Jan-2002  augustss Regen.
 1.383 03-Jan-2002  rafal Regen (added Rainbow Technologies & Rainbow's CryptoSwift 200).
 1.382 01-Jan-2002  augustss Regen.
 1.381 30-Dec-2001  ichiro regen
 1.380 29-Dec-2001  ichiro regen
 1.379 20-Dec-2001  thorpej Regen; added SiS 630 PCI-Host bridge.
 1.378 16-Dec-2001  thorpej Regen:

Add Middle Digital, Inc. vendor ID. Add product IDs for the
Middle Digital PCI-Weasel Virtual VGA, Serial Port, and Control
registers.
 1.377 15-Dec-2001  soren Regen.
 1.376 13-Dec-2001  bouyer Regen: Add some promise controllers, from FreeBSD
 1.375 11-Dec-2001  ad Regen.
 1.374 11-Dec-2001  kleink Regen: add product ID for the Motorola MPC107.
 1.373 07-Dec-2001  onoe Regen: Add HPB and LPC functions of 82801BAM.
 1.372 07-Nov-2001  thorpej Regen; correct i80312 description.
 1.371 07-Nov-2001  thorpej Regen; add Cyclone PCI-700 (IQ80310).
 1.370 25-Oct-2001  augustss Regen.
 1.369 24-Oct-2001  thorpej Regen; Add product IDs for the Powerhouse Systems PowerPro and PowerTop
PowerPC system controllers.
 1.368 24-Oct-2001  thorpej Regen; more Intel Gig-E fixup, and add Intel i82544 IDs.
 1.367 16-Oct-2001  tron branches: 1.367.2;
Regen.
 1.366 13-Oct-2001  ichiro regen.
 1.365 11-Oct-2001  tron Regen.
 1.364 03-Oct-2001  simonb Regen: Minor correction to the name of the 405GP PCI bridge.
 1.363 01-Oct-2001  thorpej Regen; added product ID for RealTek 8139[BC].
 1.362 28-Sep-2001  thorpej Regen; more corrections to Intel Gig-e product IDs.
 1.361 27-Sep-2001  itojun regen
 1.360 15-Sep-2001  chris Regen
 1.359 10-Sep-2001  eeh Regen.
 1.358 05-Sep-2001  drochner branches: 1.358.2;
regen
 1.357 04-Sep-2001  thorpej Regen; added Intel IXP1200 Network Processor.
 1.356 04-Sep-2001  pooka regen.. again.. *sigh*
 1.355 04-Sep-2001  pooka regen
 1.354 30-Aug-2001  soren Regen.
 1.353 28-Aug-2001  tsubai Regen.
 1.352 27-Aug-2001  enami Regen.
 1.351 27-Aug-2001  ad Regen.
 1.350 23-Aug-2001  thorpej Regen; take part numbers out of PCnet-PCI product descriptions.
 1.349 23-Aug-2001  thorpej Regen; Add Promise ATA/100 TX2.
 1.348 20-Aug-2001  fvdl Regen.
 1.347 20-Aug-2001  gehenna Regen
 1.346 18-Aug-2001  thorpej Regen; added Avance Logic ALS4000.
 1.345 17-Aug-2001  matt regen.
 1.344 31-Jul-2001  matt regen
 1.343 28-Jul-2001  pooka regen
 1.342 25-Jul-2001  thorpej Regen; Added Antares Gigabit Ethernet.
 1.341 23-Jul-2001  bouyer Regen for TITAN PCI100H.
 1.340 30-Jun-2001  thorpej branches: 1.340.2;
Regen.
 1.339 28-Jun-2001  thorpej Add Tamarack Microelectronics, Inc. vendor ID, and product ID for
Tamarack TC9021 Gigabit Ethernet.
 1.338 27-Jun-2001  mcr added Solidum PAX.ware 1100 and Lucent ORCA PCI targets
 1.337 20-Jun-2001  thorpej Regen; add/update 3Com 3CR990 products.
 1.336 20-Jun-2001  thorpej Regen; add SysKonnect SKNET-GE.
 1.335 20-Jun-2001  imp Regen.
 1.334 18-Jun-2001  onoe regen: Add Cisco/Aironet 350
 1.333 17-Jun-2001  tsubai Regen.
 1.332 13-Jun-2001  simonb Regen; add IBM 405GP PCI Bridge & ROB-in i960RP Microprocessor.
 1.331 11-Jun-2001  thorpej Regen; Add Level One vendor ID, and LXT-1001 10/100/1000 Ethernet
product ID.
 1.330 11-Jun-2001  tron Regen from "pcidevs".
 1.329 31-May-2001  nisimura Regen; product IDs for IDT RC32334 and RC32332 systeml controllers.
 1.328 21-May-2001  thorpej Regen; add ICH3 network controller IDs.
 1.327 18-May-2001  enami Regen.
 1.326 17-May-2001  drochner regen
 1.325 14-May-2001  thorpej Regen; added DP83820 Gigabit Ethernet chip.
 1.324 06-May-2001  fvdl Regen.
 1.323 25-Apr-2001  simonb Regen.
 1.322 21-Apr-2001  tsutsui Regen from pcidevs rev. 1.318:
> Correct an entry for Acard UDMA IDE controller.
> The chip is actually marked as ATP860-A, not ATP860R.
 1.321 13-Apr-2001  hubertf Regen for moved Trident CyberBlade entry
 1.320 12-Apr-2001  itojun regen.
 1.319 12-Apr-2001  matt Regen.
 1.318 09-Apr-2001  ad Regen.
 1.317 31-Mar-2001  minoura Regen.
 1.316 21-Mar-2001  soren Regen.
 1.315 21-Mar-2001  hubertf regen for trident cyberclade
 1.314 20-Mar-2001  mrg regen
 1.313 17-Mar-2001  thorpej Regen.
 1.312 13-Mar-2001  bouyer Regen.
 1.311 07-Mar-2001  matt Regen.
 1.310 05-Mar-2001  matt branches: 1.310.2;
Regen
 1.309 04-Mar-2001  msaitoh regen
 1.308 02-Mar-2001  thorpej Regen -- Add Mylex AcceleRAID and eXtremeRAID product and subsystem IDs.
 1.307 02-Mar-2001  thorpej Regen; added Xircom WinGlobal modem product ID.
 1.306 18-Feb-2001  bouyer Regen.
 1.305 18-Feb-2001  matt regen
 1.304 12-Feb-2001  tshiozak add CMI8738B.
 1.303 11-Feb-2001  ad Regen.
 1.302 04-Feb-2001  briggs Regen.
 1.301 02-Feb-2001  hubertf Regen: Add M5243 PCI-AGP Bridge
Fixes PR 11466 by Jared D. McNeill <jmcneill@invisible.yi.org>
 1.300 31-Jan-2001  thorpej Regen; add SEGA Dreamcast Broadband Adapter.
 1.299 26-Jan-2001  rh regen
 1.298 26-Jan-2001  rh regen
 1.297 22-Jan-2001  jdolecek regen: US Robotics (3Com) 56K Voice Internal PCI Modem (WinModem) entry added
 1.296 22-Jan-2001  mjl Regen for stallion.
 1.295 18-Jan-2001  jdolecek regen: make pci_knowndevs[] const
 1.294 17-Jan-2001  thorpej Regen; Intel Gigabit Ethernet update.
 1.293 15-Jan-2001  thorpej Regen.
 1.292 12-Jan-2001  itojun regen
 1.291 09-Jan-2001  rh regen
 1.290 09-Jan-2001  thorpej Regen; added Symbios 53c1510D.
 1.289 08-Jan-2001  thorpej Regen; added Accton EN2242.
 1.288 08-Jan-2001  thorpej Regen; added DEC SWXCR RAID.
 1.287 08-Jan-2001  rh regen
 1.286 03-Jan-2001  mycroft Regen.
 1.285 31-Dec-2000  ad Regen.
 1.284 30-Dec-2000  eeh Regen.
 1.283 27-Dec-2000  tsutsui Regen. (Fix Acard UDMA IDE)
 1.282 27-Dec-2000  augustss Regen.
 1.281 23-Dec-2000  tsutsui Regen. (Adding Acard UDMA IDE controllers)
 1.280 14-Dec-2000  onoe regen
 1.279 05-Dec-2000  drochner regen
 1.278 20-Nov-2000  onoe regen.
CXD32222 -> CXD3222 (Sony OHCI Controller)
 1.277 18-Nov-2000  thorpej Regen.
 1.276 14-Nov-2000  bouyer Regen.
 1.275 04-Nov-2000  thorpej Regen.
 1.274 03-Nov-2000  ad regen.
 1.273 03-Nov-2000  ad Regen.
 1.272 27-Oct-2000  thorpej Regen.
 1.271 27-Oct-2000  thorpej Regen.
 1.270 19-Oct-2000  thorpej Regen.
 1.269 14-Oct-2000  simonb Regen
 1.268 12-Oct-2000  itojun regen
 1.267 03-Oct-2000  thorpej Regen: ADMtek AN985
 1.266 27-Sep-2000  augustss Regen.
 1.265 20-Sep-2000  thorpej Regen.
 1.264 19-Sep-2000  fvdl Regen.
 1.263 13-Sep-2000  ad Regen.
 1.262 13-Sep-2000  tron Regen.
 1.261 13-Sep-2000  tron Regen.
 1.260 13-Sep-2000  tron Regen.
 1.259 07-Sep-2000  soren Regen.
 1.258 04-Sep-2000  soren Regen.
 1.257 04-Sep-2000  itojun regen
 1.256 02-Sep-2000  cgd regen for changed pcidevs
 1.255 29-Aug-2000  wiz regen
 1.254 21-Aug-2000  enami Regen.
 1.253 21-Aug-2000  haya Regen.
 1.252 07-Aug-2000  billc Manually edit the headers to show which version of pcidevs this was
generated from.

XXX - this really should be automated
 1.251 07-Aug-2000  billc Added PCI IDs for 3Com's Home Connect (3c450) and Office Connect (3cSOHO100).
They both are register compat with later versions of the 3c905 (tornado/
vortex) series.
 1.250 04-Aug-2000  ad Regen.
 1.249 23-Jul-2000  jonathan * Add entries for older Yamaha YMF chips (724, 740) plus the
newer steppings (740C, 724F) which use the same microcode as the
DS-1S/DS-1E.
Regen.
 1.248 20-Jul-2000  ad Regen.
 1.247 10-Jul-2000  ad Regen.
 1.246 09-Jul-2000  mycroft Regen.
 1.245 08-Jul-2000  mrg regen
 1.244 04-Jul-2000  enami Regen.
 1.243 03-Jul-2000  gmcgarry Regen.
 1.242 24-Jun-2000  joda regen
 1.241 21-Jun-2000  tron Regen.
 1.240 16-Jun-2000  soren branches: 1.240.2;
Regen.
 1.239 13-Jun-2000  tron Regen.
 1.238 12-Jun-2000  nathanw Regen.
 1.237 12-Jun-2000  bouyer Regen.
 1.236 12-Jun-2000  bouyer Regen.
 1.235 09-Jun-2000  augustss Regen.
 1.234 07-Jun-2000  ad Regen.
 1.233 07-Jun-2000  mrg regen.
 1.232 07-Jun-2000  soren Regen.
 1.231 06-Jun-2000  kleink Regen.
 1.230 05-Jun-2000  kleink Regen.
 1.229 05-Jun-2000  kleink Regen.
 1.228 30-May-2000  matt Regen
 1.227 28-May-2000  drochner regen
 1.226 27-May-2000  scw Regen.
 1.225 27-May-2000  soren branches: 1.225.2;
Regen.
 1.224 26-May-2000  matt Regen.
 1.223 18-May-2000  drochner regen
 1.222 18-May-2000  garbled regen
 1.221 14-May-2000  soren Regen.
 1.220 12-May-2000  thorpej Regen.
 1.219 07-May-2000  jonathan PCI product codes for Yamaha YMF744B (DS-1S) YMF754 (DS-1E) audio chips.
 1.218 30-Apr-2000  dante Add ASB-3940U3W host adapters (AdvanSys)
 1.217 28-Apr-2000  augustss Regen.
 1.216 26-Apr-2000  thorpej Regen.
 1.215 22-Apr-2000  augustss Regen.
 1.214 19-Apr-2000  bouyer Regen
 1.213 18-Apr-2000  cgd regen for changed pcidevs
 1.212 17-Apr-2000  thorpej Regen.
 1.211 03-Apr-2000  joda regen
 1.210 31-Mar-2000  tsarna Add auvia, a driver for the integrated AC'97 audio on the VIA VT82C686A
southbridge.

Tested on a ASUS K7M (w/ AD1881 codec). Please report any problems.
 1.209 30-Mar-2000  joda regen
 1.208 27-Mar-2000  ad Regen.
 1.207 23-Mar-2000  joda regen
 1.206 23-Mar-2000  ad Regen.
 1.205 21-Mar-2000  joda regen
 1.204 16-Mar-2000  thorpej Regen.
 1.203 14-Mar-2000  tsarna Regen
 1.202 13-Mar-2000  ad Regen.
 1.201 11-Mar-2000  jdolecek regen
 1.200 09-Mar-2000  jdolecek regen
 1.199 06-Mar-2000  mark Regenerate from pcidevs.
 1.198 04-Mar-2000  tron Regen from "pcidevs".
 1.197 16-Feb-2000  soren Regen.
 1.196 08-Feb-2000  bouyer regen
 1.195 03-Feb-2000  dante Add AdvanSys U2W host adapters
 1.194 03-Feb-2000  joda regen
 1.193 31-Jan-2000  thorpej Regen.
 1.192 25-Jan-2000  haya Regen.
 1.191 24-Jan-2000  joda regen
 1.190 23-Jan-2000  tsubai Regen.
 1.189 12-Jan-2000  haya Regen.
 1.188 11-Jan-2000  matt Regen.
 1.187 09-Jan-2000  soren Regen.
 1.186 05-Jan-2000  drochner regen
 1.185 31-Dec-1999  hubertf Add an entry for the Trident Microsystems CYBER 9525
(as found in an Toshiba Satellite 2650 XDVD).
 1.184 17-Dec-1999  drochner regen
 1.183 17-Dec-1999  augustss Regen.
 1.182 17-Dec-1999  soren Regen.
 1.181 17-Dec-1999  soren Regen.
 1.180 15-Dec-1999  kleink Regen.
 1.179 04-Dec-1999  castor Regen
 1.178 04-Dec-1999  thorpej Regen.
 1.177 01-Dec-1999  drochner regen
 1.176 30-Nov-1999  drochner regen
 1.175 17-Nov-1999  augustss Regen.
 1.174 12-Nov-1999  is Identification of DOMEX PCI-SCSI board, by Thilo Manske, PR 8772.
 1.173 07-Nov-1999  cgd regen
 1.172 06-Nov-1999  rh regen.
 1.171 06-Nov-1999  augustss Regen.
 1.170 04-Nov-1999  tsarna regen
 1.169 04-Nov-1999  augustss Regen.
 1.168 04-Nov-1999  joda regen
 1.167 01-Nov-1999  augustss Regen.
 1.166 29-Oct-1999  matt Regen.
 1.165 29-Oct-1999  haya Maintainance the name of Ricoh PCI-CardBus bridges.
 1.164 11-Oct-1999  hannken branches: 1.164.2; 1.164.4;
Regen.
 1.163 29-Sep-1999  thorpej branches: 1.163.2;
Regen.
 1.162 29-Sep-1999  thorpej Regen.
 1.161 27-Sep-1999  ad Regen.
 1.160 11-Sep-1999  soren Regen.
 1.159 10-Sep-1999  augustss Regen.
 1.158 08-Sep-1999  thorpej Regen.
 1.157 08-Sep-1999  thorpej Regen.
 1.156 08-Sep-1999  thorpej Regen.
 1.155 01-Sep-1999  drochner regen
 1.154 28-Aug-1999  augustss Regen.
 1.153 27-Aug-1999  thorpej Regen.
 1.152 24-Aug-1999  soren Regenerate.
 1.151 17-Aug-1999  drochner regen
 1.150 16-Aug-1999  mcr Added Solidum Systems PCI vendor ID and Device IDs
 1.149 12-Aug-1999  bouyer Regen.
 1.148 01-Aug-1999  veego Regen.
 1.147 29-Jul-1999  thorpej Regen.
 1.146 28-Jul-1999  soren Regen.
 1.145 27-Jul-1999  castor regen
 1.144 27-Jul-1999  thorpej Regen.
 1.143 20-Jul-1999  drochner regen
 1.142 15-Jul-1999  ross Regen.
 1.141 15-Jul-1999  augustss Regen.
 1.140 14-Jul-1999  fvdl Regen.
 1.139 12-Jul-1999  kleink Regen.
 1.138 01-Jul-1999  itojun IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
 1.137 27-Jun-1999  drochner regen
 1.136 19-Jun-1999  augustss Regen.
 1.135 18-Jun-1999  tsubai Regen.
 1.134 05-Jun-1999  tron Regen.
 1.133 05-Jun-1999  tron Regen.
 1.132 02-Jun-1999  drochner regen
 1.131 29-May-1999  mrg regen.
 1.130 29-May-1999  mrg regen.
 1.129 29-May-1999  fvdl Regen.
 1.128 27-May-1999  mrg regen.
 1.127 23-May-1999  veego Regen.
 1.126 20-May-1999  augustss Regen.
 1.125 17-May-1999  drochner regen
 1.124 07-May-1999  hwr Regen.
 1.123 07-May-1999  hwr Regen.
 1.122 07-May-1999  drochner regen
 1.121 07-May-1999  matt Regen
 1.120 06-May-1999  mrg regen
 1.119 12-Apr-1999  jonathan Add entries for TI, Ricoh, Toshiba PCI-to-cardbus bridge chips, so
we can identify them as cardbus chips supported by the cardbus patches.

Add entry for OPTI chipsets whose interrupts arent properly set up by
some BIOSes.

From cardbus patches<ftp://nandra.iri.co.jp/pub/NetBSD/CardBus by
HAYAKAWA Koichi <haya@tcad.ulsi.sony.co.jp>.
 1.118 25-Mar-1999  explorer branches: 1.118.2;
Add LAN Media Corporation info
 1.117 19-Mar-1999  mycroft Regen.
 1.116 17-Mar-1999  thorpej Regen.
 1.115 16-Mar-1999  tron Regen from "pcidevs".
 1.114 11-Mar-1999  sakamoto Regen.
 1.113 09-Mar-1999  drochner regen
 1.112 19-Feb-1999  thorpej Regen.
 1.111 19-Feb-1999  thorpej Regen.
 1.110 19-Feb-1999  thorpej Regen.
 1.109 14-Feb-1999  tron Regen from pcidevs.
 1.108 05-Feb-1999  thorpej Regen.
 1.107 28-Jan-1999  augustss Regen.
 1.106 16-Jan-1999  drochner regen
 1.105 30-Dec-1998  hwr Regen
 1.104 21-Dec-1998  drochner regen
 1.103 20-Dec-1998  drochner regen
 1.102 18-Dec-1998  thorpej Regen.
 1.101 09-Dec-1998  thorpej Regen.
 1.100 05-Dec-1998  matt Add Sigma Designs REALmagic Hollywood Plus MPEG-2 decoder
 1.99 30-Nov-1998  jtk regen
 1.98 29-Nov-1998  thorpej Regen.
 1.97 29-Nov-1998  thorpej Regen.
 1.96 27-Nov-1998  drochner regen
 1.95 26-Nov-1998  mcr regenerated pcidevs.h and pcidevs_data.h due to kern/6280
(not kern/5847 as originally noted)
 1.94 20-Oct-1998  thorpej Regen.
 1.93 19-Oct-1998  bouyer Regen.
 1.92 05-Oct-1998  tron Regen.
 1.91 04-Oct-1998  tron Regen.
 1.90 01-Oct-1998  fvdl Regen.
 1.89 26-Sep-1998  dante Change product ADVSYS 2300 to ADVSYS WIDE
 1.88 22-Sep-1998  mark Regenerate from pcidevs.
 1.87 18-Sep-1998  drochner regen
 1.86 18-Sep-1998  mark Regen.
 1.85 06-Sep-1998  veego Regen.
 1.84 26-Aug-1998  drochner regen
 1.83 26-Aug-1998  dante Changed ADVSYSPROD to ADVSYS vendor ID
Added 1200A, 1200B, ULTRA, 2300 AdvanSys products ID
 1.82 07-Aug-1998  thorpej Regen.
 1.81 28-Jul-1998  thorpej Regen.
 1.80 27-Jul-1998  tron Regen from pcidevs.
 1.79 27-Jul-1998  tron Regen from pcidevs.
 1.78 27-Jul-1998  augustss Regen.
 1.77 25-Jul-1998  explorer commit this so it gets the right generated from tag
 1.76 25-Jul-1998  explorer define RISCom and RISCom N2 product
 1.75 22-Jul-1998  drochner regen
 1.74 19-Jul-1998  tron Regen from pcidevs.
 1.73 13-Jul-1998  mark Regen.
 1.72 10-Jul-1998  tron Regen from pcidevs.
 1.71 30-Jun-1998  augustss Regen.
 1.70 15-Jun-1998  bouyer Regen.
 1.69 15-Jun-1998  bouyer Regen.
 1.68 15-Jun-1998  bouyer Regen.
 1.67 25-May-1998  mark Regen from pcidevs.
 1.66 14-May-1998  augustss Regen.
 1.65 13-May-1998  augustss Regen.
 1.64 05-May-1998  thorpej Regen.
 1.63 04-May-1998  thorpej Regen.
 1.62 30-Apr-1998  mycroft Regen.
 1.61 16-Apr-1998  drochner regen
 1.60 28-Mar-1998  thorpej Regen.
 1.59 28-Mar-1998  cgd regen
 1.58 07-Mar-1998  augustss Regen.
 1.57 04-Mar-1998  cgd regen
 1.56 04-Mar-1998  cgd regen
 1.55 27-Feb-1998  mycroft Regen.
 1.54 07-Feb-1998  augustss Newly generated version.
 1.53 07-Feb-1998  augustss Add the AGP device in the 82443LX.
 1.52 27-Jan-1998  thorpej Regen: add Packet Engines G-NIC gigabit Ethernet.
 1.51 22-Jan-1998  mycroft Regen.
 1.50 09-Jan-1998  thorpej Regen.
 1.49 08-Jan-1998  thorpej Regen: back out RCS ID related changes.
 1.48 05-Jan-1998  perry regened with RCSIDs in place
 1.47 16-Nov-1997  christos Regen.
 1.46 27-Oct-1997  thorpej Regen.
 1.45 14-Oct-1997  thorpej branches: 1.45.2;
Regen.
 1.44 08-Oct-1997  mycroft Regen.
 1.43 06-Oct-1997  lonhyn pcidevs change regen.
 1.42 01-Oct-1997  drochner regen
 1.41 23-Sep-1997  mycroft Regen.
 1.40 15-Sep-1997  bouyer Regen.
 1.39 12-Sep-1997  drochner regen
 1.38 28-Aug-1997  thorpej Regen: added SMC83C170 entry.
 1.37 23-Aug-1997  drochner regen
 1.36 14-Aug-1997  drochner Regen with new RCS ID. (thanks, Bernd)
 1.35 14-Aug-1997  drochner Include some more stuff.
 1.34 03-Aug-1997  fvdl Regen.
 1.33 19-Jul-1997  cgd branches: 1.33.2;
regen for new pcidevs
 1.32 24-Jun-1997  thorpej Correct Intel Triton MX PCI IDs, from Tom Yu <tlyu@mit.edu>, PR #3478.
 1.31 24-Jun-1997  kml Added definitions for Essential Communications RoadRunner HIPPI and
Gigabit Ethernet interfaces.
 1.30 13-May-1997  jtk regen
 1.29 04-Apr-1997  augustss Regen.
 1.28 20-Mar-1997  chuck regen
 1.27 16-Feb-1997  veego regen.
 1.26 01-Jan-1997  veego branches: 1.26.4;
Add the Matrox Millenium and regen the header files.
 1.25 30-Nov-1996  jtk forgot to regenerate these after committing pcidevs for its NetBSD header tag
 1.24 28-Nov-1996  jtk add Cirrus CL-7541, 7543 and ACC 2188; regen .h files
 1.23 28-Nov-1996  thorpej Regen.
 1.22 19-Oct-1996  jonathan regen from pcidevs 1.20
 1.21 15-Oct-1996  christos regen
 1.20 13-Oct-1996  christos regen
 1.19 08-Oct-1996  gibbs dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.

Regen microcode header file.

dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.

Fix a problem with handing the QUEUE FULL condition.

Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.

Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.

dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.

dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.

Regen data file.

scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.

Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
 1.18 24-Sep-1996  christos New cyclades driver from Timo Rossi.
 1.17 29-Aug-1996  cgd regen for new pcidevs
 1.16 26-Aug-1996  cgd regen for new pcidevs
 1.15 23-Aug-1996  cgd regen for new pcidevs
 1.14 15-Jul-1996  cgd regen for updated pcidevs
 1.13 22-Jun-1996  chuck regenerate to fix "generated from" comment
(next commit pcidevs first, then regenerate)
 1.12 22-Jun-1996  chuck add product code for efficient networks eni155p atm card and regenerate
 1.11 16-May-1996  mycroft branches: 1.11.4;
Regen.
 1.10 13-May-1996  thorpej Regenerate.
 1.9 07-May-1996  thorpej Regenerate; pcidevs changed.
 1.8 04-Apr-1996  mycroft Regen.
 1.7 19-Feb-1996  christos pcidevs was changed.
 1.6 31-Jan-1996  cgd update for new version of 'pcidevs'
 1.5 22-Jan-1996  cgd update PCIVERBOSE code in various ways:
(1) remove the 'UNSUPP' keyword from the device list,
because it can't be reasonably used (becuase different
devices may be supported on different machines, for
good reason).
(2) enhance pci_devinfo so that class/subclass information
is optional (so pci_devinfo can be used by drivers that
match classes of devices, and want to look up the
devices' names easily).
(3) more known vendors and devices.
 1.4 10-Nov-1995  christos pcidevs was changed
 1.3 10-Nov-1995  christos - pcidevs: add 3c590 and adaptec ultra
- aic7xxx.c: fix the probe routines to use pcidevs.h
 1.2 20-Jun-1995  cgd vendor IDs for Acer and SIS
 1.1 18-Jun-1995  cgd built from pcidevs list
 1.11.4.1 04-Mar-1997  mycroft Regen.
 1.26.4.1 12-Mar-1997  is Merge in changes from The Trunk
 1.33.2.9 14-Oct-1997  thorpej Sync w/ trunk.
 1.33.2.8 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.7 14-Oct-1997  thorpej Regen.
 1.33.2.6 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.5 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.4 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.3 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.45.2.2 17-Nov-1997  thorpej Regen.
 1.45.2.1 27-Oct-1997  thorpej Regen.
 1.118.2.13 11-Sep-2000  he Pull up regenerated files (requested by billc):
Recognize 3Com's Home Connect (3c450) and Office Connect (3cSOHO100)
Ethernet cards.
 1.118.2.12 23-Jul-2000  he Pull up regenerated files (requested by jonathan):
Add product codes for various Yamaha audio chips.
 1.118.2.11 07-Jul-2000  he Pull up regenerated files (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
 1.118.2.10 03-Jun-2000  he Pull up regenerated files (requested by tsubai):
Add support for PCI variants of Cyclom-4Y and -8Y cards.
Also fixes PR#7175 (new serial controller).
 1.118.2.9 22-May-2000  he Pull up regenerated files (requested by bouyer):
Add product IDs for some VIA Technologies devices.
 1.118.2.8 10-Feb-2000  he Pull up regenerated file (requeste by bouyer):
Add support for US Robotics 3CP5609 PCI 16550 Modem.
 1.118.2.7 15-Jan-2000  he Regenerate after fixing DPT SCSI boards description.
 1.118.2.6 20-Oct-1999  he Regenerate these after adding Realtek to pcidevs.
 1.118.2.5 05-Oct-1999  he Regenerate these from recent pcidevs pullup.
 1.118.2.4 24-Sep-1999  cgd regenerate _after_ pcidevs is checked in
 1.118.2.3 29-Aug-1999  he Regenerated.
Recognize 3c905C-TX card. (bouyer)
 1.118.2.2 22-Jun-1999  perry regen (fvdl): recognize another 390xB card
 1.118.2.1 13-Apr-1999  jonathan branches: 1.118.2.1.2; 1.118.2.1.4;
Pull up sys/dev/pci/pcidevs 1.113->1.114 (CardBus bridge chips) to 1.4.
pcidevs.h, pcidevs_data.h: regen.
 1.118.2.1.4.2 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.118.2.1.4.1 28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.118.2.1.2.3 02-Aug-1999  thorpej Regen.
 1.118.2.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.118.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.163.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.164.4.1 15-Nov-1999  fvdl Sync with -current
 1.164.2.10 23-Apr-2001  bouyer Sync with HEAD.
 1.164.2.9 21-Apr-2001  bouyer Sync with HEAD
 1.164.2.8 27-Mar-2001  bouyer Sync with HEAD.
 1.164.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.164.2.6 11-Feb-2001  bouyer Sync with HEAD.
 1.164.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.164.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.164.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.164.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.164.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.225.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.240.2.27 07-Apr-2004  jmc Regen (requested by itojun in ticket #71)

Add National Semiconductors SC1100 (GEODE) PCI devices
 1.240.2.26 06-Jun-2002  he Pull up regenerated files (requested by mycroft):
Add Intel ICH3 network controller IDs. Part of fix to fxp driver to
work around a bug which can cause some machines to randomly hang, and to
drag along performance improvements and improved hardware support.
 1.240.2.25 25-Mar-2002  he Pull up regenerated files (requested by bouyer):
Add support for the pciide part of the AMD-768 chipset.
 1.240.2.24 06-Feb-2002  he Pull up regenerated files (requested by tsutsui):
Add support for Acard ATP-850/860 pciide controllers.
 1.240.2.23 29-Jan-2002  he Pull up regenerated files (requested by bouyer):
Add support for the 53c1010-33, and bring documentation up to
date.
 1.240.2.22 24-Jan-2002  he Pull up regenerated files (requested by he):
Add driver for the ESS Allegro-1 / Maestro-3 audio hardware.
 1.240.2.21 25-Oct-2001  he Pull up regenerated files (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.240.2.20 18-Jun-2001  jhawk Pull up regenerated files (requested by tsubai):
Support the new dual USB iBook.
 1.240.2.19 11-Jun-2001  he Pull up regenerated files (requested by tron):
Support the D-Link DFE-530TX+. Fixes PR#13161.
 1.240.2.18 15-May-2001  he Pull up regenerated files (requested by bouyer):
Add support for newer VIA pciide controllers.
Add support for the AMD 766 pciide controller.
Properly distinguish between HPT366 and HPT370 controllers.
 1.240.2.17 06-May-2001  he Pull up regenerated files (requested by he):
Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.
 1.240.2.16 03-May-2001  he Pull up regenerated files (requested by skrll):
Add a driver for the ESS Technology Maestro-1/2/2E AC97 audio chips,
ES1968 and ES1978.
 1.240.2.15 23-Apr-2001  he Pull up regenerated files (requested by hubertf):
Support Accton EN2242 and other AmdTek AN985 compatible cards
with the tlp(4) driver.
 1.240.2.14 22-Mar-2001  he Pull up regenerated files (requested by hubertf):
Make the Intel Pro/100 as e.g. found on Toshiba Satellite Pro
4600s work.
 1.240.2.13 20-Mar-2001  he Pull up regenerated files (requested by chuck):
Add support for the 3Com 3c555, 3c556 and 3c556B MiniPCI Ethernet
cards.
 1.240.2.12 26-Feb-2001  he Pull up regenerated files (requested by bouyer):
Add support for the Intel 82801BAM IDE controller.
 1.240.2.11 31-Dec-2000  jhawk Regen.
 1.240.2.10 30-Oct-2000  tv Regen.
 1.240.2.9 19-Oct-2000  he Pull up regenerated files (requested by billc):
Add PCI IDs for 3Com Home Connect (3c450) and Office Connect
(3cSOHO100), register compatible with later versions of 3c905.
 1.240.2.8 21-Sep-2000  thorpej Regen: Add National Semiconductor DP83815 10/100 Ethernet.
 1.240.2.7 13-Sep-2000  tron Regen.
 1.240.2.6 22-Aug-2000  enami Regen.
 1.240.2.5 23-Jul-2000  jonathan Pull up pcidevs.h rev 1.251 and pcidevs_data.h rev 249, by pulling
up pcidevs rev 1.245 (YMF 7xx audio product codes), then regen.
 1.240.2.4 16-Jul-2000  jhawk Pullup pcidevs rev 1.242 and regen pcidevs_data.h, pcidevs.h, approved by
jhawk:
Add ID for i82559ER.
 1.240.2.3 06-Jul-2000  enami Regen.
 1.240.2.2 27-Jun-2000  thorpej Regen.
 1.240.2.1 26-Jun-2000  bouyer Regen.
 1.310.2.29 17-Jan-2003  thorpej Sync with HEAD.
 1.310.2.28 15-Jan-2003  thorpej Sync with HEAD.
 1.310.2.27 03-Jan-2003  thorpej Sync with HEAD.
 1.310.2.26 29-Dec-2002  thorpej Sync with HEAD.
 1.310.2.25 19-Dec-2002  thorpej Sync with HEAD.
 1.310.2.24 11-Dec-2002  thorpej Sync with HEAD.
 1.310.2.23 26-Nov-2002  thorpej Sync with HEAD.
 1.310.2.22 11-Nov-2002  nathanw Catch up to -current
 1.310.2.21 18-Oct-2002  nathanw Catch up to -current.
 1.310.2.20 17-Sep-2002  nathanw Catch up to -current.
 1.310.2.19 27-Aug-2002  nathanw Catch up to -current.
 1.310.2.18 13-Aug-2002  nathanw Catch up to -current.
 1.310.2.17 01-Aug-2002  nathanw Catch up to -current.
 1.310.2.16 20-Jun-2002  nathanw Catch up to -current.
 1.310.2.15 17-Apr-2002  nathanw Catch up to -current.
 1.310.2.14 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.310.2.13 28-Feb-2002  nathanw Regen.
 1.310.2.12 28-Feb-2002  nathanw Regen.
 1.310.2.11 28-Feb-2002  nathanw Catch up to -current.
 1.310.2.10 11-Jan-2002  nathanw More catchup.
 1.310.2.9 08-Jan-2002  nathanw Catch up to -current.
 1.310.2.8 14-Nov-2001  nathanw Catch up to -current.
 1.310.2.7 22-Oct-2001  nathanw Catch up to -current.
 1.310.2.6 08-Oct-2001  nathanw Catch up to -current.
 1.310.2.5 21-Sep-2001  nathanw Catch up to -current.
 1.310.2.4 24-Aug-2001  nathanw Catch up with -current.
 1.310.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.310.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.310.2.1 05-Mar-2001  nathanw file pcidevs_data.h was added on branch nathanw_sa on 2001-04-09 01:57:07 +0000
 1.340.2.9 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.340.2.8 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.340.2.7 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.340.2.6 16-Mar-2002  jdolecek Catch up with -current.
 1.340.2.5 11-Feb-2002  jdolecek Sync w/ -current.
 1.340.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.340.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.340.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.340.2.1 03-Aug-2001  lukem update to -current
 1.358.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.358.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.367.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.427.2.4 29-Aug-2002  gehenna catch up with -current.
 1.427.2.3 15-Jul-2002  gehenna catch up with -current.
 1.427.2.2 20-Jun-2002  gehenna catch up with -current.
 1.427.2.1 30-May-2002  gehenna Catch up with -current.
 1.431.2.36 26-Oct-2005  jmc regen
 1.431.2.35 01-Jun-2005  riz Regen for ticket 5721.
 1.431.2.34 01-May-2005  tron Regen for ticket 5756.
 1.431.2.33 19-Mar-2005  tron Regen for ticket 1755.
 1.431.2.32 11-Nov-2004  he Pull up regenerated files (requested by itohy in ticket #1741):
Add support for the Workbit NinjaSCSI-32 PCI/Cardbus
SCSI driver, njs(4).
 1.431.2.31 12-Jul-2004  he Pull up regenerated files (requested by grant in ticket #1720):
Add support for SATALink 3112.
 1.431.2.30 22-Jun-2004  tron Regen for ticket #1718.
 1.431.2.29 06-Apr-2004  jmc Regen (requested by briggs in ticket #1648)

Pull in changes to support the Intel 82801EB/ER (ICH5) Controller. PR#25002
 1.431.2.28 28-Mar-2004  jmc Regen for ticket #1631
 1.431.2.27 15-Mar-2004  jmc Regen for ticket #1612
 1.431.2.26 20-Oct-2003  cyber Pull up revision 1.569 (requested by tron in ticket #1440):
Add entry for Intel i865G Integrated Graphics Device.
 1.431.2.25 10-Sep-2003  grant Regenerate (requested by tron in ticket #1417):

Correct names and descriptions for i875 entries to be consistent with
other Intel chipsets.
 1.431.2.24 15-Aug-2003  tron Regen.
 1.431.2.23 10-Jul-2003  tron Regen for ticket #1365.
 1.431.2.22 30-Jun-2003  grant Regen (requested by drochner in ticket #1343):

add Intel PRO/100M.
 1.431.2.21 19-Jun-2003  grant Regen (requested by hamajima in ticket #1323):

Support the PowerBook G4 12-inch (and maybe 17-inch).
Kauai ATA, new obio chip, and Japanese keymap for WSDISPLAY_COMPAT_RAWKBD
 1.431.2.20 16-Jun-2003  grant Regenerate (requested by bouyer in ticket #1234):

Add several SiS host bridges, from FreeBSD.

Remove duplicate in previous.
 1.431.2.19 02-Jun-2003  tron Regen for ticket 1143.
 1.431.2.18 28-Jan-2003  jmc Regen (requested by fvdl in ticket #1126)
Pullup support for bge device. (Broadcom Gigabit Ethernet)
 1.431.2.17 27-Jan-2003  jmc Regen from pcidevs commits to
Add Intel 82801E Communications I/O Controller Hub (C-ICH)
 1.431.2.16 12-Dec-2002  he Pull up regenerated file (requested by ad in ticket #1030):
Add support for Adaptec 2005S.
Handle DPT ioctls() from native binaries.
Fix SCSI probe problem.
 1.431.2.15 28-Nov-2002  tron Regen for ticket #1019.
 1.431.2.14 26-Nov-2002  tron Regen for tickets #1017 and #1018.
 1.431.2.13 21-Nov-2002  tron Regen for ticket #925.
 1.431.2.12 16-Nov-2002  he Pull up regenerated files (requested by ad in ticket #646):
Add additional Adaptec RAID controller types.
Fixes PR#17719.
 1.431.2.11 07-Nov-2002  tron Regen for ticket #452.
 1.431.2.10 01-Nov-2002  tron Regen for ticket #724.
 1.431.2.9 02-Aug-2002  lukem regen (for ticket #603)
 1.431.2.8 01-Aug-2002  lukem regen (for ticket #589)
 1.431.2.7 12-Jul-2002  thorpej Regen. pullup-1-6 ticket #488 (matt).
 1.431.2.6 25-Jun-2002  lukem regen for ticket #362 from cjs
 1.431.2.5 21-Jun-2002  lukem regen for tickes #344 / #345
 1.431.2.4 11-Jun-2002  lukem regen for ticket #249
 1.431.2.3 11-Jun-2002  lukem regen for ticket #166
 1.431.2.2 11-Jun-2002  lukem regen for ticket #139
 1.431.2.1 10-Jun-2002  tv Regen.
 1.541.2.18 11-Dec-2005  christos Sync with head.
 1.541.2.17 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.541.2.16 01-Apr-2005  skrll Sync with HEAD.
 1.541.2.15 08-Mar-2005  skrll Sync with HEAD.
 1.541.2.14 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.541.2.13 04-Feb-2005  skrll Sync with HEAD.
 1.541.2.12 24-Jan-2005  skrll Sync with HEAD.
 1.541.2.11 17-Jan-2005  skrll Sync with HEAD.
 1.541.2.10 18-Dec-2004  skrll Sync with HEAD.
 1.541.2.9 29-Nov-2004  skrll Sync with HEAD.
 1.541.2.8 14-Nov-2004  skrll Sync with HEAD.
 1.541.2.7 02-Nov-2004  skrll Sync with HEAD.
 1.541.2.6 19-Oct-2004  skrll Sync with HEAD
 1.541.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.541.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.541.2.3 03-Sep-2004  skrll Sync with HEAD
 1.541.2.2 12-Aug-2004  skrll Sync with HEAD.
 1.541.2.1 03-Aug-2004  skrll Sync with HEAD
 1.613.2.17 12-Nov-2004  jmc branches: 1.613.2.17.2;
Regen (requested by martti in ticket #953)

Regen
 1.613.2.16 12-Nov-2004  jmc Regen (requested by martti in ticket #947)

Regen
 1.613.2.15 08-Oct-2004  jmc Regen for ticket #896
 1.613.2.14 18-Sep-2004  he Pull up regenerated files (requested by martin in ticket #856):
Add support for PCI-X version of LSI FC929, from PR#26836.
 1.613.2.13 30-Aug-2004  tron Regen for ticket 800.
 1.613.2.12 30-Aug-2004  tron Regen for ticket 800.
 1.613.2.11 22-Aug-2004  tron Regen for ticket 781.
 1.613.2.10 28-Jul-2004  tron Regen for ticket #721.
 1.613.2.9 28-Jul-2004  tron Regen for ticket #718.
 1.613.2.8 23-Jul-2004  he Pull up regenerated files (requested by mycroft in ticket #691):
Add support for SiS 741. Fixes PR#26394.
 1.613.2.7 05-Jul-2004  he Pull up regenerated files (requested by mycroft in ticket #606):
Update ServerWorks chip IDs, per
http://www.plasma-online.de/english/identify/picture/serverworks.html
Seems remarkably more sane.
 1.613.2.6 22-Jun-2004  tron Regen for ticket #537.
 1.613.2.5 13-May-2004  jdc Regnerate (requested by tron in ticket #316)
 1.613.2.4 11-May-2004  tron Regen for ticket 284, this time with correct revision id for "pcidevs".
 1.613.2.3 11-May-2004  tron Regen for ticket 284.
 1.613.2.2 05-Apr-2004  tron Regen for ticket 54.
 1.613.2.1 01-Apr-2004  jmc Regen (requested by tron in ticket #38)

Correct entry for PCI vendor id 0x11af. It is assigned to Avid Technology
Inc. and not to Pro-Log Corporation. PR#25004
 1.613.2.17.2.19 21-Nov-2006  ghen Regen for ticket #10749.
 1.613.2.17.2.18 11-Sep-2006  tron Regen for ticket #10693.
 1.613.2.17.2.17 04-Jun-2006  tron Regen for ticket #10635.
 1.613.2.17.2.16 11-Apr-2006  riz Regen for ticket 10409.
 1.613.2.17.2.15 17-Mar-2006  riz Regen for ticket 10364.
 1.613.2.17.2.14 01-Dec-2005  tron Regen for ticket #10158.
 1.613.2.17.2.13 01-Dec-2005  riz Regen for ticket 5990.
 1.613.2.17.2.12 21-Jul-2005  snj Regen for ticket 5507.
 1.613.2.17.2.11 05-Jul-2005  riz Regen for ticket 2029.
 1.613.2.17.2.10 21-Jun-2005  riz Regen for ticket 2007.
 1.613.2.17.2.9 19-May-2005  tron Regen for ticket 1532.
 1.613.2.17.2.8 19-May-2005  tron Regen for ticket 1531.
 1.613.2.17.2.7 19-May-2005  tron Regen for ticket 1531.
 1.613.2.17.2.6 11-May-2005  riz Regen for ticket 1402.
 1.613.2.17.2.5 10-May-2005  riz Regen for ticket 1341.
 1.613.2.17.2.4 05-May-2005  riz Regen for ticket 1153.
 1.613.2.17.2.3 01-May-2005  tron Regen for ticket 1438.
 1.613.2.17.2.2 17-Apr-2005  tron Regen for ticket 1120.
 1.613.2.17.2.1 07-Apr-2005  tron Regen for ticket 1103.
 1.684.2.1 29-Apr-2005  kent sync with -current
 1.687.2.4 26-Mar-2005  yamt sync with head.
 1.687.2.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.687.2.2 12-Feb-2005  yamt sync with head.
 1.687.2.1 25-Jan-2005  yamt file pcidevs_data.h was added on branch yamt-km on 2005-02-12 18:17:48 +0000
 1.700.2.48 10-Nov-2008  snj Regen for ticket 1976.
 1.700.2.47 08-Apr-2008  jdc Regenerate for pcidevs 1.701.2.49.
(requested by bouyer in ticket #1909).
 1.700.2.46 19-Nov-2007  bouyer Regen for ticket #1863
 1.700.2.45 19-Nov-2007  bouyer Regen for ticket 1862
 1.700.2.44 14-Oct-2007  riz Regen for ticket 1770.
 1.700.2.43 14-Oct-2007  riz Regen for ticket 1769.
 1.700.2.42 13-Sep-2007  bouyer Regen for ticket #1822
 1.700.2.41 31-Mar-2007  bouyer regen for ticket 1681
 1.700.2.40 03-Mar-2007  bouyer regen for ticket #1673
 1.700.2.39 23-Dec-2006  ghen Regen for ticket #1609.
 1.700.2.38 23-Dec-2006  ghen Regen for ticket #1608.
 1.700.2.37 20-Nov-2006  ghen Regen for ticket #1584.
 1.700.2.36 27-Aug-2006  ghen branches: 1.700.2.36.2;
Regen for ticket #1479.
 1.700.2.35 15-Aug-2006  ghen Regen for ticket #1466.
 1.700.2.34 03-Aug-2006  tron Regenerate for ticket #1446.
 1.700.2.33 31-Jul-2006  tron Regenerate for ticket #1441.
 1.700.2.32 30-Jul-2006  tron Regen for ticket #1432.
 1.700.2.31 04-Jun-2006  tron Regen for ticket #1351.
 1.700.2.30 04-Jun-2006  tron Regen for ticket #1349.
 1.700.2.29 04-May-2006  tron Regen for ticket #1298.
 1.700.2.28 30-Apr-2006  riz Regen for ticket 1295.
 1.700.2.27 20-Apr-2006  snj Regen for ticket 1266.
 1.700.2.26 08-Apr-2006  tron Regen for ticket #1247.
 1.700.2.25 17-Mar-2006  tron Regen for ticket #1203.
 1.700.2.24 15-Feb-2006  riz Regen for ticket 1169.
 1.700.2.23 14-Feb-2006  riz Sigh. Regen _again_ for ticket 1168.
 1.700.2.22 14-Feb-2006  riz Regen for ticket 1168.
 1.700.2.21 05-Feb-2006  riz Regen for ticket 1156.
 1.700.2.20 21-Jan-2006  snj Regen for ticket 1126.
 1.700.2.19 10-Jan-2006  snj Regen for ticket 1112.
 1.700.2.18 05-Jan-2006  riz Regen for ticket 1086.
 1.700.2.17 15-Dec-2005  tron branches: 1.700.2.17.2;
Regen for ticket #1047.
 1.700.2.16 24-Nov-2005  tron Regen for ticket #994.
 1.700.2.15 21-Nov-2005  tron Regen for ticket #957.
 1.700.2.14 08-Sep-2005  tron Regen for ticket #752.
 1.700.2.13 06-Sep-2005  riz Regen for ticket 748.
 1.700.2.12 24-Jul-2005  riz Regen for ticket 617.
 1.700.2.11 28-Jun-2005  tron Regen for ticket 485.
 1.700.2.10 22-Jun-2005  tron Regen for ticket 478.
 1.700.2.9 21-Jun-2005  tron Regen for ticket 476.
 1.700.2.8 18-Jun-2005  riz Regen for ticket 450.
 1.700.2.7 28-May-2005  snj Regen for ticket 323.
 1.700.2.6 10-May-2005  tron Regen for ticket 272.
 1.700.2.5 21-Apr-2005  tron Regen for ticket 180.
 1.700.2.4 07-Apr-2005  jmc Regen for ticket #59
 1.700.2.3 07-Apr-2005  jmc Regen for ticket #16
 1.700.2.2 07-Apr-2005  jmc Regen for ticket #15
 1.700.2.1 07-Apr-2005  tron Regen for ticket 116.
 1.700.2.36.2.1 04-Oct-2007  bouyer regen for ticket #1822
 1.700.2.17.2.1 04-Oct-2007  bouyer regen for ticket #1822
 1.725.2.10 27-Feb-2008  yamt sync with head.
 1.725.2.9 11-Feb-2008  yamt sync with head.
 1.725.2.8 21-Jan-2008  yamt sync with head
 1.725.2.7 07-Dec-2007  yamt sync with head
 1.725.2.6 15-Nov-2007  yamt sync with head.
 1.725.2.5 27-Oct-2007  yamt sync with head.
 1.725.2.4 03-Sep-2007  yamt sync with head.
 1.725.2.3 26-Feb-2007  yamt sync with head.
 1.725.2.2 30-Dec-2006  yamt sync with head.
 1.725.2.1 21-Jun-2006  yamt sync with head.
 1.733.2.1 02-Nov-2005  yamt sync with head.
 1.734.2.2 29-Nov-2005  yamt sync with head.
 1.734.2.1 22-Nov-2005  yamt sync with head.
 1.751.2.4 01-Mar-2006  yamt sync with head.
 1.751.2.3 18-Feb-2006  yamt sync with head.
 1.751.2.2 01-Feb-2006  yamt sync with head.
 1.751.2.1 15-Jan-2006  yamt sync with head.
 1.758.2.1 09-Sep-2006  rpaulo sync with head
 1.759.2.3 07-Jun-2006  kardel Sync with head.
 1.759.2.2 01-Jun-2006  kardel Sync with head.
 1.759.2.1 22-Apr-2006  simonb Sync with head.
 1.769.2.8 14-Sep-2006  yamt sync with head.
 1.769.2.7 03-Sep-2006  yamt sync with head.
 1.769.2.6 11-Aug-2006  yamt sync with head
 1.769.2.5 26-Jun-2006  yamt sync with head.
 1.769.2.4 24-May-2006  yamt sync with head.
 1.769.2.3 11-Apr-2006  yamt sync with head
 1.769.2.2 01-Apr-2006  yamt sync with head.
 1.769.2.1 13-Mar-2006  yamt sync with head.
 1.771.2.3 11-May-2006  elad sync with head
 1.771.2.2 19-Apr-2006  elad sync with head.
 1.771.2.1 07-Mar-2006  elad file pcidevs_data.h was added on branch elad-kernelauth on 2006-04-19 03:25:36 +0000
 1.775.2.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.775.2.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.787.2.3 22-Jun-2006  chap Complete a sync sys/ with head.
 1.787.2.2 19-Jun-2006  chap Sync with head.
 1.787.2.1 19-May-2006  chap file pcidevs_data.h was added on branch chap-midi on 2006-06-19 04:01:36 +0000
 1.792.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.814.2.7 15-Sep-2006  tron Regen for ticket #153.
 1.814.2.6 09-Sep-2006  rpaulo Regen for ticket #139.
 1.814.2.5 07-Sep-2006  riz Regen for ticket #115.
 1.814.2.4 07-Sep-2006  riz Regen for ticket #113
 1.814.2.3 07-Sep-2006  riz Regen for ticket #112.
 1.814.2.2 15-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #28):
sys/dev/pci/pcidevs: revision 1.819
sys/dev/pci/pcidevs.h: revision 1.819
sys/dev/pci/pcidevs_data.h: revision 1.818 (via patch)
sys/dev/pci/pdcsata.c: revision 1.10
Add the Promise PDC20771, present on the Promise FastTrak TX2300
Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.
This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.
The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.
The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.814.2.1 11-Aug-2006  riz Regen for ticket #8.
 1.829.2.3 01-Feb-2007  ad Sync with head.
 1.829.2.2 12-Jan-2007  ad Sync with head.
 1.829.2.1 18-Nov-2006  ad Sync with head.
 1.830.2.3 18-Dec-2006  yamt sync with head.
 1.830.2.2 10-Dec-2006  yamt sync with head.
 1.830.2.1 22-Oct-2006  yamt sync with head
 1.853.2.25 31-Oct-2008  snj Regen for ticket 1215.
 1.853.2.24 29-Sep-2008  jdc Regenerate for pullup ticket #1192.
(addd SYMBIOS SAS1068_2, SAS1064E_2 and SAS1068E_2)
 1.853.2.23 17-May-2008  bouyer Regen for ticket 1145
 1.853.2.22 17-May-2008  bouyer Regen for ticket 1143
 1.853.2.21 19-Apr-2008  bouyer Regen for ticket 1128
 1.853.2.20 09-Mar-2008  bouyer Regen for ticket #1097
 1.853.2.19 23-Feb-2008  bouyer Regen for ticket #1061
 1.853.2.18 22-Feb-2008  bouyer Regen for ticket #1074
 1.853.2.17 11-Jan-2008  xtraeme Regen for ticket #1037.
 1.853.2.16 15-Nov-2007  pavel Backout accidental commit to the release branch.
 1.853.2.15 15-Nov-2007  manu regen
 1.853.2.14 04-Nov-2007  xtraeme Regen for ticket #954.
 1.853.2.13 24-Oct-2007  pavel regen for ticket #935.
 1.853.2.12 22-Oct-2007  pavel regen for ticket #931.
 1.853.2.11 07-Oct-2007  xtraeme Regen for ticket #923.
 1.853.2.10 31-Aug-2007  pavel regen for ticket #678
 1.853.2.9 29-Aug-2007  liamjfoy Regen for ticket #846
 1.853.2.8 29-Aug-2007  liamjfoy Pull up following revision(s) (requested by masanobu in ticket #850):

sys/dev/pci/if_wm.c 1.137
sys/dev/pci/if_wm.c 1.138
sys/dev/pci/if_wm.c 1.141
sys/dev/pci/if_wm.c 1.144
sys/dev/pci/if_wmreg.h 1.23
sys/dev/pci/pcidevs 1.893
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphy.c 1.12
sys/dev/mii/miidevs 1.72
sys/dev/mii/miidevs.h regen
sys/dev/mii/miidevs_data.h regen
share/man/man4/wm.4 1.18

Fix for 82541 and 82547's reset bug.
Modify wm_reset() to make some device stable.
Add ICH9 support to wm.
Add I82566 support to igphy.

Pulled done via patch.
 1.853.2.7 26-Aug-2007  liamjfoy Regen pcidevs.h pcidevs_data.h
 1.853.2.6 10-Jun-2007  bouyer Regen for ticket 713
 1.853.2.5 02-May-2007  snj branches: 1.853.2.5.2;
Regen for ticket 597.
 1.853.2.4 21-Feb-2007  tron Regenerate for ticket #446.
 1.853.2.3 17-Feb-2007  tron Regen for ticket #449.
 1.853.2.2 17-Feb-2007  tron Regen for ticket #423.
 1.853.2.1 12-Dec-2006  tron Regen for ticket for #267.
 1.853.2.5.2.4 03-Jun-2008  skrll Sync with netbsd-4.
 1.853.2.5.2.3 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.853.2.5.2.2 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.853.2.5.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.867.2.5 17-May-2007  yamt sync with head.
 1.867.2.4 07-May-2007  yamt sync with head.
 1.867.2.3 15-Apr-2007  yamt sync with head.
 1.867.2.2 24-Mar-2007  yamt sync with head.
 1.867.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.870.2.9 23-Oct-2007  ad Sync with head.
 1.870.2.8 12-Oct-2007  ad Sync with head.
 1.870.2.7 09-Oct-2007  ad Sync with head.
 1.870.2.6 20-Aug-2007  ad Sync with HEAD.
 1.870.2.5 15-Jul-2007  ad Sync with head.
 1.870.2.4 09-Jun-2007  ad Sync with head.
 1.870.2.3 27-May-2007  ad Sync with head.
 1.870.2.2 10-Apr-2007  ad Sync with head.
 1.870.2.1 13-Mar-2007  ad Sync with head.
 1.871.4.2 29-Mar-2007  reinoud Pullup to -current
 1.871.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.871.2.1 11-Jul-2007  mjf Sync with head.
 1.884.6.13 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.884.6.12 21-Nov-2007  joerg Sync with HEAD.
 1.884.6.11 14-Nov-2007  joerg Sync with HEAD.
 1.884.6.10 31-Oct-2007  joerg Sync with HEAD.
 1.884.6.9 28-Oct-2007  joerg Sync with HEAD.
 1.884.6.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.884.6.7 02-Oct-2007  joerg Sync with HEAD.
 1.884.6.6 06-Sep-2007  jmcneill Regen.
 1.884.6.5 03-Sep-2007  jmcneill Sync with HEAD.
 1.884.6.4 27-Aug-2007  jmcneill Regen.
 1.884.6.3 16-Aug-2007  jmcneill Sync with HEAD.
 1.884.6.2 09-Aug-2007  jmcneill Sync with HEAD.
 1.884.6.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.884.2.3 10-Sep-2007  skrll Sync with HEAD.
 1.884.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.884.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.886.2.2 06-Aug-2007  martin regen
 1.886.2.1 06-Aug-2007  martin file pcidevs_data.h was added on branch matt-mips64 on 2007-08-06 22:40:09 +0000
 1.891.2.3 23-Mar-2008  matt sync with HEAD
 1.891.2.2 09-Jan-2008  matt sync with HEAD
 1.891.2.1 06-Nov-2007  matt sync with HEAD
 1.902.2.1 14-Oct-2007  yamt sync with head.
 1.904.2.4 21-Nov-2007  bouyer Sync with HEAD
 1.904.2.3 18-Nov-2007  bouyer Sync with HEAD
 1.904.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.904.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.912.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.912.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.912.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.912.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.919.4.1 11-Dec-2007  yamt sync with head.
 1.919.2.1 26-Dec-2007  ad Sync with head.
 1.920.2.3 11-Jan-2008  bouyer Sync with HEAD
 1.920.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.920.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.929.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.929.6.4 05-Oct-2008  mjf Sync with HEAD.
 1.929.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.929.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.929.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.929.2.1 24-Mar-2008  keiichi sync with head.
 1.937.4.9 09-Oct-2010  yamt sync with head
 1.937.4.8 11-Aug-2010  yamt sync with head.
 1.937.4.7 11-Mar-2010  yamt sync with head
 1.937.4.6 19-Aug-2009  yamt sync with head.
 1.937.4.5 18-Jul-2009  yamt sync with head.
 1.937.4.4 20-Jun-2009  yamt sync with head
 1.937.4.3 16-May-2009  yamt sync with head
 1.937.4.2 04-May-2009  yamt sync with head.
 1.937.4.1 16-May-2008  yamt sync with head.
 1.937.2.2 04-Jun-2008  yamt sync with head
 1.937.2.1 18-May-2008  yamt sync with head.
 1.938.2.4 10-Oct-2008  skrll Sync with HEAD.
 1.938.2.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.938.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.938.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.942.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.942.4.1 19-Oct-2008  haad Sync with HEAD.
 1.942.2.2 31-Jul-2008  simonb Sync with head.
 1.942.2.1 18-Jul-2008  simonb Sync with head.
 1.962.4.21 09-Nov-2015  sborrill Regen
 1.962.4.20 30-Apr-2015  snj regen for ticket 1962
 1.962.4.19 07-Sep-2013  bouyer Regen for ticket 1867
 1.962.4.18 19-Jun-2013  bouyer regen for ticket #1850
 1.962.4.17 20-Jan-2013  bouyer regen for ticket #1842
 1.962.4.16 17-Mar-2012  bouyer Regen for ticket 1739
 1.962.4.15 22-Nov-2010  riz branches: 1.962.4.15.2;
Regen for ticket 1470.
 1.962.4.14 20-Nov-2010  riz Regen for ticket 1362.
 1.962.4.13 19-Nov-2010  riz Regen for ticket 1359.
 1.962.4.12 19-Nov-2010  riz Regen for ticket #1358.
 1.962.4.11 28-Mar-2010  snj Regen for ticket 1326.
 1.962.4.10 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1277):
sys/dev/pci/if_wm.c 1.184-1.192, 1.194
sys/dev/pci/if_wmreg.h 1.29-1.35
sys/dev/pci/if_wmvar.h 1.5-1.8
sys/dev/pci/pcidevs 1.1006,1.1009-1.1010, 1.1012-1.1013 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/mii/igphyreg.h 1.5
sys/dev/mii/inbmphyreg.h 1.1

- Add support for i82583V.
- Add some ICH9 and ICH10 devices.
- Add support for PCH.
- Fix the bug that ICH9 can't found a PHY. Fixes PR#42237
- Fix an incorrect test for WM_F_EEPROM_INVALID since rev. 1.183. Some old
chips don't set EECD_EE_PRES.
- Fix a bug that both WM_F_EEPROM_SPI and WM_F_EEPROM_FLASH are set.
- Add a missing decrement for a timeout reported by Wolfgang Stukenbrock
in PR#42422.
- PBA setting for i82574 is not 12K but 20K.
- Enable checking the management mode on 82574.
- Fix the length of the delay() in wm_gmii_reset(). It fixed the problem that
sometimes the driver misunderstood PHYs in mii_attach(). It was reported
by MATSUI Yoshihiro. We observed it on ICH9.
- Fix the checking of jumbo frame function
- Remove the extra macro definition for the offset 0x1a in EEPROM.
- Add missing break in wm_reset()...
- Fix the offset of WMREG_PBS...
- Make wm_reset() and wm_gmii_reset() close to e1000 driver.
At least, this change make wm_attach() stable on ICH9.
- Reset GMII interface after wm_reset() in wm_init().
- Rework for assigning mii_{read,write}reg(). Use PCI product ID to identify
the PHY.
- Add code about LPLU(Low Power Link Up) function. It seems that we have to
do the same work for ICH9.
- Fixes the rx stall problem on 82578 by MANY workaround code. We need more
work for 82577.
 1.962.4.9 27-Jan-2010  sborrill Regen
 1.962.4.8 23-Jan-2010  bouyer Regen for ticket 1254
 1.962.4.7 18-Dec-2009  snj Regen for ticket 1175.
 1.962.4.6 28-Oct-2009  bouyer Regen for ticket 1114
 1.962.4.5 26-Sep-2009  snj Regen for ticket 1021.
 1.962.4.4 21-May-2009  snj Regen for ticket 771.
 1.962.4.3 05-May-2009  bouyer Regen for ticket 737
 1.962.4.2 03-May-2009  snj Regen for ticket 722.
 1.962.4.1 20-Mar-2009  msaitoh branches: 1.962.4.1.4;
Regen for ticket 587.
 1.962.4.15.2.2 14-Oct-2011  matt Regen.
 1.962.4.15.2.1 07-Jan-2011  matt Regen.
 1.962.4.1.4.9 05-Nov-2013  matt Regen.
 1.962.4.1.4.8 05-Nov-2013  matt Pull down xhci support from HEAD
 1.962.4.1.4.7 03-Jan-2012  matt Regen.
 1.962.4.1.4.6 31-Dec-2011  matt Regen.
 1.962.4.1.4.5 24-Dec-2011  matt Regen.
 1.962.4.1.4.4 10-May-2010  matt Regen.
 1.962.4.1.4.3 21-Apr-2010  matt sync to netbsd-5
 1.962.4.1.4.2 07-Apr-2010  cliff add RMI XLR PCI-X bridge
 1.962.4.1.4.1 09-Nov-2009  cliff in pcidevs:
- add vendor entry for RMI
- add product entry for RMI XLS integrated PCIe Interface
regenerate (make) pcidevs.h and pcidevs_data.h
 1.962.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.962.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.962.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.976.2.2 23-Jul-2009  jym Sync with HEAD.
 1.976.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1015.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1015.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1015.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1021.2.7 12-Jun-2011  rmind sync with head
 1.1021.2.6 31-May-2011  rmind sync with head
 1.1021.2.5 21-Apr-2011  rmind sync with head
 1.1021.2.4 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.1021.2.3 05-Mar-2011  rmind sync with head
 1.1021.2.2 03-Jul-2010  rmind sync with head
 1.1021.2.1 30-May-2010  rmind sync with head
 1.1051.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.1051.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.1051.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1078.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1095.6.7 02-Jun-2012  mrg sync to latest -current.
 1.1095.6.6 29-Apr-2012  mrg sync to latest -current.
 1.1095.6.5 05-Apr-2012  mrg sync to latest -current.
 1.1095.6.4 06-Mar-2012  mrg sync to -current
 1.1095.6.3 06-Mar-2012  mrg sync to -current
 1.1095.6.2 04-Mar-2012  mrg sync to latest -current.
 1.1095.6.1 18-Feb-2012  mrg merge to -current.
 1.1095.2.5 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1095.2.4 16-Jan-2013  yamt sync with (a bit old) head
 1.1095.2.3 30-Oct-2012  yamt sync with head
 1.1095.2.2 23-May-2012  yamt sync with head.
 1.1095.2.1 17-Apr-2012  yamt sync with head
 1.1096.2.18 30-Apr-2015  snj regen for ticket 1296
 1.1096.2.17 19-Apr-2015  riz Regen for ticket 1293.
 1.1096.2.16 07-Dec-2014  martin regen
 1.1096.2.15 04-Dec-2014  snj regen for ticket 1202
 1.1096.2.14 09-Nov-2014  martin Regen for ticket #1188
 1.1096.2.13 07-Sep-2013  bouyer regen for ticket 939
 1.1096.2.12 14-Jul-2013  riz Regen for ticket #906.
 1.1096.2.11 22-Nov-2012  riz Regen for ticket 691.
 1.1096.2.10 18-Nov-2012  msaitoh Regen for ticket #658
 1.1096.2.9 31-Oct-2012  riz Regen for ticket 643.
 1.1096.2.8 24-Oct-2012  riz Regen for ticket #631
 1.1096.2.7 24-Oct-2012  riz Regen for ticket 628.
 1.1096.2.6 28-Jun-2012  riz branches: 1.1096.2.6.2;
Regen for ticket #362.
 1.1096.2.5 23-Apr-2012  riz Regen for ticket #191.
 1.1096.2.4 16-Apr-2012  riz Regen for ticket 180.
 1.1096.2.3 03-Apr-2012  riz Regen for ticket #151.
 1.1096.2.2 03-Apr-2012  riz Regen for ticket #149.
 1.1096.2.1 22-Mar-2012  riz Regen for ticket #137.
 1.1096.2.6.2.1 18-Nov-2012  matt Merge tickets 658 and 659.
 1.1124.2.5 03-Dec-2017  jdolecek update from HEAD
 1.1124.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1124.2.3 23-Jun-2013  tls resync from head
 1.1124.2.2 25-Feb-2013  tls resync with head
 1.1124.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1149.4.1 23-Jul-2013  riastradh sync with HEAD
 1.1149.2.2 18-May-2014  rmind sync with head
 1.1149.2.1 28-Aug-2013  rmind sync with head
 1.1176.2.1 10-Aug-2014  tls Rebase.
 1.1191.2.12 14-Aug-2018  martin Regen for ticket #1628
 1.1191.2.11 03-Jan-2018  snj regen for ticket 1547
 1.1191.2.10 25-Jul-2017  snj regen for ticket 1413
 1.1191.2.9 09-Dec-2016  snj regen for ticket 1300
 1.1191.2.8 09-Dec-2016  snj regen for ticket 1298
 1.1191.2.7 08-Dec-2016  snj regen for ticket 1291
 1.1191.2.6 19-Apr-2015  riz branches: 1.1191.2.6.4;
Regen for ticket #699
 1.1191.2.5 17-Feb-2015  martin Regen (ticket #528)
 1.1191.2.4 04-Feb-2015  snj regen for ticket 473
 1.1191.2.3 28-Jan-2015  snj regen for ticket 467
 1.1191.2.2 17-Jan-2015  martin regen (ticket #432)
 1.1191.2.1 07-Nov-2014  snj regen for ticket 190
 1.1191.2.6.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.1198.2.11 28-Aug-2017  skrll Sync with HEAD
 1.1198.2.10 05-Feb-2017  skrll Sync with HEAD
 1.1198.2.9 05-Dec-2016  skrll Sync with HEAD
 1.1198.2.8 05-Oct-2016  skrll Sync with HEAD
 1.1198.2.7 09-Jul-2016  skrll Sync with HEAD
 1.1198.2.6 29-May-2016  skrll Sync with HEAD
 1.1198.2.5 19-Mar-2016  skrll Sync with HEAD
 1.1198.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1198.2.3 21-Sep-2015  skrll Regen
 1.1198.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1198.2.1 06-Apr-2015  skrll Sync with HEAD
 1.1245.2.6 26-Apr-2017  pgoyette Regen
 1.1245.2.5 26-Apr-2017  pgoyette Sync with HEAD
 1.1245.2.4 20-Mar-2017  pgoyette Sync with HEAD
 1.1245.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1245.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.1245.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.1269.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.1277.2.2 11-May-2017  pgoyette Sync with HEAD
 1.1277.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.1280.2.31 03-Feb-2024  martin regen (ticket #1931)
 1.1280.2.30 18-Oct-2023  martin regen (for ticket #1915)
 1.1280.2.29 13-Oct-2023  martin Regen for ticket #1913 (Intel 82599 LS and Pericom(Diodes) PCIe switches added)
 1.1280.2.28 13-Oct-2023  martin Regen for ticket #1911 (add ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier)
 1.1280.2.27 21-Aug-2023  martin regen (for ticket #1887)
 1.1280.2.26 29-Jul-2023  martin regen (ticket #1855)
 1.1280.2.25 21-Jun-2023  martin Regen for ticket #1846
 1.1280.2.24 18-Jan-2023  martin Regen for ticket #1783
 1.1280.2.23 11-Oct-2022  martin regen (Ticket #1771)
 1.1280.2.22 02-Aug-2022  snj regen for ticket 1754
 1.1280.2.21 03-Dec-2021  martin regen (ticket #1710)
 1.1280.2.20 23-Oct-2021  martin Regen for ticket #1700:

- Add modern QUMRANET/Red Hat VIRTIO range PCI devices.
- Add some more product IDs for mcx(4).
- Add current generation NVIDIA graphics cards (3050-3090 etc.).
- Add RDC R6022 PCI-Host bridge.
- Add a whole bunch of radeon devices.
- Add Realtek RTL8821CE.
- Add Intel 660p SSD, and expand the 760p description.
- Add Intel I219's version number.
- Add Intel I219V 15-19 and I219LM 16-19.
- Add Intel I225V, I225LM and WiFi 6 AX201.
- Add newer Intel PCH internal devices.
- Add Intel Jasper Lake devices.
- PDC20265 is Ultra/100, not 66.
- Fix Realtek RTL8125 description.
- Sort Cavium devices.
 1.1280.2.19 20-Jul-2020  martin Regen for ticket #1579
 1.1280.2.18 20-Jul-2020  martin regen for ticket #1578
 1.1280.2.17 19-Nov-2019  martin regen for ticket #1448
 1.1280.2.16 06-Aug-2019  martin regen (ticket #1326)
 1.1280.2.15 17-Jul-2019  martin regen
 1.1280.2.14 07-Mar-2019  martin Regen for ticket #1205
 1.1280.2.13 11-Feb-2019  martin Regen for ticket #1188
 1.1280.2.12 04-Dec-2018  martin Regen for ticket #1123
 1.1280.2.11 04-Dec-2018  martin Regen for #1119
 1.1280.2.10 17-Oct-2018  martin Regen for ticket #1064
 1.1280.2.9 26-Jul-2018  snj regen for ticket 934
 1.1280.2.8 15-Jun-2018  msaitoh Regen for ticket #878.
 1.1280.2.7 07-Jun-2018  martin Regen (ticket #846)
 1.1280.2.6 18-Apr-2018  martin regen for ticket #780
 1.1280.2.5 14-Apr-2018  martin regen (for ticket #751):

Add Nvidia GeForce 9400M as found in the late 2009 13" MacBook (MacBook6,1)
Add new I219 devices (using with 300 series chipset).
 1.1280.2.4 09-Apr-2018  martin Regen (ticket #723)
 1.1280.2.3 08-Mar-2018  martin Regen for ticket #616
 1.1280.2.2 21-Nov-2017  martin regen
 1.1280.2.1 25-Jun-2017  snj regen for ticket 55
 1.1310.2.15 26-Jan-2019  pgoyette Sync with HEAD
 1.1310.2.14 18-Jan-2019  pgoyette Synch with HEAD
 1.1310.2.13 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1310.2.12 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1310.2.11 20-Oct-2018  pgoyette Sync with head
 1.1310.2.10 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1310.2.9 28-Jul-2018  pgoyette Sync with HEAD
 1.1310.2.8 25-Jun-2018  pgoyette Sync with HEAD
 1.1310.2.7 21-May-2018  pgoyette Sync with HEAD
 1.1310.2.6 02-May-2018  pgoyette Synch with HEAD
 1.1310.2.5 22-Apr-2018  pgoyette Sync with HEAD
 1.1310.2.4 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1310.2.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1310.2.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.1310.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.1333.2.3 21-Apr-2020  martin Sync with HEAD
 1.1333.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1333.2.1 10-Jun-2019  christos Sync with HEAD
 1.1370.2.26 26-Oct-2025  martin Regen for ticket #1978
 1.1370.2.25 08-May-2025  martin regen for ticket #1944
 1.1370.2.24 08-May-2025  martin Regen for ticket #1944:
Various VIA IDE controller related additions/changes.
 1.1370.2.23 03-Jul-2024  martin Regen for ticket #1852 (Brainboxes devices)
 1.1370.2.22 03-Feb-2024  martin regen (ticket #1790)
 1.1370.2.21 18-Oct-2023  martin Regen for ticket #1915
 1.1370.2.20 13-Oct-2023  martin Regen for ticket #1750 (Intel 82599 LS and Pericom(Diodes) PCIe switches added)
 1.1370.2.19 13-Oct-2023  martin Regen for ticket #1748 (add ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier)
 1.1370.2.18 21-Aug-2023  martin regen (for ticket #1719)
 1.1370.2.17 29-Jul-2023  martin regen (ticket #1671)
 1.1370.2.16 21-Jun-2023  martin Regen for ticket #1654
 1.1370.2.15 30-Jan-2023  martin Regen for ticket #1580
 1.1370.2.14 18-Jan-2023  martin Regen for ticket #1566
 1.1370.2.13 11-Oct-2022  martin regen (Ticket #1537)
 1.1370.2.12 27-Jul-2022  martin regen for ticket #1482
 1.1370.2.11 03-Dec-2021  martin regen (ticket #1380)
 1.1370.2.10 21-Oct-2021  martin Regen (for ticket #1362)
 1.1370.2.9 10-Jul-2020  martin Regen for ticket #991
 1.1370.2.8 07-Jul-2020  martin regen
 1.1370.2.7 28-Apr-2020  martin Regen for ticket #864
 1.1370.2.6 19-Mar-2020  martin Regen (for ticket #784)
 1.1370.2.5 31-Jan-2020  martin regen (for ticket #670)
 1.1370.2.4 19-Nov-2019  martin Regen for ticket #449
 1.1370.2.3 24-Oct-2019  martin Regen for ticket #373
 1.1370.2.2 24-Sep-2019  martin regen for ticket #237 (Mellanox device IDs added)
 1.1370.2.1 26-Aug-2019  martin Regen for ticket #112
 1.1382.2.2 29-Feb-2020  ad Sync with head.
 1.1382.2.1 25-Jan-2020  ad Sync with head.
 1.1391.2.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.1391.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.1405.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.1405.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.1405.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.1409.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1411.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1451.2.18 26-Oct-2025  martin Regen for ticket #1184
 1.1451.2.17 08-May-2025  martin regen for ticket #1101
 1.1451.2.16 08-May-2025  martin Regen for ticket #1101:
Various VIA IDE controller related additions/changes.
 1.1451.2.15 06-Dec-2024  snj regen for ticket 1024
 1.1451.2.14 24-Aug-2024  martin Regen for ticket #805
 1.1451.2.13 03-Jul-2024  martin Regen for ticket #730 (Brainboxes devices)
 1.1451.2.12 03-Feb-2024  martin regen (ticket #560)
 1.1451.2.11 03-Nov-2023  martin Regen for ticket #447 (Add Mellanox ConnectX-6 Lx)
 1.1451.2.10 18-Oct-2023  martin Regen for ticket #421
 1.1451.2.9 13-Oct-2023  martin Regen for ticket #406 (Intel 82599 LS and Pericom(Diodes) PCIe switches added)
 1.1451.2.8 13-Oct-2023  martin Regen for ticket #403 (add ASMEDIA 0x0624 - ASM1062 + JMB575 Port Multiplier)
 1.1451.2.7 08-Oct-2023  martin Regen for ticket #393 (Add missing I225/I226 series devices)
 1.1451.2.6 21-Aug-2023  martin regen (for ticket #333)
 1.1451.2.5 29-Jul-2023  martin regen (ticket #252)
 1.1451.2.4 21-Jun-2023  martin Regen for ticket #209
 1.1451.2.3 21-Jun-2023  martin Regen for ticket #209
 1.1451.2.2 30-Jan-2023  martin Regen for ticket #61
 1.1451.2.1 18-Jan-2023  martin Regen for ticket #50
 1.1485.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1505.2.1 26-Oct-2025  martin Regen for ticket #71
 1.219 06-Nov-2010  jakllsch branches: 1.219.18;
Rework pciide(4) detachment to take the legacy interrupt mapping into
consideration and avoid future code duplication.

Ports wanting to enable detachment of controllers with compatibility-mapped
channels will need to supply a pciide_machdep_compat_intr_disestablish()
function.
 1.218 05-Nov-2010  jakllsch pciide(4): Sprinkle static, add detachment support.
 1.217 19-Oct-2009  bouyer branches: 1.217.2; 1.217.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.216 18-Mar-2008  cube branches: 1.216.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.215 16-Nov-2006  christos branches: 1.215.24; 1.215.44; 1.215.48;
__unused removal on arguments; approved by core.
 1.214 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.213 11-Dec-2005  christos branches: 1.213.20; 1.213.22;
merge ktrace-lwp.
 1.212 27-Feb-2005  perry branches: 1.212.4;
nuke trailing whitespace
 1.211 04-Feb-2005  perry de-__P
 1.210 17-Sep-2004  enami branches: 1.210.4; 1.210.6;
Whitespace nit.
 1.209 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.208 08-Oct-2003  bouyer Make the ATA mid-layer appears as atabus, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0006.html
This adds a device (atabus) between IDE controllers and wd or atapibus, to
have each ATA channel show up in the device tree. Later there will be atabus
devices in /dev, so that we can do IOCTL on them.
Each atabus has its own kernel thread, to handle operations that needs polling,
e.g. reset and others.

Device probing on each bus it defered to the atabus thread creation.
This allows to do the reset and basic device probes in parallel, which reduce
boot time on systems with several pciide controllers.
 1.207 05-Oct-2003  bouyer Remove references to University of California from my copyright notices.
 1.206 25-Sep-2003  mycroft Hide the use of config_interrupts() in one place.
 1.205 23-Sep-2003  mycroft Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.

Also remove the SINGLE_DRIVE nonsense again.
 1.204 21-Sep-2003  bouyer Ops, remove a line that escaped out of my local tree.
 1.203 21-Sep-2003  bouyer The return value from pciide_mapregs_* are ignored; make them return void.
Re-add support for HPT366 in compat mode.
 1.202 21-Sep-2003  bouyer Since we can't detect ghost drives in the wdc back-end, resurect
WDC_CAPABILITY_SINGLE_DRIVE.
 1.201 20-Sep-2003  enami Make sure the message from pciide_chipen() starts at the beginning of line.
 1.200 19-Sep-2003  mycroft 1) Use config_interrupts() to attach IDE and ATAPI drives. This eliminates
most polling.
2) Clean up some goofiness in pciide -- get rid of the whole "candisable" path
(it's gratuitous) and simplify the code by calling pciide_map_compat_intr(),
*_set_modes() and wdc_print_modes() from central locations.
3) Add a register writability and register ghost test to eliminate phantom
drives more quickly.
 1.199 17-Sep-2003  bouyer Add back support for the legacy VT8237 IDE controller.
This wasn't an error, on this chipset we have the SATA controller on function
0 of the IDE controller, not the pcib bridge.
Fix provided by Stephen Degler.
 1.198 15-Sep-2003  bouyer Add support for Intel 82801EB Serial ATA. Not tested with a drive yet,
Matthias Scheler tested that the controller attaches properly.
 1.197 15-Sep-2003  bouyer Add support for VIA 8237 Serial ATA. From Stephen Degler in kern/22727,
with some cleanup by me.
 1.196 17-Aug-2003  bouyer Add support for VIA VT8237 (KT600) IDE controller. From Stephen Degler in
PR port-i386/22453.
 1.195 10-Aug-2003  bouyer Corect offset for the promise "magic registers" (it depends on channel number).
This makes cable detect work properly for newer promise (pdc268 and newer).
 1.194 28-Jun-2003  bouyer branches: 1.194.2;
Correct setup of General Purpose Register for PDC20265 (Ultra/100) and newer.
From Andreas Johansson in private mail.
 1.193 28-Jun-2003  bouyer Add support for ICH5, from Quentin Garnier in private mail.
 1.192 17-May-2003  thorpej * Use aprint*().
* Add Ultra/133 to wdc_print_modes().
 1.191 28-Apr-2003  nakayama Make DMA mode works on Promise Ultra66/100 with 48-bit LBA drives.
Ok'ed by bouyer in tech-kern@netbsd.org.
 1.190 19-Apr-2003  christos PR/21236: Simon Hitzemann: Fix missing space in error format. While I am
there make a single copy of the error string instead of 6 and share it.
 1.189 05-Apr-2003  kent Add '(ICH3)' to the names of 82801CA for consistency with other 82801xx names
 1.188 04-Apr-2003  kent Support for ICH4M IDE Controller
 1.187 20-Mar-2003  thorpej Add support for the Silicon Image SATALink 3112 Serial ATA controller.
 1.186 19-Mar-2003  thorpej Fix pasto.
 1.185 18-Mar-2003  thorpej Add register definitions for the Intel i31244 Serial ATA controller.
 1.184 18-Mar-2003  thorpej Add very basic support for the Intel i31244 Serial ATA controller.
We only support legacy (i.e. PCI IDE compatible) mode, for now. Also
note that DMA is disabled for rev 0 chips unless explicitly enabled
with PCIIDE_I31244_ENABLEDMA.
 1.183 15-Mar-2003  bouyer Ops, I commited the previous change (improved SiS support) from thr wrong tree.
Sync with the latest diff I made available, and also include changes from
kern/20710 which is much better than the hack I've done.
 1.182 14-Mar-2003  bouyer Rework SiS support: more controller supported (up to Ultra/133) and better
support for the older ones.
Information for this work extracted from Soeren Schmidt's FreeBSD driver.
 1.181 28-Feb-2003  enami Match ServerWorks CSB6 IDE controller.
 1.180 27-Jan-2003  thorpej Experimental support for RAID volumes configured by ATA "RAID" controllers.
Such RAID controllers are actually just IDE controllers with a BIOS that
can create RAID volumes and write the configuration info to config blocks
on the disks. The BIOS can do I/O to these volumes, and the OS must
understand the config blocks and implement RAID in software in order to be
able to use these volumes.

Only SPAN (simple concatenation) and RAID0 are supported at this time,
and writing back config blocks is also not supported at this time. Currently,
only the Promise configuration scheme is supported, although supporting
the Highpoint scheme should not be too difficult.

In any case, this is sufficient to use the Promise RAID0 volume (thus
preserving the win2k AS installation) on this new Intel server I have.

Thanks to Soren Schmidt for doing the work in FreeBSD; it made this
task much easier. The config block parsing code is adapted from his
work.
 1.179 25-Jan-2003  thorpej Add a couple more Promise ATA133 controllers.
 1.178 24-Jan-2003  thorpej * Enable Ultra133 on the NVIDIA nForce 2.
* Make sure to test for PCI_VENDOR_AMD before testing for any
AMD products.
 1.177 24-Jan-2003  thorpej Add support for the NVIDIA nForce ATA100 and nForce2 ATA133
IDE controllers, which are more-or-less compatible with the
AMD controllers.

XXX Need to determine the correct timing value for the nForce2
XXX at Ultra133, so we cap it at Ultra100, for now.
 1.176 26-Dec-2002  matt Recognize Promise Serial ATA/150 TX2plus
 1.175 20-Nov-2002  bouyer For sis_setup_channel, acer_setup_channel, hpt_setup_channel,
pdc202xx_setup_channel, pdc20268_setup_channel:
Properly compute the address of the DMA control register for channel 1.
I think the controllers ignore these bits, I suspect it's only there so that
the BIOS can tell the OS is has configured DMA, but better be correct.
Thanks to Alexander Yurchenko for pointing this out.
 1.174 05-Oct-2002  kent Add support for VIA VT8235
 1.173 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.172 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.171 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.170 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.169 15-Sep-2002  bouyer Fix typo in comment. From Alexander Yurchenko <grange@rt.mipt.ru>
 1.168 25-Aug-2002  bouyer Support Ultra/133 on promise controllers that can do it.
 1.167 25-Aug-2002  bouyer Correct setup for Ultra133 capable VIA chipsets, From Matthias Drochner
on current-users, with cross-check and some improvement from linux-2.4.19
and FreeBSD-current.
Also don't set the APO_UDMA_CLK66 bit for Ultra/100 capable chipset, and
support Ultra/133 for the VT8233A.
 1.166 23-Aug-2002  bouyer Add support for HPT372. From sdegler@kashmir.degler.net in kern/17908,
with some improvement from me, and from FreeBSD.
 1.165 23-Aug-2002  bouyer Add support for Promise Ultra133TX2 and Ultra133TX2v2, from FreeBSD and
stephen@degler.net in kern/17509.
 1.164 10-Aug-2002  toshii Use UDMA/100 on SiS745 chipset.
 1.163 30-Jul-2002  bouyer Add support for the 82801DB ICH4 IDE controller, from kern/17757 by
Andreas Wrede <andreas@planix.com>
 1.162 26-Jul-2002  wiz Spell '[Rr]ight' correctly. From Jim Bernard.
 1.161 26-Jul-2002  onoe Add support of Silicon Image 0680 Ultra ATA/133 ATA Controller.
It's ugly that all register values are written in numeric, but I can't
find any definition of the registers to be written in literal.
 1.160 22-Jul-2002  bouyer Ops, this had already been commited by cjs.
Still, call the controller ATA133, even though we use it at ATA100 for now ...
 1.159 22-Jul-2002  bouyer Add VIA VT8233A support (at Ultra/100 until someone can test 133 for me).
From Ryo HAYASAKA, PR kern/17206.
 1.158 10-Jun-2002  cjs Recognise the VT8233A ATA100 controller and use Ultra-DMA mode 5 with it.
 1.157 09-Jun-2002  taca Add support for VIA Technologies's VT8231 IDE Controller to ATA/100.
 1.156 08-Jun-2002  bouyer Ops, use the proper setup_channel() function for promise adapters.
Using pdc202xx_setup_channel() for PDC20268 and newer is wrong, and will
cause trap trying to read from a non-existent register on some arches
(e.g. macppc).
pointed out by Makoto Fujiwara on port-macppc.
 1.155 04-Jun-2002  fvdl AMD 8111 DMA support.
 1.154 01-Jun-2002  bouyer Remove the "set south-bridge's enable bit" code. It doens't seems to make
any difference for rev 0xc3 controllers, and hang on 0xc4 controllers.
Fixes kern/16954
 1.153 19-May-2002  bouyer branches: 1.153.2;
Add support for HPT374. Submited by Matthew Rezny in kern/16897, with
minor adjustements by me.
 1.152 24-Apr-2002  aymeric branches: 1.152.2;
OPTi changes:
o keep WDC_CAPABILITY_DATA32 regardless of the version of the chip.
o correct typo to disable DMA correctly
 1.151 23-Apr-2002  bouyer More copyright fixes, pointed out by Thomas. Thanks !
 1.150 14-Apr-2002  bouyer bus_space_unmap() ctl_baseioh instead of ctl_ioh for the native case.
Pointed out by enami, and should fix kern/16307.
 1.149 12-Apr-2002  mycroft Add support for the ServerWorks OSB4 and CSB5 chipsets.
Note: The code is written a little more cruftily than it should be. It's also
only tested on the OSB4. I'm not sure it even makes sense to have support for
`native' mode, but I put it in just in case.
 1.148 05-Apr-2002  thorpej Reenable DMA on the Symphony/Winbond chips. The lossage I saw was
due to a broken pmap_extract() on ARM.
 1.147 04-Apr-2002  thorpej Hm, Symphony/Winbond support doens't seem to work quite right
yet; disable it for now.
 1.146 03-Apr-2002  thorpej Add bus master DMA support for the Symphony Labs 82C105 PCI IDE
controller. This part is also found in the Winbond 83C553 Southbrige.
 1.145 24-Mar-2002  bouyer Add support for the AMD768. Tested by Murray Armfield <murray@river-styx.org>.
 1.144 29-Jan-2002  bouyer Support Ultra/100 on Intel 830M. From ks@ub.uni-mainz.de on -current-users.
 1.143 28-Jan-2002  bouyer In hpt_pci_intr(): There is interrupt pending once IDEDMA_CTL_ACT is
turned off. It seems that IDEDMA_CTL_INTR is asserted before DMA transfer
is complete, leading to race condition in case of interrupt sharing.
Discovered reading the FreeBSD code.
 1.142 14-Jan-2002  augustss Add 82201CA to the chip table.
 1.141 08-Jan-2002  bouyer Fix typo in comment. Reported by Alexander Yurchenko in private mail.
 1.140 18-Dec-2001  bouyer Ops, a Ultra100>=TX2 is always in native mode !
 1.139 18-Dec-2001  bouyer The CMD0649 has 2 truly independant channel. tested by and patch from
Love <lha@stacken.kth.se>.
I suspect this is true for the 648 too; if someone with a 648 and one device
on each channel could test that all works with one_channel = 1, it would
be great !
 1.138 16-Dec-2001  bouyer dd support for the Promise Ultra100TX2, Promise Ultra100TX2v2 and Ultra133
IDE controllers. In part from OpenBSD via ragge, in part from FreeBSD.
 1.137 13-Dec-2001  bouyer pdc202xx_setup_channel: remove a duplicate line.
 1.136 21-Nov-2001  wiz Explicitly write explicitly without a second e.
 1.135 15-Nov-2001  bouyer Support Ultra/100 on CMD 0649.
 1.134 13-Nov-2001  lukem add RCSID
 1.133 26-Oct-2001  augustss Add Via KT266 as an ATA100 controller.
 1.132 21-Oct-2001  thorpej branches: 1.132.2;
Add a config flag (0x02) that can force DMA to be *disabled* on
chipsets for which it would otherwise be enabled by default.
 1.131 16-Oct-2001  tron Add UDMA/100 support for SiS chipsets 645, 650 and 730.
 1.130 14-Oct-2001  tron Use UDMA/100 on SiS 735 chipset.
 1.129 24-Sep-2001  bouyer Ali M5229 IDE controllers: tweak the rigth 0x79 register (the one from the
pci/isa bridge, not the one from the IDE controller).
 1.128 23-Aug-2001  tsutsui branches: 1.128.2;
Check 80 pins cable in acard_setup_channel() for Acard ATP860.
 1.127 03-Aug-2001  tsutsui Fix some typos in newer ALi M5229 support. Approved by bouyer.
 1.126 01-Aug-2001  tsutsui Remove unused pciide_print() declaration. From OpenBSD.
 1.125 28-Jul-2001  tsutsui Enable the Acard UIDE controllers by default.

My WDC MDMA-only (non-UDMA) drives did not work on the Acard controllers,
but it turns out that the problem was not Acard specific.
These WDC drives do not work on the ESS ISAPnP wdc port nor on
macppc obio wdc port neither, and another Quantum MDMA-only drive
works fine on the Acard.

These WDC drives work fine on my i386 pciide (which is initialized
by the BIOS), so maybe we have to do something in MI wdc to initialize
such drives properly...
 1.124 26-Jul-2001  bouyer Better support for newer ALI M5229 chipsets: support Ultra/66 for rev >= 0xC2,
Ultra/100 for revs >= 0xC4.
The the generic PCIIDE interupt routine for chipsets rev >= 0xC2 in native
mode, it seems that newer chipsets don't have the ACER_CHIDS register :(
From Linux and FreeBSD.
 1.123 23-Jul-2001  bouyer Handle HPT-370A controllers, from skanto@sjk-software.fi (kern/13540) but
with some differences to the original patch: don't assume all controllers with
rev >= HPT370_REV are HPT370, and explicitely print if we have a chip with a
rev the driver does't know.
 1.122 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.121 04-Jul-2001  bouyer branches: 1.121.2;
Better fix for rev 1.94 (disable UDMA for SiS controllers with rev 0xd0):
Different chipsets have the same vendor/device/rev ID for the IDE controller,
but only one of them is buggy. So check dev/rev ID of the function 0
(pchb on the buggy one) of the same device to detect the buggy controller.
 1.120 13-Jun-2001  scw Workaround for buggy OPTi pciide chipset revisions, as reported
in PR/11644.
 1.119 08-Jun-2001  simonb For ports that wire up pciide in compatibility mode, have
them define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
in pci_machdep.h and pciide_map_compat_intr() only calls
pciide_machdep_compat_intr_establish() if that preprocessor
define exists.

Ports that don't need to do this no longer need to supply a
dummy function.
 1.118 30-May-2001  bouyer Uninitialised variable (from Krister Walfridsson): in acard_chip_map()
drop compatchan and use the real channel number instead.
 1.117 14-May-2001  matt Add latent vendor entries for ServerWorks and Winbond IDE controllers.
No code to use them as yet.
 1.116 06-May-2001  fvdl Add amd766 support. Rename some variables to 7x6 now that it supports
both 756 and 766.
 1.115 06-May-2001  fvdl Add missing break statement.
 1.114 04-May-2001  bouyer Now that we can do it, print "HPT366" or "HPT370" depending on PCI revision.
 1.113 04-May-2001  bouyer Better support for VIA chipsets: look at the product/rev ID of the ISA bridge
to guess the pciide capabilities, rather than trying to guess it by ourselve.
Add preliminary support for the 686b (Ultra/100) guessed from FreeBSD/linux
driver (datasheet not publically available, I contacted via).
Let chip-specific map routine do the autoconf printf if ide_name is NULL
(they may have more details about the controller than we have in pciide_attach)
 1.112 21-Apr-2001  tsutsui Preliminary support for Acard ATP850/860 UDMA PCI IDE controllers.

XXX Currently disabled by default because it has some problems on macppc.
XXX Maybe some more initialization is needed, but there is few information
XXX about the chips.
 1.111 21-Apr-2001  tsutsui space -> tab
 1.110 20-Mar-2001  bouyer Don't set up PDC2xx_SCR the same way for promise Ultra/66 & Ultra/100,
this special setup seems to break some adapters.
Reported by Kazushi Marukawa.
 1.109 20-Mar-2001  bouyer Add BUS_DMA_STREAMING for the data bus_dmamap_load().
 1.108 12-Mar-2001  bouyer Support the Promise Ultra/100 at full speed, and fixes the "bogus intr"
problem some peoples reported for Promise Ultra/100.
Thanks to Chuck Silvers for giving me a Promise Ultra/100 so I could do some
tests.
 1.107 18-Feb-2001  bouyer branches: 1.107.2;
ALi controller: can only do UltraDMA for revs >= 0x20.
From OpenBSD.
 1.106 18-Feb-2001  bouyer Add support for INTEL 82801BAM IDE controller, from OpenBSD.
 1.105 12-Jan-2001  bouyer Fix bug which affects pciide controllers in native mode (found by
Paul Kranenburg, many thanks !): the control register I/O is 4 byte long
although only one is used, but the control register is at offset 2, and not
0 as expected by IC code. Use bus_space_subregion() to get a handle which
points to the control register, and is one byte long.
 1.104 05-Jan-2001  bouyer Run at Ultra/66 on VIA controllers that can do it. PCI vendor/device/revision
is the same for the Ultra/33 and Ultra/66 version, so test writability of
the U66 enable bit (idea from Chris Cappuccio).
Thanks to David Carrel for testings.
 1.103 05-Jan-2001  bouyer Ops, make it compile again.
 1.102 05-Jan-2001  bouyer Add support for Ultra/100 on intel ICH2; from Tomokazu HARADA in kern/11747.
 1.101 05-Jan-2001  bouyer Add support for Ultra/100 on the HPT370
XXX the datasheet for the HPT370 is wrong
While I'm there clear the DRIVE_DMA flag when we're going to use Ultra/DMA
where it was missed, so that wdc_print_modes() only prints what's used.
 1.100 29-Dec-2000  tsutsui s/AP0_UDMA_MASK/APO_UDMA_MASK/
 1.99 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.98 21-Dec-2000  mycroft Disable the 16-bit I/O space hack for ALL PROMISE CONTROLLERS.
This code is TOTALLY BROKEN and causes a NULL POINTER DEREFERENCE whenever it
is fired.
 1.97 17-Dec-2000  pk Cast a `bus_addr_t' argument to `u_long' for `%lx' format (XXX..)
 1.96 04-Dec-2000  fvdl Avoid format warnings.
 1.95 30-Nov-2000  thorpej Don't restrict I/O space to 16-bits on the Promise Ultra/33 boards.
Empirical evidence suggests that the board works just fine with
an I/O address >= 0x10000.
 1.94 26-Nov-2000  christos Don't try to use ultra-dma on sis chips with revision 0xd0. It loses
immediately with a lost interrupt on udma mode 2, downgrades to mode 1
at which point it silently corrupts data on high disk activity. This
happens on two out of 3 machines I own that exhibit high disk activity.
 1.93 19-Nov-2000  bouyer Add support for Intel ICH2
 1.92 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.91 08-Nov-2000  matt Make the test for dmareg >= 0x10000 quirked on IDE_16BIT_IOSPACE
 1.90 08-Nov-2000  wrstuden Move guts of pciide_print_modes() to wdc_print_modes() so that non-pciide
wdc drivers (like macppc's obio IDE interface) can use it. Also add
support to both wd attach line and to wdc_print_modes() to print
Ultra/{33,66,100} for respective UDMA modes (From Manuel Bouyer).
 1.89 05-Nov-2000  matt Don't allow use of mapreg is they are at or above 0x10000 in I/O space. (in
other words, if the address uses bits in the top 16 bits, don't use it).
 1.88 04-Oct-2000  bouyer only VT82C586A rev >= 6 supports Ultra-DMA. From OpenBSD.
 1.87 21-Aug-2000  enami Recognize Promise ATA-100 controller as PDC-20262 instead of 20246.
 1.86 21-Aug-2000  enami Match the Promise ATA-100 controller found on the mother board
MS-6321 (MSI 694D Pro). Reported in PR#10756 by Kazuki Sakamoto.
 1.85 09-Aug-2000  drochner recognize the i440MX mobile chipset's IDE interface
 1.84 02-Aug-2000  bouyer PCIIDE_CMD0646U_UDMA->PCIIDE_CMD0646U_ENABLEUDMA for consistency with
PCIIDE_AMD756_ENABLEDMA
defopt PCIIDE_CMD0646U_ENABLEUDMA, PCIIDE_AMD756_ENABLEDMA,
PCIIDE_CMD064x_DISABLE
Fix a typo pointed out by John Hawkinson
 1.83 02-Aug-2000  bouyer Add support for the CMD PCI646U. Linux claims that this driver is brocken
with UDMA, so enable Ultra-DMA only if "options PCIIDE_CMD0646U_UDMA" is set.
 1.82 01-Aug-2000  bouyer Add support for the CMD PCI0646U2, an Ultra/33 version of the 0646.
Note: there's also a PCI0646U, for which I don't have docs for now.
 1.81 27-Jul-2000  bouyer HPT370: clear disable interrupt bit; make it works in Ultra/66 mode.
 1.80 20-Jul-2000  bouyer Make it compile when PCIIDE_AMD756_ENABLEDMA is defined. From kern/10555
by MURATA Shuuichirou.
 1.79 07-Jul-2000  bouyer Use the CMD PCI0648/9 IRQ ACK code for the 0646 too, makes the 0646 works
in native mode.
 1.78 06-Jul-2000  bouyer Work around a bug in AMD756 rev D2, from patches provided by David Sainty:
disable multiword DMA for these chips. multiword DMA can be forced with
options PCIIDE_AMD756_ENABLEDMA on rev D2 chips, but use at your own risk !
While I'm there remove a duplicate allocation of sc_wdcdev.nchannels in HPT
code.
 1.77 05-Jul-2000  bouyer Back out previous, it has to be done in a different way.
 1.76 05-Jul-2000  bouyer Apply patch from David Sainty <David.Sainty@optimation.co.nz>:
Some AMD controllers have a bug which can look up the machine when using DMA, so
disable DMA for some revisions (info provided by AMD).
"options PCIIDE_AMD756_ENABLEDMA" can be used to force DMA on these chips.
 1.75 05-Jul-2000  bouyer HPT: use pciide_channels[i] not pciide_channels[0]. My HPT370 now probes
both channels (but still doesn't work properly; I suspect I got a broken one).
 1.74 04-Jul-2000  enami Match with promise ultra100/ata contoller. I haven't actually test this
contoller with ultra100 drive, but it works at least with ultra66 or more
older drive
 1.73 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.72 27-Jun-2000  tron Add special IRQ handler for CMD PCI0648 and PCI0649 taken from the
experimental version of Manuel Bouyer's driver.
 1.71 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.70 26-Jun-2000  bouyer Add support for the CMD PCI0648 and PCI0649 IDE controllers.
Thanks to Matthias Scheler for testing.
 1.69 26-Jun-2000  bouyer Correct 80 pin handling for promise Ultra/66: when the bit is set
we *don't* have a Ultra/66 cable.
 1.68 12-Jun-2000  bouyer branches: 1.68.2;
Shorter description for the HPT366
 1.67 12-Jun-2000  bouyer - add a pciide_irqack() callback, which clears the IDE DMA status bit once
the IRQ has been cleared on the drive.
- use pa->pa_class instead of re-reading PCI_CLASS_REG when possible
- Add support for Highpoint HPT366 and HPT370 (370 untested), based
on patches from Roger Brooks <R.S.Brooks@liverpool.ac.uk> posted on
current-users Mach, 15. Given how Highpoint docs have been wrong for the
366, the 370 is likely to not work.
Thanks to Chris Cappuccio <chris@dqc.org> for sending me the Highpoint
docs, and to Total Archive (http://www.totalarchive.com/) for sending
me hardware.
 1.66 07-Jun-2000  scw The OPTi controller supports a 32-bit dataport after all.
Also detect when the chip is sitting on a 25MHz PCIbus and
set the timing registers accordingly.
 1.65 07-Jun-2000  thorpej Add missing break;
 1.64 06-Jun-2000  thorpej Improve the Cypress name a little.
 1.63 06-Jun-2000  thorpej In pciide_mapreg_dma(), check to see what type the BAR is before
mapping the registers, as suggested by a comment in that function.
 1.62 06-Jun-2000  soren Shorten names of VIA controllers to fit in 80 columns with versions.
 1.61 06-Jun-2000  thorpej Actually program the DMA mode of the drives into the Cypress
controller. Fixes a long-standing problem where IDE DMA wasn't
working on the AlphaPC 164SX.
 1.60 04-Jun-2000  gmcgarry pciiide -> pciide
 1.59 27-May-2000  scw Add support for the OPTi 82c621 PCIIDE controller and its derivatives.
I only have a Compaq laptop on which to test this, so reports of
success/failure in other systems would be welcomed.
 1.58 15-May-2000  bouyer branches: 1.58.2;
Sync my copyrigth notice.
 1.57 12-May-2000  thorpej Print the revision info from the PCI configuration header. From
Dave Sainty, kern/10025.
 1.56 01-Apr-2000  bouyer - DMA code cleanup: pciide_dma_finish() doesn't stop/unload the current DMA op
if an IRQ was not detected, unless the force flag was given. Use this to
detect if the IRQ was for us (closer to shared IRQ for controllers which
don't have their own IRQ handler in pciide.c) and to poll for DMA xfer.
Also makes the timeout recovery code simpler.
- ATAPI cleanup: don't call controller-specific functions from atapiconf.c
(wdc_*), so that it's possible to attach an atapibus to something else
than a wdc/pciide (Hi Lennart :).
Overload struct scsi_adapter with struct atapi_adapter, defined
as struct scsi_adapter + atapi-specific callbacks. scsipi_link still points
to an scsi_adapter, atapi code casts it to atapi_adapter if needed.
Move atapi_softc to atapiconf.h so that it can be used by the underlying
controller code (e.g. atapi_wdc.c).
Add an atapi-specific callback *atapi_probedev(), which probe a drive
in a controller-specific way, allocate the sc_link and fills in the
ataparams if needed. It then calls atapi_probedev() (from atapiconf.c)
to do the generic initialisations and attach the device.
- While I'm there merge and centralise the state definitions in atavar.h.
It should now be possible to use a common ata/atapi routine to set the
drive's modes (will do later).
 1.55 10-Mar-2000  bouyer Don't reset cp->hw_ok ro 0 when cp isn't initialised in cy693_chip_map()
(used only in failure case). Pointed out by Wolfgang Solfrank.
While I'm here correct indentation.
 1.54 09-Mar-2000  soren Move PCIIDE_CHANNEL_NAME macro to pciidereg.h.
 1.53 06-Mar-2000  bouyer Add support for the AMD 756 DMA/UDMA IDE controller, provided in
PR kern/9536 by Dave Sainty.
 1.52 18-Jan-2000  bouyer Clean up revision stuff for the sis. Suggested by Chris Cappuccio.
 1.51 16-Jan-2000  bouyer From chris@openbsd.org:
"Don't enable UDMA modes for revisions of SiS 5513 < 0xd0
The only revisions I know which don't actually support UDMA are 0x09 and below..
But the only revision I know which does support UDMA is 0xd0 (and presumably
above that)"
 1.50 26-Dec-1999  soren Lower-case Bus-Master for consistency.
 1.49 12-Dec-1999  thorpej Use htole32() and le32toh().
 1.48 28-Nov-1999  bouyer Improve Ultra/66 support now that I've got some docs from Promise.
 1.47 13-Nov-1999  soren Export softc.
 1.46 03-Nov-1999  mycroft Fix silly error that caused the secondary channel to be ignored if the primary
channel was disabled.
 1.45 25-Oct-1999  bouyer Add a missing '\n' in the cmd0640 attach printfs.
 1.44 02-Sep-1999  ross branches: 1.44.2; 1.44.4; 1.44.6;
Make it compile.
 1.43 01-Sep-1999  bouyer Don't try to unmap unmapped space in case of failure in
pciide_mapregs_compat(). From OpenBSD.
 1.42 30-Aug-1999  bouyer Add support for Intel 810 chipset (ICH/ICH0).
While I'm there merge back piix_channel_map into piix_chip_map.
 1.41 29-Aug-1999  bouyer Add support for the Promise Ultra/33 and /66 pci IDE controller. In addition to
chip-dependant code this required the following changes:
- Instead of attaching the device in a generic way with some chip-dependant
routines, use a chip-dependant attach routine with some common code
factored out. The code is marginally bigger, but this allows the CMD64x
flag hack to go away.
- For chips that report per-channel 'irq triggered', test this before calling
wdcintr() for the native-pci irq case (compat intr can't be shared),
as wdcintr() has no good way to know if a irq was for it or not, and
ends up with irq loss. XXX for chips that don't have this feature irq sharing
will not work properly !
- add my copyrigth notice (could have been done some time ago I think :)

There are still some issues to be solved with the Promise controller and
ATAPI devices.
Many thanks to Paul Newhouse for shipping me 2 Ultra/33 boards for doing this
work.
 1.40 12-Jul-1999  bouyer Fix typo in a printf, from Soren S. Jorvan.
 1.39 08-Jun-1999  mrg fix a few KNF nits ..
 1.38 27-May-1999  bouyer For the PIIX, make sure the PIO_mode and DMA_mode get reset to the values used
by the controller for all drives.
 1.37 05-May-1999  bouyer Fix the way we compute the mode to use: for multiword DMA, the used mode was
2 less than the one we could really use, so for multiword DMA mode 0 or 1,
the driver tried to use DMA mode 255 or 254 (0 - 2 with a u_int8_t).
 1.36 03-May-1999  ross Protect WDCDEBUG from multiple definitions.
 1.35 28-Apr-1999  thorpej Make PCI IDE DMA work on big-endian systems.
 1.34 06-Apr-1999  bouyer Kill an extra 'pciide0: ' in a printf
 1.33 22-Feb-1999  bouyer branches: 1.33.2;
In cy693_setup_channel(), setup timings for IOR too (they were left to 0,
which is a way too higth timing for some devices). Thanks to Ken Wellsch
for trying the multiple debug kernels until the problem was located.
 1.32 16-Feb-1999  bouyer Correctly compute PIO/DMA mode for sis and acer chips when the drive support
a DMA mode with higther capabilities than PIO mode.
 1.31 02-Feb-1999  bouyer channel_map is called before setup_chip, so whe need to enable the channel
status bits in acer_channel_map().
 1.30 02-Feb-1999  bouyer Support for Acerlab M5229 IDE controller. Thanks to Thilo Manske for testing
the code, and to Takahiro Kambe who run several tests and finally found the
bug by himself :)
 1.29 16-Dec-1998  bouyer Defer mapping of pci interrupt to pciide_mapregs_native(). This way,
the native interrupt shouldn't be mapped if a channel is in native mode,
but disabled.
 1.28 16-Dec-1998  bouyer Rearange the modes setup to allow these to be dyanmically changed. Fill
in the new "set_mode" callback.
 1.27 03-Dec-1998  bouyer Rename pio_mode, etc ... to PIO_cap, etc ... for consistency with the
ata_drive_datas struct. Suggested by Soren S. Jorvan.
 1.26 03-Dec-1998  bouyer Now that vtophy() is no longuer used, re-enable WDCDEBUG, with
wdcdebug_pciide_mask = 0 (so that one can easily patch this variable and give
me more informations :)
 1.25 03-Dec-1998  bouyer add a udma_mode field to wdc_softc, and use it the same way dma_mode is used
(higthest ultra-dma mode supported). There may be a higther ultra-dma mode
defined ...
 1.24 03-Dec-1998  bouyer Use correct register when disabling the second channel.
 1.23 03-Dec-1998  bouyer Restore changes from revision 1.17:
"If a channel has no drives, do *not* unmap its I/O regions.
It's not really safe to use them for anything else, and in legacy mode it
will just cause us to probe the channel again as an ISA device."
 1.22 03-Dec-1998  bouyer Correct a few bogons in the SiS chip initialisation.
 1.21 03-Dec-1998  bouyer Ouh ! Correct the 8-bit PCI registers reading/writing functions: need to
multiply the register offset by 8.
 1.20 02-Dec-1998  bouyer - change drive_flags from u_int8_t to u_int16_t
- keep the modes supported by the drive in struct ata_drive_datas (will be
later used for downgrading the DMA/PIO mode on error)
- use config flags to force/disable PIO/DMA/UDMA modes
- For the CMD PCI0643/6 setup DMA mode to DMA Read multiple.
 1.19 24-Nov-1998  drochner a small optimization for the compat interrupt handling, possible after
channel_softc is within pciide_channel
 1.18 21-Nov-1998  drochner some restructuring, more or less to get support for weird IDE controllers,
eg the Cypress ISA bridge:
-put channel mapping into the chip specific part, unify with
channel_probe() into channel_map()
-use pointer to channel data as function call argument wherever possible
instead of the channel number
-allow the "compat" channel number to differ from the per-controller
channel number - for mapping and interrupt functions
-add support for SiS5598 and Cypress 82C693 chips
Mostly done by Manuel, I only contributed to the first 2 items.
 1.17 17-Nov-1998  mycroft If a channel has no drives, do *not* unmap its I/O regions.
It's not really safe to use them for anything else, and in legacy mode it
will just cause us to probe the channel again as an ISA device.
 1.16 12-Nov-1998  bouyer Force PCI_COMMAND_MASTER_ENABLE if DMA has been setup properly. The BIOS is
supposed to do it but who knows ...
 1.15 11-Nov-1998  bouyer - clearify the boot messages (features supported vs features used). Thanks to
Havard Eidnes for his complains about this :)
- fix some typo in comments
- hoppefully better detection of drives reporting bogus PIO modes.
 1.14 09-Nov-1998  bouyer Support for the CMD PCI064{3,6}. Tested on a 0646 with a
"wd0: PIO mode 4, DMA mode 2, UDMA mode 2" device.
 1.13 22-Oct-1998  bouyer Add config flags for pciide: 0x001 forces the use of DMA when the driver
don't know how to set the controller's modes.
 1.12 20-Oct-1998  bouyer Fix for Apollo DMA mode (not UDMA): DMA mode = PIO mode - 2, not PIO mode + 2 !
 1.11 19-Oct-1998  bouyer Add support for the second flavour of the VIA IDE chip (which has UDMA).
Don't claim DMA support if we don't have explicit support for this chip.
They're to may way to loose when trying to use DMA without configuring the
controller and disks.
 1.10 13-Oct-1998  bouyer pciide.c: don't define WDCDEBUG, so it compiles on alpha. Correct a bogon
in the printing of DMA mode (piix3/4 only)
others: set the debug_mask to 0, so that debug messages are turned off by
default but can be easily turned on.
Reset drive_flags to 0 for unconfigured devices, so that they are ignored
later. For configured devices, reset state to 0 after probe/attach.
 1.9 12-Oct-1998  bouyer Merge bouyer-ide
 1.8 14-Aug-1998  drochner 2 changes to pciide_probe_wdc() (used in compatibility mode to check
if i drive is responding):
-if the reset succeeds, check some registers to make sure there is really
a drive (and not a chipset which echoes back the last written value)
-explicitely select the master before trying to read the master's status
 1.7 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.6 12-Mar-1998  cgd branches: 1.6.2;
when considering attaching compatibility-mode channels, try a quick reset
and see if anything responds. if nothing (that's attributable to the
PCI IDE controller) responds, then that channel either has no devices on
it or has been disabled (via a non-standard mechanism) by the BIOS. If nothing
responds, don't map the compat.-mode interrupt or attach the wdc to that
channel, because the BIOS is likely to assign that IRQ to a different PCI
device. If that happens, the kernel will panic because that device will
try to map the IRQ level-triggered, but the compat interrupt will have been
mapped edge-triggered. (One possible way around this is to map the compat
interrupt edge-triggered, but it's not clear reading the spec that this
is correct or desirable.)
 1.5 06-Mar-1998  cgd reorganize mapping/attachment of wdc channels so that it'll be easier to
insert a check to see whether a channel appears to be enabled. Shouldn't
be necessary, according to the spec, but some PC chipsets allow individual
compatibility channels to be disabled. "I hate PCs."
 1.4 06-Mar-1998  cgd despite the spec, some people map the bus master IDE registers into
memory space. Note that in a comment, but don't try to fix it (for now).
 1.3 04-Mar-1998  cgd clean up a printf
 1.2 04-Mar-1998  cgd slight cleanup (consistency, make a few comments better). add support
for recognizing bus-master DMA interface and mapping the regs (but
still no support for DMA).
 1.1 04-Mar-1998  cgd PCI IDE glue. Right now, just glues 'wdc's to PCI IDE controller
channels. Eventually should do things like support PCI IDE DMA (it _DOES
NOT_ do that now).
 1.6.2.17 05-Oct-1998  bouyer Rename WDC_CAPABILITY_PIO to WDC_CAPABILITY_MODE, as it's used to tell wether
the controller's driver can tell which timing mode it uses. Check this
before setting DMA modes too.
This allow the generic DMA code to work again.
 1.6.2.16 04-Oct-1998  bouyer atavar.h: drv_softc is a struct device * instead of void*, as it's mostly
used for dv_xname
wd.c: convert for drv_softc type change, printf cleanup
wdc.c: always call ata_get_params() (params was used initialised with
non-32bit controllers, leaving to bogus PIO/DMA mode report).
Cleaup of the PIO/DMA mode message.
pciide_piix_reg.h: Fix definition of PIIX_IDETIM_CLEAR (unused before)
pciide.c: add a method do disable a channel on know device. If a channel
doesn't have any drive, we disable it and free its resources if disable
was successfull. This should help with laptops where the second channel
of the PIIX4 is unused but not disabled by BIOS. On such laptops,
irq15 can be used for PCMCIA but it was claimed by pciide.
Misc printf cleanup.
wdc_isa.c: printf cleanup.
 1.6.2.15 02-Oct-1998  bouyer Cleanup a few error message, remove some dead code. Re-add a reset at end of
attach, unless we have WDC_NO_EXTRA_RESETS.
Add support for data32iot/data32ioh from -current: each controller pass
WDC_CAPABILITY_DATA32 if they can do 32bit, and WDC_CAPABILITY_DATA16 if they
can do 16bit. For controller that support both, the usual autodetect
mechanism is still used.
 1.6.2.14 20-Sep-1998  bouyer - always call config_found() from wdcattach(), instead of printing our own
the "not configured" message ourselve. When no atapibus is configured,
use a fake ata_atapi_attach, else call wdc_atapibus_attach(). This way we
don't have to include the whole atapi support in an ata-only config.
- the dma_* function pointers take a 'int flags' as last argument, instead
of an 'int read'. The 2 valid flags are: WDC_DMA_READ (to select read/write)
and WDC_DMA_POLL, to signal interrupt-less mode (for core dumps).
- Reworked wdcprobe() so look more like the old one. A status of 0xff is
interpreted as "no drive" (freebsd does this); this this speed up
the probe for non-IDE machines (a reset timeout has been bumped to 31s,
to match the specs). The probe set ups the drive flags to either ATA or
ATAPI (depend on register signature) or OLD (if register signature don't
match, but a working drive appears to be there). Later the ATA code
will look at the OLD flag to decide wether there is no drive, or an old
(ST506) one if WDC_IDENTIFY fails.
- For known PCI chips, don't use the wdcprobe() heuristic to find wether
a channel is enabled/disabled; use the chip's specific registers for this.
- Clear the command queue when we have a polled command. This allows dumps to
work even if a command was being handled by the controller at panic time.
- Increase the number of available DMA segments by one, as user requests may
not be aligned on a page boundary.
 1.6.2.13 21-Aug-1998  bouyer Sync with -current
 1.6.2.12 13-Aug-1998  bouyer - sync with -current
- full support of CMD PCI0640 chips. This needs a special probe routine, as
this chip doesn't honnor the "PCI_COMMAND_IO_ENABLE" bit. sigh.
- do not map the native pci interrupts if we don't have a native channel.
some chips (e.g. PCI0640) have a valid interrupt value which gets
established, which may prevent the compat channel or some other ISA
device from working properly later.
- b* -> mem*
 1.6.2.11 25-Jun-1998  bouyer Add support for VIA's apollo VP chipset.
 1.6.2.10 17-Jun-1998  bouyer in piix3_4_setup(), drvp is not a pointer to an array, but a pointer to the
rigth element of the array. This was breaking more-or-less badly on configs
with a slave drive on a channel.
 1.6.2.9 13-Jun-1998  bouyer Coorect a comment.
 1.6.2.8 12-Jun-1998  bouyer Correct a bug where the PIO mode would not be set up for the controller,
if UDMA mode is used. Ultra-DMA/33 works !
 1.6.2.7 11-Jun-1998  bouyer pciide: when setting up DMA mode, also enable fast timings for PIO modes
if possible. For ATAPI devices, commands are always send via PIO.
atapi: matain a drive state (like wd drives) and use it to set up the
timings if needed.
 1.6.2.6 10-Jun-1998  bouyer - Fix timing settings for DMA: the controller was always set up to use
DMA mode 0 (compatible).
- The 2 Ultra-dma registers are in fact one 32-bit register.
Change the macros and setup in a way it may now work (but still untested,
thus not enabled by default).
- For DMA mode 1, use a more efficient timing than the one suggested
by intel.
Some work is still needed here to get ATAPI DMA working (should be done soon).
 1.6.2.5 09-Jun-1998  bouyer - sync with trunck
- for the piix, don't set timings for nonexistent drives.
 1.6.2.4 06-Jun-1998  bouyer Renamed pciide_pIIx_reg.h to pciide_piix_reg.h via repository copy,
as suggested by Soren S. Jorvan.
 1.6.2.3 05-Jun-1998  bouyer Disable Ultra DMA for now, as it does not work.
 1.6.2.2 05-Jun-1998  bouyer A few bux fixes (untested):
- If the PIO mode of the controller is unknown, put the drive in the
hightest mode it supports. A drive in a faster mode than the controller
should work.
- Create DMA maps even for unknown controllers in pciide.
 1.6.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.33.2.11 14-Aug-2000  he Pull up revision 1.84 (via patch, requested by bouyer):
Change PCIIDE_CMD0646U_UDMA to PCIIDE_CMD0646U_ENABLEUDMA
for consistency with PCIIDE_AMD756_ENABLEDMA.
 1.33.2.10 14-Aug-2000  he Pull up revisions 1.82-1.83 (requested by bouyer):
Add UltraDMA support for the CMD PCI0646U and PCI0646U2 controllers;
normally disabled on PCI0646U due to a chip bug, but can be
enabled with a kernel option.
 1.33.2.9 27-Jul-2000  he Pull up revision 1.81 (requested by bouyer):
Clear the interrupt disable bit of the HPT370, and document HPT370
support.
 1.33.2.8 27-Jul-2000  he Pull up revision 1.80 (requested by bouyer):
Make pciide compile with ``options PCIIDE_AMD756_ENABLEDMA.''
Fixes PR#10555.
 1.33.2.7 23-Jul-2000  he Pull up revision 1.79 (requested by bouyer):
Handle CMD PCI0646 interrupts as for the PCI0648; makes the
PCI0646 work in native mode with shared interrupts.
 1.33.2.6 23-Jul-2000  he Pull up revision 1.74 (requested by bouyer):
Add support for the Promise Ultra/100 PCI IDE controller (in
Ultra/66 mode only).
 1.33.2.5 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.33.2.4 24-Jun-1999  perry pullup 1.37->1.38 (bouyer)
 1.33.2.3 05-May-1999  perry branches: 1.33.2.3.2; 1.33.2.3.4;
pullup 1.36->1.37 (bouyer)
 1.33.2.2 28-Apr-1999  perry sync to 1.35 (thorpej): fixes PCIIDE DMA on big-endian systems
 1.33.2.1 06-Apr-1999  bouyer Kill an extra 'pciide0:' in a printf.
 1.33.2.3.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.33.2.3.2.2 02-Aug-1999  thorpej Update from trunk.
 1.33.2.3.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.44.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.44.4.1 15-Nov-1999  fvdl Sync with -current
 1.44.2.9 23-Apr-2001  bouyer Sync with HEAD.
 1.44.2.8 27-Mar-2001  bouyer Sync with HEAD.
 1.44.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.44.2.6 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.44.2.5 15-Jan-2001  bouyer req_sense_length is dead.
 1.44.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.44.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.44.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.44.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.58.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.68.2.33 22-Apr-2002  he Pull up revision 1.150 (requested by bouyer):
Fix use of bus_space_unmap() for the native case. Fixes PR#16307.
 1.68.2.32 25-Mar-2002  he Pull up revision 1.145 (requested by bouyer):
Add support for the pciide part of the AMD-768 chipset.
 1.68.2.31 09-Feb-2002  he Pull up revision 1.143 (requested by bouyer):
In hpt_pci_intr(), accept interrupt only once IDEDMA_CTL_ACT is
turned off. Fixes DMA errors, lost interrupts, and other nasty
errors with some HPT730s in native mode.
 1.68.2.30 06-Feb-2002  he Pull up revisions 1.112,1.118,1.125,1.128 (via patch, requested by tsutsui):
Add support for Acard ATP-850/860 pciide controllers.
 1.68.2.29 05-Jan-2002  he Pull up revision 1.135 (requested by bouyer):
Support Ultra-DMA 100 on the CMD 0649.
 1.68.2.28 13-Nov-2001  he Pull up revision 1.123 (requested by bouyer):
Support HPT-370A controllers. Fixes PR#13540.
 1.68.2.27 13-Nov-2001  he Pull up revision 1.121 (requested by bouyer):
Disable UDMA only for SiS controllers which are really buggy,
not all the ones with revision 0xd0.
 1.68.2.26 29-Jul-2001  he Pull up revision 1.120 (requested by scw):
Workaround for buggy OPTi pciide chipset revisions, as reported
in PR#11644.
 1.68.2.25 02-Jul-2001  jhawk Pull up revision 1.94 (requested by bouyer):
Don't try to use ultra-dma on sis chips with revision 0xd0. It loses
immediately with a lost interrupt on udma mode 2, downgrades to mode 1
at which point it silently corrupts data on high disk activity.
 1.68.2.24 15-May-2001  he Pull up revisions 1.113-1.116 (via patch, requested by bouyer):
Add support for newer VIA pciide controllers.
Add support for the AMD 766 pciide controller.
Properly distinguish between HPT366 and HPT370 controllers.
 1.68.2.23 24-Apr-2001  he Pull up revision 1.110 (requested by bouyer):
Revert setting of PDC2xx_SCR for Promise Ultra/100, it seems to
break with some adapters.
 1.68.2.22 13-Mar-2001  he Pull up revision 1.108 (requested by bouyer):
Support Ultra/100 speed on Promise Ultra/100, and fix ``bogus
intr'' messages generated under some conditions.
 1.68.2.21 26-Feb-2001  he Pull up revision 1.107 (requested by bouyer):
Disable Ultra-DMA on Ali controllers which don't support it.
 1.68.2.20 26-Feb-2001  he Pull up revision 1.106 (requested by bouyer):
Add support for the Intel 82801BAM IDE controller.
 1.68.2.19 04-Feb-2001  he Pull up revision 1.105 (requested by bouyer):
Fix bug which affects pciide controllers in native mode. Main
effect was a non-functionnal IDE controller on some sparc64 and
macppc when booted from IDE disk.
 1.68.2.18 04-Feb-2001  he Pull up revisions 1.102-1.103 (requested by bouyer):
Add support for Ultra/100 on Intel ICH2.
 1.68.2.17 04-Feb-2001  he Pull up revision 1.104 (requested by bouyer):
Run at Ultra/66 on VIA controllers that can do it.
 1.68.2.16 04-Feb-2001  he Pull up revision 1.101 (requested by bouyer):
Add support for Ultra/100 on the HPT370 controller.
 1.68.2.15 15-Dec-2000  he Pull up revision 1.93 (requested by bouyer):
Add support for Intel ICH2 IDE controller.
 1.68.2.14 04-Oct-2000  bouyer Pull up 1.87->1.88, approved by thorpej:
only VT82C586A rev >= 6 supports Ultra-DMA. From OpenBSD.
 1.68.2.13 22-Aug-2000  enami Pullup rev. 1.87 (approved by jhawk):
Recognize Promise ATA-100 controller as PDC-20262 instead of 20246.
 1.68.2.12 22-Aug-2000  enami Pullup rev. 1.86 (approved by jhawk and thorpej):
Match the Promise ATA-100 controller found on the mother board
MS-6321 (MSI 694D Pro). Reported in PR#10756 by Kazuki Sakamoto.
 1.68.2.11 03-Aug-2000  bouyer Pull up (approved by thorpej):
sys/dev/pci/pciide.c 1.82 -> 1.84
sys/dev/pci/pciide_cmd_reg.h 1.8 -> 1.9
sys/dev/pci/files.pci 1.100 -> 1.101
share/man/man4/pciide.4 1.23 -> 1.24

Add support for the CMD PCI646U. Linux claims that this driver is brocken
with UDMA, so enable Ultra-DMA only if "options PCIIDE_CMD0646U_ENABLEUDMA"
is set.
defopt PCIIDE_CMD0646U_ENABLEUDMA, PCIIDE_AMD756_ENABLEDMA,
PCIIDE_CMD064x_DISABLE
Fix a typo pointed out by John Hawkinson
Update documentation.
 1.68.2.10 02-Aug-2000  bouyer Pull up (approved by thorpej):
pciide_cmd_reg.h 1.7 -> 1.8
pciide.c 1.81 -> 1.82
Add supports for the PCI0646U2, Ultra/33 version of the PCI0646.
 1.68.2.9 27-Jul-2000  bouyer Pull up (approved by thorpej):
sys/dev/pci/pciide.c 1.80 -> 1.81
sys/dev/pci/pciide_hpt_reg.h 1.1 -> 1.2
distrib/notes/i386/hardware 1.74 -> 1.75
share/man/man4/pciide.4 1.22 -> 1.23
Make sure the HPT370's interrupts disable bit is cleared. Now that HPT370
supports works, document it.
 1.68.2.8 20-Jul-2000  bouyer Pull up 1.80 (approved by thorpej):
Make is compile when PCIIDE_AMD756_ENABLEDMA is defined; close PR kern/10555.
 1.68.2.7 19-Jul-2000  bouyer Pull up 1.79, approved by thorpej:
Use the CMD PCI0648/9 IRQ ACK code for the 0646 too, makes the 0646 works
in native mode.
 1.68.2.6 07-Jul-2000  bouyer Pull up
pciide.c 1.77 -> 1.78
pciide_amd_reg.h 1.1 -> 1.2
(approved by thorpej): workaround for a bug in some revs of the AMD IDE
controller, which can lock up the machine when multiword DMA is used.
 1.68.2.5 06-Jul-2000  enami Pull up rev. 1.74 (approved by releng-1-5):
Match with promise ultra100/ata contoller. I haven't actually test this
contoller with ultra100 drive, but it works at least with ultra66 or more
older drive
 1.68.2.4 05-Jul-2000  bouyer Pull up rev 1.75, approved by thorpej:
Fix a error where we would always try to attach channel 0 of an HPT controller
(only aftects HPT370, the 366 has only one channel per pciide function).
 1.68.2.3 27-Jun-2000  tron Really pull up revision 1.72.
 1.68.2.2 27-Jun-2000  bouyer Pull up
pciide.c 1.69->1.70, 1.71->1.72
pciide_cmd_reg.h 1.6->1.7
Approved by thorpej:
Add support for the CMD PCI0648/0649 IDE controller.
 1.68.2.1 27-Jun-2000  bouyer Pull up 1.69, approved by thorpej:
Fix promise Ultra/66 cable detection: the Ultra/66 cable detection bit
was interpreted backward.
 1.107.2.20 29-Dec-2002  thorpej Sync with HEAD.
 1.107.2.19 11-Dec-2002  thorpej Sync with HEAD.
 1.107.2.18 18-Oct-2002  nathanw Catch up to -current.
 1.107.2.17 17-Sep-2002  nathanw Catch up to -current.
 1.107.2.16 27-Aug-2002  nathanw Catch up to -current.
 1.107.2.15 13-Aug-2002  nathanw Catch up to -current.
 1.107.2.14 01-Aug-2002  nathanw Catch up to -current.
 1.107.2.13 20-Jun-2002  nathanw Catch up to -current.
 1.107.2.12 17-Apr-2002  nathanw Catch up to -current.
 1.107.2.11 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.107.2.10 28-Feb-2002  nathanw Catch up to -current.
 1.107.2.9 11-Jan-2002  nathanw More catchup.
 1.107.2.8 08-Jan-2002  nathanw Catch up to -current.
 1.107.2.7 14-Nov-2001  nathanw Catch up to -current.
 1.107.2.6 22-Oct-2001  nathanw Catch up to -current.
 1.107.2.5 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.107.2.4 21-Sep-2001  nathanw Catch up to -current.
 1.107.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.107.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.107.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.121.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.121.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.121.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.121.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.121.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.121.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.121.2.1 03-Aug-2001  lukem update to -current
 1.128.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.132.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.152.2.3 29-Aug-2002  gehenna catch up with -current.
 1.152.2.2 20-Jun-2002  gehenna catch up with -current.
 1.152.2.1 30-May-2002  gehenna Catch up with -current.
 1.153.2.17 12-Jul-2004  he Pull up revision 1.187 (via patch, requested by grant in ticket #1720):
Add support for SATALink 3112.
 1.153.2.16 28-Mar-2004  jmc Pullup rev 1.196 via patch (requested by bouyer in ticket #1632)

Add support for VIA VT8237 (KT600) IDE controller. PR#22453
 1.153.2.15 28-Mar-2004  jmc Pullup rev 1.195 (requested by bouyer in ticket #1630)

Correct offset for the promise "magic registers" (it depends on channel number).
This makes cable detect work properly for newer promise (pdc268 and newer).
 1.153.2.14 16-Aug-2003  tron Pull up revision 1.194 (requested by bouyer in ticket #1369):
Correct setup of General Purpose Register for PDC20265 (Ultra/100) and newer.
From Andreas Johansson in private mail.
 1.153.2.13 16-Aug-2003  tron Pull up revision 1.193 via patch (requested by bouyer in ticket #1367):
Add support for ICH5, from Quentin Garnier in private mail.
 1.153.2.12 16-Jun-2003  grant Apply patch (requested by bouyer in ticket #1234):

Rework SiS support: more controller supported (up to Ultra/133) and better
support for the older ones.
Information for this work extracted from Soeren Schmidt's FreeBSD driver.

Ops, I commited the previous change (improved SiS support) from the wrong tree.
Sync with the latest diff I made available, and also include changes from
kern/18015 which is much better than the hack I've done.
 1.153.2.11 28-Apr-2003  tron Pull up revision 1.191 (requested by nakayama in ticket #1275):
Make DMA mode works on Promise Ultra66/100 with 48-bit LBA drives.
Ok'ed by bouyer in tech-kern@netbsd.org.
 1.153.2.10 28-Nov-2002  tron Pull up revision 1.174 (requested by kent in ticket #1019):
Add support for VIA VT8235
 1.153.2.9 01-Nov-2002  tron Pull up revision 1.168 (requested by bouyer in ticket #728):
Support Ultra/133 on promise controllers that can do it.
 1.153.2.8 01-Nov-2002  tron Pull up revision 1.167 (requested by bouyer in ticket #727):
Correct setup for Ultra133 capable VIA chipsets, From Matthias Drochner
on current-users, with cross-check and some improvement from linux-2.4.19
and FreeBSD-current.
Also don't set the APO_UDMA_CLK66 bit for Ultra/100 capable chipset, and
support Ultra/133 for the VT8233A.
 1.153.2.7 01-Nov-2002  tron Pull up revision 1.166 (requested by bouyer in ticket #725):
Add support for HPT372. From sdegler@kashmir.degler.net in kern/17908,
with some improvement from me, and from FreeBSD.
 1.153.2.6 01-Nov-2002  tron Pull up revision 1.165 (requested by bouyer in ticket #724):
Add support for Promise Ultra133TX2 and Ultra133TX2v2, from FreeBSD and
stephen@degler.net in kern/17509.
 1.153.2.5 02-Aug-2002  lukem pull up revisions 1.158-1.160 (requested by bouyer in ticket #603):
1.160:
Ops, this had already been commited by cjs. Still, call the
controller ATA133, even though we use it at ATA100 for now ...
1.159:
Add VIA VT8233A support (at Ultra/100 until someone can test 133 for
me). From Ryo HAYASAKA, PR kern/17206.
1.158:
Recognise the VT8233A ATA100 controller and use Ultra-DMA mode
5 with it.
 1.153.2.4 01-Aug-2002  lukem Pull up revision 1.163 (requested by bouyer in ticket #590):
Add support for the 82801DB ICH4 IDE controller, from kern/17757 by
Andreas Wrede <andreas@planix.com>
 1.153.2.3 10-Jun-2002  tv Pull up revision 1.157 (requested by taca in ticket #228):
Add support for VIA Technologies's VT8231 IDE Controller to ATA/100.
 1.153.2.2 10-Jun-2002  tv Pull up revision 1.156 (requested by bouyer in ticket #214):
Ops, use the proper setup_channel() function for promise adapters.
Using pdc202xx_setup_channel() for PDC20268 and newer is wrong, and will
cause trap trying to read from a non-existent register on some arches
(e.g. macppc).
pointed out by Makoto Fujiwara on port-macppc.
 1.153.2.1 04-Jun-2002  lukem pull up rev 1.154 (requested by bouyer in #129):
Remove the "set south-bridge's enable bit" code. It doens't seems to make
any difference for rev 0xc3 controllers, and hang on 0xc4 controllers.
Fixes kern/16954
 1.194.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.194.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.194.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.194.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.194.2.1 03-Aug-2004  skrll Sync with HEAD
 1.210.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.210.6.1 12-Feb-2005  yamt sync with head.
 1.210.4.1 29-Apr-2005  kent sync with -current
 1.212.4.2 24-Mar-2008  yamt sync with head.
 1.212.4.1 30-Dec-2006  yamt sync with head.
 1.213.22.2 10-Dec-2006  yamt sync with head.
 1.213.22.1 22-Oct-2006  yamt sync with head
 1.213.20.1 18-Nov-2006  ad Sync with head.
 1.215.48.1 03-Apr-2008  mjf Sync with HEAD.
 1.215.44.1 24-Mar-2008  keiichi sync with head.
 1.215.24.1 23-Mar-2008  matt sync with HEAD
 1.216.4.1 11-Mar-2010  yamt sync with head
 1.217.4.1 05-Mar-2011  rmind sync with head
 1.217.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.219.18.2 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.219.18.1 12-Sep-2012  tls Initial snapshot of work to eliminate 64K MAXPHYS. Basically works for
physio (I/O to raw devices); needs more doing to get it going with the
filesystems, but it shouldn't damage data.

All work's been done on amd64 so far. Not hard to add support to other
ports. If others want to pitch in, one very helpful thing would be to
sort out when and how IDE disks can do 128K or larger transfers, and
adjust the various PCI IDE (or at least ahcisata) drivers and wd.c
accordingly -- it would make testing much easier. Another very helpful
thing would be to implement a smart minphys() for RAIDframe along the
lines detailed in the MAXPHYS-NOTES file.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file pciide.c.orig was initially added on branch thorpej_scsipi.
 1.1.2.2 20-Nov-2000  bouyer Remove files that should not have been added
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8 14-May-2008  tsutsui Normalize my licenses.
 1.7 25-Dec-2007  perry branches: 1.7.6; 1.7.8; 1.7.10; 1.7.12;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.6 11-Dec-2005  christos branches: 1.6.46; 1.6.52; 1.6.56; 1.6.60;
merge ktrace-lwp.
 1.5 08-May-2005  tsutsui branches: 1.5.2;
ACARD ATP865-A (used on AEC-6280/6880) supports UltraDMA/133 too.
 1.4 27-Feb-2005  perry nuke trailing whitespace
 1.3 24-Oct-2003  tsutsui branches: 1.3.8; 1.3.10;
Add support for Acard ATP865/A Ultra100 IDE Controllers. From Tsubai Masanari.
 1.2 21-Oct-2001  thorpej branches: 1.2.4; 1.2.20;
Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.1 21-Apr-2001  tsutsui branches: 1.1.2; 1.1.4; 1.1.6;
Preliminary support for Acard ATP850/860 UDMA PCI IDE controllers.

XXX Currently disabled by default because it has some problems on macppc.
XXX Maybe some more initialization is needed, but there is few information
XXX about the chips.
 1.1.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.3 22-Oct-2001  nathanw Catch up to -current.
 1.1.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.4.1 21-Apr-2001  nathanw file pciide_acard_reg.h was added on branch nathanw_sa on 2001-06-21 20:05:10 +0000
 1.1.2.2 23-Apr-2001  bouyer Sync with HEAD.
 1.1.2.1 21-Apr-2001  bouyer file pciide_acard_reg.h was added on branch thorpej_scsipi on 2001-04-23 09:42:30 +0000
 1.2.20.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.20.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.20.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.20.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.20.1 03-Aug-2004  skrll Sync with HEAD
 1.2.4.2 06-Feb-2002  he Pull up revision 1.1 (new, requested by tsutsui):
Add support for Acard ATP-850/860 pciide controllers.
 1.2.4.1 21-Oct-2001  he file pciide_acard_reg.h was added on branch netbsd-1-5 on 2002-02-06 14:18:08 +0000
 1.3.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.8.1 29-Apr-2005  kent sync with -current
 1.5.2.1 21-Jan-2008  yamt sync with head
 1.6.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.56.1 26-Dec-2007  ad Sync with head.
 1.6.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.46.1 09-Jan-2008  matt sync with HEAD
 1.7.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.10.1 16-May-2008  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.13 21-Jul-2017  nakayama Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.

The patch is from port-sparc64@.
 1.12 19-Oct-2009  bouyer branches: 1.12.18; 1.12.22; 1.12.38; 1.12.40; 1.12.56;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.11 25-Dec-2007  perry branches: 1.11.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.10 11-Dec-2005  christos branches: 1.10.46; 1.10.52; 1.10.56; 1.10.60;
merge ktrace-lwp.
 1.9 06-Aug-2005  bouyer Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
 1.8 27-Feb-2005  perry branches: 1.8.2; 1.8.4;
nuke trailing whitespace
 1.7 05-Oct-2003  bouyer branches: 1.7.6; 1.7.8; 1.7.10;
Remove references to University of California from my copyright notices.
 1.6 23-Apr-2002  bouyer branches: 1.6.10;
More copyright fixes, pointed out by Thomas. Thanks !
 1.5 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.4 26-Jul-2001  bouyer Better support for newer ALI M5229 chipsets: support Ultra/66 for rev >= 0xC2,
Ultra/100 for revs >= 0xC4.
The the generic PCIIDE interupt routine for chipsets rev >= 0xC2 in native
mode, it seems that newer chipsets don't have the ACER_CHIDS register :(
From Linux and FreeBSD.
 1.3 15-May-2000  bouyer branches: 1.3.6; 1.3.8;
Sync my copyrigth notice.
 1.2 29-Aug-1999  bouyer branches: 1.2.2;
Add support for the Promise Ultra/33 and /66 pci IDE controller. In addition to
chip-dependant code this required the following changes:
- Instead of attaching the device in a generic way with some chip-dependant
routines, use a chip-dependant attach routine with some common code
factored out. The code is marginally bigger, but this allows the CMD64x
flag hack to go away.
- For chips that report per-channel 'irq triggered', test this before calling
wdcintr() for the native-pci irq case (compat intr can't be shared),
as wdcintr() has no good way to know if a irq was for it or not, and
ends up with irq loss. XXX for chips that don't have this feature irq sharing
will not work properly !
- add my copyrigth notice (could have been done some time ago I think :)

There are still some issues to be solved with the Promise controller and
ATAPI devices.
Many thanks to Paul Newhouse for shipping me 2 Ultra/33 boards for doing this
work.
 1.1 02-Feb-1999  bouyer branches: 1.1.2;
Support for Acerlab M5229 IDE controller. Thanks to Thilo Manske for testing
the code, and to Takahiro Kambe who run several tests and finally found the
bug by himself :)
 1.1.2.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.8.1 03-Aug-2001  lukem update to -current
 1.3.6.3 20-Jun-2002  nathanw Catch up to -current.
 1.3.6.2 22-Oct-2001  nathanw Catch up to -current.
 1.3.6.1 24-Aug-2001  nathanw Catch up with -current.
 1.6.10.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.10.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.10.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.7.6.1 07-Aug-2005  riz Pull up revision 1.9 via patch (requested by bouyer in ticket #5555):
Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
 1.8.4.2 21-Jan-2008  yamt sync with head
 1.8.4.1 21-Jun-2006  yamt sync with head.
 1.8.2.1 18-Aug-2005  tron Pull up revision 1.9 (requested by bouyer in ticket #653):
Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
 1.10.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.10.56.1 26-Dec-2007  ad Sync with head.
 1.10.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.46.1 09-Jan-2008  matt sync with HEAD
 1.11.10.1 11-Mar-2010  yamt sync with head
 1.12.56.1 25-Jul-2017  snj Pull up following revision(s) (requested by nakayama in ticket #153):
sys/dev/pci/aceride.c: revision 1.37
sys/dev/pci/pciide_acer_reg.h: revision 1.13
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.
The patch is from port-sparc64@.
 1.12.40.1 28-Aug-2017  skrll Sync with HEAD
 1.12.38.1 26-Jul-2017  snj Pull up following revision(s) (requested by nakayama in ticket #1458):
sys/dev/pci/aceride.c: revision 1.37
sys/dev/pci/pciide_acer_reg.h: revision 1.13
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.
The patch is from port-sparc64@.
 1.12.22.1 03-Dec-2017  jdolecek update from HEAD
 1.12.18.1 23-Jul-2017  snj Pull up following revision(s) (requested by nakayama in ticket #1463):
sys/dev/pci/aceride.c: revision 1.37
sys/dev/pci/pciide_acer_reg.h: revision 1.13
Apply workaround from FreeBSD to fix read data corruption observed
on Fire V100 and mSATA-SSD with mSATA to IDE adapter.
The patch is from port-sparc64@.
 1.7 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.6 24-Jan-2003  thorpej branches: 1.6.2;
* Enable Ultra133 on the NVIDIA nForce 2.
* Make sure to test for PCI_VENDOR_AMD before testing for any
AMD products.
 1.5 24-Jan-2003  thorpej Add support for the NVIDIA nForce ATA100 and nForce2 ATA133
IDE controllers, which are more-or-less compatible with the
AMD controllers.

XXX Need to determine the correct timing value for the nForce2
XXX at Ultra133, so we cap it at Ultra100, for now.
 1.4 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.3 06-May-2001  fvdl branches: 1.3.2;
Add amd766 support. Rename some variables to 7x6 now that it supports
both 756 and 766.
 1.2 06-Jul-2000  bouyer branches: 1.2.2; 1.2.4; 1.2.6;
Work around a bug in AMD756 rev D2, from patches provided by David Sainty:
disable multiword DMA for these chips. multiword DMA can be forced with
options PCIIDE_AMD756_ENABLEDMA on rev D2 chips, but use at your own risk !
While I'm there remove a duplicate allocation of sc_wdcdev.nchannels in HPT
code.
 1.1 06-Mar-2000  bouyer branches: 1.1.4;
Add support for the AMD 756 DMA/UDMA IDE controller, provided in
PR kern/9536 by Dave Sainty.
 1.1.4.2 15-May-2001  he Pull up revision 1.3 (requested by bouyer):
Add support for newer VIA pciide controllers.
Add support for the AMD 766 pciide controller.
Properly distinguish between HPT366 and HPT370 controllers.
 1.1.4.1 07-Jul-2000  bouyer Pull up
pciide.c 1.77 -> 1.78
pciide_amd_reg.h 1.1 -> 1.2
(approved by thorpej): workaround for a bug in some revs of the AMD IDE
controller, which can lock up the machine when multiword DMA is used.
 1.2.6.2 22-Oct-2001  nathanw Catch up to -current.
 1.2.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.4.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.1 06-Jul-2000  bouyer file pciide_amd_reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:34 +0000
 1.2.2.2 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.2.2.1 06-Jul-2000  he file pciide_amd_reg.h was added on branch netbsd-1-4 on 2000-07-07 17:33:50 +0000
 1.3.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21 03-Apr-2025  andvar viaide(4): Add support for VIA VT6415/VT6330 single-channel IDE controllers.

Beyond adding the usual identification code, several adjustments were required:

1) Introduced 'single_channel` to set 'nchannels` to 1 for this controller.

2) Added 'APO_IDECONF_ALWAYS_EN` definition and the 'no_ideconf` flag to mimic
enabled channel bits, as this controller's enable chip register is unset.
Applied the same to VT6410, following OpenBSD and Linux, since some
controllers are known to not set this register as well.

3) Combined all VIA controllers identified by PCI ID (not ISA bus) using switch
fallthrough, as they currently share the same UDMA setting. Consequently,
the VX900 name printing was moved to the device description and adjusted
to better reflect the device.

4) Moved setting interface bits for RAID controllers under the RAID capability
check, enabling the above fallthrough and paving the way for support of other
RAID-capable controllers in upcoming changes.

5) The VT6330 is a combo FireWire/IDE controller. Added its FireWire controller
PCI ID to pcidevs.

Tested on ASRock P5B-DE.

Reviewed by jak and bad.

Addresses PR kern/45917
 1.20 10-Jul-2011  jakllsch branches: 1.20.60; 1.20.86; 1.20.92;
Add complete support for all channels on VT6421A SATA/PATA controller to
viaide(4).
 1.19 30-Jun-2011  wiz dependant -> dependent
 1.18 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.17 25-Dec-2007  perry branches: 1.17.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.16 11-Dec-2005  christos branches: 1.16.46; 1.16.52; 1.16.56; 1.16.60;
merge ktrace-lwp.
 1.15 27-Feb-2005  perry branches: 1.15.4;
nuke trailing whitespace
 1.14 08-Oct-2003  bouyer branches: 1.14.8; 1.14.10;
Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.13 05-Oct-2003  bouyer Remove references to University of California from my copyright notices.
 1.12 25-Aug-2002  bouyer branches: 1.12.6;
Correct setup for Ultra133 capable VIA chipsets, From Matthias Drochner
on current-users, with cross-check and some improvement from linux-2.4.19
and FreeBSD-current.
Also don't set the APO_UDMA_CLK66 bit for Ultra/100 capable chipset, and
support Ultra/133 for the VT8233A.
 1.11 23-Apr-2002  bouyer branches: 1.11.2; 1.11.4;
More copyright fixes, pointed out by Thomas. Thanks !
 1.10 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.9 04-May-2001  bouyer branches: 1.9.2;
Better support for VIA chipsets: look at the product/rev ID of the ISA bridge
to guess the pciide capabilities, rather than trying to guess it by ourselve.
Add preliminary support for the 686b (Ultra/100) guessed from FreeBSD/linux
driver (datasheet not publically available, I contacted via).
Let chip-specific map routine do the autoconf printf if ide_name is NULL
(they may have more details about the controller than we have in pciide_attach)
 1.8 05-Jan-2001  bouyer branches: 1.8.2;
Run at Ultra/66 on VIA controllers that can do it. PCI vendor/device/revision
is the same for the Ultra/33 and Ultra/66 version, so test writability of
the U66 enable bit (idea from Chris Cappuccio).
Thanks to David Carrel for testings.
 1.7 29-Dec-2000  tsutsui s/AP0_UDMA_MASK/APO_UDMA_MASK/
 1.6 15-May-2000  bouyer branches: 1.6.4;
Sync my copyrigth notice.
 1.5 18-Jan-2000  bouyer Correct URLs.
 1.4 16-Dec-1998  bouyer branches: 1.4.2; 1.4.8;
Rearange the modes setup to allow these to be dyanmically changed. Fill
in the new "set_mode" callback.
 1.3 19-Oct-1998  bouyer Fix a comment.
 1.2 12-Oct-1998  bouyer Merge bouyer-ide
 1.1 25-Jun-1998  bouyer branches: 1.1.2;
file pciide_apollo_reg.h was initially added on branch bouyer-ide.
 1.1.2.1 25-Jun-1998  bouyer Add support for VIA's apollo VP chipset.
 1.4.8.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.4.8.2 05-Jan-2001  bouyer Sync with HEAD
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.6.4.2 15-May-2001  he Pull up revision 1.9 (via patch, requested by bouyer):
Add support for newer VIA pciide controllers.
Add support for the AMD 766 pciide controller.
Properly distinguish between HPT366 and HPT370 controllers.
 1.6.4.1 04-Feb-2001  he Pull up revision 1.8 (requested by bouyer):
Run at Ultra/66 on VIA controllers that can do it.
 1.8.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.8.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.8.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.9.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.9.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.4.1 01-Nov-2002  tron Pull up revision 1.12 (requested by bouyer in ticket #727):
Correct setup for Ultra133 capable VIA chipsets, From Matthias Drochner
on current-users, with cross-check and some improvement from linux-2.4.19
and FreeBSD-current.
Also don't set the APO_UDMA_CLK66 bit for Ultra/100 capable chipset, and
support Ultra/133 for the VT8233A.
 1.11.2.1 29-Aug-2002  gehenna catch up with -current.
 1.12.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.8.1 29-Apr-2005  kent sync with -current
 1.15.4.1 21-Jan-2008  yamt sync with head
 1.16.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.16.56.1 26-Dec-2007  ad Sync with head.
 1.16.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.16.46.1 09-Jan-2008  matt sync with HEAD
 1.17.10.1 11-Mar-2010  yamt sync with head
 1.20.92.1 02-Aug-2025  perseant Sync with HEAD
 1.20.86.1 09-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1101):

sys/dev/pci/viaide.c: revision 1.90
sys/dev/pci/ahcisata_pci.c: revision 1.72
sys/dev/pci/pciide_apollo_reg.h: revision 1.21
sys/dev/pci/viaide.c: revision 1.91
sys/dev/pci/viaide.c: revision 1.92
sys/dev/pci/viaide.c: revision 1.93
sys/dev/pci/viaide.c: revision 1.94
sys/dev/pci/viaide.c: revision 1.96
sys/dev/pci/viaide.c: revision 1.97
sys/dev/pci/viaide.c: revision 1.98
share/man/man4/viaide.4: revision 1.11
share/man/man4/viaide.4: revision 1.12

Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
Add VIA VT8261 southbridge SATA controller IDs and PCIB.
viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.
Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.
via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.
Fixes PR kern/59010.
Reviewed and approved by jakllsch@.

Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.
These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.
This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.
The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

viaide(4): add IDE controller identification by the VT8237S ISA bridge.
The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.
Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaurs demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.


viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.
The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.
Tested on ECS VX900-I.
Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.
Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).
Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.
Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.
For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html
Should fix and close PR kern/37517.
Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.
Reviewed by bad.
viaide(4): check if chip enable register returns 0 before emulating enable
bits.
At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
viaide(4): update the list of supported VIA controllers.
viaide(4): remove notes section about VT6421, it is not currently required to
setup RAID/JBOD sets to access drives.
 1.20.60.1 09-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1944):

sys/dev/pci/viaide.c: revision 1.90
sys/dev/pci/ahcisata_pci.c: revision 1.72
sys/dev/pci/pciide_apollo_reg.h: revision 1.21
sys/dev/pci/viaide.c: revision 1.91
sys/dev/pci/viaide.c: revision 1.92
sys/dev/pci/viaide.c: revision 1.93
sys/dev/pci/viaide.c: revision 1.94
sys/dev/pci/viaide.c: revision 1.96
sys/dev/pci/viaide.c: revision 1.97
sys/dev/pci/viaide.c: revision 1.98
share/man/man4/viaide.4: revision 1.11
share/man/man4/viaide.4: revision 1.12

Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
Add VIA VT8261 southbridge SATA controller IDs and PCIB.
viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.
Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.
via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.
Fixes PR kern/59010.
Reviewed and approved by jakllsch@.

Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.
These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.
This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.
The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

viaide(4): add IDE controller identification by the VT8237S ISA bridge.
The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.
Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaurs demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.


viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.
The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.
Tested on ECS VX900-I.
Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.
Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).
Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.
Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.
For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html
Should fix and close PR kern/37517.
Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.
Reviewed by bad.
viaide(4): check if chip enable register returns 0 before emulating enable
bits.
At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
viaide(4): update the list of supported VIA controllers.
viaide(4): remove notes section about VT6421, it is not currently required to
setup RAID/JBOD sets to access drives.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file pciide_apollo_reg.h.orig was initially added on branch thorpej_scsipi.
 1.1.2.2 20-Nov-2000  bouyer Remove files that should not have been added
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18 05-Dec-2021  msaitoh s/followings bits/following bits/ in comment.
 1.17 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.16 25-Dec-2007  perry branches: 1.16.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.15 11-Dec-2005  christos branches: 1.15.46; 1.15.52; 1.15.56; 1.15.60;
merge ktrace-lwp.
 1.14 27-Feb-2005  perry branches: 1.14.4;
nuke trailing whitespace
 1.13 05-Oct-2003  bouyer branches: 1.13.8; 1.13.10;
Remove references to University of California from my copyright notices.
 1.12 23-Apr-2002  bouyer branches: 1.12.10;
More copyright fixes, pointed out by Thomas. Thanks !
 1.11 15-Nov-2001  bouyer Support Ultra/100 on CMD 0649.
 1.10 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.9 02-Aug-2000  bouyer branches: 1.9.2; 1.9.4;
Add support for the CMD PCI646U. Linux claims that this driver is brocken
with UDMA, so enable Ultra-DMA only if "options PCIIDE_CMD0646U_UDMA" is set.
 1.8 01-Aug-2000  bouyer Add support for the CMD PCI0646U2, an Ultra/33 version of the 0646.
Note: there's also a PCI0646U, for which I don't have docs for now.
 1.7 26-Jun-2000  bouyer Add support for the CMD PCI0648 and PCI0649 IDE controllers.
Thanks to Matthias Scheler for testing.
 1.6 15-May-2000  bouyer branches: 1.6.4;
Sync my copyrigth notice.
 1.5 29-Aug-1999  bouyer branches: 1.5.2;
Add support for the Promise Ultra/33 and /66 pci IDE controller. In addition to
chip-dependant code this required the following changes:
- Instead of attaching the device in a generic way with some chip-dependant
routines, use a chip-dependant attach routine with some common code
factored out. The code is marginally bigger, but this allows the CMD64x
flag hack to go away.
- For chips that report per-channel 'irq triggered', test this before calling
wdcintr() for the native-pci irq case (compat intr can't be shared),
as wdcintr() has no good way to know if a irq was for it or not, and
ends up with irq loss. XXX for chips that don't have this feature irq sharing
will not work properly !
- add my copyrigth notice (could have been done some time ago I think :)

There are still some issues to be solved with the Promise controller and
ATAPI devices.
Many thanks to Paul Newhouse for shipping me 2 Ultra/33 boards for doing this
work.
 1.4 02-Dec-1998  bouyer branches: 1.4.4;
- change drive_flags from u_int8_t to u_int16_t
- keep the modes supported by the drive in struct ata_drive_datas (will be
later used for downgrading the DMA/PIO mode on error)
- use config flags to force/disable PIO/DMA/UDMA modes
- For the CMD PCI0643/6 setup DMA mode to DMA Read multiple.
 1.3 09-Nov-1998  bouyer Support for the CMD PCI064{3,6}. Tested on a 0646 with a
"wd0: PIO mode 4, DMA mode 2, UDMA mode 2" device.
 1.2 12-Oct-1998  bouyer Merge bouyer-ide
 1.1 13-Aug-1998  bouyer branches: 1.1.2;
file pciide_cmd_reg.h was initially added on branch bouyer-ide.
 1.1.2.1 13-Aug-1998  bouyer - sync with -current
- full support of CMD PCI0640 chips. This needs a special probe routine, as
this chip doesn't honnor the "PCI_COMMAND_IO_ENABLE" bit. sigh.
- do not map the native pci interrupts if we don't have a native channel.
some chips (e.g. PCI0640) have a valid interrupt value which gets
established, which may prevent the compat channel or some other ISA
device from working properly later.
- b* -> mem*
 1.4.4.2 14-Aug-2000  he Pull up revisions 1.8-1.9 (requested by bouyer):
Add UltraDMA support for the CMD PCI0646U and PCI0646U2 controllers;
normally disabled on PCI0646U due to a chip bug, but can be
enabled with a kernel option.
 1.4.4.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.4.4 05-Jan-2002  he Pull up revision 1.11 (via patch, requested by bouyer):
Support Ultra-DMA 100 on the CMD 0649.
 1.6.4.3 03-Aug-2000  bouyer Pull up (approved by thorpej):
sys/dev/pci/pciide.c 1.82 -> 1.84
sys/dev/pci/pciide_cmd_reg.h 1.8 -> 1.9
sys/dev/pci/files.pci 1.100 -> 1.101
share/man/man4/pciide.4 1.23 -> 1.24

Add support for the CMD PCI646U. Linux claims that this driver is brocken
with UDMA, so enable Ultra-DMA only if "options PCIIDE_CMD0646U_ENABLEUDMA"
is set.
defopt PCIIDE_CMD0646U_ENABLEUDMA, PCIIDE_AMD756_ENABLEDMA,
PCIIDE_CMD064x_DISABLE
Fix a typo pointed out by John Hawkinson
Update documentation.
 1.6.4.2 02-Aug-2000  bouyer Pull up (approved by thorpej):
pciide_cmd_reg.h 1.7 -> 1.8
pciide.c 1.81 -> 1.82
Add supports for the PCI0646U2, Ultra/33 version of the PCI0646.
 1.6.4.1 27-Jun-2000  bouyer Pull up
pciide.c 1.69->1.70, 1.71->1.72
pciide_cmd_reg.h 1.6->1.7
Approved by thorpej:
Add support for the CMD PCI0648/0649 IDE controller.
 1.9.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.9.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.9.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.12.10.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.10.1 03-Aug-2004  skrll Sync with HEAD
 1.13.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.8.1 29-Apr-2005  kent sync with -current
 1.14.4.1 21-Jan-2008  yamt sync with head
 1.15.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.56.1 26-Dec-2007  ad Sync with head.
 1.15.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.15.46.1 09-Jan-2008  matt sync with HEAD
 1.16.10.1 11-Mar-2010  yamt sync with head
 1.73 03-Oct-2025  thorpej Use device_{get,set}prop_bool() for "pciide-disable-dma".
 1.72 16-Apr-2025  andvar Introduce the ATADEBUG_PCIIDE_MASK option to allow setting the
atadebug_pciide_mask variable, similar to the existing ATADEBUG_MASK
and ATADEBUG_WD_MASK options used in ata/ata.c and ata/wdc.c

No functional changes intended by default.

approved by bouyer.
 1.71 31-Mar-2024  thorpej branches: 1.71.2;
As the final step in configuraing bus-master DMA, consult the boolean device
property "pciide-disable-dma" and disable bus-master DMA if that property is
present and true.
 1.70 20-Nov-2023  thorpej pciide_dma_dmamap_setup(): If we end up with a DMA segment with an odd
length or odd starting address, unload the map and return EINVAL. Some
controllers get really upset if a DMA segment has an odd address or length.
This can happen if a physio user performs a virtually-contiguous I/O that
starts at an odd address and spans a page boundary where the resulting
physical pages are discontiguous. The EINVAL return will cause the upper
layers in the ATA code to re-try the I/O using PIO, which should (will
in all of my tests) succeed.

PR port-alpha/56434
 1.69 20-Nov-2023  thorpej Revert previous. I'm going to make a slight change to the patch, and
want it collapsed into a single commit to make it easier to pull into
netbsd-10.
 1.68 20-Nov-2023  thorpej pciide_dma_dmamap_setup(): If we end up with a DMA segment with an odd
length, unload the map and return EIO. Some controllers get really upset
if a DMA segment has an odd length. This can happen if a physio user
performs a virtually-contiguous I/O that starts at an odd address and spans
a page boundary where the resulting physical pages are discontiguous.

Ultimately, it's up to the physio user to paint inside the lines, but this
will prevent the disk controller from wandering off into the weeds, at least.

PR port-alpha/56434
 1.67 24-Aug-2020  msaitoh branches: 1.67.20;
s/ressource/resource/. No functional change.
 1.66 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.65 20-Oct-2017  jdolecek branches: 1.65.2; 1.65.4;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.64 17-Oct-2017  jdolecek reintroduce ATACH_IRQ_WAIT flag for attachments using wdcintr(), only
process the interrupt when the flag is set - this fixes spurious interrupt
during post-reset drive setup in wdc_ata_bio_start(), and wdc_atapi_start()

while those functions set WDCTL_IDS, this seems to be ignored by certain
(maybe all) PCI-IDE controllers; usually the implicit KERNEL_LOCK() would
prevent the interrupt anyway, but not when the start routine is started
from the atabus thread, which doesn't take it

fixes 'panic: wdc_ata_bio_intr: bad state' reported on current-users
by Chavdar Ivanov
 1.63 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.62 13-Oct-2016  jdolecek branches: 1.62.4;
provide intr xname
 1.61 07-Jul-2016  msaitoh branches: 1.61.2;
KNF. Remove extra spaces. No functional change.
 1.60 29-Mar-2014  christos branches: 1.60.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.59 22-Jun-2013  matt branches: 1.59.2;
When allocating the channel queue, make sure the return memory is zeroed.
 1.58 14-Nov-2012  jakllsch don't attempt to re-unmap the interrupt on detach
 1.57 31-Jul-2012  bouyer branches: 1.57.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.56 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.55 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.54 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.53 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.52 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.51 17-May-2011  dyoung branches: 1.51.4; 1.51.8;
PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.50 10-May-2011  dyoung Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.49 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.48 17-Nov-2010  dholland branches: 1.48.2;
Fix build when NATA_DMA is 0.
 1.47 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.46 06-Nov-2010  jakllsch Rework pciide(4) detachment to take the legacy interrupt mapping into
consideration and avoid future code duplication.

Ports wanting to enable detachment of controllers with compatibility-mapped
channels will need to supply a pciide_machdep_compat_intr_disestablish()
function.
 1.45 05-Nov-2010  jakllsch Correct copy/paste error in as-of-yet-unused pciide_common_detach().
 1.44 05-Nov-2010  jakllsch Pave the way for detachment of pciide(4)-family ATA controllers.
 1.43 19-Oct-2009  bouyer branches: 1.43.2; 1.43.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.42 23-Aug-2009  jmcneill Print device description on the same line as locators.
 1.41 15-Mar-2009  cegger ansify function definitions
 1.40 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.39 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.38 18-Mar-2008  cube branches: 1.38.4; 1.38.12; 1.38.18;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.37 04-Mar-2007  christos branches: 1.37.16; 1.37.32; 1.37.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.36 09-Feb-2007  ad branches: 1.36.2;
Merge newlock2 to head.
 1.35 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.34 17-Oct-2006  itohy Silence unused variable warning.
 1.33 17-Oct-2006  itohy Make pciide(4)-only configurations (without other DMA-capable driver) compile.
 1.32 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.31 29-Mar-2006  thorpej branches: 1.31.8; 1.31.10;
Use device_cfdata().
 1.30 17-Jan-2006  bouyer branches: 1.30.2; 1.30.4; 1.30.6; 1.30.8; 1.30.10;
Add missing ch_ndrive initialisations. Pointed out by Juan RP.
 1.29 04-Jan-2006  bouyer Fix forcing use of DMA mode for the generic pciide driver: default_chip_map()
is called from pciide_attach() and at this point we don't know which drives
are here. Just assume all drives are there and allocate DMA ressources for
all of them.
 1.28 11-Dec-2005  christos branches: 1.28.2;
merge ktrace-lwp.
 1.27 29-May-2005  christos branches: 1.27.2;
Add a const.
 1.26 27-Feb-2005  perry branches: 1.26.2;
nuke trailing whitespace
 1.25 15-Feb-2005  briggs Allow MAXPHYS-sized instead of IDEDMA_BYTE_COUNT_MAX-sized transfers
to be described by a transfer table.
 1.24 15-Feb-2005  briggs Move the definition of NIDEDMA_TABLES from pciidereg.h to be closer to
its only user in pciide_common.c. Also redefine NIDEDMA_TABLES to match
the max DMA transfer size specified in the call to bus_dmamap_create()
(IDEDMA_BYTE_COUNT_MAX instead of MAXPHYS).
The macro is also redefined to handle devices that have a PAGE_SIZE greater
than sc_dma_maxsegsz (buggy revision of satalink 3112 on ibm4xx).
 1.23 04-Feb-2005  perry de-__P
 1.22 24-Nov-2004  bouyer branches: 1.22.4; 1.22.6;
Move bus_dma setup out of pciide_dma_init() in a new function,
pciide_dma_dmamap_setup(), for the benefit of drivers that needs special
registers setup in dmainit().
 1.21 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.20 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.19 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.18 16-Aug-2004  enami Dereference ch_wdc after filled.
 1.17 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.16 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.15 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.14 02-Aug-2004  bouyer branches: 1.14.2;
Make it possible for (*dma_finish)() to abort quietly a DMA op. Use this
in wdc_reset_channel().
 1.13 02-Aug-2004  bouyer Don't map the interrupt in pciide_mapregs_compat().
In default_chip_map() we'll do further checks to see if the channel should
really be enabled, and in case it's not we would keep the interrupt mapped.
Fix kern/26502 from Christian Biere.
 1.12 04-Jun-2004  bouyer Don't try to bus_space_subregion() registers that didn't get mapped.
Problem reported and fix tested by Kurt Schreiner on port-alpha.
 1.11 25-May-2004  thorpej Add the notion of "shadow registers" to the wdc driver. These shadow
registers are registers that overlap with others on many controllers, but
which may actually be distinct on some controllers. Right now, the two
shadows are:

- wd_status (usually overlaps wd_command)
- wd_features (usually overlaps wd_error)

Add a new helper function, wdc_init_shadow_regs(), used to initialize
the shadow register handles on controllers where they do actually overlap.

Partially from Jordan Rhody @ Wasabi Systems, Inc.
 1.10 05-May-2004  bouyer default_chip_map(): We can't use pciide_mapchan() here, because
pciide_mapchan() will attach an atabus, and we don't know yet if this
channel is enabled or not.
Fix kern/25455 by Dave Huang.
 1.9 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.8 03-Jan-2004  thorpej branches: 1.8.2;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.7 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.6 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.5 19-Dec-2003  thorpej Some controllers must have certain bits always be set in the IDEDMA_CMD
register for proper operation. Add a prototype field in the pciide_channel
for this register and use it as necessary when writing the IDEDMA_CMD
register.
 1.4 19-Dec-2003  thorpej Move the PCIIDE_OPTIONS_* constants into pciidevar.h
 1.3 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.2 23-Oct-2003  bouyer If we found a compat channel disabled, unmap the registers. There may be
an ISA IDE adapter at the same address.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.8.2.3 11-Aug-2004  jmc branches: 1.8.2.3.2;
Pullup rev 1.13 (requested by bouyer in ticket #734)

Don't map the interrupt in pciide_mapregs_compat().
In default_chip_map() we'll do further checks to see if the channel should
really be enabled, and in case it's not we would keep the interrupt mapped.
PR#26502
 1.8.2.2 05-Jun-2004  jmc Pullup rev 1.12 (requested by bouyer in ticket #443)

Don't try to bus_space_subregion() registers that didn't get mapped.
 1.8.2.1 09-May-2004  jdc Pull up revision 1.10 (requested by bouyer in ticket #267)

default_chip_map(): We can't use pciide_mapchan() here, because
pciide_mapchan() will attach an atabus, and we don't know yet if this
channel is enabled or not.
Fix kern/25455 by Dave Huang.
 1.8.2.3.2.2 05-Jan-2006  riz Pull up following revision(s) (requested by bouyer in ticket #10212):
sys/dev/pci/pciide_common.c: revision 1.29 via patch
Fix forcing use of DMA mode for the generic pciide driver: default_chip_map()
is called from pciide_attach() and at this point we don't know which drives
are here. Just assume all drives are there and allocate DMA ressources for
all of them.
 1.8.2.3.2.1 16-Mar-2005  tron Pull up revision 1.22 (requested by bouyer in ticket #1016):
Move bus_dma setup out of pciide_dma_init() in a new function,
pciide_dma_dmamap_setup(), for the benefit of drivers that needs special
registers setup in dmainit().
 1.14.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.8 15-Feb-2005  skrll Sync with HEAD.
 1.14.2.7 04-Feb-2005  skrll Sync with HEAD.
 1.14.2.6 29-Nov-2004  skrll Sync with HEAD.
 1.14.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.14.2.2 03-Aug-2004  skrll Sync with HEAD
 1.14.2.1 02-Aug-2004  skrll file pciide_common.c was added on branch ktrace-lwp on 2004-08-03 10:49:11 +0000
 1.22.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.6.1 12-Feb-2005  yamt sync with head.
 1.22.4.1 29-Apr-2005  kent sync with -current
 1.26.2.1 05-Jan-2006  riz Pull up following revision(s) (requested by bouyer in ticket #1087):
sys/dev/pci/pciide_common.c: revision 1.29
Fix forcing use of DMA mode for the generic pciide driver: default_chip_map()
is called from pciide_attach() and at this point we don't know which drives
are here. Just assume all drives are there and allocate DMA ressources for
all of them.
 1.27.2.5 24-Mar-2008  yamt sync with head.
 1.27.2.4 03-Sep-2007  yamt sync with head.
 1.27.2.3 26-Feb-2007  yamt sync with head.
 1.27.2.2 30-Dec-2006  yamt sync with head.
 1.27.2.1 21-Jun-2006  yamt sync with head.
 1.28.2.2 01-Feb-2006  yamt sync with head.
 1.28.2.1 15-Jan-2006  yamt sync with head.
 1.30.10.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.30.8.1 19-Apr-2006  elad sync with head.
 1.30.6.1 01-Apr-2006  yamt sync with head.
 1.30.4.1 22-Apr-2006  simonb Sync with head.
 1.30.2.1 09-Sep-2006  rpaulo sync with head
 1.31.10.2 10-Dec-2006  yamt sync with head.
 1.31.10.1 22-Oct-2006  yamt sync with head
 1.31.8.3 06-Feb-2007  ad Quiten noisy boot messages.
 1.31.8.2 06-Feb-2007  ad Quieten noisy boot messages.
 1.31.8.1 18-Nov-2006  ad Sync with head.
 1.36.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.36.1 03-Apr-2008  mjf Sync with HEAD.
 1.37.32.1 24-Mar-2008  keiichi sync with head.
 1.37.16.1 23-Mar-2008  matt sync with HEAD
 1.38.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.38.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.38.4.3 11-Mar-2010  yamt sync with head
 1.38.4.2 16-Sep-2009  yamt sync with head
 1.38.4.1 04-May-2009  yamt sync with head.
 1.43.4.3 31-May-2011  rmind sync with head
 1.43.4.2 21-Apr-2011  rmind sync with head
 1.43.4.1 05-Mar-2011  rmind sync with head
 1.43.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.48.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.51.8.1 18-Feb-2012  mrg merge to -current.
 1.51.4.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.51.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.51.4.2 30-Oct-2012  yamt sync with head
 1.51.4.1 17-Apr-2012  yamt sync with head
 1.57.2.4 03-Dec-2017  jdolecek update from HEAD
 1.57.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.57.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.57.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.59.2.1 18-May-2014  rmind sync with head
 1.60.6.2 05-Dec-2016  skrll Sync with HEAD
 1.60.6.1 09-Jul-2016  skrll Sync with HEAD
 1.61.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.62.4.3 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.62.4.2 12-Aug-2017  jdolecek remove all logic around ATACH_IRQ_WAIT and channel-global ch_error/ch_status,
so that there is less hidden state shared by commands; primary intent is
to make the NCQ and non-NCQ paths more similar, and remove possibility
of incorrect handling for the NCQ commands

tested both disk and ATAPI - piixide(4) on QEMU, and siisata(4),
ahcisata(4), mvsata(4) on real hw
 1.62.4.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.65.4.1 10-Jun-2019  christos Sync with HEAD
 1.65.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.67.20.1 26-Nov-2023  bouyer Pull up following revision(s) (requested by thorpej in ticket #470):
sys/dev/pci/pciide_common.c: revision 1.70
pciide_dma_dmamap_setup(): If we end up with a DMA segment with an odd
length or odd starting address, unload the map and return EINVAL. Some
controllers get really upset if a DMA segment has an odd address or length.
This can happen if a physio user performs a virtually-contiguous I/O that
starts at an odd address and spans a page boundary where the resulting
physical pages are discontiguous. The EINVAL return will cause the upper
layers in the ATA code to re-try the I/O using PIO, which should (will
in all of my tests) succeed.
PR port-alpha/56434
 1.71.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.11 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.10 25-Dec-2007  perry branches: 1.10.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.9 11-Dec-2005  christos branches: 1.9.46; 1.9.52; 1.9.56; 1.9.60;
merge ktrace-lwp.
 1.8 27-Feb-2005  perry branches: 1.8.4;
nuke trailing whitespace
 1.7 05-Oct-2003  bouyer branches: 1.7.8; 1.7.10;
Remove references to University of California from my copyright notices.
 1.6 23-Apr-2002  bouyer branches: 1.6.10;
More copyright fixes, pointed out by Thomas. Thanks !
 1.5 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.4 15-May-2000  bouyer branches: 1.4.6; 1.4.8;
Sync my copyrigth notice.
 1.3 29-Aug-1999  bouyer branches: 1.3.2;
Add definitions of the DMA mode control registers. They should be used
by pciide, but I have yet to find how to map them.
 1.2 03-Dec-1998  bouyer branches: 1.2.4;
Add URLs of documentation source (from Matthias Drochner).
 1.1 21-Nov-1998  drochner headers for new hardware support in pciide.c. from Manuel.
 1.2.4.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.4.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.6.10.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.10.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.8.4.1 21-Jan-2008  yamt sync with head
 1.9.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.56.1 26-Dec-2007  ad Sync with head.
 1.9.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.46.1 09-Jan-2008  matt sync with HEAD
 1.10.10.1 11-Mar-2010  yamt sync with head
 1.6 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.5 25-Dec-2007  perry branches: 1.5.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.4 11-Dec-2005  christos branches: 1.4.46; 1.4.52; 1.4.56; 1.4.60;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 27-Jul-2004  rumble branches: 1.2.2; 1.2.6; 1.2.8;
Add support for the controller found on the AMD (previously
NatSemi) Geode SC1100 controller (as found on the Soekris
NET4801). The chip has two bugs: the first requires dword
alignment, and the second cannot handle exact 64K transfers.

Also, fix a few typos while we're here.

Timings from FreeBSD. Reviewed by Manuel Bouyer.
 1.1 09-Jul-2004  bouyer branches: 1.1.2;
Add geodeide(4), a driver for the AMD Geode CS5530A IDE controller.
Tested by Ian Zagorskih (ianzag at megasignal.com).
 1.1.2.3 28-Jul-2004  tron Pull up revision 1.2 (requested by rumble in ticket #718):
Add support for the controller found on the AMD (previously
NatSemi) Geode SC1100 controller (as found on the Soekris
NET4801). The chip has two bugs: the first requires dword
alignment, and the second cannot handle exact 64K transfers.
Also, fix a few typos while we're here.
Timings from FreeBSD. Reviewed by Manuel Bouyer.
 1.1.2.2 14-Jul-2004  tron Pull up revision 1.1 (requested by bouyer in ticket #644):
Add geodeide(4), a driver for the AMD Geode CS5530A IDE controller.
Tested by Ian Zagorskih (ianzag at megasignal.com).
 1.1.2.1 09-Jul-2004  tron file pciide_geode_reg.h was added on branch netbsd-2-0 on 2004-07-14 09:08:28 +0000
 1.2.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.6.1 29-Apr-2005  kent sync with -current
 1.2.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.2.2.2 03-Aug-2004  skrll Sync with HEAD
 1.2.2.1 27-Jul-2004  skrll file pciide_geode_reg.h was added on branch ktrace-lwp on 2004-08-03 10:49:11 +0000
 1.3.4.1 21-Jan-2008  yamt sync with head
 1.4.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.56.1 26-Dec-2007  ad Sync with head.
 1.4.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.46.1 09-Jan-2008  matt sync with HEAD
 1.5.10.1 11-Mar-2010  yamt sync with head
 1.16 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.15 25-Dec-2007  perry branches: 1.15.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.14 05-Aug-2006  xtraeme branches: 1.14.30; 1.14.36; 1.14.40; 1.14.44;
HPT368 support. Patch from Jonathan A. Kollasch via PR kern/34097.

Thanks.
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.8;
merge ktrace-lwp.
 1.12 27-Feb-2005  perry branches: 1.12.2; 1.12.4;
nuke trailing whitespace
 1.11 10-Mar-2004  bouyer branches: 1.11.8; 1.11.10;
Add the HPT370 DPLL output frequency register.
 1.10 05-Oct-2003  bouyer Remove references to University of California from my copyright notices.
 1.9 23-Aug-2002  bouyer branches: 1.9.6;
Add support for HPT372. From sdegler@kashmir.degler.net in kern/17908,
with some improvement from me, and from FreeBSD.
 1.8 01-Jun-2002  simonb Add "__attribute__((__unused__))" to hpt374_pio, hpt374_dma and hpt374_udma.
 1.7 19-May-2002  bouyer branches: 1.7.2;
Add support for HPT374. Submited by Matthew Rezny in kern/16897, with
minor adjustements by me.
 1.6 23-Apr-2002  bouyer branches: 1.6.2;
More copyright fixes, pointed out by Thomas. Thanks !
 1.5 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.4 23-Jul-2001  bouyer Handle HPT-370A controllers, from skanto@sjk-software.fi (kern/13540) but
with some differences to the original patch: don't assume all controllers with
rev >= HPT370_REV are HPT370, and explicitely print if we have a chip with a
rev the driver does't know.
 1.3 05-Jan-2001  bouyer branches: 1.3.2; 1.3.4;
Add support for Ultra/100 on the HPT370
XXX the datasheet for the HPT370 is wrong
While I'm there clear the DRIVE_DMA flag when we're going to use Ultra/DMA
where it was missed, so that wdc_print_modes() only prints what's used.
 1.2 27-Jul-2000  bouyer branches: 1.2.2;
Ops, forgot this one: Add interrupt disable bit #define for HPT370
 1.1 12-Jun-2000  bouyer branches: 1.1.2; 1.1.4; 1.1.6;
- add a pciide_irqack() callback, which clears the IDE DMA status bit once
the IRQ has been cleared on the drive.
- use pa->pa_class instead of re-reading PCI_CLASS_REG when possible
- Add support for Highpoint HPT366 and HPT370 (370 untested), based
on patches from Roger Brooks <R.S.Brooks@liverpool.ac.uk> posted on
current-users Mach, 15. Given how Highpoint docs have been wrong for the
366, the 370 is likely to not work.
Thanks to Chris Cappuccio <chris@dqc.org> for sending me the Highpoint
docs, and to Total Archive (http://www.totalarchive.com/) for sending
me hardware.
 1.1.6.3 27-Jul-2000  he Pull up revision 1.2 (requested by bouyer):
Clear the interrupt disable bit of the HPT370, and document HPT370
support.
 1.1.6.2 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.1.6.1 12-Jun-2000  he file pciide_hpt_reg.h was added on branch netbsd-1-4 on 2000-07-07 17:33:50 +0000
 1.1.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.1.4.1 12-Jun-2000  minoura file pciide_hpt_reg.h was added on branch minoura-xpg4dl on 2000-06-22 17:07:35 +0000
 1.1.2.3 13-Nov-2001  he Pull up revision 1.4 (requested by bouyer):
Support HPT-370A controllers. Fixes PR#13540.
 1.1.2.2 04-Feb-2001  he Pull up revision 1.3 (requested by bouyer):
Add support for Ultra/100 on the HPT370 controller.
 1.1.2.1 27-Jul-2000  bouyer Pull up (approved by thorpej):
sys/dev/pci/pciide.c 1.80 -> 1.81
sys/dev/pci/pciide_hpt_reg.h 1.1 -> 1.2
distrib/notes/i386/hardware 1.74 -> 1.75
share/man/man4/pciide.4 1.22 -> 1.23
Make sure the HPT370's interrupts disable bit is cleared. Now that HPT370
supports works, document it.
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 27-Jul-2000  bouyer file pciide_hpt_reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:34 +0000
 1.3.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.4.1 03-Aug-2001  lukem update to -current
 1.3.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.3.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.3.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.6.2.3 29-Aug-2002  gehenna catch up with -current.
 1.6.2.2 20-Jun-2002  gehenna catch up with -current.
 1.6.2.1 30-May-2002  gehenna Catch up with -current.
 1.7.2.1 01-Nov-2002  tron Pull up revision 1.8-1.9 (requested by bouyer in ticket #725):
Add support for HPT372. From sdegler@kashmir.degler.net in kern/17908,
with some improvement from me, and from FreeBSD.
 1.9.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.6.1 03-Aug-2004  skrll Sync with HEAD
 1.11.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.12.4.2 21-Jan-2008  yamt sync with head
 1.12.4.1 30-Dec-2006  yamt sync with head.
 1.12.2.1 06-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1455):
sys/dev/pci/hptide.c: revision 1.21
sys/dev/pci/pciide_hpt_reg.h: revision 1.14
HPT368 support. Patch from Jonathan A. Kollasch via PR kern/34097.
Thanks.
 1.13.8.1 11-Aug-2006  yamt sync with head
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.44.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.40.1 26-Dec-2007  ad Sync with head.
 1.14.36.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.30.1 09-Jan-2008  matt sync with HEAD
 1.15.10.1 11-Mar-2010  yamt sync with head
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 11-Feb-2005  rearnsha Add support for the Artisea device operating in DPA mode.

Approved by briggs.
 1.1 18-Mar-2003  thorpej branches: 1.1.2; 1.1.10; 1.1.12;
Add register definitions for the Intel i31244 Serial ATA controller.
 1.1.12.1 12-Feb-2005  yamt sync with head.
 1.1.10.1 29-Apr-2005  kent sync with -current
 1.1.2.1 15-Feb-2005  skrll Sync with HEAD.
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 01-Dec-2004  grant branches: 1.1.4;
add iteide(4) driver for ITE8212-based IDE controllers. from
OpenBSD, ported to NetBSD by me.

ok'd by bouyer@, thorpej@.
 1.1.4.2 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.1 01-Dec-2004  skrll file pciide_ite_reg.h was added on branch ktrace-lwp on 2004-12-18 09:32:10 +0000
 1.5 29-Apr-2008  martin Convert to new 2 clause license
 1.4 10-Sep-2007  cube branches: 1.4.20; 1.4.22; 1.4.24;
Remove 3rd clause and my name from all the licences which were only in my
name.
 1.3 11-Dec-2005  christos branches: 1.3.30; 1.3.44; 1.3.46;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 06-Dec-2004  cube branches: 1.1.4; 1.1.6; 1.1.8;
Add ixpide(4), a driver for the IDE controller found in the ATI IXP series
of integrated chipsets.

Documented from the Linux driver. Tested by reinoud@, ok'd by bouyer@.
 1.1.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 29-Apr-2005  kent sync with -current
 1.1.4.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.4.2 18-Dec-2004  skrll Sync with HEAD.
 1.1.4.1 06-Dec-2004  skrll file pciide_ixp_reg.h was added on branch ktrace-lwp on 2004-12-18 09:32:10 +0000
 1.2.4.1 27-Oct-2007  yamt sync with head.
 1.3.46.1 06-Nov-2007  matt sync with HEAD
 1.3.44.1 02-Oct-2007  joerg Sync with HEAD.
 1.3.30.1 09-Oct-2007  ad Sync with head.
 1.4.24.1 16-May-2008  yamt sync with head.
 1.4.22.1 18-May-2008  yamt sync with head.
 1.4.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.1 10-Nov-2010  skrll branches: 1.1.6;
Add nside(4) - a driver for the National Semiconductor PC87415 IDE
controller as found in many HP PA-RISC machines.

From OpenBSD.

Reviewed by Manuel Bouyer.
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 10-Nov-2010  rmind file pciide_natsemi_reg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:56 +0000
 1.12 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 25-Dec-2007  perry branches: 1.11.6; 1.11.8; 1.11.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.10 16-Feb-2006  perry branches: 1.10.40; 1.10.46; 1.10.50; 1.10.54;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.9 24-Dec-2005  perry branches: 1.9.2; 1.9.4; 1.9.6;
__inline__ -> inline
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 19-Aug-2004  thorpej branches: 1.7.12;
- Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.6 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.5 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.4 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.3 21-Oct-2001  thorpej branches: 1.3.18;
Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.2 07-Jun-2000  scw branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12;
The OPTi controller supports a 32-bit dataport after all.
Also detect when the chip is sitting on a 25MHz PCIbus and
set the timing registers accordingly.
 1.1 27-May-2000  scw Add support for the OPTi 82c621 PCIIDE controller and its derivatives.
I only have a Compaq laptop on which to test this, so reports of
success/failure in other systems would be welcomed.
 1.2.12.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.10.1 22-Oct-2001  nathanw Catch up to -current.
 1.2.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.8.1 07-Jun-2000  bouyer file pciide_opti_reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:35 +0000
 1.2.6.2 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.2.6.1 07-Jun-2000  he file pciide_opti_reg.h was added on branch netbsd-1-4 on 2000-07-07 17:33:50 +0000
 1.2.4.2 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.2.4.1 07-Jun-2000  minoura file pciide_opti_reg.h was added on branch minoura-xpg4dl on 2000-06-22 17:07:36 +0000
 1.3.18.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.18.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.18.2 25-Aug-2004  skrll Sync with HEAD.
 1.3.18.1 03-Aug-2004  skrll Sync with HEAD
 1.7.12.2 21-Jan-2008  yamt sync with head
 1.7.12.1 21-Jun-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.9.2.1 18-Feb-2006  yamt sync with head.
 1.10.54.1 02-Jan-2008  bouyer Sync with HEAD
 1.10.50.1 26-Dec-2007  ad Sync with head.
 1.10.46.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.40.1 09-Jan-2008  matt sync with HEAD
 1.11.10.1 16-May-2008  yamt sync with head.
 1.11.8.1 18-May-2008  yamt sync with head.
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.1 04-Jun-1998  bouyer branches: 1.1.2;
file pciide_pIIx_reg.h was initially added on branch bouyer-ide.
 1.1.2.2 06-Jun-1998  bouyer Renamed pciide_pIIx_reg.h to pciide_piix_reg.h via repository copy,
as suggested by Soren S. Jorvan.
 1.1.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.17 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.16 15-Oct-2022  rin Fix style and typo in comments. No binary changes.
 1.15 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.14 25-Dec-2007  perry branches: 1.14.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.13 11-Dec-2005  christos branches: 1.13.46; 1.13.52; 1.13.56; 1.13.60;
merge ktrace-lwp.
 1.12 27-Feb-2005  perry branches: 1.12.4;
nuke trailing whitespace
 1.11 05-Oct-2003  bouyer branches: 1.11.8; 1.11.10;
Remove references to University of California from my copyright notices.
 1.10 28-Jun-2003  bouyer branches: 1.10.2;
Correct setup of General Purpose Register for PDC20265 (Ultra/100) and newer.
From Andreas Johansson in private mail.
 1.9 28-Apr-2003  nakayama Make DMA mode works on Promise Ultra66/100 with 48-bit LBA drives.
Ok'ed by bouyer in tech-kern@netbsd.org.
 1.8 26-Jul-2002  wiz Spell '[Rr]ight' correctly. From Jim Bernard.
 1.7 23-Apr-2002  bouyer branches: 1.7.2; 1.7.4;
More copyright fixes, pointed out by Thomas. Thanks !
 1.6 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.5 05-Jul-2001  toshii branches: 1.5.2;
Fix typo. s/extention/extension/
 1.4 12-Mar-2001  bouyer Correct definition of PDC262_U66_EN (from FreeBSD).
Correct values of MW DMA 2, and add values for UDMA5 (from linux).
 1.3 15-May-2000  bouyer branches: 1.3.4; 1.3.6; 1.3.8;
Sync my copyrigth notice.
 1.2 28-Nov-1999  bouyer Improve Ultra/66 support now that I've got some docs from Promise.
 1.1 29-Aug-1999  bouyer branches: 1.1.2; 1.1.8;
Add support for the Promise Ultra/33 and /66 pci IDE controller. In addition to
chip-dependant code this required the following changes:
- Instead of attaching the device in a generic way with some chip-dependant
routines, use a chip-dependant attach routine with some common code
factored out. The code is marginally bigger, but this allows the CMD64x
flag hack to go away.
- For chips that report per-channel 'irq triggered', test this before calling
wdcintr() for the native-pci irq case (compat intr can't be shared),
as wdcintr() has no good way to know if a irq was for it or not, and
ends up with irq loss. XXX for chips that don't have this feature irq sharing
will not work properly !
- add my copyrigth notice (could have been done some time ago I think :)

There are still some issues to be solved with the Promise controller and
ATAPI devices.
Many thanks to Paul Newhouse for shipping me 2 Ultra/33 boards for doing this
work.
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.8.5 01-Aug-2002  nathanw Catch up to -current.
 1.3.8.4 20-Jun-2002  nathanw Catch up to -current.
 1.3.8.3 22-Oct-2001  nathanw Catch up to -current.
 1.3.8.2 24-Aug-2001  nathanw Catch up with -current.
 1.3.8.1 09-Apr-2001  nathanw Catch up with -current.
 1.3.6.2 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.3.6.1 15-May-2000  he file pciide_pdc202xx_reg.h was added on branch netbsd-1-4 on 2000-07-07 17:33:50 +0000
 1.3.4.1 13-Mar-2001  he Pull up revision 1.4 (requested by bouyer):
Support Ultra/100 speed on Promise Ultra/100, and fix ``bogus
intr'' messages generated under some conditions.
 1.5.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.4.2 16-Aug-2003  tron Pull up revision 1.10 (requested by bouyer in ticket #1369):
Correct setup of General Purpose Register for PDC20265 (Ultra/100) and newer.
From Andreas Johansson in private mail.
 1.7.4.1 28-Apr-2003  tron Pull up revision 1.9 (requested by nakayama in ticket #1275):
Make DMA mode works on Promise Ultra66/100 with 48-bit LBA drives.
Ok'ed by bouyer in tech-kern@netbsd.org.
 1.7.2.1 29-Aug-2002  gehenna catch up with -current.
 1.10.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.12.4.1 21-Jan-2008  yamt sync with head
 1.13.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.13.56.1 26-Dec-2007  ad Sync with head.
 1.13.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.13.46.1 09-Jan-2008  matt sync with HEAD
 1.14.10.1 11-Mar-2010  yamt sync with head
 1.1 20-Sep-2009  christos branches: 1.1.4;
PR/42100: Dave J. Barnes: Support for old toshiba PICCOLO IDE controllers.
 1.1.4.2 11-Mar-2010  yamt sync with head
 1.1.4.1 20-Sep-2009  yamt file pciide_piccolo_reg.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:58 +0000
 1.16 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.15 04-Jul-2018  kamil Avoid undefined behavior in pciiide macros

Cast the 'bytes' argument in PIIX_IDETIM_SET() and PIIX_IDETIM_CLEAR()
to unsigned int. This prevents UB because of shifting the bits and changing
the bit of signedness.

sys/dev/pci/piixide.c:714:11, left shift of 65535 by 16 places cannot be represented in type 'int'
sys/dev/pci/piixide.c:720:11, left shift of 32768 by 16 places cannot be represented in type 'int'

Detected with Kernel Undefined Behavior Sanitizer.

Reported by <Harry Pantazis>
 1.14 19-Oct-2009  bouyer branches: 1.14.62; 1.14.64;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.13 25-Dec-2007  perry branches: 1.13.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.12 03-Sep-2006  xtraeme branches: 1.12.28; 1.12.34; 1.12.38; 1.12.42;
* Add support for ICH8 and ICH8M SATA/RAID controllers.
* If the controller is in AHCI, ask for SATA IDE mode of operation.

jsg@openbsd says:

"X60/T60 Thinkpads are shipped in AHCI configuration by default,
this makes them work without changing a BIOS option."

Tested by eye of the beholder. From OpenBSD.

Ok'ed tls.
 1.11 17-Jun-2006  jmcneill branches: 1.11.2;
Forgot to commit the register definition for PIIX_UDMATIM.
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.8; 1.10.14; 1.10.16;
merge ktrace-lwp.
 1.9 27-Feb-2005  perry branches: 1.9.4;
nuke trailing whitespace
 1.8 05-Oct-2003  bouyer branches: 1.8.8; 1.8.10;
Remove references to University of California from my copyright notices.
 1.7 23-Apr-2002  bouyer branches: 1.7.10;
More copyright fixes, pointed out by Thomas. Thanks !
 1.6 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.5 05-Jan-2001  bouyer branches: 1.5.2; 1.5.4;
Add support for Ultra/100 on intel ICH2; from Tomokazu HARADA in kern/11747.
 1.4 15-May-2000  bouyer branches: 1.4.4;
Sync my copyrigth notice.
 1.3 30-Aug-1999  bouyer branches: 1.3.2;
Add support for Intel 810 chipset (ICH/ICH0).
While I'm there merge back piix_channel_map into piix_chip_map.
 1.2 12-Oct-1998  bouyer branches: 1.2.6;
Merge bouyer-ide
 1.1 04-Jun-1998  bouyer branches: 1.1.2;
file pciide_pIIx_reg.h was initially added on branch bouyer-ide.
 1.1.2.4 04-Oct-1998  bouyer atavar.h: drv_softc is a struct device * instead of void*, as it's mostly
used for dv_xname
wd.c: convert for drv_softc type change, printf cleanup
wdc.c: always call ata_get_params() (params was used initialised with
non-32bit controllers, leaving to bogus PIO/DMA mode report).
Cleaup of the PIO/DMA mode message.
pciide_piix_reg.h: Fix definition of PIIX_IDETIM_CLEAR (unused before)
pciide.c: add a method do disable a channel on know device. If a channel
doesn't have any drive, we disable it and free its resources if disable
was successfull. This should help with laptops where the second channel
of the PIIX4 is unused but not disabled by BIOS. On such laptops,
irq15 can be used for PCMCIA but it was claimed by pciide.
Misc printf cleanup.
wdc_isa.c: printf cleanup.
 1.1.2.3 10-Jun-1998  bouyer Fix confusion between binary and hex in DMA modes: 0x10 -> 0x02.
 1.1.2.2 10-Jun-1998  bouyer - Fix timing settings for DMA: the controller was always set up to use
DMA mode 0 (compatible).
- The 2 Ultra-dma registers are in fact one 32-bit register.
Change the macros and setup in a way it may now work (but still untested,
thus not enabled by default).
- For DMA mode 1, use a more efficient timing than the one suggested
by intel.
Some work is still needed here to get ATAPI DMA working (should be done soon).
 1.1.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.2.6.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.3.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.1 04-Feb-2001  he Pull up revision 1.5 (requested by bouyer):
Add support for Ultra/100 on Intel ICH2.
 1.5.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.5.2.1 22-Oct-2001  nathanw Catch up to -current.
 1.7.10.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.10.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.8.1 29-Apr-2005  kent sync with -current
 1.9.4.3 21-Jan-2008  yamt sync with head
 1.9.4.2 30-Dec-2006  yamt sync with head.
 1.9.4.1 21-Jun-2006  yamt sync with head.
 1.10.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.10.14.1 19-Jun-2006  chap Sync with head.
 1.10.8.2 14-Sep-2006  yamt sync with head.
 1.10.8.1 26-Jun-2006  yamt sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.1 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #117):
sys/dev/pci/piixide.c: revision 1.29
sys/dev/pci/pciide_piix_reg.h: revision 1.12
* Add support for ICH8 and ICH8M SATA/RAID controllers.
* If the controller is in AHCI, ask for SATA IDE mode of operation.
jsg@openbsd says:
"X60/T60 Thinkpads are shipped in AHCI configuration by default,
this makes them work without changing a BIOS option."
Tested by eye of the beholder. From OpenBSD.
Ok'ed tls.
 1.12.42.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.38.1 26-Dec-2007  ad Sync with head.
 1.12.34.1 18-Feb-2008  mjf Sync with HEAD.
 1.12.28.1 09-Jan-2008  matt sync with HEAD
 1.13.10.1 11-Mar-2010  yamt sync with head
 1.14.64.1 10-Jun-2019  christos Sync with HEAD
 1.14.62.1 28-Jul-2018  pgoyette Sync with HEAD
 1.1 06-Nov-2010  jakllsch branches: 1.1.6;
Add Intel SCH IDE controller driver.
From OpenBSD via Tomokazu HARADA in PR#42310.
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 06-Nov-2010  rmind file pciide_sch_reg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:56 +0000
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 20-Dec-2003  thorpej branches: 1.2.4;
Add support for the Silicon Image 3114 SATALink 4-port SATA controller.
 1.1 20-Mar-2003  thorpej branches: 1.1.2;
Add support for the Silicon Image SATALink 3112 Serial ATA controller.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.2.4.2 12-Jul-2004  he Pull up revision 1.1 (new, requested by grant in ticket #1720):
Add support for SATALink 3112.
 1.2.4.1 20-Dec-2003  he file pciide_sii3112_reg.h was added on branch netbsd-1-6 on 2004-07-12 21:24:08 +0000
 1.16 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.15 25-Dec-2007  perry branches: 1.15.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.14 11-Dec-2005  christos branches: 1.14.46; 1.14.52; 1.14.56; 1.14.60;
merge ktrace-lwp.
 1.13 16-Jun-2005  bouyer branches: 1.13.2;
Add quirk for SIS 96x that masquerade as a SIS503. Based on patch sent by
Robert Fuller in kern/30431, information found in the linux kernel.
While here, add SIS 965 to the table (from FreeBSD).
 1.12 27-Feb-2005  perry branches: 1.12.2;
nuke trailing whitespace
 1.11 05-Oct-2003  bouyer branches: 1.11.6; 1.11.8; 1.11.10;
Remove references to University of California from my copyright notices.
 1.10 14-Mar-2003  bouyer branches: 1.10.2;
Rework SiS support: more controller supported (up to Ultra/133) and better
support for the older ones.
Information for this work extracted from Soeren Schmidt's FreeBSD driver.
 1.9 23-Apr-2002  bouyer branches: 1.9.4;
More copyright fixes, pointed out by Thomas. Thanks !
 1.8 21-Oct-2001  thorpej Make the various timing, etc. tables const, and add the __unused__
attribute to them, just in case something other than the pciide driver
proper needs to pull in the header.
 1.7 16-Oct-2001  tron Add missing timings for Ultra DMA modes 3 to 5 on SiS hostadapters.
Problem pointed out by IWAMOTO Toshihiro on "tech-kern@netbsd.org".
 1.6 15-May-2000  bouyer branches: 1.6.6; 1.6.8;
Sync my copyrigth notice.
 1.5 04-Dec-1998  drochner branches: 1.5.4; 1.5.10;
The chipset manual doesn't tell the truth about the channel enable
register bits. Replace by experimental result.
 1.4 03-Dec-1998  bouyer Correct definition for SIS_TIM_UDMA_EN macro. Ultra-DMA should now work ...
 1.3 03-Dec-1998  bouyer Add URLs of documentation source (from Matthias Drochner).
 1.2 03-Dec-1998  bouyer Correct a few bogons in the SiS chip initialisation.
 1.1 21-Nov-1998  drochner headers for new hardware support in pciide.c. from Manuel.
 1.5.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.4.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.6.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.6.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.9.4.1 16-Jun-2003  grant Apply patch (requested by bouyer in ticket #1234):

Rework SiS support: more controller supported (up to Ultra/133) and better
support for the older ones.
Information for this work extracted from Soeren Schmidt's FreeBSD driver.
 1.10.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.11.6.1 05-Jul-2005  riz Pull up revision 1.13 via patch (requested by bouyer in ticket #2032):
Add quick for SIS 96x that masquerade as a SIS503. Based on patch sent by
Robert Fuller in kern/30431, information found in the linux kernel.
While here, add SIS 965 to the table (from FreeBSD).
 1.12.2.1 26-Jun-2005  tron Pull up revision 1.13 (requested by bouyer in ticket #498):
Add quirk for SIS 96x that masquerade as a SIS503. Based on patch sent by
Robert Fuller in kern/30431, information found in the linux kernel.
While here, add SIS 965 to the table (from FreeBSD).
 1.13.2.1 21-Jan-2008  yamt sync with head
 1.14.60.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.56.1 26-Dec-2007  ad Sync with head.
 1.14.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.46.1 09-Jan-2008  matt sync with HEAD
 1.15.10.1 11-Mar-2010  yamt sync with head
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 25-Dec-2007  perry branches: 1.5.6; 1.5.8; 1.5.10;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.4 11-Jun-2007  nisimura branches: 1.4.8; 1.4.14; 1.4.16; 1.4.20;
- fix errors in register number and bit field definitions.
- put a bit better comment about how LEGIRQ bit works.
 1.3 11-Dec-2005  christos branches: 1.3.30; 1.3.32;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 03-Apr-2002  thorpej branches: 1.1.2; 1.1.8; 1.1.14; 1.1.22; 1.1.24;
Add bus master DMA support for the Symphony Labs 82C105 PCI IDE
controller. This part is also found in the Winbond 83C553 Southbrige.
 1.1.24.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.22.1 29-Apr-2005  kent sync with -current
 1.1.14.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.1 03-Apr-2002  jdolecek file pciide_sl82c105_reg.h was added on branch kqueue on 2002-06-23 17:48:02 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 03-Apr-2002  nathanw file pciide_sl82c105_reg.h was added on branch nathanw_sa on 2002-04-17 00:06:06 +0000
 1.2.4.2 21-Jan-2008  yamt sync with head
 1.2.4.1 03-Sep-2007  yamt sync with head.
 1.3.32.1 11-Jul-2007  mjf Sync with head.
 1.3.30.1 15-Jul-2007  ad Sync with head.
 1.4.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.16.1 26-Dec-2007  ad Sync with head.
 1.4.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.8.1 09-Jan-2008  matt sync with HEAD
 1.5.10.1 16-May-2008  yamt sync with head.
 1.5.8.1 18-May-2008  yamt sync with head.
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.2 26-Aug-2021  andvar Add missing RCSID in header files and one __KERNEL_RCSID().
 1.1 06-Mar-2006  bouyer branches: 1.1.4; 1.1.8; 1.1.10; 1.1.16; 1.1.22;
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 06-Mar-2006  rpaulo file pciide_svwsata_reg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 06-Mar-2006  yamt file pciide_svwsata_reg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:06 +0000
 1.1.10.2 04-May-2006  tron Pull up following revision(s) (requested by jonathan in ticket #1298):
share/man/man4/pciide.4: revision 1.60
share/man/man4/Makefile: revision 1.376 via patch
sys/dev/pci/svwsata.c: revision 1.1
sys/dev/pci/files.pci: revision 1.243
sys/arch/i386/conf/INSTALL: revision 1.281
sys/dev/pci/pcidevs: revision 1.771 via patch
sys/dev/pci/pciidevar.h: revision 1.33
sys/arch/i386/conf/XEN0: revision 1.34
sys/arch/i386/conf/GENERIC: revision 1.732
sys/dev/pci/pciide_svwsata_reg.h: revision 1.1
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.1.10.1 06-Mar-2006  tron file pciide_svwsata_reg.h was added on branch netbsd-3 on 2006-05-04 12:12:08 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 06-Mar-2006  simonb file pciide_svwsata_reg.h was added on branch simonb-timecounters on 2006-04-22 11:39:15 +0000
 1.1.4.2 13-Mar-2006  yamt sync with head.
 1.1.4.1 06-Mar-2006  yamt file pciide_svwsata_reg.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:27 +0000
 1.11 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 27-Feb-2005  perry branches: 1.9.4;
nuke trailing whitespace
 1.8 15-Feb-2005  briggs Move the definition of NIDEDMA_TABLES from pciidereg.h to be closer to
its only user in pciide_common.c. Also redefine NIDEDMA_TABLES to match
the max DMA transfer size specified in the call to bus_dmamap_create()
(IDEDMA_BYTE_COUNT_MAX instead of MAXPHYS).
The macro is also redefined to handle devices that have a PAGE_SIZE greater
than sc_dma_maxsegsz (buggy revision of satalink 3112 on ibm4xx).
 1.7 27-Nov-2003  fvdl branches: 1.7.8; 1.7.10;
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.6 14-Nov-2000  thorpej branches: 1.6.24;
NBPG -> PAGE_SIZE
 1.5 09-Mar-2000  soren Move PCIIDE_CHANNEL_NAME macro to pciidereg.h.
 1.4 02-Feb-1999  bouyer branches: 1.4.2; 1.4.8;
Support for Acerlab M5229 IDE controller. Thanks to Thilo Manske for testing
the code, and to Takahiro Kambe who run several tests and finally found the
bug by himself :)
 1.3 12-Oct-1998  bouyer Merge bouyer-ide
 1.2 04-Mar-1998  cgd branches: 1.2.2;
add def'ns for PCI IDE bus-master DMA interface recognition and register
mapping.
 1.1 04-Mar-1998  cgd PCI IDE glue. Right now, just glues 'wdc's to PCI IDE controller
channels. Eventually should do things like support PCI IDE DMA (it _DOES
NOT_ do that now).
 1.2.2.2 20-Sep-1998  bouyer - always call config_found() from wdcattach(), instead of printing our own
the "not configured" message ourselve. When no atapibus is configured,
use a fake ata_atapi_attach, else call wdc_atapibus_attach(). This way we
don't have to include the whole atapi support in an ata-only config.
- the dma_* function pointers take a 'int flags' as last argument, instead
of an 'int read'. The 2 valid flags are: WDC_DMA_READ (to select read/write)
and WDC_DMA_POLL, to signal interrupt-less mode (for core dumps).
- Reworked wdcprobe() so look more like the old one. A status of 0xff is
interpreted as "no drive" (freebsd does this); this this speed up
the probe for non-IDE machines (a reset timeout has been bumped to 31s,
to match the specs). The probe set ups the drive flags to either ATA or
ATAPI (depend on register signature) or OLD (if register signature don't
match, but a working drive appears to be there). Later the ATA code
will look at the OLD flag to decide wether there is no drive, or an old
(ST506) one if WDC_IDENTIFY fails.
- For known PCI chips, don't use the wdcprobe() heuristic to find wether
a channel is enabled/disabled; use the chip's specific registers for this.
- Clear the command queue when we have a polled command. This allows dumps to
work even if a command was being handled by the controller at panic time.
- Increase the number of available DMA segments by one, as user requests may
not be aligned on a page boundary.
 1.2.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.4.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.6.24.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.24.4 15-Feb-2005  skrll Sync with HEAD.
 1.6.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.24.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.9.4.1 30-Dec-2006  yamt sync with head.
 1.10.22.1 10-Dec-2006  yamt sync with head.
 1.10.20.1 12-Jan-2007  ad Sync with head.
 1.51 26-Dec-2021  andvar fix various typos, mainly in comments.
 1.50 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.49 22-Oct-2017  jdolecek branches: 1.49.2;
do not share queue between the non-indepedant channels; instead make
sure only one of the channels is ever active on the same controller

fixes PR kern/52606 by Martin Husemann, thanks for report and testing
 1.48 19-Oct-2017  jdolecek replace the chek for the shared channel of cmdide(4) a flag of the
product array, rather than switch inside attach routine

XXX judging from product name, Silicon Image 0680 might be newer than 0649
XXX and hence have actually independant channels, but I don't have the hw
XXX so keeping as-is

no functional change, just to improve visibility in course of fixing
PR kern/52606
 1.47 24-Aug-2015  pooka add some _KERNEL_OPT as the finishing touch
 1.46 31-Jul-2012  bouyer branches: 1.46.2; 1.46.16;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.45 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.44 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.43 04-Apr-2011  dyoung branches: 1.43.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.42 06-Nov-2010  jakllsch branches: 1.42.2;
Rework pciide(4) detachment to take the legacy interrupt mapping into
consideration and avoid future code duplication.

Ports wanting to enable detachment of controllers with compatibility-mapped
channels will need to supply a pciide_machdep_compat_intr_disestablish()
function.
 1.41 05-Nov-2010  jakllsch Pave the way for detachment of pciide(4)-family ATA controllers.
 1.40 14-Nov-2009  cegger branches: 1.40.2; 1.40.4;
include <sys/device_if.h> for device_t. There is no use of struct device.
 1.39 05-Oct-2009  dyoung It's a big job to write detachment hooks for pciide(4) and all of
its derivatives, and I haven't the time myself. In struct
pciide_product_desc, provide a tiny bit of commented-out code to
guide an enterprising developer who takes on the immense task.
 1.38 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.37 15-Mar-2009  cegger ansify function definitions
 1.36 04-Jan-2008  joerg branches: 1.36.10; 1.36.18; 1.36.24;
Allow saving of up to 4 PCI registers in the IDE code.
 1.35 17-Oct-2006  itohy branches: 1.35.24; 1.35.30; 1.35.38;
Make pciide(4)-only configurations (without other DMA-capable driver) compile.
 1.34 17-Jun-2006  jmcneill branches: 1.34.4; 1.34.6;
Restore IDE and UDMA timings on resume for the PIIX4.
 1.33 06-Mar-2006  bouyer branches: 1.33.6; 1.33.8;
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.32 24-Dec-2005  perry branches: 1.32.4; 1.32.6; 1.32.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.31 11-Dec-2005  christos merge ktrace-lwp.
 1.30 27-Feb-2005  perry branches: 1.30.2; 1.30.4;
nuke trailing whitespace
 1.29 11-Feb-2005  rearnsha Add support for the Artisea device operating in DPA mode.

Approved by briggs.
 1.28 04-Feb-2005  perry de-__P
 1.27 26-Jan-2005  jmcneill Add powerhooks for PIIX IDE driver.
 1.26 24-Nov-2004  bouyer branches: 1.26.4; 1.26.6;
Move bus_dma setup out of pciide_dma_init() in a new function,
pciide_dma_dmamap_setup(), for the benefit of drivers that needs special
registers setup in dmainit().
 1.25 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.24 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.23 19-Aug-2004  thorpej Protect against multiple inclusion.
 1.22 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.21 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.20 03-Jan-2004  thorpej branches: 1.20.4;
Rename "struct channel_softc" to "struct wdc_channel".
 1.19 19-Dec-2003  thorpej While legacy PCI IDE controllers have only 2 channels, it is quite common
for modern PCI SATA controllers to have more. Define a new PCIIDE_MAX_CHANNELS
which to specify the maximum number of channels we support, and use it to
allocate channel resources.
 1.18 19-Dec-2003  thorpej Some controllers must have certain bits always be set in the IDEDMA_CMD
register for proper operation. Add a prototype field in the pciide_channel
for this register and use it as necessary when writing the IDEDMA_CMD
register.
 1.17 19-Dec-2003  thorpej Const poison the channel name.
 1.16 19-Dec-2003  thorpej Move the PCIIDE_OPTIONS_* constants into pciidevar.h
 1.15 17-Dec-2003  thorpej Add BA5 space tag/handles for Silicon Image SATALink.
 1.14 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.13 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.12 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.11 23-Sep-2003  mycroft GC a structure element.
 1.10 20-Mar-2003  thorpej branches: 1.10.2;
Add support for the Silicon Image SATALink 3112 Serial ATA controller.
 1.9 14-Mar-2003  bouyer Rework SiS support: more controller supported (up to Ultra/133) and better
support for the older ones.
Information for this work extracted from Soeren Schmidt's FreeBSD driver.
 1.8 24-Jan-2003  thorpej Add support for the NVIDIA nForce ATA100 and nForce2 ATA133
IDE controllers, which are more-or-less compatible with the
AMD controllers.

XXX Need to determine the correct timing value for the nForce2
XXX at Ultra133, so we cap it at Ultra100, for now.
 1.7 08-Jun-2001  simonb branches: 1.7.16;
For ports that wire up pciide in compatibility mode, have
them define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
in pci_machdep.h and pciide_map_compat_intr() only calls
pciide_machdep_compat_intr_establish() if that preprocessor
define exists.

Ports that don't need to do this no longer need to supply a
dummy function.
 1.6 12-Jan-2001  bouyer branches: 1.6.2;
Fix bug which affects pciide controllers in native mode (found by
Paul Kranenburg, many thanks !): the control register I/O is 4 byte long
although only one is used, but the control register is at offset 2, and not
0 as expected by IC code. Use bus_space_subregion() to get a handle which
points to the control register, and is one byte long.
 1.5 06-Jun-2000  thorpej branches: 1.5.2;
Actually program the DMA mode of the drives into the Cypress
controller. Fixes a long-standing problem where IDE DMA wasn't
working on the AlphaPC 164SX.
 1.4 01-Apr-2000  bouyer branches: 1.4.2;
- DMA code cleanup: pciide_dma_finish() doesn't stop/unload the current DMA op
if an IRQ was not detected, unless the force flag was given. Use this to
detect if the IRQ was for us (closer to shared IRQ for controllers which
don't have their own IRQ handler in pciide.c) and to poll for DMA xfer.
Also makes the timeout recovery code simpler.
- ATAPI cleanup: don't call controller-specific functions from atapiconf.c
(wdc_*), so that it's possible to attach an atapibus to something else
than a wdc/pciide (Hi Lennart :).
Overload struct scsi_adapter with struct atapi_adapter, defined
as struct scsi_adapter + atapi-specific callbacks. scsipi_link still points
to an scsi_adapter, atapi code casts it to atapi_adapter if needed.
Move atapi_softc to atapiconf.h so that it can be used by the underlying
controller code (e.g. atapi_wdc.c).
Add an atapi-specific callback *atapi_probedev(), which probe a drive
in a controller-specific way, allocate the sc_link and fills in the
ataparams if needed. It then calls atapi_probedev() (from atapiconf.c)
to do the generic initialisations and attach the device.
- While I'm there merge and centralise the state definitions in atavar.h.
It should now be possible to use a common ata/atapi routine to set the
drive's modes (will do later).
 1.3 13-Nov-1999  soren Export softc.
 1.2 12-Oct-1998  bouyer branches: 1.2.6; 1.2.12; 1.2.14; 1.2.18;
Merge bouyer-ide
 1.1 04-Mar-1998  cgd branches: 1.1.2;
PCI IDE glue. Right now, just glues 'wdc's to PCI IDE controller
channels. Eventually should do things like support PCI IDE DMA (it _DOES
NOT_ do that now).
 1.1.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.2.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.14.1 15-Nov-1999  fvdl Sync with -current
 1.2.12.2 15-Jan-2001  bouyer req_sense_length is dead.
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.4.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.2.1 04-Feb-2001  he Pull up revision 1.6 (requested by bouyer):
Fix bug which affects pciide controllers in native mode. Main
effect was a non-functionnal IDE controller on some sparc64 and
macppc when booted from IDE disk.
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.16.2 12-Jul-2004  he Pull up revision 1.10 (via patch, requested by grant in ticket #1720):
Add support for SATALink 3112.
 1.7.16.1 16-Jun-2003  grant Apply patch (requested by bouyer in ticket #1234):

Rework SiS support: more controller supported (up to Ultra/133) and better
support for the older ones.
Information for this work extracted from Soeren Schmidt's FreeBSD driver.
 1.10.2.8 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.2.7 15-Feb-2005  skrll Sync with HEAD.
 1.10.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.10.2.5 29-Nov-2004  skrll Sync with HEAD.
 1.10.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.4.1 16-Mar-2005  tron Pull up revision 1.26 (requested by bouyer in ticket #1016):
Move bus_dma setup out of pciide_dma_init() in a new function,
pciide_dma_dmamap_setup(), for the benefit of drivers that needs special
registers setup in dmainit().
 1.26.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.26.6.1 12-Feb-2005  yamt sync with head.
 1.26.4.1 29-Apr-2005  kent sync with -current
 1.30.4.3 21-Jan-2008  yamt sync with head
 1.30.4.2 30-Dec-2006  yamt sync with head.
 1.30.4.1 21-Jun-2006  yamt sync with head.
 1.30.2.1 04-May-2006  tron Pull up following revision(s) (requested by jonathan in ticket #1298):
share/man/man4/pciide.4: revision 1.60
share/man/man4/Makefile: revision 1.376 via patch
sys/dev/pci/svwsata.c: revision 1.1
sys/dev/pci/files.pci: revision 1.243
sys/arch/i386/conf/INSTALL: revision 1.281
sys/dev/pci/pcidevs: revision 1.771 via patch
sys/dev/pci/pciidevar.h: revision 1.33
sys/arch/i386/conf/XEN0: revision 1.34
sys/arch/i386/conf/GENERIC: revision 1.732
sys/dev/pci/pciide_svwsata_reg.h: revision 1.1
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.32.8.2 26-Jun-2006  yamt sync with head.
 1.32.8.1 13-Mar-2006  yamt sync with head.
 1.32.6.1 22-Apr-2006  simonb Sync with head.
 1.32.4.1 09-Sep-2006  rpaulo sync with head
 1.33.8.1 13-Jul-2006  gdamore Merge from HEAD.
 1.33.6.1 19-Jun-2006  chap Sync with head.
 1.34.6.1 22-Oct-2006  yamt sync with head
 1.34.4.1 18-Nov-2006  ad Sync with head.
 1.35.38.1 08-Jan-2008  bouyer Sync with HEAD
 1.35.30.1 18-Feb-2008  mjf Sync with HEAD.
 1.35.24.1 09-Jan-2008  matt sync with HEAD
 1.36.24.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.18.1 28-Apr-2009  skrll Sync with HEAD.
 1.36.10.3 11-Mar-2010  yamt sync with head
 1.36.10.2 16-May-2009  yamt sync with head
 1.36.10.1 04-May-2009  yamt sync with head.
 1.40.4.2 21-Apr-2011  rmind sync with head
 1.40.4.1 05-Mar-2011  rmind sync with head
 1.40.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.42.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.43.4.1 30-Oct-2012  yamt sync with head
 1.46.16.1 22-Sep-2015  skrll Sync with HEAD
 1.46.2.1 03-Dec-2017  jdolecek update from HEAD
 1.49.2.1 22-Apr-2018  pgoyette Sync with HEAD
 1.5 24-Sep-2016  mrg introduce a better pci_drvname() and PCI_IOC_DRVNAME as pciio_drvnameonbus()
and PCI_IOC_DRVNAMEONBUS. the new ones also take a (autoconf) PCI bus
number, which allows lookups for any device on any pci bus node. use this
in pcictl which current reports the wrong values sometimes.

up next: use these in libpciaccess.
 1.4 25-Jul-2014  mrg branches: 1.4.4; 1.4.8;
introduce a new pci_drvname(3) to libpci. implement it in the backend
via PCI_IOC_DRVNAME.

update manual and set lists (and remove a couple of doubled entries.)o

this will be used in libpciaccess() to implement the has_kernel_driver()
method.
 1.3 06-Jun-2009  cegger branches: 1.3.22; 1.3.36;
typo in comment: autconfiguration -> autoconfiguration
 1.2 14-Sep-2001  simonb branches: 1.2.2; 1.2.4; 1.2.8; 1.2.126; 1.2.142;
Fix tyop.
 1.1 13-Sep-2001  thorpej Add an ioctl interface to the PCI bus. Add ioctls to read/write
PCI configuration space registers, and to fetch bus info.
 1.2.142.1 23-Jul-2009  jym Sync with HEAD.
 1.2.126.1 20-Jun-2009  yamt sync with head
 1.2.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.1 14-Sep-2001  thorpej file pciio.h was added on branch kqueue on 2002-01-10 19:57:03 +0000
 1.2.4.2 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.1 14-Sep-2001  fvdl file pciio.h was added on branch thorpej-devvp on 2001-10-01 12:46:03 +0000
 1.2.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.2.2.1 14-Sep-2001  nathanw file pciio.h was added on branch nathanw_sa on 2001-09-21 22:36:02 +0000
 1.3.36.1 10-Aug-2014  tls Rebase.
 1.3.22.2 03-Dec-2017  jdolecek update from HEAD
 1.3.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.4.1 05-Oct-2016  skrll Sync with HEAD
 1.172 31-Dec-2024  skrll Use C99 types
 1.171 14-Jun-2024  msaitoh branches: 1.171.2;
PCI_CLASS_MASK: Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.170 19-Apr-2024  andvar s/Resorce/Resource/ in comment and log message.
 1.169 02-Feb-2024  andvar s/Staus/Status/ in comments.
 1.168 17-Oct-2022  mrg branches: 1.168.2;
add pcie capability and read request size linux compat, some pci root support

implement support for:
- pcie_capability_read_dword()
- pcie_capability_read_word()
- pcie_capability_write_dword()
- pcie_capability_write_word()
- pcie_get_readrq()
- pcie_set_readrq()

implement the "struct pci_dev" bus->self member by creating a minimal fake
"struct pci_dev" for the pci bus itself. this is kind of gross. it checks
that the current device's parent is a netbsd "pci" device, and that it has
a (grand) parent "ppb" device, and then fills in the fake device based upon
the pci and ppb devices.

add some PCIE_LCSR2_TGT_LSPEED encodings, and map them to linux names.
map several other PCIE_LCSR and PCIE_LCAP names.

uncomment several pcie code segments in radeon and amdgpu. (not sure that
we can test the amdgpu_si.c change, as we use the radeon version and the
amdgpu version hangs on the one machine i have.)

tested on amdgpu (RX550) and radeon (7750 & 3650).


ok @riastradh
 1.167 01-Oct-2022  rin No need to mangle argument of macro.
 1.166 20-Sep-2022  mrg fill out more of the linux pci API compat

- implement pcie_get_speed_cap(), pcie_bandwidth_available(), and
pci_is_root_bus().
- expand "enum pci_bus_speed" to add PCIe 5.x and 6.x speeds.
- add "enum pcie_link_width".
- add defines for PCIE_LCSR_LINKSPEED (PCIe generation) and PCIE_LCSR_NLW
(negotiated lane width) to pcireg.h
- enable amdgpu_device_get_pcie_info() code now it works.

ok riastradh@
 1.165 31-Jan-2022  msaitoh Decode SCSI programming interface. Whitespace fix.
 1.164 31-Jan-2022  msaitoh Add three new extended capabilities:

- Physical Layer 32.0 GT/s
- Alternate Protocol
- System Firmware Intermediary
 1.163 01-Jan-2022  msaitoh Print Physical Layer 16.0 GT/s and Lane Margining at the Receiver extended cap.

- Decode Physical Layer 16.0 GT/s extended capability.
- Decode Lane Margining at the Receiver extended capability.
- Rename pcie_link_compliance_preset_deemphasis to
pcie_link_preset_preshoot_deemphasis because the table is referenced from
multiple places.
- Print "reserved" instead of "unknown" when printing equalization preset.
One of them is known to be the default value.
- Rename PCI_EXTCAP_PYSLAY_16GT to PCI_EXTCAP_PL16G.
 1.162 28-Dec-2021  msaitoh Decode link control2's Compliance Preset/De-emphasis more. Fix typo.
 1.161 10-Oct-2021  msaitoh Use PCI-SIG official acronyms:

- RP stands for Root Port.
- RC stands for Root Complex.
- RCIEP stands for Root Complex Integrated End Point.
 1.160 10-Oct-2021  msaitoh Add Some PCI config information:

- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
 1.159 10-Oct-2021  msaitoh Whitespace fix. No functional change.
 1.158 09-Sep-2021  mrg fix part of the previous: Link Capability Max Speed is a value not
a bitmask. pointed out by msaitoh@.
 1.157 09-Sep-2021  mrg add some bits in the pci Link Capabilities Register, and also the similar
set in the Link Capabilities 2 Register.
 1.156 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.155 24-Jun-2021  thorpej From the "Should have been done years ago" department, add some macros
describing the format of PCI Type 0 and Type 1 Configuration Cycle
addresses.
 1.154 15-May-2021  jakllsch Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to prevent
sign extension of product ID when shifted up into place in PCI_ID_CODE()

Should fix PR 56176.
 1.153 28-Dec-2020  skrll branches: 1.153.4; 1.153.6;
Add second space indentation for bit field values for Enhanced Allocation
capabilities. From thorpej.
 1.152 28-Dec-2020  skrll Trailing whitespace
 1.151 18-Feb-2020  msaitoh branches: 1.151.6;
Add comment.
 1.150 25-Jan-2020  msaitoh Add PCIe 4.0 stuff a little:

- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.
 1.149 22-Jan-2020  msaitoh Remove unused shift and mask definitions.
 1.148 11-Dec-2019  msaitoh branches: 1.148.2;
s/enalbe/enable/
 1.147 01-Mar-2019  msaitoh branches: 1.147.4;
- Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.146 30-Nov-2018  msaitoh Add new PCIE_HAS_LINKREGS(pcie_devtype) and use it. No functional change.
 1.145 30-Nov-2018  msaitoh Add new macro PCIE_HAS_ROOTREGS(pcie_devtype) and use it. No functional
change.
 1.144 28-Nov-2018  msaitoh The register offset of the mask and pending register is depend on the 64bit
address capable bit, so fix the definition of PCI MSI vector mask and pending
register. This problem was not a real bug because PCI_MSI{MASK,PENDING} were
not used from anywhere.
 1.143 05-Nov-2018  msaitoh Decode PCI Enhanced Allocation.
 1.142 03-Oct-2018  msaitoh - Don't print TPH requester's ST Table Size if the ST table location field
is not PCI_TPH_REQ_STTBLLOC_TPHREQ because the size field is only applicaple
for PCI_TPH_REQ_STTBLLOC_TPHREQ case.
- Add comment.
 1.141 27-Sep-2018  msaitoh Root Complex Event Collector Bus Number Association ECN.
- If capability version is 2 (or greater), decode RCEC Associated Bus Numbers
register.
 1.140 12-Sep-2018  msaitoh Add ATS Relaxed Ordering supported bit described in Address Translation
Relaxed Ordering ECN.
 1.139 02-Jul-2018  msaitoh VGA 16 bit decode bit is not bit 3 but bit 4.
 1.138 09-May-2018  msaitoh branches: 1.138.2;
Fix typo. s/TPL/TLP/
 1.137 01-Feb-2018  msaitoh branches: 1.137.2;
- Add PCie Link Activation ECN.
- Use macro.
- KNF.
 1.136 18-Dec-2017  msaitoh Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.

NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.
 1.135 19-Oct-2017  msaitoh Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.
 1.134 10-Oct-2017  msaitoh Decode IOMMU capability of PCI secure device capability. From "AMD I/O
Virtualization Technology(IOMMU) Specification (#48882) Revision 3.00".
 1.133 05-Oct-2017  msaitoh - Add PCI_MAPREG_ROM_ADDR_MASK macro and PCI_MAPREG_ROM_ADDR() macro.
- print PCI_MAPREG_ROM_ENABLE bit.
- Decode Expansion ROM Validation ECN.
- Add Native PCIe Enclosure Management ECN's extended capability type.
Not decoded yet.
 1.132 13-Jul-2017  msaitoh - Official shortname of LN Requester is LNR, so change PCI_EXTCAP_LN_REQ
to PCI_EXTCAP_LNR
- Use macro.
 1.131 15-Jun-2017  msaitoh Fix a bug that LTR's latency in L1 PM Substates capability and Latency
Tolerance Reporting capability isn't printed correctly.
 1.130 29-May-2017  msaitoh branches: 1.130.2;
Print MSI Message data in 32bits when the Extended Message Data Capable bit
is set.
 1.129 24-May-2017  msaitoh Decode TPH Requester Control register.
 1.128 21-Apr-2017  msaitoh Add Flattening Portal Bridge capability ID and Hierarchy ID extended
capability ID.
 1.127 20-Apr-2017  msaitoh Add Downstream Port Containment (DPC) ECN and Enhanced DPC(eDPC) ECN.
 1.126 17-Apr-2017  msaitoh Use macro. No functional change.
 1.125 28-Mar-2017  msaitoh Sort & indent. No functional change.
 1.124 28-Mar-2017  msaitoh Indent. No functional change.
 1.123 28-Mar-2017  msaitoh Lowercase for consistency. No functional change.
 1.122 14-Mar-2017  msaitoh Add two new PCI classes:
- processing accelerators
- non-essential instrumentation
 1.121 27-Feb-2017  msaitoh Decode AGP capability.
 1.120 15-Feb-2017  msaitoh - Print Data Select and Data Scale in pci_conf_print_pcipm_cap().
- The Message Data register of MSI cap is not 32bit but 16bit.
- When the PCIE_LCAP_MAX_SPEED bitfiled is 0, it means it supports 2.5GT/s only.
- Print link de-emphasis value by "-X dB".
- Print Completion Timeout Ranges Supported filed with alphabets.
- Print TPH Completer Supported fileld's meaning.
- Print PCIE_DCAP2_MAX_EETLP correctly. 0 means 4 End-End TLP Prefixes.
- If the Supported Link Speed Vector is 0, the Link Capability 2 register is not
implemented. Don't decode LCAP2 when the vector is 0.
- The ACS's Egress Control Vector is 32bit, so print with 0x%08x.
- Print SR-IOV's device ID.
- Use __SHIFTOUT() to avoid using magic number.
- Prefix "0x" for hexadecimal value.
 1.119 28-Dec-2016  msaitoh branches: 1.119.2;
The Power Controller Control bit (PCIE_SLCSR_PCC) in the Slot Control & Status
Register is 0 on power on. Print "Power <on|off>" instead of "<on|off>".
 1.118 27-Dec-2016  msaitoh Fix PASID Control Register.
 1.117 31-Oct-2016  msaitoh Decode Resizable BAR.
 1.116 20-Oct-2016  msaitoh - pci_conf_print_pwrbdgt_base_power(): From 0xf3 to 0xff of the Base power are
reserved above 300W (PCI 3.0 Errata).
- Emergency Power Reduction mechanism with PWRBRK signal ECN.
- Extended Message Data for MSI ECN.
- Fix typo in comment.
 1.115 19-Oct-2016  msaitoh Add VF Resizable BARs ECN.
 1.114 17-Aug-2016  msaitoh Add Dynamic Power Allocation (DPA) ECN support.
 1.113 11-May-2016  msaitoh branches: 1.113.2;
Add Precision Time Management (PTM) ECN.
 1.112 18-Nov-2015  msaitoh - Add the Auto Slot Power Limit Disable bit in Slot Control register and
the Completion Timeout Prefix/Header Log Capable bit in the AER capability
and control register (ECN: Downstream Port Containment (DPC)).
- Add the Poisoned TLP Egress Block bit (ECN: Enhanced DPC).
- Update Link Capabilities 2 register and Link Control 3 register (ECN:
Separate Refclk Independent SSC Architecture (SRIS))
- ECN: Readiness Notifications (RN)
- Add the Retimer Presence Detect Supported bit in the Link Capabilities 2
register and the Retimer Presence Detected bit in the Link Status 2 register
(ECN: Extension Devices)
 1.111 17-Nov-2015  msaitoh - ARI's function group is not bit 32-24 but 22-20.
- Add the Structure Length field in AF capability register.
- Add Enhanced Allocation extended capability ID (ECN: Enhanced Allocation (EA)
for Memory and I/O Resources).
- Add LN System CLS (ECN: Lightweight Notification (LN) Protocol).
- Add ST Upper and Lower bit definitions (ECN: TLP Processiong Hints).
- Add the Global Invalidate bit in the ATS capability register and the PRG
Response PASID Required bit in the Page Request status register (ECN: PASID
Translation)
- Decode ASPM support bit more (ECN: ASPM Optionally)
- Use __BITS()
 1.110 17-Nov-2015  msaitoh No functional change:
- Add comments.
- Remove obsolete comment.
- Move definitions to better location.
- Rename bit definition.
- KNF.
- Indent.
 1.109 16-Nov-2015  msaitoh Define PCIE_XCAP_{VER,TYPE}(x) and use them.
 1.108 12-Nov-2015  msaitoh - Restore pci_subr.c rev. 1.135's change in pci_conf_print_caplist().
As wrote in the comment, HyperTransport capability appears multiple times.
pci_conf_cap() reruns only the first entry, so it can't be used here.
- Try to decode HyperTransport capability. Currently, the capability type
of each HyperTransport capability is printed and only the MSI Mapping
capability is decoded.
- Style change.
 1.107 12-Nov-2015  msaitoh PCI_HT_CAP() is right shifted value, so PCI_HT_CAP_* should not use
__SHIFTIN(). This change fixes a bug that HyperTransport system misunderstand
whether MSI/MSI-X can be used or not.
 1.106 30-Oct-2015  msaitoh - Move PCI_INTRSTR_LEN from pcireg.h to pcivar.h.
- In PCI-X cap, print 2nd bus's PCI-X mode, error protection type, Max clock
frequency and Max clock period.
- In SATA cap, print register location correctly.
- In Virtual Channel cap, print reference clock with "ns".
- In Root Complex Link Declaration, print Link Entry number.
 1.105 21-Oct-2015  msaitoh Decode SATA Capability and Multicast Extendeded Capability.
 1.104 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.103 27-Jul-2015  msaitoh Add NVMe.
 1.102 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.101 23-Feb-2015  knakahara - add macros to calculate MSI MME and MMC.
- add MSI-X table offset macros.
- fix MSI-X table entry name.
 1.100 24-Nov-2014  msaitoh branches: 1.100.2;
Add PCIe CRS Software Visibility bit.
 1.99 23-Oct-2014  msaitoh Add some HyperTransport related defines. It's required for the MSI.
 1.98 23-Oct-2014  msaitoh Add comment.
 1.97 06-Oct-2014  msaitoh - Add some PCI subclass and interfaces.
- The interface of PCI_SUBCLASS_BRIDGE_RACEWAY is not decoded yet.
- Fix typo in a message.
- Add comment.
- Modify comment.
 1.96 24-Sep-2014  msaitoh Rename PCIE_XCAP_VER_* macros to avoid confusion.
 1.95 09-Jun-2014  msaitoh branches: 1.95.2;
Add IOMMU and the Root Complex Event Collector.
 1.94 30-May-2014  msaitoh - Add PCI-X capability stuff.
- remove extra ':' in pci_conf_print_pcie_cap()
- Add comments.
 1.93 27-May-2014  msaitoh - Add some register definition for MSI and MSI-X
- print MSI-X capability
 1.92 27-May-2014  msaitoh - Fix incorrect calculation in PCI_MSIX_CTL_TBLSIZE().
- The PCI_MSIX_CTL_TBLSIZE bit field is in N-1, so add +1.
 1.91 24-May-2014  msaitoh Print some PCI Capabilities:
- Vendor specific (ID:0x09)
- Debugport (ID:0x0a)
- Subsystem (ID:0x0d)
- PCI Advanced Features (ID:0x13)
 1.90 24-May-2014  msaitoh - Decode the programming interface field in the Class Code register and print
it.
- Print the cache line size in bytes.
- Print the Link Status 2 register itself.
- Some bits were not printed if the bit is 0. Always print them using with
onoff() macro.
- Print more bits.
- KNF.
- Use macro.
- Add comments.
 1.89 23-May-2014  msaitoh - Add some register definitions (subclass, power management, etc.)
- Print some information (subclass, power management)
- Use macro.
 1.88 23-May-2014  msaitoh PME# clock is not bit 2 but bit 3. Use the macro!
 1.87 23-May-2014  msaitoh No functional change:
- sort in PCI capability ID order.
- add comments.
 1.86 09-May-2014  msaitoh Print the CRS Software Visibility Enable bit and the Crosslink Supported bit.
 1.85 29-Mar-2014  christos branches: 1.85.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.84 21-Apr-2013  msaitoh branches: 1.84.4;
- Add some PCIe 2.0 or higher capability register definitions.
- Rename some registers.
- Add comments.
- Indent.
 1.83 21-Apr-2013  msaitoh Delete "PCI_" from PCIX and PICE capability registers.
 1.82 17-Apr-2013  msaitoh - Add slot related registers
- Add root port related registers
- Fix the definition of PCI_PCIE_SLCAP_PSN
- Cleanup
 1.81 17-Apr-2013  msaitoh Add PCI_CAP_SUBVENDOR (= 0x0d).
 1.80 16-Apr-2013  msaitoh Decode some PCIe capability register bits.
 1.79 16-Apr-2013  msaitoh Fix a bug that IRQ(MSI) bits in PCIe capability register is incorrectly
decoded. The bit field is not 0x4e000000 but 0x3e000000.
 1.78 15-Apr-2013  msaitoh Add some PCIE capability register bit definitions from FreeBSD.
 1.77 12-Apr-2013  msaitoh Add comments for some PCI Express Capability registers.
 1.76 03-Mar-2013  msaitoh Add PCI Express's relax ordering bit.
 1.75 20-Oct-2012  matt Add PCI_SUBCLASS_MASS_STORAGE_NVM
 1.74 02-Sep-2012  matt branches: 1.74.2;
Finish devices the bits in PCIE capability LCSR field.
 1.73 17-Aug-2011  dyoung branches: 1.73.2; 1.73.8; 1.73.10;
Redefine PCI_MSI_* and PCI_PCIE_* constants in terms of bits(3).

Use named constants and more conventional variable names in
pci_msi_establish() and pci_msi_disestablish(). Fix a couple of bugs:
pci_msi_establish() returned a pointer to the struct intrhand instead of
to the struct msi_hdl as it was intended to, and pci_msi_disestablish()
did not free(9) the msi_hdl.
 1.72 06-Jun-2011  msaitoh Add two new capabilities(PCI_CAP_SATA and PCI_CAP_PCIAF).
 1.71 05-Apr-2011  dyoung branches: 1.71.2;
Use PCI_MAPREG_START instead of the anonymous constant 0x10.
 1.70 26-Jan-2011  dyoung Define masks for subsystem vendor and subsystem ID fields, plus a couple
of macros for extracting them.
 1.69 10-Jan-2011  jmcneill branches: 1.69.2; 1.69.4;
ppb_fix_pcix changes:
- rename to ppb_fix_pcie
- support version PCI-E 2.0
- print version and device/port type information
- use constants from pcireg.h instead of magic numbers

changes:

ppb2 at pci0 dev 21 function 0: vendor 0x15ad product 0x07a0 (rev. 0x01)
ppb2: unsupported PCI Express version

to:

ppb2 at pci0 dev 21 function 0: vendor 0x15ad product 0x07a0 (rev. 0x01)
ppb2: PCI Express 2.0 <Root Port of PCI-E Root Complex>
 1.68 11-Dec-2010  matt Add some PCI Express definitions, MSI, MSIX, etc.
 1.67 20-Mar-2010  dyoung Add PCI_BAR(n) for the nth Base Address Register.
 1.66 26-Feb-2010  dyoung branches: 1.66.2;
Move the definitions for PCI_BAR0, PCI_BAR1, PCI_BAR2, PCI_BAR3,
PCI_BAR4, and PCI_BAR5 to pcireg.h for re-use.
 1.65 23-Feb-2010  dyoung Remove unused functions pci_disable_retry() and cardbus_disable_retry().
 1.64 12-Feb-2010  msaitoh - Add some PCIe config registers.
- The register at 0x1c is not Control Status register. It contains Control
bits only. Rename it.
 1.63 01-Feb-2010  msaitoh branches: 1.63.2;
Fix the bug that unaligned access occurs on amd64. It also fixes the bug
that error bits aren't cleard because these bits are W2C (in other word, W1C).

Reported by Michael van Elst.
 1.62 28-Jan-2010  msaitoh Add some register definitions.
 1.61 11-Sep-2009  christos Add support for the 5100 and newer firmware. Tested also with the 4900.
Thanks to everyone for helping and testing.
 1.60 17-Aug-2009  jakllsch A few new PCI register #defines:
- size of config and extended config space
- EFI ROM code type number
- extended capability list register bits
 1.59 16-Jan-2009  cegger rename PCI_PMCSR_PME to PCI_PMCSR_PME_STS.
Per request from jmcneill
 1.58 16-Jan-2009  cegger add Power Management flag. From FreeBSD.
 1.57 25-Dec-2007  perry branches: 1.57.6; 1.57.10; 1.57.18; 1.57.20; 1.57.26;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.56 28-Nov-2007  briggs branches: 1.56.2; 1.56.6;
Correct a typo. To create the command/status word, shift the components
left, not right.
 1.55 12-Nov-2007  joerg Merge pci_disable_retry function from jmcneill-pm as it is found in
various drivers.
 1.54 13-May-2007  kent branches: 1.54.6; 1.54.8; 1.54.12; 1.54.14;
Add PCI_SUBCLASS_MULTIMEDIA_HDAUDIO to pcireg.h
and azalia(4) uses it
 1.53 26-Jan-2007  dyoung branches: 1.53.2; 1.53.6; 1.53.8;
#Define PCI_PMCSR_PME_EN.
 1.52 08-Nov-2006  drochner branches: 1.52.2; 1.52.4;
avoid magic number
 1.51 17-Jun-2006  christos branches: 1.51.4; 1.51.6;
re-factor the pci powestate api. reviewed by gimpy
 1.50 31-May-2006  drochner branches: 1.50.2;
-add 2 subclasses new in rev. 3.0 of the spec, and fix a pasto in another
-get power management rev printing right
 1.49 01-Mar-2006  gdamore branches: 1.49.2; 1.49.8;
Add pci_find_rom() API as discussed on tech-kern.
 1.48 27-Feb-2006  gdamore Add PCI_MAPREG_TYPE_ROM and allow it to be used with pci_mapreg_map().
Fix to configure (but do not enable) BARs for expansion ROMs.
Reviewed by briggs@
 1.47 11-Dec-2005  christos branches: 1.47.2; 1.47.4; 1.47.6;
merge ktrace-lwp.
 1.46 02-Aug-2004  joda branches: 1.46.12;
bridge memory and lower prefetch memory ranges are only 12 bits wide
 1.45 04-Feb-2004  soren Use the right bits for the AGP version.
 1.44 02-Dec-2003  briggs Configure PCI-Cardbus bridges, too.
Patch from KIYOHARA Takashi on current-users.
 1.43 21-Oct-2003  thorpej - Since we access PCI config space as 32-bit words, redefine the PCI-X
command register bits offset and shifted appropriatly (PCI-X command
makes up the upper 16 bits of the register that holds the PCI-X cap ID
and next-cap-pointer).
- Define shift counts for max memory read byte count in the command
and status registers.
 1.42 05-May-2003  fvdl branches: 1.42.2;
Define PCI32_DMA_BOUNCE_THRESHOLD
 1.41 20-Apr-2003  fvdl Add register definitions for the PCI-X capability.
 1.40 25-Mar-2003  thorpej Add PCI VPD access routines. From psi.cz!freza, PR kern/20889.
 1.39 21-Sep-2002  drochner -correct the "MSI" capability
-add some new subclasses and capability IDs
 1.38 18-Jun-2002  tshiozak add support for the per-device power management capability.

int pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int newstate)
set power state of the device to newstate.
int pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
get current power state of the device.

In the future, these functions will be used for ACPI support.
 1.37 22-Mar-2002  drochner branches: 1.37.2;
iadd subclass codes from the 2.3 spec
 1.36 30-Aug-2001  briggs Rename PCI_MAPREG_TYPE_ROM to PCI_MAPREG_ROM_ENABLE to keep up with pciconf.?
 1.35 06-Jul-2001  thorpej branches: 1.35.2;
Add a bunch of Vital Product Data definitions.
 1.34 12-Feb-2001  briggs branches: 1.34.2;
Deal with a lack of the proper type of memory. For example, if a bridge
only supports 16-bit I/O addresses, do not configure it with addresses
having the upper 16-bits non-zero.
 1.33 09-Feb-2001  briggs Add an option (defopt) PCI_NETBSD_CONFIGURE that provides PCI bus
configuration (assignment of bus numbers, BARs, timer values,
interrupt lines, etc.).
The interface must be called from m.d. code prior to probing the bus.
It is meant to be called once for each primary (bus == 0) PCI bus in
the system. It will configure any busses behind PCI-PCI bridges.
Section 9 man page for pci_configure_bus() will come soon.
In the meantime, sample usage is in arch/sandpoint/sandpoint/mainbus.c.
[ Reviewed by thorpej ]
 1.32 07-Oct-2000  cgd Update for current PCI device class/subclass and capability codes.
(also, tweak the I2O subclass string to be "standard" -- the removal
of version info didn't extend that far.)
 1.31 02-Oct-2000  ad I2O subclasses currently have nothing to do with the protocol version.
 1.30 21-Aug-2000  castor Add a bunch of macros of the form PCI_<regname>_CODE similar to
existing PCI_ID_CODE to create the PCI appropriate register from
parameters.

Avoid use of 'class' in macro -- it's a C++ reserved keyword.
 1.29 18-Jul-2000  soda add "#define PCI_INTERRUPT_PIN_MAX 0x04"
 1.28 09-Jun-2000  soda branches: 1.28.2;
long long constant needs "LL" suffix.
 1.27 12-May-2000  jhawk branches: 1.27.2;
Define some PCI power management CSR constants.
 1.26 10-May-2000  thorpej Add support for mapping 64-bit PCI memory space. If the region
is mapped in a way that is inaccessible by a 32-bit bus_addr_t, then
print a message to that effect and return failure.

Original patches by Bill Studenmund, with a few small changes by me.
 1.25 08-May-2000  kleink Add a register offset for the Capability List Pointer in header type 2.

XXX Ideally the PCI-Cardbus Bridge header should be restructured to just
XXX present standard register definitions, making it ~safe to be included.
 1.24 28-Apr-2000  uch add PCI_MAPREG_PPB_END (PCI-PCI bridge) PCI_MAPREG_PCB_END (PCI-Cardbus bridge)
 1.23 25-Jan-2000  drochner use BUS_SPACE_MAP_PREFETCHABLE instead BUS_SPACE_MAP_CACHEABLE where the
PCI BAR bit is referred to
 1.22 16-Nov-1999  enami Make this file compile again; terminate the continuation line with backslash.
 1.21 15-Nov-1999  thorpej Add a macro to generate a class code given class, subclass, and interface.

From UCHIYAMA Yasushi's PCI BIOS patches.
 1.20 27-Sep-1999  cgd branches: 1.20.2; 1.20.8;
add classes/subclasses new in PCI 2.2. Needs a bit of cleanup, but then,
so does everything involving configuration space headers and if i don't
get this out of my source tree i'll go insane.
 1.19 21-Dec-1998  drochner add two of the newer register definitions
 1.18 07-Nov-1998  drochner add support for "extended capabilities" (new in PCI spec 2.2)
 1.17 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.16 01-Jun-1998  cgd according to the PCI 2.1 spec, the low _two_ bits of I/O BARs have
defined meaning/value other than specifying the address of the region.
(lowest bit is 1, meaning I/O space. second-lowest bit is reserved.)
 1.15 18-May-1998  cgd add a PCI_HDRTYPE_TYPE() macro, to get the 'type' portion of the
headertype register (i.e., not including the 'multifunction' bit).
 1.14 14-Apr-1998  thorpej Add UDF and 66MHz capable bit definitions for the PCI status register.
From Zubin D. Dittia <zubin@clouseau.arl.wustl.edu>, PR #4249.
 1.13 11-Apr-1997  cgd clean up some constants ([A-F]->[a-f] in hex constants
 1.12 19-Mar-1997  cgd fix multi-function device support, add new known classes/subclasses,
and clean up class/subclass printing. From brb@brig.com via PR 3359.
 1.11 10-Aug-1996  mycroft Change PCI_MAPREG_{MEM,IO}_SIZE() to use the standard `x & -x' trick to select
the lowest bit set. This isn't any more or less valid according to the PCI
spec, but it deals with lame devices that don't implement all of the top
bits.
 1.10 06-Aug-1996  cgd revert PCI_MAPREG_IO_ADDR_MASK and PCI_MAPREG_IO_SIZE_MASK to their old
values, i.e. 0xfffffffe and 0xffffffff respectively. The changed
definitions were incorrect, according to the PCI Local Bus Specification
(Revision 2.0). Further rationale and a workaround for the broken
devices that instigated the change provided in a message to
current-users@netbsd.org, dated Mon, 05 Aug 1996 22:06:58 -0400,
message ID 16773.839297218@ux2.sp.cs.cmu.edu>.
 1.9 26-Jul-1996  mycroft Add PCI_MAPREG_{IO,MEM}_SIZE(), and use them.
 1.8 26-Jul-1996  mycroft Changes PCI_MAPREG_IO_ADDR_MASK to 0xfffe.
 1.7 27-Mar-1996  cgd branches: 1.7.4;
modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.6 27-Mar-1996  cgd add definitions for the BIST/Header Type/Latency Timer/Cache Line Size
configuration space register, and use it to determine whether or not
a given PCI device uses multiple functions.
 1.5 04-Mar-1996  cgd reorganize mapping register definitions
 1.4 27-Jul-1995  mycroft Add stuff for I/O mapping.
 1.3 18-Jun-1995  cgd macros to split out various parts of PCI registers, adjust constants
to match. (now, comparisons are comparisons, code doing them doesn't
have to mask.) define types for the various parts of the registers'
contents, where practical.
 1.2 27-Oct-1994  cgd new RCS ID format.
 1.1 09-Aug-1994  mycroft Add PCI autoconfiguration support.
 1.7.4.1 10-Dec-1996  mycroft From trunk:
Deal with devices that do not allow allow of the I/O address bits to be set.
 1.20.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.20.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.20.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.20.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.27.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.28.2.2 25-Oct-2001  he Pull up revisions 1.31-1.32 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.28.2.1 10-Aug-2000  soda Pull up to netbsd-1-5 branch
Approved by: thorpej

- define PCI_INTERRUPT_PIN_MAX and use it instead of magic number.
- define I386_PCI_INTERRUPT_LINE_NO_CONNECTION and use it instead of
magic number.

Revisions pulled up:
> cvs rdiff -r1.28 -r1.29 syssrc/sys/dev/pci/pcireg.h
> cvs rdiff -r1.14 -r1.15 syssrc/sys/arch/i386/include/pci_machdep.h
> cvs rdiff -r1.38 -r1.39 syssrc/sys/arch/i386/pci/pci_machdep.c
> cvs rdiff -r1.1 -r1.2 syssrc/sys/arch/i386/pci/opti82c558.c \
> syssrc/sys/arch/i386/pci/sis85c503.c \
> syssrc/sys/arch/i386/pci/via82c586.c
 1.34.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.34.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.34.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.34.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.34.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.35.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.35.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.35.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.35.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.37.2.1 15-Jul-2002  gehenna catch up with -current.
 1.42.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.42.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.42.2.1 03-Aug-2004  skrll Sync with HEAD
 1.46.12.7 21-Jan-2008  yamt sync with head
 1.46.12.6 07-Dec-2007  yamt sync with head
 1.46.12.5 15-Nov-2007  yamt sync with head.
 1.46.12.4 03-Sep-2007  yamt sync with head.
 1.46.12.3 26-Feb-2007  yamt sync with head.
 1.46.12.2 30-Dec-2006  yamt sync with head.
 1.46.12.1 21-Jun-2006  yamt sync with head.
 1.47.6.2 01-Jun-2006  kardel Sync with head.
 1.47.6.1 22-Apr-2006  simonb Sync with head.
 1.47.4.1 09-Sep-2006  rpaulo sync with head
 1.47.2.1 01-Mar-2006  yamt sync with head.
 1.49.8.1 19-Jun-2006  chap Sync with head.
 1.49.2.1 26-Jun-2006  yamt sync with head.
 1.50.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.51.6.1 10-Dec-2006  yamt sync with head.
 1.51.4.2 01-Feb-2007  ad Sync with head.
 1.51.4.1 18-Nov-2006  ad Sync with head.
 1.52.4.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.52.2.1 30-Jul-2007  liamjfoy Pull up following revision(s) (requested by dyoung in ticket #739):
sys/dev/pci/pccbb.c: revision 1.140
sys/dev/pci/pccbb.c: revision 1.141
sys/dev/pci/pccbb.c: revision 1.142
sys/dev/pci/pccbb.c: revision 1.143
sys/dev/pci/pccbb.c: revision 1.144
sys/dev/pci/pccbbvar.h: revision 1.28
sys/dev/pci/pcireg.h: revision 1.53
sys/dev/pci/pccbb.c: revision 1.139
Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR.

Fix grammar in comment. From Patrick Welche.

Use the right subroutine name for the debug message.

Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().

Cosmetic: KNF indentation, curly braces, and argument declarations.

sc_pwrcycle is shared between the interrupt handler and Cardbus
event thread, so make it volatile.

Fix a bug in Cardbus power activation.

Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'. TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt. When pccbb_power() powered-up a
cardslot, it did wait for the interrupt. If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0: power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete. After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up. An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

/*
* Wait as long as 200ms for a power-cycle interrupt. If
* interrupts are enabled, but the socket has already
* changed to the desired status, keep waiting for the
* interrupt. "Consuming" the interrupt in this way keeps
* the interrupt from prematurely waking some subsequent
* pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

* XXX Not every bridge interrupts on the ->OFF transition.
* XXX That's ok, we will time-out after 200ms.
*
* XXX The power cycle event will never happen when attaching
* XXX a 16-bit card. That's ok, we will time-out after
* XXX 200ms.
*/

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
 1.53.8.1 11-Jul-2007  mjf Sync with head.
 1.53.6.1 27-May-2007  ad Sync with head.
 1.53.2.1 17-May-2007  yamt sync with head.
 1.54.14.3 18-Feb-2008  mjf Sync with HEAD.
 1.54.14.2 08-Dec-2007  mjf Sync with HEAD.
 1.54.14.1 19-Nov-2007  mjf Sync with HEAD.
 1.54.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.54.8.1 09-Jan-2008  matt sync with HEAD
 1.54.6.3 03-Dec-2007  joerg Sync with HEAD.
 1.54.6.2 14-Nov-2007  joerg Sync with HEAD.
 1.54.6.1 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.56.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.56.2.1 26-Dec-2007  ad Sync with head.
 1.57.26.2 15-Feb-2014  matt sync pcireg.h with HEAD.
update if_wm.c and ppb.c accordingly.
 1.57.26.1 24-Dec-2011  matt Pull down latest from -HEAD.
 1.57.20.3 09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.57.20.2 11-May-2013  riz Applied patch (requested by msaitoh in ticket #1844):

sys/dev/pci/pcireg.h 1.69
sys/dev/pci/ppb.c 1.44-1.45

Support PCI Express 2.0.
Print version and device/port type information
[msaitoh, ticket #1844]
 1.57.20.1 19-Nov-2010  riz branches: 1.57.20.1.2;
Pull up revisions (requested by msaitoh in ticket #1358):
sys/dev/pci/if_wm.c 1.196-1.199,1.202,1.205
sys/dev/pci/if_wmvar.h 1.9
sys/dev/pci/if_wmreg.h 1.36-1.39
sys/dev/pci/pcireg.h 1.61-1.64
sys/dev/pci/pcidevs 1.1023
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
mii/igphy.c 1.21
mii/igphyvar.h 1.1
mii/inbmphyreg.h 1.2

- Count Receive error, CRC error, Alignment error, Symbol error, Sequence
error, Carrier extension error and Receive length error into ierror.
Fixes PR#30349 reported by UMEZAWA Takeshi.
- Add support for 82575, 82576 and 82580(ER).
- Apply the patch for 82575 from Wolfgang Stukenbrock (PR#42422). We use
only one RX ring and with the legacy mode.
- Add support for 82576.
- Partial support for 82580.
- Partial support for the serdes systems.
- Add two workarounds for ICH8 with igp3.
- Workaround for 82566 Kumeran PCS lock loss.
- WOL from S5 stops working.
- (pcireg.h) Add PCIe config register definitions.
- Note that the changes to count Missed packet (rx fifo overflow) and Receive
no buffers (rx ring full) into iqdrops in rev. 1.196 of if_wm.c is not
pulled up.
 1.57.20.1.2.1 07-Jan-2011  matt Add/define some MSI support
 1.57.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.57.10.5 11-Aug-2010  yamt sync with head.
 1.57.10.4 11-Mar-2010  yamt sync with head
 1.57.10.3 16-Sep-2009  yamt sync with head
 1.57.10.2 19-Aug-2009  yamt sync with head.
 1.57.10.1 04-May-2009  yamt sync with head.
 1.57.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.63.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.66.2.4 12-Jun-2011  rmind sync with head
 1.66.2.3 21-Apr-2011  rmind sync with head
 1.66.2.2 05-Mar-2011  rmind sync with head
 1.66.2.1 30-May-2010  rmind sync with head
 1.69.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.69.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.71.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.73.10.1 28-Nov-2012  matt Add LCSR definitions and NVM storage subclass.
 1.73.8.1 05-Aug-2013  martin Pullup

sys/dev/pci/pcireg.h 1.74-1.82 and 1.84 via patch
sys/dev/pci/pci_subr.c 1.92-1.102, 1.104-1.105 via patch

Add some PCI(e) register and bit definitions in pcireg.h.
Fix the definition of PCI_PCIE_SLCAP_PSN.
Fix a bug that IRQ(MSI) bits in PCIe capability register is incorrectly
decoded.
Print more registers in "pcictl dump".
Fix bug in comment.

Requested by msaitoh in ticket #928
 1.73.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.73.2.1 30-Oct-2012  yamt sync with head
 1.74.2.4 03-Dec-2017  jdolecek update from HEAD
 1.74.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.74.2.2 23-Jun-2013  tls resync from head
 1.74.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.84.4.1 18-May-2014  rmind sync with head
 1.85.2.1 10-Aug-2014  tls Rebase.
 1.95.2.4 11-Aug-2018  martin Pull up the following, requested by msaitoh in ticket #1628:

share/man/man4/wm.4 1.40 via patch
sys/dev/mii/ihphyreg.h 1.2
sys/dev/mii/inbmphyreg.h 1.10
sys/dev/pci/if_wm.c 1.504, 1.506, 1.510-1.535, 1.539-1.540, 1.546, 1.548, 1.551-1.552, 1.558, 1.565-1.573, 1.575, 1.579, 1.582, 1.584 via patch
sys/dev/pci/if_wmreg.h 1.99-1.103, 1.106-1.107 via patch
sys/dev/pci/if_wmvar.h 1.34-1.39 via patch
sys/dev/pci/pcidevs 1.1327 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
sys/dev/pci/pcireg.h patch

Sync wm(4) up to 2018/08/08 except MSI/MSI-X and NET_MPSAFE:
- remove extra "+"
- Fix a bug that non-GMII devices don't send a routing message when
the link status is changed.
- Set WMREG_KABGTXD not in wm_init_locked() but in wm_reset(). Same as
other OSes.
- If a interrupt is a spurious interrupt, don't print debug message.
- Don't print the Image Unique ID if an NVM is iNVM (i210 and I211).
- Print sc_flags with snprintb().
- Fix a bug that a RAL was written at incorrect address when the index
number is more than 16 on 82544 and newer.
- The layout of RAL on PCH* are different from others. Fix it.
- Flush every MTA write. Same as Linux.
- Move the location of calling wm_set_filter. Same as some other OSes.
- Add CSR_WRITE_FLUSH() after writing WMREG_CTRL in
wm_gmii_mediachange().
- Add missing "else" in wm_nvm_release().
- Make new wm_phy_post_reset() and use this function at all location
after resetting phy.
- Move the location of calling wm_get_hw_control. Same as Linux.
- Add I219 specific wokaround for legacy interrupt. From OpenBSD.
- Move the location of calling wm_lplu_d0_disable().
- Fix latency calculation in wm_platform_pm_pch_lpt().
- Set OBFF water mark and enable OBFF on PCH_LPT and newer.
- Disable D0 LPLU on 8257[12356], 82580, I350 and I21[01], too. Before
this commit, above devices and non-PCIe devices accessed wrong
register.
- Use device_printf() instead of aprint_error_dev() for PHY read/write
functions because those are used not only in device attach.
- Fix a bug that wm_gmii_i82544_{read,write}reg() didn't take care of
page select. PHY access from igphy() automatically did it, but
accessing from wm(4) for wrokaround didn't work correctly. This
change affects 8254[17], 8257[12] ICH8, ICH9 and ICH10.
- Call wm_kmrn_lock_loss_workaround_ich8lan() before any PHY access in
wm_linkintr_gmii().
- Register access in wm_kmrn_lock_loss_workaround_ich8lan() now works
correctly. Enable this function.
- Configure the LCD with the extended configuration region in NVM if
it's required.
- If TX is not required to flush, RX is also not required to flush
in wm_flush_desc_rings(). Same as other OSes.
- Remove wrong semaphore access in wm_nvm_{read,write}_{ich8,spt} to
prevent hangup. A semaphore is get/put in wm_nvm_{read,write}.
- Move some initialization stuff in wm_attach() before wm_reset(). Some
flags and callback function are required to set correctly before
wm_reset() because wm_reset() and some helper functions refer them.
- Add wm_write_smbus_addr() to set SMBus address by software.
- Modify wm_gmii_hv_{read,write}reg_locked() to make them access
HV_SMB_ADDR correctly.
- Use new nvm.{acquire,release}() for semaphore.
- Our MII readreg/writereg API has not way to detect an error.
kmrn_{read,write}reg() are not used for MII API, so it's not required
for these functions to use the same API. So,
- Change return value as error code.
- Change register value from int to uint16_t.
- read: pass pointer for uint16_t as an argument.
- Check return value on caller side.
- Check whether it's required to use MDIC workaround for 80003 or not
in wm_reset(). If the workaround isn't required, don't use the
workaround code in wm_gmii_i80003_{read,write}reg.
- Add WM_F_WA_I210_CLSEM flag for a workaround. FreeBSD/Linux drivers
say "In rare circumstances, the SW semaphore may already be held
unintentionally on I21[01]". PXE boot is one of the case.
- Qemu's e1000e emulation (82574L)'s SPI has only 64 words. I've never
seen on real 82574 hardware with such small SPI ROM. Check
sc->sc_nvm_wordsize before accessing higher address words to prevent
timeout.
- Check some wm_nvm_read()'s return vale.
- Print NVM offset and word count when EERD polling failed.
- On I219, drop TARC0 bit 28 for DMA hang workaround (from Linux).
- 82583 supports jumbo frame. Fixes PR#52773 reported by
Shinichi Doyashiki.
- Fix typo in comment. Reported by Shinichi Doyashiki in PR#52885.
- Add ASPM workaround for 8257[1234] and 82583 to prevent device
timeout or hangup. Fixes PR#52818 reported by Shinichi Doyashiki.
- CID-1427779: Fix uninitialized variables.
- Fix a bug that wm_pll_workaround_i210() is not called when
a) Chip is I211 or b) Chip is I210 and it uses iNVM (not FLASH).
- Do wm_reset_mdicnfg_82580() on 82580 only.
- Fix FLASH access on PCH_SPT and newer. Their FLASH access should be
done by 32bit. Especially for ICH_FLASH_HSFCTL register, it's located
at 0x0006, so it must be accessed via ICH_FLASH_HSFSTS(0x0004) and
use shift or mask.
- Make wm_nvm_valid_bank_detect_ich8lan() the same as other OSes.
- If the extended configuration size in the EXTCNFSIZE register is 0,
don't continue in wm_init_lcd_from_nvm().
- Add PCH_CNP support (I219 with Intel 300 series chipset).
- Enable I219 support.
- I354 uses an external PHY, so don't use wm_set_eee_i350().
- Fix a bug that the link can't detect in link interrupt function for
non-SERDES fiber.
- Fix a bug that 82542 misunderstand fiber's signal detection.
- Add debug printf()s.
- Update comment.
- Rename functions and variables.
- Add diagnostic code.
- Sort registers.
- Lowercase hexadecimal values.
- KNF.
 1.95.2.3 14-Dec-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #325):
sys/dev/pci/pcireg.h: revision 1.100
sys/dev/pci/pci_subr.c: revision 1.133
Add PCIe CRS Software Visibility bit.
 1.95.2.2 12-Dec-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #312):
sys/dev/pci/pci_subr.c: revision 1.130
sys/dev/pci/pci_subr.c: revision 1.131
sys/dev/pci/pci_subr.c: revision 1.132
sys/dev/pci/pcireg.h: revision 1.97
sys/dev/pci/pcireg.h: revision 1.98
sys/dev/pci/pcireg.h: revision 1.99
sys/dev/pci/pci_subr.c: revision 1.127
sys/dev/pci/pci_subr.c: revision 1.128
sys/dev/pci/pci_subr.c: revision 1.129
Always print the Slot implemented bit in the PCIe Capabilities
Register using with onoff().
- Add some PCI subclass and interfaces.
- The interface of PCI_SUBCLASS_BRIDGE_RACEWAY is not decoded yet.
- Fix typo in a message.
- Add comment.
- Modify comment.
s/genric/generic/
Add comment.
Fix typo in comment.
Fix a bug that the specification revision of the Power Management function
was incorrectly printed in the output of capability "list".
The value is also printed in the detail output and it has no bug.
- Cleanup pci_conf_print_caplist. Use table. The reason why it loops twice
is that some capabilities appear multiple times (e.g. HyperTransport cap).
- Print the specification revision of Power Management and AGP not in
the capability list part but in the detail part.
Add some HyperTransport related defines. It's required for the MSI.
 1.95.2.1 12-Dec-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #311):
sys/dev/pci/ppb.c: revision 1.53
sys/dev/pci/ppb.c: revision 1.54
sys/dev/pci/pcireg.h: revision 1.96
- Modify message of PCIe capability version. This field (PCIE_XCAP_VER_MASK)
is not specification's version number but the capability structure's version
number. To avoid confusion, print "PCI Express capability version x".
- The max number of PCIe lane is not 16 but 32. Fix the bug using with macro.
- Use macro instead of magic number.
- Gb/s -> GT/s
Rename PCIE_XCAP_VER_* macros to avoid confusion.
 1.100.2.9 28-Aug-2017  skrll Sync with HEAD
 1.100.2.8 05-Feb-2017  skrll Sync with HEAD
 1.100.2.7 05-Dec-2016  skrll Sync with HEAD
 1.100.2.6 05-Oct-2016  skrll Sync with HEAD
 1.100.2.5 29-May-2016  skrll Sync with HEAD
 1.100.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.100.2.3 22-Sep-2015  skrll Sync with HEAD
 1.100.2.2 06-Jun-2015  skrll Sync with HEAD
 1.100.2.1 06-Apr-2015  skrll Sync with HEAD
 1.113.2.4 26-Apr-2017  pgoyette Sync with HEAD
 1.113.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.113.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.113.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.119.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.130.2.11 29-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1728:

sys/dev/pci/pci_subr.c 1.232-1.239 via patch
sys/dev/pci/pcireg.h 1.62-1.63

- Decode link control2's Compliance Preset/De-emphasis more.
- Decode Physical Layer 16.0 GT/s extended capability.
- Decode Lane Margining at the Receiver extended capability.
- Print "reserved" instead of "unknown" when printing equalization
preset. One of them is known to be the default value.
- Fix typo.
 1.130.2.10 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1714:

sys/dev/pci/pcireg.h 1.148-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.217-1.222, 1.224, 1.227-1.232
via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158
sys/dev/pci/ppb.c 1.74

- Print Bridge Config Retry Enable bit and Retimer Presence Detect
Supported bit.
- Add PCIe 4.0 stuff a little:
- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.
- Change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack.
- Print some DPC register values not with %04x but with %08x because
those are 32bit.
- Fix a bug that the virtual channel extended configuration's
arbitration phase register can't be decoded correctly.
- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Remove unused shift and mask definitions.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.130.2.9 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1388:

sys/dev/pci/pcireg.h 1.147 via patch
sys/dev/pci/pci_subr.c 1.212, 1.215-1.217 via patch

- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard
Timer Status and Discard Timer SERR# Enable bit in pci_subr.c.
- Print some DPC register values not with %04x but with %08x because
those are 32bit.
- Remove whitespace for consistency.
- Use macro.
- Whitespace fixes.
 1.130.2.8 04-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1118):

sys/dev/pci/pci_subr.c: revision 1.210
sys/dev/pci/pci_subr.c: revision 1.207
sys/dev/pci/pcireg.h: revision 1.143
sys/dev/pci/pci_subr.c: revision 1.208
sys/dev/pci/pcireg.h: revision 1.144
sys/dev/pci/pci_subr.c: revision 1.209
sys/dev/pci/pcireg.h: revision 1.145
sys/dev/pci/pcireg.h: revision 1.146

Decode PCI Enhanced Allocation.

The register offset of the mask and pending register is depend on the 64bit
address capable bit, so fix the definition of PCI MSI vector mask and pending
register. This problem was not a real bug because PCI_MSI{MASK,PENDING} were
not used from anywhere.

The downstream port of PCIe switch is not a root port, so don't print
root port related register. For example, Intel 63xxESB controller's
downstream port device was printed by pcictl(8) with this bug:
 1.130.2.7 30-Oct-2018  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1074):
sys/dev/pci/pci_subr.c: revision 1.204-1.206
sys/dev/pci/pcireg.h: revision 1.141-1.142

Root Complex Event Collector Bus Number Association ECN.
- If capability version is 2 (or greater), decode RCEC Associated Bus Numbers
register.
- Don't print TPH requester's ST Table Size if the ST table location field
is not PCI_TPH_REQ_STTBLLOC_TPHREQ because the size field is only applicable
for PCI_TPH_REQ_STTBLLOC_TPHREQ case.
- Add comment.
 1.130.2.6 23-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1028):

sys/dev/pci/pci_subr.c: revision 1.203
sys/dev/pci/pcireg.h: revision 1.140

Add ATS Relaxed Ordering supported bit described in Address Translation
Relaxed Ordering ECN.
 1.130.2.5 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #933):
sys/dev/pci/pci_subr.c: revision 1.202
sys/dev/pci/pcireg.h: revision 1.139
sys/dev/pci/ppbreg.h: revision 1.9
VGA 16 bit decode bit is not bit 3 but bit 4.
--
- Print Power Management Control/status register in 32bit.
- Simplify.
 1.130.2.4 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #930):
sys/dev/pci/pci_subr.c: revision 1.201
sys/dev/pci/pcireg.h: revision 1.138
Fix typo. s/TPL/TLP/
 1.130.2.3 26-Feb-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #576):
sys/dev/pci/pci_subr.c: 1.197-1.200
sys/dev/pci/pcireg.h: 1.136-1.137
sys/dev/pci/ppbreg.h: 1.8
Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.
NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.
"s/above 300W/greater than 300W/" in pci_conf_print_pcie_power(). From
PCIe Base Spec 3.1a Errata 2017-12-13.
Cleanup:
- Don't pass a capability pointer as a argument of pci_conf_find_cap() and
determine the first pointer in the pci_conf_find_cap() function.
- Don't pass a capability pointer as a argument of pci_conf_find_extcap()
because it's not used.
- Remove unsed code.
- Add PCie Link Activation ECN.
- Use macro.
- KNF.
 1.130.2.2 21-Nov-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #362):
sys/dev/pci/pcireg.h: revision 1.133
sys/dev/pci/pcireg.h: revision 1.134
sys/dev/pci/pcireg.h: revision 1.135
sys/dev/pci/pci_subr.c: revision 1.190
sys/dev/pci/pci_subr.c: revision 1.191
sys/dev/pci/pci_subr.c: revision 1.192
sys/dev/pci/pci_subr.c: revision 1.193
sys/dev/pci/pci_subr.c: revision 1.194
sys/dev/pci/pcireg.h: revision 1.132
- Official shortname of LN Requester is LNR, so change PCI_EXTCAP_LN_REQ
to PCI_EXTCAP_LNR
- Use macro.
- Add PCI_MAPREG_ROM_ADDR_MASK macro and PCI_MAPREG_ROM_ADDR() macro.
- print PCI_MAPREG_ROM_ENABLE bit.
- Decode Expansion ROM Validation ECN.
- Add Native PCIe Enclosure Management ECN's extended capability type.
Not decoded yet.
Decode IOMMU capability of PCI secure device capability. From "AMD I/O
Virtualization Technology(IOMMU) Specification (#48882) Revision 3.00".
IOMMU cap dump fixes:
- Print Capability Register's value.
- Indent output correctly.
- s/cahced/cached/
- Print MSI Message number with 0x%02x
Fix a bug that the TPH ST table is decoded even if it's not in the TPH
Requester extended capability structure.
 1.130.2.1 04-Jul-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #80):
sys/dev/pci/pci_subr.c: revision 1.184
sys/dev/pci/pci_subr.c: revision 1.185
sys/dev/pci/pci_subr.c: revision 1.186
sys/dev/pci/pci_subr.c: revision 1.187
sys/dev/pci/pci_subr.c: revision 1.188
sys/dev/pci/pci_subr.c: revision 1.189
sys/dev/pci/pcireg.h: revision 1.131
Add missing return to print the Slot Power Limit Value correctly.
Fix to print the following bit fields correctly.
- Supported Link Speeds Vector in LCAP2
- Lower SKP OS Generation Supported Speed Vector in LCAP2
- Lower SKP OS Reception Supported Speed Vector in LCAP2
- Enable Lower SKP OS Generation Vector in LCTL3
Note that the above bitfields start from 0 and the follwing bitfields start
from 1:
- Maximum Link Speed in LCAP
- Current Link Speed in LCSR
- Target Link Speed in LCSR2
For the Target Link Speed in LCSR2, 0 is allowed for a device which supports
2.5GT/s only (and this check also works for devices which compliant to
versions of the base specification prior to 3.0.
Tested with BCM5709:
- Target Link Speed: unknown value (0)
+ Target Link Speed: 2.5GT/s
For Attention Indicator Control bit and Power Indicator Control bit, it's
allowed to be a read only value 0 if corresponding capability register bit
is 0.
Fix a bug that LTR's latency in L1 PM Substates capability and Latency
Tolerance Reporting capability isn't printed correctly.
Fix printf format/argument.
 1.137.2.6 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.137.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.137.2.4 20-Oct-2018  pgoyette Sync with head
 1.137.2.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.137.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.137.2.1 21-May-2018  pgoyette Sync with HEAD
 1.138.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.138.2.1 10-Jun-2019  christos Sync with HEAD
 1.147.4.4 29-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1412:

sys/dev/pci/pci_subr.c 1.232-1.239 via patch
sys/dev/pci/pcireg.h 1.62-1.63

- Decode link control2's Compliance Preset/De-emphasis more.
- Decode Physical Layer 16.0 GT/s extended capability.
- Decode Lane Margining at the Receiver extended capability.
- Print "reserved" instead of "unknown" when printing equalization
preset. One of them is known to be the default value.
- Fix typo.
 1.147.4.3 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1384:

sys/dev/pci/pcireg.h 1.152-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.222, 1.227-1.232 via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158, 1.163
sys/dev/pci/ppb.c 1.74

- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.147.4.2 19-Mar-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #782):

sys/dev/pci/pcireg.h: revision 1.150
sys/dev/pci/pcireg.h: revision 1.151
sys/dev/pci/pci_subr.c: revision 1.220
sys/dev/pci/pci_subr.c: revision 1.221
sys/dev/pci/pcireg.h: revision 1.149

- Print Bridge Config Retry Enable bit and Retimer Presence Detect Supported
bit.
- Avoid using magic number.

Add PCIe 4.0 stuff a little:
- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.

Remove unused shift and mask definitions.

Add comment.
 1.147.4.1 21-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #629:

sys/dev/pci/pcireg.h 1.148
sys/dev/pci/pci_subr.c 1.218-1.219

- Fix a bug that the virtual channel extended configuration's
arbitration phase register can't be decoded correctly.
- Fix typo.
 1.148.2.2 29-Feb-2020  ad Sync with head.
 1.148.2.1 25-Jan-2020  ad Sync with head.
 1.151.6.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.153.6.1 31-May-2021  cjep sync with head
 1.153.4.2 01-Aug-2021  thorpej Sync with HEAD.
 1.153.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.168.2.1 22-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #723):

sys/dev/pci/pcireg.h: revision 1.171

PCI_CLASS_MASK: Use unsigned to avoid undefined behavior. Found by kUBSan.
 1.171.2.1 02-Aug-2025  perseant Sync with HEAD
 1.120 23-Jun-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).

This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.

Take 2: Make sure to handle NULL match function.
 1.119 20-May-2024  riastradh Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.
 1.118 20-May-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
 1.117 27-Feb-2022  riastradh branches: 1.117.4;
pci(9): Provide default definition of pci_get_segment, always zero.

pci_machdep.h can define __HAVE_PCI_GET_SEGMENT to provide a nonzero
definition.
 1.116 15-Sep-2021  thorpej Adjust the device_call() calling convention so as to provide type checking
of the arguments passed to the call, using auto-generated argument
structures and binding macros.
 1.115 12-May-2021  thorpej - Define a device call for PCI bus instances to fetch a direct child's
device handle given the device's device/function #s (extracted from
a pcitag_t). Use it to associate the handle with the child device
at config_found() time.
- Implement this device call for ACPI and OpenFirmware.
- Enable the OpenFirmware variant for evbarm FDT, macppc, ofppc, sparc64.
- Obsolete acpi_device_register(); it is no longer needed.
- Obsolete setting the OpenFirmware handle in PCI devices in the
sparc64 device_register(); it is no longer needed.
 1.114 27-Jan-2021  thorpej branches: 1.114.4; 1.114.6;
Introduce autoconfiguration helpers based around device_compatible_entry:
- pci_compatible_match(): matches against the PCI ID.
- pci_compatible_match_subsys(): matches against PCI SUBSYS ID.
- pci_compatible_lookup(): look up entry by PCI ID.
- pci_compatible_lookup_subsys(): look up entry by PCI SUBSYS ID.
- pci_compatible_lookup_id(): look up entry by an arbitrary ID using the
PCI ID code conventions.

- Define PCI_COMPAT_EOL as a compat data array sentinel.
 1.113 01-Dec-2018  msaitoh branches: 1.113.12;
Save control registers in PCI-X, PCIe, MSI and MSI-X capability area when
suspend and restore them when resume. For PCIe cababilities register, it's
required to check the existence of each register to not to write the next area.

This chagnge fixes a stability of suspend/resume.
 1.112 19-May-2018  jakllsch branches: 1.112.2;
Refine previous change to enable PCI window decoding in Command
Register upon mapping; conditionalize on a global variable, that is set
to true on x86 machines booting under EFI.

For now, initialize the global variable at compile time to false. This
is intended to limit potential problems for other NetBSD ports, should
this changeset be pulled up to netbsd-8.

Related to PR #53286.
 1.111 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.110 28-Feb-2018  msaitoh branches: 1.110.2;
- Add new PCI quirk PCI_QUIRK_HASEXTCNF and PCI_QUIRK_NOEXTCNF. Some devices'
extended configuration area may be broken or violate spec. If an extended
configuration space is strange but it really exist, use PCI_QUIRK_HASEXTCNF.
If an extended configuration space is plausible to exist but it really
doesn't exist, use PCI_QUIRK_NOEXTCNF.
- Add PCI_PRODUCT_INTEL_XEOND_MEM_0_TTR_1(0x6fa8) and
PCI_PRODUCT_INTEL_COREI76K_IMC_0(0x6f68) with PCI_QUIRK_HASEXTCNF. The
document clearly states they violate spec and it support the extended
configuration space.
 1.109 25-Nov-2016  knakahara branches: 1.109.8;
provide all PCI MSI/MSI-X manipulation stub functions.

"#ifdef __HAVE_PCI_MSI_MSIX" workaround such as nvme_pci(4) is not required
any more.
http://mail-index.netbsd.org/source-changes/2016/09/17/msg077799.html
 1.108 11-Jul-2016  knakahara branches: 1.108.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.107 30-Oct-2015  msaitoh - Move PCI_INTRSTR_LEN from pcireg.h to pcivar.h.
- In PCI-X cap, print 2nd bus's PCI-X mode, error protection type, Max clock
frequency and Max clock period.
- In SATA cap, print register location correctly.
- In Virtual Channel cap, print reference clock with "ns".
- In Root Complex Link Declaration, print Link Entry number.
 1.106 22-Oct-2015  knakahara add pci_intr_alloc related stubs to reduce ifdef from device drivers.
 1.105 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.104 17-Aug-2015  knakahara Add kernel code to support intrctl(8).
 1.103 13-Aug-2015  msaitoh - Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
 1.102 27-Apr-2015  knakahara add x86 MD MSI/MSI-X support code.
 1.101 26-Dec-2014  msaitoh Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fix ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.100 16-Oct-2014  riastradh branches: 1.100.2;
Generalize pci_find_rom and use it to locate x86 video ROM in drm2.

- Make pci_find_rom take the ROM `BAR' size as a parameter, instead
of using pci_find_mem with the ROM `BAR' to detect the size.

- Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2,
when nothing else reports that location.

- Adapt the one other caller in radeonfb, which already has the
maximum ROM size handy (romsz).

XXX pullup to netbsd-7
 1.99 29-Mar-2014  christos branches: 1.99.4;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.98 29-Jan-2012  drochner branches: 1.98.2; 1.98.6; 1.98.10;
extend the pci_aprint_devinfo slightly to cover the cases commonly
used by drivers: a short name for the quiet/naive case and a string
to override the "pcidevs" based name by one provided by the driver,
ride on yesterday's kernel minor version bump
 1.97 26-Jan-2012  drochner put printing of the pci_devinfo into its own function (not inlined
by purpose) - this is a stack hog, and with this change my uTCA amd64
system boots again
a lot of similar code can be eliminated from pci device drivers this way,
but before doing so (and making the new function part of the module API)
I'd like to consider a modification to make it work with drivers which
prefer to print names from other sources (like pciide)
 1.96 21-Oct-2011  dyoung branches: 1.96.2; 1.96.6;
Tell a pci(4) instance its subordinate PCI buses using a new member
in the pcibus_attach_args, pba_sub. pciN attaches to pba_bus itself.
If pba_bus < pba_sub, then [pba_bus + 1, pba_sub] are subordinate to
pba_bus.

On i386, make mainbus0 attach pci0 with pba_sub = 255 because all buses
1 and up must be subordinate to pci0.

XXX Deal with other architectures.
 1.95 24-Aug-2011  dyoung Add to pci_bus_devorder() an argument that tells the number of slots
available in the devs array. Change the type of the devs array from
char to uint8_t. Treat the return value of pci_bus_devorder() as the
number of slots that it filled.

Don't use the __PCI_BUS_DEVORDER #definition to configure the kernel
but let the linker do it. Make pci_bus_devorder() available on all
architectures by adding a default implementation that will DTRT on
all architectures but hpcmips, the only architecture to #define
__PCI_BUS_DEVORDER. On hpcmips, adapt the implementation to the new
calling convention.

XXX I can compile an hpcmips GENERIC kernel, but I don't have a
XXX hpcmips box to test it on.
 1.94 22-Jun-2011  matt Add inline accessors for pba_pc and pa_pc so that <machine/pci_machdep.h>
can use them in inline functions.
 1.93 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.92 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.91 10-Feb-2011  jmcneill pcimmap: if the requested page is marked prefetchable in a child device's
BAR, pass the BUS_SPACE_MAP_PREFETCHABLE flag down to bus_space_mmap
 1.90 09-Jun-2010  mrg branches: 1.90.2; 1.90.4;
declare 'struct pci_attach_args' before it is used. fixes ia64 build.
 1.89 27-May-2010  pgoyette Extract pci_verbose interface definitions into their own header file so
we don't need to include pcivar.h in the module. pcivar.h tries to pull
in machine/pci_machdep.h which doesn't exist on all machine/architecture
combos. Keeping track and building the module only for those that work
would have been a maintenance headache; this change allows us to build
the module on all systems, regardless of whether the system has pci
support or not.
 1.88 25-May-2010  pgoyette Rework the pciverbose module dispatch vectors to avoid renaming the
externally-visible entrypoint name. Also this avoids a potential
need to bump kernel version.

Requested by dyoung@ and mrg@
 1.87 24-May-2010  pgoyette Extract the vendor/product tables and related access routines into a
separate kernel module. Update pci bus attach routine to load the
module (if available) when we're about to start scanning the bus, and
unload the module after the scan is finished.

On architectures which support loading of modules by the boot loader,
the 'pciverbose' module can be loaded and executed without needing to
rebuild the kernel. On all architectures, using 'options PCIVERBOSE'
in the kernel configuration file will create a 'builtin' module which
is functionally equivalent to previous behavior.

XXX Although not nearly as large as the vendor and product tables,
XXX the PCI class and subclass tables might also be offloaded into
XXX the module at a future time.

XXX Cardbus (and possibly other) drivers should also be modified to
XXX load the module before scanning/attaching devices.
 1.86 28-Apr-2010  dyoung Add data types, function prototypes, and stub implementations
for pci_chipset_tag_create() and pci_chipset_tag_destroy(). On
architectures that support it, an MI PCI bus driver can override the
architecture's default pci(9) and pci_intr(9) implementation.

Coming up next: documentation.
After that: x86 implementation.
Last but not least: make cbb(4) use MI PCI overrides.
 1.85 12-Mar-2010  matt branches: 1.85.2;
Add placeholdr flags indicating that the bus has MSI/MSI-X support.
 1.84 23-Feb-2010  dyoung Remove unused functions pci_disable_retry() and cardbus_disable_retry().
 1.83 22-Jul-2008  bjs branches: 1.83.12; 1.83.14; 1.83.18;
Add pci_mapreg_submap(): This function is pci_mapreg_map() with two
additional arguments, offset and maxsize. This new functionality
eases handling certain tasks within the direct rendering manager, though
I hope others will also find it useful.

pci_mapreg_map() is now merely a wrapper around pci_mapreg_submap();
the latter contains all of the code from the former.

ok christos@
 1.82 30-May-2008  ad branches: 1.82.2; 1.82.4;
pci_intr_setattr(), allows PCI interrupts to be marked MPSAFE on x86, and
other platforms if the code is added.

pci_intr_map(...)
pci_intr_setattr(pc, ih, PCI_INTR_MPSAFE, 1);
pci_intr_establish(...)
 1.81 05-May-2008  dyoung branches: 1.81.2;
Restore PCI devices to a state that is closer to the state that
NetBSD finds them in: save and restore power management state
(D0..D3) and PCI Configuration Registers 0x0 through 0x40 during
device attachment and detachment, respectively. Among other things,
this will fix sip(4) detachment and re-attachment.
 1.80 09-Apr-2008  dyoung branches: 1.80.2; 1.80.4;
Export some PCI autoconf routines for use by elansc(4), for example.
 1.79 23-Mar-2008  cube Split device_t and softc for pci(4).
 1.78 21-Mar-2008  dyoung pci_activate() expects for its void * argument to be a device_t,
so change the type of the argument to device_t. Update each use
of pci_activate().

Use device_t and accessors. Use aprint_*_dev().
 1.77 09-Dec-2007  jmcneill branches: 1.77.6; 1.77.10;
Merge jmcneill-pm branch.
 1.76 12-Nov-2007  joerg branches: 1.76.2; 1.76.4;
Merge pci_disable_retry function from jmcneill-pm as it is found in
various drivers.
 1.75 19-Oct-2007  ad branches: 1.75.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.74 04-Mar-2007  christos branches: 1.74.2; 1.74.14; 1.74.16; 1.74.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.73 25-Sep-2006  jmcneill branches: 1.73.4;
Create a PCI bus powerhook to handle setting PCI D# power state transitions
on suspend/standby/resume.
 1.72 17-Jun-2006  christos branches: 1.72.4; 1.72.6;
re-factor the pci powestate api. reviewed by gimpy
 1.71 01-Mar-2006  gdamore branches: 1.71.2; 1.71.8; 1.71.10;
Add pci_find_rom() API as discussed on tech-kern.
 1.70 11-Dec-2005  christos branches: 1.70.4; 1.70.6;
merge ktrace-lwp.
 1.69 04-Feb-2005  perry branches: 1.69.6;
de-__P
 1.68 26-Jan-2005  jmcneill Add support functions for capturing and restoring PCI configuration
registers for power management code.
 1.67 13-Sep-2004  drochner branches: 1.67.4; 1.67.6;
remove macros which just hide cfdata internals
(and are used at one place only)
 1.66 30-Aug-2004  drochner Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.65 30-Aug-2004  drochner add centralized {eisa,isa,pci,agp,mca}busprint() functions which do
what tens of the bus' parents foo{...}bridge_print()s scattered around do
 1.64 17-Aug-2004  drochner make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)
 1.63 02-Aug-2004  mycroft For the PCIVERBOSE case, separate vendors and products into separate tables.
Eliminating redundant pointers in the tables saves nearly 20K (20% of the table
size). In the process, add a pci_findproduct() and make that and
pci_findvendor() return a "const char *".
 1.62 29-Jul-2004  drochner make the "generic" PCI bus enumeration code the standard case which
gets used if nothing else is defined in MD headers,
introduce a "PCI_MACHDEP_ENUMERATE_BUS" CPP definition which can
be used by MD headers (just 1 port atm) to plug in special code
 1.61 08-May-2004  christos GC pci_{g,s}et_powerstate into pci_powerstate(). Idea from mycroft and gimpy.
Nothing uses them yet.
 1.60 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.59 15-Aug-2003  itojun - check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.58 29-Jun-2003  fvdl branches: 1.58.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.57 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.56 15-Jun-2003  fvdl Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.55 25-Mar-2003  thorpej Add PCI VPD access routines. From psi.cz!freza, PR kern/20889.
 1.54 19-Mar-2003  christos It is not appropriate for pcivar.h to include "locators.h"
The two files that need it, should include it themselves.
 1.53 18-Jun-2002  tshiozak add support for the per-device power management capability.

int pci_set_powerstate(pci_chipset_tag_t pc, pcitag_t tag, int newstate)
set power state of the device to newstate.
int pci_get_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
get current power state of the device.

In the future, these functions will be used for ACPI support.
 1.52 30-May-2002  drochner implement a check whether a BAR is present at all at a given configuration
space address and use it where the mappings of the VGA card are registered
before descenting too deep into "memory" type specific code
(pci_mem_find() gets noisy if it doesn't like the register)
 1.51 18-May-2002  sommerfeld branches: 1.51.2;
Add "pa_rawintrpin" containing unswizzled interrupt pin to pci_attach_args.
 1.50 16-May-2002  thorpej branches: 1.50.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.49 15-May-2002  thorpej Split the code that enumerates the PCI bus and that actually probes
for a device into two functions:

* pci_probe_device() actually probes/attaches the device specified
by the provide pcitag_t.

* pci_enumerate_bus() enumerates the bus, and calls pci_probe_device()
for each device on the bus. A pci_enumerate_bus_generic() is provided
which implements the old method of doing this: If something found at
dev0/func0, determine number of functions and probe each one.

Machine-dependent code will be able to specify the bus enumeration
routine in the future.
 1.48 13-Sep-2001  thorpej Add an ioctl interface to the PCI bus. Add ioctls to read/write
PCI configuration space registers, and to fetch bus info.
 1.47 10-Sep-2001  fvdl Add a pci_find_device function, to find a PCI device using a match
function on all (probed) PCI buses:

int pci_find_device(struct pci_attach_args *pa,
int (*match)(struct pci_attach_args *));

The pci_attach_args structure pointed to by pa is filled in if the
device is found, and 1 is returned. Otherwise 0 is returned.

This function is, unfortunately, needed by the i810 agp code. It's
also of use for LKMs.

Also frob pci_probe_bus to take 2 extra args when used by pci_find_device.
 1.46 04-May-2001  bouyer branches: 1.46.2; 1.46.4;
Add pci bus number to pci_attach_args, as suggested by Jason on tech-kern
(needed for pciide)
 1.45 05-Mar-2001  matt Only include "locators.h" is _KERNEL is defined.
 1.44 12-Feb-2001  mrg branches: 1.44.2;
backout the parts of the previous change (7 months ago) that were *not* part
of the sys/vm removal, but some (fortunately disabled) work-in-progress.
 1.43 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.42 10-May-2000  thorpej branches: 1.42.4;
Add support for mapping 64-bit PCI memory space. If the region
is mapped in a way that is inaccessible by a 32-bit bus_addr_t, then
print a message to that effect and return failure.

Original patches by Bill Studenmund, with a few small changes by me.
 1.41 30-Sep-1999  thorpej branches: 1.41.2;
Define flags in pci_attach_args which indicate it's okay to use the
Memory Read Line, Memory Read Multiple, and Memory Write and Invalidate
PCI commands.
 1.40 06-May-1999  thorpej Back out previous. Thanks to cgd for pointing out another way to do this.
 1.39 06-May-1999  thorpej Add a `bus' member to the pci_attach_args. This is not normally used,
but some child drivers might need to know this information.
 1.38 19-Mar-1999  cgd branches: 1.38.4;
pull pci_machdep.h in from machine/
 1.37 07-Nov-1998  drochner add support for "extended capabilities" (new in PCI spec 2.2)
 1.36 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.35 12-Jul-1998  augustss Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers
 1.34 09-Jun-1998  thorpej Remove the PCI-ISA bridge callback mechanism; it's no longer needed.
 1.33 31-May-1998  cgd add a PCI 'quirks' mechanism, meant to be used as the mechanism
of last resort when trying to communicate information about
bogus behaviour of PCI devices to the MI autoconfiguration code.
In general, bogus behaviour should be handled by drivers, but there
are some types of bogons which can't be addressed that way. The
only quirk currently defined is one which indicates that the device
is multi-function even though the device's header says otherwise.
(Mmm, Intel 82371FB PCI-to-ISA Bridge (PIIX); you'd think that at least
Intel would have gotten it right...)
 1.32 25-May-1998  mark Include arm32/pci/pci_machdep.h if arm32 is defined.
 1.31 18-May-1998  cgd largely reimplement pci_conf_print():
* print all configuration space registers. Then, where possible,
interpret them. (That is, PRESENT ALL THE DATA, then interpret it --
don't hide data behind interpretation. Also, when interpreting
fields, try to print out the specific value that's being interpreted.)
* handle different header types.
* allow caller to specify a function which can interpret the
device-dependent header and is responsible for pretty-printing it.

It spews (use 'options MSGBUFSIZE=...' 8-), but when you want the data,
you really want _all_ of it.

Still needs some cleanup and additional code (e.g. interepretation
of PCI-PCI (type 1) and PCI-Cardbus (type 2(?)) bridge headers).
 1.30 15-May-1998  tsubai Add macppc support.
 1.29 14-Apr-1998  thorpej Add pci_conf_print(), a function to dump the PCI configuration space, useful
in driver debugging. From Zubin D. Dittia <zubin@clouseau.arl.wustl.edu>,
PR #4249.
 1.28 14-Oct-1997  sakamoto add bebox
 1.27 06-Oct-1997  thorpej Back out last change. (Partially my fault, for not reviewing it close
enough.)
 1.26 03-Oct-1997  lonhyn pci_mapreg_info() has been changed to take arguments like pci_mapreg_map()
 1.25 30-Aug-1997  mycroft Don't export pci_*_find() any more.
 1.24 17-Jul-1997  jtk branches: 1.24.2;
use "locators.h" defines for indices for cf_loc[] and default values
 1.23 06-Jun-1997  thorpej Pull thorpej-bus-dma branch into mainline.
 1.22 13-Apr-1997  cgd branches: 1.22.2;
create pci_mapreg_info() which simply gets mapping register information.
It's used by pci_mapreg_map() and can be used directly by drivers
with special needs (e.g. those being attached as console devices).
 1.21 13-Apr-1997  cgd rename pci_map_register to pci_mapreg_map. The latter name is more
descriptive, and allows for a sane name for a function which just digs
the info out of the mapping register but doesn't do the mapping.
 1.20 13-Apr-1997  cgd implement pci_map_register(), which gets information about a device's
mapping register, maps it, and returns all of the relevant information.
deprecate use of pci_{io,mem}_find(), but leave them around (for a while)
for backward compatibility with third-party drivers.
 1.19 10-Apr-1997  cgd pass memory- and i/o-enabled flags down via the PCI bus and device attach
arguments, so that a device can tell if its memory and I/O spaces are
enabled. The flags are cleared, depending on the contents of devices CSR
registers, in the machine-independent PCI bus code.
 1.18 01-Dec-1996  leo The atari has a pci_machdep.h file.
 1.17 23-Nov-1996  cgd Provide a routine so that ISA/EISA bridges can set up a callback so
that their child busses can be attached after the PCI bus
autoconfiguration for their parent bus is done.

This works because:
(1) there can be at most one ISA/EISA bridge per PCI bus, and
(2) any ISA/EISA bridges must be attached to primary PCI
busses (i.e. bus zero).

That boils down to: there can only be one of these outstanding
at a time, it is cleared when configuring PCI bus 0 before any
subdevices have been found, and it is run after all subdevices
of PCI bus 0 have been found.

This (or something like it) is needed because there are some (legacy)
PCI devices which can show up as ISA/EISA devices as well (the prime
example of which are VGA controllers). If you attach ISA from a
PCI-ISA/EISA bridge, and the bridge is seen before the video board is,
the board can show up as an ISA device, and that can (bogusly)
complicate the PCI device's attach code, or make the PCI device not be
properly attached at all.

This could be done with machine-dependent code, but as more ports
add support for PCI (and PCI-ISA/EISA bridges) more will need it.
The i386 port could (perhaps should) be converted to use it as well.
 1.16 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.15 28-Mar-1996  cgd remove inappropriate an potentially confusing comments ("unnecessary?") from
the pa_device and pa_function members of the pci_attach_args structure.
 1.14 27-Mar-1996  cgd modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.13 14-Mar-1996  cgd (1) provide #defines for cf_loc[] entries for devices that attach to
pcibus and pci.
(2) remove the #ifdef i386 from pci.c, and provide a machine-dependent
hook (pci_md_attach_hook()) to do any machine-dependent attachment
gunk, e.g. on the i386 printing out the configuration mode (if bus 0)
(3) don't pass max device number for a given bus in, use
PCI_MAX_DEVICE_NUMBER, which can be defined on a per-machine basis.
(defaults to 32. on i386, it's 32 if pci conf mode == 1, 16 if 2.)
 1.12 08-Mar-1996  cgd pass a bus_chipset_tag_t (defined in <machine/bus.h>) to the bus when
attaching, and to the devices when attaching them. #include <machine/bus.h>
to make this backward compatible with old #include requirements.
Also, clean up idempotency so that isa/eisa/pci "var.h" headers are
consistent (make them all idempotent).
 1.11 28-Feb-1996  cgd make PCI bus match/attach and sub-device attachment machine-independent.
 1.10 22-Jan-1996  cgd update PCIVERBOSE code in various ways:
(1) remove the 'UNSUPP' keyword from the device list,
because it can't be reasonably used (becuase different
devices may be supported on different machines, for
good reason).
(2) enhance pci_devinfo so that class/subclass information
is optional (so pci_devinfo can be used by drivers that
match classes of devices, and want to look up the
devices' names easily).
(3) more known vendors and devices.
 1.9 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.8 18-Jun-1995  cgd prototype for pci_devinfo function
 1.7 18-Jun-1995  cgd add include for the alpha, alphabetize
 1.6 23-May-1995  cgd split single-subdevice lookup & attachment into a subroutine
(pci_attach_subdev()). remove pciattach() function and the pcicd cfdriver
struct, the former because thre are a lot of attachment actions which really
are machine-dependent (perhaps even "most"), and the latter because now that
both pcimatch() and pciattach() are machine-dependent it's bad style to
declare them here and it gains nothing.
 1.5 17-Apr-1995  cgd clean up several ISA device interfaces: autoconfiguration, header
inclusion, and interrupt configuration. more work still needs to be done,
but it's getting better...
 1.4 27-Jan-1995  cgd include files from the correct places.
 1.3 04-Nov-1994  mycroft Make a wrapper match function to check the bus and device numbers, rather
than insisting that every driver do it.
 1.2 27-Oct-1994  cgd new RCS ID format.
 1.1 09-Aug-1994  mycroft Add PCI autoconfiguration support.
 1.22.2.1 13-May-1997  thorpej Provide the bus dma tag to children.
 1.24.2.2 15-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.24.2.1 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.38.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.41.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.41.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.42.4.1 15-May-2001  he Pull up revision 1.46 (requested by bouyer):
Add a pa_bus member to pci_attach_args, so that the PCI bus number
can be used in pci device drivers.
 1.44.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.44.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.44.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.44.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.46.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.46.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.46.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.46.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.46.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.50.2.4 15-Jul-2002  gehenna catch up with -current.
 1.50.2.3 20-Jun-2002  gehenna catch up with -current.
 1.50.2.2 30-May-2002  gehenna Catch up with -current.
 1.50.2.1 16-May-2002  gehenna file pcivar.h was added on branch gehenna-devsw on 2002-05-30 14:46:31 +0000
 1.51.2.1 15-Aug-2003  tron Pull up revision 1.59 (requested by itojun in ticket #1412):
- check HDRTYPE early, and ignore if it is not supported (n > 2).
- defer access to interrupt configuration register, as its existence depends on
HDRTYPE.
- add "skip particular funtion in multifunction device" functionality
to quirk table.
- add GEODE/NS SC1100 quirk (now boots on soekris Net4801).
 1.58.2.7 04-Feb-2005  skrll Sync with HEAD.
 1.58.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.58.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.58.2.4 03-Sep-2004  skrll Sync with HEAD
 1.58.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.58.2.2 03-Aug-2004  skrll Sync with HEAD
 1.58.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.67.6.1 12-Feb-2005  yamt sync with head.
 1.67.4.1 29-Apr-2005  kent sync with -current
 1.69.6.7 24-Mar-2008  yamt sync with head.
 1.69.6.6 21-Jan-2008  yamt sync with head
 1.69.6.5 15-Nov-2007  yamt sync with head.
 1.69.6.4 27-Oct-2007  yamt sync with head.
 1.69.6.3 03-Sep-2007  yamt sync with head.
 1.69.6.2 30-Dec-2006  yamt sync with head.
 1.69.6.1 21-Jun-2006  yamt sync with head.
 1.70.6.1 22-Apr-2006  simonb Sync with head.
 1.70.4.1 09-Sep-2006  rpaulo sync with head
 1.71.10.1 13-Jul-2006  gdamore Merge from HEAD.
 1.71.8.1 19-Jun-2006  chap Sync with head.
 1.71.2.1 26-Jun-2006  yamt sync with head.
 1.72.6.1 22-Oct-2006  yamt sync with head
 1.72.4.1 18-Nov-2006  ad Sync with head.
 1.73.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.74.20.2 13-Nov-2007  bouyer Sync with HEAD
 1.74.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.74.16.3 23-Mar-2008  matt sync with HEAD
 1.74.16.2 09-Jan-2008  matt sync with HEAD
 1.74.16.1 06-Nov-2007  matt sync with HEAD
 1.74.14.7 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.74.14.6 20-Nov-2007  joerg GC struct ifnet.
 1.74.14.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.74.14.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.74.14.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.74.14.2 23-Aug-2007  joerg Introduce pci_net_generic_power, which should be enough for most
network drivers and be a good foundation for C&P for the rest.

For iwi(4), don't reset the PCI retry register again, pci_conf_restore
should take care of that already.

For bge(4), add a NetBSD style if_stop.
 1.74.14.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.74.2.1 23-Oct-2007  ad Sync with head.
 1.75.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.75.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.76.4.1 11-Dec-2007  yamt sync with head.
 1.76.2.1 26-Dec-2007  ad Sync with head.
 1.77.10.3 28-Sep-2008  mjf Sync with HEAD.
 1.77.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.77.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.77.6.1 24-Mar-2008  keiichi sync with head.
 1.80.4.4 11-Aug-2010  yamt sync with head.
 1.80.4.3 11-Mar-2010  yamt sync with head
 1.80.4.2 04-May-2009  yamt sync with head.
 1.80.4.1 16-May-2008  yamt sync with head.
 1.80.2.2 04-Jun-2008  yamt sync with head
 1.80.2.1 18-May-2008  yamt sync with head.
 1.81.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.81.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.82.4.1 19-Oct-2008  haad Sync with HEAD.
 1.82.2.1 28-Jul-2008  simonb Sync with head.
 1.83.18.1 07-Jan-2011  matt Add/define some MSI support
 1.83.14.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.83.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.83.12.2 15-Feb-2014  matt Add a few OKAY flags from HEAD
 1.83.12.1 05-Nov-2013  matt Pull in support for pci_aprint_devinfo_fancy
 1.85.2.5 31-May-2011  rmind sync with head
 1.85.2.4 21-Apr-2011  rmind sync with head
 1.85.2.3 05-Mar-2011  rmind sync with head
 1.85.2.2 03-Jul-2010  rmind sync with head
 1.85.2.1 30-May-2010  rmind sync with head
 1.90.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.90.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.96.6.1 18-Feb-2012  mrg merge to -current.
 1.96.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.96.2.1 17-Apr-2012  yamt sync with head
 1.98.10.1 18-May-2014  rmind sync with head
 1.98.6.2 03-Dec-2017  jdolecek update from HEAD
 1.98.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.98.2.1 16-Jan-2015  snj Pull up following revision(s) (requested by msaitoh in ticket #1229):
sys/arch/x86/pci/ichlpcib.c: revision 1.40, 1.45
sys/dev/pci/pcivar.h: revision 1.101
sys/dev/pci/pci_map.c: revision 1.32
sys/dev/ic/i82801lpcreg.h: revision 1.12
Use '\n' at the end of all aprint_error_dev() format strings.
--
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fixes ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.99.4.2 08-Jan-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #394):
sys/dev/pci/pcivar.h: revision 1.101
sys/dev/pci/pci_map.c: revision 1.32
sys/dev/ic/i82801lpcreg.h: revision 1.12
sys/arch/x86/pci/ichlpcib.c: revision 1.45
Fix a bug that ichlpcib(4) maps I/O area incorrectly and then fails to attach
gpio. It might also fix ACPI related problem described in PR#48960:
- The LPCIB_PCI_PMBASE and LPCIB_PCI_GPIO register are alike PCI BAR but not
completely compatible with it. It's ok because the registers' addresses are
out of BAR0-BAR5(0x10-0x24) and are located in the device-dependent header.
The PMBASE and GPIO registers define the base address and the type but not
describe the size. The size is fixed to 128bytes. So use
pci_mapreg_submap().
- Make pci_mapreg_submap() extern again.
- Fix the calculation of the map size in pci_mapreg_submap().
 1.99.4.1 17-Oct-2014  martin Pull up following revision(s) (requested by riastradh in ticket #144):
sys/dev/pci/radeonfb.c: revision 1.85
sys/dev/pci/pcivar.h: revision 1.100
sys/dev/pci/pci_map.c: revision 1.31
sys/external/bsd/drm2/include/linux/pci.h: revision 1.9
Generalize pci_find_rom and use it to locate x86 video ROM in drm2.
- Make pci_find_rom take the ROM `BAR' size as a parameter, instead
of using pci_find_mem with the ROM `BAR' to detect the size.
- Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2,
when nothing else reports that location.
- Adapt the one other caller in radeonfb, which already has the
maximum ROM size handy (romsz).
XXX pullup to netbsd-7
 1.100.2.6 05-Dec-2016  skrll Sync with HEAD
 1.100.2.5 05-Oct-2016  skrll Sync with HEAD
 1.100.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.100.2.3 22-Sep-2015  skrll Sync with HEAD
 1.100.2.2 06-Jun-2015  skrll Sync with HEAD
 1.100.2.1 06-Apr-2015  skrll Sync with HEAD
 1.108.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.109.8.2 07-Dec-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1128):

sys/dev/pci/pcivar.h: revision 1.113
sys/dev/pci/pci.c: revision 1.153

Save control registers in PCI-X, PCIe, MSI and MSI-X capability area when
suspend and restore them when resume. For PCIe capabilities register, it's
required to check the existence of each register to not to write the next area.

This change fixes a stability of suspend/resume.
 1.109.8.1 07-Jun-2018  martin Pull up following revision(s) (requested by jakllsch in ticket #832):

sys/dev/pci/pcivar.h: revision 1.112
sys/dev/pci/pci_map.c: revision 1.34,1.35
sys/arch/x86/x86/efi.c: revision 1.15

Enable the appropriate memory or I/O space decode in the PCI
Command/Status Register upon mapping a BAR.

This should fix PR #53286. It's also possible there are other similar
PRs that might be fixed by this.
-
Refine previous change to enable PCI window decoding in Command
Register upon mapping; conditionalize on a global variable, that is set
to true on x86 machines booting under EFI.

For now, initialize the global variable at compile time to false. This
is intended to limit potential problems for other NetBSD ports, should
this changeset be pulled up to netbsd-8.

Related to PR #53286.
 1.110.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.110.2.2 21-May-2018  pgoyette Sync with HEAD
 1.110.2.1 22-Apr-2018  pgoyette Sync with HEAD
 1.112.2.1 10-Jun-2019  christos Sync with HEAD
 1.113.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.114.6.1 31-May-2021  cjep sync with head
 1.114.4.1 13-May-2021  thorpej Sync with HEAD.
 1.117.4.1 04-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #928):

sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.25
sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c: revision 1.4
sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h: revision 1.6
sys/external/bsd/drm2/dist/drm/i915/i915_drv.h: revision 1.49
sys/external/bsd/drm2/include/linux/mxm-wmi.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c: revision 1.13
sys/external/bsd/common/include/linux/bitops.h: revision 1.17
sys/external/bsd/drm2/nouveau/files.nouveau: revision 1.40
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.30
sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.12
sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_sorgm200.c: revision 1.3
sys/external/bsd/common/include/linux/printk.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_gk20a.c: revision 1.10
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c: revision 1.4
sys/external/bsd/drm2/include/linux/acpi.h: revision 1.11
sys/external/bsd/drm2/drm/drm_cdevsw.c: revision 1.31
sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h: revision 1.5
sys/external/bsd/drm2/include/acpi/video.h: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h: revision 1.4
sys/arch/sparc64/include/pci_machdep.h: revision 1.31
sys/arch/sparc64/dev/pci_machdep.c: revision 1.83
sys/external/bsd/drm2/include/linux/kref.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c: revision 1.12
sys/external/bsd/drm2/linux/linux_dma_buf.c: revision 1.17
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c: revision 1.4
sys/external/bsd/drm2/drm/drm_module.c: revision 1.32
sys/external/bsd/drm2/dist/drm/i915/i915_gem.h: revision 1.8
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c: revision 1.7
sys/external/bsd/drm2/include/linux/smp.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.20
sys/arch/x86/x86/bus_dma.c: revision 1.91
sys/external/bsd/drm2/radeon/files.radeon: revision 1.40
sys/external/bsd/drm2/include/acpi/acpi_bus.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.21
sys/external/bsd/common/include/asm/barrier.h: revision 1.20
sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h: revision 1.2
sys/external/bsd/common/include/asm/barrier.h: revision 1.21
sys/modules/drmkms/drmkms_pci.h: revision 1.1
sys/external/bsd/drm2/dist/drm/drm_dp_helper.c: revision 1.17
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.23
sys/external/bsd/drm2/linux/linux_xa.c: revision 1.4
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.23
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.25
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.26
sys/dev/pci/pcivar.h: revision 1.120
sys/arch/xen/include/pci_machdep.h: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.26
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.27
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.27
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.28
sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c: revision 1.8
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.28
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.29
sys/external/bsd/drm2/include/linux/pci.h: revision 1.57
sys/external/bsd/drm2/include/linux/pci.h: revision 1.58
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c: revision 1.6
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c: revision 1.3
sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c: revision 1.3
share/man/man9/bus_dma.9: revision 1.69
sys/external/bsd/drm2/drm/drm_gem_cma_helper.c: revision 1.15
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon.h: revision 1.12
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c: revision 1.7
sys/dev/acpi/acpi_mcfg.c: revision 1.29
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c: revision 1.7
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.13
sys/modules/amdgpu/Makefile: revision 1.9
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.14
sys/external/bsd/common/linux/linux_tasklet.c: revision 1.12
sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h: revision 1.10
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.23
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h: revision 1.9
sys/external/bsd/drm2/include/linux/interval_tree.h: revision 1.14
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.26
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c: revision 1.5
sys/dev/pci/pci.c: revision 1.168
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.27
sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c: revision 1.9
sys/external/bsd/drm2/pci/files.drmkms_pci: revision 1.18
sys/external/bsd/drm2/linux/linux_sync_file.c: revision 1.3
sys/external/bsd/drm2/amdgpu/files.amdgpu: revision 1.31
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c: revision 1.4
sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.24
sys/arch/xen/xen/xpci_xenbus.c: revision 1.29

drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html

linux asm/barrier.h: Fix !MULTIPROCESSOR build.

remove "nouveau" from a comment. noted by jmcneill.

drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
comment a function that has a clear overbounds read but it isn't used.
found by GCC 12.

nix the NetBSD specific GEM_BUG_ON().
avoids GCC 12 warnings, and matches upstream closer.
avoid uninitialised variable usage in drm_gem_cma_create_internal().
in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.
found by GCC 12.

avoid a GCC 12 warning.
there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical. as these indexes will always both
be 0, the only valid index, the condition is always false. GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.
amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
470 | stream->writeback_info[j] = stream->writeback_info[i];

convert a KASSERT() into an if () panic() sequence to appease GCC 12.
OK riastradh@.

drm: Fix conditionals around drmkms_pci and agp.
Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled. (Might not be very useful, but it'll
build. Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)

drmkms: Fix module build.
avoid an unlikely array bounds issue picked up by GCC 12.
nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.

drm: enable almost all PCIe functionality
linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.
this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed". for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus. add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)
tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].
this still does not quite work on nvidia cards. there are two problems
that remain:
- the call to set the link speed is skipped because the speed is set
to the default value of "-1". nvkm_pcie_set_link() will actually
determine the right value for this and for some cards, calling this
function if the current speed is -1 helps set the link speed. it
may be that on linux other paths we don't have enabled properly
would set this (there's one via debugfs, and a jetson specific one,
though perhaps setting either AC or DC speed values as boot options
(after hooking up these for netbsd) would currently work.
- worse, cards newer than kepler - geforce 900, 1000, and newer, are
all lacking the backing support to set pcie link speed. the GT 1030
card i have been testing with remains at pcie 1.0.

radeon: fix and enable ACPI methods for getting ROM BIOS
The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)
XXX amdgpu should get the same treatment.

drm: put_cpu() should enable preemption, not disable it again

drm(4): make pr_debug equivalent to aprint_debug
significantly reduces the default spam from amdgpu(4).

drm: Set CONFIG_ACPI in linux/acpi.h and make it build.

Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.
Should help with failures of the forms:
- unable to locate a BIOS ROM
- bios: unable to locate usable image
on various machines.

radeon_acpi.c: ifdef out unused function on NetBSD.
Should fix syzkaller build.

drm(4): Fix st_rdev in stat.
dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.
PR kern/58180

linux_sync_file: Fix missing init/fini steps.
Noted by rjs@.
PR kern/58210

ttm: Sync ttm_bo_uvm_fault_idle better with Linux.
PR xsrc/58133
ttm: Undo mistake in previous.

PR xsrc/58133
linux: Add a few more cases to pci_get_class.
Should fix crash on boot with amdgpu now that the ACPI business is
enabled.

i915: Fix dmabuf mmap object.

drm: Fix missing bounds checks in dma buf mmap.

drm_gem.c: Fix sense of assertion.
This is the opposite of WARN_ON.
Noted by rjs@.

drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.
linux_xa: Delete and replace collision in xa_store as intended.
Don't free the colliding node that's still in the tree.
Noted by rjs@.

i915_gem_mman.c: Apply mmap types via pmap flags.
This way, userland gets buffers mapped write-combining or uncached as
needed.
PR xsrc/58307

x86: Teach bus_dmamem_map about BUS_DMA_PREFETCHABLE.
PR port-amd64/58308

bus_dma(9): Document BUS_DMA_PREFETCHABLE.
Like BUS_DMA_NOCACHE. Doesn't absolve you of the need for
bus_dmamap_sync, but if you later pass the vaddr to bus_dmamap_load,
the DMA map might notice the mapping is write-combining and use this
to make bus_dmamap_sync cheaper.
PR kern/58309

nouveau_nvkm_subdev_instmem_gk20a.c: Use BUS_DMA_PREFETCHABLE.
Matches Linux's pgprot_writecombine.
Unclear where the appropriate bus_dmamap_sync happens, or is supposed
to happen -- not using it would be wrong, but asking for a
prefetchable mapping may paper over symptoms, at least!

ttm: Sync more with Linux.
Add the original copyright and attribution since this is now,
intentionally, a modified copy of the original and not just roughly
the same algorithm.

ttm: Respect PGO_ALLPAGES.
Not sure this is useful but it reduces XXX's and makes this match
udv_fault better so it's easier to understand.

ttm: Sync cacheability flag logic with Linux.

ttm: Add XXX about readahead fault failures.

pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.
New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.
This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).
This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
Take 2: Make sure to handle NULL match function.
linux_pci: Nix pci enumeration kludges.
Now that we can pass a cookie through, this stuff will be a little
less fragile.

i915: Omit needless i915_gem_object_pin/unpin_pages cycle in fault.
vm_fault_cpu and vm_fault_gtt, called by i915_gem_fault, already do
the pinning and unpinning internally, so there is no need for
i915_gem_fault to do it.
No functional change intended, except that the transient pin count
will be one lower than before during the fault routine (but it will
still be positive).

i915: Match Linux fault routine return code actions.
Omit needless EINTR interception -- this is now handled by
i915_error_to_vmf_fault.
Earlier revert was over a false alarm -- bisection shows the new
warnings arose from linux_pci.c 1.29 here:
https://mail-index.netbsd.org/source-changes/2024/06/23/msg151929.html

linux_pci: Fix shifto in pci_get_class.
It looks like Linux's pci_get_class also matches the interface part
of the PCI class register (but not the revision part), and I hadn't
noticed that in the previous shim structured differently.

With GCC12 kernel ALL/amd64 triggers "'sor' may be used uninitialized".
If "sublinks & 3" is zero GCC is right and sor[1] may be returned unitialized.
Fix by initializing "sor" to zero to return -1 instead of uninitialized value.
Ok: Taylor R Campbell <riastradh@>

amdgpu: Map BAR 2, not BAR 5, on pre-bonaire chips.
PR kern/58384

amdgpu: Map consecutive pages, not the same one over and over again.
PR kern/58385

linux/bitops: Fix overestimate for BITS_TO_LONGS(9)
Fortunately, this seems harmless except for allocating
excessive buffer memory.
Pointed out by nonaka@, OK riastradh@.
 1.50 17-May-2023  tsutsui Update URL of the technical manual.
 1.49 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.48 22-Dec-2017  tsutsui branches: 1.48.2; 1.48.4;
Update a URL of Am53c974A technical manual.
 1.47 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.46 30-Jan-2012  drochner branches: 1.46.6; 1.46.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.45 13-Nov-2010  uebayasi branches: 1.45.8; 1.45.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.44 28-Aug-2008  tsutsui branches: 1.44.16;
Restore Technical manual's URL.
 1.43 28-Apr-2008  martin branches: 1.43.2; 1.43.6;
Remove clause 3 and 4 from TNF licenses
 1.42 13-Apr-2008  tsutsui branches: 1.42.2; 1.42.4;
Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
 1.41 10-Apr-2008  cegger use aprint_*_dev and device_xname
 1.40 19-Oct-2007  ad branches: 1.40.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.39 04-Mar-2007  christos branches: 1.39.2; 1.39.14; 1.39.16; 1.39.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.38 16-Nov-2006  christos branches: 1.38.4;
__unused removal on arguments; approved by core.
 1.37 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.36 28-Apr-2006  tsutsui branches: 1.36.8; 1.36.10;
Free one more resource on attach failure.
 1.35 11-Apr-2006  tsutsui Free resources if attach fails.
 1.34 11-Dec-2005  christos branches: 1.34.4; 1.34.6; 1.34.8; 1.34.10; 1.34.12;
merge ktrace-lwp.
 1.33 28-Jun-2005  thorpej branches: 1.33.2;
Use ANSI function decls and static.
 1.32 21-Jan-2005  tsutsui Unload xfer dmamap in pscsp_dma_stop().
 1.31 02-Jan-2005  tsutsui branches: 1.31.2;
u_intNN_t -> uintNN_t
 1.30 25-Sep-2004  tsutsui Use ANSI function decls.
 1.29 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.28 23-Nov-2003  tsutsui Call bus_space_{read,write}_1() directly to access ncr53c9x common registers.
 1.27 16-Nov-2003  tsutsui Misc cleanup:
- tweak some attach messages
- establish interrupt after all dma resouces are successfully allocated
- wrap an assertion with #ifdef DIAGNOSTIC
- assume NCRCFG2_FE bit is always enabled
- call bus_dmamap_sync for mdldmap at POSTWRITE for consistency
- pass proper dmamapsize for mdldmap
 1.26 19-Oct-2003  tsutsui Utilize bus_dma(9) functions more efficiently.

pcscp(4) is the first device driver I wrote about five years ago,
but I still have to learn about bus_dma(9) implementation...
 1.25 12-Oct-2003  tsutsui - Update technical manual's URL.
- Remove __P().
- Remove trailing whitespace.
 1.24 03-May-2003  wiz branches: 1.24.2;
DMA, not dma nor Dma.
 1.23 28-Dec-2002  tsutsui sparc/tab cosmetics.
 1.22 25-Nov-2002  tsutsui - Remove code to map PCI_MAPREG_TYPE_MEM, which is not supported by 53c974.
- Print PCI devinfo in the attachment message.
 1.21 15-Nov-2002  tsutsui Remove an entry for AMD PCNETS_PCI.

AMD Am79C974 PCnet-SCSI Ethernet and SCSI conrtoller is
a multi-function PCI device which has two device IDs
of Am53C974(PCscsi-PCI) and Am79C970(PCnet-PCI),
and there is no its own ID.
 1.20 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.19 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.18 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.17 13-Nov-2001  lukem add RCSID
 1.16 19-Jul-2001  thorpej Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.15 25-Apr-2001  bouyer branches: 1.15.2;
Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.14 29-Mar-2001  petrov use NCR_F_DMASELECT instead ncr53c9x_dmaselect
 1.13 08-Mar-2001  thorpej Add BUS_DMA_STREAMING to data transfer map loads.
 1.12 28-Dec-2000  sommerfeld branches: 1.12.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.11 14-Nov-2000  thorpej NBPG -> PAGE_SIZE
 1.10 05-Jun-2000  tsutsui Adapt MI ncr53c9x changes.
 1.9 02-Jun-2000  tsutsui KNF some lines.
 1.8 20-Mar-2000  tsutsui branches: 1.8.2;
Use sc_cfg4 for the Am53c974.
 1.7 14-Jan-2000  tsutsui minor cosmetic
 1.6 12-Dec-1999  thorpej Use htole32().
 1.5 30-Sep-1999  thorpej branches: 1.5.2; 1.5.8;
Update for SCSPI changes.
 1.4 22-Sep-1999  mhitch Set sc_cfg3_fscsi for the AMD53C974 to match the change in ncr53c9x.c.
 1.3 25-Apr-1999  thorpej Fix a couple of problems in the PCscsi-PCI driver:
* resid in pcscp_dma_intr() should also be set in the data out phase.
* Don't set up DMA in the transfer pad operations.
* Change URL of the PDF technical manual to the index page.
* include <machine/bswap.h> on big endian machines.

Fixes timeouts writing large blocks to tapes. From Izumi Tsutsui,
PR 7252.
 1.2 08-Jan-1999  thorpej branches: 1.2.2;
One more cosmetic change, from Izumi Tsutsui.
 1.1 06-Jan-1999  thorpej Device driver for the AMD Am53c974 PCscsi-PCI SCSI chip (i.e. the chip used
on the Tekram DC-390 SCSI cards), from Izumi Tsutsui, PR#6654. Minor
cosmetic changes by me.
 1.2.2.2 04-Dec-1999  he Pull up revision 1.4 (requested by mhitch):
Fix the problems in detecting the clock speed on the TCDS Dual
SCSI Option cards, and correctly configure the Fast SCSI interfaces.
This allows installation on the 3000/500 -> 3000/900 Alphas which
have the Fast SCSI interface on the on-board SCSI adapters.
 1.2.2.1 26-Apr-1999  perry branches: 1.2.2.1.2;
pullup 1.2->1.3 (thorpej)
 1.2.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.2.8 21-Apr-2001  bouyer Sync with HEAD
 1.5.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.5.2.6 22-Jan-2001  bouyer make it compile
 1.5.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.5.2.4 22-Nov-2000  bouyer Sync with HEAD.
 1.5.2.3 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.2 20-Oct-1999  thorpej Eliminate sleeping from adapter routines.
 1.5.2.1 19-Oct-1999  thorpej Adapt to scsipi API changes.
 1.8.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.12.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.12.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.12.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.12.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.12.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.15.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.15.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 03-Aug-2001  lukem update to -current
 1.24.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.2.6 24-Jan-2005  skrll Sync with HEAD.
 1.24.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.24.2.4 19-Oct-2004  skrll Sync with HEAD
 1.24.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.2.1 03-Aug-2004  skrll Sync with HEAD
 1.31.2.1 29-Apr-2005  kent sync with -current
 1.33.2.4 27-Oct-2007  yamt sync with head.
 1.33.2.3 03-Sep-2007  yamt sync with head.
 1.33.2.2 30-Dec-2006  yamt sync with head.
 1.33.2.1 21-Jun-2006  yamt sync with head.
 1.34.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.34.10.2 11-May-2006  elad sync with head
 1.34.10.1 19-Apr-2006  elad sync with head.
 1.34.8.1 24-May-2006  yamt sync with head.
 1.34.6.2 01-Jun-2006  kardel Sync with head.
 1.34.6.1 22-Apr-2006  simonb Sync with head.
 1.34.4.1 09-Sep-2006  rpaulo sync with head
 1.36.10.2 10-Dec-2006  yamt sync with head.
 1.36.10.1 22-Oct-2006  yamt sync with head
 1.36.8.1 18-Nov-2006  ad Sync with head.
 1.38.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.39.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.39.16.1 06-Nov-2007  matt sync with HEAD
 1.39.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.39.2.1 23-Oct-2007  ad Sync with head.
 1.40.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.40.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.42.4.2 04-May-2009  yamt sync with head.
 1.42.4.1 16-May-2008  yamt sync with head.
 1.42.2.1 18-May-2008  yamt sync with head.
 1.43.6.1 19-Oct-2008  haad Sync with HEAD.
 1.43.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.44.16.1 05-Mar-2011  rmind sync with head
 1.45.12.1 18-Feb-2012  mrg merge to -current.
 1.45.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.8.1 17-Apr-2012  yamt sync with head
 1.46.10.1 18-May-2014  rmind sync with head
 1.46.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.4.1 10-Jun-2019  christos Sync with HEAD
 1.48.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file pcscp.c.orig was initially added on branch thorpej_scsipi.
 1.1.2.2 20-Nov-2000  bouyer Remove files that should not have been added
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1 20-Nov-2000  bouyer branches: 1.1.2;
file pcscp.c.rej was initially added on branch thorpej_scsipi.
 1.1.2.2 20-Nov-2000  bouyer Remove files that should not have been added
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 06-Jan-1999  thorpej branches: 1.1.140; 1.1.142; 1.1.144;
Device driver for the AMD Am53c974 PCscsi-PCI SCSI chip (i.e. the chip used
on the Tekram DC-390 SCSI cards), from Izumi Tsutsui, PR#6654. Minor
cosmetic changes by me.
 1.1.144.1 16-May-2008  yamt sync with head.
 1.1.142.1 18-May-2008  yamt sync with head.
 1.1.140.1 02-Jun-2008  mjf Sync with HEAD.
 1.35 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.34 31-Jul-2012  bouyer branches: 1.34.2; 1.34.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.33 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.32 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.31 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.30 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.29 04-Apr-2011  dyoung branches: 1.29.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.28 05-Nov-2010  jakllsch branches: 1.28.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.27 19-Oct-2009  bouyer branches: 1.27.2; 1.27.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.26 18-Mar-2008  cube branches: 1.26.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.25 09-Feb-2007  ad branches: 1.25.20; 1.25.36; 1.25.40;
Merge newlock2 to head.
 1.24 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 11-Dec-2005  christos branches: 1.22.20; 1.22.22;
merge ktrace-lwp.
 1.21 24-May-2005  lukem branches: 1.21.2;
add __KERNEL_RCSID
 1.20 27-Feb-2005  perry nuke trailing whitespace
 1.19 23-Aug-2004  bouyer branches: 1.19.4; 1.19.6;
Revert 1.12, it cause problems on promise controllers, as reported in
PR kern/26568 by Paul Shupak.
 1.18 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.17 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.16 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.15 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.14 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.13 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.12 02-Aug-2004  bouyer branches: 1.12.2;
If acknowledge "bogus" interrupts (that is, interrupts that have happened
according to the controller-dependant registers while wdc was not waiting for
an interrupt). A reset can generate spurious interrupts (or even a flow of
spurious interrupts on the promise) that needs to be properly acknowledged.
 1.11 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.10 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.9 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.8 22-Nov-2003  fvdl Use the redefined Promise product ids.
 1.7 15-Nov-2003  bouyer Clear interrupts at end of attach, in case there is one pending.
Avoid "bogus intr" messages when interrupts are enabled later.
Patch tested by myself and Chuck Silvers.
 1.6 29-Oct-2003  mycroft Simplify a little.
 1.5 25-Oct-2003  christos Fix uninitialized variable warnings
 1.4 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.3 22-Oct-2003  fvdl Match the Promise FastTrak 378.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.12.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.12.2.2 03-Aug-2004  skrll Sync with HEAD
 1.12.2.1 02-Aug-2004  skrll file pdcide.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.19.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.19.4.1 29-Apr-2005  kent sync with -current
 1.21.2.3 24-Mar-2008  yamt sync with head.
 1.21.2.2 26-Feb-2007  yamt sync with head.
 1.21.2.1 30-Dec-2006  yamt sync with head.
 1.22.22.2 10-Dec-2006  yamt sync with head.
 1.22.22.1 22-Oct-2006  yamt sync with head
 1.22.20.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.22.20.1 18-Nov-2006  ad Sync with head.
 1.25.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.36.1 24-Mar-2008  keiichi sync with head.
 1.25.20.1 23-Mar-2008  matt sync with HEAD
 1.26.4.1 11-Mar-2010  yamt sync with head
 1.27.4.2 21-Apr-2011  rmind sync with head
 1.27.4.1 05-Mar-2011  rmind sync with head
 1.27.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29.4.1 30-Oct-2012  yamt sync with head
 1.34.4.1 18-May-2014  rmind sync with head
 1.34.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.32 03-Sep-2021  andvar fix typos in comments, mainly s/extention/extension/ and s/sufficent/sufficient/
 1.31 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.30 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.29 20-Oct-2017  jdolecek branches: 1.29.2; 1.29.4;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.28 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.27 29-Mar-2014  christos branches: 1.27.18;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.26 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.25 31-Jul-2012  bouyer branches: 1.25.2; 1.25.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.24 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.23 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.22 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.21 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.20 04-Apr-2011  dyoung branches: 1.20.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.19 05-Nov-2010  jakllsch branches: 1.19.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.18 26-Nov-2009  njoly branches: 1.18.2; 1.18.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.17 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.16 18-Mar-2008  cube branches: 1.16.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.15 09-Feb-2007  ad branches: 1.15.20; 1.15.36; 1.15.40;
Merge newlock2 to head.
 1.14 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.13 25-Oct-2006  bouyer Map the SATA registers for SATA channels, and probe drives using them instead
of using the old PATA way. Tested with a PDC20375 (2xSATA + 1xPATA).
While there add the PDC20618-621 products (Ultra/133 controllers);
untested. Yes, it's strange to support PATA-only devices in a driver
called pdcsata, but that's how it is ...
 1.12 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.11 03-Sep-2006  xtraeme branches: 1.11.2; 1.11.4;
Add support for PDC40519 and PDC40779... from obsd.
 1.10 13-Aug-2006  dsainty Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.

This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.

The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.

The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.9 26-Jun-2006  xtraeme branches: 1.9.2;
Add missing __KERNEL_RCSID()
 1.8 26-Jun-2006  xtraeme Add support for PDC20775 and PDC40518.
 1.7 20-Jun-2006  christos PR/33445: Brian Buhrow: Fix a number of problems with the pdcsata driver:

> The driver for the family of Promise SATA controllers,
> /usr/src/sys/dev/pci/pdcsata.c is not very robust when it comes to handling
> transient drive errors, or interrupt hickups when the card is under load.
> Worse, my experience seems to indicate, and the Linux driver confirms,
> that these cards tend to fall over rather frequently during high load
> operations or if drives unexpectedly reset or go to sleep. Symptoms
> include interupt timeouts during heavy load, the inability to reset drives
> if they go to sleep, and a failure of the card to generate interrupts at
> all if the interrupt load gets too high.
 1.6 26-Jan-2006  bouyer branches: 1.6.2; 1.6.6; 1.6.14;
Add support for Promise PDC2057x SATA/150 Ide controllers.
From FreeBSD, tested by Douglas Wade Needham.
 1.5 16-Jan-2006  bouyer properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.4 04-Dec-2005  christos branches: 1.4.2;
PR/32238: Ryo Shimizu: Add support for Promise SATA300TX4 SATA Controller
(PDC40718)
 1.3 27-Feb-2005  perry branches: 1.3.2; 1.3.4; 1.3.6;
nuke trailing whitespace
 1.2 28-Nov-2004  bouyer branches: 1.2.2; 1.2.6; 1.2.8;
Add RAID support, from Shin'ichiro TAYA on current-users@.
 1.1 24-Nov-2004  bouyer pdcsata(4), a driver for the Promise SATA150 (aka PDC203xx) serie of
controllers. Tested with a PDC20375 (2 SATA, one PATA) controller on sparc64.
Added to all kernel config file which had pdcide(4).
 1.2.8.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.6.1 29-Apr-2005  kent sync with -current
 1.2.2.4 11-Dec-2005  christos Sync with head.
 1.2.2.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.2.2 29-Nov-2004  skrll Sync with HEAD.
 1.2.2.1 28-Nov-2004  skrll file pdcsata.c was added on branch ktrace-lwp on 2004-11-29 07:24:17 +0000
 1.3.6.4 24-Mar-2008  yamt sync with head.
 1.3.6.3 26-Feb-2007  yamt sync with head.
 1.3.6.2 30-Dec-2006  yamt sync with head.
 1.3.6.1 21-Jun-2006  yamt sync with head.
 1.3.4.3 07-Apr-2005  tron Pull up revision 1.2 via patch (requested by bouyer in ticket #1037):
Add RAID support, from Shin'ichiro TAYA on current-users@.
 1.3.4.2 02-Apr-2005  he Pull up revision 1.1 (via patch, requested by bouyer in ticket #1019):
Add pdcsata(4), a driver for the Promise SATA150 (aka PDC203xx)
series of controllers.
 1.3.4.1 27-Feb-2005  he file pdcsata.c was added on branch netbsd-2 on 2005-04-02 21:24:31 +0000
 1.3.2.4 15-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #1466):
sys/dev/pci/pcidevs: revision 1.798, 1.819
sys/dev/pci/pdcsata.c: revision 1.8, 1.10
Add support for PDC20775 and PDC40518.

Add the Promise PDC20771, present on the Promise FastTrak TX2300
Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.
This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.
The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.
The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.3.2.3 28-Jul-2006  riz Pull up following revision(s) (requested by simonb in ticket #1430):
sys/dev/pci/pdcsata.c: revision 1.7
PR/33445: Brian Buhrow: Fix a number of problems with the pdcsata driver:
The driver for the family of Promise SATA controllers,
/usr/src/sys/dev/pci/pdcsata.c is not very robust when it comes to handling
transient drive errors, or interrupt hickups when the card is under load.
Worse, my experience seems to indicate, and the Linux driver confirms,
that these cards tend to fall over rather frequently during high load
operations or if drives unexpectedly reset or go to sleep. Symptoms
include interupt timeouts during heavy load, the inability to reset drives
if they go to sleep, and a failure of the card to generate interrupts at
all if the interrupt load gets too high.
--
 1.3.2.2 05-Feb-2006  riz Pull up following revision(s) (requested by bouyer in ticket #1156):
sys/dev/pci/pdcsata.c: revision 1.6
Add support for Promise PDC2057x SATA/150 Ide controllers.
From FreeBSD, tested by Douglas Wade Needham.
 1.3.2.1 21-Jan-2006  snj Pull up following revision(s) (requested by simonb in ticket #1126):
sys/dev/pci/pcidevs: revision 1.739
sys/dev/pci/pdcsata.c: revision 1.4
PR/32238: Ryo Shimizu: Add support for Promise SATA300TX4 SATA Controller
(PDC40718)
 1.4.2.1 01-Feb-2006  yamt sync with head.
 1.6.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.6.4 14-Sep-2006  yamt sync with head.
 1.6.6.3 03-Sep-2006  yamt sync with head.
 1.6.6.2 11-Aug-2006  yamt sync with head
 1.6.6.1 26-Jun-2006  yamt sync with head.
 1.6.2.1 09-Sep-2006  rpaulo sync with head
 1.9.2.2 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #115):
share/man/man4/pdcsata.4: revision 1.5
sys/dev/pci/pcidevs: revision 1.827
sys/dev/pci/pcidevs: revision 1.828
sys/dev/pci/pcidevs: revision 1.829
sys/dev/pci/pdcsata.c: revision 1.11
Add some ICH8 devices... from obsd.
Add some missing devices from Promise and sort them.
Add missing PDC20265 device... removed accidentally in previous.
Add support for PDC40519 and PDC40779... from obsd.
Mention PDC40519 and PDC40779... and bump date.
 1.9.2.1 15-Aug-2006  ghen Pull up following revision(s) (requested by xtraeme in ticket #28):
sys/dev/pci/pcidevs: revision 1.819
sys/dev/pci/pcidevs.h: revision 1.819
sys/dev/pci/pcidevs_data.h: revision 1.818 (via patch)
sys/dev/pci/pdcsata.c: revision 1.10
Add the Promise PDC20771, present on the Promise FastTrak TX2300
Add support for the Promise PDC20771, present on the Promise FastTrak TX2300.
This support is not based on a datasheet, because a datasheet is not readily
available for this chip. However, Promise have partially open sourced their
driver for Linux, and all suggestions are that the PDC20771 is pretty similar
to other recent SATA chips.
The TX2300 has two ports, but there is unoccupied space on the board for a
third PATA port. It isn't entirely obvious how many channels the PDC20771 can
support.
The pdc205xx_drv_probe probe is necessary to avoid probing two wd* devices for
every physical device.
 1.11.4.2 10-Dec-2006  yamt sync with head.
 1.11.4.1 22-Oct-2006  yamt sync with head
 1.11.2.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.11.2.1 18-Nov-2006  ad Sync with head.
 1.15.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.36.1 24-Mar-2008  keiichi sync with head.
 1.15.20.1 23-Mar-2008  matt sync with HEAD
 1.16.4.1 11-Mar-2010  yamt sync with head
 1.18.4.2 21-Apr-2011  rmind sync with head
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.18.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.19.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.4.1 30-Oct-2012  yamt sync with head
 1.25.4.1 18-May-2014  rmind sync with head
 1.25.2.3 03-Dec-2017  jdolecek update from HEAD
 1.25.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.27.18.2 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.27.18.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.29.4.1 10-Jun-2019  christos Sync with HEAD
 1.29.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.67 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.66 26-May-2018  jakllsch branches: 1.66.2;
Match PCI_PRODUCT_INTEL_82Q45_IDER.

Not entirely sure which chip map to use, but as this is for AMT, it's
probably not like there's a real PATA interface to configure DMA for,
and as the 965 AMT stuff uses the sata version of the chip map, we'll
cargo cult it for now.
 1.65 01-Feb-2016  msaitoh branches: 1.65.16;
Rename macro (sync with pcidevs rev. 1.1246). No functional change.
 1.64 14-Nov-2012  jakllsch branches: 1.64.12; 1.64.14; 1.64.18;
enable the generic pciide detach function in piixide(4)
 1.63 31-Jul-2012  bouyer branches: 1.63.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.62 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.61 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.60 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.59 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.58 05-Mar-2012  sborrill Add support for Intel 6 Series Serial ATA Controller
 1.57 04-Apr-2011  dyoung branches: 1.57.4; 1.57.8; 1.57.10;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.56 05-Nov-2010  jakllsch branches: 1.56.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.55 30-Jul-2010  njoly Adjust for Intel ICH10 devices update.
 1.54 24-Feb-2010  dyoung branches: 1.54.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.53 08-Jan-2010  dyoung branches: 1.53.2;
Expand PMF_FN_* macros.
 1.52 30-Nov-2009  sborrill Add support for Intel 3400 SATA
 1.51 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.50 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.49 09-Mar-2009  christos Match Inter 82965PM, from Anon Ymous
 1.48 11-Feb-2009  markd Add some more ICH9 SATA controller variants.
 1.47 01-Oct-2008  christos branches: 1.47.2; 1.47.4; 1.47.8; 1.47.12;
ICH10 support from Brad du Plessis
 1.46 18-Mar-2008  cube branches: 1.46.4; 1.46.6; 1.46.10;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.45 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.44 15-Jan-2008  drochner branches: 1.44.2; 1.44.6;
fix some unaligned PCI config space accesses in suspend/resume functions
 1.43 04-Jan-2008  joerg Allow saving of up to 4 PCI registers in the IDE code.
 1.42 09-Dec-2007  jmcneill branches: 1.42.2;
Merge jmcneill-pm branch.
 1.41 09-Sep-2007  xtraeme branches: 1.41.6; 1.41.8; 1.41.10;
Another ICH8M SATA Controller found in jmcneill's laptop.
 1.40 31-Aug-2007  xtraeme Proper ICH8M IDE Controller support (missed in previous).
 1.39 31-Aug-2007  xtraeme Attach to the ICH8M IDE Controller.
 1.38 30-Aug-2007  xtraeme Attach to the ICH9 SATA devices.
 1.37 10-Mar-2007  itohy branches: 1.37.2; 1.37.10; 1.37.14; 1.37.16;
I tried the test code in PR kern/35934 on PIIX4 and ICH6,
both of which turned out to have the problem.
Enabled (untested) workaround for all PIIX controllers.

XXX Do other controllers also have this problem?
 1.36 09-Feb-2007  ad branches: 1.36.2;
Merge newlock2 to head.
 1.35 01-Dec-2006  cube branches: 1.35.2; 1.35.4;
Now that we have a AHCI driver (thanks a bunch, Manuel!), we can remove the
nonsense quirk that switched operating mode on ICH7 and ICH8.

I removed the obvious candidates for ahcisata(4), and I'll have a closer
look later if there are others to be removed; ahcisata(4) will take over
handling the device anyway, but there is no reason to keep AHCI devices in
that list.

Along the way, remove the code that tries to put the chip in Enhanced mode,
it makes absolutely no sense to do that, and some BIOSes might not have
prepared the BARs for that, as proven by PR#34885. If people want to use
all IDE and SATA channels, they have to tell the BIOS.
 1.34 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.33 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.32 08-Nov-2006  drochner avoid magic number
 1.31 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.30 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.29 03-Sep-2006  xtraeme branches: 1.29.2; 1.29.4;
* Add support for ICH8 and ICH8M SATA/RAID controllers.
* If the controller is in AHCI, ask for SATA IDE mode of operation.

jsg@openbsd says:

"X60/T60 Thinkpads are shipped in AHCI configuration by default,
this makes them work without changing a BIOS option."

Tested by eye of the beholder. From OpenBSD.

Ok'ed tls.
 1.28 08-Aug-2006  cube Add support for the 631xESB/632xESB.
 1.27 17-Jun-2006  jmcneill branches: 1.27.2;
Restore IDE and UDMA timings on resume for the PIIX4.
 1.26 19-May-2006  markd branches: 1.26.2; 1.26.4;
Add Intel 82801GBM/GHM Serial ATA Controller.
 1.25 11-Dec-2005  christos branches: 1.25.4; 1.25.6; 1.25.8; 1.25.12;
merge ktrace-lwp.
 1.24 10-Aug-2005  bouyer Not add PIIX are wired to compat mode these days. Problem reported and fix
tested by Havard Eidnes.
 1.23 21-Jul-2005  tron Add support for PATA and SATA ports in the Intel ICH7 southbridge (82801G).
Patch supplied by Marcello Balduccini in PR port-i386/30795.
 1.22 20-Jun-2005  briggs branches: 1.22.2;
Match the 6300ESB on-board SATA/RAID controller.
Set the ATA RAID flag, if appropriate, in the SATA chip map.
Ensure that the interrupts are enabled in the SATA chip map.
 1.21 15-Jun-2005  bouyer Support Intel 82801FBM Serial ATA Controller. From Kurt Schreiner on tech-kern.
 1.20 24-May-2005  lukem add __KERNEL_RCSID
 1.19 27-Feb-2005  perry branches: 1.19.2;
nuke trailing whitespace
 1.18 26-Jan-2005  jmcneill Add powerhooks for PIIX IDE driver.
 1.17 10-Nov-2004  cube branches: 1.17.4; 1.17.6;
Add support for the ICH6 IDE controller (82801FB).
 1.16 22-Oct-2004  cube Add support for the 82801FB/FR (ICH6/6R) SATA controllers.
 1.15 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.14 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.13 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.12 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.11 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.10 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.9 11-May-2004  thorpej branches: 1.9.2;
Handle the i6300ESB IDE / SATA controllers. These are apparently just ICH5.
 1.8 03-Jan-2004  thorpej branches: 1.8.2;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.7 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.6 14-Dec-2003  thorpej Split the Intel i31244 SATA controller ("Artisea") driver out of piixide
into its own driver (artsata).
 1.5 06-Dec-2003  bouyer Clone artisea_chip_map() for use by the ICH5 SATA controllers.
The 31244 is really different from the ICH5, and one day the map function
could be incompatibles. Suggested by thorpej@
 1.4 05-Dec-2003  bouyer Add support for the Intel 82801ER Serial ATA/Raid Controller.
From Simas Mockevicius on current-users@.
 1.3 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.8.2.1 28-Jul-2004  tron branches: 1.8.2.1.2;
Pull up revision 1.9 (requested by joda in ticket #721):
Handle the i6300ESB IDE / SATA controllers. These are apparently just ICH5.
 1.8.2.1.2.4 22-Aug-2005  riz Pull up following revision(s) (requested by bouyer in ticket #5602):
sys/dev/pci/piixide.c: revision 1.24
Not all PIIX are wired to compat mode these days. Problem reported and fix
tested by Havard Eidnes.
 1.8.2.1.2.3 21-Jun-2005  riz Pull up revision 1.21 (requested by bouyer in ticket #2008):
Support Intel 82801FBM Serial ATA Controller. From Kurt Schreiner on tech-kern.
 1.8.2.1.2.2 19-May-2005  tron Pull up revision 1.17 via patch (requested by riz in ticket #1531):
Ad support for the ICH6 IDE controller (82801FB).
 1.8.2.1.2.1 19-May-2005  tron Pull up revision 1.16 (requested by riz in ticket #1531):
Add support for the 82801FB/FR (ICH6/6R) SATA controllers.
 1.9.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.2.8 04-Feb-2005  skrll Sync with HEAD.
 1.9.2.7 14-Nov-2004  skrll Sync with HEAD.
 1.9.2.6 02-Nov-2004  skrll Sync with HEAD.
 1.9.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.9.2.2 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 11-May-2004  skrll file piixide.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.17.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.6.1 12-Feb-2005  yamt sync with head.
 1.17.4.1 29-Apr-2005  kent sync with -current
 1.19.2.5 08-Apr-2008  jdc Pull up revisions:
src/sys/dev/pci/pcidevs 1.816
src/sys/dev/pci/piixide.c 1.28
(requested by bouyer in ticket #1909).

Add device IDs for Intel's 631xESB/632xESB southbridges, and start the list
for the 5000X northbridge. I'll add the rest later, the spec is currently
unavailable so I'll collect them from another source.

Add support for the 631xESB/632xESB.
 1.19.2.4 24-Aug-2005  tron Pull up revision 1.24 (requested by bouyer in ticket #692):
Not add PIIX are wired to compat mode these days. Problem reported and fix
tested by Havard Eidnes.
 1.19.2.3 23-Jul-2005  riz Pull up revision 1.23 (requested by tron in ticket #609):
Add support for PATA and SATA ports in the Intel ICH7 southbridge (82801G).
Patch supplied by Marcello Balduccini in PR port-i386/30795.
 1.19.2.2 03-Jul-2005  tron Pull up revision 1.22 (requested by briggs in ticket #522):
Match the 6300ESB on-board SATA/RAID controller.
Set the ATA RAID flag, if appropriate, in the SATA chip map.
Ensure that the interrupts are enabled in the SATA chip map.
 1.19.2.1 21-Jun-2005  tron Pull up revision 1.21 (requested by bouyer in ticket #479):
Support Intel 82801FBM Serial ATA Controller. From Kurt Schreiner on tech-kern.
 1.22.2.8 24-Mar-2008  yamt sync with head.
 1.22.2.7 17-Mar-2008  yamt sync with head.
 1.22.2.6 21-Jan-2008  yamt sync with head
 1.22.2.5 27-Oct-2007  yamt sync with head.
 1.22.2.4 03-Sep-2007  yamt sync with head.
 1.22.2.3 26-Feb-2007  yamt sync with head.
 1.22.2.2 30-Dec-2006  yamt sync with head.
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.25.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.25.8.4 14-Sep-2006  yamt sync with head.
 1.25.8.3 11-Aug-2006  yamt sync with head
 1.25.8.2 26-Jun-2006  yamt sync with head.
 1.25.8.1 24-May-2006  yamt sync with head.
 1.25.6.1 01-Jun-2006  kardel Sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.26.2.2 19-Jun-2006  chap Sync with head.
 1.26.2.1 19-May-2006  chap file piixide.c was added on branch chap-midi on 2006-06-19 04:01:37 +0000
 1.27.2.2 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #117):
sys/dev/pci/piixide.c: revision 1.29
sys/dev/pci/pciide_piix_reg.h: revision 1.12
* Add support for ICH8 and ICH8M SATA/RAID controllers.
* If the controller is in AHCI, ask for SATA IDE mode of operation.
jsg@openbsd says:
"X60/T60 Thinkpads are shipped in AHCI configuration by default,
this makes them work without changing a BIOS option."
Tested by eye of the beholder. From OpenBSD.
Ok'ed tls.
 1.27.2.1 11-Aug-2006  riz Pull up following revision(s) (requested by cube in ticket #8):
sys/dev/pci/piixide.c: revision 1.28
sys/dev/pci/pcidevs: revision 1.816
Add device IDs for Intel's 631xESB/632xESB southbridges, and start the list
for the 5000X northbridge. I'll add the rest later, the spec is currently
unavailable so I'll collect them from another source.
Add support for the 631xESB/632xESB.
 1.29.4.2 10-Dec-2006  yamt sync with head.
 1.29.4.1 22-Oct-2006  yamt sync with head
 1.29.2.3 06-Feb-2007  ad Quiten noisy boot messages.
 1.29.2.2 12-Jan-2007  ad Sync with head.
 1.29.2.1 18-Nov-2006  ad Sync with head.
 1.35.4.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.35.2.1 24-Oct-2007  pavel Pull up following revisions (requested by msaitoh in ticket #935):
sys/dev/pci/piixide.c: revision 1.38-1.41 via patch
sys/dev/pci/pcidevs: revision 1.900 via patch
Attach to the ICH9 SATA devices.
Attach to the ICH8M IDE Controller.
Proper ICH8M IDE Controller support (missed in previous).
Another ICH8M SATA Controller found in jmcneill's laptop.
 1.36.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.16.3 23-Mar-2008  matt sync with HEAD
 1.37.16.2 09-Jan-2008  matt sync with HEAD
 1.37.16.1 06-Nov-2007  matt sync with HEAD
 1.37.14.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.37.14.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.37.14.4 02-Oct-2007  joerg Sync with HEAD.
 1.37.14.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.37.14.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.37.14.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.37.10.2 10-Sep-2007  skrll Sync with HEAD.
 1.37.10.1 03-Sep-2007  skrll Sync with HEAD.
 1.37.2.1 09-Oct-2007  ad Sync with head.
 1.41.10.1 11-Dec-2007  yamt sync with head.
 1.41.8.1 26-Dec-2007  ad Sync with head.
 1.41.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.42.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.42.2.1 08-Jan-2008  bouyer Sync with HEAD
 1.44.6.2 05-Oct-2008  mjf Sync with HEAD.
 1.44.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.44.2.1 24-Mar-2008  keiichi sync with head.
 1.46.10.1 19-Oct-2008  haad Sync with HEAD.
 1.46.6.1 10-Oct-2008  skrll Sync with HEAD.
 1.46.4.3 11-Aug-2010  yamt sync with head.
 1.46.4.2 11-Mar-2010  yamt sync with head
 1.46.4.1 04-May-2009  yamt sync with head.
 1.47.12.1 21-Apr-2010  matt sync to netbsd-5
 1.47.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.47.4.2 17-Mar-2012  bouyer Pull up following revision(s) (requested by sborrill in ticket #1739):
sys/dev/pci/piixide.c: revision 1.58
sys/dev/pci/pcidevs: patch
Add support for Intel 6 Series Serial ATA Controller
 1.47.4.1 18-Dec-2009  snj Pull up following revision(s) (requested by sborrill in ticket #1175):
sys/dev/pci/piixide.c: revision 1.52
Add support for Intel 3400 SATA
 1.47.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.47.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.53.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.53.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.53.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.54.2.2 21-Apr-2011  rmind sync with head
 1.54.2.1 05-Mar-2011  rmind sync with head
 1.56.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.57.10.1 07-Mar-2012  riz Pull up following revision(s) (requested by sborrill in ticket #98):
sys/dev/pci/piixide.c: revision 1.58
Add support for Intel 6 Series Serial ATA Controller
 1.57.8.1 06-Mar-2012  mrg sync to -current
 1.57.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.57.4.2 30-Oct-2012  yamt sync with head
 1.57.4.1 17-Apr-2012  yamt sync with head
 1.63.2.3 03-Dec-2017  jdolecek update from HEAD
 1.63.2.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.63.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.64.18.1 18-Jan-2017  skrll Sync with netbsd-5
 1.64.14.1 19-Mar-2016  skrll Sync with HEAD
 1.64.12.1 09-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1298):
sys/dev/pci/piixide.c: revision 1.65
sys/dev/pci/pcidevs: revision 1.1246
- s/82081/82801/ from OpenBSD.
- 0x2829 is SATA. 0x282a is RAID.
--
Rename macro (sync with pcidevs rev. 1.1246). No functional change.
 1.65.16.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.65.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.66.2.1 10-Jun-2019  christos Sync with HEAD
 1.73 24-Feb-2025  jmcneill piixpm: Cleanup log message when SMI is used
 1.72 12-Jan-2023  msaitoh branches: 1.72.6;
Modify error message to match the current behavior.
 1.71 10-Jan-2023  msaitoh Use MMIO for PM register access on newer revision's devices.

Newer revision's device only support memory mapped access. At least,
X670E's SMBus device that the revision ID is 0x71 doesn't support I/O
access. Use MMIO access for newer devices. Linux uses >= 0x51 for the
check, so we do the same check. Note that X570's SMBus(rev. 0x61) supports
I/O access...
 1.70 09-Jan-2023  msaitoh Modify for following MMIO support. No functional change.
 1.69 09-Jan-2023  msaitoh Simplify and modify for following MMIO support. No functional change.
 1.68 09-Jan-2023  msaitoh Modify comment. Whitespace. No functional change.
 1.67 01-Apr-2022  pgoyette branches: 1.67.4;
Call iic_fini_tag() when the tag is no longer needed.

Without this, a LOCKDEBUG kernel can panic when trying to re-init the tag.
 1.66 12-Oct-2021  andvar fix various typos, mainly in comments.
 1.65 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.64 24-Apr-2021  thorpej branches: 1.64.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.63 14-Jan-2020  msaitoh branches: 1.63.8;
Save/restore port number before selecting port. Linux driver says it must
be required on some systems.
 1.62 14-Jan-2020  msaitoh Simplify. No functional change.
 1.61 09-Jan-2020  msaitoh Acquire/release host semaphore to share SMBus between the host and
the embedded controller (IMC).

Without this change, "shutdown -r" does power off and not boot on ECS HDC-I2.
This change fixes the problem.
 1.60 24-Dec-2019  thorpej branches: 1.60.2;
Make ichsmb and piixpm MP-safe:
- Synchronize with the interrupt handler using a mutex.
- Use a condvar to wait for completion, rather than tsleep().
- Mark our interrupt handler as such.

Also, other general correctness fixes:
- Loop around testing the completion condition to protect aginst
spurious wakes.
- The "i2c exec" function returns an error code, so actually do so.
 1.59 24-Dec-2019  msaitoh Don't force using SMBUS0SEL register.

- Use it depending on USE_SMBUS0SEL bit.
- If we use SMBUS0EN_LO register to select the port, update the port
select bits only.
 1.58 23-Dec-2019  msaitoh - Read SB800_SMB_HOSTC correctly. This register is not in the PCI config space
but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the check.
- Modify comment.
- Whitespace fix.
 1.57 23-Dec-2019  msaitoh Fix number of port for Hudson rev. 0x1f and newer. Same as OpenBSD and Linux.
 1.56 23-Dec-2019  thorpej piixpm_i2c_exec(): No need to check 'cold' to force I2C_F_POLL; the i2c
upper layer does it for us.
 1.55 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.54 13-Jul-2019  msaitoh branches: 1.54.2;
Improve SB800 and newer chipsets support:
- Add newer chipset (e.g. X370/X399 and newer) support that the PCI device id
is 0x790b. The register definitions are mainly taken from FreeBSD.
- Rename PIIXPM_INDIRECTIO_* to SB800_INDIRECTIO_* because those are only
for SB800 and newer chipsets.
- SB800 also support 4 ports.
- SB800's interrupt configuration bit is different from others.
Use SB800_SMB_HOSTC's bit 0.
- Do not bus_space_map devices which are at address 0 (it's uninitialized)
in piixpm_attach().
- Add the port number to the dmesg output.
- Avoid uninitiliazed use of ctl and corresponding warnings. From OpenBSD rev.
1.38
 1.53 12-Jul-2019  msaitoh Sync with OpenBSD's piixpm.c up to rev. 1.35:
- Print "polling" correctly when in the attach function. Same as OpenBSD
rev. 1.22-23.
- Improve debug printf()'s. Part of OpenBSD 1.24.
- Do not bus_space_map devices which are at address 0 (it's uninitialized).
Same as OpenBSD rev. 1.25.
- Add ServerWorks HT1100 device from OpenBSD. Same as OpenBSD rev. 1.32
- Use unique wait channel. From OpenBSD rev. 1.35
 1.52 29-Mar-2017  msaitoh branches: 1.52.6; 1.52.14;
Fix 0x%d and 0x%u.
 1.51 13-Oct-2016  jdolecek branches: 1.51.2;
provide intr xname
 1.50 18-Jul-2016  pgoyette Insert missing 'break;' statements.

CID 1364142
 1.49 11-Jul-2016  msaitoh branches: 1.49.2;
KNF. No functional change.
 1.48 10-Jul-2016  pgoyette The piixpm(4) driver also supports AMD's HUDSON chipset's SMBus function.

From OpenBSD, verified.
 1.47 10-Dec-2015  pgoyette Initialize the mutex before calling xxx_rescan(). Otherwise if we
load/attach an i2cbus at a later time (ie, load the iic module),
we'll end-up re-initializing the mutex.

(Caught with a LOCKDEBUG kernel)
 1.46 03-May-2015  pgoyette Teach a couple of i2cbus controllers how to rescan. This enables
{,un}loading and {at,de}taching of the iic(4) driver/module at a
later time. Tested piixpm on QEMU, and ichsmb on my live server.
 1.45 22-Jun-2014  hannken branches: 1.45.4;
Consistently pass a "struct piixpm_softc" to piixpm_intr.
Prevents a crash on hardware interrupts.
 1.44 29-Mar-2014  christos branches: 1.44.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.43 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.42 22-Jul-2013  soren The SB800 SMBus controller has four selectable SDA lines.
Expose them as four iic busses.
 1.41 18-Jul-2013  soren Clear errors before beginning a transfer.

Closes PR port-i386/46792.
 1.40 14-Feb-2012  pgoyette branches: 1.40.2; 1.40.6; 1.40.10; 1.40.18;
Replace the xxx_acquire()/xxx_release() rwlocks with mutexes. There are
only RW_WRITERs for these, and no RW_READERs, so no need to incur the
extra overhead of allowing for both. As discussed on tech-kern.

For piixpm and ichsmb, the acquire/release protocol needs to be used,
even if the request is I2C_F_POLL'd (or if the device supports only
polled mode). Otherwise multiple requests can be running at the same
time, and they stomp on each other and create anomolous results.

Part 2 addresses my PR kern/45889

3 ACKs from releng
 1.39 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.38 07-Jan-2012  pgoyette Modify the attach message for consistency with most other pci devices.
 1.37 03-Oct-2011  jmcneill branches: 1.37.2; 1.37.6;
avoid printing an empty line in the sb800 case
 1.36 02-Oct-2011  jmcneill Newer ATI SB800 SMBus controllers don't report the base address in PCI
config space. According to the SB800-Series Southbridges Register Reference
Guide, we can still read this value from PM config space using indirect I/O.
 1.35 13-Feb-2011  hannken The ServerWorks CSB5 smbus controller often times out and hangs until reboot.

Increase the delay between setting the command register and reading the
status register. Reset the smbus controller if it has timed out.

Tested on an IBM eServer x335.
 1.34 10-Feb-2011  hannken Make the SMbus Send/Receive functions work.

If cmdlen = 0 and len = 1 use the XXX_HC_CMD_BYTE protocol, send
data through XXX_SMB_HCMD or receive data from XXX_SMB_HD0.

Ok: Paul Goyette
 1.33 27-Jul-2010  jakllsch branches: 1.33.2; 1.33.4;
Make PIIXPM_DEBUG work with 64-bit size_t.
 1.32 24-Feb-2010  dyoung branches: 1.32.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.31 08-Jan-2010  dyoung branches: 1.31.2;
Expand PMF_FN_* macros.
 1.30 03-Nov-2009  pgoyette Set iba_type properly. The only thing that ever looks at this is the
'options I2C_SCAN' code in dev/i2c/i2c.c which is disabled by default.
 1.29 18-Mar-2009  cegger bzero -> memset
 1.28 13-Feb-2009  pgoyette Fix dmesg output:

Old:
piixpm0 at pci0 dev 20 function 0
piixpm0: ATI Technologies SB600/SB700/SB800 SMBus Controller (rev. 0x13)
piixpm0: interrupting at SMIpiixpm0: polling

New:
piixpm0 at pci0 dev 20 function 0
piixpm0: ATI Technologies SB600/SB700/SB800 SMBus Controller (rev. 0x13)
piixpm0: interrupting at SMI, polling

Cosmetic change only, no functional changes intended.
 1.27 03-Feb-2009  pgoyette branches: 1.27.2;
Update the i2c_exec() functions to handle quick_read/quick_write protocol.

Although interface routines i2c_smbus_*() exist, nothing in NetBSD actually
uses them yet.
 1.26 12-Oct-2008  martin branches: 1.26.2; 1.26.4;
Move printing of the "polling" message at attach time out of the wrong if
scope, so that it is actually printed even in non-error cases.
Suggested by jmcneill.
 1.25 09-Jul-2008  joerg - device/softc split
- reduce namespace pollution
 1.24 10-Apr-2008  cegger branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10;
use aprint_*_dev and device_xname
 1.23 26-Mar-2008  jmcneill PR#38301: Add support for SMBus controllers for ATI SB600, SB700, SB800
chipsets, from Christoph Egger.
 1.22 10-Mar-2008  sketch Fix console output.
 1.21 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.20 05-Feb-2008  simonb branches: 1.20.2; 1.20.6;
Remove an extra \n from an attach message. Get's rid of a blank
line during boot.
 1.19 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.18 09-Dec-2007  jmcneill branches: 1.18.2;
Merge jmcneill-pm branch.
 1.17 19-Oct-2007  ad branches: 1.17.2; 1.17.4; 1.17.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 27-Aug-2007  xtraeme branches: 1.16.2; 1.16.6;
Use rwlock(9) rather than lockmgr(9).
 1.15 26-Aug-2007  xtraeme There's no need to add timecounter code inside of __HAVE_TIMECOUNTER
ifdefs.
 1.14 06-Aug-2007  martin branches: 1.14.2;
Some serverworks mainboards use this power management too
 1.13 04-Mar-2007  christos branches: 1.13.2; 1.13.10; 1.13.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 10-Dec-2006  uwe branches: 1.12.2;
Print pci device info instead of "Power Management Controller".
 1.11 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.10 31-Oct-2006  toshii Match ATI SB[34]00 smbus controllers.
 1.9 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.8 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.7 17-Aug-2006  christos branches: 1.7.2; 1.7.4; 1.7.6;
Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.6 26-Jun-2006  drochner use the "i2cbus" interface attribute rather than putting a string name
into the i2cbus attach args
 1.5 26-Jun-2006  drochner -make sure it is a PIIX4 before accessing counter stuff
(there might be usable registers on 440mx and that ATI thing too,
but that needs to be checked/tested)
-make sure the I/O access to the power management stuff was enabled
by the BIOS before trying to map/access stuff
-most PIIX4s have a bug in the timer latch which causes jitter or worse
if it is read naively - check the revision
-use common code in dev/ic/acpipmtimer.c
 1.4 22-Jun-2006  jmcneill Add timecounter support for Intel PIIX Power Management Controllers.

Ok kardel@.
 1.3 17-Jun-2006  jmcneill branches: 1.3.2;
Restore the device activity PCI configuration registers on resume.
 1.2 07-May-2006  jmcneill branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10; 1.2.12;
Add __KERNEL_RCSID.
 1.1 07-May-2006  jmcneill Add support for the Intel PIIX4 power management controller, from OpenBSD.
 1.2.12.1 13-Jul-2006  gdamore Merge from HEAD.
 1.2.10.2 01-Jun-2006  kardel Sync with head.
 1.2.10.1 07-May-2006  kardel file piixpm.c was added on branch simonb-timecounters on 2006-06-01 22:36:49 +0000
 1.2.8.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.8.1 07-May-2006  tron file piixpm.c was added on branch peter-altq on 2006-05-24 15:50:28 +0000
 1.2.6.5 03-Sep-2006  yamt sync with head.
 1.2.6.4 11-Aug-2006  yamt sync with head
 1.2.6.3 26-Jun-2006  yamt sync with head.
 1.2.6.2 24-May-2006  yamt sync with head.
 1.2.6.1 07-May-2006  yamt file piixpm.c was added on branch yamt-pdpolicy on 2006-05-24 10:58:01 +0000
 1.2.4.1 19-Jun-2006  chap Sync with head.
 1.2.2.2 11-May-2006  elad sync with head
 1.2.2.1 07-May-2006  elad file piixpm.c was added on branch elad-kernelauth on 2006-05-11 23:28:48 +0000
 1.3.2.8 17-Mar-2008  yamt sync with head.
 1.3.2.7 11-Feb-2008  yamt sync with head.
 1.3.2.6 21-Jan-2008  yamt sync with head
 1.3.2.5 27-Oct-2007  yamt sync with head.
 1.3.2.4 03-Sep-2007  yamt sync with head.
 1.3.2.3 30-Dec-2006  yamt sync with head.
 1.3.2.2 21-Jun-2006  yamt sync with head.
 1.3.2.1 17-Jun-2006  yamt file piixpm.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:06 +0000
 1.7.6.2 10-Dec-2006  yamt sync with head.
 1.7.6.1 22-Oct-2006  yamt sync with head
 1.7.4.2 09-Sep-2006  rpaulo sync with head
 1.7.4.1 17-Aug-2006  rpaulo file piixpm.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.7.2.2 12-Jan-2007  ad Sync with head.
 1.7.2.1 18-Nov-2006  ad Sync with head.
 1.12.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.14.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.13.14.5 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.13.14.4 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.14.3 05-Oct-2007  joerg Convert piixpm(4) to PNP power management.
 1.13.14.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.13.14.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.13.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.13.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.13.2.3 23-Oct-2007  ad Sync with head.
 1.13.2.2 09-Oct-2007  ad Sync with head.
 1.13.2.1 20-Aug-2007  ad Sync with HEAD.
 1.14.2.2 06-Aug-2007  martin Some serverworks mainboards use this power management too
 1.14.2.1 06-Aug-2007  martin file piixpm.c was added on branch matt-mips64 on 2007-08-06 22:41:23 +0000
 1.16.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.2.3 23-Mar-2008  matt sync with HEAD
 1.16.2.2 09-Jan-2008  matt sync with HEAD
 1.16.2.1 06-Nov-2007  matt sync with HEAD
 1.17.6.1 11-Dec-2007  yamt sync with head.
 1.17.4.1 26-Dec-2007  ad Sync with head.
 1.17.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.20.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.20.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.20.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.20.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.20.2.1 24-Mar-2008  keiichi sync with head.
 1.24.10.1 19-Oct-2008  haad Sync with HEAD.
 1.24.8.1 18-Jul-2008  simonb Sync with head.
 1.24.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.24.4.3 11-Aug-2010  yamt sync with head.
 1.24.4.2 11-Mar-2010  yamt sync with head
 1.24.4.1 04-May-2009  yamt sync with head.
 1.26.4.1 20-Nov-2010  riz Pull up following revision(s) (requested by martin in ticket #1391):
sys/dev/pci/piixpm.c: revision 1.28
Fix dmesg output:
Old:
piixpm0 at pci0 dev 20 function 0
piixpm0: ATI Technologies SB600/SB700/SB800 SMBus Controller (rev. 0x13)
piixpm0: interrupting at SMIpiixpm0: polling
New:
piixpm0 at pci0 dev 20 function 0
piixpm0: ATI Technologies SB600/SB700/SB800 SMBus Controller (rev. 0x13)
piixpm0: interrupting at SMI, polling
Cosmetic change only, no functional changes intended.
 1.26.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.26.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.27.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.31.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.2.1 05-Mar-2011  rmind sync with head
 1.33.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.33.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.6.1 18-Feb-2012  mrg merge to -current.
 1.37.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.2.1 17-Apr-2012  yamt sync with head
 1.40.18.1 23-Jul-2013  riastradh sync with HEAD
 1.40.10.2 18-May-2014  rmind sync with head
 1.40.10.1 28-Aug-2013  rmind sync with head
 1.40.6.2 03-Dec-2017  jdolecek update from HEAD
 1.40.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.2.2 07-Aug-2014  msaitoh Pull up following revision(s) (requested by hannken in ticket #1096):
sys/dev/pci/piixpm.c: revision 1.45
Consistently pass a "struct piixpm_softc" to piixpm_intr.
Prevents a crash on hardware interrupts.
 1.40.2.1 20-Sep-2013  riz Pull up following revision(s) (requested by fair in ticket #936):
sys/dev/pci/piixpmreg.h: revision 1.6
sys/dev/pci/piixpm.c: revision 1.42
The SB800 SMBus controller has four selectable SDA lines.
Expose them as four iic busses.
 1.44.2.1 10-Aug-2014  tls Rebase.
 1.45.4.5 28-Aug-2017  skrll Sync with HEAD
 1.45.4.4 05-Dec-2016  skrll Sync with HEAD
 1.45.4.3 05-Oct-2016  skrll Sync with HEAD
 1.45.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.45.4.1 06-Jun-2015  skrll Sync with HEAD
 1.49.2.4 26-Apr-2017  pgoyette Resolve a couple of conflicts
 1.49.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.49.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.49.2.1 26-Jul-2016  pgoyette Sync with HEAD
 1.51.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.52.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.52.6.4 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1790:

sys/dev/pci/piixpm.c 1.66,1.68-1.72 via patch
sys/dev/pci/piixpmreg.h 1.13

Add support new AMD chipsets that do not have indirect access
I/O ports.
 1.52.6.3 30-Nov-2021  martin Apply patch, requested by msaitoh in ticket #1709:

sys/dev/pci/piixpm.c patch

Fix a bug that I2C access panics on old AMD chipset (e.g SB600).
Fixes PR kern/56525.
 1.52.6.2 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1591:

sys/dev/pci/piixpm.c 1.57-1.59,
1.61-1.63 via patch
sys/dev/pci/piixpmreg.h 1.9-1.12

- Fix number of port for Hudson rev. 0x1f and newer.
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI
config space but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the
check.
- Don't force using SMBUS0SEL register.
- Acquire/release host semaphore to share SMBus between the host and
the embedded controller (IMC). Without this change, "shutdown -r"
does power off and not boot on some machines.
- Save/restore port number before selecting port.
- Modify comment.
- Whitespace fix.
 1.52.6.1 06-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1327):

sys/dev/pci/piixpmreg.h: revision 1.8
sys/dev/pci/piixpm.c: revision 1.53
sys/dev/pci/piixpm.c: revision 1.54

Sync with OpenBSD's piixpm.c up to rev. 1.35:
- Print "polling" correctly when in the attach function. Same as OpenBSD
rev. 1.22-23.
- Improve debug printf()'s. Part of OpenBSD 1.24.
- Do not bus_space_map devices which are at address 0 (it's uninitialized).
Same as OpenBSD rev. 1.25.
- Add ServerWorks HT1100 device from OpenBSD. Same as OpenBSD rev. 1.32
- Use unique wait channel. From OpenBSD rev. 1.35


Improve SB800 and newer chipsets support:
- Add newer chipset (e.g. X370/X399 and newer) support that the PCI device id
is 0x790b. The register definitions are mainly taken from FreeBSD.
- Rename PIIXPM_INDIRECTIO_* to SB800_INDIRECTIO_* because those are only
for SB800 and newer chipsets.
- SB800 also support 4 ports.
- SB800's interrupt configuration bit is different from others.
Use SB800_SMB_HOSTC's bit 0.
- Do not bus_space_map devices which are at address 0 (it's uninitialized)
in piixpm_attach().
- Add the port number to the dmesg output.
- Avoid uninitiliazed use of ctl and corresponding warnings. From OpenBSD rev.
1.38
 1.54.2.3 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1573:

sys/dev/pci/piixpm.c 1.66,1.68-1.72 via patch
sys/dev/pci/piixpmreg.h 1.13

Add support new AMD chipsets that do not have indirect access
I/O ports.
 1.54.2.2 30-Nov-2021  martin Apply patch, requested by msaitoh in ticket #1378:

sys/dev/pci/piixpm.c patch

Fix a bug that I2C access panics on old AMD chipset (e.g SB600).
Fixes PR kern/56525.
 1.54.2.1 16-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1017:

sys/dev/pci/piixpm.c 1.57-1.59, 1.61-1.63 via patch
sys/dev/pci/piixpmreg.h 1.9-1.12

- Fix number of port for Hudson rev. 0x1f and newer.
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI
config space but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI and 1 on IRQ, so invert the
check.
- Don't force using SMBUS0SEL register.
- Acquire/release host semaphore to share SMBus between the host and
the embedded controller (IMC). Without this change, "shutdown -r"
does power off and not boot on some machines.
- Save/restore port number before selecting port.
- Modify comment.
- Whitespace fix.
 1.60.2.1 17-Jan-2020  ad Sync with head.
 1.63.8.1 24-Mar-2021  thorpej Don't filter interface attributes in rescan functions for devices that
carry only a single interface attribute. The autoconfiguration machinery
already considers interface attributes when searching for possible parents.
 1.64.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.67.4.1 23-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #55):

sys/dev/pci/piixpm.c: revision 1.68
sys/dev/pci/piixpm.c: revision 1.69
sys/dev/pci/piixpmreg.h: revision 1.13
sys/dev/pci/piixpm.c: revision 1.70
sys/dev/pci/piixpm.c: revision 1.71
sys/dev/pci/piixpm.c: revision 1.72

Modify comment. Whitespace. No functional change.

Simplify and modify for following MMIO support. No functional change.
Modify for following MMIO support. No functional change.

Use MMIO for PM register access on newer revision's devices.
Newer revision's device only support memory mapped access. At least,
X670E's SMBus device that the revision ID is 0x71 doesn't support I/O
access. Use MMIO access for newer devices. Linux uses >= 0x51 for the
check, so we do the same check. Note that X570's SMBus(rev. 0x61) supports
I/O access...

Modify error message to match the current behavior.
 1.72.6.1 02-Aug-2025  perseant Sync with HEAD
 1.13 10-Jan-2023  msaitoh Use MMIO for PM register access on newer revision's devices.

Newer revision's device only support memory mapped access. At least,
X670E's SMBus device that the revision ID is 0x71 doesn't support I/O
access. Use MMIO access for newer devices. Linux uses >= 0x51 for the
check, so we do the same check. Note that X570's SMBus(rev. 0x61) supports
I/O access...
 1.12 14-Jan-2020  msaitoh branches: 1.12.24;
Add AMDFCH41_SMBUS_PORTMASK.
 1.11 09-Jan-2020  msaitoh Acquire/release host semaphore to share SMBus between the host and
the embedded controller (IMC).

Without this change, "shutdown -r" does power off and not boot on ECS HDC-I2.
This change fixes the problem.
 1.10 24-Dec-2019  msaitoh branches: 1.10.2;
Don't force using SMBUS0SEL register.

- Use it depending on USE_SMBUS0SEL bit.
- If we use SMBUS0EN_LO register to select the port, update the port
select bits only.
 1.9 23-Dec-2019  msaitoh - Read SB800_SMB_HOSTC correctly. This register is not in the PCI config space
but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the check.
- Modify comment.
- Whitespace fix.
 1.8 13-Jul-2019  msaitoh branches: 1.8.2;
Improve SB800 and newer chipsets support:
- Add newer chipset (e.g. X370/X399 and newer) support that the PCI device id
is 0x790b. The register definitions are mainly taken from FreeBSD.
- Rename PIIXPM_INDIRECTIO_* to SB800_INDIRECTIO_* because those are only
for SB800 and newer chipsets.
- SB800 also support 4 ports.
- SB800's interrupt configuration bit is different from others.
Use SB800_SMB_HOSTC's bit 0.
- Do not bus_space_map devices which are at address 0 (it's uninitialized)
in piixpm_attach().
- Add the port number to the dmesg output.
- Avoid uninitiliazed use of ctl and corresponding warnings. From OpenBSD rev.
1.38
 1.7 18-Mar-2014  riastradh branches: 1.7.22; 1.7.30;
Merge riastradh-drm2 to HEAD.
 1.6 22-Jul-2013  soren The SB800 SMBus controller has four selectable SDA lines.
Expose them as four iic busses.
 1.5 13-Feb-2011  hannken branches: 1.5.4; 1.5.10; 1.5.14; 1.5.18; 1.5.26;
The ServerWorks CSB5 smbus controller often times out and hangs until reboot.

Increase the delay between setting the command register and reading the
status register. Reset the smbus controller if it has timed out.

Tested on an IBM eServer x335.
 1.4 26-Jun-2006  drochner branches: 1.4.6; 1.4.84; 1.4.90; 1.4.92;
oops, need to commit the register definition for PM mapping too
 1.3 22-Jun-2006  jmcneill Add timecounter support for Intel PIIX Power Management Controllers.

Ok kardel@.
 1.2 17-Jun-2006  jmcneill branches: 1.2.2;
Restore the device activity PCI configuration registers on resume.
 1.1 07-May-2006  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12;
Add support for the Intel PIIX4 power management controller, from OpenBSD.
 1.1.12.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.10.2 01-Jun-2006  kardel Sync with head.
 1.1.10.1 07-May-2006  kardel file piixpmreg.h was added on branch simonb-timecounters on 2006-06-01 22:36:49 +0000
 1.1.8.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.8.1 07-May-2006  tron file piixpmreg.h was added on branch peter-altq on 2006-05-24 15:50:28 +0000
 1.1.6.4 11-Aug-2006  yamt sync with head
 1.1.6.3 26-Jun-2006  yamt sync with head.
 1.1.6.2 24-May-2006  yamt sync with head.
 1.1.6.1 07-May-2006  yamt file piixpmreg.h was added on branch yamt-pdpolicy on 2006-05-24 10:58:01 +0000
 1.1.4.1 19-Jun-2006  chap Sync with head.
 1.1.2.2 11-May-2006  elad sync with head
 1.1.2.1 07-May-2006  elad file piixpmreg.h was added on branch elad-kernelauth on 2006-05-11 23:28:48 +0000
 1.2.2.3 30-Dec-2006  yamt sync with head.
 1.2.2.2 21-Jun-2006  yamt sync with head.
 1.2.2.1 17-Jun-2006  yamt file piixpmreg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:06 +0000
 1.4.92.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.90.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.84.1 05-Mar-2011  rmind sync with head
 1.4.6.2 09-Sep-2006  rpaulo sync with head
 1.4.6.1 26-Jun-2006  rpaulo file piixpmreg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.5.26.1 23-Jul-2013  riastradh sync with HEAD
 1.5.18.1 28-Aug-2013  rmind sync with head
 1.5.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.10.1 20-Sep-2013  riz Pull up following revision(s) (requested by fair in ticket #936):
sys/dev/pci/piixpmreg.h: revision 1.6
sys/dev/pci/piixpm.c: revision 1.42
The SB800 SMBus controller has four selectable SDA lines.
Expose them as four iic busses.
 1.5.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.30.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.22.3 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1790:

sys/dev/pci/piixpm.c 1.66,1.68-1.72 via patch
sys/dev/pci/piixpmreg.h 1.13

Add support new AMD chipsets that do not have indirect access
I/O ports.
 1.7.22.2 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1591:

sys/dev/pci/piixpm.c 1.57-1.59,
1.61-1.63 via patch
sys/dev/pci/piixpmreg.h 1.9-1.12

- Fix number of port for Hudson rev. 0x1f and newer.
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI
config space but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the
check.
- Don't force using SMBUS0SEL register.
- Acquire/release host semaphore to share SMBus between the host and
the embedded controller (IMC). Without this change, "shutdown -r"
does power off and not boot on some machines.
- Save/restore port number before selecting port.
- Modify comment.
- Whitespace fix.
 1.7.22.1 06-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1327):

sys/dev/pci/piixpmreg.h: revision 1.8
sys/dev/pci/piixpm.c: revision 1.53
sys/dev/pci/piixpm.c: revision 1.54

Sync with OpenBSD's piixpm.c up to rev. 1.35:
- Print "polling" correctly when in the attach function. Same as OpenBSD
rev. 1.22-23.
- Improve debug printf()'s. Part of OpenBSD 1.24.
- Do not bus_space_map devices which are at address 0 (it's uninitialized).
Same as OpenBSD rev. 1.25.
- Add ServerWorks HT1100 device from OpenBSD. Same as OpenBSD rev. 1.32
- Use unique wait channel. From OpenBSD rev. 1.35


Improve SB800 and newer chipsets support:
- Add newer chipset (e.g. X370/X399 and newer) support that the PCI device id
is 0x790b. The register definitions are mainly taken from FreeBSD.
- Rename PIIXPM_INDIRECTIO_* to SB800_INDIRECTIO_* because those are only
for SB800 and newer chipsets.
- SB800 also support 4 ports.
- SB800's interrupt configuration bit is different from others.
Use SB800_SMB_HOSTC's bit 0.
- Do not bus_space_map devices which are at address 0 (it's uninitialized)
in piixpm_attach().
- Add the port number to the dmesg output.
- Avoid uninitiliazed use of ctl and corresponding warnings. From OpenBSD rev.
1.38
 1.8.2.2 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1573:

sys/dev/pci/piixpm.c 1.66,1.68-1.72 via patch
sys/dev/pci/piixpmreg.h 1.13

Add support new AMD chipsets that do not have indirect access
I/O ports.
 1.8.2.1 16-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1017:

sys/dev/pci/piixpm.c 1.57-1.59, 1.61-1.63 via patch
sys/dev/pci/piixpmreg.h 1.9-1.12

- Fix number of port for Hudson rev. 0x1f and newer.
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI
config space but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI and 1 on IRQ, so invert the
check.
- Don't force using SMBUS0SEL register.
- Acquire/release host semaphore to share SMBus between the host and
the embedded controller (IMC). Without this change, "shutdown -r"
does power off and not boot on some machines.
- Save/restore port number before selecting port.
- Modify comment.
- Whitespace fix.
 1.10.2.1 17-Jan-2020  ad Sync with head.
 1.12.24.1 23-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #55):

sys/dev/pci/piixpm.c: revision 1.68
sys/dev/pci/piixpm.c: revision 1.69
sys/dev/pci/piixpmreg.h: revision 1.13
sys/dev/pci/piixpm.c: revision 1.70
sys/dev/pci/piixpm.c: revision 1.71
sys/dev/pci/piixpm.c: revision 1.72

Modify comment. Whitespace. No functional change.

Simplify and modify for following MMIO support. No functional change.
Modify for following MMIO support. No functional change.

Use MMIO for PM register access on newer revision's devices.
Newer revision's device only support memory mapped access. At least,
X670E's SMBus device that the revision ID is 0x71 doesn't support I/O
access. Use MMIO access for newer devices. Linux uses >= 0x51 for the
check, so we do the same check. Note that X570's SMBus(rev. 0x61) supports
I/O access...

Modify error message to match the current behavior.
 1.1 17-May-2000  thorpej branches: 1.1.6;
Register definitions and preliminary API definition for the PLX 9060
family of PCI bus controllers.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 17-May-2000  bouyer file plx9060reg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:36 +0000
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 04-Feb-2005  perry de-__P
 1.1 17-May-2000  thorpej branches: 1.1.6; 1.1.30; 1.1.38; 1.1.40;
Register definitions and preliminary API definition for the PLX 9060
family of PCI bus controllers.
 1.1.40.1 12-Feb-2005  yamt sync with head.
 1.1.38.1 29-Apr-2005  kent sync with -current
 1.1.30.1 04-Feb-2005  skrll Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 17-May-2000  bouyer file plx9060var.h was added on branch thorpej_scsipi on 2000-11-20 11:42:36 +0000
 1.37 04-Jun-2025  macallan enable font loading
 1.36 04-Jun-2025  macallan make pipeline overrun protection in pm2fb_putchar_aa() actually work. Doh.
 1.35 25-Sep-2022  thorpej branches: 1.35.10;
Remove unnecessary include of <sys/malloc.h>.
 1.34 19-Dec-2021  andvar s/forground/foreground/ in comments.
 1.33 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.32 24-Apr-2021  thorpej branches: 1.32.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.31 22-Dec-2019  thorpej branches: 1.31.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.30 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.29 16-Dec-2016  macallan branches: 1.29.14; 1.29.16;
use hardware rendering for anti-aliased fonts
 1.28 16-Sep-2015  macallan branches: 1.28.2;
prop_dictionary_get_bool() doesn't return FALSE if the property doesn't
exist, so initialize things first.
No more console stealing on sparc64.
 1.27 17-Dec-2014  macallan - add support for Permedia 2
- make this work on alpha
from Naruaki Etomi
 1.26 09-Dec-2014  macallan begin to address PR 49229:
- program aperture endianness to match host, now xf86-video-wsfb works as
expected
- properly restore the colour map when er-entering terminal emulation
 1.25 09-Oct-2013  macallan branches: 1.25.6;
support WSDISPLAYIO_GET_FBINFO
 1.24 15-Sep-2013  martin Remove/comment out unused variables, initialize a few others.
 1.23 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.22 28-Jun-2013  christos branches: 1.22.2;
this could have never worked. Cleanup bogus code.
http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html
 1.21 06-Oct-2012  macallan don't crash when we're not the console
 1.20 04-Oct-2012  macallan support underlined characters
while there, make sure the glyph cache doesn't exceed 2048 lines since that's
the drawing engine's limit
 1.19 13-Sep-2012  macallan make video modes work that need a screen width which isn't directly supported
by the rendering engine - just use the next higher supported stride
 1.18 13-Sep-2012  macallan add mode setting support
While there, don't pretend to support the Permedia2 non-V - I don't have the
hardware and it has never been tested in the first place. The only hardware
this has been tested on is a TechSource Raptor GFX 8P / Sun PGX32 which
happens to be a Permedia2V with Sun firmware.
 1.17 12-Sep-2012  macallan support anti-aliased fonts in 8 bit
while there, fix pm2fb_bitblt() packed mode, for real this time
TODO:
- use packed mode when uploading glyphs
- let the hardware do the alpha blending if possible
- mode setting
 1.16 05-Sep-2012  macallan branches: 1.16.2;
fix horizontal scrolling in 8bit, while there use an R3G3B2 palette
 1.15 05-Sep-2012  macallan some preparations for mode setting support and such:
- DDC2 support, so far only used for WSDISPLAYIO_GET_EDID
- fix 8 bit support, use packed mode for some extra speed
- pm2 and pm2v have different DACs, deal with it where appropriate
 1.14 23-May-2012  macallan first step to fix PR 46461 - don't jump through a NULL pointer when we're
not the console but the firmware set up the graphics hardware anyway
 1.13 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.12 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.11 11-Jan-2012  macallan use rasops_init(0, 0)
 1.10 24-Nov-2011  macallan branches: 1.10.2;
fix debug build
 1.9 24-Nov-2011  macallan #include "opt_pm2fb.h"
 1.8 24-Nov-2011  macallan support DDC2, so far only for WSDISPLAYIO_GET_EDID
 1.7 22-Jan-2011  cegger branches: 1.7.4;
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.6 16-Dec-2010  cegger branches: 1.6.2; 1.6.4;
ioctl: KNF switch-case, remove useless brackets
 1.5 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.4 04-May-2010  macallan use alternate font if available ( for autogenerated box drawing characters )
 1.3 16-Mar-2010  macallan Implement character drawing by hardware so we don't need to map the framebuffer
anymore. Also do some cleanup, remove no longer relevant debugging code etc.
 1.2 28-Oct-2009  macallan branches: 1.2.2; 1.2.4; 1.2.6;
fix occasionally wrong colours in rectangle fills
 1.1 28-Oct-2009  macallan A driver for the Permedia 2 graphics processor, so far it's been tested only
on sparc64 with a Sun PGX32 / TechSource Raptor GFX 8P
So far it accelerates block copies, rectangle fills and the cursor, it
supports the usual wsdisplay / vcons stuff.
TODO:
- character drawing by hardware so we don't need to map the framebuffer
- DDC2 support
- mode setting
This driver still relies on the firmware to set up graphics modes etc. so it
won't work on x86 ( or non-OpenFirmware for that matter ) unless you use the
VESA BIOS to set up graphics and pass the right properties ( width, height
etc. ) to the driver. For the same reason it will work only if it's the
OpenFirmware console.
 1.2.6.2 05-Mar-2011  rmind sync with head
 1.2.6.1 30-May-2010  rmind sync with head
 1.2.4.3 11-Aug-2010  yamt sync with head.
 1.2.4.2 11-Mar-2010  yamt sync with head
 1.2.4.1 28-Oct-2009  yamt file pm2fb.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:59 +0000
 1.2.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.4.2 30-Oct-2012  yamt sync with head
 1.7.4.1 17-Apr-2012  yamt sync with head
 1.10.2.3 02-Jun-2012  mrg sync to latest -current.
 1.10.2.2 05-Apr-2012  mrg sync to latest -current.
 1.10.2.1 18-Feb-2012  mrg merge to -current.
 1.16.2.3 03-Dec-2017  jdolecek update from HEAD
 1.16.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.22.2.2 18-May-2014  rmind sync with head
 1.22.2.1 28-Aug-2013  rmind sync with head
 1.25.6.3 05-Feb-2017  skrll Sync with HEAD
 1.25.6.2 22-Sep-2015  skrll Sync with HEAD
 1.25.6.1 06-Apr-2015  skrll Sync with HEAD
 1.28.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.29.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.29.16.1 10-Jun-2019  christos Sync with HEAD
 1.29.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.31.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.32.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.35.10.1 02-Aug-2025  perseant Sync with HEAD
 1.12 16-Dec-2016  macallan flesh out alpha operations properly
 1.11 16-Dec-2016  macallan add bit definitions for dither and alpha blending registers
 1.10 17-Dec-2014  macallan branches: 1.10.2;
- add support for Permedia 2
- make this work on alpha
from Naruaki Etomi
 1.9 14-Dec-2014  macallan fix bit flip in PM2_DAC_COLOR_MODE register
from Naruaki Etomi
 1.8 12-Sep-2012  macallan branches: 1.8.14;
support anti-aliased fonts in 8 bit
while there, fix pm2fb_bitblt() packed mode, for real this time
TODO:
- use packed mode when uploading glyphs
- let the hardware do the alpha blending if possible
- mode setting
 1.7 05-Sep-2012  macallan branches: 1.7.2;
add a few more registers
 1.6 02-Feb-2012  macallan add a bunch of register definitions
not used yet but I better commit them now than have he tell me that I forgot
them when pm2fb.c starts using them
 1.5 24-Nov-2011  macallan branches: 1.5.2;
add MONITOR_DATA register
 1.4 16-Mar-2010  macallan branches: 1.4.8;
Implement character drawing by hardware so we don't need to map the framebuffer
anymore. Also do some cleanup, remove no longer relevant debugging code etc.
 1.3 30-Oct-2009  christos branches: 1.3.2; 1.3.4; 1.3.6;
spell the guys name properly.
 1.2 28-Oct-2009  macallan fix occasionally wrong colours in rectangle fills
 1.1 28-Oct-2009  macallan A driver for the Permedia 2 graphics processor, so far it's been tested only
on sparc64 with a Sun PGX32 / TechSource Raptor GFX 8P
So far it accelerates block copies, rectangle fills and the cursor, it
supports the usual wsdisplay / vcons stuff.
TODO:
- character drawing by hardware so we don't need to map the framebuffer
- DDC2 support
- mode setting
This driver still relies on the firmware to set up graphics modes etc. so it
won't work on x86 ( or non-OpenFirmware for that matter ) unless you use the
VESA BIOS to set up graphics and pass the right properties ( width, height
etc. ) to the driver. For the same reason it will work only if it's the
OpenFirmware console.
 1.3.6.1 30-May-2010  rmind sync with head
 1.3.4.3 11-Aug-2010  yamt sync with head.
 1.3.4.2 11-Mar-2010  yamt sync with head
 1.3.4.1 30-Oct-2009  yamt file pm2reg.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:59 +0000
 1.3.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.8.2 30-Oct-2012  yamt sync with head
 1.4.8.1 17-Apr-2012  yamt sync with head
 1.5.2.1 18-Feb-2012  mrg merge to -current.
 1.7.2.2 03-Dec-2017  jdolecek update from HEAD
 1.7.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.14.2 05-Feb-2017  skrll Sync with HEAD
 1.8.14.1 06-Apr-2015  skrll Sync with HEAD
 1.10.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.14 16-Jun-2025  macallan set & support RI_FULLCLEAR
now we get a clean console when X exits
 1.13 16-Jun-2025  macallan defflag PM3FB_DEBUG
wipe glyphcache when re-entering terminal mode
 1.12 27-May-2025  macallan add support for anti-aliased fonts
while there, enable support for font loading
 1.11 25-May-2025  macallan fix tpyo when calculating PM3_HORIZ_TOTAL - now mode setting works properly,
no more semi-random garbage at the right border
 1.10 14-Aug-2024  macallan initialize a screen even if we're not the console
 1.9 25-Sep-2022  thorpej branches: 1.9.10;
Remove unnecessary include of <sys/malloc.h>.
 1.8 25-Aug-2021  andvar Add missing RCSID and __KERNEL_RCSID().
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.5 22-Dec-2019  thorpej branches: 1.5.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.4 06-Mar-2017  macallan branches: 1.4.12; 1.4.16;
print out the actual stride value
 1.3 07-Dec-2016  macallan branches: 1.3.2; 1.3.4;
- don't flush the engine after every blitter operation
- make sure we don't overrun the pipeline in pm3fb_init()
 1.2 07-Dec-2016  macallan fix downward scrolling, set BUS_SPACE_MAP_PREFETCHABLE
 1.1 20-Nov-2016  macallan branches: 1.1.2;
add driver for Permedia 3 based graphics devices
from Naruaki Etomi, via PR 49518
 1.1.2.4 28-Aug-2017  skrll Sync with HEAD
 1.1.2.3 05-Feb-2017  skrll Sync with HEAD
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 20-Nov-2016  skrll file pm3fb.c was added on branch nick-nhusb on 2016-12-05 10:55:16 +0000
 1.3.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.3.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.3.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.3.2.1 07-Dec-2016  pgoyette file pm3fb.c was added on branch pgoyette-localcount on 2017-01-07 08:56:40 +0000
 1.4.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.12.2 03-Dec-2017  jdolecek update from HEAD
 1.4.12.1 06-Mar-2017  jdolecek file pm3fb.c was added on branch tls-maxphys on 2017-12-03 11:37:28 +0000
 1.5.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.9.10.1 02-Aug-2025  perseant Sync with HEAD
 1.4 27-May-2025  macallan add PM3_SOURCE_DATA register
 1.3 25-Aug-2021  andvar branches: 1.3.10;
Add missing RCSID and __KERNEL_RCSID().
 1.2 17-Jun-2017  macallan branches: 1.2.4;
moar registers
 1.1 20-Nov-2016  macallan branches: 1.1.2; 1.1.4;
add driver for Permedia 3 based graphics devices
from Naruaki Etomi, via PR 49518
 1.1.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.1 20-Nov-2016  pgoyette file pm3reg.h was added on branch pgoyette-localcount on 2017-01-07 08:56:40 +0000
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 20-Nov-2016  skrll file pm3reg.h was added on branch nick-nhusb on 2016-12-05 10:55:16 +0000
 1.2.4.2 03-Dec-2017  jdolecek update from HEAD
 1.2.4.1 17-Jun-2017  jdolecek file pm3reg.h was added on branch tls-maxphys on 2017-12-03 11:37:28 +0000
 1.3.10.1 02-Aug-2025  perseant Sync with HEAD
 1.76 29-Aug-2024  andvar improve grammar in the comment.
 1.75 26-Nov-2023  rin branches: 1.75.2;
ppb(4): Print out PCIe Gen5 link speed correctly
 1.74 10-Oct-2021  msaitoh branches: 1.74.4;
Use PCI-SIG official acronyms:

- RP stands for Root Port.
- RC stands for Root Complex.
- RCIEP stands for Root Complex Integrated End Point.
 1.73 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.72 11-May-2021  thorpej branches: 1.72.4;
Forward the bridge's devhandle to the downstream bus.
 1.71 24-Apr-2021  thorpej branches: 1.71.2; 1.71.4;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.70 12-Jul-2020  rin branches: 1.70.4;
Remove duplicate include of opt_ppb.h.
No binary changes.
 1.69 09-Jul-2019  msaitoh branches: 1.69.2;
Identify 16GT/s.
 1.68 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.67 29-Jan-2019  msaitoh If the secondary bus is configured and the bus mastering is not enabled,
enable it. Suggested by thorpej@.
 1.66 28-Jan-2019  msaitoh Explicitly enable bus masterling in case BIOS, UEFI or firmware don't enable
it. Might fix PR kern/53811.
 1.65 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.64 07-Dec-2018  msaitoh - defflag PPB_USEINTR
- Print "interrupting at "
 1.63 10-May-2017  msaitoh branches: 1.63.2; 1.63.8; 1.63.10;
Fix typos.
 1.62 09-May-2017  msaitoh - Fix a bug that a device which has no PCIe capability incorrectly
accessess the PCI config area in ppbdetach().
- Don't add event counters if slot interrupt isn't used.
 1.61 27-Apr-2017  msaitoh Make ppb(4) interrupt support stable:
- Disable all interrupts in the beginning of attach. Without this, interrupt
storm occurs while cold == 1 on some environment.
- Disable command complete interrput for a while to prevent hangup on some
enviroment. I'm sorry, I don't know what this bit is :-|
- Check all status bits and return 0 if an interrupt is not for me. It's
required for INTx. Tested on XEN3_DOM0 because it doesn't support MSI yet.
- Return 1 when a interrupt is processed.
 1.60 26-Apr-2017  msaitoh branches: 1.60.2;
Disable ppb(4)'s interrupt for a while. It causes hangup on some environment.
Define PPB_USEINTR if you'd like to use interrupt.
 1.59 26-Apr-2017  msaitoh Disable and disestablish interrupt in ppbdetach().
 1.58 24-Apr-2017  chs in ppbdetach(), try to detach the children before tearing down our own state,
to avoid trouble if detaching the children fails.
 1.57 18-Apr-2017  msaitoh Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count
status change event. HotPlug function itself have not implemented yet.

- Interrupt and each event are counted by evcnt(9). Example:

ppb0 Interrupt 0 0 intr
ppb0 Attention Button Pressed 0 0 misc
ppb0 Power Fault Detected 0 0 misc
ppb0 MRL Sensor Changed 0 0 misc
ppb0 Presence Detect Changed 0 0 misc
ppb0 Command Completed 0 0 misc
ppb0 Data Link Layer State Changed 0 0 misc

- Print message if ppb_printevent is not zero. The default vaule is 0.
The output messages:

Attention Button Pressed
Power Fault Detected
MRL Sensor Changed
Presence Detect Changed
Command Completed
Data Link Layer State Changed

- Remove workaround code to disable interrupt (ppb.c rev. 1.35).

Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround.
dmesg when bge's device timeout occured:

ppb3: Presence Detect Changed
ppb3: Data Link Layer State Changed
ppb3: Presence Detect Changed

vmstat -e |grep ppb

ppb3 Interrupt 2 0 intr
ppb3 Presence Detect Changed 2 0 misc
ppb3 Data Link Layer State Changed 1 0 misc
 1.56 05-Apr-2017  msaitoh Move struct ppb_softc into ppbvar.h.
 1.55 16-Nov-2015  msaitoh branches: 1.55.2; 1.55.4;
Define PCIE_XCAP_{VER,TYPE}(x) and use them.
 1.54 24-Sep-2014  msaitoh branches: 1.54.2;
Rename PCIE_XCAP_VER_* macros to avoid confusion.
 1.53 24-Sep-2014  msaitoh - Modify message of PCIe capability version. This field (PCIE_XCAP_VER_MASK)
is not specification's version number but the capability structure's version
number. To avoid confusion, print "PCI Express capability version x".
- The max number of PCIe lane is not 16 but 32. Fix the bug using with macro.
- Use macro instead of magic number.
- Gb/s -> GT/s
 1.52 21-Apr-2013  msaitoh branches: 1.52.10;
Delete "PCI_" from PCIX and PICE capability registers.
 1.51 06-Mar-2013  yamt ppb: fix link speed print
 1.50 20-Oct-2012  matt Print out negotiated link width and speed for PCIe (merged from
matt-nb5-mips64).
 1.49 29-Jan-2012  drochner branches: 1.49.6;
extend the pci_aprint_devinfo slightly to cover the cases commonly
used by drivers: a short name for the quiet/naive case and a string
to override the "pcidevs" based name by one provided by the driver,
ride on yesterday's kernel minor version bump
 1.48 26-Jan-2012  drochner put printing of the pci_devinfo into its own function (not inlined
by purpose) - this is a stack hog, and with this change my uTCA amd64
system boots again
a lot of similar code can be eliminated from pci device drivers this way,
but before doing so (and making the new function part of the module API)
I'd like to consider a modification to make it work with drivers which
prefer to print names from other sources (like pciide)
 1.47 21-Oct-2011  dyoung branches: 1.47.2; 1.47.6;
Tell a pci(4) instance its subordinate PCI buses using a new member
in the pcibus_attach_args, pba_sub. pciN attaches to pba_bus itself.
If pba_bus < pba_sub, then [pba_bus + 1, pba_sub] are subordinate to
pba_bus.

On i386, make mainbus0 attach pci0 with pba_sub = 255 because all buses
1 and up must be subordinate to pci0.

XXX Deal with other architectures.
 1.46 17-Aug-2011  dyoung Redefine PCI_MSI_* and PCI_PCIE_* constants in terms of bits(3).

Use named constants and more conventional variable names in
pci_msi_establish() and pci_msi_disestablish(). Fix a couple of bugs:
pci_msi_establish() returned a pointer to the struct intrhand instead of
to the struct msi_hdl as it was intended to, and pci_msi_disestablish()
did not free(9) the msi_hdl.
 1.45 10-Jan-2011  cegger add missing break
 1.44 10-Jan-2011  jmcneill ppb_fix_pcix changes:
- rename to ppb_fix_pcie
- support version PCI-E 2.0
- print version and device/port type information
- use constants from pcireg.h instead of magic numbers

changes:

ppb2 at pci0 dev 21 function 0: vendor 0x15ad product 0x07a0 (rev. 0x01)
ppb2: unsupported PCI Express version

to:

ppb2 at pci0 dev 21 function 0: vendor 0x15ad product 0x07a0 (rev. 0x01)
ppb2: PCI Express 2.0 <Root Port of PCI-E Root Complex>
 1.43 11-Dec-2010  matt On powerpc, recognize PCI Express RC root bridges.
 1.42 24-Feb-2010  dyoung branches: 1.42.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.41 08-Jan-2010  dyoung branches: 1.41.2;
Expand PMF_FN_* macros.
 1.40 02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.39 03-May-2008  cegger branches: 1.39.8; 1.39.10; 1.39.14; 1.39.18; 1.39.22;
device_t / softc split. Tested on amd64.
"looks good" spz
 1.38 03-May-2008  cegger unuspported -> unsupported
 1.37 22-Feb-2008  dyoung branches: 1.37.2; 1.37.4;
Add methods for detaching self and for detaching children.

Use device_t and accessors. Use aprint_*_dev().
 1.36 09-Dec-2007  jmcneill branches: 1.36.6; 1.36.10;
Merge jmcneill-pm branch.
 1.35 16-Oct-2007  joerg branches: 1.35.6; 1.35.8;
Merge 1.34.22.7 from jmcneill-pm:
Next attempt at trying to fix the irregular interrupt storms on my
Thinkpad: when we find a PCI Express device, check the list of
notification events and if any are sets, clear them. We can't handle
them ATM anyway.
 1.34 16-Nov-2006  christos branches: 1.34.8; 1.34.22; 1.34.24; 1.34.26;
__unused removal on arguments; approved by core.
 1.33 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32 11-Dec-2005  christos branches: 1.32.20; 1.32.22;
merge ktrace-lwp.
 1.31 28-Jun-2005  thorpej branches: 1.31.2;
Use ANSI function decls and static.
 1.30 04-Feb-2005  perry de-__P
 1.29 30-Aug-2004  drochner branches: 1.29.4; 1.29.6;
Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.28 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.27 09-Dec-2003  briggs Use aprint_*()
 1.26 15-Jun-2003  fvdl branches: 1.26.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.25 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.24 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.23 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.22 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.21 16-May-2002  thorpej branches: 1.21.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.20 13-Nov-2001  lukem add RCSID
 1.19 04-Nov-1999  thorpej branches: 1.19.6; 1.19.8;
Don't pass rd/mult capability though a PCI-PCI bridge. The bridge would
have to break it up into mutliple rd/line's anyhow, so why bother letting
the device issue it in the first place.
 1.18 08-Jun-1998  thorpej branches: 1.18.14; 1.18.16; 1.18.20;
Nuke __BROKEN_INDIRECT_CONFIG.
 1.17 04-Mar-1998  cgd clean up slightly, correct a few comments
 1.16 12-Jan-1998  thorpej branches: 1.16.2;
Update for config changes.
 1.15 30-Aug-1997  mycroft branches: 1.15.2; 1.15.4;
Pass down bus_dma_tag_t's as appropriate (per Jason's bus_dma code).
 1.14 30-Aug-1997  mycroft Pass the I/O and memory enable flags through the bridge.
 1.13 05-Dec-1996  cgd update these so they compile whether or not __BROKEN_INDIRECT_CONFIG
is defined.
 1.12 21-Oct-1996  thorpej New bus.h implementation/interface:
- No more distinction between i/o-mapped and memory-mapped
devices. It's all "bus space" now, and space tags
differentiate the space with finer grain than the
bus chipset tag.
- Add memory barrier methods.
- Implement space alloc/free methods.
- Implement region read/write methods (like memcpy to/from
bus space).
This interface provides a better abstraction for dealing with
machine-independent chipset drivers.
 1.11 13-Oct-1996  christos backout kprintf changes
 1.10 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.9 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.8 03-May-1996  christos remove unused variables
 1.7 27-Mar-1996  cgd modify these to provide a new, better-specified PCI interface
(soon to be documented on mailing lists; eventually in section 9 manual
pages), most importantly:
(1) support interrupt pin swizzling on non-i386 systems with
PCI-PCI bridges (per PPB spec; done, but meaningless, on i386).
(2) provide pci_{io,mem}_find(), to determine what I/O or memory
space is described by a given PCI configuration space
mapping register.
(3) provide pci_intr_map(), pci_intr_string(), and
pci_intr_{,dis}establish() to manipulate and print info about
PCI interrupts.
(4) make pci functions take as an argument a machine-dependent
cookie, to allow more flexibility in implementation.
 1.6 17-Mar-1996  cgd spacing nit
 1.5 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.4 14-Mar-1996  cgd These devices don't actually need softc's that are supersets of 'struct
device.' No point in adding that complexity + space if they're not needed,
so axe them.
 1.3 14-Mar-1996  cgd (1) provide #defines for cf_loc[] entries for devices that attach to
pcibus and pci.
(2) remove the #ifdef i386 from pci.c, and provide a machine-dependent
hook (pci_md_attach_hook()) to do any machine-dependent attachment
gunk, e.g. on the i386 printing out the configuration mode (if bus 0)
(3) don't pass max device number for a given bus in, use
PCI_MAX_DEVICE_NUMBER, which can be defined on a per-machine basis.
(defaults to 32. on i386, it's 32 if pci conf mode == 1, 16 if 2.)
 1.2 04-Mar-1996  cgd fix aux argument to config_found() for secondary bus.
 1.1 28-Feb-1996  cgd Preliminary support for PCI-PCI bridges. Recognize a PCI-PCI bridge
and attach the secondary pci bus as a 'pci' device. Note that this support
is incomplete and will not yet work for ports other than that i386. (The
i386 can rely on the PCI interrupt 'line' information to determine
interrupt mapping, which is not necessarily possible on other systems.)
 1.15.4.2 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.15.4.1 30-Aug-1997  thorpej file ppb.c was added on branch marc-pcmcia on 1997-09-01 20:29:55 +0000
 1.15.2.2 30-Aug-1997  mycroft Pass down bus_dma_tag_t's as appropriate (per Jason's bus_dma code).
 1.15.2.1 30-Aug-1997  mycroft file ppb.c was added on branch thorpej-bus-dma on 1997-08-30 06:53:59 +0000
 1.16.2.2 12-Jan-1998  thorpej Update for config changes.
 1.16.2.1 12-Jan-1998  thorpej file ppb.c was added on branch bouyer-scsipi on 1998-01-12 09:40:13 +0000
 1.18.20.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.16.1 15-Nov-1999  fvdl Sync with -current
 1.18.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.19.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.19.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.19.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.6.4 03-Jan-2003  thorpej Sync with HEAD.
 1.19.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.19.6.2 20-Jun-2002  nathanw Catch up to -current.
 1.19.6.1 14-Nov-2001  nathanw Catch up to -current.
 1.21.2.2 16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.21.2.1 16-May-2002  thorpej file ppb.c was added on branch gehenna-devsw on 2002-05-16 01:01:31 +0000
 1.26.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.26.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.26.2.2 03-Sep-2004  skrll Sync with HEAD
 1.26.2.1 03-Aug-2004  skrll Sync with HEAD
 1.29.6.1 12-Feb-2005  yamt sync with head.
 1.29.4.1 29-Apr-2005  kent sync with -current
 1.31.2.4 27-Feb-2008  yamt sync with head.
 1.31.2.3 21-Jan-2008  yamt sync with head
 1.31.2.2 27-Oct-2007  yamt sync with head.
 1.31.2.1 30-Dec-2006  yamt sync with head.
 1.32.22.2 10-Dec-2006  yamt sync with head.
 1.32.22.1 22-Oct-2006  yamt sync with head
 1.32.20.1 18-Nov-2006  ad Sync with head.
 1.34.26.1 18-Oct-2007  yamt sync with head.
 1.34.24.3 23-Mar-2008  matt sync with HEAD
 1.34.24.2 09-Jan-2008  matt sync with HEAD
 1.34.24.1 06-Nov-2007  matt sync with HEAD
 1.34.22.10 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.34.22.9 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.34.22.8 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.34.22.7 08-Oct-2007  joerg Next attempt at trying to fix the irregular interrupt storms on my
Thinkpad: when we find a PCI Express device, check the list of
notification events and if any are sets, clear them. We can't handle
them ATM anyway.
 1.34.22.6 04-Oct-2007  joerg Remove SCI hack as the ACPI EC issues are fixed and those were the
likely source of this problem.
 1.34.22.5 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.34.22.4 04-Sep-2007  joerg Disable PCI-E SCI on all ICH6+ chipsets.
 1.34.22.3 21-Aug-2007  joerg Disable SCI on the ICH6 PCI Express Ports -- if the BIOS enabled it
and such an event happened, the resulting interrupt storm would at
best keep the CPU over 40% busy and otherwise hang the box.

This is a bandaid until proper PCI Express support exists.
 1.34.22.2 08-Aug-2007  jmcneill Improve ppb power management support.
 1.34.22.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.34.8.1 23-Oct-2007  ad Sync with head.
 1.35.8.1 11-Dec-2007  yamt sync with head.
 1.35.6.1 26-Dec-2007  ad Sync with head.
 1.36.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.36.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.36.6.1 24-Mar-2008  keiichi sync with head.
 1.37.4.3 11-Mar-2010  yamt sync with head
 1.37.4.2 04-May-2009  yamt sync with head.
 1.37.4.1 16-May-2008  yamt sync with head.
 1.37.2.1 18-May-2008  yamt sync with head.
 1.39.22.1 07-Jan-2011  matt On powerpc systems, match powerpc processors which are really PCIe PPBs.
 1.39.18.4 15-Feb-2014  matt sync pcireg.h with HEAD.
update if_wm.c and ppb.c accordingly.
 1.39.18.3 24-Dec-2011  matt Pull latest from -HEAD.
Add printing bus lanes and speed.
 1.39.18.2 28-Jan-2010  matt Change ppb_fix_pcix to ppb_fix_pcie since pcix is usually PCI-X while
pcie is PCI-Express.
 1.39.18.1 21-Jan-2010  matt Support the SB1250 LDT HB.
 1.39.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.10.1 11-May-2013  riz Applied patch (requested by msaitoh in ticket #1844):

sys/dev/pci/pcireg.h 1.69
sys/dev/pci/ppb.c 1.44-1.45

Support PCI Express 2.0.
Print version and device/port type information
[msaitoh, ticket #1844]
 1.39.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.41.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.2.1 05-Mar-2011  rmind sync with head
 1.47.6.1 18-Feb-2012  mrg merge to -current.
 1.47.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.47.2.2 30-Oct-2012  yamt sync with head
 1.47.2.1 17-Apr-2012  yamt sync with head
 1.49.6.3 03-Dec-2017  jdolecek update from HEAD
 1.49.6.2 23-Jun-2013  tls resync from head
 1.49.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.52.10.1 12-Dec-2014  martin Pull up following revision(s) (requested by msaitoh in ticket #311):
sys/dev/pci/ppb.c: revision 1.53
sys/dev/pci/ppb.c: revision 1.54
sys/dev/pci/pcireg.h: revision 1.96
- Modify message of PCIe capability version. This field (PCIE_XCAP_VER_MASK)
is not specification's version number but the capability structure's version
number. To avoid confusion, print "PCI Express capability version x".
- The max number of PCIe lane is not 16 but 32. Fix the bug using with macro.
- Use macro instead of magic number.
- Gb/s -> GT/s
Rename PCIE_XCAP_VER_* macros to avoid confusion.
 1.54.2.2 28-Aug-2017  skrll Sync with HEAD
 1.54.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.55.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.55.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.60.2.2 11-May-2017  pgoyette Sync with HEAD
 1.60.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.63.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.63.10.1 10-Jun-2019  christos Sync with HEAD
 1.63.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.63.2.3 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1714:

sys/dev/pci/pcireg.h 1.148-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.217-1.222, 1.224, 1.227-1.232
via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158
sys/dev/pci/ppb.c 1.74

- Print Bridge Config Retry Enable bit and Retimer Presence Detect
Supported bit.
- Add PCIe 4.0 stuff a little:
- 10-bit Tag Requester/Completer.
- Add Data link Feature extended capability.
- Add Physical Layer 16.0 GT/s extended capability. Not decode yet.
- Change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack.
- Print some DPC register values not with %04x but with %08x because
those are 32bit.
- Fix a bug that the virtual channel extended configuration's
arbitration phase register can't be decoded correctly.
- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Remove unused shift and mask definitions.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.63.2.2 17-Jul-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1295):

sys/dev/pci/pci_subr.c: revision 1.213
sys/dev/pci/ppb.c: revision 1.69

Identify 16GT/s.
 1.63.2.1 01-Feb-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1181):

sys/dev/pci/ppb.c: revision 1.66
sys/dev/pci/ppb.c: revision 1.67

Explicitly enable bus masterling in case BIOS, UEFI or firmware don't enable
it. Might fix PR kern/53811.

-

If the secondary bus is configured and the bus mastering is not enabled,
enable it. Suggested by thorpej@.
 1.69.2.1 03-Dec-2021  martin Pull up the following revisions, requested by msaitoh in ticket #1384:

sys/dev/pci/pcireg.h 1.152-1.154, 1.156-1.161
sys/dev/pci/pci_subr.c 1.222, 1.227-1.232 via patch
sys/dev/pci/nvme_pci.c 1.31
sys/dev/pci/pci.c 1.158, 1.163
sys/dev/pci/ppb.c 1.74

- When parsing Enhanced Allocation entries, use the correct calculation
for finding the next entry.
- Add 32.0GT/s to the list of pcie speeds (PCIe 5.x.).
- Add Some PCI config information:
- Lane Margining at the Receiver
- NVME admin interface
- UFSHCI
- InfiniBand
- Host fabric
- HDA 1.0 with vendor ext
- USB4 HCI
- MIPI I3C
- Cellular controller/modem (+ Ethernet)
- Change PCI_VENDOR_MASK and PCI_PRODUCT_MASK to unsigned values, to
prevent sign extension of product ID when shifted up into place in
PCI_ID_CODE(). Fixes PR kern/56176.
- Add LCAP & LCAP2 definitions.
- Use PCI-SIG official acronyms for some macros.
- Fix typo in some messages.
- Fix typo in comments.
- Whitespace fixes.
 1.70.4.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.71.4.1 31-May-2021  cjep sync with head
 1.71.2.1 13-May-2021  thorpej Sync with HEAD.
 1.72.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.74.4.1 06-Feb-2024  martin Pull up following revision(s) (requested by rin in ticket #588):

sys/dev/pci/ppb.c: revision 1.75

ppb(4): Print out PCIe Gen5 link speed correctly
 1.75.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.9 02-Jul-2018  msaitoh VGA 16 bit decode bit is not bit 3 but bit 4.
 1.8 18-Dec-2017  msaitoh branches: 1.8.2; 1.8.4;
Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.

NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.
 1.7 10-May-2017  msaitoh branches: 1.7.2;
Fix typos.
 1.6 11-Dec-2005  christos branches: 1.6.120; 1.6.140; 1.6.154;
merge ktrace-lwp.
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 08-Nov-2001  thorpej branches: 1.4.16; 1.4.24; 1.4.26;
Fix the Bridge Control Register bit definitions, add ones that
appeared in PCI 2.2.
 1.3 06-Jul-2001  mcr branches: 1.3.2; 1.3.6;
added bridge secondary bus reset macros.
 1.2 14-Mar-1996  cgd branches: 1.2.42;
(1) provide #defines for cf_loc[] entries for devices that attach to
pcibus and pci.
(2) remove the #ifdef i386 from pci.c, and provide a machine-dependent
hook (pci_md_attach_hook()) to do any machine-dependent attachment
gunk, e.g. on the i386 printing out the configuration mode (if bus 0)
(3) don't pass max device number for a given bus in, use
PCI_MAX_DEVICE_NUMBER, which can be defined on a per-machine basis.
(defaults to 32. on i386, it's 32 if pci conf mode == 1, 16 if 2.)
 1.1 28-Feb-1996  cgd Preliminary support for PCI-PCI bridges. Recognize a PCI-PCI bridge
and attach the secondary pci bus as a 'pci' device. Note that this support
is incomplete and will not yet work for ports other than that i386. (The
i386 can rely on the PCI interrupt 'line' information to determine
interrupt mapping, which is not necessarily possible on other systems.)
 1.2.42.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.42.1 24-Aug-2001  nathanw Catch up with -current.
 1.3.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.3.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.26.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.24.1 29-Apr-2005  kent sync with -current
 1.4.16.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.154.1 11-May-2017  pgoyette Sync with HEAD
 1.6.140.1 28-Aug-2017  skrll Sync with HEAD
 1.6.120.1 03-Dec-2017  jdolecek update from HEAD
 1.7.2.2 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #933):
sys/dev/pci/pci_subr.c: revision 1.202
sys/dev/pci/pcireg.h: revision 1.139
sys/dev/pci/ppbreg.h: revision 1.9
VGA 16 bit decode bit is not bit 3 but bit 4.
--
- Print Power Management Control/status register in 32bit.
- Simplify.
 1.7.2.1 26-Feb-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #576):
sys/dev/pci/pci_subr.c: 1.197-1.200
sys/dev/pci/pcireg.h: 1.136-1.137
sys/dev/pci/ppbreg.h: 1.8
Add VGA 16bit decode bit into the PCI bridge control register. This bit is
defined in PCI-to-PCI Bridge Architecture Specification Revision 1.2. This
bit has meaning if the VGA enable bit or the VGA Palette Snoop Enable bit is
set.
NOTE: sys/arch/x86/pci/pci_ranges.c::mmio_range_extend_by_vga_enable() and/or
some other functions should be modified.
"s/above 300W/greater than 300W/" in pci_conf_print_pcie_power(). From
PCIe Base Spec 3.1a Errata 2017-12-13.
Cleanup:
- Don't pass a capability pointer as a argument of pci_conf_find_cap() and
determine the first pointer in the pci_conf_find_cap() function.
- Don't pass a capability pointer as a argument of pci_conf_find_extcap()
because it's not used.
- Remove unsed code.
- Add PCie Link Activation ECN.
- Use macro.
- KNF.
 1.8.4.1 10-Jun-2019  christos Sync with HEAD
 1.8.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.4 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.3 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.2 18-Apr-2017  msaitoh branches: 1.2.2; 1.2.4; 1.2.12; 1.2.16; 1.2.32;
Enable PCIe's interrupt as much as possilbe in ppb(4) to detect and count
status change event. HotPlug function itself have not implemented yet.

- Interrupt and each event are counted by evcnt(9). Example:

ppb0 Interrupt 0 0 intr
ppb0 Attention Button Pressed 0 0 misc
ppb0 Power Fault Detected 0 0 misc
ppb0 MRL Sensor Changed 0 0 misc
ppb0 Presence Detect Changed 0 0 misc
ppb0 Command Completed 0 0 misc
ppb0 Data Link Layer State Changed 0 0 misc

- Print message if ppb_printevent is not zero. The default vaule is 0.
The output messages:

Attention Button Pressed
Power Fault Detected
MRL Sensor Changed
Presence Detect Changed
Command Completed
Data Link Layer State Changed

- Remove workaround code to disable interrupt (ppb.c rev. 1.35).

Tested with Dell Latitude 2120 without if_bge.c rev. 1.304's workaround.
dmesg when bge's device timeout occured:

ppb3: Presence Detect Changed
ppb3: Data Link Layer State Changed
ppb3: Presence Detect Changed

vmstat -e |grep ppb

ppb3 Interrupt 2 0 intr
ppb3 Presence Detect Changed 2 0 misc
ppb3 Data Link Layer State Changed 1 0 misc
 1.1 05-Apr-2017  msaitoh Move struct ppb_softc into ppbvar.h.
 1.2.32.1 20-Apr-2020  bouyer Sync with HEAD
 1.2.16.2 03-Dec-2017  jdolecek update from HEAD
 1.2.16.1 18-Apr-2017  jdolecek file ppbvar.h was added on branch tls-maxphys on 2017-12-03 11:37:28 +0000
 1.2.12.2 28-Aug-2017  skrll Sync with HEAD
 1.2.12.1 18-Apr-2017  skrll file ppbvar.h was added on branch nick-nhusb on 2017-08-28 17:52:25 +0000
 1.2.4.2 26-Apr-2017  pgoyette Sync with HEAD
 1.2.4.1 18-Apr-2017  pgoyette file ppbvar.h was added on branch pgoyette-localcount on 2017-04-26 02:53:22 +0000
 1.2.2.2 21-Apr-2017  bouyer Sync with HEAD
 1.2.2.1 18-Apr-2017  bouyer file ppbvar.h was added on branch bouyer-socketcan on 2017-04-21 16:53:51 +0000
 1.42 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.41 24-Apr-2021  thorpej branches: 1.41.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.40 30-Nov-2018  jmcneill branches: 1.40.14;
Add support for polling com devices when no interrupt is available.
 1.39 07-Jul-2016  msaitoh branches: 1.39.16; 1.39.18;
KNF. Remove extra spaces. No functional change.
 1.38 04-May-2015  ryo PR/49819: Roberto E. Vargas Caballero: Add support for SystemBase SB16C1050 PCI serial card
 1.37 07-Feb-2014  msaitoh branches: 1.37.6;
s/mesage/message/
 1.36 23-Jul-2013  soren Restrict the hack for offset BAR's to x86.
A cleaner fix requires a rewrite of puc.c, but not today.
 1.35 22-Jul-2013  soren Oops.
 1.34 22-Jul-2013  martin Unbreak the build - soren, please review!
 1.33 22-Jul-2013  soren Allow console on com_puc without a compile-time option so that PC servers
can become headless after the first reboot (sadly, e.g. Intel AMT presents
as a com_puc, but doesn't appear in the BIOS serial port table, so you need
a keyboard and monitor to install and set the installboot parameters first).

Fix com_puc console on devices with offset BAR's.
 1.32 28-May-2011  ryo branches: 1.32.4; 1.32.14; 1.32.18; 1.32.26;
Add support for SYSTEMBASE SB16C105x 4-port/8-port serial PCI cards.

- Added initialize code for SB16C105x to puc.c, but
It is better to add a member (*config_function)() to
struct puc_device_description and use it
- It seems SB16C1054 *rev 0x91* has different BAR layout, but not supported yet.
 1.31 09-Jul-2008  joerg branches: 1.31.16; 1.31.22;
- device/softc split
 1.30 10-Apr-2008  cegger branches: 1.30.4; 1.30.6; 1.30.8; 1.30.10;
use aprint_*_dev and device_xname
 1.29 16-Nov-2006  christos branches: 1.29.48;
__unused removal on arguments; approved by core.
 1.28 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.27 11-Dec-2005  christos branches: 1.27.20; 1.27.22;
merge ktrace-lwp.
 1.26 26-Aug-2005  drochner kill some more simple submatch() functions, use config_stdsubmatch()
 1.25 25-Aug-2005  drochner replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
 1.24 28-Jun-2005  thorpej branches: 1.24.2;
Use ANSI function decls and static.
 1.23 27-Feb-2005  perry nuke trailing whitespace
 1.22 04-Feb-2005  perry de-__P
 1.21 13-Sep-2004  drochner branches: 1.21.4; 1.21.6;
a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.20 03-Feb-2004  fredb Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.19 25-Jan-2004  jdolecek pass the DMA tags to child devices, too
 1.18 19-Mar-2003  christos branches: 1.18.2;
It is not appropriate for pcivar.h to include "locators.h"
The two files that need it, should include it themselves.
 1.17 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.12 13-Nov-2001  lukem add RCSID
 1.11 02-Mar-2001  thorpej branches: 1.11.2; 1.11.4;
In the self-describing bogus code block, at least use plausible
subclass IDs.
 1.10 03-Jan-2001  bouyer Add a 'flag' member to struct puc_attach_args and struct port. For
PUC_PORT_TYPE_COM, use it to store the clock frequency (with 8 lower bits
to 0, used for real flags if needed).
Update all descriptions to set flags to 0 for LPT or COM_FREQ for COM.
Add support for the VScom PCI-800H 8 port serial adapter (which uses
a 14.7456 Mhz crystal instead of the standart 1.8432Mhz :)
XXX now that we can pass other frequency than COM_FREQ, the VScom PCI-800
entry could probably be updated to DTRT - does anyone have one ?
 1.9 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.8 29-Jul-2000  jhawk Whitespace fix (space rather than tab after #ifdef)
 1.7 29-Jul-2000  jlam Make this compile without PUCCN defined.
 1.6 28-Jul-2000  castor Guard the console code in puc.c with the defopt PUCCN so we can
use the puc driver without having the com drivers.
 1.5 25-Jul-2000  jeffs Add code to allow the PCI com serial ports to be used as the system
console. This is not enabled by default, and is turned on with
options PUCCN. Done by castor@netbsd.org.
 1.4 17-Apr-2000  cgd branches: 1.4.4;
#if 0 the (way bogus) PCI_CLASS_COMMUNICATIONS/PCI_SUBCLASS_BRIDGE_PCI (!!!)
match pointed out (again?) by Johan Danielsson, after i repeatedly told
him not to do something similar in com_cardbus.
 1.3 06-Feb-1999  cgd branches: 1.3.8;
add code to cope with multiple ports per BAR, as are found, for instance,
on the 8 port card Simon Gerraty has. In general, cards which have
this lots of ports also have a separate interrupt status register, but
this change is just to talk to the various ports independently. It works,
but it's not optimal. (XXX still need a good name for the card in the
comments, and to update the manual page.)
 1.2 21-Dec-1998  drochner use a symbolic definition for the PCI subsystem ID
 1.1 26-Jun-1998  cgd add a driver for "PCI 'universal' communications" cards, that is, PCI cards
which contain 'standard' com- and lpt-type ports. Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not. (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.) Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
 1.3.8.3 12-Mar-2001  bouyer Sync with HEAD.
 1.3.8.2 05-Jan-2001  bouyer Sync with HEAD
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.2 22-Mar-2001  he Apply patch (requested by he):
The function puc_find_description() is now external, so make it so.
 1.4.4.1 22-Mar-2001  he Pull up revisions 1.10-1.11 (requested by sommerfeld):
Add support for NetMos NM9835, Titan PCI-800H, Lava 8-port,
Actiontec 56K PCI Master. This also adds a ``flags'' member
to two structs in this driver.
 1.11.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.3 03-Jan-2003  thorpej Sync with HEAD.
 1.11.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.11.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.18.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.18.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.6.1 12-Feb-2005  yamt sync with head.
 1.21.4.1 29-Apr-2005  kent sync with -current
 1.24.2.2 30-Dec-2006  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.27.22.2 10-Dec-2006  yamt sync with head.
 1.27.22.1 22-Oct-2006  yamt sync with head
 1.27.20.1 18-Nov-2006  ad Sync with head.
 1.29.48.2 28-Sep-2008  mjf Sync with HEAD.
 1.29.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.30.10.1 19-Oct-2008  haad Sync with HEAD.
 1.30.8.1 18-Jul-2008  simonb Sync with head.
 1.30.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.4.1 04-May-2009  yamt sync with head.
 1.31.22.1 06-Jun-2011  jruoho Sync with HEAD.
 1.31.16.1 31-May-2011  rmind sync with head
 1.32.26.1 23-Jul-2013  riastradh sync with HEAD
 1.32.18.2 18-May-2014  rmind sync with head
 1.32.18.1 28-Aug-2013  rmind sync with head
 1.32.14.2 03-Dec-2017  jdolecek update from HEAD
 1.32.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.6.2 09-Jul-2016  skrll Sync with HEAD
 1.37.6.1 06-Jun-2015  skrll Sync with HEAD
 1.39.18.1 10-Jun-2019  christos Sync with HEAD
 1.39.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.40.14.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.40.14.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.41.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.14 05-Mar-2014  msaitoh No functional change:
- Rename function for consistency.
- Add prototypes.
- KNF.
 1.13 26-Jan-2014  msaitoh PUCCN improvements:
- Fix a bug that the puc cn mechanism doesn't use the UART's frequency
in pucdata.c's table.

- Add a new option PUC_CNAUTO. If this option is set, consinit() in
x86/x86/consinit.c checks puc com device to use it as console.
Without this option, the behavior is the same as before.

- Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
If PUC_CNBUS is set, the specified number's bus will be scanned.

- Rename comcnprobe() to puc_cnprobe() to make it clear.

- Rename comcninit() to puc_cninit() to make it clear.

- Add code for a device that a device's com register is MMIO (#if0 ed).
 1.12 23-Jan-2014  msaitoh Add comments and KNF. No functional change.
 1.11 22-Jul-2013  soren Allow console on com_puc without a compile-time option so that PC servers
can become headless after the first reboot (sadly, e.g. Intel AMT presents
as a com_puc, but doesn't appear in the BIOS serial port table, so you need
a keyboard and monitor to install and set the installboot parameters first).

Fix com_puc console on devices with offset BAR's.
 1.10 28-Apr-2010  dyoung branches: 1.10.8; 1.10.18; 1.10.22; 1.10.30;
On x86, change the bus_space_tag_t to a pointer to a struct
bus_space_tag. For now, bus_space_tag's only member is
bst_type, the type of space, which is either X86_BUS_SPACE_IO
or X86_BUS_SPACE_MEM. In the future, new bus_space_tag members
will refer to override-functions installed by a new function,
bus_space_tag_create(9).

Add pointers to constant struct bus_space_tag, x86_bus_space_io and
x86_bus_space_mem. Use them to replace most uses of X86_BUS_SPACE_IO
and X86_BUS_SPACE_MEM.

Add an x86-specific bus_space_is_equal(9) implementation that compares
the two tags' bst_type.
 1.9 13-Jan-2007  cube branches: 1.9.44; 1.9.66; 1.9.68;
Work around false-positives for gcc's detection of use of uninitialised
variables.
 1.8 11-Dec-2005  christos branches: 1.8.20;
merge ktrace-lwp.
 1.7 27-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 14-Jun-2003  thorpej branches: 1.6.2; 1.6.10; 1.6.12;
Also pass a type argument to comcnattach() and com_kgdb_attach().
comspeed() (and thus cominit()) may need this information.
 1.5 29-Mar-2003  matt Make this compile again.
 1.4 13-Nov-2001  lukem add RCSID
 1.3 30-May-2001  lukem branches: 1.3.2;
add missing #include "opt_kgdb.h"
 1.2 09-Dec-2000  imp branches: 1.2.2;
Change $Id: to $NetBSD$
 1.1 25-Jul-2000  jeffs branches: 1.1.2;
Add code to allow the PCI com serial ports to be used as the system
console. This is not enabled by default, and is turned on with
options PUCCN. Done by castor@netbsd.org.
 1.1.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 25-Jul-2000  bouyer file puccn.c was added on branch thorpej_scsipi on 2000-11-20 11:42:36 +0000
 1.2.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.10.1 29-Apr-2005  kent sync with -current
 1.6.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.4.1 26-Feb-2007  yamt sync with head.
 1.8.20.1 01-Feb-2007  ad Sync with head.
 1.9.68.1 30-May-2010  rmind sync with head
 1.9.66.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.9.44.1 11-Aug-2010  yamt sync with head.
 1.10.30.1 23-Jul-2013  riastradh sync with HEAD
 1.10.22.2 18-May-2014  rmind sync with head
 1.10.22.1 28-Aug-2013  rmind sync with head
 1.10.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7 05-Mar-2014  msaitoh No functional change:
- Rename function for consistency.
- Add prototypes.
- KNF.
 1.6 26-Jan-2014  msaitoh PUCCN improvements:
- Fix a bug that the puc cn mechanism doesn't use the UART's frequency
in pucdata.c's table.

- Add a new option PUC_CNAUTO. If this option is set, consinit() in
x86/x86/consinit.c checks puc com device to use it as console.
Without this option, the behavior is the same as before.

- Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
If PUC_CNBUS is set, the specified number's bus will be scanned.

- Rename comcnprobe() to puc_cnprobe() to make it clear.

- Rename comcninit() to puc_cninit() to make it clear.

- Add code for a device that a device's com register is MMIO (#if0 ed).
 1.5 22-Jul-2013  soren Allow console on com_puc without a compile-time option so that PC servers
can become headless after the first reboot (sadly, e.g. Intel AMT presents
as a com_puc, but doesn't appear in the BIOS serial port table, so you need
a keyboard and monitor to install and set the installboot parameters first).

Fix com_puc console on devices with offset BAR's.
 1.4 11-Dec-2005  christos branches: 1.4.110; 1.4.120; 1.4.126; 1.4.134;
merge ktrace-lwp.
 1.3 08-Jul-2003  itojun function prototype must not have variable name
 1.2 09-Dec-2000  imp branches: 1.2.24;
Change $Id: to $NetBSD$
 1.1 25-Jul-2000  jeffs branches: 1.1.2;
Add code to allow the PCI com serial ports to be used as the system
console. This is not enabled by default, and is turned on with
options PUCCN. Done by castor@netbsd.org.
 1.1.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 25-Jul-2000  bouyer file puccn.h was added on branch thorpej_scsipi on 2000-11-20 11:42:36 +0000
 1.2.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.24.1 03-Aug-2004  skrll Sync with HEAD
 1.4.134.1 23-Jul-2013  riastradh sync with HEAD
 1.4.126.2 18-May-2014  rmind sync with head
 1.4.126.1 28-Aug-2013  rmind sync with head
 1.4.120.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.110.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.119 03-May-2025  rin puc(4): Add support to EXAR XR17D358

Tested on M.2 card model.
 1.118 12-Dec-2024  msaitoh puc(4): Add some Oxford Semiconductor devices support from FreeBSD.
 1.117 11-Nov-2024  msaitoh Add many Brainboxes devices. Repoted in PR/kern 58824 by Cameron Williams.
 1.116 23-Jun-2024  jakllsch branches: 1.116.2;
Add Brainboxes puc(4) devices

From Cameron Williams in PR 58358.
 1.115 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.114 29-Jan-2023  thorpej Add and entry for the EXAR XR17V354 4-port UART.

From HÃ¥kan Engvall.
PR kern/57202
 1.113 01-May-2022  mrg branches: 1.113.4;
attach the other pciid for intel 100 series KT serial.

seen on a thinkpad 460s.
 1.112 12-Oct-2021  msaitoh Add Intel 400 Series PCH-V devices.
 1.111 11-Oct-2021  msaitoh Add some Intel KT devices.
 1.110 17-Jul-2021  riastradh puc(4): Add Intel Core 5G (mobile) KT.
 1.109 02-Feb-2021  bouyer branches: 1.109.4;
Also match Oxford Semiconductor Exsys EX-41098 PCI UARTs
 1.108 13-Jun-2020  ryo branches: 1.108.2;
add entry for ASIX AX99100 PCIe 4port serial card
 1.107 05-Apr-2020  ryo add entry for NetMos NM9900 Octa UART

notice: On the boards I've obtained, the number on the cable stamp
doesn't match the actual unit number of the attached device.
Cable's 0,1,2,..,7 corresponds to comN+0,2,4,6,1,3,5,7 :-(
 1.106 24-Mar-2020  ryo add entry for NetMos NM9900 Quad UART.

The NM9900 seems to have variations such as 4UART and 2UART+1Printer,
but I tested on 4UART board.
 1.105 14-Nov-2019  hauke The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.

ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}
 1.104 02-May-2019  jdolecek branches: 1.104.2;
add NetMos NM9912 entries

PR kern/54149 by Mouse
 1.103 29-Nov-2018  jmcneill Add Amazon.com EC2 virtual 16650-compatible PCI serial device
 1.102 21-May-2018  jnemeth branches: 1.102.2;
add Oxford Semiconductor OXPCIe954 PCIe 4-port serial card
 1.101 13-Apr-2018  msaitoh Add 300 series chipset support.
 1.100 27-Dec-2017  christos branches: 1.100.2;
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card
 1.99 15-Jan-2017  msaitoh branches: 1.99.8;
Add Intel 200 series devices.
 1.98 01-Dec-2015  msaitoh branches: 1.98.2;
Add Intel 100 Series chipset's devices.
 1.97 23-Aug-2015  jakllsch whitespace
 1.96 23-Aug-2015  jakllsch Support PCI_PRODUCT_INTEL_82Q45_KT_1 in addition to PCI_PRODUCT_INTEL_82Q45_KT.
 1.95 04-May-2015  ryo PR/49819: Roberto E. Vargas Caballero: Add support for SystemBase SB16C1050 PCI serial card
 1.94 18-Mar-2015  msaitoh Add 9 Series support.
 1.93 06-Feb-2014  msaitoh branches: 1.93.4; 1.93.6;
USE PCI_BAR[0-5]. Part of PR#48016.
 1.92 26-Jan-2014  msaitoh Add some OXPCIe952 devices.
 1.91 23-Jan-2014  msaitoh Add entry for Intel Quark X1000 UART.
 1.90 20-Jan-2014  msaitoh Fix a bug that EG20T's UARTs from #1 to #3 never match.
Tested with my MinnowBoard.
 1.89 25-Dec-2013  msaitoh Add DIGI Neo 8-port serial(PCIe) and OXFORD OXPCIe952 Parallel.
 1.88 25-Dec-2013  msaitoh Add support S1200's UART. Part of PR#48016.
 1.87 07-Nov-2013  msaitoh Add some Mobile 4th generation Intel Core Processor devices
(Lynx Point-LP).
 1.86 04-Sep-2013  christos PR/48180: Christian Groessler: Support for Oxford Semi OXuPCI952 dual serial
PCI card
 1.85 17-Jul-2013  soren Extend support for Nanjing QinHeng Electronics puc(4) devices.
 1.84 03-Jun-2013  msaitoh branches: 1.84.2; 1.84.4;
Add Intel 8 Series KT.
 1.83 19-Dec-2012  msaitoh space change.
 1.82 18-Oct-2012  msaitoh - Indent.
- Fix some product names or device names.
 1.81 25-Sep-2012  gson Add Lava Computers SSERIAL-PCI single port serial PCI card.
 1.80 15-Aug-2012  msaitoh branches: 1.80.2;
Add EXSYS EX-41098-2 UARTs support. The clock frequency is
different from other card(s).
Fixes PR#46362 reported by Wolfgang Stukenbrock.
 1.79 07-Aug-2012  msaitoh Add some Intel's KT (Serial over LAN) devices.
 1.78 05-Aug-2012  msaitoh Use PCI_VENDOR_* and PCI_PRODUCT_*. Fixes PR#46303.
 1.77 27-Jul-2012  matt Add EG20T UART entries.
Closes PR/45567.
 1.76 09-Aug-2011  dyoung branches: 1.76.2; 1.76.8;
Add support for the Oxford Semiconductor OXPCIe952, a 2-port serial chip
with a PCI Express interface, in legacy mode. Cursorily tested with a
StarTech PEX2S952LP.

See the manual for your adapter to see how to put it into legacy mode.
There is also a "native" mode that uses a different clock multiplier
and (I think) provides a richer feature set, but also requires a bit of
additional initialization (see FreeBSD's puc(4)).

The native-mode PCI functions use different PCI Device IDs than the
legacy-mode functions.
 1.75 28-May-2011  ryo Add support for SYSTEMBASE SB16C105x 4-port/8-port serial PCI cards.

- Added initialize code for SB16C105x to puc.c, but
It is better to add a member (*config_function)() to
struct puc_device_description and use it
- It seems SB16C1054 *rev 0x91* has different BAR layout, but not supported yet.
 1.74 14-May-2011  martin PR kern/44956: add support for Qinheng PCI cards to the puc driver
 1.73 02-May-2011  manu Add support for new SUNIX PCI seriel and/or parallel adapters, with new
SUNIX vendor Id 0x1fd4 and product Id 0x1999. Constants were taken from
Linux open source driver distributed by SUNIX.

The following models should be supported now:
5008 1 parallel port
5016 16 serial ports, only 8 supported right now (PUC_MAX_PORTS limit)
5027 1 serial port
5037 2 serial ports
5056 4 serial ports
5066 8 serial ports, this model is the only one that was actually tested.
5069 1 serial port and 1 parallel port
5079 2 serial ports and 1 parallel port
5099 4 serial ports and 1 parallel port
 1.72 02-May-2011  manu Add new PCI vendor Id for Sunix, and the corresponding device Id.
 1.71 11-Mar-2011  he Add two NetMos NM9865 1-port and 2-port controllers, as found in
2x and 1x on a 4-port card sold as Sunsway/ST Lab I-430.
 1.70 20-Feb-2011  msaitoh - Add support for Moschip NM9904 and NM9922. These devices use PCI multi
function, so only one PUC_PORT_TYPE_COM entry is used in these devices.
- Use macro.
 1.69 01-Aug-2010  msaitoh branches: 1.69.2; 1.69.4;
Add the following cards' support from FreeBSD:
- Comtrol RocketPort 550/4, 550/8 and 550/16 series
- Lava Computers Quatro-PCI
- some NetMos NM9865 cards
- VScom PCI-200Li
 1.68 13-Jul-2010  msaitoh Add three card support from Tsubai.
- Advantech PCI-1604UP (2S)
- InnoSys Keyspan SX Pro (4S)
- I-O DATA RSA-PCI2 (2S)
 1.67 11-Jul-2010  mrg use PCI_PRODUCT_NETMOS_NM9901 instead of 0x9901 magic number.
 1.66 08-Jul-2010  msaitoh - Fix the frequency for Advantech PCI1620 port 4-8.
- Fix the mask for IBM SurePos 300
- s/Titan/VScom/
- Add the following cards:
- Avlab PCI 2 Serial
- Avlab Low Profile PCI 4 Serial (another revision?)
- Moxa CP-102/PCI.
- SUNIX 4036 2S
- Syba Tech Ltd. PCI-4S
- Syba Tech Ltd. PCI-4S2P-550-ECP
- PR#37299
- VScom PCI-010L
- VScom PCI-100L
- VScom PCI-110L
- VScom PCI-200L
- VScom PCI-210L
- VScom PCI-400L
- VScom PCI-011H
- VScom PCI-100H
 1.65 08-Jul-2010  msaitoh - Fix an entry for CP-168EL-A/PCIe reported by Ryo SHIMIZU.
- Add an entry for NetMos NM9901 UART. Tested my own NM9901 card.
 1.64 08-Jul-2010  msaitoh - Fix a table for Advantech PCI-1620
- Add entry for PCI-1610 and PCI-1612
 1.63 08-Jul-2010  msaitoh Use real company name and product name.
 1.62 08-Jul-2010  msaitoh - revert pucdata.c rev. 1.60 and add a new entry which checks subvendor code.
- Add the following cards' support (include fixing for PR#37566 and PR#39288):
Advantech PCI-1620A-AE (8-port serial)
Decision Computer Inc PCCOM PCI 2 Port (2 port serial)
Decision Computer Inc PCCOM PCI 4 Port (4 port serial)
Decision Computer Inc PCCOM PCI 8 Port (8 port serial)
Exsys EX-41098 (4 port serial)
IO-DATA RSA-PCI2 (8 port serial)
Moxa Technologies SmartIO C168EL-A/PCI (8-port serial)
Moxa Technologies SmartIO C168EL/PCIe (8-port serial)
Moxa Technologies SmartIO C168U/PCI (8-port serial)
Moxa Technologies SmartIO CP104-EL/PCIe (4-port serial)
Multi-Tech ISI5634PCI/4 (4 port serial)
NetMos NM9835 UART (1 port serial)
NetMos NM9865 4 UART (4 port serial)
NetMos NM9865 UART (1 port serial)
NetMos NM9901 PCIe (single parallel)
Oxford OX16PCI958 (8 port serial)
SIIG Cyber 4 PCI 16550 (4-port serial)
SIIG Cyber 4S PCI 16C650 (20x family) (4-port serial)
 1.61 08-Jul-2010  msaitoh Sort by PCI_VENDOR_*. No functional change.
 1.60 02-Jul-2010  msaitoh Fix frequency for OX16PCI954.
 1.59 19-Jan-2010  mbalmer branches: 1.59.2; 1.59.4;
Add the IBM 481033H SCC
 1.58 18-Nov-2009  enami Add an entry for AVlab's low profile PCI 4 port serial card, which is
sold in japan from kuroutoshikou as SERIAL4P-LPPCI2.
 1.57 29-Aug-2009  tsutsui Add support for Oxford Semiconductor OXmPCI952 2 port UARTs.
Also update URL of Oxford UART chips.
 1.56 08-Dec-2008  dyoung Distinguish the NetMos NM9845 Quad UART chip from the NetMos NM9845
Quad UART + One Parallel chip.
 1.55 06-Sep-2008  rmind branches: 1.55.2; 1.55.4; 1.55.10;
PR/38012: David Dudley: Support for B&B Electronics MIPort serial cards.
 1.54 03-Apr-2008  riz branches: 1.54.4; 1.54.6; 1.54.10;
Support for Digi International 4 and 8 port boards, from OpenBSD.

XXX need to convert the rest of the PCI vendor/product IDs to macros
 1.53 22-Feb-2008  tsutsui Add an entry for I-O DATA RSA-PCI 2-port serial board.
(works only on 16550A compatible mode)
 1.52 01-Nov-2007  jnemeth branches: 1.52.12; 1.52.16;
PR/37259 - Daniel Neri -- typo in EXAR XR17C158 description
 1.51 28-Jan-2007  chs branches: 1.51.18; 1.51.20; 1.51.24;
add some SIIG and Moxa cards.
 1.50 09-Dec-2006  manu Add support for 4 and 8 ports modem boards from Perle systems
 1.49 13-Nov-2006  bouyer branches: 1.49.2;
Add NetMos 9855 Quad UART and 1284 Printer port
 1.48 31-Oct-2006  manu Add support for Perle systems PCI-RAS 4 modem ports
See http://www.perle.com/products/Multimodem-Cards.shtml for product details
 1.47 09-Oct-2006  cube Add an entry for the 2 UARTs version of the Moschip NM9835.
 1.46 03-Sep-2006  christos branches: 1.46.2; 1.46.4;
add missing initializers
 1.45 11-Jun-2006  bouyer Add entry for "Moxa Technologies, SmartIO CP104-V2/PCI". From Gert Doering
in kern/33566.
 1.44 09-Mar-2006  hamajima branches: 1.44.4;
Add support for EXAR XR17D15x serial.
(I tested only XR17D154.)
 1.43 06-Mar-2006  martin branches: 1.43.2;
Add support for Moxa CP104 serial card, from Olivier Cherrier
 1.42 24-Jan-2006  christos branches: 1.42.2; 1.42.4; 1.42.6;
Add support for more puc chips from Pavel Cahyna.
This might NetMos 9845 card which need the COM_FREQ * 4 hack, but this
can be re-added by a more specific entry (matching subsystem IDs).
 1.41 11-Dec-2005  christos branches: 1.41.2;
merge ktrace-lwp.
 1.40 27-Feb-2005  perry branches: 1.40.2; 1.40.4;
nuke trailing whitespace
 1.39 16-Oct-2004  bouyer branches: 1.39.4; 1.39.6;
Add the dual-serial VScom PCI-200 adapter. Tested by Jukka Salmi.
 1.38 13-Oct-2004  drochner support ADDI-DATA APCI-7800 8-port serial adapter
 1.37 04-Jul-2004  mycroft Support for the VS-Com PCI-210H 2s/1p card, from PR 18478.
 1.36 03-Feb-2004  fredb branches: 1.36.2;
Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.35 25-Jan-2004  jdolecek fix register offset of second port for NetMos NM9815 Dual 1284 Printer port
card
 1.34 06-Dec-2003  jdolecek add entry for another NetMos card - NetMos NM9815 Dual 1284 Printer port
 1.33 28-Sep-2003  jdolecek add entry for Lava Quattro-PCI (4 port serial)
contributed in PR kern/22977 by Heison Chak
 1.32 29-Oct-2002  chs branches: 1.32.6;
add Boca Research 4- and 8-port cards. from openbsd.
 1.31 02-Aug-2002  bouyer Add Siig 20x 8 ports and and Oxford x952 cards. From Paul Shupak in kern/17790.
 1.30 05-Jul-2002  enami Add an entry for Avlab Technology, Inc. Low Profile PCI 4 Serial (in Japan,
sold by Kuroutoshikou as SERIAL4P-LPPCI.)
 1.29 02-Jun-2002  seb Support Titan PCI-800L, a 8 serial puc card, from PR 17140.
Reviewed/approved by veego@ and martin@.
 1.28 24-May-2002  lukem Support NetMos NM9845 Quad UART and 1284 Printer port.
All 4 serial ports and parallel port seem to work.
 1.27 13-May-2002  hannken branches: 1.27.2; 1.27.4;
Add support for NetMos NM9805 1284 Printer port.
Tested by David Kwok <dkwok@iware.com.au>.
 1.26 11-Apr-2002  hannken Add config for the SUNIX line of pci serial/parallel cards.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>
 1.25 16-Dec-2001  thorpej Fix a minor typo.
 1.24 16-Dec-2001  thorpej Add the serial port on the Middle Digital, Inc. PCI Weasel.
 1.23 26-Nov-2001  jonathan * Add entry for Dolphin Peripherals 4036 dual-serial card.
(Note: PCI ID conflicts with Dolphin Peripherals 4025; a 4025 may
attach two serial units, but I cannot find one to test).
 1.22 18-Nov-2001  christos Add Titan 200H (from Wojciech Puchar)
 1.21 13-Nov-2001  lukem add RCSID
 1.20 06-Aug-2001  soren Add support for the PCI-400 card and correct the clock rate for all the
VScom/Titan cards.
 1.19 04-Jul-2001  thorpej branches: 1.19.2;
Add another Lava serial board.
 1.18 13-Mar-2001  bouyer Looks like "VSCom PCI-800H" should be in fact "Titan PCI-800H".
 1.17 04-Mar-2001  msaitoh branches: 1.17.2;
add support for NetMos NM9835 Dual UART and 1284 Printer port.
 1.16 14-Feb-2001  christos make this compile again.
 1.15 14-Feb-2001  christos PR/12204: Andreas Wrede: Add support for Lava 8-port serial card.
 1.14 04-Jan-2001  bouyer Ops, add COM_FREQ to a few PUC_PORT_TYPE_COM I missed.
Thanks to Bernd Ernesti for pointing this out.
 1.13 04-Jan-2001  veego Use COM_FREQ for COM part of the last commited entry.

Why are there other drivers here which have PUC_PORT_TYPE_COM but don't
use COM_FREQ or even don't have the extra field?
 1.12 04-Jan-2001  veego Add support for boards with an Oxford Semiconductor chip.
This one was an I/O Flex PCI I/O Card Model-223 with 4 serial and
1 parallel ports.
XXX We need to move the PCI IDs to pcidevs.
 1.11 03-Jan-2001  bouyer Add a 'flag' member to struct puc_attach_args and struct port. For
PUC_PORT_TYPE_COM, use it to store the clock frequency (with 8 lower bits
to 0, used for real flags if needed).
Update all descriptions to set flags to 0 for LPT or COM_FREQ for COM.
Add support for the VScom PCI-800H 8 port serial adapter (which uses
a 14.7456 Mhz crystal instead of the standart 1.8432Mhz :)
XXX now that we can pass other frequency than COM_FREQ, the VScom PCI-800
entry could probably be updated to DTRT - does anyone have one ?
 1.10 06-Sep-2000  bouyer Add definition for "Actiontec 56K PCI Master", from Bill Hudspeth.
 1.9 08-Feb-2000  bouyer branches: 1.9.4;
Supports "USR 3CP5609 PCI 16550 Modem", from Kent Polk.
 1.8 04-Dec-1999  castor Add support for Lava Computers MFG 2sp-pci and quattro cards.
 1.7 16-Nov-1999  jun Commit patch kern/8778
Subject: NEC PCI modem support
 1.6 03-Jul-1999  cgd branches: 1.6.2; 1.6.8;
'Dolphin' -> 'Dolphin Peripherals' where appropriate
 1.5 03-Jul-1999  cgd Add support for 36 more SIIG PCI serial/parallel cards (for a total of 37).
This means that all SIIG PCI serial/parallel cards (described on their
web site as "I/O boards" as of July 2, 1999) should now be supported.
 1.4 06-Feb-1999  cgd branches: 1.4.2; 1.4.4; 1.4.6;
put in better name/description for Simon G's board
 1.3 06-Feb-1999  cgd add code to cope with multiple ports per BAR, as are found, for instance,
on the 8 port card Simon Gerraty has. In general, cards which have
this lots of ports also have a separate interrupt status register, but
this change is just to talk to the various ports independently. It works,
but it's not optimal. (XXX still need a good name for the card in the
comments, and to update the manual page.)
 1.2 12-Jul-1998  cgd I went to Fry's and noticed a few more cards that probably will be
supportable with this driver, but currently aren't supported. Add them.
 1.1 26-Jun-1998  cgd add a driver for "PCI 'universal' communications" cards, that is, PCI cards
which contain 'standard' com- and lpt-type ports. Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not. (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.) Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
 1.4.6.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.4.4.1 02-Aug-1999  thorpej Update from trunk.
 1.4.2.2 10-Feb-2000  he Pull up revision 1.9 (via patch, requested by bouyer):
Add support for US Robotics 3CP5609 PCI 16550 Modem.
 1.4.2.1 06-Jul-1999  perry pullup 1.4->1.6 (cgd)
 1.6.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.6.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.6.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.4.3 04-Sep-2002  itojun pullup sys/dev/pci/pucdata.c 1.31 via patch (bouyer)

Add Siig 20x 8 ports and and Oxford x952 cards. From Paul Shupak in kern/17790.
 1.9.4.2 22-Mar-2001  he Pull up revisions 1.11-1.18 (requested by sommerfeld):
Add support for NetMos NM9835, Titan PCI-800H, Lava 8-port,
Actiontec 56K PCI Master. This also adds a ``flags'' member
to two structs in this driver.
 1.9.4.1 06-Sep-2000  bouyer Pull up 1.9 -> 1.10, approved by thorpej:
Add a new modem: Actiontec 56K PCI Master
 1.17.2.9 11-Nov-2002  nathanw Catch up to -current
 1.17.2.8 13-Aug-2002  nathanw Catch up to -current.
 1.17.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.17.2.6 20-Jun-2002  nathanw Catch up to -current.
 1.17.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.17.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.17.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.17.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.17.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.19.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.19.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.19.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.27.4.3 02-Aug-2002  lukem Pull up revision 1.31 (requested by bouyer in ticket #611):
Add Siig 20x 8 ports and and Oxford x952 cards. From Paul Shupak in kern/17790.
 1.27.4.2 11-Jun-2002  lukem Pull up revision 1.29 (requested by seb in ticket #249):
Support Titan PCI-800L, a 8 serial puc card, from PR 17140.
Reviewed/approved by veego@ and martin@.
 1.27.4.1 11-Jun-2002  lukem Pull up revision 1.28 (requested by lukem in ticket #167):
Support NetMos NM9845 Quad UART and 1284 Printer port.
All 4 serial ports and parallel port seem to work.
 1.27.2.4 29-Aug-2002  gehenna catch up with -current.
 1.27.2.3 15-Jul-2002  gehenna catch up with -current.
 1.27.2.2 20-Jun-2002  gehenna catch up with -current.
 1.27.2.1 30-May-2002  gehenna Catch up with -current.
 1.32.6.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.32.6.4 19-Oct-2004  skrll Sync with HEAD
 1.32.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.32.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.32.6.1 03-Aug-2004  skrll Sync with HEAD
 1.36.2.1 04-Jul-2004  he branches: 1.36.2.1.2;
Pull up revision 1.37 (requested by mycroft in ticket #597):
Support for the VS-Com PCI-210H 2s/1p card. Fixes PR#18478.
 1.36.2.1.2.2 21-Nov-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #10749):
sys/dev/pci/pucdata.c: revision 1.49
sys/dev/pci/pcidevs: revision 1.849
sys/dev/pci/pcidevs: revision 1.850
Add NetMos 9855 Quad UART and 1284 Printer port
Fix typo in previous (hi bouyer).
 1.36.2.1.2.1 06-Aug-2006  tron Apply patch (requested by bouyer in ticket #10643):
Add support for Moxa SmartIO CP104 and CP104-V2/PCI and EXAR XR17D15x.
 1.39.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.39.4.1 29-Apr-2005  kent sync with -current
 1.40.4.5 27-Feb-2008  yamt sync with head.
 1.40.4.4 15-Nov-2007  yamt sync with head.
 1.40.4.3 26-Feb-2007  yamt sync with head.
 1.40.4.2 30-Dec-2006  yamt sync with head.
 1.40.4.1 21-Jun-2006  yamt sync with head.
 1.40.2.4 20-Nov-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1584):
sys/dev/pci/pucdata.c: revision 1.49
sys/dev/pci/pcidevs: revision 1.849
sys/dev/pci/pcidevs: revision 1.850
Add NetMos 9855 Quad UART and 1284 Printer port
Fix typo in previous (hi bouyer).
 1.40.2.3 15-Jun-2006  tron Pull up following revision(s) (requested by bouyer in ticket #1373):
sys/dev/pci/pucdata.c: revision 1.45
Add entry for "Moxa Technologies, SmartIO CP104-V2/PCI". From Gert Doering
in kern/33566.
 1.40.2.2 15-Jun-2006  tron Pull up following revision(s) (requested by bouyer in ticket #1373):
sys/dev/pci/pucdata.c: revision 1.44
Add support for EXAR XR17D15x serial.
(I tested only XR17D154.)
 1.40.2.1 15-Jun-2006  tron Pull up following revision(s) (requested by bouyer in ticket #1373):
share/man/man4/puc.4: revision 1.19
sys/dev/pci/pucdata.c: revision 1.43
Add support for Moxa CP104 serial card, from Olivier Cherrier
 1.41.2.1 01-Feb-2006  yamt sync with head.
 1.42.6.3 03-Sep-2006  yamt sync with head.
 1.42.6.2 26-Jun-2006  yamt sync with head.
 1.42.6.1 13-Mar-2006  yamt sync with head.
 1.42.4.1 22-Apr-2006  simonb Sync with head.
 1.42.2.1 09-Sep-2006  rpaulo sync with head
 1.43.2.1 19-Apr-2006  elad sync with head.
 1.44.4.1 19-Jun-2006  chap Sync with head.
 1.46.4.2 10-Dec-2006  yamt sync with head.
 1.46.4.1 22-Oct-2006  yamt sync with head
 1.46.2.3 01-Feb-2007  ad Sync with head.
 1.46.2.2 12-Jan-2007  ad Sync with head.
 1.46.2.1 18-Nov-2006  ad Sync with head.
 1.49.2.3 09-Mar-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1097):
sys/dev/pci/pucdata.c: revision 1.53
sys/dev/pci/pcidevs: revision 1.930
Add I-O DATA RSA-PCI 2 port serial board.
Add an entry for I-O DATA RSA-PCI 2-port serial board.
(works only on 16550A compatible mode)
 1.49.2.2 04-Nov-2007  xtraeme Pull up following revision(s) (requested by jnemeth in ticket #968):
sys/dev/pci/pucdata.c: revision 1.52

PR/37259 - Daniel Neri -- typo in EXAR XR17C158 description
 1.49.2.1 18-Feb-2007  tron branches: 1.49.2.1.2;
Pull up following revision(s) (requested by chs in ticket #424):
sys/dev/pci/pucdata.c: revision 1.51
add some SIIG and Moxa cards.
 1.49.2.1.2.2 03-Jun-2008  skrll Sync with netbsd-4.
 1.49.2.1.2.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.51.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.51.20.2 23-Mar-2008  matt sync with HEAD
 1.51.20.1 06-Nov-2007  matt sync with HEAD
 1.51.18.1 04-Nov-2007  jmcneill Sync with HEAD.
 1.52.16.4 17-Jan-2009  mjf Sync with HEAD.
 1.52.16.3 28-Sep-2008  mjf Sync with HEAD.
 1.52.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.52.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.52.12.1 24-Mar-2008  keiichi sync with head.
 1.54.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.54.10.1 19-Oct-2008  haad Sync with HEAD.
 1.54.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.54.4.4 11-Aug-2010  yamt sync with head.
 1.54.4.3 11-Mar-2010  yamt sync with head
 1.54.4.2 16-Sep-2009  yamt sync with head
 1.54.4.1 04-May-2009  yamt sync with head.
 1.55.10.1 21-Apr-2010  matt sync to netbsd-5
 1.55.4.2 23-Jan-2010  bouyer Pull up following revision(s) (requested by mbalmer in ticket #1255):
sys/dev/pci/pucdata.c: revision 1.59
Add the IBM 481033H SCC
 1.55.4.1 16-Oct-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #1070):
sys/dev/pci/pucdata.c: revision 1.57
Add support for Oxford Semiconductor OXmPCI952 2 port UARTs.
Also update URL of Oxford UART chips.
 1.55.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.59.4.4 31-May-2011  rmind sync with head
 1.59.4.3 21-Apr-2011  rmind sync with head
 1.59.4.2 05-Mar-2011  rmind sync with head
 1.59.4.1 03-Jul-2010  rmind sync with head
 1.59.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.69.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.69.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.76.8.1 31-Oct-2012  riz sys/dev/pci/pucdata.c 1.77-1.82
sys/dev/pci/pcidevs 1.1125, 1.1129 via patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen
share/man/man4/puc.4 1.36-1.38

Add entries for puc(4) devices into pcidevs.
Add some Intel devices from document (Intel 7 Series / C216 Chipset
Family Platform Controller Hub (PCH) Family Specification Update)
into pcidevs.
Modify some devices in pcidevs to clarify.
Add Intel chipset internal serial over lan devices. Closes PR/45567.
Use PCI_VENDOR_* and PCI_PRODUCT_*. Fixes PR#46303.
Add EXSYS EX-41098-2 UARTs support. The clock frequency is different
from other card(s). Fixes PR#46362 reported by Wolfgang Stukenbrock.
Add Lava Computers SSERIAL-PCI single port serial PCI card.
Update the manual.
 1.76.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.76.2.2 23-Jan-2013  yamt sync with head
 1.76.2.1 30-Oct-2012  yamt sync with head
 1.80.2.5 03-Dec-2017  jdolecek update from HEAD
 1.80.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.80.2.3 23-Jun-2013  tls resync from head
 1.80.2.2 25-Feb-2013  tls resync with head
 1.80.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.84.4.1 23-Jul-2013  riastradh sync with HEAD
 1.84.2.2 18-May-2014  rmind sync with head
 1.84.2.1 28-Aug-2013  rmind sync with head
 1.93.6.5 05-Feb-2017  skrll Sync with HEAD
 1.93.6.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.93.6.3 22-Sep-2015  skrll Sync with HEAD
 1.93.6.2 06-Jun-2015  skrll Sync with HEAD
 1.93.6.1 06-Apr-2015  skrll Sync with HEAD
 1.93.4.4 14-Nov-2019  martin Pull up following revision(s) (requested by hauke in ticket #1712):

sys/dev/pci/pucdata.c: revision 1.105

The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.
ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}
 1.93.4.3 03-Jan-2018  snj Pull up following revision(s) (requested by maya in ticket #1547):
sys/dev/pci/pucdata.c: revision 1.99-1.100
sys/dev/pci/pcidevs: revision 1.1278
Add Intel 200 series chipset devices from "Table 2-2. PCH-H Device and
Revision ID Table, Intel 200 Series Chipset Family Platform Controller
Hub(PCI) Datasheet Volume 1 of 2 (335192-001)".
--
Add Intel 200 series devices.
--
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card
 1.93.4.2 08-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1292):
sys/dev/pci/pucdata.c: revisions 1.95-1.98
share/man/man4/puc.4: revisions 1.39-40
Add three devices to puc(4):
- Add support for SystemBase SB16C1050 PCI serial card. PR#49819
reported by Roberto E. Vargas Caballero.
- Add another Intel Q45 KT.
- Add Intel 100 Series Chipset KT.
 1.93.4.1 30-Apr-2015  snj branches: 1.93.4.1.4;
Pull up following revision(s) (requested by msaitoh in ticket #725):
sys/arch/x86/pci/ichlpcib.c: revisions 1.47, 1.48
sys/dev/pci/ichsmb.c: revisions 1.39, 1.40, 1.41
sys/dev/pci/pucdata.c: revision 1.94
Add 9 Series support.
--
Add Intel C61x and X99 devices.
--
attach Mobile 5th Gen. Core SMBus
 1.93.4.1.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.98.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.99.8.6 03-Dec-2021  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1712:

sys/dev/pci/pucdata.c 1.103, 1.106-1.112
share/man/man4/puc.4 1.42-1.43

- Add Amazon.com EC2 virtual 16650-compatible PCI serial device.
- Add NetMos NM9900 Quad and Octal serial card.
- Add ASIX AX99100 PCIe 4port serial card.
- Add Oxford Semiconductor Exsys EX-41098 PCI serial card.
 1.99.8.5 14-Nov-2019  martin Pull up following revision(s) (requested by hauke in ticket #1440):

sys/dev/pci/pucdata.c: revision 1.105

The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.
ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}
 1.99.8.4 05-May-2019  martin Pull up following revision(s) (requested by jdolecek in ticket #1255):

sys/dev/pci/pucdata.c: revision 1.104

add NetMos NM9912 entries

PR kern/54149 by Mouse
 1.99.8.3 07-Jun-2018  martin Pull up following revision(s) (requested by jnemeth in ticket #846):

sys/dev/pci/pcidevs: revision 1.1334
sys/dev/pci/pucdata.c: revision 1.102

add Oxford Semiconductor OXPCIe954 PCIe 4-port serial card
 1.99.8.2 16-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #763):

sys/dev/pci/ichsmb.c: revision 1.57
sys/dev/pci/pucdata.c: revision 1.101

Add 300 series chipset support.
 1.99.8.1 13-Jan-2018  snj Pull up following revision(s) (requested by maya in ticket #472):
sys/dev/pci/pucdata.c: revision 1.100
PR/52868: Petar Bogdanovic: Add support for Manhattan 158220 card
 1.100.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.100.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.100.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.102.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.102.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.102.2.1 10-Jun-2019  christos Sync with HEAD
 1.104.2.4 24-Aug-2024  martin Pull up following revision(s) (requested by jakllsch in ticket #1880):

sys/dev/pci/pucdata.c: revision 1.116

Add Brainboxes puc(4) devices
From Cameron Williams in PR 58358.
 1.104.2.3 30-Jan-2023  martin Pull up following revision(s) (requested by thorpej in ticket #1580):

share/man/man4/puc.4: revision 1.44
sys/dev/pci/pucdata.c: revision 1.114

Add and entry for the EXAR XR17V354 4-port UART.
From Hakan Engvall.
PR kern/57202
 1.104.2.2 03-Dec-2021  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1382:

sys/dev/pci/pucdata.c 1.106-1.112
share/man/man4/puc.4 1.42-1.43

- Add NetMos NM9900 Quad and Octal serial card.
- Add ASIX AX99100 PCIe 4port serial card.
- Add Oxford Semiconductor Exsys EX-41098 PCI serial card.
 1.104.2.1 14-Nov-2019  martin Pull up following revision(s) (requested by hauke in ticket #426):

sys/dev/pci/pucdata.c: revision 1.105

The 16C1054 and 16C1058 serial multi-port controllers need a clock
multiplier of 8, just like the 16C1050 controller.

Verified with an ExSys EX-41388.
ryo@ checked back with the hardware his original commit was based on,
and confirmed the change.

XXX Pull-up to netbsd-{7,8,9}
 1.108.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.109.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.113.4.3 06-Dec-2024  snj Pull up following revision(s) (requested by msaitoh in ticket #1025):
share/man/man4/puc.4: revision 1.46
sys/dev/pci/pucdata.c: revision 1.117
Add many Brainboxes devices. Reported in PR/kern 58824 by Cameron Williams.
 1.113.4.2 24-Aug-2024  martin Pull up following revision(s) (requested by jakllsch in ticket #806):

sys/dev/pci/pucdata.c: revision 1.116

Add Brainboxes puc(4) devices
From Cameron Williams in PR 58358.
 1.113.4.1 30-Jan-2023  martin Pull up following revision(s) (requested by thorpej in ticket #61):

share/man/man4/puc.4: revision 1.44
sys/dev/pci/pucdata.c: revision 1.114

Add and entry for the EXAR XR17V354 4-port UART.
From Hakan Engvall.
PR kern/57202
 1.116.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 30-Nov-2018  jmcneill Add support for polling com devices when no interrupt is available.
 1.11 18-Mar-2014  riastradh branches: 1.11.28; 1.11.30;
Merge riastradh-drm2 to HEAD.
 1.10 17-Jul-2013  soren Extend support for Nanjing QinHeng Electronics puc(4) devices.
 1.9 01-Aug-2010  msaitoh branches: 1.9.8; 1.9.18; 1.9.22; 1.9.30;
Add the following cards' support from FreeBSD:
- Comtrol RocketPort 550/4, 550/8 and 550/16 series
- Lava Computers Quatro-PCI
- some NetMos NM9865 cards
- VScom PCI-200Li
 1.8 11-Dec-2005  christos branches: 1.8.74; 1.8.96; 1.8.98;
merge ktrace-lwp.
 1.7 04-Feb-2005  perry de-__P
 1.6 03-Feb-2004  fredb branches: 1.6.8; 1.6.10;
Enable the 8X clock on the SIIG Cyberserial serial and combination PCI
cards at attachment time, in order to support bit rates greater than 115K,
as discussed on tech-kern.
 1.5 25-Jan-2004  jdolecek pass the DMA tags to child devices, too
 1.4 03-Jan-2001  bouyer branches: 1.4.24;
Add a 'flag' member to struct puc_attach_args and struct port. For
PUC_PORT_TYPE_COM, use it to store the clock frequency (with 8 lower bits
to 0, used for real flags if needed).
Update all descriptions to set flags to 0 for LPT or COM_FREQ for COM.
Add support for the VScom PCI-800H 8 port serial adapter (which uses
a 14.7456 Mhz crystal instead of the standart 1.8432Mhz :)
XXX now that we can pass other frequency than COM_FREQ, the VScom PCI-800
entry could probably be updated to DTRT - does anyone have one ?
 1.3 25-Jul-2000  jeffs Add code to allow the PCI com serial ports to be used as the system
console. This is not enabled by default, and is turned on with
options PUCCN. Done by castor@netbsd.org.
 1.2 06-Feb-1999  cgd branches: 1.2.8; 1.2.18;
add code to cope with multiple ports per BAR, as are found, for instance,
on the 8 port card Simon Gerraty has. In general, cards which have
this lots of ports also have a separate interrupt status register, but
this change is just to talk to the various ports independently. It works,
but it's not optimal. (XXX still need a good name for the card in the
comments, and to update the manual page.)
 1.1 26-Jun-1998  cgd add a driver for "PCI 'universal' communications" cards, that is, PCI cards
which contain 'standard' com- and lpt-type ports. Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not. (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.) Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
 1.2.18.1 22-Mar-2001  he Pull up revisions 1.3-1.4 (requested by sommerfeld):
Add support for NetMos NM9835, Titan PCI-800H, Lava 8-port,
Actiontec 56K PCI Master. This also adds a ``flags'' member
to two structs in this driver.
 1.2.8.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.24.4 04-Feb-2005  skrll Sync with HEAD.
 1.4.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.24.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 12-Feb-2005  yamt sync with head.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.8.98.1 05-Mar-2011  rmind sync with head
 1.8.96.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.8.74.1 11-Aug-2010  yamt sync with head.
 1.9.30.1 23-Jul-2013  riastradh sync with HEAD
 1.9.22.1 28-Aug-2013  rmind sync with head
 1.9.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.30.1 10-Jun-2019  christos Sync with HEAD
 1.11.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5 06-Sep-2025  riastradh pvscsi(4): Zero rings before using them.

bus_dmamem_alloc(9) doesn't guarantee zeroing, as far as I can tell,
and who knows what might happen if the ring header and contents have
anything nonzero initially.

Insert an initial preread/prewrite sync between zeroing and first
use, and, out of paranoia, a final postread/postwrite sync between
last use and unload/free.

Prompted by (but not really related to):

PR kern/59618: occasional virtio block device lock ups/hangs
 1.4 06-Sep-2025  riastradh pvscsi(4): Use bus_dmamap_sync, not membar_*, for DMA.

membar_* may be a noop if we're booting on a single _virtual_ CPU,
but the barriers are still needed in case the host behind pvscsi(4)
is running on another _physical_ CPU.

Prompted by (and related to but not the same issue as):

PR kern/59618: occasional virtio block device lock ups/hangs
 1.3 06-Sep-2025  riastradh pvscsi(4): Use paravirt_membar_sync(9) where needed.

PR kern/59618: occasional virtio block device lock ups/hangs

(pvscsi(4) is not virtio(4) but the same fundamental issue arises.)
 1.2 05-Aug-2025  skrll branches: 1.2.2; 1.2.4;
Add the barrier that a comment describes.
 1.1 04-Aug-2025  skrll Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.
 1.2.4.2 08-Aug-2025  martin Pull up following revision(s) (requested by skrll in ticket #1148):

sys/arch/evbarm/conf/GENERIC64: revision 1.227
sys/dev/pci/files.pci: revision 1.451
sys/dev/pci/pvscsi.c: revision 1.1
sys/dev/pci/pvscsi.c: revision 1.2
sys/dev/pci/pvscsi.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.617

Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.

Add the barrier that a comment describes.
 1.2.4.1 05-Aug-2025  martin file pvscsi.c was added on branch netbsd-10 on 2025-08-08 14:21:39 +0000
 1.2.2.4 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #64):

sys/dev/pci/pvscsi.c: revision 1.4
sys/dev/pci/pvscsi.c: revision 1.5

pvscsi(4): Use bus_dmamap_sync, not membar_*, for DMA.
membar_* may be a noop if we're booting on a single _virtual_ CPU,
but the barriers are still needed in case the host behind pvscsi(4)
is running on another _physical_ CPU.

Prompted by (and related to but not the same issue as):
PR kern/59618: occasional virtio block device lock ups/hangs


pvscsi(4): Zero rings before using them.

bus_dmamem_alloc(9) doesn't guarantee zeroing, as far as I can tell,
and who knows what might happen if the ring header and contents have
anything nonzero initially.

Insert an initial preread/prewrite sync between zeroing and first
use, and, out of paranoia, a final postread/postwrite sync between
last use and unload/free.

Prompted by (but not really related to):
PR kern/59618: occasional virtio block device lock ups/hangs
 1.2.2.3 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #63):

sys/dev/pci/pvscsi.c: revision 1.3

pvscsi(4): Use paravirt_membar_sync(9) where needed.

PR kern/59618: occasional virtio block device lock ups/hangs
(pvscsi(4) is not virtio(4) but the same fundamental issue arises.)
 1.2.2.2 08-Aug-2025  martin Pull up following revision(s) (requested by skrll in ticket #6):

sys/arch/evbarm/conf/GENERIC64: revision 1.227
sys/dev/pci/files.pci: revision 1.451
sys/dev/pci/pvscsi.c: revision 1.1
sys/dev/pci/pvscsi.c: revision 1.2
sys/dev/pci/pvscsi.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.617

Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.

Add the barrier that a comment describes.
 1.2.2.1 05-Aug-2025  martin file pvscsi.c was added on branch netbsd-11 on 2025-08-08 14:19:54 +0000
 1.1 04-Aug-2025  skrll branches: 1.1.2; 1.1.4;
Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.
 1.1.4.2 08-Aug-2025  martin Pull up following revision(s) (requested by skrll in ticket #1148):

sys/arch/evbarm/conf/GENERIC64: revision 1.227
sys/dev/pci/files.pci: revision 1.451
sys/dev/pci/pvscsi.c: revision 1.1
sys/dev/pci/pvscsi.c: revision 1.2
sys/dev/pci/pvscsi.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.617

Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.

Add the barrier that a comment describes.
 1.1.4.1 04-Aug-2025  martin file pvscsi.h was added on branch netbsd-10 on 2025-08-08 14:21:39 +0000
 1.1.2.2 08-Aug-2025  martin Pull up following revision(s) (requested by skrll in ticket #6):

sys/arch/evbarm/conf/GENERIC64: revision 1.227
sys/dev/pci/files.pci: revision 1.451
sys/dev/pci/pvscsi.c: revision 1.1
sys/dev/pci/pvscsi.c: revision 1.2
sys/dev/pci/pvscsi.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.617

Add a port of the FreeBSD driver for the VMware PV SCSI controller found
in VMware's ESXi product.

Tested on ESXi/Arm such that an installation from ISO succeeds and boots.

Add the barrier that a comment describes.
 1.1.2.1 04-Aug-2025  martin file pvscsi.h was added on branch netbsd-11 on 2025-08-08 14:19:54 +0000
 1.10 20-Jan-2017  maya Check pmf_device_register return value. NFC
Appeases static analyzers.
 1.9 14-Jul-2016  msaitoh branches: 1.9.2; 1.9.4;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.8 23-Apr-2015  pgoyette Update module dependencies for all the existing modules that depend on sysmon components.
 1.7 30-Aug-2011  mbalmer branches: 1.7.12; 1.7.30;
Unconditionally include <sys/modules.h>.
 1.6 29-Aug-2011  mbalmer Register as built-in module when not compiled as a module. Reminded by
jmcneill.
 1.5 29-Aug-2011  jmcneill have pci register itself as a module, and make PCI driver modules depend on it
 1.4 26-Aug-2011  mbalmer Add a pmf resume function to put the hardware in a defined state after
resume. Problem found by jmcneill@.
 1.3 26-Aug-2011  mbalmer Remove one of the copyrights, it is the same person. Remove variable name
in prototype.
 1.2 20-Aug-2011  mbalmer Remove a commented out include and clarify a comment why the timeout
period is ignored.
 1.1 11-Aug-2011  mbalmer pwdog(4) is a device driver for QUANCOM Electronic PWDOG1 PCI
attached watchdog timers.
 1.7.30.3 05-Feb-2017  skrll Sync with HEAD
 1.7.30.2 05-Oct-2016  skrll Sync with HEAD
 1.7.30.1 06-Jun-2015  skrll Sync with HEAD
 1.7.12.1 03-Dec-2017  jdolecek update from HEAD
 1.9.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.9.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.45 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.44 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.43 24-Apr-2021  thorpej branches: 1.43.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.42 21-May-2020  macallan branches: 1.42.4;
prune unneeded includes
 1.41 21-Jun-2017  macallan allow font loading etc.
 1.40 20-Jan-2017  maya Check pmf_device_register return value. NFC
Appeases static analyzers.
 1.39 16-Sep-2015  macallan branches: 1.39.2; 1.39.4;
prop_dictionary_get_bool() doesn't return FALSE if the property doesn't
exist, so initialize things first.
No more console stealing on sparc64.
 1.38 09-Oct-2013  macallan branches: 1.38.6;
support WSDISPLAYIO_GET_FBINFO
 1.37 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.36 04-Oct-2012  macallan branches: 1.36.2;
don't call allocattr() for the default attribute
 1.35 23-May-2012  macallan branches: 1.35.2;
first step to fix PR 46461 - don't jump through a NULL pointer when we're
not the console but the firmware set up the graphics hardware anyway
 1.34 19-Apr-2012  macallan glyphcache_init() works much better with its parameters in the right order
 1.33 19-Apr-2012  macallan use rasops_get_cmap()
 1.32 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.31 08-Mar-2012  macallan when doing host blits, let the fifo drain every now and then. Apparently even
a relatively slow CPU can overload a relatively fast Rage 128 in some
circumstances.
This cures weird artifacts seen when scrolling lots and lots of text very
fast. Why this only showed up with glyph cacheing which should reduce the
frequency of host blits isn't quite clear though.
 1.30 16-Feb-2012  macallan remove debug spam
 1.29 16-Feb-2012  macallan cache glyphs in video memory when using anti-aliased fonts on r128fb and
radeonfb
 1.28 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.27 11-Jan-2012  macallan use rasops_init(0, 0)
 1.26 04-Jan-2012  macallan use WSFONT_GLYPH()
 1.25 04-Jan-2012  macallan generate a better r3g3b2 colour map which actually produces white for 0xff
 1.24 04-Jan-2012  macallan split putchar into separate methods for bitmap and alpha fonts, use
FONT_IS_ALPHA()
 1.23 28-Dec-2011  macallan support anti-aliased fonts in 8 bit r3g3b2 colour
 1.22 29-Jun-2011  macallan branches: 1.22.2; 1.22.6;
support WSDISPLAYIO_GET_EDID
 1.21 15-Feb-2011  macallan don't muck with the LVDS_BLON bit
 1.20 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.19 06-Jan-2011  macallan branches: 1.19.2; 1.19.4;
clear the screen before redrawing on reentering text mode
 1.18 25-Dec-2010  macallan there is no R128_LITTLE_ENDIAN_EN flag, just lack of R128_HOST_BIG_ENDIAN_EN
Someone(tm) needs to test this on little endian hw
 1.17 16-Dec-2010  cegger ioctl: KNF switch-case, remove useless brackets
 1.16 15-Nov-2010  macallan explicitly set and clear the backlight on bit, just in case someone messes
with it while we're not looking
 1.15 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.14 07-Oct-2010  macallan use WSDISPLAYIO_PARAM_BACKLIGHT as a switch and WSDISPLAYIO_PARAM_BRIGHTNESS
for backlight level instead of following radeonfb
TODO: adapt radeonfb and powerd scripts
 1.13 30-Sep-2010  macallan use the drawing engine to draw characters so we don't have to sync after each
command and don't need to map the framebuffer anymore
 1.12 14-Sep-2010  macallan support backlight control via wsconsctl
 1.11 09-Sep-2010  macallan add backlight control via PMF
TODO: support wsconsctl
 1.10 01-Oct-2009  jmmv branches: 1.10.2; 1.10.4;
Recognize PCI_PRODUCT_ATI_RAGEGLPCI. Works on a PowerMac G3 B&W running
NetBSD/macppc.
 1.9 20-Aug-2009  macallan use vcons_replay_msgbuf() when appropriate
 1.8 06-May-2009  elad Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.7 03-Jan-2009  yamt branches: 1.7.2;
remove extra semicolons.
 1.6 25-Aug-2008  jmcneill branches: 1.6.2;
Match on Rage Mobility M3 (AGP)
 1.5 30-May-2008  macallan branches: 1.5.4;
remove test for VGA subclass, also match PCI_PRODUCT_ATI_RAGE3AGP4XT
this makes r128fb work on 2nd generation iMacs
From Brett Slager
 1.4 08-May-2008  macallan nuke clause 3
 1.3 27-Feb-2008  macallan branches: 1.3.2; 1.3.4; 1.3.6;
get rid of the last #ifdef macppc and use PCI_MAGIC_IO_RANGE to select
at which offset we mmap PCI IO space
 1.2 23-Nov-2007  macallan branches: 1.2.10; 1.2.12; 1.2.16;
make this compile on sparc64
 1.1 07-Nov-2007  macallan branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
add preliminary driver for ATI Rage 128 graphics controllers
So far it supports some acceleration ( copies and rectangle fills ) but
no video mode programming at all.
Known problems:
- tested only on macppc
- matches only one r128 chip out of ca. 30
- character drawing is unaccelerated
- no attempt is made to restore the console when X exits
 1.1.8.3 08-Dec-2007  mjf Sync with HEAD.
 1.1.8.2 19-Nov-2007  mjf Sync with HEAD.
 1.1.8.1 07-Nov-2007  mjf file r128fb.c was added on branch mjf-devfs on 2007-11-19 00:48:18 +0000
 1.1.6.4 17-Mar-2008  yamt sync with head.
 1.1.6.3 07-Dec-2007  yamt sync with head
 1.1.6.2 15-Nov-2007  yamt sync with head.
 1.1.6.1 07-Nov-2007  yamt file r128fb.c was added on branch yamt-lazymbuf on 2007-11-15 11:44:27 +0000
 1.1.4.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.4.1 07-Nov-2007  bouyer file r128fb.c was added on branch bouyer-xenamd64 on 2007-11-13 16:01:33 +0000
 1.1.2.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.1.2.2 11-Nov-2007  joerg Sync with HEAD.
 1.1.2.1 07-Nov-2007  joerg file r128fb.c was added on branch jmcneill-pm on 2007-11-11 16:47:43 +0000
 1.2.16.4 17-Jan-2009  mjf Sync with HEAD.
 1.2.16.3 28-Sep-2008  mjf Sync with HEAD.
 1.2.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.2.12.1 24-Mar-2008  keiichi sync with head.
 1.2.10.3 23-Mar-2008  matt sync with HEAD
 1.2.10.2 09-Jan-2008  matt sync with HEAD
 1.2.10.1 23-Nov-2007  matt file r128fb.c was added on branch matt-armv6 on 2008-01-09 01:54:01 +0000
 1.3.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.3.4.6 09-Oct-2010  yamt sync with head
 1.3.4.5 11-Mar-2010  yamt sync with head
 1.3.4.4 16-Sep-2009  yamt sync with head
 1.3.4.3 16-May-2009  yamt sync with head
 1.3.4.2 04-May-2009  yamt sync with head.
 1.3.4.1 16-May-2008  yamt sync with head.
 1.3.2.2 04-Jun-2008  yamt sync with head
 1.3.2.1 18-May-2008  yamt sync with head.
 1.5.4.1 19-Oct-2008  haad Sync with HEAD.
 1.6.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.4.1 05-Mar-2011  rmind sync with head
 1.10.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.19.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.19.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.19.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.22.6.5 02-Jun-2012  mrg sync to latest -current.
 1.22.6.4 29-Apr-2012  mrg sync to latest -current.
 1.22.6.3 05-Apr-2012  mrg sync to latest -current.
 1.22.6.2 11-Mar-2012  mrg sync to latest -current
 1.22.6.1 18-Feb-2012  mrg merge to -current.
 1.22.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.22.2.3 30-Oct-2012  yamt sync with head
 1.22.2.2 23-May-2012  yamt sync with head.
 1.22.2.1 17-Apr-2012  yamt sync with head
 1.35.2.3 03-Dec-2017  jdolecek update from HEAD
 1.35.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.36.2.2 18-May-2014  rmind sync with head
 1.36.2.1 28-Aug-2013  rmind sync with head
 1.38.6.3 28-Aug-2017  skrll Sync with HEAD
 1.38.6.2 05-Feb-2017  skrll Sync with HEAD
 1.38.6.1 22-Sep-2015  skrll Sync with HEAD
 1.39.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.39.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.42.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.43.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 06-Jan-2012  macallan Forgot to commit this along with r128fb.c. Again.
 1.4 28-Dec-2011  macallan add a bunch of register definitions
 1.3 30-Sep-2010  macallan branches: 1.3.8; 1.3.12;
add a couple more register definitions, mostly from xf86-video-r128
 1.2 09-Sep-2010  macallan add backlight control via PMF
TODO: support wsconsctl
 1.1 07-Nov-2007  macallan branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.18; 1.1.28; 1.1.48; 1.1.50;
add preliminary driver for ATI Rage 128 graphics controllers
So far it supports some acceleration ( copies and rectangle fills ) but
no video mode programming at all.
Known problems:
- tested only on macppc
- matches only one r128 chip out of ca. 30
- character drawing is unaccelerated
- no attempt is made to restore the console when X exits
 1.1.50.1 05-Mar-2011  rmind sync with head
 1.1.48.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.28.1 09-Oct-2010  yamt sync with head
 1.1.18.2 09-Jan-2008  matt sync with HEAD
 1.1.18.1 07-Nov-2007  matt file r128fbreg.h was added on branch matt-armv6 on 2008-01-09 01:54:02 +0000
 1.1.8.2 19-Nov-2007  mjf Sync with HEAD.
 1.1.8.1 07-Nov-2007  mjf file r128fbreg.h was added on branch mjf-devfs on 2007-11-19 00:48:19 +0000
 1.1.6.2 15-Nov-2007  yamt sync with head.
 1.1.6.1 07-Nov-2007  yamt file r128fbreg.h was added on branch yamt-lazymbuf on 2007-11-15 11:44:27 +0000
 1.1.4.2 13-Nov-2007  bouyer Sync with HEAD
 1.1.4.1 07-Nov-2007  bouyer file r128fbreg.h was added on branch bouyer-xenamd64 on 2007-11-13 16:01:33 +0000
 1.1.2.2 11-Nov-2007  joerg Sync with HEAD.
 1.1.2.1 07-Nov-2007  joerg file r128fbreg.h was added on branch jmcneill-pm on 2007-11-11 16:47:44 +0000
 1.3.12.1 18-Feb-2012  mrg merge to -current.
 1.3.8.1 17-Apr-2012  yamt sync with head
 1.117 08-Aug-2021  tnn radeonfb: use BUS_SPACE_MAP_PREFETCHABLE for the framebuffer mapping

Makes the driver work on cia(4) based alpha machines, which can only
do dense access to linear mappings with prefetch. ok macallan@
 1.116 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.115 21-Jun-2021  christos branches: 1.115.2;
fix proplib deprecation
 1.114 24-Apr-2021  thorpej branches: 1.114.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.113 14-Mar-2021  rin branches: 1.113.2;
Initialize dp->rd_cmap_{red,green,blue} in radeonfb_init_palette() for 8bpp,
so that color map can be obtained by WSDISPLAYIO_GETCMAP ioctl(2).

Now, mlterm-fb from pkgsrc/x11/mlterm works just fine on radeonfb(4).
 1.112 30-Oct-2020  macallan branches: 1.112.2;
support screen blanking of r5xx
somewhat crude but works
 1.111 11-Oct-2020  jdc Handle EDID:N entries, where N is the port number, so that we can set up
the display on port1 when port0 has no EDID information.
Try harder not to return NULL from radeonfb_modelookup() because we use
the result without checking later.
While here, adjust RADEONFB_DEBUG output:
don't print RADEON_PIXCLKS_CNTL (fixes a crash on sparc64 because it's
not aligned)
don't ignore the bottom 200 lines of the display (for no apparent reason))
 1.110 28-Sep-2020  macallan first step towards r5xx support:
- no CRTC programming yet, we just use whatever mode the (open)firmware hands
us
- palette control, fb location etc. all work
- hardware acceleration for character drawing, scrolling etc. works
- hardware cursor works
... tested & still works on various radeons in various macppc machines
 1.109 05-Jul-2020  martin Adapt to proplib api changes
 1.108 11-Jun-2020  macallan only read the backlight level register on mobility chips
 1.107 11-Jun-2020  macallan reduce stack usage in radeonfb_pickres() and radeonfb_set_cursor()
 1.106 06-Feb-2020  macallan sent PMF events when (un)blanking so things like lmu can turn their lights on
or off as well
 1.105 15-Aug-2019  rin branches: 1.105.2;
Support bitmap fonts with stride 4 (i.e., width 17 to 32).
 1.104 27-Mar-2019  macallan branches: 1.104.4;
fix the fix(es) - don't try to access a BIOS we didn't find.
Now this works on sparc64 again.
 1.103 22-Mar-2019  martin Even if you try very hard, some cards just do not have a BIOS.
 1.102 21-Mar-2019  macallan don't malloc(0)
spotted by mrg@
 1.101 20-Mar-2019  macallan add code to read disabled ROMs, adapted from xf86-video-radeon
With this radeonfb does The Right Thing(tm) on my 2xDVI mac radeon with
decidedly non-standard output wiring.
( apparently at least *some* mac radeons have a hidden x86 BIOS with valid
connector tables )
 1.100 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.99 28-Jun-2018  macallan branches: 1.99.2;
restrict a magic number 'fix' inherited from xf86-video-radeon to actual
rv100 chips instead of applying it to anything older than r300.
Now DVI output works properly on 1st generation Mac Minis.
tested by christos
 1.98 16-Jun-2018  macallan explicitly turn off tiling translation - now software rendered characters
look right again on r3xx hardware
 1.97 15-Jun-2018  macallan cosmetics, no functional change
 1.96 14-Jun-2018  macallan make this work on rv350 chips found in last generation *Books
Needs testing on non-Apple hardware.
 1.95 06-Jun-2018  maya Remove duplicate ;
 1.94 24-Jan-2018  riastradh branches: 1.94.2;
Fix integer overflows noted by Silvio Cesare of InfoSect.

Someone^TM should name these idioms so we can eliminate this class of
copypasta bug.
 1.93 11-Oct-2017  macallan add missing break;s
 1.92 25-Aug-2017  macallan Radeon PLLs can't have odd post dividers when used with digital outputs -
add a flag to track this in relevant functions.
Now DVI output works properly on my Mini 2
Needs testing on Mini 1 and other hardware...
 1.91 23-Aug-2017  macallan Mac Mini WIP:
- plug the external TMDS into the right CRTC when in use
- use the right output types for Mini configs
now VGA works properly ( and not just by accident ) on my Mini 2. DVI is still
garbled but at least produces output.
 1.90 11-Aug-2017  macallan set display output parameters according to properties
Now VGA output works as intended on my Mini 2. DVI is still garbled ( but
visible ) and Mini 1 is untested.
 1.89 02-Jun-2017  macallan enable font loading / screen resizing
 1.88 05-Nov-2014  macallan branches: 1.88.2;
- unmap registers in WSDISPLAYIO_MODE_MAPPED only if a drm attached
- don't try to touch backlight registers when they're not mapped
 1.87 21-Oct-2014  macallan remove outdated comments
 1.86 21-Oct-2014  macallan get rid of RADEONFB_MMAP_BARS which hasn't been useful for years
 1.85 16-Oct-2014  riastradh Generalize pci_find_rom and use it to locate x86 video ROM in drm2.

- Make pci_find_rom take the ROM `BAR' size as a parameter, instead
of using pci_find_mem with the ROM `BAR' to detect the size.

- Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2,
when nothing else reports that location.

- Adapt the one other caller in radeonfb, which already has the
maximum ROM size handy (romsz).

XXX pullup to netbsd-7
 1.84 22-Jul-2014  riastradh branches: 1.84.2;
Do not printf(foobar()). Bad bad bad bad bad!
 1.83 20-Feb-2014  joerg branches: 1.83.2;
Mark radeonfb_unclip as unused.
 1.82 22-Jan-2014  macallan implement WSDISPLAYIO_{GET|PUT}CMAP ioctl()s
while there:
- unmap registers and vram only in WSDISPLAYIO_MODE_MAPPED ( so DRM can map
them ) but not in WSDISPLAYIO_MODE_DUMBFB ( so wsfb can do things that
require hardware access, like palette and cursor ioctl()s )
- reject ioctl()s that need hardware access if registers are unmapped ( so we
don't crash instead )
- use the same bit order in cursor sprite images as the other drivers do
with all this, Xorg with wsfb works properly on top of radeonfb

tested on i386 and macppc ( fingers crossed for alpha ;) )
 1.81 14-Jan-2014  macallan cap mappable framebuffer size at 64MB before dividing it up for each output
now we can actually access the 2nd fb on boards with more than 64MB VRAM
 1.80 14-Jan-2014  macallan - move cursor area to the end of each display's chunk of fb RAM
- use memory between display and cursor as glyph cache instead of blindly
trying to use 8MB
should fix PR 48492
 1.79 09-Oct-2013  macallan support WSDISPLAYIO_GET_FBINFO
 1.78 15-Sep-2013  martin Remove an unused variable
 1.77 15-Sep-2013  martin Comment out (but leave for documentation purposes) a variable.
 1.76 28-Mar-2013  macallan branches: 1.76.4;
clear screen when leaving X so we don't leave garbage in the borders
 1.75 25-Mar-2013  macallan change hsync start to match xf86-video-radeon so CRT modes set up by radeonfb
and Xorg no longer differ by a few pixels horizontally
 1.74 07-Jan-2013  macallan add PCI_PRODUCT_ATI_RADEON_RV370_5B63 - confirmed working by Dieter Roelants
 1.73 01-Jan-2013  macallan add a compile option to override the fallback to software drawing of bitmap
fonts on R3xx ( options RADEONFB_ALWAYS_ACCEL_PUTCHAR ) since this works just
fine on my RV350.
Next step: don't map VRAM if we don't need it.
 1.72 31-Dec-2012  macallan fix some typos & comments
 1.71 31-Dec-2012  macallan R4xx support is untested at best, so don't pretend to support them.
 1.70 31-Dec-2012  macallan clean up some more confusion between (ws)displays and CRTCs.
Now palette initialization no longer stomps over the port table, which gives
us a fighting chance to intentionally enable the right outputs.
How on earth did this ever work?
 1.69 30-Dec-2012  macallan Make R3xx actually work by wiring outputs, DACs and CRTCs sanely, add a bunch of R3xx-specific workarounds. Tested in xvr-100, iBook G4 and an RV350.
 1.68 20-Dec-2012  macallan don't access registers when they're not mapped
now X works on i386 with radeonfb
 1.67 20-Dec-2012  macallan make hardware accelerated drawing work on little endian hardware
tested on i386 and macppc
 1.66 20-Dec-2012  macallan first step to make this work (again) on x86 - make sure that if we use the 2nd
CRTC it's actually enabled
 1.65 04-Dec-2012  macallan make sure to use the same stride as the drawing engine when setting up video
modes. Now things work with horizontal resolutions that aren't multiples of
64 ( like 1440x900 )
 1.64 04-Oct-2012  macallan support underlined characters
 1.63 27-Jun-2012  macallan branches: 1.63.2;
don't spam the EDID block to the console unless options RADEONFB_DEBUG
 1.62 22-Apr-2012  uebayasi Consistent declaration.
 1.61 12-Apr-2012  macallan - set colour channel info only in 32bit colour
- fix comment ( don't claim to run in some byte-swapped mode when we don't )
 1.60 26-Mar-2012  macallan correctly draw alpha fonts with an uneven number of pixels per characters
radeon is weird how it handles leftovers
 1.59 15-Mar-2012  macallan adjust the backlight control interface to match the other drivers ( genfb,
r128fb, voyagerfb etc. ) so the lid_switch script does the right thing
noticed by riz, I thought I fixed that a long time ago
 1.58 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.57 28-Feb-2012  macallan let the fifo drain periodically - we need this even in 8 bit on some
hardware, like rv100 paired with a semi-fast CPU
 1.56 28-Feb-2012  macallan add methods to map/unmap video memory and registers when entering/leaving X
so DRI has a fighting chance of working
 1.55 28-Feb-2012  macallan support anti-aliased fonts in 8 bit as well
 1.54 16-Feb-2012  macallan cache glyphs in video memory when using anti-aliased fonts on r128fb and
radeonfb
 1.53 30-Jan-2012  drochner branches: 1.53.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.52 11-Jan-2012  macallan use rasops_init(0, 0)
 1.51 05-Jan-2012  macallan turns out we can feed some radeons faster than they can process image uploads,
so make periodic stops to let the fifo drain a bit
now this works on my Blade 2500 with a 32MB XVR-100
 1.50 04-Jan-2012  macallan use WSFONT_GLYPH()
 1.49 03-Jan-2012  macallan support anti-aliased fonts in 32bit colour
enable with options RADEONFB_DEPTH_32
 1.48 29-Dec-2011  macallan rework putchar():
- get rid of engine stalls when using the blitter to draw characters
- add a wrapper for non-accelerated putchar() so we only wait for the
engine when we actually want to scribble into video memory
- rework accelerated putchar(), should work on R3xx now but needs testing
 1.47 29-Dec-2011  macallan finish device_t-ification
 1.46 18-Aug-2011  christos branches: 1.46.2; 1.46.6;
fix gcc-4.5 warnings
 1.45 21-Jul-2011  njoly Fix RADEONFB_DEBUG build.
 1.44 11-May-2011  dyoung Constify pci_attach_args.
 1.43 15-Apr-2011  dyoung Refer to bits in the PCI CSR with using PCI_COMMAND_* instead of
PCI_FLAGS_*: change PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED to
PCI_COMMAND_IO_ENABLE and PCI_COMMAND_MEM_ENABLE, respectively.
 1.42 06-Feb-2011  jmcneill - add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options
 1.41 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.40 16-Dec-2010  cegger branches: 1.40.2; 1.40.4;
ioctl: KNF switch-case, remove useless brackets
 1.39 03-Nov-2010  macallan pull in rasops8 for radeonfb, while there defflag a bunch of options and
make them all use the same prefix
 1.38 02-Nov-2010  macallan when drawing characters by software make sure the engine is idle before
accessing video memory
 1.37 24-Aug-2010  macallan re-initialize the DAC when re-entering terminal emulation mode
 1.36 17-Aug-2010  macallan - fix 8 bit support and run the console in 8 bit for a little extra speed
- fix colour oddities seen occasionally on sparc64
- try to use firmware DAC wiring until we figure out what's wrong
TODO:
- find out why radeonfb gets the DAC wiring ass-backwards on my xvr-100
while Xorg's radeon driver gets it right
- find out why reverse characters aren't drawn in reverse

tested on macppc and sparc64
 1.35 04-May-2010  macallan use alternate font if available ( for autogenerated box drawing characters )
 1.34 23-Jul-2009  macallan branches: 1.34.2; 1.34.4;
quick hack to allow brightness control via PMF
 1.33 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.32 06-May-2009  elad Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.31 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.30 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.29 01-Jun-2008  macallan branches: 1.29.12;
adjust virtual resolution to preferred mode if available
From Marco Trillo
 1.28 05-May-2008  jmcneill branches: 1.28.2;
Change autoconf message 'direct rendering on dev unsupported' to
the more accurate 'drm at dev not configured'.
 1.27 10-Apr-2008  cegger branches: 1.27.2; 1.27.4;
use aprint_*_dev and device_xname
 1.26 12-Mar-2008  phx Make console drivers support PCI_IOC_CFGREAD/WRITE ioctls. This is useful for
XFree86, which can alternatively find the graphics card through /dev/ttyE0.
Approved by macallan.
 1.25 28-Feb-2008  macallan switch to PCI_MAGIC_IO_RANGE
 1.24 01-Dec-2007  ad branches: 1.24.10; 1.24.14;
Back out previous.
 1.23 01-Dec-2007  ad Noisy printfs.
 1.22 26-Nov-2007  bjs Add PCI_PRODUCT_ATI_RADEON_R430_554F to the R420 chip class.

This will not work until (at the very least) we map the memory properly
(MMIO/VRAM BARs are 64-bit)--some of the values in the configuration
space may be different. I will discuss this with others, and maybe
it will work someday.
 1.21 19-Oct-2007  ad branches: 1.21.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.20 03-Sep-2007  macallan branches: 1.20.4;
back out the reference divider probing - doesn't work right on R1xx
 1.19 02-Sep-2007  macallan always try to probe the reference divider, use default only if that fails
 1.18 18-Aug-2007  macallan branches: 1.18.2;
use bool with prop_dictionary_get_bool
 1.17 03-Aug-2007  macallan branches: 1.17.2; 1.17.4;
unbork fallout from newlock2 merge:
- reinitializing video after X exits works again
- backlight levels should be right again
 1.16 03-Aug-2007  macallan make IO mapping actually work
 1.15 09-Jul-2007  ad branches: 1.15.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.14 21-Mar-2007  macallan try to attach a drm
 1.13 21-Mar-2007  macallan use EDID data passed as property when present
This should allow radeonfb to do The Right Thing on Macs that use non-
standard video timings and have built-in monitors that don't provide data
via DDC since those usually have an EDID block in the OF tree.
 1.12 04-Mar-2007  christos branches: 1.12.2; 1.12.4; 1.12.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 09-Feb-2007  ad branches: 1.11.2;
Merge newlock2 to head.
 1.10 09-Feb-2007  macallan don't hardcode inverted backlight levels needed on some macppc models
 1.9 03-Jan-2007  macallan add preliminary support for setting backlight levels via ioctl()
from Johan Wallen
 1.8 13-Dec-2006  macallan branches: 1.8.2;
various minor fixes:
- avoid virtual resolution < physical resolution (Marco Trillo)
- don't use hardware-accelerated putchar() on R3xx
- clear screen when attaching wsdisplay
 1.7 28-Nov-2006  christos branches: 1.7.2;
PR/35146: George Michaelson: minor fix to let radeonfb.c compile
 1.6 07-Oct-2006  gdamore Fix an incorrect calculation for the destination X direction when doing
blitting. Thanks to David Redman (Tadpole) for noticing it. This probably
escaped notice before, since we never do overlapping blits (in the X
direction), but this fix may prevent problems if someone ever does use it
for that.
 1.5 29-Aug-2006  macallan branches: 1.5.2; 1.5.4; 1.5.6; 1.5.8;
- use RADEON_DEFAULT_MODE when no EDID data available
- let only root mmap PCI resources through wscons
- allow IO access on macppc
 1.4 19-Aug-2006  macallan fix a typo so we actually write sane values into the clipping registers
 1.3 19-Aug-2006  macallan fix some typos, add mmap() support for X
needs options RADEONFB_MMAP_BARS for now
 1.2 19-Aug-2006  macallan make this work on macppc.
fixes and caveats:
- will switch to 32bit colour, 8bit support needs some more work
- added support for fonts with widths that aren't multiples of 8
- for now the driver will always try to become system console
- mode switching works but is ugly
- all the acceleration bits work
- X should work with wsfb, mmap() needs some more work
- it still needs a hack to allow wsdisplay_cnattach to be called twice
 1.1 16-Aug-2006  gdamore Initial import of radeonfb. Works to some degree on at least some hardware.
Most of the testing was done on MIPS hardware -- it probably needs work before
it will be useful with x86 hardware, and it is probably incompatible with
the X11 server.

"ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
does not endorse, this software. ATI will not be responsible or liable
for any actual or alleged damage or loss caused by or in connection with
the use of or reliance on this software."

Enjoy!
 1.5.8.3 18-Dec-2006  yamt sync with head.
 1.5.8.2 10-Dec-2006  yamt sync with head.
 1.5.8.1 22-Oct-2006  yamt sync with head
 1.5.6.2 09-Sep-2006  rpaulo sync with head
 1.5.6.1 29-Aug-2006  rpaulo file radeonfb.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.5.4.2 12-Jan-2007  ad Sync with head.
 1.5.4.1 18-Nov-2006  ad Sync with head.
 1.5.2.2 03-Sep-2006  yamt sync with head.
 1.5.2.1 29-Aug-2006  yamt file radeonfb.c was added on branch yamt-pdpolicy on 2006-09-03 15:24:23 +0000
 1.7.2.3 12-May-2007  pavel Pull up following revision(s) (requested by macallan in ticket #615):
sys/dev/pci/radeonfb.c: revision 1.13
use EDID data passed as property when present
This should allow radeonfb to do The Right Thing on Macs that use non-
standard video timings and have built-in monitors that don't provide data
via DDC since those usually have an EDID block in the OF tree.
 1.7.2.2 04-Mar-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #477):
sys/dev/pci/radeonfb.c: revision 1.10
sys/dev/pci/radeonfbvar.h: revision 1.4
don't hardcode inverted backlight levels needed on some macppc models
 1.7.2.1 04-Mar-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #472):
sys/dev/pci/radeonfb.c: revision 1.9
sys/dev/pci/radeonfbreg.h: revision 1.3
sys/dev/pci/radeonfbvar.h: revision 1.3
add preliminary support for setting backlight levels via ioctl()
from Johan Wallen
 1.8.2.7 17-Mar-2008  yamt sync with head.
 1.8.2.6 07-Dec-2007  yamt sync with head
 1.8.2.5 27-Oct-2007  yamt sync with head.
 1.8.2.4 03-Sep-2007  yamt sync with head.
 1.8.2.3 26-Feb-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 13-Dec-2006  yamt file radeonfb.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.11.2.2 24-Mar-2007  yamt sync with head.
 1.11.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.6.1 29-Mar-2007  reinoud Pullup to -current
 1.12.4.1 11-Jul-2007  mjf Sync with head.
 1.12.2.4 23-Oct-2007  ad Sync with head.
 1.12.2.3 20-Aug-2007  ad Sync with HEAD.
 1.12.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.12.2.1 10-Apr-2007  ad Sync with head.
 1.15.2.2 03-Sep-2007  skrll Sync with HEAD.
 1.15.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.17.4.2 03-Aug-2007  macallan unbork fallout from newlock2 merge:
- reinitializing video after X exits works again
- backlight levels should be right again
 1.17.4.1 03-Aug-2007  macallan file radeonfb.c was added on branch matt-mips64 on 2007-08-03 05:40:48 +0000
 1.17.2.4 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.17.2.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.2.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.17.2.1 03-Aug-2007  jmcneill file radeonfb.c was added on branch jmcneill-pm on 2007-09-03 16:48:24 +0000
 1.18.2.3 23-Mar-2008  matt sync with HEAD
 1.18.2.2 09-Jan-2008  matt sync with HEAD
 1.18.2.1 06-Nov-2007  matt sync with HEAD
 1.20.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.21.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.24.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.24.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.10.1 24-Mar-2008  keiichi sync with head.
 1.27.4.6 09-Oct-2010  yamt sync with head
 1.27.4.5 11-Aug-2010  yamt sync with head.
 1.27.4.4 19-Aug-2009  yamt sync with head.
 1.27.4.3 16-May-2009  yamt sync with head
 1.27.4.2 04-May-2009  yamt sync with head.
 1.27.4.1 16-May-2008  yamt sync with head.
 1.27.2.2 04-Jun-2008  yamt sync with head
 1.27.2.1 18-May-2008  yamt sync with head.
 1.28.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.12.2 23-Jul-2009  jym Sync with HEAD.
 1.29.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.4.4 31-May-2011  rmind sync with head
 1.34.4.3 21-Apr-2011  rmind sync with head
 1.34.4.2 05-Mar-2011  rmind sync with head
 1.34.4.1 30-May-2010  rmind sync with head
 1.34.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.34.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.34.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.40.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.40.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.46.6.6 29-Apr-2012  mrg sync to latest -current.
 1.46.6.5 05-Apr-2012  mrg sync to latest -current.
 1.46.6.4 06-Mar-2012  mrg sync to -current
 1.46.6.3 06-Mar-2012  mrg sync to -current
 1.46.6.2 04-Mar-2012  mrg sync to latest -current.
 1.46.6.1 18-Feb-2012  mrg merge to -current.
 1.46.2.6 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.2.5 23-Jan-2013  yamt sync with head
 1.46.2.4 16-Jan-2013  yamt sync with (a bit old) head
 1.46.2.3 30-Oct-2012  yamt sync with head
 1.46.2.2 23-May-2012  yamt sync with head.
 1.46.2.1 17-Apr-2012  yamt sync with head
 1.53.2.2 29-Sep-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1120):
sys/dev/pci/radeonfb.c: revision 1.84
sys/dev/wsfb/genfb.c: revision 1.54
Do not printf(foobar()). Bad bad bad bad bad!
 1.53.2.1 21-Mar-2012  riz Pull up following revision(s) (requested by macallan in ticket #132):
sys/dev/pci/radeonfb.c: revision 1.59
sys/dev/pci/radeonfbvar.h: revision 1.16
adjust the backlight control interface to match the other drivers ( genfb,
r128fb, voyagerfb etc. ) so the lid_switch script does the right thing
noticed by riz, I thought I fixed that a long time ago
 1.63.2.5 03-Dec-2017  jdolecek update from HEAD
 1.63.2.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.63.2.3 23-Jun-2013  tls resync from head
 1.63.2.2 25-Feb-2013  tls resync with head
 1.63.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.76.4.1 18-May-2014  rmind sync with head
 1.83.2.1 10-Aug-2014  tls Rebase.
 1.84.2.1 17-Oct-2014  martin Pull up following revision(s) (requested by riastradh in ticket #144):
sys/dev/pci/radeonfb.c: revision 1.85
sys/dev/pci/pcivar.h: revision 1.100
sys/dev/pci/pci_map.c: revision 1.31
sys/external/bsd/drm2/include/linux/pci.h: revision 1.9
Generalize pci_find_rom and use it to locate x86 video ROM in drm2.
- Make pci_find_rom take the ROM `BAR' size as a parameter, instead
of using pci_find_mem with the ROM `BAR' to detect the size.
- Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2,
when nothing else reports that location.
- Adapt the one other caller in radeonfb, which already has the
maximum ROM size handy (romsz).
XXX pullup to netbsd-7
 1.88.2.1 28-Aug-2017  skrll Sync with HEAD
 1.94.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.94.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.94.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.99.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.99.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.99.2.1 10-Jun-2019  christos Sync with HEAD
 1.104.4.2 17-Jul-2020  martin Pull up following revision(s) (requested by macallan in ticket #1019):

sys/dev/pci/radeonfbvar.h: revision 1.21
sys/dev/pci/radeonfb.c: revision 1.107

reduce stack usage in radeonfb_pickres() and radeonfb_set_cursor()

forgot to commit a header change, again...
 1.104.4.1 18-Aug-2019  martin Pull up following revision(s) (requested by rin in ticket #86):

sys/dev/pci/radeonfb.c: revision 1.105

Support bitmap fonts with stride 4 (i.e., width 17 to 32).
 1.105.2.1 29-Feb-2020  ad Sync with head.
 1.112.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.113.2.3 24-Apr-2021  thorpej Make sure to explcitly specify the "wsemuldisplaydev" interface attribute
when attaching the wscons display instance, because these devices can
also attach children using the "drm" interface attribute.
 1.113.2.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.113.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.114.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.115.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.6 18-Sep-2020  macallan minor adaptatioons to new radeonfbreg.h
 1.5 08-Feb-2018  dholland Typos.
 1.4 03-Nov-2010  macallan pull in rasops8 for radeonfb, while there defflag a bunch of options and
make them all use the same prefix
 1.3 03-Jan-2009  yamt branches: 1.3.4; 1.3.6;
remove extra semicolons.
 1.2 19-Oct-2007  ad branches: 1.2.16; 1.2.20; 1.2.28;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.1 16-Aug-2006  gdamore branches: 1.1.2; 1.1.6; 1.1.12; 1.1.18; 1.1.32; 1.1.34; 1.1.38;
Initial import of radeonfb. Works to some degree on at least some hardware.
Most of the testing was done on MIPS hardware -- it probably needs work before
it will be useful with x86 hardware, and it is probably incompatible with
the X11 server.

"ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
does not endorse, this software. ATI will not be responsible or liable
for any actual or alleged damage or loss caused by or in connection with
the use of or reliance on this software."

Enjoy!
 1.1.38.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.34.1 06-Nov-2007  matt sync with HEAD
 1.1.32.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.18.1 23-Oct-2007  ad Sync with head.
 1.1.12.3 27-Oct-2007  yamt sync with head.
 1.1.12.2 30-Dec-2006  yamt sync with head.
 1.1.12.1 16-Aug-2006  yamt file radeonfb_bios.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.1.6.2 09-Sep-2006  rpaulo sync with head
 1.1.6.1 16-Aug-2006  rpaulo file radeonfb_bios.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.2.2 03-Sep-2006  yamt sync with head.
 1.1.2.1 16-Aug-2006  yamt file radeonfb_bios.c was added on branch yamt-pdpolicy on 2006-09-03 15:24:23 +0000
 1.2.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.2.20.1 04-May-2009  yamt sync with head.
 1.2.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.3.6.1 05-Mar-2011  rmind sync with head
 1.3.4.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.4 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.3 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.2 19-Oct-2007  ad branches: 1.2.108;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.1 16-Aug-2006  gdamore branches: 1.1.2; 1.1.6; 1.1.12; 1.1.18; 1.1.32; 1.1.34; 1.1.38;
Initial import of radeonfb. Works to some degree on at least some hardware.
Most of the testing was done on MIPS hardware -- it probably needs work before
it will be useful with x86 hardware, and it is probably incompatible with
the X11 server.

"ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
does not endorse, this software. ATI will not be responsible or liable
for any actual or alleged damage or loss caused by or in connection with
the use of or reliance on this software."

Enjoy!
 1.1.38.1 25-Oct-2007  bouyer Sync with HEAD.
 1.1.34.1 06-Nov-2007  matt sync with HEAD
 1.1.32.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.1.18.1 23-Oct-2007  ad Sync with head.
 1.1.12.3 27-Oct-2007  yamt sync with head.
 1.1.12.2 30-Dec-2006  yamt sync with head.
 1.1.12.1 16-Aug-2006  yamt file radeonfb_i2c.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.1.6.2 09-Sep-2006  rpaulo sync with head
 1.1.6.1 16-Aug-2006  rpaulo file radeonfb_i2c.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.2.2 03-Sep-2006  yamt sync with head.
 1.1.2.1 16-Aug-2006  yamt file radeonfb_i2c.c was added on branch yamt-pdpolicy on 2006-09-03 15:24:23 +0000
 1.2.108.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.9 28-Sep-2020  macallan moar registers
 1.8 18-Sep-2020  macallan update register definitions from xsrc/external/mit/xf86-video-ati/
merge in enough of the local changes to make radeonfb compile
tested on various macppc boxes
 1.7 15-Mar-2019  macallan moar registers
 1.6 23-Aug-2017  macallan branches: 1.6.4;
consistency...
 1.5 30-Dec-2012  macallan branches: 1.5.14;
Make R3xx actually work by wiring outputs, DACs and CRTCs sanely, add a bunch of R3xx-specific workarounds. Tested in xvr-100, iBook G4 and an RV350.
 1.4 30-Dec-2011  macallan branches: 1.4.6;
add some register definitions
 1.3 03-Jan-2007  macallan branches: 1.3.80; 1.3.84;
add preliminary support for setting backlight levels via ioctl()
from Johan Wallen
 1.2 29-Aug-2006  macallan branches: 1.2.2; 1.2.4; 1.2.6; 1.2.10; 1.2.12;
those should have been committed along with radeonfb.c
doh
 1.1 16-Aug-2006  gdamore Initial import of radeonfb. Works to some degree on at least some hardware.
Most of the testing was done on MIPS hardware -- it probably needs work before
it will be useful with x86 hardware, and it is probably incompatible with
the X11 server.

"ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
does not endorse, this software. ATI will not be responsible or liable
for any actual or alleged damage or loss caused by or in connection with
the use of or reliance on this software."

Enjoy!
 1.2.12.3 26-Feb-2007  yamt sync with head.
 1.2.12.2 30-Dec-2006  yamt sync with head.
 1.2.12.1 29-Aug-2006  yamt file radeonfbreg.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.2.10.1 04-Mar-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #472):
sys/dev/pci/radeonfb.c: revision 1.9
sys/dev/pci/radeonfbreg.h: revision 1.3
sys/dev/pci/radeonfbvar.h: revision 1.3
add preliminary support for setting backlight levels via ioctl()
from Johan Wallen
 1.2.6.2 09-Sep-2006  rpaulo sync with head
 1.2.6.1 29-Aug-2006  rpaulo file radeonfbreg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.2.4.1 12-Jan-2007  ad Sync with head.
 1.2.2.2 03-Sep-2006  yamt sync with head.
 1.2.2.1 29-Aug-2006  yamt file radeonfbreg.h was added on branch yamt-pdpolicy on 2006-09-03 15:24:23 +0000
 1.3.84.1 18-Feb-2012  mrg merge to -current.
 1.3.80.2 23-Jan-2013  yamt sync with head
 1.3.80.1 17-Apr-2012  yamt sync with head
 1.4.6.2 03-Dec-2017  jdolecek update from HEAD
 1.4.6.1 25-Feb-2013  tls resync with head
 1.5.14.1 28-Aug-2017  skrll Sync with HEAD
 1.6.4.1 10-Jun-2019  christos Sync with HEAD
 1.23 23-Jul-2023  andvar s/probaby/probably/ in comments.
 1.22 28-Sep-2020  macallan first step towards r5xx support:
- no CRTC programming yet, we just use whatever mode the (open)firmware hands
us
- palette control, fb location etc. all work
- hardware acceleration for character drawing, scrolling etc. works
- hardware cursor works
... tested & still works on various radeons in various macppc machines
 1.21 11-Jun-2020  macallan forgot to commit a header change, again...
 1.20 05-Nov-2014  macallan branches: 1.20.26;
- unmap registers in WSDISPLAYIO_MODE_MAPPED only if a drm attached
- don't try to touch backlight registers when they're not mapped
 1.19 22-Jan-2014  macallan implement WSDISPLAYIO_{GET|PUT}CMAP ioctl()s
while there:
- unmap registers and vram only in WSDISPLAYIO_MODE_MAPPED ( so DRM can map
them ) but not in WSDISPLAYIO_MODE_DUMBFB ( so wsfb can do things that
require hardware access, like palette and cursor ioctl()s )
- reject ioctl()s that need hardware access if registers are unmapped ( so we
don't crash instead )
- use the same bit order in cursor sprite images as the other drivers do
with all this, Xorg with wsfb works properly on top of radeonfb

tested on i386 and macppc ( fingers crossed for alpha ;) )
 1.18 28-Mar-2013  macallan branches: 1.18.4;
clear screen when leaving X so we don't leave garbage in the borders
 1.17 20-Dec-2012  macallan don't access registers when they're not mapped
now X works on i386 with radeonfb
 1.16 15-Mar-2012  macallan branches: 1.16.2;
adjust the backlight control interface to match the other drivers ( genfb,
r128fb, voyagerfb etc. ) so the lid_switch script does the right thing
noticed by riz, I thought I fixed that a long time ago
 1.15 28-Feb-2012  macallan support anti-aliased fonts in 8 bit as well
 1.14 16-Feb-2012  macallan cache glyphs in video memory when using anti-aliased fonts on r128fb and
radeonfb
 1.13 30-Jan-2012  drochner branches: 1.13.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.12 30-Dec-2011  macallan this should have been committed along with the previous changes in
radeonfb.c
 1.11 06-Feb-2011  jmcneill branches: 1.11.4; 1.11.8;
- add support for using compressed images as splash images
- retire SPLASHSCREEN_PROGRESS and SPLASHSCREEN_IMAGE options
 1.10 03-Nov-2010  macallan branches: 1.10.2; 1.10.4;
pull in rasops8 for radeonfb, while there defflag a bunch of options and
make them all use the same prefix
 1.9 02-Nov-2010  macallan when drawing characters by software make sure the engine is idle before
accessing video memory
 1.8 17-Aug-2010  macallan - fix 8 bit support and run the console in 8 bit for a little extra speed
- fix colour oddities seen occasionally on sparc64
- try to use firmware DAC wiring until we figure out what's wrong
TODO:
- find out why radeonfb gets the DAC wiring ass-backwards on my xvr-100
while Xorg's radeon driver gets it right
- find out why reverse characters aren't drawn in reverse

tested on macppc and sparc64
 1.7 28-Jul-2009  macallan branches: 1.7.2; 1.7.4;
forgot to commit that along with radeonfb.c
 1.6 03-Aug-2007  macallan branches: 1.6.2; 1.6.28; 1.6.36;
unbork fallout from newlock2 merge:
- reinitializing video after X exits works again
- backlight levels should be right again
 1.5 09-Feb-2007  ad branches: 1.5.6; 1.5.14;
Merge newlock2 to head.
 1.4 09-Feb-2007  macallan don't hardcode inverted backlight levels needed on some macppc models
 1.3 03-Jan-2007  macallan add preliminary support for setting backlight levels via ioctl()
from Johan Wallen
 1.2 29-Aug-2006  macallan branches: 1.2.2; 1.2.4; 1.2.6; 1.2.10; 1.2.12;
those should have been committed along with radeonfb.c
doh
 1.1 16-Aug-2006  gdamore Initial import of radeonfb. Works to some degree on at least some hardware.
Most of the testing was done on MIPS hardware -- it probably needs work before
it will be useful with x86 hardware, and it is probably incompatible with
the X11 server.

"ATI Technologies Inc. ("ATI") has not assisted in the creation of, and
does not endorse, this software. ATI will not be responsible or liable
for any actual or alleged damage or loss caused by or in connection with
the use of or reliance on this software."

Enjoy!
 1.2.12.4 03-Sep-2007  yamt sync with head.
 1.2.12.3 26-Feb-2007  yamt sync with head.
 1.2.12.2 30-Dec-2006  yamt sync with head.
 1.2.12.1 29-Aug-2006  yamt file radeonfbvar.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.2.10.2 04-Mar-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #477):
sys/dev/pci/radeonfb.c: revision 1.10
sys/dev/pci/radeonfbvar.h: revision 1.4
don't hardcode inverted backlight levels needed on some macppc models
 1.2.10.1 04-Mar-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #472):
sys/dev/pci/radeonfb.c: revision 1.9
sys/dev/pci/radeonfbreg.h: revision 1.3
sys/dev/pci/radeonfbvar.h: revision 1.3
add preliminary support for setting backlight levels via ioctl()
from Johan Wallen
 1.2.6.2 09-Sep-2006  rpaulo sync with head
 1.2.6.1 29-Aug-2006  rpaulo file radeonfbvar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.2.4.1 12-Jan-2007  ad Sync with head.
 1.2.2.2 03-Sep-2006  yamt sync with head.
 1.2.2.1 29-Aug-2006  yamt file radeonfbvar.h was added on branch yamt-pdpolicy on 2006-09-03 15:24:23 +0000
 1.5.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.5.6.1 20-Aug-2007  ad Sync with HEAD.
 1.6.36.2 03-Aug-2007  macallan unbork fallout from newlock2 merge:
- reinitializing video after X exits works again
- backlight levels should be right again
 1.6.36.1 03-Aug-2007  macallan file radeonfbvar.h was added on branch matt-mips64 on 2007-08-03 05:40:48 +0000
 1.6.28.2 09-Oct-2010  yamt sync with head
 1.6.28.1 19-Aug-2009  yamt sync with head.
 1.6.2.2 03-Aug-2007  macallan unbork fallout from newlock2 merge:
- reinitializing video after X exits works again
- backlight levels should be right again
 1.6.2.1 03-Aug-2007  macallan file radeonfbvar.h was added on branch jmcneill-pm on 2007-08-03 05:40:48 +0000
 1.7.4.1 05-Mar-2011  rmind sync with head
 1.7.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.7.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.10.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.8.5 05-Apr-2012  mrg sync to latest -current.
 1.11.8.4 06-Mar-2012  mrg sync to -current
 1.11.8.3 06-Mar-2012  mrg sync to -current
 1.11.8.2 04-Mar-2012  mrg sync to latest -current.
 1.11.8.1 18-Feb-2012  mrg merge to -current.
 1.11.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.4.2 23-Jan-2013  yamt sync with head
 1.11.4.1 17-Apr-2012  yamt sync with head
 1.13.2.1 21-Mar-2012  riz Pull up following revision(s) (requested by macallan in ticket #132):
sys/dev/pci/radeonfb.c: revision 1.59
sys/dev/pci/radeonfbvar.h: revision 1.16
adjust the backlight control interface to match the other drivers ( genfb,
r128fb, voyagerfb etc. ) so the lid_switch script does the right thing
noticed by riz, I thought I fixed that a long time ago
 1.16.2.4 03-Dec-2017  jdolecek update from HEAD
 1.16.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.2 23-Jun-2013  tls resync from head
 1.16.2.1 25-Feb-2013  tls resync with head
 1.18.4.1 18-May-2014  rmind sync with head
 1.20.26.1 17-Jul-2020  martin Pull up following revision(s) (requested by macallan in ticket #1019):

sys/dev/pci/radeonfbvar.h: revision 1.21
sys/dev/pci/radeonfb.c: revision 1.107

reduce stack usage in radeonfb_pickres() and radeonfb_set_cursor()

forgot to commit a header change, again...
 1.27 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.26 31-Jul-2012  bouyer branches: 1.26.2; 1.26.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.25 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.24 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.23 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.22 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.21 04-Apr-2011  dyoung branches: 1.21.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.20 05-Nov-2010  jakllsch branches: 1.20.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.19 14-Mar-2009  dsl branches: 1.19.2; 1.19.4;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.18 18-Mar-2008  cube branches: 1.18.4; 1.18.12; 1.18.18;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.17 24-Oct-2007  xtraeme branches: 1.17.12; 1.17.16;
- Add support for the ServerWorks HT-1000 IDE Controller in rccide.
- Add support for another ServerWorks HT-1000 SATA Controller.

From OpenBSD.
 1.16 09-Feb-2007  ad branches: 1.16.18; 1.16.20; 1.16.24;
Merge newlock2 to head.
 1.15 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.14 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.13 11-Dec-2005  christos branches: 1.13.20; 1.13.22;
merge ktrace-lwp.
 1.12 21-Aug-2004  thorpej branches: 1.12.12;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.11 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.10 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.9 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.8 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.7 03-Jan-2004  thorpej branches: 1.7.4;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.6 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.5 14-Dec-2003  thorpej Liberally apply "static", and wrap a line.
 1.4 02-Dec-2003  bouyer Use a different interrupt routine for the CSB6. The CSB6 doens't
assert IDEDMA_CTL_INTR for non-DMA commands.
It would be nice to have a way to know if the interrupt was for us or not at
this point, but for now let wdcintr() deal with it.
Problem reported and patch tested by Martti Kuparinen.
 1.3 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.2 07-Nov-2003  enami Sync with sys/dev/pci/pcidevs change (ProductID 0x0213 was renamed
to CSB6_RAID from CSB6_IDE). And exclude the device of RAID subclass
(i.e., match IDE subclass only).
 1.1 04-Nov-2003  mycroft Re-add ServerWorks IDE support, as "rccide". Note: this is untested, as I no
longer have a ServerWorks-based motherboard.
 1.7.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.7.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.7.4.2 03-Aug-2004  skrll Sync with HEAD
 1.7.4.1 03-Jan-2004  skrll file rccide.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.12.12.4 24-Mar-2008  yamt sync with head.
 1.12.12.3 27-Oct-2007  yamt sync with head.
 1.12.12.2 26-Feb-2007  yamt sync with head.
 1.12.12.1 30-Dec-2006  yamt sync with head.
 1.13.22.2 10-Dec-2006  yamt sync with head.
 1.13.22.1 22-Oct-2006  yamt sync with head
 1.13.20.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.13.20.1 18-Nov-2006  ad Sync with head.
 1.16.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.16.20.2 23-Mar-2008  matt sync with HEAD
 1.16.20.1 06-Nov-2007  matt sync with HEAD
 1.16.18.1 28-Oct-2007  joerg Sync with HEAD.
 1.17.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.12.1 24-Mar-2008  keiichi sync with head.
 1.18.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.4.1 04-May-2009  yamt sync with head.
 1.19.4.2 21-Apr-2011  rmind sync with head
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.19.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.20.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.21.4.1 30-Oct-2012  yamt sync with head
 1.26.4.1 18-May-2014  rmind sync with head
 1.26.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.8 08-Jul-2014  msaitoh Add support for RDC R1012 IDE controller.
Tested on EduCake(Vortex86EX) with sdcard:

| read | write |
------+---------+-------+
pciide| 999519| 244574|
rdcide| 16011238| 939895|
------+---------+-------+
(bytes/sec)
rd: dd if=/dev/rwd0a of=/dev/null bs=1m count=100
wr: dd if=/dev/zero of=/var/tmp/hoge bs=1m count=100
 1.7 31-Jul-2012  bouyer branches: 1.7.2; 1.7.12;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.6 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.5 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.4 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.3 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.2 04-Apr-2011  dyoung branches: 1.2.2; 1.2.6; 1.2.8;
Make rdcide_chip_map()'s pci_attach_args argument const.
 1.1 04-Apr-2011  bouyer Add rdcide(4), a driver for the IDE controller found in RDC's
vortex86/PMX-1000 system-on-chip.
 1.2.8.1 30-Oct-2012  yamt sync with head
 1.2.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.6.1 04-Apr-2011  jruoho file rdcide.c was added on branch jruoho-x86intr on 2011-06-06 09:08:26 +0000
 1.2.2.2 21-Apr-2011  rmind sync with head
 1.2.2.1 04-Apr-2011  rmind file rdcide.c was added on branch rmind-uvmplock on 2011-04-21 01:42:00 +0000
 1.7.12.1 10-Aug-2014  tls Rebase.
 1.7.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.1 04-Apr-2011  bouyer branches: 1.1.2; 1.1.6;
Add rdcide(4), a driver for the IDE controller found in RDC's
vortex86/PMX-1000 system-on-chip.
 1.1.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.1 04-Apr-2011  jruoho file rdcide_reg.h was added on branch jruoho-x86intr on 2011-06-06 09:08:26 +0000
 1.1.2.2 21-Apr-2011  rmind sync with head
 1.1.2.1 04-Apr-2011  rmind file rdcide_reg.h was added on branch rmind-uvmplock on 2011-04-21 01:42:00 +0000
 1.11 18-Jan-2025  mrg match RTS5249. fix a comment.
 1.10 25-Sep-2022  thorpej branches: 1.10.10;
Remove unnecessary include of <sys/malloc.h>.
 1.9 27-Apr-2020  jmcneill Add support for Realtek RTS522A
 1.8 09-Dec-2018  jdolecek branches: 1.8.4;
use pci_intr_establish_xname() everywhere
 1.7 24-Apr-2018  maya branches: 1.7.2;
rtsx(4): Add support for RT525A, from openbsd.

ok rkujawa
 1.6 07-Jul-2016  msaitoh branches: 1.6.10; 1.6.16;
KNF. Remove extra spaces. No functional change.
 1.5 06-Nov-2015  nonaka Always use pci_intr_alloc(9)/pci_intr_release(9).
 1.4 05-Sep-2015  nonaka Use MSI/MSI-X instead of legacy INTx, if available.
 1.3 29-Oct-2014  nonaka branches: 1.3.2;
Added RTS5227/RTL8402/RTL8411/RTL8411B support.
 1.2 29-Mar-2014  christos branches: 1.2.4; 1.2.6; 1.2.8; 1.2.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.1 19-Mar-2014  nonaka Add a driver for Realtek RTS5209/RTS5229 Card Reader.
Ported from OpenBSD.
 1.2.10.3 03-Dec-2017  jdolecek update from HEAD
 1.2.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.10.1 29-Mar-2014  tls file rtsx_pci.c was added on branch tls-maxphys on 2014-08-20 00:03:48 +0000
 1.2.8.1 17-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #432):
sys/dev/ic/rtsxreg.h: revision 1.2
sys/dev/ic/rtsxvar.h: revision 1.2
sys/dev/pci/rtsx_pci.c: revision 1.3
sys/dev/ic/rtsx.c: revision 1.2
share/man/man4/rtsx.4: revision 1.3-1.4
Added RTS5227/RTL8402/RTL8411/RTL8411B support.
 1.2.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.6.1 29-Mar-2014  yamt file rtsx_pci.c was added on branch yamt-pagecache on 2014-05-22 11:40:33 +0000
 1.2.4.2 18-May-2014  rmind sync with head
 1.2.4.1 29-Mar-2014  rmind file rtsx_pci.c was added on branch rmind-smpnet on 2014-05-18 17:45:44 +0000
 1.3.2.3 09-Jul-2016  skrll Sync with HEAD
 1.3.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.2.1 22-Sep-2015  skrll Sync with HEAD
 1.6.16.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.6.16.1 02-May-2018  pgoyette Synch with HEAD
 1.6.10.1 14-Jun-2018  martin Pull up following revision(s) (requested by maya in ticket #878):

share/man/man4/rtsx.4: revision 1.5
sys/dev/pci/pcidevs: revision 1.1331
sys/dev/ic/rtsxreg.h: revision 1.3
sys/dev/ic/rtsxvar.h: revision 1.3
sys/dev/pci/rtsx_pci.c: revision 1.7
sys/dev/ic/rtsx.c: revision 1.3

add realtek RT525A PCI-E card reader
found in my Dell XPS 15 9550.

rtsx(4): Add support for RT525A, from openbsd.
ok rkujawa

Denote RTS525A, bump date
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.8.4.1 28-Apr-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #864):

share/man/man4/rtsx.4: revision 1.6
sys/dev/pci/pcidevs: revision 1.1410
sys/dev/pci/rtsx_pci.c: revision 1.9

Add an eclectic mix of
GeForce GTX 680, RTS522A PCI-E Card Reader, intel wifi 9560
+ whitespace

Add support for Realtek RTS522A
 1.10.10.1 02-Aug-2025  perseant Sync with HEAD
 1.58 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.57 21-Oct-2019  christos follow the channel locking protocol during probe (like the other drivers)
 1.56 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.55 20-Oct-2017  jdolecek branches: 1.55.2; 1.55.4;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.54 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.53 23-Aug-2016  msaitoh branches: 1.53.4;
Remove PCI_PRODUCT_CMDTECH_240's entry because CMDTECH_AAR_1210SA has
the same ID.
 1.52 29-Mar-2014  christos branches: 1.52.4; 1.52.6; 1.52.12;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.51 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.50 15-Sep-2013  martin Comment out unused variables
 1.49 27-Oct-2012  chs branches: 1.49.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.48 31-Jul-2012  bouyer branches: 1.48.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.47 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.46 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.45 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.44 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.43 04-Apr-2011  dyoung branches: 1.43.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.42 05-Nov-2010  jakllsch branches: 1.42.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.41 08-Jun-2010  mrg attach on Sil240 and IXP 300 chips as well, as if they are 3112
variants. should fix PR#32577, id's found in linux driver.
 1.40 23-Mar-2010  mrg only apply the satalink 3112 rev 0.1 and earlier to actual 3112 based
cards, not eg, 3512 cards.

should help performance for 3512 cards, derived from discussions in
PR#42980: satalink DMA fails under amd64.
 1.39 26-Nov-2009  njoly branches: 1.39.2; 1.39.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.38 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.37 10-Apr-2008  cegger branches: 1.37.2; 1.37.4;
use aprint_*_dev and device_xname
 1.36 18-Mar-2008  cube Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.35 27-Dec-2007  ws branches: 1.35.2; 1.35.6;
Change cacheline fixup for 3114's second set of channels, too.
Fix provided by Masanori Kanaoka in PR 37519.
Fixed differently to avoid code duplication.
 1.34 09-Feb-2007  ad branches: 1.34.20; 1.34.26; 1.34.32;
Merge newlock2 to head.
 1.33 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.32 25-Oct-2006  bouyer Use common wdc_sataprobe() where possible; explain why we can't in satalink.c
 1.31 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.30 26-Jun-2006  xtraeme branches: 1.30.4; 1.30.6;
Add missing __KERNEL_RCSID()
 1.29 29-Mar-2006  thorpej branches: 1.29.4;
Use device_cfdata().
 1.28 16-Jan-2006  bouyer branches: 1.28.2; 1.28.4; 1.28.6; 1.28.8; 1.28.10;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.27 24-Dec-2005  perry branches: 1.27.2;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.26 11-Dec-2005  christos merge ktrace-lwp.
 1.25 01-Jun-2005  ragge branches: 1.25.2;
The read/read multiple cacheline problem may also appear on the 3114
controller, so apply the cacheline fix to it as well.
 1.24 27-Feb-2005  perry branches: 1.24.2;
nuke trailing whitespace
 1.23 05-Sep-2004  skd branches: 1.23.4; 1.23.6;
Fill out correct cap variable so that DMA works again.
 1.22 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.21 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.20 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.19 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.18 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.17 19-Jul-2004  msaitoh branches: 1.17.2;
Add Adaptec AAR-1210SA serial ATA RAID.
RAID is not supported by this driver.
 1.16 23-Jun-2004  briggs When the Silicon Image 3112 retries a PCI memory read command, it
may retry it as a memory read multiple command under some circumstances.
This can totally confuse some PCI controllers, so ensure that it
will never do this by making sure that the Read Threshold (FIFO
Read Request Control) field of the FIFO Valid Byte Count and Control
registers for both channels (BA5 offset 0x40 and 0x44) are set to
be at least as large as the cacheline size register (the unit of
measure for these registers is 32 bytes).
 1.15 28-May-2004  thorpej Use the common sata_speed() routine.
 1.14 25-May-2004  thorpej Add the notion of "shadow registers" to the wdc driver. These shadow
registers are registers that overlap with others on many controllers, but
which may actually be distinct on some controllers. Right now, the two
shadows are:

- wd_status (usually overlaps wd_command)
- wd_features (usually overlaps wd_error)

Add a new helper function, wdc_init_shadow_regs(), used to initialize
the shadow register handles on controllers where they do actually overlap.

Partially from Jordan Rhody @ Wasabi Systems, Inc.
 1.13 07-May-2004  sekiya Add support for Silicon Image 3512 chip to satalink driver -- treat it as
a 3112 variant (without RAID support), which does the right thing with the
controller on my K8NNXP.
 1.12 07-Jan-2004  thorpej branches: 1.12.2;
Initialize some importantant members of the drive info structure. (I have
no idea how this worked for me before, but I swear that it did...)

kern/24015.
 1.11 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.10 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.9 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.8 31-Dec-2003  martin Include <dev/ata/atareg.h>, so that WDSD_IBM is defined.
 1.7 30-Dec-2003  thorpej Move the drive probing code out of atabusconfig() and into a new
wdc_drvprobe() function. wdc_drvprobe() is used if the controller
does not specify a custom one prior to calling wdcattach(). The
WDC_CAPABILITY_DRVPROBE bit is gone.
 1.6 20-Dec-2003  thorpej Fix a typo.
 1.5 20-Dec-2003  thorpej Add support for the Silicon Image 3114 SATALink 4-port SATA controller.
 1.4 19-Dec-2003  thorpej Use a register map to find the offsets of various per-channel
registers in the BA5 space.
 1.3 15-Dec-2003  thorpej Remove the notice that was in cmdide.c before SATALink support was split
out. All of the code in this file was written by me.
 1.2 15-Dec-2003  thorpej Use the SControl and SStatus registers to query the SATA PHY for
device detection.
 1.1 13-Dec-2003  thorpej Split out the Silicon Image SATALink support into its own driver,
"satalink".
 1.12.2.1 11-May-2004  tron Pull up revision 1.13 (requested by sekiya in ticket #284):
Add support for Silicon Image 3512 chip to satalink driver -- treat it as
a 3112 variant (without RAID support), which does the right thing with the
controller on my K8NNXP.
 1.17.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.17.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.17.2.2 03-Aug-2004  skrll Sync with HEAD
 1.17.2.1 19-Jul-2004  skrll file satalink.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.23.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.4.1 29-Apr-2005  kent sync with -current
 1.24.2.1 01-Jun-2005  tron Pull up revision 1.25 (requested by ragge in ticket #364):
The read/read multiple cacheline problem may also appear on the 3114
controller, so apply the cacheline fix to it as well.
 1.25.2.5 24-Mar-2008  yamt sync with head.
 1.25.2.4 21-Jan-2008  yamt sync with head
 1.25.2.3 26-Feb-2007  yamt sync with head.
 1.25.2.2 30-Dec-2006  yamt sync with head.
 1.25.2.1 21-Jun-2006  yamt sync with head.
 1.27.2.1 01-Feb-2006  yamt sync with head.
 1.28.10.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.28.8.1 19-Apr-2006  elad sync with head.
 1.28.6.2 11-Aug-2006  yamt sync with head
 1.28.6.1 01-Apr-2006  yamt sync with head.
 1.28.4.1 22-Apr-2006  simonb Sync with head.
 1.28.2.1 09-Sep-2006  rpaulo sync with head
 1.29.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.30.6.2 10-Dec-2006  yamt sync with head.
 1.30.6.1 22-Oct-2006  yamt sync with head
 1.30.4.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.30.4.1 18-Nov-2006  ad Sync with head.
 1.34.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.34.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.34.20.2 23-Mar-2008  matt sync with HEAD
 1.34.20.1 09-Jan-2008  matt sync with HEAD
 1.35.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.35.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.35.2.1 24-Mar-2008  keiichi sync with head.
 1.37.4.3 11-Aug-2010  yamt sync with head.
 1.37.4.2 11-Mar-2010  yamt sync with head
 1.37.4.1 16-May-2008  yamt sync with head.
 1.37.2.1 18-May-2008  yamt sync with head.
 1.39.4.4 21-Apr-2011  rmind sync with head
 1.39.4.3 05-Mar-2011  rmind sync with head
 1.39.4.2 03-Jul-2010  rmind sync with head
 1.39.4.1 30-May-2010  rmind sync with head
 1.39.2.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.39.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.39.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.43.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.43.4.1 30-Oct-2012  yamt sync with head
 1.48.2.3 03-Dec-2017  jdolecek update from HEAD
 1.48.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.49.2.1 18-May-2014  rmind sync with head
 1.52.12.1 18-Jan-2017  skrll Sync with netbsd-5
 1.52.6.1 05-Oct-2016  skrll Sync with HEAD
 1.52.4.1 08-Dec-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1290):
sys/dev/pci/satalink.c: revision 1.53
Remove PCI_PRODUCT_CMDTECH_240's entry because CMDTECH_AAR_1210SA has
the same ID.
 1.53.4.2 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.53.4.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.55.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.55.4.1 10-Jun-2019  christos Sync with HEAD
 1.55.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.8 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.7 31-Jul-2012  bouyer branches: 1.7.2; 1.7.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.6 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.5 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.4 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.3 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.2 04-Apr-2011  dyoung branches: 1.2.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.1 06-Nov-2010  jakllsch branches: 1.1.2; 1.1.6;
Add Intel SCH IDE controller driver.
From OpenBSD via Tomokazu HARADA in PR#42310.
 1.1.6.3 21-Apr-2011  rmind sync with head
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 06-Nov-2010  rmind file schide.c was added on branch rmind-uvmplock on 2011-03-05 20:53:57 +0000
 1.1.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.1 30-Oct-2012  yamt sync with head
 1.7.4.1 18-May-2014  rmind sync with head
 1.7.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.21 05-Jan-2023  msaitoh Add quirk setting for some Intel eMMC devices.

On some Intel eMMC controllers, the driver reports "autoconfiguration error:
couldn't enable card: 60" even though they really have eMMC device.
This change fixes the problem on some machines. It might be required more
quirks for newer devices (or HS400 support). At least, this change fixes the
problem on GIGABYTE MA10-ST0.
 1.20 04-Jan-2023  msaitoh Fix typo. No functional change.
 1.19 14-Oct-2022  jmcneill branches: 1.19.2;
Disable ADMA2 on Ricoh SDHCI controllers.

PR# 57015
 1.18 10-Nov-2021  msaitoh Support 64bit BAR.
 1.17 01-Jan-2020  mlelstv Add support for single power writes, and enable for Ricoh 5u823.
 1.16 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.15 28-Sep-2019  mlelstv Fix typo, remove debug printf.
 1.14 27-Apr-2017  msaitoh branches: 1.14.2; 1.14.10; 1.14.16;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.13 17-Feb-2017  nonaka branches: 1.13.4;
sdhc(4): hardware reset support for Intel eMMC controller
 1.12 09-Aug-2015  mlelstv branches: 1.12.2; 1.12.4;
Replace the LOWER_FREQ quirk with the SLOW_SDR50 quirk for the
Ricoh 5U823 controller. This stabilizes SD cards at standard speed
and high speed and also UHS-I SDR50.
 1.11 29-Mar-2014  christos branches: 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.10 20-Dec-2012  jakllsch branches: 1.10.2;
Add detachment support for sdhc_pci.
Tested on an ExpressCard JMicron JMB38[89] with as-of-yet-uncommitted changes.
 1.9 29-Jul-2012  matt branches: 1.9.2;
Add FORCE_DMA quirk for 5U822 (already in lace for 5C822).
 1.8 12-Jul-2012  jakllsch Ricoh R5C822 has working DMA, but does not advertise support for it, use force.
 1.7 02-Mar-2012  nonaka Added Ricoh 5U822/5U823 SD/MMC Controller support.
 1.6 02-Feb-2012  nonaka Use "opt_sdmmc.h" for SDHC_DEBUG.
 1.5 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.4 02-Feb-2011  jakllsch branches: 1.4.4; 1.4.8;
Like some other TI SDHCI parts, PCI_PRODUCT_TI_PCIXX12SD also needs the SD
card moved to the SDHCI controller.
 1.3 02-Oct-2009  uebayasi branches: 1.3.2; 1.3.6; 1.3.8; 1.3.10; 1.3.12;
Pass not (struct sdhc_pci_softc *) but (struct sdhc_softc *) to sdhc_intr().
No functional change because struct sdhc_pci_softc has struct sdhc_softc as
the 1st member.
 1.2 29-Jun-2009  hubertf Use PCI IDs from pcidevs, instead of storing them in here.
Compile tested and OK'd by NONAKA Kimihiro.
 1.1 21-Apr-2009  nonaka branches: 1.1.2; 1.1.4; 1.1.6;
Added SD/MMC support from OpenBSD.
tested on i386, amd64 at current-users ML by pgoyette@.
tested on zaurus by myself.
 1.1.6.3 23-Jul-2009  jym Sync with HEAD.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 21-Apr-2009  jym file sdhc_pci.c was added on branch jym-xensuspend on 2009-05-13 17:20:29 +0000
 1.1.4.4 11-Mar-2010  yamt sync with head
 1.1.4.3 18-Jul-2009  yamt sync with head.
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 21-Apr-2009  yamt file sdhc_pci.c was added on branch yamt-nfs-mp on 2009-05-04 08:13:01 +0000
 1.1.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.1.2.1 21-Apr-2009  skrll file sdhc_pci.c was added on branch nick-hppapmap on 2009-04-28 07:35:59 +0000
 1.3.12.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.8.2 21-Apr-2010  matt sync to netbsd-5
 1.3.8.1 02-Oct-2009  matt file sdhc_pci.c was added on branch matt-nb5-mips64 on 2010-04-21 00:27:49 +0000
 1.3.6.1 05-Mar-2011  rmind sync with head
 1.3.2.2 28-Oct-2009  bouyer Pull up the following revisions, requested by sborrill in ticket #1114:
share/man/man4/sdhc.4 1.1-1.2
sys/dev/pci/sdhc_pci.c 1.1-1.3
distrib/sets/lists/man/mi patch
share/man/man4/Makefile patch
sys/arch/amd64/conf/GENERIC patch
sys/arch/i386/conf/ALL patch
sys/arch/i386/conf/GENERIC patch
sys/dev/pci/files.pci patch
sys/dev/pci/pcidevs patch
sys/dev/pci/pcidevs.h regen
sys/dev/pci/pcidevs_data.h regen

Add sdhc(4), a driver for SD controllers following the SD Host
Controller Standard Simplified Specification.
 1.3.2.1 02-Oct-2009  bouyer file sdhc_pci.c was added on branch netbsd-5 on 2009-10-28 09:03:42 +0000
 1.4.8.4 06-Mar-2012  mrg sync to -current
 1.4.8.3 06-Mar-2012  mrg sync to -current
 1.4.8.2 04-Mar-2012  mrg sync to latest -current.
 1.4.8.1 18-Feb-2012  mrg merge to -current.
 1.4.4.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.4.3 23-Jan-2013  yamt sync with head
 1.4.4.2 30-Oct-2012  yamt sync with head
 1.4.4.1 17-Apr-2012  yamt sync with head
 1.9.2.3 03-Dec-2017  jdolecek update from HEAD
 1.9.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 25-Feb-2013  tls resync with head
 1.10.2.1 18-May-2014  rmind sync with head
 1.11.6.2 28-Aug-2017  skrll Sync with HEAD
 1.11.6.1 22-Sep-2015  skrll Sync with HEAD
 1.12.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.12.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.13.4.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.14.16.3 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1721):

sys/dev/pci/sdhc_pci.c: revision 1.21

Add quirk setting for some Intel eMMC devices.

On some Intel eMMC controllers, the driver reports "autoconfiguration error:
couldn't enable card: 60" even though they really have eMMC device.

This change fixes the problem on some machines. It might be required more
quirks for newer devices (or HS400 support). At least, this change fixes the
problem on GIGABYTE MA10-ST0.
 1.14.16.2 18-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1566):

sys/dev/pci/sdhc_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.1469
sys/dev/pci/pcidevs: revision 1.1470
sys/dev/pci/pcidevs: revision 1.1471
sys/dev/pci/pcidevs: revision 1.1472
sys/dev/pci/pcidevs: revision 1.1473
sys/dev/pci/pcidevs: revision 1.1474
sys/dev/pci/pcidevs: revision 1.1475
sys/dev/pci/pcidevs: revision 1.1476

Add some AMD 17h/9xh devices from OpenBSD.
Add AMD F17/Axh devices.
Add some Xeon Scalable devices from OpenBSD.
Update Intel Elkhart Lake devices.
Add Elkhart Lake Shared SRAM.
Fix typo. s/SSC/SCC/.
Fix typo. No functional change.
add Aquantia (Marvell) AQC113 ethernet devices and the variants
Add AMD Family 19h/1xh devices.
 1.14.16.1 03-Dec-2021  martin Pull up the followin revisions (all via patch), requested by msaitoh
in ticket #1383:

sys/dev/sdmmc/sdhc.c 1.110, 1.112
sys/dev/sdmmc/sdmmc_mem.c 1.74
sys/dev/pci/sdhc_pci.c 1.18

- Support 64bit BAR.
- Use unsigned to avoid undefined behavior in hwrite[12]() and
sdmmc_mem_sd_switch().
- Fix typo in comment.
 1.14.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.10.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14.2.3 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1889):

sys/dev/pci/sdhc_pci.c: revision 1.21

Add quirk setting for some Intel eMMC devices.

On some Intel eMMC controllers, the driver reports "autoconfiguration error:
couldn't enable card: 60" even though they really have eMMC device.

This change fixes the problem on some machines. It might be required more
quirks for newer devices (or HS400 support). At least, this change fixes the
problem on GIGABYTE MA10-ST0.
 1.14.2.2 18-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1783):

sys/dev/pci/sdhc_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.1469
sys/dev/pci/pcidevs: revision 1.1470
sys/dev/pci/pcidevs: revision 1.1471
sys/dev/pci/pcidevs: revision 1.1472
sys/dev/pci/pcidevs: revision 1.1473
sys/dev/pci/pcidevs: revision 1.1474
sys/dev/pci/pcidevs: revision 1.1475
sys/dev/pci/pcidevs: revision 1.1476

Add some AMD 17h/9xh devices from OpenBSD.
Add AMD F17/Axh devices.
Add some Xeon Scalable devices from OpenBSD.
Update Intel Elkhart Lake devices.
Add Elkhart Lake Shared SRAM.
Fix typo. s/SSC/SCC/.
Fix typo. No functional change.
add Aquantia (Marvell) AQC113 ethernet devices and the variants
Add AMD Family 19h/1xh devices.
 1.14.2.1 03-Dec-2021  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1713:

sys/dev/sdmmc/sdhc.c 1.110, 1.112
sys/dev/sdmmc/sdmmc_mem.c 1.74
sys/dev/pci/sdhc_pci.c 1.18

- Support 64bit BAR.
- Use unsigned to avoid undefined behavior in hwrite[12]() and
sdmmc_mem_sd_switch().
- Fix typo in comment.
 1.19.2.2 22-Aug-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #336):

sys/dev/pci/sdhc_pci.c: revision 1.21

Add quirk setting for some Intel eMMC devices.

On some Intel eMMC controllers, the driver reports "autoconfiguration error:
couldn't enable card: 60" even though they really have eMMC device.

This change fixes the problem on some machines. It might be required more
quirks for newer devices (or HS400 support). At least, this change fixes the
problem on GIGABYTE MA10-ST0.
 1.19.2.1 18-Jan-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #50):

sys/dev/pci/sdhc_pci.c: revision 1.20
sys/dev/pci/pcidevs: revision 1.1472
sys/dev/pci/pcidevs: revision 1.1473
sys/dev/pci/pcidevs: revision 1.1474
sys/dev/pci/pcidevs: revision 1.1475
sys/dev/pci/pcidevs: revision 1.1476

Update Intel Elkhart Lake devices.
Add Elkhart Lake Shared SRAM.
Fix typo. s/SSC/SCC/.
Fix typo. No functional change.
add Aquantia (Marvell) AQC113 ethernet devices and the variants
Add AMD Family 19h/1xh devices.
 1.23 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.22 31-Dec-2021  andvar s/interrups/interrupts/
 1.21 05-May-2021  jdolecek disable MSI for SiI3124 - interrupts don't seem to work on this old board
when MSI is enabled, maybe because it's behind a PCI bridge

PR kern/55115 by John D. Baker
 1.20 25-Oct-2018  jdolecek branches: 1.20.4; 1.20.16;
release intr if pci_intr_establish_xname() fails
 1.19 24-Oct-2018  jdolecek detach the controller itself on shutdown; adjust to not detach already
detached atabus/channel
 1.18 22-Oct-2018  jdolecek first disestablish interrupt, then release
 1.17 22-Oct-2018  jdolecek enable MSI support where available, blatantly copied from jmcneill's msk(4)
 1.16 21-Jun-2017  jdolecek branches: 1.16.4; 1.16.6;
switch to pci_intr_establish_xname()
 1.15 17-Jun-2017  jdolecek match Adaptec 1220SA; that card actually uses Silicon Image 3132, and works
well with the siisata(4) driver
 1.14 14-Jul-2016  msaitoh branches: 1.14.6; 1.14.10;
KNF. No functional change.
 1.13 29-Mar-2014  christos branches: 1.13.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.12 17-Aug-2013  jakllsch Revert previous; the SiI3114 is not even BAR/register compatible with
siisata(4).
 1.11 20-Oct-2012  matt branches: 1.11.2;
Recognize 3114.
 1.10 30-Jan-2012  drochner branches: 1.10.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.9 13-Nov-2010  uebayasi branches: 1.9.8; 1.9.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.8 24-Feb-2010  dyoung branches: 1.8.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.7 30-Jan-2010  jakllsch branches: 1.7.2;
Sprinkle __KERNEL_RCSID() into siisata(4).
Slightly adjust some comment styling.
 1.6 08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.5 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.4 04-Jul-2009  jakllsch Remove unused elements from siisata_softc.

Clean up siisata pci attachment.
noteable changes:
- Use aprint_*_dev where appropriate.
- Condense board match table and use C99 initializers.
- Use aprint_verbose for extra info.

Also, add 2009 to my copyright, as well as remove my local CVS tags.
 1.3 17-Jun-2009  jakllsch A few changes for siisata(4):

- Support detachment. From KIYOHARA Takashi.
- Add PCI detachment functionality (albeit not very interesting when
the bus can not yet be rescanned).
- Rework interrupt handlers to reduce near-duplicate code.
Borrowed from ahcisata(4).
- Attempt to make polled I/O work. Untested.
- Fix formatting of some messages.
- For always-polled commands, disable interrupt
at slot level rather than port level.
- Instead of busy-waiting indefinitely for completion of some commands
move on after 31 seconds. Use cv_timedwait(9) instead of DELAY(9).
- Use abstracted SATA FIS code.
- Enable use of disks that don't respond with the standard signature.
 1.2 16-Dec-2008  jakllsch branches: 1.2.2; 1.2.4;
In case the PCI command bits aren't already set, do so before performing
an access that requires them to be. From KIYOHARA Takashi.
 1.1 23-May-2008  jnemeth branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.14;
Import siisata(4) by Jonathan A. Kollasch.

The siisata driver supports the Silicon Image SteelVine family of SATA-II
controllers, interfacing the hardware with the ata(4) and atapi(4) sub-
systems.

The following controllers are supported by the siisata driver:

Silicon Image SiI3124 4-port PCI/PCI-X
Silicon Image SiI3132 2-port PCI-Express x1
Silicon Image SiI3531 1-port PCI-Express x1

SATA Native Command Queueing is not yet supported.
Device hot swapping is not yet supported.
Silicon Image's Software RAID is not yet supported by the
ataraid(4) driver.

Approved by: core (christos), releng (bouyer)
 1.1.14.3 28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisatavar.h: revision 1.4
sys/dev/pci/siisata_pci.c: revision 1.4
Remove unused elements from siisata_softc.
Clean up siisata pci attachment.
noteable changes:
- Use aprint_*_dev where appropriate.
- Condense board match table and use C99 initializers.
- Use aprint_verbose for extra info.
Also, add 2009 to my copyright, as well as remove my local CVS tags.
 1.1.14.2 28-Sep-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #1023):
sys/dev/ic/siisata.c: revision 1.3
sys/dev/ic/siisatareg.h: revision 1.3
sys/dev/ic/siisatavar.h: revision 1.3
sys/dev/pci/files.pci: revision 1.315
sys/dev/pci/siisata_pci.c: revision 1.3
A few changes for siisata(4):
- Support detachment. From KIYOHARA Takashi.
- Add PCI detachment functionality (albeit not very interesting when
the bus can not yet be rescanned).
- Rework interrupt handlers to reduce near-duplicate code.
Borrowed from ahcisata(4).
- Attempt to make polled I/O work. Untested.
- Fix formatting of some messages.
- For always-polled commands, disable interrupt
at slot level rather than port level.
- Instead of busy-waiting indefinitely for completion of some commands
move on after 31 seconds. Use cv_timedwait(9) instead of DELAY(9).
- Use abstracted SATA FIS code.
- Enable use of disks that don't respond with the standard signature.
 1.1.14.1 09-Jan-2009  snj branches: 1.1.14.1.4;
Pull up following revision(s) (requested by jakllsch in ticket #244):
sys/dev/pci/siisata_pci.c: revision 1.2
In case the PCI command bits aren't already set, do so before performing
an access that requires them to be. From KIYOHARA Takashi.
 1.1.14.1.4.2 29-Apr-2011  matt Add 3114 entry
 1.1.14.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.1.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 23-May-2008  wrstuden file siisata_pci.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2 04-Jun-2008  yamt sync with head
 1.1.4.1 23-May-2008  yamt file siisata_pci.c was added on branch yamt-pf42 on 2008-06-04 02:05:14 +0000
 1.1.2.3 17-Jan-2009  mjf Sync with HEAD.
 1.1.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1 23-May-2008  mjf file siisata_pci.c was added on branch mjf-devfs2 on 2008-06-02 13:23:43 +0000
 1.2.4.5 11-Mar-2010  yamt sync with head
 1.2.4.4 18-Jul-2009  yamt sync with head.
 1.2.4.3 20-Jun-2009  yamt sync with head
 1.2.4.2 04-May-2009  yamt sync with head.
 1.2.4.1 16-Dec-2008  yamt file siisata_pci.c was added on branch yamt-nfs-mp on 2009-05-04 08:13:01 +0000
 1.2.2.1 23-Jul-2009  jym Sync with HEAD.
 1.7.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.2.1 05-Mar-2011  rmind sync with head
 1.9.12.1 18-Feb-2012  mrg merge to -current.
 1.9.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.8.2 30-Oct-2012  yamt sync with head
 1.9.8.1 17-Apr-2012  yamt sync with head
 1.10.6.3 03-Dec-2017  jdolecek update from HEAD
 1.10.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.2.2 18-May-2014  rmind sync with head
 1.11.2.1 28-Aug-2013  rmind sync with head
 1.13.6.2 28-Aug-2017  skrll Sync with HEAD
 1.13.6.1 05-Oct-2016  skrll Sync with HEAD
 1.14.10.2 25-Jun-2017  snj Pull up following revision(s) (requested by jdolecek in ticket #56):
sys/dev/pci/mvsata_pci.c: revision 1.9
sys/dev/pci/siisata_pci.c: revision 1.16
switch to pci_intr_establish_xname()
 1.14.10.1 25-Jun-2017  snj Pull up following revision(s) (requested by jdolecek in ticket #55):
share/man/man4/siisata.4: revision 1.6
sys/dev/pci/pcidevs: revision 1.1291
sys/dev/pci/siisata_pci.c: revision 1.15
add entry for Adaptec 1220SA
--
match Adaptec 1220SA; that card actually uses Silicon Image 3132, and works
well with the siisata(4) driver
--
add Adaptec 1220SA
 1.14.6.2 17-Jun-2017  jdolecek revert, bad tree
 1.14.6.1 17-Jun-2017  jdolecek match Adaptec 1220SA; that card actually uses Silicon Image 3132, and works
well with the siisata(4) driver
 1.16.6.1 10-Jun-2019  christos Sync with HEAD
 1.16.4.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.20.16.1 13-May-2021  thorpej Sync with HEAD.
 1.20.4.1 09-May-2021  martin Pull up following revision(s) (requested by dolecek in ticket #1270):

sys/dev/pci/siisata_pci.c: revision 1.21

disable MSI for SiI3124 - interrupts don't seem to work on this old board
when MSI is enabled, maybe because it's behind a PCI bridge

PR kern/55115 by John D. Baker
 1.27 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.26 19-Oct-2009  bouyer branches: 1.26.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.25 15-May-2009  tsutsui Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2
 1.24 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.23 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.22 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.21 16-Nov-2006  christos branches: 1.21.52; 1.21.68;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 11-Dec-2005  christos branches: 1.19.20; 1.19.22;
merge ktrace-lwp.
 1.18 28-Jun-2005  thorpej branches: 1.18.2;
Use ANSI function decls and static.
 1.17 27-Feb-2005  perry nuke trailing whitespace
 1.16 04-Feb-2005  perry de-__P
 1.15 09-Apr-2003  thorpej branches: 1.15.2; 1.15.10; 1.15.12;
Use PAGE_SIZE rather than NBPG.
 1.14 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.13 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 23-Apr-2002  bouyer More copyright fixes, pointed out by Thomas. Thanks !
 1.10 20-Apr-2002  bouyer Move a few things around, so that ic/siop_common.c and pci/siop_pci_common.c
can be compiled without including siopvar.h.
 1.9 13-Nov-2001  lukem add RCSID
 1.8 15-May-2000  bouyer branches: 1.8.6; 1.8.8; 1.8.10;
- split siop_pci in attachements vs helper functions, for comming esiop
- add a reset callback to enable PCI-specific features. This improve bandwith
by a factor of 2 on my alpha with a 875 !
- sync copyrigth notice
 1.7 10-May-2000  thorpej Support 64-bit PCI memory mapping registers, as sometimes are used
on the Symbios 53c896 controller. Also, prefer memory space over
I/O space.
 1.6 09-May-2000  bouyer Ops, abort if we can't map the registers ! Pointed out by Matthias Drochner.
 1.5 06-May-2000  soren Print the usual interrupt line.
 1.4 02-May-2000  bouyer - do sync/wide negotiation
- use a circular queue for the start slots, so that order has better chances
to be preserved.
 1.3 02-May-2000  nathanw In siop_lookup_product(), actually check the PCI *vendor* ID as well as the
product ID.
Prevents false matches of other devices, such as the DEC 21050 ppb.
 1.2 27-Apr-2000  bouyer Fix copyrigth notice.
 1.1 21-Apr-2000  bouyer Snapshot of work in progress: new driver for the NCR 53c8xx SCSI controller
(the name 'siop' is still being discussed, may change).
Only basic disconnect/reselect for now, no sync/wide negotiation.
Tested with 810A, 875 and 895 on i386 only.
The bus-independant part should also be able to handle the 53c720 and 53c770.
A new driver with enhanced script should appear for the 825/875/895 'soon'.
 1.8.10.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.8.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.8.8.1 14-Nov-2001  nathanw Catch up to -current.
 1.8.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.6.1 15-May-2000  bouyer file siop_pci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:37 +0000
 1.15.12.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.12.1 12-Feb-2005  yamt sync with head.
 1.15.10.1 29-Apr-2005  kent sync with -current
 1.15.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.18.2.1 30-Dec-2006  yamt sync with head.
 1.19.22.2 10-Dec-2006  yamt sync with head.
 1.19.22.1 22-Oct-2006  yamt sync with head
 1.19.20.1 18-Nov-2006  ad Sync with head.
 1.21.68.2 23-Jul-2009  jym Sync with HEAD.
 1.21.68.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.52.2 11-Mar-2010  yamt sync with head
 1.21.52.1 16-May-2009  yamt sync with head
 1.26.4.1 05-Mar-2011  rmind sync with head
 1.39 04-Oct-2025  thorpej Use device_{get,set}prop_bool() for "use_pciclock".
 1.38 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.37 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.36 17-Oct-2016  flxd branches: 1.36.14; 1.36.16;
Add 53C810AP for FreeAXP's emulation of a DEC KZPAA adapter.
 1.35 29-Mar-2014  christos branches: 1.35.6; 1.35.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.34 13-Nov-2010  uebayasi branches: 1.34.8; 1.34.18; 1.34.22;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.33 26-Nov-2009  njoly branches: 1.33.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.32 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.31 16-May-2009  tsutsui Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)
 1.30 15-May-2009  tsutsui Split device_t/softc.

No crash on:
esiop0 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0 at gsc0 hpa 0xf0830000 path 2/0/7 irq 3 ipl 6: NCR53C720 rev 2
 1.29 13-Feb-2009  bouyer Make sure PCI_COMMAND_MASTER_ENABLE is set in PCI_COMMAND_STATUS_REG.
 1.28 11-Jun-2008  kiyohara branches: 1.28.4; 1.28.10;
Support use PCI Clock(SF_CHIP_USEPCIC). We can set the value "use_pciclock"
by prop_dictionary_set_bool().
 1.27 10-Apr-2008  cegger branches: 1.27.2; 1.27.4; 1.27.6; 1.27.8;
use aprint_*_dev and device_xname
 1.26 11-Dec-2005  christos branches: 1.26.70;
merge ktrace-lwp.
 1.25 28-Jun-2005  thorpej Use ANSI function decls and static.
 1.24 27-Feb-2005  perry nuke trailing whitespace
 1.23 04-Feb-2005  perry de-__P
 1.22 10-Mar-2004  bouyer branches: 1.22.8; 1.22.10;
The 1010-66 always generate AIP values on the bus, regardless of the SCNTL4
settings. Disable AIP completely, as this confuse pre-Ultra160 drives.
From FreeBSD.
 1.21 25-Oct-2003  christos return not break.
 1.20 25-Oct-2003  christos Fix uninitialized variable warnings
 1.19 09-Apr-2003  thorpej branches: 1.19.2;
Use PAGE_SIZE rather than NBPG.
 1.18 31-Jan-2003  thorpej Use aprint_*().
 1.17 04-May-2002  bouyer branches: 1.17.4;
It seems that the 1010-33 has a bug: it sometimes generate spurious SCSI gross
errors for narrow transfers after a reselect. FreeBSD sym driver has a comment
about this, but their workaround (disable SCSI gross error reports) doesn't
work for me. Instead dissallow disconnect if the target is not wide
(FreeBSD doens't allow disconnect until the target has been fully probed, which
is why they may not have noticed my problem).
 1.16 26-Apr-2002  thorpej 53c1010 chips are ultra3, not ultra2.
 1.15 23-Apr-2002  bouyer More copyright fixes, pointed out by Thomas. Thanks !
 1.14 23-Apr-2002  bouyer - factor out parts of (e)siop_attach() to siop_common_attach()
- Add support for DT transfers (aka Ultra/160) in esiop

Note that DT transfers are not enabled for 53c1010-33 rev 0 yet; if I trust
FreeBSD it has a bug which prevent them to do DT properly.
From the same source there may be issues with some revs of 53c1010-66.
 1.13 23-Apr-2002  bouyer Enable software LED control based on LED0 feature, not #define.
For now, set the LED0 feature if SIOP_SYMLED is defined in siop_pci_common.c.
From Jason R Thorpe.
 1.12 23-Apr-2002  bouyer Set SF_CHIP_LEDC for chips that support it. Based on patch sent in private
mail by Jason R Thorpe.
 1.11 20-Apr-2002  bouyer Move a few things around, so that ic/siop_common.c and pci/siop_pci_common.c
can be compiled without including siopvar.h.
 1.10 08-Feb-2002  briggs Dup 53c1010-33 entry for 53c1010-66 (PCI_PRODUCT_SYMBIOS_1010_2).
 1.9 13-Nov-2001  lukem add RCSID
 1.8 15-Mar-2001  bouyer branches: 1.8.2;
1010 has clock quadrupler but without PPL, so use SF_CHIP_DBLR.
 1.7 12-Mar-2001  bouyer Preliminary support for SYM53C1010-33 (at 80MB/s only for now), based on
patches sent by Matthias Drochner <M.Drochner@fz-juelich.de> and
Kenneth R Westerback <kwesterback@home.com>
 1.6 10-Jan-2001  thorpej branches: 1.6.2;
Add the 53c1510d and 53c895a. 1510d confirmed working by
Mark Davies <mark@MCS.VUW.AC.NZ>.
 1.5 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.4 29-Nov-2000  matt Fix c896 support. If the first mem bar is 64bit, then the second one will
be too. And offset for the 2nd being after the 1st by a 64-bit bar, not
32-bit.
 1.3 23-Oct-2000  bouyer branches: 1.3.2;
Add ram size to struct properties, and pass it to the bus independant part.
 1.2 25-May-2000  bouyer branches: 1.2.4;
Separate the sheduler from the main script, allocate another DMA-safe
memory page for the sheduler. Put the main script in the on-chip RAM when
available.
Avoid a null-pointer dereference when DSA is invalid.
 1.1 15-May-2000  bouyer - split siop_pci in attachements vs helper functions, for comming esiop
- add a reset callback to enable PCI-specific features. This improve bandwith
by a factor of 2 on my alpha with a 875 !
- sync copyrigth notice
 1.2.4.3 29-Jan-2002  he Pull up revisions 1.6-1.8 (requested by bouyer):
Add support for the 53c1010-33, and bring documentation up to
date.
 1.2.4.2 20-Mar-2001  he Pull up revision 1.4 (requested by matt):
Fix c896 support related to PCI configuration and handling of
64-bit BARs.
 1.2.4.1 15-Dec-2000  he Pull up revision 1.3 (requested by bouyer):
Speed improvements to the siop driver, and add tagged queueing
support. As a side effect, better handling of some not so common
phase or message sequences.
 1.3.2.7 27-Mar-2001  bouyer Sync with HEAD.
 1.3.2.6 12-Mar-2001  bouyer Sync with HEAD.
 1.3.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.3.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 23-Oct-2000  bouyer file siop_pci_common.c was added on branch thorpej_scsipi on 2000-11-20 11:42:37 +0000
 1.6.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.6.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.6.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.8.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.8.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.4.1 17-Mar-2005  tron Pull up revision 1.22 (requested by bouyer in ticket #1748):
The 1010-66 always generate AIP values on the bus, regardless of the SCNTL4
settings. Disable AIP completely, as this confuse pre-Ultra160 drives.
From FreeBSD.
 1.19.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.10.1 12-Feb-2005  yamt sync with head.
 1.22.8.1 29-Apr-2005  kent sync with -current
 1.26.70.2 29-Jun-2008  mjf Sync with HEAD.
 1.26.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.8.1 18-Jun-2008  simonb Sync with head.
 1.27.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.4.3 11-Mar-2010  yamt sync with head
 1.27.4.2 16-May-2009  yamt sync with head
 1.27.4.1 04-May-2009  yamt sync with head.
 1.27.2.1 17-Jun-2008  yamt sync with head.
 1.28.10.2 23-Jul-2009  jym Sync with HEAD.
 1.28.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.4.1 03-Mar-2009  skrll Sync with HEAD.
 1.33.4.1 05-Mar-2011  rmind sync with head
 1.34.22.1 18-May-2014  rmind sync with head
 1.34.18.2 03-Dec-2017  jdolecek update from HEAD
 1.34.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.35.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.35.6.1 05-Dec-2016  skrll Sync with HEAD
 1.36.16.1 10-Jun-2019  christos Sync with HEAD
 1.36.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.9 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.8 16-May-2009  tsutsui Misc cleanup:
- some KNF
- u_intNN_t -> uintNN_t
- wrap long lines and fix indent
- remove return statements at the end of void functions
- use __arraycount()

XXX: many inconsistent aprint_error_dev(9) vs printf(9)
 1.7 11-Dec-2005  christos branches: 1.7.74; 1.7.90;
merge ktrace-lwp.
 1.6 27-Feb-2005  perry nuke trailing whitespace
 1.5 04-Feb-2005  perry de-__P
 1.4 23-Apr-2002  bouyer branches: 1.4.10; 1.4.18; 1.4.20;
More copyright fixes, pointed out by Thomas. Thanks !
 1.3 20-Apr-2002  bouyer Move a few things around, so that ic/siop_common.c and pci/siop_pci_common.c
can be compiled without including siopvar.h.
 1.2 23-Oct-2000  bouyer branches: 1.2.2; 1.2.4; 1.2.6;
Add ram size to struct properties, and pass it to the bus independant part.
 1.1 15-May-2000  bouyer branches: 1.1.4;
- split siop_pci in attachements vs helper functions, for comming esiop
- add a reset callback to enable PCI-specific features. This improve bandwith
by a factor of 2 on my alpha with a 875 !
- sync copyrigth notice
 1.1.4.1 15-Dec-2000  he Pull up revision 1.2 (requested by bouyer):
Speed improvements to the siop driver, and add tagged queueing
support. As a side effect, better handling of some not so common
phase or message sequences.
 1.2.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.1 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 23-Oct-2000  bouyer file siop_pci_common.h was added on branch thorpej_scsipi on 2000-11-20 11:42:37 +0000
 1.4.20.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.20.1 12-Feb-2005  yamt sync with head.
 1.4.18.1 29-Apr-2005  kent sync with -current
 1.4.10.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.10.1 04-Feb-2005  skrll Sync with HEAD.
 1.7.90.1 23-Jul-2009  jym Sync with HEAD.
 1.7.74.2 11-Mar-2010  yamt sync with head
 1.7.74.1 16-May-2009  yamt sync with head
 1.9 08-Aug-2023  mrg ensure all data passed to copyout() has been initialised.

found by GCC 12.
 1.8 21-Sep-2021  christos use KAUTH_MACHDEP_UNMANAGEDMEM instead of KAUTH_GENERIC_ISSUSER like all the
other framebuffers.
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.5 26-Jan-2014  bouyer branches: 1.5.46;
Complete WSDISPLAYIO_SMODE/WSDISPLAYIO_GMODE support.
In sisfb_mmap(), allow mapping the framebuffer and mmio and io registers
when in WSDISPLAYIO_MODE_MAPPED mode. This can be used by X11.
 1.4 24-Jan-2014  bouyer Snapshot of work in progress:
Add support xorg wsfb driver. Tested on evbmips/loongson
 1.3 18-Jan-2014  bouyer Request a 80x25 tty emulation, which is more likely to work than 80x30
on a 640x400 VGA.
 1.2 30-Jan-2012  drochner branches: 1.2.2; 1.2.6; 1.2.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.1 27-Aug-2011  bouyer branches: 1.1.2; 1.1.6;
Add a basic driver for the SIS315 Pro frame buffer found on some loogson2-based
systems, from OpenBSD.
At this time it can only map the framebuffer and attaches wscons,
using whatever resolution was configured by the firmware.
It doens't support any accelaration or mode change.
 1.1.6.1 18-Feb-2012  mrg merge to -current.
 1.1.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.2.10.1 18-May-2014  rmind sync with head
 1.2.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.2.1 07-Feb-2014  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1019):
sys/dev/pci/sisfb.c: revision 1.3
sys/arch/evbmips/conf/LOONGSON: revision 1.22

Make sysinst much more useable when used with the VGA display on
LOONGSON.
 1.5.46.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 27-Aug-2011  bouyer Add a basic driver for the SIS315 Pro frame buffer found on some loogson2-based
systems, from OpenBSD.
At this time it can only map the framebuffer and attaches wscons,
using whatever resolution was configured by the firmware.
It doens't support any accelaration or mode change.
 1.38 05-Feb-2019  mrg add missing break; after "100NEW" configuration.
don't also set "133OLD", since the 100NEW cards don't support 133.
 1.37 23-Jun-2018  maxv branches: 1.37.2;
constify
 1.36 31-May-2014  christos branches: 1.36.20; 1.36.26;
PR/48858: Roy Bixler: siside0:0:1:0: lost interrupt, submitter claims this
makes the cdrom work.
 1.35 24-May-2014  abs Add in missing space after "96X UDMA%d". Changes "96X UDMA6746" to "96X UDMA6 746"
 1.34 07-Oct-2013  jakllsch branches: 1.34.2;
Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.33 31-Jul-2012  bouyer branches: 1.33.2; 1.33.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.32 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.31 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.30 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.29 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.28 24-May-2011  joerg branches: 1.28.4; 1.28.10;
Properly use format string
 1.27 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.26 05-Nov-2010  jakllsch branches: 1.26.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.25 19-Oct-2009  bouyer branches: 1.25.2; 1.25.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.24 12-Mar-2009  bsh Turn off interrupt disable bit in command status reg.
This is necessary to make S-ATA drives work on some motherboards with
SiS964 including my ASUS P4S800D.
 1.23 18-Mar-2008  cube branches: 1.23.4; 1.23.12; 1.23.18;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.22 09-Feb-2007  ad branches: 1.22.20; 1.22.36; 1.22.40;
Merge newlock2 to head.
 1.21 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 26-Jun-2006  xtraeme branches: 1.19.4; 1.19.6;
Add support for SIS 660/760 IDE Controllers and SIS 181/182
SATA Controllers (from obsd).
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.8; 1.18.16;
merge ktrace-lwp.
 1.17 16-Jun-2005  bouyer branches: 1.17.2;
Add quirk for SIS 96x that masquerade as a SIS503. Based on patch sent by
Robert Fuller in kern/30431, information found in the linux kernel.
While here, add SIS 965 to the table (from FreeBSD).
 1.16 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.15 24-May-2005  lukem add __KERNEL_RCSID
 1.14 27-Feb-2005  perry branches: 1.14.2;
nuke trailing whitespace
 1.13 21-Aug-2004  thorpej branches: 1.13.4; 1.13.6;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.12 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.11 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.10 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.9 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.8 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.7 21-Jul-2004  mycroft branches: 1.7.2;
Add the SiS 741, per PR 26394.
 1.6 22-Apr-2004  skd Added initial support for SIS 180 SATA controller. Patterned after
VIA 8237 support.
 1.5 03-Jan-2004  thorpej branches: 1.5.2;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.4 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.3 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.5.2.1 23-Jul-2004  he branches: 1.5.2.1.2;
Pull up revision 1.7 (requested by mycroft in ticket #691):
Add support for SiS 741. Fixes PR#26394.
 1.5.2.1.2.1 05-Jul-2005  riz Pull up revision 1.17 via patch (requested by bouyer in ticket #2032):
Add quick for SIS 96x that masquerade as a SIS503. Based on patch sent by
Robert Fuller in kern/30431, information found in the linux kernel.
While here, add SIS 965 to the table (from FreeBSD).
 1.7.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.7.2.2 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 21-Jul-2004  skrll file siside.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.13.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.13.4.1 29-Apr-2005  kent sync with -current
 1.14.2.1 26-Jun-2005  tron Pull up revision 1.17 (requested by bouyer in ticket #498):
Add quirk for SIS 96x that masquerade as a SIS503. Based on patch sent by
Robert Fuller in kern/30431, information found in the linux kernel.
While here, add SIS 965 to the table (from FreeBSD).
 1.17.2.3 24-Mar-2008  yamt sync with head.
 1.17.2.2 26-Feb-2007  yamt sync with head.
 1.17.2.1 30-Dec-2006  yamt sync with head.
 1.18.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.18.8.1 11-Aug-2006  yamt sync with head
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.19.6.2 10-Dec-2006  yamt sync with head.
 1.19.6.1 22-Oct-2006  yamt sync with head
 1.19.4.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.19.4.1 18-Nov-2006  ad Sync with head.
 1.22.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.22.36.1 24-Mar-2008  keiichi sync with head.
 1.22.20.1 23-Mar-2008  matt sync with HEAD
 1.23.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.23.4.2 11-Mar-2010  yamt sync with head
 1.23.4.1 04-May-2009  yamt sync with head.
 1.25.4.3 31-May-2011  rmind sync with head
 1.25.4.2 21-Apr-2011  rmind sync with head
 1.25.4.1 05-Mar-2011  rmind sync with head
 1.25.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.26.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.10.1 03-Jun-2014  msaitoh Pull up following revision(s) (requested by abs in ticket #1069):
sys/dev/pci/siside.c: revision 1.35

Add in missing space after "96X UDMA%d". Changes "96X UDMA6746" to
"96X UDMA6 746"
 1.28.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.4.1 30-Oct-2012  yamt sync with head
 1.33.4.1 18-May-2014  rmind sync with head
 1.33.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.34.2.1 10-Aug-2014  tls Rebase.
 1.36.26.1 25-Jun-2018  pgoyette Sync with HEAD
 1.36.20.1 01-Aug-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1314):

sys/dev/pci/siside.c: revision 1.38

add missing break; after "100NEW" configuration.
don't also set "133OLD", since the 100NEW cards don't support 133.
 1.37.2.1 10-Jun-2019  christos Sync with HEAD
 1.29 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.28 31-Jul-2012  bouyer branches: 1.28.2; 1.28.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.27 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.26 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.25 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.24 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.23 08-Apr-2012  jakllsch As suggested in the previous commit, the overwrite of the pci_attach_args
is a bug. Although I have not tested on real hardware, Linux's
pata_sl82c105.c only looks at the revision of the PCI bridge.
 1.22 04-Apr-2011  dyoung branches: 1.22.4; 1.22.8;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.21 05-Nov-2010  jakllsch branches: 1.21.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.20 28-Apr-2008  martin branches: 1.20.20; 1.20.22;
Remove clause 3 and 4 from TNF licenses
 1.19 18-Mar-2008  cube branches: 1.19.2; 1.19.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.18 26-Apr-2007  garbled branches: 1.18.8; 1.18.24; 1.18.28;
Remove the PCIIDE_SLIDE_SETIRQA hack. Recent revalations have uncovered
the fact that it's useless.
 1.17 20-Mar-2007  garbled Put a small hack in slide.c disabled by default. PCIIDE_SLIDE_SETIRQA. This
sets IDE_IRQA in the IDE Control/Status Register. This is needed on prep
machines with Motorola RAVEN host bridges, as they wire up the ide device
oddly.
 1.16 09-Feb-2007  ad branches: 1.16.2; 1.16.6; 1.16.8; 1.16.10;
Merge newlock2 to head.
 1.15 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.14 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.13 03-Sep-2006  christos branches: 1.13.2; 1.13.4;
add missing initializer
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.8;
merge ktrace-lwp.
 1.11 24-May-2005  lukem branches: 1.11.2;
add __KERNEL_RCSID
 1.10 27-Feb-2005  perry nuke trailing whitespace
 1.9 21-Aug-2004  thorpej branches: 1.9.4; 1.9.6;
atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.8 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.7 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.6 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.5 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.4 03-Jan-2004  thorpej branches: 1.4.4;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.3 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.4.4.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.4.4.2 03-Aug-2004  skrll Sync with HEAD
 1.4.4.1 03-Jan-2004  skrll file slide.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.9.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.4.1 29-Apr-2005  kent sync with -current
 1.11.2.3 24-Mar-2008  yamt sync with head.
 1.11.2.2 26-Feb-2007  yamt sync with head.
 1.11.2.1 30-Dec-2006  yamt sync with head.
 1.12.8.1 03-Sep-2006  yamt sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.4.2 10-Dec-2006  yamt sync with head.
 1.13.4.1 22-Oct-2006  yamt sync with head
 1.13.2.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.13.2.1 18-Nov-2006  ad Sync with head.
 1.16.10.1 29-Mar-2007  reinoud Pullup to -current
 1.16.8.1 11-Jul-2007  mjf Sync with head.
 1.16.6.2 27-May-2007  ad Sync with head.
 1.16.6.1 10-Apr-2007  ad Sync with head.
 1.16.2.2 07-May-2007  yamt sync with head.
 1.16.2.1 24-Mar-2007  yamt sync with head.
 1.18.28.2 02-Jun-2008  mjf Sync with HEAD.
 1.18.28.1 03-Apr-2008  mjf Sync with HEAD.
 1.18.24.1 24-Mar-2008  keiichi sync with head.
 1.18.8.1 23-Mar-2008  matt sync with HEAD
 1.19.4.1 16-May-2008  yamt sync with head.
 1.19.2.1 18-May-2008  yamt sync with head.
 1.20.22.2 21-Apr-2011  rmind sync with head
 1.20.22.1 05-Mar-2011  rmind sync with head
 1.20.20.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.21.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.22.8.1 29-Apr-2012  mrg sync to latest -current.
 1.22.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.22.4.2 30-Oct-2012  yamt sync with head
 1.22.4.1 17-Apr-2012  yamt sync with head
 1.28.4.1 18-May-2014  rmind sync with head
 1.28.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.2 05-Oct-2017  msaitoh Use pcireg.h's macro. No functional change.
 1.1 09-Nov-2010  skrll branches: 1.1.6; 1.1.20;
Update sti(4) from OpenBSD bringing across support for sti @ pci.

Thanks to Adam Hoka for testing.
 1.1.20.1 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 09-Nov-2010  rmind file sti_pci.c was added on branch rmind-uvmplock on 2011-03-05 20:53:58 +0000
 1.27 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.26 31-Jul-2012  bouyer branches: 1.26.2; 1.26.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.25 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.24 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.23 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.22 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.21 04-Apr-2011  dyoung branches: 1.21.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.20 05-Nov-2010  jakllsch branches: 1.20.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.19 26-May-2008  nisimura branches: 1.19.18; 1.19.20;
- assign 2 clause TNF license to the files cited as my ownership.
- abandon and remove my copyright notice from the three files were
copied in order to adapt HW I don't have; pvr.c, pm.c and stic.c
 1.18 18-Mar-2008  cube branches: 1.18.2; 1.18.4; 1.18.6;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.17 09-Feb-2007  ad branches: 1.17.20; 1.17.36; 1.17.40;
Merge newlock2 to head.
 1.16 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 11-Dec-2005  christos branches: 1.14.20; 1.14.22;
merge ktrace-lwp.
 1.13 24-May-2005  lukem branches: 1.13.2;
add __KERNEL_RCSID
 1.12 27-Feb-2005  perry nuke trailing whitespace
 1.11 21-Aug-2004  nisimura branches: 1.11.4; 1.11.6;
Redo the previous adjustment work.
 1.10 21-Aug-2004  nisimura Remove fluctuation of written name in alphabetical representation of
copyright holder.
 1.9 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.8 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.7 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.6 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.5 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.4 03-Jan-2004  thorpej branches: 1.4.2; 1.4.4;
More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.3 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.2 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.1 31-Oct-2003  nisimura Added stpcide(4) driver for STMicroelectronics STPC IDE controllers.
 1.4.4.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.4.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.4.4.2 03-Aug-2004  skrll Sync with HEAD
 1.4.4.1 03-Jan-2004  skrll file stpcide.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.4.2.2 22-Aug-2004  tron Pull up revision 1.11 (requested by nisimura in ticket #779):
Redo the previous adjustment work.
 1.4.2.1 22-Aug-2004  tron Pull up revision 1.10 (requested by nisimura in ticket #779):
Remove fluctuation of written name in alphabetical representation of
copyright holder.
 1.11.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.4.1 29-Apr-2005  kent sync with -current
 1.13.2.3 24-Mar-2008  yamt sync with head.
 1.13.2.2 26-Feb-2007  yamt sync with head.
 1.13.2.1 30-Dec-2006  yamt sync with head.
 1.14.22.2 10-Dec-2006  yamt sync with head.
 1.14.22.1 22-Oct-2006  yamt sync with head
 1.14.20.2 06-Feb-2007  ad Quiten noisy boot messages.
 1.14.20.1 18-Nov-2006  ad Sync with head.
 1.17.40.2 02-Jun-2008  mjf Sync with HEAD.
 1.17.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.36.1 24-Mar-2008  keiichi sync with head.
 1.17.20.1 23-Mar-2008  matt sync with HEAD
 1.18.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.4.1 04-May-2009  yamt sync with head.
 1.18.2.1 04-Jun-2008  yamt sync with head
 1.19.20.2 21-Apr-2011  rmind sync with head
 1.19.20.1 05-Mar-2011  rmind sync with head
 1.19.18.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.20.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.21.4.1 30-Oct-2012  yamt sync with head
 1.26.4.1 18-May-2014  rmind sync with head
 1.26.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.63 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.62 08-Jan-2024  chs mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.61 07-Aug-2021  thorpej branches: 1.61.6;
Merge thorpej-cfargs2.
 1.60 24-Apr-2021  thorpej branches: 1.60.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.59 06-Feb-2021  isaki branches: 1.59.2;
Add a missing mutex_spin_exit().
 1.58 19-Apr-2020  isaki branches: 1.58.2;
Fix round_blocksize not to return 0.
 1.57 28-Oct-2019  joerg branches: 1.57.6;
Fix operand priority of bit op vs ternary operator.
 1.56 08-Jun-2019  isaki branches: 1.56.2;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.55 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.54 16-Mar-2019  isaki branches: 1.54.2;
Use C99 style struct initializer to audio_hw_if.
 1.53 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.52 01-Jun-2017  chs branches: 1.52.8; 1.52.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.51 14-Jul-2016  msaitoh - Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.50 29-Mar-2014  christos branches: 1.50.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.49 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.48 17-Jul-2013  soren A few "isa" files are so tightly integrated into the x86 platform code
as to not really be part of the optional isa bus autoconf machinery.

Allows configuring a kernel like so:

include "arch/amd64/conf/GENERIC"
no isa
 1.47 27-Oct-2012  chs branches: 1.47.2; 1.47.8;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.46 24-Nov-2011  mrg branches: 1.46.8;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.45 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.44 26-Nov-2009  njoly branches: 1.44.12; 1.44.14;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.43 18-Aug-2009  drochner comparision with a string literal by "==" can't work (found by gcc-4.4.1),
replace with strcmp()
 1.42 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.41 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.40 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.39 28-Apr-2008  martin branches: 1.39.12; 1.39.14;
Remove clause 3 and 4 from TNF licenses
 1.38 10-Apr-2008  cegger branches: 1.38.2; 1.38.4;
use aprint_*_dev and device_xname
 1.37 19-Oct-2007  ad branches: 1.37.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.36 04-Mar-2007  christos branches: 1.36.2; 1.36.14; 1.36.16; 1.36.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 16-Nov-2006  christos branches: 1.35.4; 1.35.6;
__unused removal on arguments; approved by core.
 1.34 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.33 03-Sep-2006  christos branches: 1.33.2; 1.33.4;
add missing initializer
 1.32 08-Mar-2006  lukem Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.31 11-Dec-2005  christos branches: 1.31.4; 1.31.6; 1.31.8; 1.31.10;
merge ktrace-lwp.
 1.30 28-Jun-2005  thorpej branches: 1.30.2;
Use ANSI function decls and static.
 1.29 30-Apr-2005  hannken sv_set_params(): avoid null pointer dereference when `setmode' is 0.

Reviewed by: Lennart Augustsson <augustss@netbsd.org>
 1.28 27-Feb-2005  perry branches: 1.28.2;
nuke trailing whitespace
 1.27 15-Jan-2005  kent branches: 1.27.2; 1.27.4;
ansify and KNF
 1.26 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.25 29-Oct-2004  yamt branches: 1.25.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.24 09-Jul-2004  mycroft Clean up. Attempt to make these safer against stray interrupts.
 1.23 09-Jul-2004  mycroft There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.22 03-May-2003  wiz branches: 1.22.2;
DMA, not dma nor Dma.
 1.21 22-Feb-2003  tsutsui {HZ,hz,hZ} -> Hz
 1.20 20-Feb-2003  hannken The SonicVibes DMA is broken and only works on 24-bit addresses. As long
as bus_dmamem_alloc_range() is missing we use the ISA dma tag on i386.

The iorange for the dma registers now gets allocated near the used range.
Chances are high, that this range is valid on this PCI bus.

This one is really ugly :-)

Approved by: Lennart Augustsson <augustss@netbsd.org>
 1.19 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.18 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.17 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.16 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.15 13-Nov-2001  lukem add RCSID
 1.14 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.13 19-Jul-2001  kleink branches: 1.13.2;
Hint BUS_DMA_READ and BUS_DMA_WRITE.
 1.12 28-Dec-2000  sommerfeld branches: 1.12.2; 1.12.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.11 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.10 01-Nov-1999  augustss branches: 1.10.6;
Make little endian and big endian version of all functions
that deal with 16 bit samples. Let the drivers decide which ones
to use.
 1.9 10-Jul-1999  kleink branches: 1.9.2; 1.9.4; 1.9.6;
Fix a buglet in the driver's DMA buffer list ipmlementation, causing the next-
in-list (wrong) descriptor structure of the buffer in question to be freed.
 1.8 14-Apr-1999  jonathan initialize 'p' for lame gcc-2.7.2.2 flow analysis.
 1.7 22-Mar-1999  mycroft branches: 1.7.2;
Make 48KHz output work.
 1.6 19-Feb-1999  mycroft This is an utterly revolting hack to work around the previously mentioned
lossage. On the Alpha, we force the buffers to be allocated through the SGMAP
so that the PCI bus addresses are low enough.
At least it's only one line of code...
 1.5 18-Feb-1999  mycroft Pass the correct address (PCI bus address, not PA) to the card.
Also fix some typos and add more debugging printf()s.
This would work on the Alpha, but the card I have appears to have the upper
address bits chopped off, and the ring buffer gets mapped using the DGMAP,
which uses the upper bits. Boom.
 1.4 18-Feb-1999  mycroft spaces -> tabs
 1.3 18-Feb-1999  mycroft A few things:
* Use the trigger interface.
* Permit different encodings for record and playback.
* Set AUDIO_PROP_INDEPENDENT.
* Fix the mmap(2) hole again.
* Use 16-bit mode for a-law and u-law playback.
 1.2 17-Feb-1999  mycroft Pass the direction to the allocm and round_buffersize methods.
Some drivers need this to properly allocate DMAable memory.
 1.1 10-Dec-1998  augustss Add a driver for the S3 SonicVibes chip. From OpenBSD and
Constantine Paul Sapuntzakis (csapuntz@cvs.openbsd.org) with
some changes by me.
XXX The driver still needs work.
 1.7.2.1 14-Apr-1999  jonathan branches: 1.7.2.1.2;
Pull up 1.8 delta (initialize 'p' for lame gcc-2.7.2.2 flow analysis) to 1.4.
 1.7.2.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.7.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.4.1 15-Nov-1999  fvdl Sync with -current
 1.9.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.6.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.12.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.4.1 03-Aug-2001  lukem update to -current
 1.12.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.12.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.13.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.22.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.22.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.22.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.22.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.25.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.25.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.27.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.27.2.1 29-Apr-2005  kent sync with -current
 1.28.2.1 01-May-2005  tron Pull up revision 1.29 (requested by hannken in ticket #222):
sv_set_params(): avoid null pointer dereference when `setmode' is 0.
Reviewed by: Lennart Augustsson <augustss@netbsd.org>
 1.30.2.4 27-Oct-2007  yamt sync with head.
 1.30.2.3 03-Sep-2007  yamt sync with head.
 1.30.2.2 30-Dec-2006  yamt sync with head.
 1.30.2.1 21-Jun-2006  yamt sync with head.
 1.31.10.1 19-Apr-2006  elad sync with head.
 1.31.8.2 03-Sep-2006  yamt sync with head.
 1.31.8.1 13-Mar-2006  yamt sync with head.
 1.31.6.1 22-Apr-2006  simonb Sync with head.
 1.31.4.1 09-Sep-2006  rpaulo sync with head
 1.33.4.2 10-Dec-2006  yamt sync with head.
 1.33.4.1 22-Oct-2006  yamt sync with head
 1.33.2.1 18-Nov-2006  ad Sync with head.
 1.35.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.35.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.36.16.1 06-Nov-2007  matt sync with HEAD
 1.36.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.36.2.1 23-Oct-2007  ad Sync with head.
 1.37.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.38.4.4 11-Mar-2010  yamt sync with head
 1.38.4.3 19-Aug-2009  yamt sync with head.
 1.38.4.2 16-May-2009  yamt sync with head
 1.38.4.1 16-May-2008  yamt sync with head.
 1.38.2.1 18-May-2008  yamt sync with head.
 1.39.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.12.2 12-Dec-2008  ad Checkpoint work in progress.
 1.39.12.1 11-Dec-2008  ad Checkpoint work in progress.
 1.44.14.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.44.14.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.44.12.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.44.12.2 30-Oct-2012  yamt sync with head
 1.44.12.1 17-Apr-2012  yamt sync with head
 1.46.8.3 03-Dec-2017  jdolecek update from HEAD
 1.46.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.47.8.1 23-Jul-2013  riastradh sync with HEAD
 1.47.2.2 18-May-2014  rmind sync with head
 1.47.2.1 28-Aug-2013  rmind sync with head
 1.50.6.2 28-Aug-2017  skrll Sync with HEAD
 1.50.6.1 05-Oct-2016  skrll Sync with HEAD
 1.52.10.3 21-Apr-2020  martin Sync with HEAD
 1.52.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.52.10.1 10-Jun-2019  christos Sync with HEAD
 1.52.8.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.54.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.54.2.2 29-Apr-2019  isaki Adapt to audio2.
- Drop INDEPENDENT property. Both play and rec seems to share the
sample rate (however, they require different calculations?).
- XXX It's better to modify frequency list more strictly.
- Remove obsoleted and empty methods.
 1.54.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.56.2.1 27-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #492):

sys/dev/pci/sv.c: revision 1.57
sys/dev/pci/eso.c: revision 1.72
sys/dev/ieee1394/fwohci.c: revision 1.144

Fix operand priority of bit op vs ternary operator.
 1.57.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.58.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.59.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.60.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.61.6.1 14-Jan-2024  martin Pull up following revision(s) (requested by chs in ticket #542):

sys/dev/pci/yds.c: revision 1.69
sys/dev/pci/cmpci.c: revision 1.61
sys/dev/pci/sv.c: revision 1.62
sys/dev/pci/fms.c: revision 1.50

mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 27-Feb-2005  perry nuke trailing whitespace
 1.2 15-Jan-2005  kent branches: 1.2.2; 1.2.4;
ansify and KNF
 1.1 10-Dec-1998  augustss branches: 1.1.42;
Add a driver for the S3 SonicVibes chip. From OpenBSD and
Constantine Paul Sapuntzakis (csapuntz@cvs.openbsd.org) with
some changes by me.
XXX The driver still needs work.
 1.1.42.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.42.1 17-Jan-2005  skrll Sync with HEAD.
 1.2.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.2.1 29-Apr-2005  kent sync with -current
 1.8 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.7 23-Nov-2011  jmcneill branches: 1.7.8;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.6 11-Dec-2005  christos branches: 1.6.28; 1.6.88; 1.6.110; 1.6.112;
merge ktrace-lwp.
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 03-May-2003  wiz branches: 1.4.2; 1.4.10; 1.4.12;
DMA, not dma nor Dma.
 1.3 18-Feb-1999  mycroft spaces -> tabs
 1.2 18-Feb-1999  mycroft A few things:
* Use the trigger interface.
* Permit different encodings for record and playback.
* Set AUDIO_PROP_INDEPENDENT.
* Fix the mmap(2) hole again.
* Use 16-bit mode for a-law and u-law playback.
 1.1 10-Dec-1998  augustss Add a driver for the S3 SonicVibes chip. From OpenBSD and
Constantine Paul Sapuntzakis (csapuntz@cvs.openbsd.org) with
some changes by me.
XXX The driver still needs work.
 1.4.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.10.1 29-Apr-2005  kent sync with -current
 1.4.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.112.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.6.110.2 30-Oct-2012  yamt sync with head
 1.6.110.1 17-Apr-2012  yamt sync with head
 1.6.88.1 11-Dec-2008  ad Checkpoint work in progress.
 1.6.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.7.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.24 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.23 06-Jun-2018  kamil branches: 1.23.2;
Enhance the syntax in order to be acceptable by Clang

Replace "((crv == 0))" with "(crv == 0)", as the intention is to check the
value, whether it is equal to 0.

This fixes kernel=GENERIC build under MKLLVM=yes.

Sponsored by <The NetBSD Foundation>
 1.22 01-Jun-2018  macallan set ATACH_DMA_BEFORE_CMD
 1.21 01-Jun-2018  macallan another G5-specific fix - do a 32bit read of the status register before
checking for channel interrupts. No more interrupt storms.
Adapted from FreeBSD
 1.20 07-Oct-2017  jdolecek branches: 1.20.2;
Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.19 29-Mar-2014  christos branches: 1.19.18;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.18 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.17 28-Apr-2013  macallan branches: 1.17.4;
make this work on PowerMac G5
from Phileas Fogg
 1.16 31-Jul-2012  bouyer branches: 1.16.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.15 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.14 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.13 04-Apr-2011  dyoung branches: 1.13.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.12 05-Nov-2010  jakllsch branches: 1.12.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.11 26-Nov-2009  njoly branches: 1.11.2; 1.11.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.10 18-Mar-2008  cube branches: 1.10.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.9 05-Feb-2008  simonb branches: 1.9.2; 1.9.6;
Print the "bus-master DMA support present" message out the same
other a few other SATA drivers do. Nicer output than just a line
with ": DMA" on it...
 1.8 24-Oct-2007  xtraeme branches: 1.8.2;
- Add support for the ServerWorks HT-1000 IDE Controller in rccide.
- Add support for another ServerWorks HT-1000 SATA Controller.

From OpenBSD.
 1.7 30-Nov-2006  hannken branches: 1.7.22; 1.7.24; 1.7.28;
Enable WDC_CAPABILITY_WIDEREGS. With this change LBA48 operations no
longer wrap at 128GB.
Tested on an "ServerWorks HT-1000 SATA Controller (rev. 0x00)".

Approved by: Manuel Bouyer <bouyer@netbsd.org>
 1.6 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.5 25-Oct-2006  bouyer Use common wdc_sataprobe() where possible; explain why we can't in satalink.c
 1.4 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.3 29-Mar-2006  thorpej branches: 1.3.2; 1.3.4; 1.3.10; 1.3.14; 1.3.16; 1.3.18;
Use device_cfdata().
 1.2 07-Mar-2006  bouyer branches: 1.2.2; 1.2.4;
Also support Serverwork Frodo4, Frodo8 and HT-1000 in svwsata.
From OpenBSD.
 1.1 06-Mar-2006  bouyer branches: 1.1.2;
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.1.2.1 19-Apr-2006  elad sync with head.
 1.2.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.2.2.3 01-Apr-2006  yamt sync with head.
 1.2.2.2 13-Mar-2006  yamt sync with head.
 1.2.2.1 07-Mar-2006  yamt file svwsata.c was added on branch yamt-pdpolicy on 2006-03-13 09:07:27 +0000
 1.3.18.2 10-Dec-2006  yamt sync with head.
 1.3.18.1 22-Oct-2006  yamt sync with head
 1.3.16.2 09-Sep-2006  rpaulo sync with head
 1.3.16.1 29-Mar-2006  rpaulo file svwsata.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.3.14.2 12-Jan-2007  ad Sync with head.
 1.3.14.1 18-Nov-2006  ad Sync with head.
 1.3.10.6 24-Mar-2008  yamt sync with head.
 1.3.10.5 11-Feb-2008  yamt sync with head.
 1.3.10.4 27-Oct-2007  yamt sync with head.
 1.3.10.3 30-Dec-2006  yamt sync with head.
 1.3.10.2 21-Jun-2006  yamt sync with head.
 1.3.10.1 29-Mar-2006  yamt file svwsata.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:06 +0000
 1.3.4.3 04-May-2006  tron Pull up following revision(s) (requested by jonathan in ticket #1298):
sys/dev/pci/svwsata.c: revision 1.2
share/man/man4/svwsata.4: revision 1.2
Also support Serverwork Frodo4, Frodo8 and HT-1000 in svwsata.
From OpenBSD.
 1.3.4.2 04-May-2006  tron Pull up following revision(s) (requested by jonathan in ticket #1298):
share/man/man4/pciide.4: revision 1.60
share/man/man4/Makefile: revision 1.376 via patch
sys/dev/pci/svwsata.c: revision 1.1
sys/dev/pci/files.pci: revision 1.243
sys/arch/i386/conf/INSTALL: revision 1.281
sys/dev/pci/pcidevs: revision 1.771 via patch
sys/dev/pci/pciidevar.h: revision 1.33
sys/arch/i386/conf/XEN0: revision 1.34
sys/arch/i386/conf/GENERIC: revision 1.732
sys/dev/pci/pciide_svwsata_reg.h: revision 1.1
Add svwsata(4), a driver for Serverworks K2 SATA controllers. From
OpenBSD via Joerg Sonnenberger.
 1.3.4.1 29-Mar-2006  tron file svwsata.c was added on branch netbsd-3 on 2006-05-04 12:12:07 +0000
 1.3.2.2 22-Apr-2006  simonb Sync with head.
 1.3.2.1 29-Mar-2006  simonb file svwsata.c was added on branch simonb-timecounters on 2006-04-22 11:39:16 +0000
 1.7.28.1 13-Nov-2007  bouyer Sync with HEAD
 1.7.24.2 23-Mar-2008  matt sync with HEAD
 1.7.24.1 06-Nov-2007  matt sync with HEAD
 1.7.22.1 28-Oct-2007  joerg Sync with HEAD.
 1.8.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.2.1 24-Mar-2008  keiichi sync with head.
 1.10.4.1 11-Mar-2010  yamt sync with head
 1.11.4.2 21-Apr-2011  rmind sync with head
 1.11.4.1 05-Mar-2011  rmind sync with head
 1.11.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.12.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.4.1 30-Oct-2012  yamt sync with head
 1.16.2.4 03-Dec-2017  jdolecek update from HEAD
 1.16.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.2 23-Jun-2013  tls resync from head
 1.16.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.17.4.1 18-May-2014  rmind sync with head
 1.19.18.1 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.20.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.20.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.23.2.1 10-Jun-2019  christos Sync with HEAD
 1.11 01-Aug-2023  andvar s/diable/disable/ in comments.
 1.10 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.9 24-Apr-2021  thorpej branches: 1.9.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.8 28-Feb-2014  matt branches: 1.8.46;
Use %zu for size_t
 1.7 10-Nov-2013  mrg - avoid an uninitialised variable warning
- fix a series of comparisions that duplicated one test and
did not test one variable (found by gcc set-but-unused.)
ok rkujawa
 1.6 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.5 31-Jan-2013  rkujawa branches: 1.5.2;
- Map memory space with BUS_SPACE_MAP_LINEAR
- Support WSDISPLAYIO_GET_FBINFO
- Improve debugging
 1.4 29-Jul-2012  rkujawa branches: 1.4.2; 1.4.4;
Add wsdisplay ioctls and support for mmap'ing of linear frame buffer.
 1.3 20-Jul-2012  rkujawa Preliminary blitter support for Voodoo2.
 1.2 20-Jul-2012  rkujawa Add 3Dfx Voodoo Graphics (aka Voodoo 1) support.
 1.1 18-Jul-2012  rkujawa Add 3Dfx Voodoo2 driver. Still needs some cleanup and prettyfying, but hey
it works.
 1.4.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.4.2 30-Oct-2012  yamt sync with head
 1.4.4.1 29-Jul-2012  yamt file tdvfb.c was added on branch yamt-pagecache on 2012-10-30 17:21:54 +0000
 1.4.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.2.1 25-Feb-2013  tls resync with head
 1.5.2.2 18-May-2014  rmind sync with head
 1.5.2.1 28-Aug-2013  rmind sync with head
 1.8.46.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.9.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 20-Jul-2012  rkujawa branches: 1.3.4;
Preliminary blitter support for Voodoo2.
 1.2 20-Jul-2012  rkujawa Add 3Dfx Voodoo Graphics (aka Voodoo 1) support.
 1.1 18-Jul-2012  rkujawa Add 3Dfx Voodoo2 driver. Still needs some cleanup and prettyfying, but hey
it works.
 1.3.4.2 30-Oct-2012  yamt sync with head
 1.3.4.1 20-Jul-2012  yamt file tdvfbreg.h was added on branch yamt-pagecache on 2012-10-30 17:21:54 +0000
 1.3 29-Jul-2012  rkujawa branches: 1.3.4;
Add wsdisplay ioctls and support for mmap'ing of linear frame buffer.
 1.2 20-Jul-2012  rkujawa Add 3Dfx Voodoo Graphics (aka Voodoo 1) support.
 1.1 18-Jul-2012  rkujawa Add 3Dfx Voodoo2 driver. Still needs some cleanup and prettyfying, but hey
it works.
 1.3.4.2 30-Oct-2012  yamt sync with head
 1.3.4.1 29-Jul-2012  yamt file tdvfbvar.h was added on branch yamt-pagecache on 2012-10-30 17:21:54 +0000
 1.93 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.92 16-Oct-2022  tsutsui Use a consistent pointer variable. No functional change.
 1.91 17-Sep-2022  tsutsui Use C99 designated initializers.
 1.90 17-Sep-2022  tsutsui Make local functions static.
 1.89 19-Aug-2021  andvar s/memry/memory+s/softare/software/+s/grapics/graphics+s/ouput/output
 1.88 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.87 24-Apr-2021  thorpej branches: 1.87.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.86 09-Dec-2018  jdolecek branches: 1.86.14;
use pci_intr_establish_xname() everywhere
 1.85 29-Mar-2014  christos branches: 1.85.28; 1.85.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.84 04-Nov-2013  christos remove unused code
 1.83 11-Jan-2012  macallan branches: 1.83.6; 1.83.10;
add extra parameter for wsfont_find()
 1.82 25-Jan-2011  mrg branches: 1.82.4; 1.82.8;
fix the previous. there's no "vc" variable, nor does the local "dc"
have a "softc" member. use sc->sc_dev instead.

compile tested only, but that's better than the previous revision.
 1.81 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.80 13-Nov-2010  uebayasi branches: 1.80.2; 1.80.4;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.79 15-May-2010  tsutsui Clear RI_NO_AUTO in actual attach functions during autoconf(9)
for console devices that set the flag during consinit().
 1.78 15-May-2010  tsutsui Set RI_NO_AUTO in rip->ri_flg if tga_init() is invoked from cnattach.
 1.77 16-May-2009  tsutsui branches: 1.77.2; 1.77.4;
KNF and misc cosmetics.
 1.76 16-May-2009  tsutsui Split device_t/softc. Tested on arc:
tga0 at pci0 dev 3 function 0: DC21030 step C, board type T8-02
 1.75 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.74 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.73 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.72 16-Mar-2009  dsl ANSIfy functions with function-pointer arguments
 1.71 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.70 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.69 07-Jan-2009  ahoka branches: 1.69.2;
Implement the required ioctls for running Xorg through /dev/ttyE0.

Reviewed by macallan@
 1.68 10-Apr-2008  cegger branches: 1.68.4; 1.68.12;
use aprint_*_dev and device_xname
 1.67 19-Oct-2007  ad branches: 1.67.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.66 04-Mar-2007  yamt branches: 1.66.2; 1.66.14; 1.66.16; 1.66.20;
fix fallout from caddr_t changes.
 1.65 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.64 13-Jan-2007  cube branches: 1.64.2;
Complete initializers so those files compile.
 1.63 26-Apr-2006  rpaulo branches: 1.63.8;
In tgamatch(), ifdef tag test under __alpha__ || arc.
 1.62 12-Apr-2006  jmmv Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.61 11-Dec-2005  christos branches: 1.61.4; 1.61.6; 1.61.8; 1.61.10; 1.61.12;
merge ktrace-lwp.
 1.60 27-Feb-2005  perry branches: 1.60.4;
nuke trailing whitespace
 1.59 04-Feb-2005  perry de-__P
 1.58 29-Jun-2004  kleink branches: 1.58.4; 1.58.6;
Remove redundant tga_getconf() and tga_identify() prototypes.
 1.57 13-Nov-2003  chs eliminate uvm_useracc() in favor of checking the return value of
copyin() or copyout().

uvm_useracc() tells us whether the mapping permissions allow access to
the desired part of an address space, and many callers assume that
this is the same as knowing whether an attempt to access that part of
the address space will succeed. however, access to user space can
fail for reasons other than insufficient permission, most notably that
paging in any non-resident data can fail due to i/o errors. most of
the callers of uvm_useracc() make the above incorrect assumption. the
rest are all misguided optimizations, which optimize for the case
where an operation will fail. we'd rather optimize for operations
succeeding, in which case we should just attempt the access and handle
failures due to insufficient permissions the same way we handle i/o
errors. since there appear to be no good uses of uvm_useracc(), we'll
just remove it.
 1.56 29-Oct-2003  mycroft Don't bother with one of the loops if the data to move is too narrow.
 1.55 29-Oct-2003  mycroft Calculate lastx and lastleft outside the loops...
 1.54 27-Oct-2003  chs uninitialized variables
 1.53 21-Oct-2003  tsutsui vaddr_t is not pointer, so don't compare it against NULL.
 1.52 29-Jun-2003  fvdl branches: 1.52.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.51 29-Jun-2003  simonb Fix 'struct lwp *' lossage.
 1.50 29-Oct-2002  tsutsui Remove no longer needed #ifdef __alpha__ and #ifdef __mips__.
 1.49 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.48 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.47 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.46 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.45 16-Sep-2002  mycroft Force GPSR to 0 before a blit, so my text doesn't get shifted to the right...
 1.44 16-Sep-2002  mycroft Copy forwards even when moving to the right, if the regions do not overlap.
 1.43 16-Sep-2002  mycroft Simplify the blitting code slightly, and fix fenceposts.
 1.42 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.41 17-Mar-2002  atatat branches: 1.41.4; 1.41.6;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.40 13-Mar-2002  ad Reorganise the wsfont stuff slightly so that multiple display adapters
with different bit/byte order requirements can co-exist happily.
 1.39 12-Jan-2002  tsutsui Call malloc(9) with M_ZERO flag instead of memset() after malloc().
 1.38 12-Dec-2001  elric Added support for the PowerStorm 4d20, initial support that is.
I plan on cleaning a few things up over the next few days, but this
appears to be working for me.
 1.37 13-Nov-2001  lukem add RCSID
 1.36 04-Sep-2001  thorpej Use bus_space_mmap().
 1.35 05-Aug-2001  jdolecek use unsigned variable types as appropriate
 1.34 16-Jul-2001  elric So, the PowerStorm 4d20 a.k.a. 32bit TGA2 w/ IBM RGB561 RAMDAC was causing
the kernel to panic since it is recognised as a TGA and the TGA driver
doesn't [yet] know what to do with it.

This patch fixes that by:
o making tgamatch() try to actually figure out what kind
of TGA card is there, rather than simply relying on the
vendor/product ids.
o creating a tga_cnmatch() so that the console code in
arch/alpha/pci/pci_machdep.c can cause the same to occur.
o breaking up some of tga_getdevconfig() into a few different
functions to re-use code that would have been duplicated.
o changed arch/alpha/pci/pci_machdep.c so that it calls out
to tga_cnmatch() if DEVICE_IS_TGA() matches before it decides
to attach the console as a TGA.

Addresses PR: port-alpha/12923
 1.33 07-Jul-2001  thorpej branches: 1.33.2;
bzero -> memset
 1.32 24-Jun-2001  elric This was able to crash my new alpha consistently when I started X.
 1.31 11-Feb-2001  nathanw branches: 1.31.2;
Make tga_rop_vtov deal with copies of <256 byte granularity, necessary
for proper console text handling (especially in-line insertion) on
8-bit displays.

From Christian Groessler <cpg@aladdin.de>.
Tested on 32-bit TGA by me.
 1.30 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.29 17-Dec-2000  thorpej Add back the code that clears "odd" in VCHR. This shouldn't be
necessary, but we haven't made X cope with the wierd size yet.
 1.28 30-Jun-2000  mjacob need uvm_extern.h for a function definition
 1.27 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.26 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.25 14-Jun-2000  soda branches: 1.25.2;
yet another change for NEC RISCstation 2250 of arc port.
 1.24 09-Jun-2000  soda changes for NEC RISCstation 2250 of arc port.
 1.23 20-Apr-2000  nathanw branches: 1.23.2;
Replace rcons console code with rasops console code.
Console text should now be supported on all TGA cards;
8- and 32-bit TGA and 8-bit TGA2 have been tested.

Implement accelerated character drawing, scrolling, and clearing.

Stop clearing "odd" in VHCR; it's unnecessary and hurts performance.

Use bus_space_vaddr() instead of a local hack.
 1.22 02-Apr-2000  nathanw Add code to read and write bt463-style ramdacs; pick ramdac interface
functions based on type returned from tga_getconf().
Adapt to change in ramdac interface.
Fix race condition in tga_sched_update().
Make tga_sched_update() work before interrupts are enabled.
 1.21 12-Mar-2000  nathanw Bus_space-ify TGA register accesses.
(raster operations are still using pointer-based access)
 1.20 09-Mar-2000  drochner put "#ifdef __alpha__" around "alpha_mb()" calls
(I know the driver is useless without console initialisation, but it
should at least compile.)
 1.19 05-Mar-2000  elric Moved things around a bit so that TGA2 can be used as a console.

Addresses PR: port-alpha/9542
 1.18 05-Mar-2000  elric I got the mode sense bits of the monitor wrong they needed a twiddle (~).
 1.17 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.16 25-Jan-2000  drochner use BUS_SPACE_MAP_PREFETCHABLE instead BUS_SPACE_MAP_CACHEABLE where the
PCI BAR bit is referred to
 1.15 06-Dec-1999  drochner update for changed struct wsdisplay_accessops:show_screen signature.
no functional changes
 1.14 28-Apr-1999  ross branches: 1.14.2; 1.14.8;
Accelerate scrolling. Originally by Roland Dowdeswell, revised by
{drocher,ross}@netbsd.org.
 1.13 24-Mar-1999  mrg branches: 1.13.2;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.12 11-Jan-1999  thorpej Fix a few glitches in the nwscons tga driver, PR #6655, Brett Slager.
 1.11 11-Jan-1999  drochner remove dummy "load_font" entries
 1.10 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


XXX XXX XXX
the d_mmap cdev routine should be changed to have a prototype like:
paddr_t (*d_mmap) __P((dev_t, off_t, int));

by someone!
 1.9 02-Sep-1998  drochner Since the RAMDAC drivers use the !=0-ness of fields for diagnostic
purposes, we have to zero-initialize the tga_devconfig structure.
 1.8 18-Aug-1998  thorpej Fix a couple of obvious bugs in the hardware cursor handling code, and
use the RAMDAC callbacks to get/set the cursor colormap.
 1.7 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.6 26-Jun-1998  drochner branches: 1.6.2;
adapt to wsdisplay interface change
 1.5 20-Jun-1998  drochner adapt to wscons changes (character output call)
 1.4 14-May-1998  drochner Simple screen attribute handling for wscons.
The graphics device driver passes a "default attribute" for normal text
output to the wscons framework. If the emulation module needs more
attributes (for different "renditions") it can allocate them via a
callback.
For now, only the "sun" emulation makes use of it.
 1.3 29-Apr-1998  thorpej Use the symbolic name VVR_BLANK rather than a magic constant.
 1.2 16-Apr-1998  drochner count allocated screens correctly
 1.1 15-Apr-1998  drochner The "mi" TGA driver. It's still not of much use on anything but alpha
because it depends on initialization by the firmware.
Further, an mi mmap() is needed...
 1.6.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.6.2.1 07-Aug-1998  drochner make it compile in paddr_t world
 1.13.2.1 29-Apr-1999  perry branches: 1.13.2.1.2;
pullup 1.13->1.14 (ross): scrolling fixes.
 1.13.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.14.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.14.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.23.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.25.2.4 16-Aug-2001  tv Pullup [jdolecek]:

sys/arch/amiga/dev/grf_cl.c 1.26
sys/arch/amiga/dev/grfioctl.h 1.14
sys/arch/hpcmips/dev/plumvideo.c 1.20
sys/arch/macppc/dev/ofb.c 1.25
sys/arch/sparc/dev/cgtwo.c 1.35
sys/arch/sparc/include/fbio.h patch
sys/arch/sparc64/include/fbio.h patch
sys/arch/sun3/dev/cg2.c 1.14
sys/arch/sun3/include/fbio.h patch
sys/dev/pci/tga.c 1.35
sys/dev/tc/cfb.c 1.28
sys/dev/tc/mfb.c 1.27
sys/dev/tc/sfb.c 1.46
sys/dev/tc/sfbplus.c 1.10 via patch
sys/dev/tc/tfb.c 1.30
sys/dev/tc/xcfb.c 1.23
sys/net/if_ppp.c 1.71

Use unsigned variable types to make bounds checking more correct.
 1.25.2.3 25-Jun-2001  he Pull up revision 1.32 (requested by elric):
Fix problem that some systems would panic when XalphaNetBSD is
started.
 1.25.2.2 26-Dec-2000  jhawk Pull up revision 1.29 (requested by thorpej):
Restore code to clear "odd" in VCHR. This seems to
be required for some TGA cards to run X.
 1.25.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.31.2.10 11-Nov-2002  nathanw Catch up to -current
 1.31.2.9 18-Oct-2002  nathanw Catch up to -current.
 1.31.2.8 17-Sep-2002  nathanw Catch up to -current.
 1.31.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.31.2.6 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.31.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.31.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.31.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.31.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.31.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.33.2.9 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.33.2.8 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.33.2.7 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.33.2.6 16-Mar-2002  jdolecek Catch up with -current.
 1.33.2.5 11-Feb-2002  jdolecek Sync w/ -current.
 1.33.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.33.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.33.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.33.2.1 03-Aug-2001  lukem update to -current
 1.41.6.1 01-Dec-2002  he Pull up revisions 1.43-1.45 (requested by mycroft in ticket #837):
Simplify blitting code slightly, fix fenceposts.
Copy forward when moving to the right if no overlap.
Force GPSR to 0 before a blit, so text doesn't shift right.
Fixes a few problems causing occasional corruption with
TGA/TGA2 consoles.
 1.41.4.1 15-Jul-2002  gehenna catch up with -current.
 1.52.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.52.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.52.2.4 21-Nov-2004  skrll Adapt to branch. Alpha kernels now compile.
 1.52.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.52.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.52.2.1 03-Aug-2004  skrll Sync with HEAD
 1.58.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.58.6.1 12-Feb-2005  yamt sync with head.
 1.58.4.1 29-Apr-2005  kent sync with -current
 1.60.4.4 27-Oct-2007  yamt sync with head.
 1.60.4.3 03-Sep-2007  yamt sync with head.
 1.60.4.2 26-Feb-2007  yamt sync with head.
 1.60.4.1 21-Jun-2006  yamt sync with head.
 1.61.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.61.10.2 11-May-2006  elad sync with head
 1.61.10.1 19-Apr-2006  elad sync with head.
 1.61.8.1 24-May-2006  yamt sync with head.
 1.61.6.2 01-Jun-2006  kardel Sync with head.
 1.61.6.1 22-Apr-2006  simonb Sync with head.
 1.61.4.1 09-Sep-2006  rpaulo sync with head
 1.63.8.1 01-Feb-2007  ad Sync with head.
 1.64.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.66.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.66.16.1 06-Nov-2007  matt sync with HEAD
 1.66.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.66.2.1 23-Oct-2007  ad Sync with head.
 1.67.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.67.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.68.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.68.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.68.4.4 11-Aug-2010  yamt sync with head.
 1.68.4.3 20-Jun-2009  yamt sync with head
 1.68.4.2 16-May-2009  yamt sync with head
 1.68.4.1 04-May-2009  yamt sync with head.
 1.69.2.2 23-Jul-2009  jym Sync with HEAD.
 1.69.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.77.4.2 05-Mar-2011  rmind sync with head
 1.77.4.1 30-May-2010  rmind sync with head
 1.77.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.80.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.80.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.82.8.1 18-Feb-2012  mrg merge to -current.
 1.82.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.82.4.1 17-Apr-2012  yamt sync with head
 1.83.10.1 18-May-2014  rmind sync with head
 1.83.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.85.30.1 10-Jun-2019  christos Sync with HEAD
 1.85.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.86.14.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.87.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 02-Apr-2000  nathanw Move bt463 code to dev/ic and adapt to the new ramdac interface.
Set default window type to 24-bit truecolor.
Correctly set pseudocolor mode.
 1.5 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.4 30-Apr-1999  nathanw branches: 1.4.2;
Rototillage; make this actually useful. To wit:
- Initialize more of the Bt463's registers, instead of leaving them
in undefined states. Notably, the window type table is set up
with 8-plane pseudocolor and 24-plane truecolor modes.
- Bus-space-ify, mostly. Could use some more cleanup, but not until
the rest of the tga stuff is converted, too.
- Do the TGA/RAMDAC communication dance more carefully.
- Explain a lot more of what's going on in comments.
 1.3 24-Mar-1999  mrg branches: 1.3.4;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.2 18-Aug-1998  thorpej Initial support for the Brooktree Bt463 RAMDAC.
 1.1 15-Apr-1998  drochner The "mi" TGA driver. It's still not of much use on anything but alpha
because it depends on initialization by the firmware.
Further, an mi mmap() is needed...
 1.3.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck, and commit Makefile which
I forgot in the batch of commits.
 1.5 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.4 24-Mar-1999  mrg branches: 1.4.8;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.3 18-Aug-1998  thorpej When updating the cursor colormap, actually store the data in our
copy of the cursor colormap, not the regular colormap!
 1.2 18-Aug-1998  thorpej Add set_curcmap and get_curcmap RAMDAC methods, for use by the TGA hardware
cursor code. These are unneeded on the Bt485, since the RAMDAC handles
the hardware cursor. They are needed for the Bt463, however, since the
RAMDAC only provides cursor color.
 1.1 15-Apr-1998  drochner The "mi" TGA driver. It's still not of much use on anything but alpha
because it depends on initialization by the firmware.
Further, an mi mmap() is needed...
 1.4.8.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck, and commit Makefile which
I forgot in the batch of commits.
 1.7 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.6 12-Dec-2001  elric branches: 1.6.118; 1.6.128; 1.6.134;
Added support for the PowerStorm 4d20, initial support that is.
I plan on cleaning a few things up over the next few days, but this
appears to be working for me.
 1.5 13-Nov-2001  lukem add RCSID
 1.4 02-Apr-2000  nathanw branches: 1.4.6; 1.4.8;
Restore ramdac-type field to TGA configuration structure.
 1.3 12-Mar-2000  nathanw Bus_space-ify TGA register accesses.
(raster operations are still using pointer-based access)
 1.2 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.1 15-Apr-1998  drochner branches: 1.1.14;
The "mi" TGA driver. It's still not of much use on anything but alpha
because it depends on initialization by the firmware.
Further, an mi mmap() is needed...
 1.1.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.4.6.1 14-Nov-2001  nathanw Catch up to -current.
 1.6.134.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.128.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.118.1 04-May-2009  yamt sync with head.
 1.7 03-Jul-2022  andvar fix various typos in comments, mainly s/pallete/palette/.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 12-Mar-2000  nathanw branches: 1.4.28; 1.4.36; 1.4.38;
Bus_space-ify TGA register accesses.
(raster operations are still using pointer-based access)
 1.3 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.2 29-Apr-1998  thorpej branches: 1.2.14;
Define the contents of the Video Valid register on the TGA and TGA2.
 1.1 15-Apr-1998  drochner The "mi" TGA driver. It's still not of much use on anything but alpha
because it depends on initialization by the firmware.
Further, an mi mmap() is needed...
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.38.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.36.1 29-Apr-2005  kent sync with -current
 1.4.28.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.18 18-May-2009  he Complete the device_t / softc split by changing the sc_dev member
from "struct device" to "device_t". Commit overlooked when tga.c was
changed?
 1.17 07-Jan-2009  ahoka branches: 1.17.2;
Implement the required ioctls for running Xorg through /dev/ttyE0.

Reviewed by macallan@
 1.16 11-Dec-2005  christos branches: 1.16.70; 1.16.74; 1.16.84;
merge ktrace-lwp.
 1.15 01-Jun-2005  drochner add "const" where needed
 1.14 27-Feb-2005  perry nuke trailing whitespace
 1.13 04-Feb-2005  perry de-__P
 1.12 12-Dec-2001  elric branches: 1.12.16; 1.12.24; 1.12.26;
Added support for the PowerStorm 4d20, initial support that is.
I plan on cleaning a few things up over the next few days, but this
appears to be working for me.
 1.11 04-Sep-2001  thorpej Use bus_space_mmap().
 1.10 16-Jul-2001  elric So, the PowerStorm 4d20 a.k.a. 32bit TGA2 w/ IBM RGB561 RAMDAC was causing
the kernel to panic since it is recognised as a TGA and the TGA driver
doesn't [yet] know what to do with it.

This patch fixes that by:
o making tgamatch() try to actually figure out what kind
of TGA card is there, rather than simply relying on the
vendor/product ids.
o creating a tga_cnmatch() so that the console code in
arch/alpha/pci/pci_machdep.c can cause the same to occur.
o breaking up some of tga_getdevconfig() into a few different
functions to re-use code that would have been duplicated.
o changed arch/alpha/pci/pci_machdep.c so that it calls out
to tga_cnmatch() if DEVICE_IS_TGA() matches before it decides
to attach the console as a TGA.

Addresses PR: port-alpha/12923
 1.9 20-Apr-2000  nathanw branches: 1.9.6; 1.9.8;
Replace rcons console code with rasops console code.
Console text should now be supported on all TGA cards;
8- and 32-bit TGA and 8-bit TGA2 have been tested.

Implement accelerated character drawing, scrolling, and clearing.

Stop clearing "odd" in VHCR; it's unnecessary and hurts performance.

Use bus_space_vaddr() instead of a local hack.
 1.8 02-Apr-2000  nathanw Add code to read and write bt463-style ramdacs; pick ramdac interface
functions based on type returned from tga_getconf().
Adapt to change in ramdac interface.
Fix race condition in tga_sched_update().
Make tga_sched_update() work before interrupts are enabled.
 1.7 12-Mar-2000  nathanw Bus_space-ify TGA register accesses.
(raster operations are still using pointer-based access)
 1.6 05-Mar-2000  elric Moved things around a bit so that TGA2 can be used as a console.

Addresses PR: port-alpha/9542
 1.5 04-Mar-2000  elric Added basic TGA2 support to the TGA driver. Abstracted the RAMDAC
code out into ../ic/bt485.c. Disabled tga_bt463.c, which we don't
currently support.
 1.4 18-Aug-1998  thorpej branches: 1.4.12;
Need an entry point to check cursor colormap entries for validity
before actually setting them.
 1.3 18-Aug-1998  thorpej Add set_curcmap and get_curcmap RAMDAC methods, for use by the TGA hardware
cursor code. These are unneeded on the Bt485, since the RAMDAC handles
the hardware cursor. They are needed for the Bt463, however, since the
RAMDAC only provides cursor color.
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 15-Apr-1998  drochner branches: 1.1.2;
The "mi" TGA driver. It's still not of much use on anything but alpha
because it depends on initialization by the firmware.
Further, an mi mmap() is needed...
 1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.8.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.8.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.9.8.1 03-Aug-2001  lukem update to -current
 1.9.6.3 08-Jan-2002  nathanw Catch up to -current.
 1.9.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.9.6.1 24-Aug-2001  nathanw Catch up with -current.
 1.12.26.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.26.1 12-Feb-2005  yamt sync with head.
 1.12.24.1 29-Apr-2005  kent sync with -current
 1.12.16.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.16.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.16.1 04-Feb-2005  skrll Sync with HEAD.
 1.16.84.1 19-Jan-2009  skrll Sync with HEAD.
 1.16.74.2 20-Jun-2009  yamt sync with head
 1.16.74.1 04-May-2009  yamt sync with head.
 1.16.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.17.2.1 23-Jul-2009  jym Sync with HEAD.
 1.5 30-Jun-2001  thorpej Move the Tigon/Tigon2 firmware, version 12.4.13+wpaul, to a
more appropriate location.
 1.4 28-Mar-2001  msaitoh add NetBSD RCS id
 1.3 18-Jan-2001  jdolecek branches: 1.3.2;
constify
 1.2 17-Nov-2000  bouyer Update to firmware 12.4.13+wpaul, from FreeBSD
 1.1 01-Sep-1999  drochner branches: 1.1.2; 1.1.4; 1.1.14;
quick 'n dirty port of FreeBSD's Alteon Gigabit Ethernet driver.
todo:
-IPv6
-clean up jumbo buffer allocation - NetBSD provides an opaque argument
to the free function, thus doesn't need the hack done here
-deal correctly with the mapping of the shared memory
 1.1.14.1 31-Dec-2000  jhawk Pull up revision 1.2 (requested by bouyer):
For the ti driver, add hardware 802.1Q support, update firmware
to 12.4.13+wpaul, and support the Netgear GA620T copper gigabit card,
and the Alteon ACEnic 100baseSX and 1000baseT gigabit cards. Various
small changes from FreeBSD.
 1.1.4.3 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.4.1 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.2 05-Oct-1999  he Pull up revision 1.1 (new, requested by drochner):
Back-port of driver for Alteon Gigabit Ethernet driver, originally
from FreeBSD.
 1.1.2.1 01-Sep-1999  he file ti_fw.h was added on branch netbsd-1-4 on 1999-10-05 22:07:31 +0000
 1.3.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.5 30-Jun-2001  thorpej Move the Tigon/Tigon2 firmware, version 12.4.13+wpaul, to a
more appropriate location.
 1.4 28-Mar-2001  msaitoh add NetBSD RCS id again
 1.3 18-Jan-2001  jdolecek branches: 1.3.2;
constify
 1.2 17-Nov-2000  bouyer Update to firmware 12.4.13+wpaul, from FreeBSD
 1.1 01-Sep-1999  drochner branches: 1.1.2; 1.1.4; 1.1.14;
quick 'n dirty port of FreeBSD's Alteon Gigabit Ethernet driver.
todo:
-IPv6
-clean up jumbo buffer allocation - NetBSD provides an opaque argument
to the free function, thus doesn't need the hack done here
-deal correctly with the mapping of the shared memory
 1.1.14.3 28-Mar-2001  msaitoh back out previous change
 1.1.14.2 28-Mar-2001  msaitoh add NetBSD RCS id again
 1.1.14.1 31-Dec-2000  jhawk Pull up revision 1.2 (requested by bouyer):
For the ti driver, add hardware 802.1Q support, update firmware
to 12.4.13+wpaul, and support the Netgear GA620T copper gigabit card,
and the Alteon ACEnic 100baseSX and 1000baseT gigabit cards. Various
small changes from FreeBSD.
 1.1.4.3 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.4.1 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.2 05-Oct-1999  he Pull up revision 1.1 (new, requested by drochner):
Back-port of driver for Alteon Gigabit Ethernet driver, originally
from FreeBSD.
 1.1.2.1 01-Sep-1999  he file ti_fw2.h was added on branch netbsd-1-4 on 1999-10-05 22:08:13 +0000
 1.3.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.11 07-Oct-2013  jakllsch Drop trailing whitespace.
 1.10 07-Oct-2013  jakllsch Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
 1.9 31-Jul-2012  bouyer branches: 1.9.2; 1.9.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.8 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.7 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.6 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.5 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.4 04-Apr-2011  dyoung branches: 1.4.4;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.3 05-Nov-2010  jakllsch branches: 1.3.2;
Pave the way for detachment of pciide(4)-family ATA controllers.
 1.2 20-Sep-2009  christos branches: 1.2.2; 1.2.4; 1.2.6;
remove dup decl.
 1.1 20-Sep-2009  christos PR/42100: Dave J. Barnes: Support for old toshiba PICCOLO IDE controllers.
 1.2.6.2 21-Apr-2011  rmind sync with head
 1.2.6.1 05-Mar-2011  rmind sync with head
 1.2.4.2 11-Mar-2010  yamt sync with head
 1.2.4.1 20-Sep-2009  yamt file toshide.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:59 +0000
 1.2.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.3.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.4.1 30-Oct-2012  yamt sync with head
 1.9.4.1 18-May-2014  rmind sync with head
 1.9.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.44 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.43 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.42 24-Apr-2021  thorpej branches: 1.42.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.41 10-Nov-2019  chs branches: 1.41.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.40 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.39 09-Feb-2017  macallan branches: 1.39.12; 1.39.14;
fix tpyo
 1.38 09-Feb-2017  macallan make fallback to PIO actually work properly
 1.37 07-Jul-2016  msaitoh branches: 1.37.2; 1.37.4;
KNF. Remove extra spaces. No functional change.
 1.36 29-Mar-2014  christos branches: 1.36.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.35 24-Nov-2013  bouyer XS_NOERROR | XS_RESET doens't make sense, XS_RESET is what is wanted here.
Pointed out by Edgar Fu�
 1.34 15-Sep-2013  martin Remove unused variables
 1.33 10-May-2012  macallan branches: 1.33.2; 1.33.4;
use MMIO if available
 1.32 13-Nov-2010  uebayasi branches: 1.32.8; 1.32.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.31 27-Jul-2010  jakllsch printf() size_t with 'z' format modifier in debug code.
 1.30 14-May-2008  tsutsui branches: 1.30.18; 1.30.20;
Normalize my licenses.
 1.29 12-Apr-2008  tsutsui branches: 1.29.2; 1.29.4; 1.29.6;
Split device_t/softc, with misc cosmetics.
 1.28 10-Apr-2008  cegger use aprint_*_dev and device_xname
 1.27 19-Oct-2007  ad branches: 1.27.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.26 04-Mar-2007  christos branches: 1.26.2; 1.26.14; 1.26.16; 1.26.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 16-Nov-2006  christos branches: 1.25.4;
__unused removal on arguments; approved by core.
 1.24 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.23 22-May-2006  christos branches: 1.23.6; 1.23.8;
add void casts.
 1.22 11-Apr-2006  rpaulo branches: 1.22.2;
Coverity ID 2440: in trm_timeout(), check if srb and xs are NULL
before trying to dereference them.
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 30-May-2005  christos branches: 1.20.2;
- const poisoning
- avoid variable shadowing.
 1.19 16-Apr-2005  bouyer Move epprom settings checks to the right place, so that sync/wide nego is
started based on the eeprom values and adapter capabilities.
Avoid the driver to negotiate wide transfers with a wide drive connected
to a non-wide capable controller.
Problem reported and fix tested by Dan LaBell on netbsd-help.
 1.18 27-Feb-2005  perry branches: 1.18.2;
nuke trailing whitespace
 1.17 21-Feb-2005  thorpej Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding. Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes. Place items described
by the SCSI Primary Commands document into scsi_spc.h.
 1.16 02-Jan-2005  tsutsui branches: 1.16.2; 1.16.4;
u_intNN_t -> uintNN_t
 1.15 25-Sep-2004  tsutsui Use ANSI function decls.
 1.14 30-Oct-2003  simonb branches: 1.14.4;
Remove some assigned-to but otherwise unused variables.
 1.13 02-Oct-2002  thorpej branches: 1.13.6;
Add trailing ; to CFATTACH_DECL.
 1.12 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 05-Apr-2002  bouyer branches: 1.10.4;
Implement mstohz() as discussed on tech-kern, and use it in SCSI drivers
to convert xs->timeout to callout() parameter.
 1.9 05-Apr-2002  mjacob Fix:

...trm.c:578: warning: too many arguments for format

problem.
 1.8 13-Mar-2002  wiz Fix some typos in comments.
 1.7 06-Mar-2002  tsutsui Major overhaul of trm(4) driver:
- Change structures for each device to make them more suitable with
our scsipi mid-layer.
- Use ADAPTER_REQ_SET_XFER_MODE callback.
- Cleanup misc functions/structures/style.

XXX Tagged queuieng support is disabled for now.
XXX Maybe we should have common library of the scsi protocol engine
XXX to share it among all other drivers..
 1.6 16-Dec-2001  tsutsui branches: 1.6.2;
malloc() + memset() -> malloc() with M_ZERO flag
 1.5 18-Nov-2001  tsutsui Misc cleanups:
- correct trm_clock_period[] value
- pass BUS_DMA_{READ,WRITE,STREAMING} to bus_dmamap_load() as appropriate
- make sure to call bus_dmamap_unload() even after request sense
- saved srb params on request sense do not seem to be used,
so remove them from struct trm_srb
- handle target status more properly in trm_srb_done() and no need
to handle error retry in lower driver layer
- fix some comments

XXX Maybe need more cleanup around TQING for MI SCSI callback..
 1.4 13-Nov-2001  lukem branches: 1.4.2;
add RCSID
 1.3 11-Nov-2001  tsutsui branches: 1.3.2;
- Fix some bogus comments.
- Add a missed splx(s) in error case.
 1.2 04-Nov-2001  tsutsui Fix a couple of bugs:
- make sure to allocate memory for sc_tempsrb properly.
- correct links of SRB queue in trm_link_srb().
Now trm driver works on arc.
 1.1 03-Nov-2001  tsutsui Add a driver for the Tekram DC-395U/UW/F and DC-315/U SCSI host adapters,
which have the Tekram TRM-S1040 ASIC.
This driver is written by Rui-Xiang Guo <rxg@ms25.url.com.tw>,
and a number of cosmetic changes by me.
Tested on i386 by the author, and on macppc and sparc64 by me.

XXX On arc, kernel got panic in ltsleep() called from scsipi_execute_xs(),
XXX but I'm not sure what is wrong...
 1.3.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.3.2.1 11-Nov-2001  thorpej file trm.c was added on branch thorpej-mips-cache on 2001-11-12 21:18:21 +0000
 1.4.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.4.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.4.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.4.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.1 13-Nov-2001  nathanw file trm.c was added on branch nathanw_sa on 2001-11-14 19:15:31 +0000
 1.6.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.6.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.1 16-Dec-2001  thorpej file trm.c was added on branch kqueue on 2002-01-10 19:57:07 +0000
 1.10.4.1 16-Apr-2005  tron Pull up revision 1.19 (requested by bouyer in ticket #5751):
Move epprom settings checks to the right place, so that sync/wide nego is
started based on the eeprom values and adapter capabilities.
Avoid the driver to negotiate wide transfers with a wide drive connected
to a non-wide capable controller.
Problem reported and fix tested by Dan LaBell on netbsd-help.
 1.13.6.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.6.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.6.5 17-Jan-2005  skrll Sync with HEAD.
 1.13.6.4 19-Oct-2004  skrll Sync with HEAD
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.4.1 16-Apr-2005  tron Pull up revision 1.19 (requested by bouyer in ticket #1429):
Move epprom settings checks to the right place, so that sync/wide nego is
started based on the eeprom values and adapter capabilities.
Avoid the driver to negotiate wide transfers with a wide drive connected
to a non-wide capable controller.
Problem reported and fix tested by Dan LaBell on netbsd-help.
 1.16.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.16.2.1 29-Apr-2005  kent sync with -current
 1.18.2.1 16-Apr-2005  tron Pull up revision 1.19 (requested by bouyer in ticket #159):
Move epprom settings checks to the right place, so that sync/wide nego is
started based on the eeprom values and adapter capabilities.
Avoid the driver to negotiate wide transfers with a wide drive connected
to a non-wide capable controller.
Problem reported and fix tested by Dan LaBell on netbsd-help.
 1.20.2.4 27-Oct-2007  yamt sync with head.
 1.20.2.3 03-Sep-2007  yamt sync with head.
 1.20.2.2 30-Dec-2006  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.21.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.10.1 19-Apr-2006  elad sync with head.
 1.21.8.1 24-May-2006  yamt sync with head.
 1.21.6.2 01-Jun-2006  kardel Sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.22.2.1 19-Jun-2006  chap Sync with head.
 1.23.8.2 10-Dec-2006  yamt sync with head.
 1.23.8.1 22-Oct-2006  yamt sync with head
 1.23.6.1 18-Nov-2006  ad Sync with head.
 1.25.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.16.1 06-Nov-2007  matt sync with HEAD
 1.26.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.26.2.1 23-Oct-2007  ad Sync with head.
 1.27.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.4.2 11-Aug-2010  yamt sync with head.
 1.29.4.1 16-May-2008  yamt sync with head.
 1.29.2.1 18-May-2008  yamt sync with head.
 1.30.20.1 05-Mar-2011  rmind sync with head
 1.30.18.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.32.12.1 02-Jun-2012  mrg sync to latest -current.
 1.32.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.8.1 23-May-2012  yamt sync with head.
 1.33.4.1 18-May-2014  rmind sync with head
 1.33.2.2 03-Dec-2017  jdolecek update from HEAD
 1.33.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.6.2 28-Aug-2017  skrll Sync with HEAD
 1.36.6.1 09-Jul-2016  skrll Sync with HEAD
 1.37.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.37.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.39.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.39.14.1 10-Jun-2019  christos Sync with HEAD
 1.39.12.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.41.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.42.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 10-May-2012  macallan use MMIO if available
 1.1 03-Nov-2001  tsutsui branches: 1.1.2; 1.1.4; 1.1.6; 1.1.160; 1.1.164;
Add a driver for the Tekram DC-395U/UW/F and DC-315/U SCSI host adapters,
which have the Tekram TRM-S1040 ASIC.
This driver is written by Rui-Xiang Guo <rxg@ms25.url.com.tw>,
and a number of cosmetic changes by me.
Tested on i386 by the author, and on macppc and sparc64 by me.

XXX On arc, kernel got panic in ltsleep() called from scsipi_execute_xs(),
XXX but I'm not sure what is wrong...
 1.1.164.1 02-Jun-2012  mrg sync to latest -current.
 1.1.160.1 23-May-2012  yamt sync with head.
 1.1.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.1 03-Nov-2001  thorpej file trmreg.h was added on branch kqueue on 2002-01-10 19:57:07 +0000
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 03-Nov-2001  nathanw file trmreg.h was added on branch nathanw_sa on 2001-11-14 19:15:31 +0000
 1.1.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.1.2.1 03-Nov-2001  thorpej file trmreg.h was added on branch thorpej-mips-cache on 2001-11-12 21:18:22 +0000
 1.61 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.60 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.59 24-Apr-2021  thorpej branches: 1.59.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.58 10-Nov-2019  chs branches: 1.58.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.57 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.56 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.55 27-Sep-2016  pgoyette branches: 1.55.6; 1.55.14; 1.55.16;
Add a missing ')' in the call to bswap64().

Should fix compile error of twa module for sparc and sparc64
 1.54 27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.53 07-Jul-2016  msaitoh branches: 1.53.2;
KNF. Remove extra spaces. No functional change.
 1.52 27-Sep-2014  christos branches: 1.52.2;
fix size in memset() parameter. Thanks max.
 1.51 21-Sep-2014  christos fix memset size inconsistency
 1.50 25-Jul-2014  dholland branches: 1.50.2;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.49 29-Mar-2014  christos branches: 1.49.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.48 16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.47 13-Mar-2014  hannken Add __diagused.
 1.46 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.45 17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.44 14-Sep-2013  joerg Comment out twa_error_table, but keep it around for documentation
purposes.
 1.43 02-Nov-2012  chs branches: 1.43.2;
fix autoconf output (don't print from the match routine).
 1.42 28-Jul-2012  matt branches: 1.42.2;
Make this compile with i386/conf/ALL
 1.41 27-Jul-2012  jakllsch Convert twa(4) to device_t (CFATTACH_DECL_NEW).
 1.40 30-Jan-2012  drochner branches: 1.40.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.39 27-Jan-2012  para extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.38 31-Aug-2011  plunky branches: 1.38.2; 1.38.6;
NULL does not need a cast
 1.37 24-May-2011  joerg Explicitly get rid of constness.
 1.36 22-Nov-2010  dholland branches: 1.36.2;
Extend the workaround for the 3ware 9650 full-queue bug to a full-fledged
quirk, and use it for the 9690 as well where it's also needed. Patch by me,
problem hunted down by Jiri Novotny and Zdenek Slavet and reported in
PR 44002.
 1.35 14-Nov-2010  uebayasi Avoid pointless use of a sysctl definition, CTL_NAMES. Clean up whitespace.
 1.34 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.33 18-Aug-2009  drochner branches: 1.33.4;
put some strange text within an "#if 0"'d section into a comment
additionally to appease picky parsers
 1.32 31-Jul-2009  bouyer Disable completely bogus DIAGNOSTIC check.
 1.31 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.30 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.29 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.28 27-Jul-2008  joerg branches: 1.28.4; 1.28.8; 1.28.10; 1.28.12;
Unbreak twa after the last two commits.
 1.27 25-Jun-2008  gmcgarry branches: 1.27.2;
Revert unintentional whitespace changes. From simonb.
 1.26 24-Jun-2008  gmcgarry Ragge says that 6.5.4 clause 2 says:

"Unless the type name specifies a void type, the type name shall specify
qualified or unqualified scalar type and the operand shall have scalar
type."

Therefore, don't cast to a union.
 1.25 08-Jun-2008  joerg branches: 1.25.2;
Mention 64bit support once during boot and not every time the controller
is reset.
 1.24 08-Jun-2008  tsutsui Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
 1.23 10-May-2008  joerg Remove #if 0'd code for flashing firmware. It was never active and even
the FreeBSD version of the driver removed it.
 1.22 08-May-2008  joerg Add support for 3ware 9650 and 9690 based on patches contributed by
Wasabi Systems.

Fix bus_dma usage to fix write operations in the light of bounce buffers.
Use the 64bit bus_dma tag for 9550+ to avoid bouncing buffers.
 1.21 07-May-2008  joerg branches: 1.21.2;
First part of twa(4) improvements:
- more/better diagnostic messages
- dynamically allocate units in preparation for 9650+ support
- better distribute queue slots over disks according to size
- drain large request queue on 9550
- keep track of resets, will be needed for 9650.

This changes have been contributed by Wasabi Systems.
 1.20 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.19 10-Apr-2008  cegger branches: 1.19.2; 1.19.4;
use aprint_*_dev and device_xname
 1.18 19-Oct-2007  ad branches: 1.18.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.17 04-Mar-2007  christos branches: 1.17.2; 1.17.14; 1.17.16; 1.17.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 16-Nov-2006  christos branches: 1.16.2; 1.16.4; 1.16.12;
__unused removal on arguments; approved by core.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 11-Oct-2006  jmcneill Size is the third argument to memset, not the second.
 1.13 23-Sep-2006  manu Tweak the twa(4) driver so that 3ware command line utility works with it.
This includes:
- fixing various structure definitions so that the ioctl parameter match
- adding a hw.twa*.driver_version sysctl
- do not refuse multiple device openings, as the management tool will do it.
I'm not sure we are safe. FreeBSD allows multiple openings, and use the
open flag only when an attempt to detach the device is done.
 1.12 03-Sep-2006  christos branches: 1.12.2; 1.12.4; 1.12.6;
- add missing initializer
- inline comes first
 1.11 26-Aug-2006  christos PR/34292: Aaron Hodgen: twa driver incorrectly reports drive size/description
 1.10 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.9 30-Jul-2006  bouyer branches: 1.9.2;
Add some missing splvm()/splx() around uvm_km_* I noticed.
 1.8 29-Jul-2006  wrstuden Updated driver, contributed by Jordan Rhody of Wasabi Systems.

Main fix is to improve reliability under heavy load and frequent
status monitoring.
 1.7 11-Jul-2006  simonb Use c99 uintN_t.
 1.6 11-Jul-2006  simonb Sprinkle some KNF. Still a bit more needed...
 1.5 10-Jul-2006  simonb Remove some incorrect licencing goop.
 1.4 10-Jul-2006  simonb Update for timecounters (s/time.tv_sec/time_second/).
 1.3 25-May-2006  wrstuden branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8; 1.3.10;
Add $NetBSD: ids, which work better than $netbsd: ones.
 1.2 25-May-2006  wrstuden Style changes from simonb at wasabisystems dot com:

Use config_stdsubmatch() instead of our own submatch function.
Use "__inline" in header files and "inline" in .c files.
Make some local function static.
 1.1 24-May-2006  wrstuden 3ware 9000 driver, contributed by Wasabi Systems and written
by Jordan Rhody (based on the FreeBSD driver).

Contributed in NetBSD PR 33364.
 1.3.10.4 03-Sep-2006  yamt sync with head.
 1.3.10.3 11-Aug-2006  yamt sync with head
 1.3.10.2 26-Jun-2006  yamt sync with head.
 1.3.10.1 25-May-2006  yamt file twa.c was added on branch yamt-pdpolicy on 2006-06-26 12:51:23 +0000
 1.3.8.5 27-Oct-2007  yamt sync with head.
 1.3.8.4 03-Sep-2007  yamt sync with head.
 1.3.8.3 30-Dec-2006  yamt sync with head.
 1.3.8.2 21-Jun-2006  yamt sync with head.
 1.3.8.1 25-May-2006  yamt file twa.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:07 +0000
 1.3.6.2 19-Jun-2006  chap Sync with head.
 1.3.6.1 25-May-2006  chap file twa.c was added on branch chap-midi on 2006-06-19 04:01:37 +0000
 1.3.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.2.2 01-Jun-2006  kardel Sync with head.
 1.3.2.1 25-May-2006  kardel file twa.c was added on branch simonb-timecounters on 2006-06-01 22:36:49 +0000
 1.9.2.3 11-Nov-2006  bouyer Pull up following revision(s) (requested by manu in ticket #1528):
etc/MAKEDEV.tmpl: revision 1.66 via patch
sys/conf/majors: revision 1.30 via patch
sys/dev/pci/twareg.h: revision 1.6 via patch
sys/dev/pci/twa.c: revision 1.13 via patch
sys/dev/pci/twaio.h: revision 1.4 via patch
sys/compat/freebsd/freebsd_sysctl.c: revision 1.5 via patch
Tweak the twa(4) driver so that 3ware command line utility works with
it.
This includes:
- fixing various structure definitions so that the ioctl parameter match
- adding a hw.twa*.driver_version sysctl
- do not refuse multiple device openings, as the management tool will do
it.
I'm not sure we are safe. FreeBSD allows multiple openings, and use
the
open flag only when an attempt to detach the device is done.
Fix a bug in FreeBSD sysctl emulation: use copyin for
moving data to the kernel
 1.9.2.2 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.9.2.1 30-Jul-2006  tron file twa.c was added on branch netbsd-3 on 2006-07-31 12:35:23 +0000
 1.12.6.2 10-Dec-2006  yamt sync with head.
 1.12.6.1 22-Oct-2006  yamt sync with head
 1.12.4.2 09-Sep-2006  rpaulo sync with head
 1.12.4.1 03-Sep-2006  rpaulo file twa.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.12.2.1 18-Nov-2006  ad Sync with head.
 1.16.12.1 25-Aug-2009  snj Pull up following revision(s) (requested by bouyer in ticket #1349):
sys/dev/pci/twa.c: revision 1.32
Disable completely bogus DIAGNOSTIC check.
 1.16.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.2.1 25-Aug-2009  snj Pull up following revision(s) (requested by bouyer in ticket #1349):
sys/dev/pci/twa.c: revision 1.32
Disable completely bogus DIAGNOSTIC check.
 1.17.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.17.16.1 06-Nov-2007  matt sync with HEAD
 1.17.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.17.2.1 23-Oct-2007  ad Sync with head.
 1.18.16.4 28-Sep-2008  mjf Sync with HEAD.
 1.18.16.3 29-Jun-2008  mjf Sync with HEAD.
 1.18.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.18.16.1 05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.19.4.4 19-Aug-2009  yamt sync with head.
 1.19.4.3 16-May-2009  yamt sync with head
 1.19.4.2 04-May-2009  yamt sync with head.
 1.19.4.1 16-May-2008  yamt sync with head.
 1.19.2.2 17-Jun-2008  yamt sync with head.
 1.19.2.1 18-May-2008  yamt sync with head.
 1.21.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.21.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.2.2 28-Jul-2008  simonb Sync with head.
 1.25.2.1 27-Jun-2008  simonb Sync with head.
 1.27.2.1 19-Oct-2008  haad Sync with HEAD.
 1.28.12.1 21-Apr-2010  matt sync to netbsd-5
 1.28.10.1 07-Aug-2009  snj Pull up following revision(s) (requested by bouyer in ticket #886):
sys/dev/pci/twa.c: revision 1.32
Disable completely bogus DIAGNOSTIC check.
 1.28.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.4.1 07-Aug-2009  snj Pull up following revision(s) (requested by bouyer in ticket #886):
sys/dev/pci/twa.c: revision 1.32
Disable completely bogus DIAGNOSTIC check.
 1.33.4.2 31-May-2011  rmind sync with head
 1.33.4.1 05-Mar-2011  rmind sync with head
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.38.6.1 18-Feb-2012  mrg merge to -current.
 1.38.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.38.2.2 30-Oct-2012  yamt sync with head
 1.38.2.1 17-Apr-2012  yamt sync with head
 1.40.2.1 22-Nov-2012  riz Pull up following revision(s) (requested by chs in ticket #688):
sys/dev/pci/twa.c: revision 1.43
fix autoconf output (don't print from the match routine).
 1.42.2.3 03-Dec-2017  jdolecek update from HEAD
 1.42.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.43.2.1 18-May-2014  rmind sync with head
 1.49.2.1 10-Aug-2014  tls Rebase.
 1.50.2.1 30-Oct-2014  martin Pull up following revision(s) (requested by maxv in ticket #164):
sys/dev/ieee1394/fwcrom.c: revision 1.15
sys/dev/ieee1394/fwcrom.c: revision 1.16
sys/dev/marvell/if_gfe.c: revision 1.43
sys/dev/usb/stuirda.c: revision 1.16
sys/dev/pci/cxgb/cxgb_offload.c: revision 1.4
sys/dev/pci/twa.c: revision 1.51
sys/dev/pci/twa.c: revision 1.52
Various fixes in dev/: remove dead code and fix two inconsistencies.
 1.52.2.2 05-Oct-2016  skrll Sync with HEAD
 1.52.2.1 09-Jul-2016  skrll Sync with HEAD
 1.53.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.55.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.55.16.1 10-Jun-2019  christos Sync with HEAD
 1.55.14.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.55.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.55.6.1 30-Apr-2017  pgoyette More DEVSW_MODULE_INIT for modular drivers
 1.58.10.3 22-Mar-2021  thorpej Fix missing comma.
 1.58.10.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.58.10.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.59.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.5 08-Sep-2008  gmcgarry branches: 1.5.38; 1.5.58;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.4 23-Sep-2006  manu branches: 1.4.48; 1.4.52; 1.4.54; 1.4.58;
Tweak the twa(4) driver so that 3ware command line utility works with it.
This includes:
- fixing various structure definitions so that the ioctl parameter match
- adding a hw.twa*.driver_version sysctl
- do not refuse multiple device openings, as the management tool will do it.
I'm not sure we are safe. FreeBSD allows multiple openings, and use the
open flag only when an attempt to detach the device is done.
 1.3 11-Jul-2006  simonb branches: 1.3.2; 1.3.6; 1.3.8; 1.3.10;
Remove some incorrect licencing goop.
 1.2 25-May-2006  wrstuden branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10;
Add $NetBSD: ids, which work better than $netbsd: ones.
 1.1 24-May-2006  wrstuden 3ware 9000 driver, contributed by Wasabi Systems and written
by Jordan Rhody (based on the FreeBSD driver).

Contributed in NetBSD PR 33364.
 1.2.10.3 11-Aug-2006  yamt sync with head
 1.2.10.2 26-Jun-2006  yamt sync with head.
 1.2.10.1 25-May-2006  yamt file twaio.h was added on branch yamt-pdpolicy on 2006-06-26 12:51:23 +0000
 1.2.8.3 30-Dec-2006  yamt sync with head.
 1.2.8.2 21-Jun-2006  yamt sync with head.
 1.2.8.1 25-May-2006  yamt file twaio.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:07 +0000
 1.2.6.2 19-Jun-2006  chap Sync with head.
 1.2.6.1 25-May-2006  chap file twaio.h was added on branch chap-midi on 2006-06-19 04:01:37 +0000
 1.2.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.2.2.2 01-Jun-2006  kardel Sync with head.
 1.2.2.1 25-May-2006  kardel file twaio.h was added on branch simonb-timecounters on 2006-06-01 22:36:49 +0000
 1.3.10.1 22-Oct-2006  yamt sync with head
 1.3.8.2 09-Sep-2006  rpaulo sync with head
 1.3.8.1 11-Jul-2006  rpaulo file twaio.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.3.6.1 18-Nov-2006  ad Sync with head.
 1.3.2.3 11-Nov-2006  bouyer Pull up following revision(s) (requested by manu in ticket #1528):
etc/MAKEDEV.tmpl: revision 1.66 via patch
sys/conf/majors: revision 1.30 via patch
sys/dev/pci/twareg.h: revision 1.6 via patch
sys/dev/pci/twa.c: revision 1.13 via patch
sys/dev/pci/twaio.h: revision 1.4 via patch
sys/compat/freebsd/freebsd_sysctl.c: revision 1.5 via patch
Tweak the twa(4) driver so that 3ware command line utility works with
it.
This includes:
- fixing various structure definitions so that the ioctl parameter match
- adding a hw.twa*.driver_version sysctl
- do not refuse multiple device openings, as the management tool will do
it.
I'm not sure we are safe. FreeBSD allows multiple openings, and use
the
open flag only when an attempt to detach the device is done.
Fix a bug in FreeBSD sysctl emulation: use copyin for
moving data to the kernel
 1.3.2.2 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.3.2.1 11-Jul-2006  tron file twaio.h was added on branch netbsd-3 on 2006-07-31 12:35:23 +0000
 1.4.58.1 19-Oct-2008  haad Sync with HEAD.
 1.4.54.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.4.52.1 04-May-2009  yamt sync with head.
 1.4.48.1 28-Sep-2008  mjf Sync with HEAD.
 1.5.58.1 22-Sep-2015  skrll Sync with HEAD
 1.5.38.1 03-Dec-2017  jdolecek update from HEAD
 1.12 05-Feb-2024  andvar s/bufffer/buffer/ in comments and log message.
 1.11 22-Nov-2010  dholland Extend the workaround for the 3ware 9650 full-queue bug to a full-fledged
quirk, and use it for the 9690 as well where it's also needed. Patch by me,
problem hunted down by Jiri Novotny and Zdenek Slavet and reported in
PR 44002.
 1.10 08-Sep-2008  gmcgarry branches: 1.10.16;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.9 08-May-2008  joerg branches: 1.9.4;
Add support for 3ware 9650 and 9690 based on patches contributed by
Wasabi Systems.

Fix bus_dma usage to fix write operations in the light of bounce buffers.
Use the 64bit bus_dma tag for 9550+ to avoid bouncing buffers.
 1.8 07-May-2008  joerg branches: 1.8.2;
First part of twa(4) improvements:
- more/better diagnostic messages
- dynamically allocate units in preparation for 9650+ support
- better distribute queue slots over disks according to size
- drain large request queue on 9550
- keep track of resets, will be needed for 9650.

This changes have been contributed by Wasabi Systems.
 1.7 19-Oct-2007  ad branches: 1.7.16; 1.7.18; 1.7.20;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 23-Sep-2006  manu branches: 1.6.8; 1.6.22; 1.6.24; 1.6.28;
Tweak the twa(4) driver so that 3ware command line utility works with it.
This includes:
- fixing various structure definitions so that the ioctl parameter match
- adding a hw.twa*.driver_version sysctl
- do not refuse multiple device openings, as the management tool will do it.
I'm not sure we are safe. FreeBSD allows multiple openings, and use the
open flag only when an attempt to detach the device is done.
 1.5 28-Jul-2006  wrstuden branches: 1.5.2; 1.5.6; 1.5.8; 1.5.10;
Updated twa driver contributed by Jordan Rhody of Wasabi systems.

Correct AEN severity values.
 1.4 11-Jul-2006  simonb Use c99 uintN_t.
 1.3 11-Jul-2006  simonb Remove some incorrect licencing goop.
 1.2 25-May-2006  wrstuden branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.10;
Add $NetBSD: ids, which work better than $netbsd: ones.
 1.1 24-May-2006  wrstuden 3ware 9000 driver, contributed by Wasabi Systems and written
by Jordan Rhody (based on the FreeBSD driver).

Contributed in NetBSD PR 33364.
 1.2.10.3 11-Aug-2006  yamt sync with head
 1.2.10.2 26-Jun-2006  yamt sync with head.
 1.2.10.1 25-May-2006  yamt file twareg.h was added on branch yamt-pdpolicy on 2006-06-26 12:51:23 +0000
 1.2.8.4 27-Oct-2007  yamt sync with head.
 1.2.8.3 30-Dec-2006  yamt sync with head.
 1.2.8.2 21-Jun-2006  yamt sync with head.
 1.2.8.1 25-May-2006  yamt file twareg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:07 +0000
 1.2.6.2 19-Jun-2006  chap Sync with head.
 1.2.6.1 25-May-2006  chap file twareg.h was added on branch chap-midi on 2006-06-19 04:01:37 +0000
 1.2.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.2.2.2 01-Jun-2006  kardel Sync with head.
 1.2.2.1 25-May-2006  kardel file twareg.h was added on branch simonb-timecounters on 2006-06-01 22:36:49 +0000
 1.5.10.1 22-Oct-2006  yamt sync with head
 1.5.8.2 09-Sep-2006  rpaulo sync with head
 1.5.8.1 28-Jul-2006  rpaulo file twareg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.5.6.1 18-Nov-2006  ad Sync with head.
 1.5.2.3 11-Nov-2006  bouyer Pull up following revision(s) (requested by manu in ticket #1528):
etc/MAKEDEV.tmpl: revision 1.66 via patch
sys/conf/majors: revision 1.30 via patch
sys/dev/pci/twareg.h: revision 1.6 via patch
sys/dev/pci/twa.c: revision 1.13 via patch
sys/dev/pci/twaio.h: revision 1.4 via patch
sys/compat/freebsd/freebsd_sysctl.c: revision 1.5 via patch
Tweak the twa(4) driver so that 3ware command line utility works with
it.
This includes:
- fixing various structure definitions so that the ioctl parameter match
- adding a hw.twa*.driver_version sysctl
- do not refuse multiple device openings, as the management tool will do
it.
I'm not sure we are safe. FreeBSD allows multiple openings, and use
the
open flag only when an attempt to detach the device is done.
Fix a bug in FreeBSD sysctl emulation: use copyin for
moving data to the kernel
 1.5.2.2 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.5.2.1 28-Jul-2006  tron file twareg.h was added on branch netbsd-3 on 2006-07-31 12:35:23 +0000
 1.6.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.24.1 06-Nov-2007  matt sync with HEAD
 1.6.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.8.1 23-Oct-2007  ad Sync with head.
 1.7.20.2 04-May-2009  yamt sync with head.
 1.7.20.1 16-May-2008  yamt sync with head.
 1.7.18.1 18-May-2008  yamt sync with head.
 1.7.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.7.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.2.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.8.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.9.4.1 19-Oct-2008  haad Sync with HEAD.
 1.10.16.1 05-Mar-2011  rmind sync with head
 1.12 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.11 27-Jul-2012  jakllsch branches: 1.11.2;
Convert twa(4) to device_t (CFATTACH_DECL_NEW).
 1.10 22-Nov-2010  dholland branches: 1.10.8;
Extend the workaround for the 3ware 9650 full-queue bug to a full-fledged
quirk, and use it for the 9690 as well where it's also needed. Patch by me,
problem hunted down by Jiri Novotny and Zdenek Slavet and reported in
PR 44002.
 1.9 06-May-2009  cegger branches: 1.9.4;
struct device * -> device_t, no functional changes intended.
 1.8 07-May-2008  joerg branches: 1.8.14;
First part of twa(4) improvements:
- more/better diagnostic messages
- dynamically allocate units in preparation for 9650+ support
- better distribute queue slots over disks according to size
- drain large request queue on 9550
- keep track of resets, will be needed for 9650.

This changes have been contributed by Wasabi Systems.
 1.7 04-Mar-2007  christos branches: 1.7.36; 1.7.38; 1.7.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.6 17-Aug-2006  christos branches: 1.6.4; 1.6.10;
Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.5 11-Jul-2006  simonb branches: 1.5.2;
Use c99 uintN_t.
 1.4 11-Jul-2006  simonb Remove some incorrect licencing goop.
 1.3 25-May-2006  wrstuden branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8; 1.3.10;
Add $NetBSD: ids, which work better than $netbsd: ones.
 1.2 25-May-2006  wrstuden Style changes from simonb at wasabisystems dot com:

Use config_stdsubmatch() instead of our own submatch function.
Use "__inline" in header files and "inline" in .c files.
Make some local function static.
 1.1 24-May-2006  wrstuden 3ware 9000 driver, contributed by Wasabi Systems and written
by Jordan Rhody (based on the FreeBSD driver).

Contributed in NetBSD PR 33364.
 1.3.10.4 03-Sep-2006  yamt sync with head.
 1.3.10.3 11-Aug-2006  yamt sync with head
 1.3.10.2 26-Jun-2006  yamt sync with head.
 1.3.10.1 25-May-2006  yamt file twavar.h was added on branch yamt-pdpolicy on 2006-06-26 12:51:23 +0000
 1.3.8.4 03-Sep-2007  yamt sync with head.
 1.3.8.3 30-Dec-2006  yamt sync with head.
 1.3.8.2 21-Jun-2006  yamt sync with head.
 1.3.8.1 25-May-2006  yamt file twavar.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:07 +0000
 1.3.6.2 19-Jun-2006  chap Sync with head.
 1.3.6.1 25-May-2006  chap file twavar.h was added on branch chap-midi on 2006-06-19 04:01:37 +0000
 1.3.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.2.2 01-Jun-2006  kardel Sync with head.
 1.3.2.1 25-May-2006  kardel file twavar.h was added on branch simonb-timecounters on 2006-06-01 22:36:49 +0000
 1.5.2.2 31-Jul-2006  tron Apply patch (requested by bouyer in ticket #1441):
Pullup the twa(4) driver for the 3ware Apache RAID controllers.
Matching revisions in current:
share/man/man4/twa.4 1.1
sys/dev/pci/ld_twa.c 1.2
sys/dev/pci/twa.c 1.9
sys/dev/pci/twaio.h 1.3
sys/dev/pci/twareg.h 1.5
sys/dev/pci/twavar.h 1.5
 1.5.2.1 11-Jul-2006  tron file twavar.h was added on branch netbsd-3 on 2006-07-31 12:35:23 +0000
 1.6.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.4.2 09-Sep-2006  rpaulo sync with head
 1.6.4.1 17-Aug-2006  rpaulo file twavar.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.7.40.2 16-May-2009  yamt sync with head
 1.7.40.1 16-May-2008  yamt sync with head.
 1.7.38.1 18-May-2008  yamt sync with head.
 1.7.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.10.8.1 30-Oct-2012  yamt sync with head
 1.11.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.111 02-Feb-2024  andvar s/mangement/management/ in comments.
 1.110 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.109 24-Apr-2021  thorpej branches: 1.109.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.108 10-Nov-2019  chs branches: 1.108.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.107 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.106 27-Sep-2016  pgoyette branches: 1.106.6; 1.106.14; 1.106.16;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.105 14-Jul-2016  msaitoh branches: 1.105.2;
KNF. No functional change.
 1.104 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.103 25-Jul-2014  dholland branches: 1.103.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.102 29-Mar-2014  christos branches: 1.102.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.101 16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.100 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.99 15-Sep-2013  martin Remove unused variable
 1.98 02-Dec-2012  chs branches: 1.98.2;
fix device/softc split: initialize sc->sc_dev.
 1.97 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.96 27-Jan-2012  para branches: 1.96.6;
extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.95 30-Jun-2011  wiz branches: 1.95.2; 1.95.6;
dependant -> dependent
 1.94 24-May-2011  joerg Explicitly get rid of constness.
 1.93 14-Nov-2010  uebayasi branches: 1.93.2;
Avoid pointless use of a sysctl definition, CTL_NAMES. Clean up whitespace.
 1.92 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.91 27-Jul-2010  jakllsch printf() size_t with 'z' format modifier in debug code.
 1.90 12-May-2009  cegger branches: 1.90.2; 1.90.4;
use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.89 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.88 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.87 08-Jun-2008  tsutsui branches: 1.87.12;
Replace device_lookup() with device_lookup_private() on getting softc
for future device_t/softc spilt.
 1.86 28-Apr-2008  martin branches: 1.86.2;
Remove clause 3 and 4 from TNF licenses
 1.85 10-Apr-2008  cegger branches: 1.85.2; 1.85.4;
use aprint_*_dev and device_xname
 1.84 19-Oct-2007  ad branches: 1.84.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.83 04-Mar-2007  christos branches: 1.83.2; 1.83.14; 1.83.16; 1.83.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.82 02-Dec-2006  elad branches: 1.82.2;
Change kauth(9) KPI for kauth_authorize_device_passthru() to add another
argument, u_long, serving as a bit-mask of generic requests for the
passthru request.

Discussed on tech-security@ and tech-kern@. Okay tls@.
 1.81 16-Nov-2006  christos branches: 1.81.2;
__unused removal on arguments; approved by core.
 1.80 08-Nov-2006  elad Replace securelevel checks with kauth(9) calls.
 1.79 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.78 03-Sep-2006  christos branches: 1.78.2; 1.78.4;
- add missing initializer
- add missing function decl
 1.77 27-Aug-2006  xtraeme Initialize a variable to 0 to appease gcc4 with -O3.
 1.76 23-Aug-2006  christos Acting as Elad's keyboard:

Place the securelevel checks in their logical locations.
This will be clearer in the future when code changes to use kauth(9) calls.

input and okay ad@
 1.75 11-Apr-2006  rpaulo Coverity ID 2859: Don't leak ccb, move the allocation a few lines
lower next to where it'll be used for the first time.
 1.74 23-Feb-2006  simonb branches: 1.74.2; 1.74.4; 1.74.6;
Fix memory leak in the TWEIO_GET_PARAM ioctl.
Tested by gendalia@.
 1.73 29-Jan-2006  dsl branches: 1.73.2; 1.73.4;
Make almost everything #include <sys/bswap.h> instead of <machine/bswap.h>
The bswap.h and endian.h files are all rather incestuous, but I want to
get the constant folding stuff into one place - sys/bswap.h
 1.72 24-Dec-2005  perry branches: 1.72.2;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.71 11-Dec-2005  christos merge ktrace-lwp.
 1.70 26-Aug-2005  drochner kill some more simple submatch() functions, use config_stdsubmatch()
 1.69 25-Aug-2005  drochner replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
 1.68 28-Jun-2005  thorpej branches: 1.68.2;
Use ANSI function decls and static.
 1.67 20-Jun-2005  atatat Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.66 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.65 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.64 16-Mar-2005  erh branches: 1.64.2; 1.64.4;
Fix PR#24302. Clear PCI abort and parity errors to give the card a chance at
working. Patch provided by Jean-Luc Wasmer, based on the FreeBSD driver.
 1.63 27-Feb-2005  perry nuke trailing whitespace
 1.62 20-Feb-2005  heas Add sysctl node hw.tweN.driver_version whose value is FreeBSD's driver version
number for now. This is used by 3ware's FreeBSD version of their CLI to find
controllers and check the driver version.
 1.61 15-Feb-2005  lukem Add some more stripe sizes observed in the field.
Add "JBOD" to twe_table_unittype[].
 1.60 23-Sep-2004  heas branches: 1.60.4; 1.60.6;
Take the modulus of the AEN queue tail number rather than the mask of. Now
the tail pointer advances properly.
 1.59 13-Sep-2004  drochner a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.58 04-Jun-2004  thorpej twe_ccb_map(): Remove the DEBUG panic case of "unknown" S/G list offset.
In all likelihood, this is a command passed from userspace management
tools where no S/G list is needed because no data is being passed.
 1.57 03-Jun-2004  heas Double the time we wait for the attention bit following a soft reset (and make
the timeout message just a bit clearer), as the latest firmware appears to be
a bit slower.
OK from Jason Thorpe.
 1.56 27-May-2004  thorpej Rename twe_tweio_command_handler() to twe_ccb_wait_handler() and expose it.
 1.55 15-Apr-2004  thorpej Assign a syslog priority to the AEN codes and use that priority when
logging the error message. Potentially allows critical messages to be
noticed much more quickly.
 1.54 04-Dec-2003  thorpej branches: 1.54.2;
When performing command pass-through for management tools, don't poll
for CCB completion. Instead, sleep, and use a CCB callback to wake the
sleeper.
 1.53 10-Nov-2003  thorpej Correct the size passed to a malloc() call when performing command
passthrough for userland management tools.
 1.52 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.51 25-Sep-2003  thorpej Fix up the TWEIO_COMMAND code to actually work. The 3ware management API
library can now communicate with the card.
 1.50 25-Sep-2003  thorpej - Fix a bug I introduced in a previous commit (oops).
- Add the twe_drivecommand ioctl structure.
 1.49 23-Sep-2003  thorpej - Make CCB allocation slightly more efficient by changing how the
CCB is returned to the caller.
- Make code paths that can use twe_ccb_alloc_wait() use it, and assert
that a CCB is always returned from that function.
- Assert that a CCB is always returned when allocating the reserved CCB
for an AEN fetch.
 1.48 23-Sep-2003  thorpej Add a comment clarifying why we clear TWEF_AEN in twe_reset() now.
 1.47 23-Sep-2003  thorpej Separate the AEN fetching path into its own special path that uses the
reserved CCB. This means that all remaining callers of twe_param_get*()
are called from a valid thread context, and thus have no need to use a
reserved CCB. This will allow for further cleanup in a future commit.
 1.46 22-Sep-2003  thorpej Add support for dynamically attaching and detaching RAID array units.
 1.45 22-Sep-2003  thorpej Improve AEN handling:
- Make AENs use the generic code table stuff.
- Add a few more AEN codes (from FreeBSD).
- Correct the context of a few AEN codes (some were listed as
"unit context" when they're really "port context").
- Add a queue of AENs that management tools in userspace can poll
(from FreeBSD).
 1.44 21-Sep-2003  thorpej Fetch info about the drives during attach, and inject that info
into the msgbuf using aprint_verbose().
 1.43 21-Sep-2003  thorpej Expose the "param get" functions.
 1.42 21-Sep-2003  thorpej - Record more information about the array unit, including array
type and stripe depth.
- Report array type and stripe depth when attaching the logical drive.
 1.41 21-Sep-2003  thorpej Add some helper routines to fetch 1, 2, and 4 byte parameter values.

Modeled after code in FreeBSD.
 1.40 21-Sep-2003  thorpej Add some additional code -> description tables, and add a generic
routine to translate code -> description. AENs will be converted
to this mechanism in a future commit.

Partially from FreeBSD.
 1.39 03-Aug-2003  jdolecek tweioctl(): store the result of twe_param_get() directly to the right
variable rather than using (void *) temporary
should fix strict aliasing warning of gcc 3.3
 1.38 25-Jul-2003  jdolecek print some additional information about the controller on boot (from FreeBSD)

use aprint_* as appropriate
change some debug #ifdef DIAGNOSTIC messages into #ifdef DEBUG
make aenfmt[] more const
change twe_param_get() signature to take (struct twe_param **) last arg, and
remove now unnecessary casts
 1.37 29-Jun-2003  fvdl branches: 1.37.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.36 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.35 01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.34 16-Dec-2002  fvdl Remove comparison of u_int8_t value to (512 - a few bytes), since it's
always false. As found by gcc-current.
 1.33 13-Dec-2002  christos Add /dev/twex support. To be used with FreeBSD's 3dmd.
Initial port from Masaru OKI <oki@netbsd.org>, with KNF, memory leak fixes,
denial of service problems, and null pointer fixes from me.
 1.32 25-Nov-2002  thorpej Avoid strict-alias warnings.
 1.31 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.30 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.29 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.28 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.27 06-Aug-2002  kim Missing comma in aenfmt array initialization.
 1.26 10-Jul-2002  christos Add missing messages from FreeBSD's driver. Re-organize a bit how the
message is formatted and printed.
 1.25 01-Jun-2002  lukem SIMPLEQ rototill:
- implement SIMPLEQ_REMOVE(head, elm, type, field). whilst it's O(n),
this mirrors the functionality of SLIST_REMOVE() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE()
- remove the unnecessary elm arg from SIMPLEQ_REMOVE_HEAD().
this mirrors the functionality of SLIST_REMOVE_HEAD() (the other
singly-linked list type) and FreeBSD's STAILQ_REMOVE_HEAD()
- remove notes about SIMPLEQ not supporting arbitrary element removal
- use SIMPLEQ_FOREACH() instead of home-grown for loops
- use SIMPLEQ_EMPTY() appropriately
- use SIMPLEQ_*() instead of accessing sqh_first,sqh_last,sqe_next directly
- reorder manual page; be consistent about how the types are listed
- other minor cleanups
 1.24 24-May-2002  christos NBPG is not constant on the sparc, so don't use CPP tricks.
 1.23 24-May-2002  christos Deal with the NBPG problem in a better way.
 1.22 18-May-2002  ad branches: 1.22.2;
- Use write barriers.
- NBPG -> PAGE_SIZE.
 1.21 13-Nov-2001  lukem branches: 1.21.8;
add RCSID
 1.20 10-Oct-2001  ad branches: 1.20.4;
Back out previous - it causes panics.
 1.19 20-Sep-2001  ad Use bus_dma to get temporary I/O buffers.
 1.18 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.17 15-Sep-2001  chs a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
 1.16 19-Jul-2001  thorpej branches: 1.16.2;
Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.
 1.15 31-May-2001  ad branches: 1.15.2;
Reduce the delay when polling so that dumps go faster.
 1.14 30-Mar-2001  ad AEN 0x000c appears to mean `init started'. From lukem.
 1.13 07-Mar-2001  thorpej Add BUS_DMA_STREAMING to data transfer maps.
 1.12 04-Mar-2001  ad branches: 1.12.2;
Don't choke when we get lots of AENs all at once.
 1.11 25-Feb-2001  ad Wait 10x longer for status bits.
 1.10 11-Feb-2001  ad Match an upcoming product.
 1.9 23-Jan-2001  ad Oops, be sure to clear the ATTN interrupt on error.
 1.8 22-Jan-2001  ad opt_twe.h isn't needed any more.
 1.7 22-Jan-2001  ad - Complain if interrupt-driven retrieval of AENs fails somehow.
- Clamp the number of outstanding commands to 129.
- Other tweaks.
 1.6 14-Jan-2001  thorpej splimp() -> splvm()
 1.5 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.4 14-Nov-2000  thorpej branches: 1.4.2;
NBPG -> PAGE_SIZE
 1.3 08-Nov-2000  ad - Pull in some updates from FreeBSD - mainly clarifications. Thanks to
Mike Smith <msmith@freebsd.org> for pointing these out.
- Ensure that we get AENs: reserve one CCB/command block for parameter
retrieval, and chain AEN retrievals that are the result of an interrupt.
 1.2 20-Oct-2000  ad - tsleep()/wakeup_one() will hurt when under load, so use a queue instead.
- Don't copy to or from the aligned buffer unless there's a need to.
 1.1 19-Oct-2000  ad Driver for the 3ware Escalade family of RAID controllers.
 1.4.2.8 21-Apr-2001  bouyer Sync with HEAD
 1.4.2.7 12-Mar-2001  bouyer Sync with HEAD.
 1.4.2.6 11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.5 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.4.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.4.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 14-Nov-2000  bouyer file twe.c was added on branch thorpej_scsipi on 2000-11-20 11:42:38 +0000
 1.12.2.14 03-Jan-2003  thorpej Sync with HEAD.
 1.12.2.13 19-Dec-2002  thorpej Sync with HEAD.
 1.12.2.12 11-Dec-2002  thorpej Sync with HEAD.
 1.12.2.11 18-Oct-2002  nathanw Catch up to -current.
 1.12.2.10 13-Aug-2002  nathanw Catch up to -current.
 1.12.2.9 01-Aug-2002  nathanw Catch up to -current.
 1.12.2.8 20-Jun-2002  nathanw Catch up to -current.
 1.12.2.7 09-Jan-2002  nathanw Fix merge botch.
 1.12.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.5 22-Oct-2001  nathanw Catch up to -current.
 1.12.2.4 21-Sep-2001  nathanw Catch up to -current.
 1.12.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.12.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.12.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.15.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.15.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 03-Aug-2001  lukem update to -current
 1.16.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.16.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.20.4.3 24-Nov-2001  he Pull up revision 1.20 (via patch, requested by lukem):
Improve stability of this driver by un-applying some earlier
changes.
 1.20.4.2 25-Oct-2001  he Pull up revisions 1.1-1.19 (new, via patch, requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.20.4.1 10-Oct-2001  he file twe.c was added on branch netbsd-1-5 on 2001-10-25 18:03:02 +0000
 1.21.8.4 29-Aug-2002  gehenna catch up with -current.
 1.21.8.3 15-Jul-2002  gehenna catch up with -current.
 1.21.8.2 20-Jun-2002  gehenna catch up with -current.
 1.21.8.1 30-May-2002  gehenna Catch up with -current.
 1.22.2.1 26-May-2002  perry partially resolve 1.6 pullup ticket #29 from grant
pulls up revisions 1.23, 1.24
Original commit messages:

> Deal with the NBPG problem in a better way.

> NBPG is not constant on the sparc, so don't use CPP tricks.

Note that grant erroneously requested a pullup of only 1.24, which
would not apply cleanly. Normally I would have rejected the entire
request, but this is needed to make the sparc & sparc64 ports compile.
 1.37.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.37.2.8 01-Apr-2005  skrll Sync with HEAD.
 1.37.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.37.2.6 15-Feb-2005  skrll Sync with HEAD.
 1.37.2.5 24-Sep-2004  skrll Sync with HEAD.
 1.37.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.37.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.37.2.2 03-Aug-2004  skrll Sync with HEAD
 1.37.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.54.2.2 05-Jun-2004  jmc Pullup rev 1.58 (requested by thorpej in ticket #441)

twe_ccb_map(): Remove the DEBUG panic case of "unknown" S/G list
offset.
 1.54.2.1 30-May-2004  tron Pull up revision 1.56 (requested by thorpej in ticket #410):
Rename twe_tweio_command_handler() to twe_ccb_wait_handler() and
expose it.
 1.60.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.60.6.1 25-Jan-2005  yamt convert to new apis.
 1.60.4.1 29-Apr-2005  kent sync with -current
 1.64.4.1 26-Feb-2006  riz Pull up following revision(s) (requested by simonb in ticket #1182):
sys/dev/pci/twe.c: revision 1.74
Fix memory leak in the TWEIO_GET_PARAM ioctl.
Tested by gendalia@.
--
 1.64.2.1 26-Feb-2006  riz Pull up following revision(s) (requested by simonb in ticket #1182):
sys/dev/pci/twe.c: revision 1.74
Fix memory leak in the TWEIO_GET_PARAM ioctl.
Tested by gendalia@.
--
 1.68.2.4 27-Oct-2007  yamt sync with head.
 1.68.2.3 03-Sep-2007  yamt sync with head.
 1.68.2.2 30-Dec-2006  yamt sync with head.
 1.68.2.1 21-Jun-2006  yamt sync with head.
 1.72.2.2 01-Mar-2006  yamt sync with head.
 1.72.2.1 01-Feb-2006  yamt sync with head.
 1.73.4.1 22-Apr-2006  simonb Sync with head.
 1.73.2.1 09-Sep-2006  rpaulo sync with head
 1.74.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.74.4.1 19-Apr-2006  elad sync with head.
 1.74.2.2 03-Sep-2006  yamt sync with head.
 1.74.2.1 24-May-2006  yamt sync with head.
 1.78.4.2 10-Dec-2006  yamt sync with head.
 1.78.4.1 22-Oct-2006  yamt sync with head
 1.78.2.2 12-Jan-2007  ad Sync with head.
 1.78.2.1 18-Nov-2006  ad Sync with head.
 1.81.2.1 04-Dec-2006  tron Pull up following revision(s) (requested by elad in ticket #247):
sys/dev/ic/dpt.c: revision 1.55
sys/dev/pci/amr.c: revision 1.43
sys/secmodel/bsd44/secmodel_bsd44_securelevel.c: revision 1.19
sys/dev/pci/mly.c: revision 1.33
share/man/man9/kauth.9: revision 1.37
sys/dev/ic/mlx.c: revision 1.49
sys/dev/ic/icp_ioctl.c: revision 1.14
sys/dev/i2o/iop.c: revision 1.62
sys/dev/pci/twe.c: revision 1.82
sys/sys/kauth.h: revision 1.25
sys/dev/i2o/dpti.c: revision 1.31
sys/kern/kern_auth.c: revision 1.33
sys/dev/tc/stic.c: revision 1.37
Change kauth(9) KPI for kauth_authorize_device_passthru() to add another
argument, u_long, serving as a bit-mask of generic requests for the
passthru request.
Discussed on tech-security@ and tech-kern@. Okay tls@.
 1.82.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.83.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.83.16.1 06-Nov-2007  matt sync with HEAD
 1.83.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.83.2.1 23-Oct-2007  ad Sync with head.
 1.84.16.3 29-Jun-2008  mjf Sync with HEAD.
 1.84.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.84.16.1 05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.85.4.4 11-Aug-2010  yamt sync with head.
 1.85.4.3 16-May-2009  yamt sync with head
 1.85.4.2 04-May-2009  yamt sync with head.
 1.85.4.1 16-May-2008  yamt sync with head.
 1.85.2.2 17-Jun-2008  yamt sync with head.
 1.85.2.1 18-May-2008  yamt sync with head.
 1.86.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.87.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.90.4.2 31-May-2011  rmind sync with head
 1.90.4.1 05-Mar-2011  rmind sync with head
 1.90.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.93.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.95.6.1 18-Feb-2012  mrg merge to -current.
 1.95.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.95.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.95.2.2 30-Oct-2012  yamt sync with head
 1.95.2.1 17-Apr-2012  yamt sync with head
 1.96.6.4 03-Dec-2017  jdolecek update from HEAD
 1.96.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.96.6.2 25-Feb-2013  tls resync with head
 1.96.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.98.2.1 18-May-2014  rmind sync with head
 1.102.2.1 10-Aug-2014  tls Rebase.
 1.103.4.2 05-Oct-2016  skrll Sync with HEAD
 1.103.4.1 09-Jul-2016  skrll Sync with HEAD
 1.105.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.106.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.106.16.1 10-Jun-2019  christos Sync with HEAD
 1.106.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.106.6.1 30-Apr-2017  pgoyette More DEVSW_MODULE_INIT for modular drivers
 1.108.10.3 28-Mar-2021  thorpej Correct the names of the arguments passed to the rescan function.
 1.108.10.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.108.10.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.109.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 11-Dec-2005  christos merge ktrace-lwp.
 1.4 25-Sep-2003  thorpej - Protect against multiple inclusion.
- Pull in <dev/pci/twereg.h> ourselves, as well.
 1.3 25-Sep-2003  thorpej - Fix a bug I introduced in a previous commit (oops).
- Add the twe_drivecommand ioctl structure.
 1.2 22-Sep-2003  thorpej Add TWEIO_{ADD,DEL}_UNIT ioctls (used by 3ware management tools). From
FreeBSD.
 1.1 13-Dec-2002  christos branches: 1.1.6; 1.1.8;
Add /dev/twex support. To be used with FreeBSD's 3dmd.
Initial port from Masaru OKI <oki@netbsd.org>, with KNF, memory leak fixes,
denial of service problems, and null pointer fixes from me.
 1.1.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.6.2 19-Dec-2002  thorpej Sync with HEAD.
 1.1.6.1 13-Dec-2002  thorpej file tweio.h was added on branch nathanw_sa on 2002-12-19 00:48:15 +0000
 1.16 08-Nov-2018  msaitoh "s/ are are / are /" in comment. No functional change.
 1.15 08-Sep-2008  gmcgarry branches: 1.15.80; 1.15.82;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.14 28-Apr-2008  martin branches: 1.14.2; 1.14.6;
Remove clause 3 and 4 from TNF licenses
 1.13 21-May-2006  christos branches: 1.13.56; 1.13.58; 1.13.60;
Remove packed attributes gcc-4 dislikes.
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.12; 1.12.14;
merge ktrace-lwp.
 1.11 15-Feb-2005  lukem branches: 1.11.6;
Add some more stripe sizes observed in the field.
Add "JBOD" to twe_table_unittype[].
 1.10 05-Oct-2004  heas branches: 1.10.4; 1.10.6;
Add TWE_PARAM_PROC_PERCENT; completion percentage per-sub-unit (2 bytes/ea) for
initialize/verify/rebuild processes.
 1.9 05-Oct-2004  heas Add TWE_OP_PROBEUNIT (0x7), which probes a drive (not associated with a unit
from the controller's POV) for unit information. It's arguments mirror that
of TWE_OP_PROBE.
 1.8 25-Sep-2004  heas Add TWE_OP_PROBE, which probes (and attaches) a port/drive. It's argument
is bytes 9 & 10 of the twe_cmd where the bit set corresponds to the port to
probe + 1 (ie: port 0 == 0x1).
 1.7 23-Sep-2004  heas Typo in define; PhysSectorNym -> PhysSectorNum
 1.6 22-Sep-2003  thorpej Add a few additional control bits and opcodes. From FreeBSD.
 1.5 22-Jan-2001  ad branches: 1.5.10; 1.5.26;
- Complain if interrupt-driven retrieval of AENs fails somehow.
- Clamp the number of outstanding commands to 129.
- Other tweaks.
 1.4 14-Nov-2000  thorpej branches: 1.4.2;
NBPG -> PAGE_SIZE
 1.3 08-Nov-2000  ad - Pull in some updates from FreeBSD - mainly clarifications. Thanks to
Mike Smith <msmith@freebsd.org> for pointing these out.
- Ensure that we get AENs: reserve one CCB/command block for parameter
retrieval, and chain AEN retrievals that are the result of an interrupt.
 1.2 26-Oct-2000  ad Work around a fatal firmware bug on some boards. From msmith@freebsd.org.
 1.1 19-Oct-2000  ad Driver for the 3ware Escalade family of RAID controllers.
 1.4.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 14-Nov-2000  bouyer file twereg.h was added on branch thorpej_scsipi on 2000-11-20 11:42:38 +0000
 1.5.26.6 15-Feb-2005  skrll Sync with HEAD.
 1.5.26.5 19-Oct-2004  skrll Sync with HEAD
 1.5.26.4 24-Sep-2004  skrll Sync with HEAD.
 1.5.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.26.1 03-Aug-2004  skrll Sync with HEAD
 1.5.10.2 25-Oct-2001  he Pull up revisions 1.1-1.5 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.5.10.1 22-Jan-2001  he file twereg.h was added on branch netbsd-1-5 on 2001-10-25 17:53:44 +0000
 1.10.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.11.6.1 21-Jun-2006  yamt sync with head.
 1.12.14.1 19-Jun-2006  chap Sync with head.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.8.1 24-May-2006  yamt sync with head.
 1.12.6.1 01-Jun-2006  kardel Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.60.2 04-May-2009  yamt sync with head.
 1.13.60.1 16-May-2008  yamt sync with head.
 1.13.58.1 18-May-2008  yamt sync with head.
 1.13.56.2 28-Sep-2008  mjf Sync with HEAD.
 1.13.56.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.6.1 19-Oct-2008  haad Sync with HEAD.
 1.14.2.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.15.82.1 10-Jun-2019  christos Sync with HEAD
 1.15.80.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.30 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.29 07-May-2009  cegger branches: 1.29.12; 1.29.22;
struct device * -> device_t, no functional changes intended.
 1.28 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.27 28-Apr-2008  martin branches: 1.27.14;
Remove clause 3 and 4 from TNF licenses
 1.26 04-Mar-2007  christos branches: 1.26.36; 1.26.38; 1.26.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 16-Feb-2006  perry branches: 1.25.20;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.24 24-Dec-2005  perry branches: 1.24.2; 1.24.4; 1.24.6;
__inline__ -> inline
 1.23 11-Dec-2005  christos merge ktrace-lwp.
 1.22 13-Sep-2004  drochner branches: 1.22.12;
a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.21 27-May-2004  thorpej Rename twe_tweio_command_handler() to twe_ccb_wait_handler() and expose it.
 1.20 23-Sep-2003  thorpej branches: 1.20.2;
- Make CCB allocation slightly more efficient by changing how the
CCB is returned to the caller.
- Make code paths that can use twe_ccb_alloc_wait() use it, and assert
that a CCB is always returned from that function.
- Assert that a CCB is always returned when allocating the reserved CCB
for an AEN fetch.
 1.19 23-Sep-2003  thorpej Separate the AEN fetching path into its own special path that uses the
reserved CCB. This means that all remaining callers of twe_param_get*()
are called from a valid thread context, and thus have no need to use a
reserved CCB. This will allow for further cleanup in a future commit.
 1.18 22-Sep-2003  thorpej Add support for dynamically attaching and detaching RAID array units.
 1.17 22-Sep-2003  thorpej Improve AEN handling:
- Make AENs use the generic code table stuff.
- Add a few more AEN codes (from FreeBSD).
- Correct the context of a few AEN codes (some were listed as
"unit context" when they're really "port context").
- Add a queue of AENs that management tools in userspace can poll
(from FreeBSD).
 1.16 21-Sep-2003  thorpej Expose the "param get" functions.
 1.15 21-Sep-2003  thorpej - Record more information about the array unit, including array
type and stripe depth.
- Report array type and stripe depth when attaching the logical drive.
 1.14 21-Sep-2003  thorpej Add some additional code -> description tables, and add a generic
routine to translate code -> description. AENs will be converted
to this mechanism in a future commit.

Partially from FreeBSD.
 1.13 13-Dec-2002  christos branches: 1.13.6;
Add /dev/twex support. To be used with FreeBSD's 3dmd.
Initial port from Masaru OKI <oki@netbsd.org>, with KNF, memory leak fixes,
denial of service problems, and null pointer fixes from me.
 1.12 24-May-2002  christos NBPG is not constant on the sparc, so don't use CPP tricks.
 1.11 24-May-2002  christos Deal with the NBPG problem in a better way.
 1.10 18-May-2002  ad branches: 1.10.2;
- Use write barriers.
- NBPG -> PAGE_SIZE.
 1.9 10-Oct-2001  ad branches: 1.9.4; 1.9.12;
Back out previous - it causes panics.
 1.8 20-Sep-2001  ad Use bus_dma to get temporary I/O buffers.
 1.7 04-Mar-2001  ad branches: 1.7.2; 1.7.4; 1.7.6;
Don't choke when we get lots of AENs all at once.
 1.6 23-Jan-2001  ad Fix up license.
 1.5 22-Jan-2001  ad - Complain if interrupt-driven retrieval of AENs fails somehow.
- Clamp the number of outstanding commands to 129.
- Other tweaks.
 1.4 14-Nov-2000  thorpej branches: 1.4.2;
NBPG -> PAGE_SIZE
 1.3 08-Nov-2000  ad - Pull in some updates from FreeBSD - mainly clarifications. Thanks to
Mike Smith <msmith@freebsd.org> for pointing these out.
- Ensure that we get AENs: reserve one CCB/command block for parameter
retrieval, and chain AEN retrievals that are the result of an interrupt.
 1.2 20-Oct-2000  ad - tsleep()/wakeup_one() will hurt when under load, so use a queue instead.
- Don't copy to or from the aligned buffer unless there's a need to.
 1.1 19-Oct-2000  ad Driver for the 3ware Escalade family of RAID controllers.
 1.4.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.4.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 14-Nov-2000  bouyer file twevar.h was added on branch thorpej_scsipi on 2000-11-20 11:42:38 +0000
 1.7.6.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.7.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.7.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.4 19-Dec-2002  thorpej Sync with HEAD.
 1.7.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.7.2.2 22-Oct-2001  nathanw Catch up to -current.
 1.7.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.9.12.1 30-May-2002  gehenna Catch up with -current.
 1.9.4.3 24-Nov-2001  he Pull up revision 1.9 (requested by lukem):
Improve stability of this driver by un-applying some earlier
changes.
 1.9.4.2 25-Oct-2001  he Pull up revisions 1.1-1.8 (requested by ad):
Add Mylex DACC960, CAC-EISA, and I2O block/SCSI drivers.
 1.9.4.1 10-Oct-2001  he file twevar.h was added on branch netbsd-1-5 on 2001-10-25 17:53:55 +0000
 1.10.2.1 26-May-2002  perry partially resolve 1.6 pullup ticket #29 from grant
pulls up revisions 1.11, 1.12
Original commit messages:

> Deal with the NBPG problem in a better way.

> NBPG is not constant on the sparc, so don't use CPP tricks.

Note that grant erroneously requested a pullup of only 1.12, which
would not apply cleanly. Normally I would have rejected the entire
request, but this is needed to make the sparc & sparc64 ports compile.
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.20.2.1 30-May-2004  tron Pull up revision 1.21 (requested by thorpej in ticket #410):
Rename twe_tweio_command_handler() to twe_ccb_wait_handler() and
expose it.
 1.22.12.2 03-Sep-2007  yamt sync with head.
 1.22.12.1 21-Jun-2006  yamt sync with head.
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.24.2.1 18-Feb-2006  yamt sync with head.
 1.25.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.40.2 16-May-2009  yamt sync with head
 1.26.40.1 16-May-2008  yamt sync with head.
 1.26.38.1 18-May-2008  yamt sync with head.
 1.26.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.29.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.12.1 30-Oct-2012  yamt sync with head
 1.65 23-Feb-2024  andvar s/opetions/options/ in hw.ubsec node description.
 1.64 04-Aug-2023  riastradh entropy(9): Simplify stages. Split interrupt vs non-interrupt paths.

- Nix the entropy stage (cold, warm, hot). Just use the usual kernel
`cold' (cold: single-core, single-thread; interrupts may happen),
and don't make any three-way distinction about whether interrupts
or threads or other CPUs can be running.

Instead, while cold, use splhigh/splx or forbid paths to come from
interrupt context, and while warm, use mutex or the per-CPU hard
and soft interrupt paths for low latency. This comes at a small
cost to some interrupt latency, since we may stir the pool in
interrupt context -- but only for a very short window early at boot
between configure and configure2, so it's hard to imagine it
matters much.

- Allow rnd_add_uint32 to run in hard interrupt context or with spin
locks held, but defer processing to softint and drop samples on the
floor if buffer is full. This is mainly used for cheaply tossing
samples from drivers for non-HWRNG devices into the entropy pool,
so it is often used from interrupt context and/or under spin locks.

- New rnd_add_data_intr provides the interrupt-like data entry path
for arbitrary buffers and driver-specified entropy estimates: defer
processing to softint and drop samples on the floor if buffer is
full.

- Document that rnd_add_data is forbidden under spin locks outside
interrupt context (will crash in LOCKDEBUG), and inadvisable in
interrupt context (but technically permitted just in case there are
compatibility issues for now); later we can forbid it altogether in
interrupt context or under spin locks.

- Audit all uses of rnd_add_data to use rnd_add_data_intr where it
might be used in interrupt context or under a spin lock.

This fixes a regression from last year when the global entropy lock
was changed from IPL_VM (spin) to IPL_SOFTSERIAL (adaptive). Thought
I'd caught all the problems from that, but another one bit three
different people this week, presumably because of recent changes that
led to more non-HWRNG drivers entering the entropy consolidation
path from rnd_add_uint32.

In my attempt to preserve the rnd(9) API for the (now long-since
abandoned) prospect of pullup to netbsd-9 in my rewrite of the
entropy subsystem in 2020, I didn't introduce a separate entry point
for entering entropy from interrupt context or equivalent, i.e., spin
locks held, and instead made rnd_add_data rely on cpu_intr_p() to
decide whether to process the whole sample under a lock or only take
as much as there's buffer space for before scheduling a softint. In
retrospect, that was a mistake (though perhaps not as much of a
mistake as other entropy API decisions...), a mistake which is
finally getting rectified now by rnd_add_data_intr.

XXX pullup-10
 1.63 06-May-2023  andvar s/Regiser/Register/ and s/regester/register/ in comments.
 1.62 27-Aug-2022  skrll branches: 1.62.4;
Correct the abbreviation of approximately to 'approx.'
 1.61 27-Aug-2022  skrll Trailing whitespace
 1.60 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.59 22-May-2022  riastradh opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.
 1.58 22-May-2022  riastradh ubsec(4): Prune dead branches. Assert session id validity.
 1.57 22-May-2022  riastradh ubsec(4): Tidy up error branches of ubsec_process.

Make sure to return zero, not error, when we've already done
crypto_done and set crp_etype.
 1.56 22-May-2022  riastradh ubsec(4): Assert crp_sid is valid.

If opencrypto passes a bad sid in, that's a bug in opencrypto that
needs to be fixed, not a user-triggered invalid input that we need to
fail gracefully on.
 1.55 22-May-2022  riastradh ubsec(4): ubsec_kprocess always returns zero. Prune dead branches.
 1.54 22-May-2022  riastradh ubsec(4): Fix error branch: call crypto_kdone, don't return error.
 1.53 18-May-2022  riastradh ubsec(4): Nix dead code.

No functional change intended.
 1.52 14-Jun-2020  riastradh ubsec(4): Don't use prev msg's last block as IV for next msg in CBC.

This violates the security contract of the CBC construction, which
requires that the IV be unpredictable in advance; an adaptive adversary
can exploit this to verify plaintext guesses.

XXX Compile-tested only.
 1.51 25-May-2020  thorpej unifdef everything-but-NetBSD. Gets rid of a naked cfattach decl.
 1.50 30-Apr-2020  riastradh rnd_attach_source calls the callback itself now.

No need for every driver to explicitly call it to prime the pool.

Eliminate now-unused <sys/rndpool.h>.
 1.49 30-Apr-2020  riastradh Don't attach rndsource until it's actually ready to run.
 1.48 16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.47 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.46 22-Dec-2018  maxv Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
 1.45 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.44 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.43 07-Jul-2016  msaitoh branches: 1.43.16; 1.43.18;
KNF. Remove extra spaces. No functional change.
 1.42 13-Apr-2015  riastradh Add header guards and necessary includes.
 1.41 10-Aug-2014  tls branches: 1.41.4;
Merge tls-earlyentropy branch into HEAD.
 1.40 19-Apr-2014  bad Add support for accelerated AES_CBC in ubsec(4) for BCM5823 and newer.
Update man-page and bump date.
Adjust OpenBSD RCS IDs to reflect roughly the version we are in sync with.
 1.39 18-Apr-2014  bad Rewrite the dmamap handling to allocate and cache the dmamaps beforehand.
Calling bus_dmamap_create/destroy is no longer possible in interrupt context.
Move the dmamaps to the end of struct ubsec_q so the rest of the struct
can be cleared with one call to memset().

As a bonus we get a 25% increase in throughput encrypting 8K blocks.
 1.38 29-Mar-2014  christos branches: 1.38.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.37 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.36 03-Jan-2014  pgoyette If you're going to build this driver as a module, make sure that it
depends on opencrypto module.
 1.35 26-Dec-2013  bad Also disable MCR4INT in ubsec_detach() when appropriate.
 1.34 17-Nov-2013  bad Add support for BCM5825, and BCM5860, 5861, 5862 from OpenBSD rev 1.143:
Add support for the BCM5825 and the next-generation BCM5860, 5861,
5862 Broadcom CryptoNetX IPSec/SSL Security Processors. The 5825 is a
faster version of the already supported 5823, and the even faster 586x
series is a bit different and needed some more changes.

AES support hasn't been pulled in yet.
 1.33 17-Nov-2013  bad Create the sysctl variables on module initialization.
Create them under hw.ubsec as is hip these days.
 1.32 17-Nov-2013  bad Make ubsec(4) loadable as kmod.
 1.31 17-Nov-2013  bad Fix locking botch. Callers of ubsec_rng_locked() lock and release sc_mtx already.
 1.30 17-Nov-2013  bad Use callout_setfunc()/callout_schedule() instead of callout_reset(), it is cheaper.
 1.29 13-Jun-2013  tls branches: 1.29.2;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.28 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.27 30-Jan-2012  drochner branches: 1.27.6;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.26 19-Nov-2011  tls branches: 1.26.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.25 13-Nov-2010  uebayasi branches: 1.25.8;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.24 26-Nov-2009  njoly branches: 1.24.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.23 12-May-2009  cegger use device_private().
"looks good" ad@
XXX for the device_t/softc split, please check the driver that no cases have been missed.
 1.22 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.21 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.20 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.19 18-Mar-2009  cegger bcopy -> memcpy
 1.18 18-Mar-2009  cegger bzero -> memset
 1.17 19-Dec-2008  cegger branches: 1.17.2;
use M_ZERO on malloc() and remove subsequent bzero().
 1.16 10-Apr-2008  cegger branches: 1.16.4; 1.16.12;
use aprint_*_dev and device_xname
 1.15 02-Feb-2008  tls branches: 1.15.6;
From Darran Hunt at Coyote Point: don't truncate HMAC to 96 bits unless
actually asked to.

Fixed in FreeBSD a while ago, discussed on tech-kern and tech-crypto.
 1.14 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.13 09-Jul-2007  ad branches: 1.13.8; 1.13.14; 1.13.16; 1.13.18; 1.13.20;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.12 04-Mar-2007  christos branches: 1.12.2; 1.12.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 16-Nov-2006  christos branches: 1.11.4;
__unused removal on arguments; approved by core.
 1.10 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.9 28-Mar-2006  thorpej branches: 1.9.8; 1.9.10;
Use device_unit().
 1.8 25-Nov-2005  thorpej branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
- De-couple the software crypto implementation from the rest of the
framework. There is no need to waste the space if you are only using
algoritms provided by hardware accelerators. To get the software
implementations, add "pseudo-device swcr" to your kernel config.
- Lazily initialize the opencrypto framework when crypto drivers
(either hardware or swcr) register themselves with the framework.
 1.7 28-Jun-2005  thorpej branches: 1.7.2; 1.7.8;
Use ANSI function decls and static.
 1.6 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 28-Aug-2003  thorpej branches: 1.4.4; 1.4.10; 1.4.12;
* Make matching and chip info table-driven.
* Print product name and revision at attach time.
* Use aprint_*().
 1.3 27-Aug-2003  thorpej Fix some diagnotic printfs.
 1.2 21-Aug-2003  jonathan Remove #ifdef _OpenBSD__ code which sets the softc pointer `sc' by
passing an index into ubsec_cd.cd_devs[]: that causes too much
confusion with the checks that sc is non-null.
 1.1 01-Aug-2003  jonathan Preliminary port of merged OpenBSD/FreeBSD ubsec driver for Bluesteel
Networks/Broadcom line of cryptographic accelerators.
 1.4.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.10.1 29-Apr-2005  kent sync with -current
 1.4.4.7 11-Dec-2005  christos Sync with head.
 1.4.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.4.4.2 03-Aug-2004  skrll Sync with HEAD
 1.4.4.1 28-Aug-2003  skrll file ubsec.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.7.8.1 29-Nov-2005  yamt sync with head.
 1.7.2.5 04-Feb-2008  yamt sync with head.
 1.7.2.4 21-Jan-2008  yamt sync with head
 1.7.2.3 03-Sep-2007  yamt sync with head.
 1.7.2.2 30-Dec-2006  yamt sync with head.
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.8.10.1 19-Apr-2006  elad sync with head.
 1.8.8.1 01-Apr-2006  yamt sync with head.
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.10.2 10-Dec-2006  yamt sync with head.
 1.9.10.1 22-Oct-2006  yamt sync with head
 1.9.8.1 18-Nov-2006  ad Sync with head.
 1.11.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.4.1 11-Jul-2007  mjf Sync with head.
 1.12.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.13.20.1 13-Dec-2007  bouyer Sync with HEAD
 1.13.18.1 11-Dec-2007  yamt sync with head.
 1.13.16.1 26-Dec-2007  ad Sync with head.
 1.13.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.13.8.2 23-Mar-2008  matt sync with HEAD
 1.13.8.1 09-Jan-2008  matt sync with HEAD
 1.15.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.15.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.16.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.16.4.3 11-Mar-2010  yamt sync with head
 1.16.4.2 16-May-2009  yamt sync with head
 1.16.4.1 04-May-2009  yamt sync with head.
 1.17.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.4.1 05-Mar-2011  rmind sync with head
 1.25.8.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.8.2 30-Oct-2012  yamt sync with head
 1.25.8.1 17-Apr-2012  yamt sync with head
 1.26.2.1 18-Feb-2012  mrg merge to -current.
 1.27.6.4 03-Dec-2017  jdolecek update from HEAD
 1.27.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.6.2 23-Jun-2013  tls resync from head
 1.27.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.2.1 18-May-2014  rmind sync with head
 1.38.2.2 10-Aug-2014  tls Rebase.
 1.38.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.41.4.2 09-Jul-2016  skrll Sync with HEAD
 1.41.4.1 06-Jun-2015  skrll Sync with HEAD
 1.43.18.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.43.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.43.18.1 10-Jun-2019  christos Sync with HEAD
 1.43.16.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.43.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.62.4.1 11-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #319):

sys/dev/pci/ubsec.c: revision 1.64
sys/dev/pci/hifn7751.c: revision 1.82
lib/libc/gen/getentropy.3: revision 1.5
lib/libc/gen/getentropy.3: revision 1.6
share/man/man4/rnd.4: revision 1.41
lib/libc/sys/getrandom.2: revision 1.2
lib/libc/sys/getrandom.2: revision 1.3
share/man/man5/rc.conf.5: revision 1.193
share/man/man7/entropy.7: revision 1.5
share/man/man7/entropy.7: revision 1.6
share/man/man7/entropy.7: revision 1.7
share/man/man7/entropy.7: revision 1.8
etc/security: revision 1.130
share/man/man7/entropy.7: revision 1.9
etc/security: revision 1.131
sys/crypto/cprng_fast/cprng_fast.c: revision 1.19
sys/sys/rndio.h: revision 1.3
tests/lib/libc/sys/t_getrandom.c: revision 1.5
etc/defaults/rc.conf: revision 1.164
etc/defaults/rc.conf: revision 1.165
sys/sys/rndsource.h: revision 1.10
sys/kern/kern_entropy.c: revision 1.62
sys/kern/kern_entropy.c: revision 1.63
sys/kern/kern_entropy.c: revision 1.64
sys/kern/subr_cprng.c: revision 1.44
sys/kern/kern_entropy.c: revision 1.65
sys/kern/kern_clock.c: revision 1.149
sys/dev/pci/viornd.c: revision 1.22
share/man/man9/rnd.9: revision 1.32
sys/kern/subr_prf.c: revision 1.202
sys/sys/rndsource.h: revision 1.8
sys/sys/rndsource.h: revision 1.9
share/man/man7/entropy.7: revision 1.10

1. Reinstate netbsd<=9 entropy estimator to unblock /dev/random, in
parallel with assessment of only confident entropy sources (seed,
HWRNG) for security warnings like sshd keys in motd and daily
insecurity report.

2. Make multiuser boot wait for first /dev/random output soon after
loading a seed and configuring rndctl, so that getentropy(3) meets
its contract starting early at boot without introducing blocking
paths that could cause hangs in init(8) or single-user mode.
Operators can choose to disable this wait in rc.conf.

3. Fix some bugs left over from reducing the global entropy lock from
a spin lock at IPL_VM to an adaptive lock at IPL_SOFTSERIAL.

4. Update man pages.
 1.5 13-Apr-2015  riastradh Add header guards and necessary includes.
 1.4 19-Apr-2014  bad branches: 1.4.4;
Add support for accelerated AES_CBC in ubsec(4) for BCM5823 and newer.
Update man-page and bump date.
Adjust OpenBSD RCS IDs to reflect roughly the version we are in sync with.
 1.3 17-Nov-2013  bad branches: 1.3.2;
Add support for BCM5825, and BCM5860, 5861, 5862 from OpenBSD rev 1.143:
Add support for the BCM5825 and the next-generation BCM5860, 5861,
5862 Broadcom CryptoNetX IPSec/SSL Security Processors. The 5825 is a
faster version of the already supported 5823, and the even faster 586x
series is a bit different and needed some more changes.

AES support hasn't been pulled in yet.
 1.2 11-Dec-2005  christos branches: 1.2.110; 1.2.120; 1.2.126;
merge ktrace-lwp.
 1.1 01-Aug-2003  jonathan branches: 1.1.4;
Preliminary port of merged OpenBSD/FreeBSD ubsec driver for Bluesteel
Networks/Broadcom line of cryptographic accelerators.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 01-Aug-2003  skrll file ubsecreg.h was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.2.126.1 18-May-2014  rmind sync with head
 1.2.120.2 03-Dec-2017  jdolecek update from HEAD
 1.2.120.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.110.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 10-Aug-2014  tls Rebase.
 1.4.4.1 06-Jun-2015  skrll Sync with HEAD
 1.11 14-Jun-2020  riastradh ubsec(4): Don't use prev msg's last block as IV for next msg in CBC.

This violates the security contract of the CBC construction, which
requires that the IV be unpredictable in advance; an adaptive adversary
can exploit this to verify plaintext guesses.

XXX Compile-tested only.
 1.10 13-Apr-2015  riastradh Add header guards and necessary includes.
 1.9 19-Apr-2014  bad branches: 1.9.4;
Add support for accelerated AES_CBC in ubsec(4) for BCM5823 and newer.
Update man-page and bump date.
Adjust OpenBSD RCS IDs to reflect roughly the version we are in sync with.
 1.8 18-Apr-2014  bad Rewrite the dmamap handling to allocate and cache the dmamaps beforehand.
Calling bus_dmamap_create/destroy is no longer possible in interrupt context.
Move the dmamaps to the end of struct ubsec_q so the rest of the struct
can be cleared with one call to memset().

As a bonus we get a 25% increase in throughput encrypting 8K blocks.
 1.7 17-Nov-2013  bad branches: 1.7.2;
Add support for BCM5825, and BCM5860, 5861, 5862 from OpenBSD rev 1.143:
Add support for the BCM5825 and the next-generation BCM5860, 5861,
5862 Broadcom CryptoNetX IPSec/SSL Security Processors. The 5825 is a
faster version of the already supported 5823, and the even faster 586x
series is a bit different and needed some more changes.

AES support hasn't been pulled in yet.
 1.6 17-Nov-2013  bad Make ubsec(4) loadable as kmod.
 1.5 13-Jun-2013  tls branches: 1.5.2;
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.
 1.4 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.3 04-Mar-2007  christos branches: 1.3.76; 1.3.86;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 11-Dec-2005  christos branches: 1.2.26;
merge ktrace-lwp.
 1.1 01-Aug-2003  jonathan branches: 1.1.4; 1.1.18;
Preliminary port of merged OpenBSD/FreeBSD ubsec driver for Bluesteel
Networks/Broadcom line of cryptographic accelerators.
 1.1.18.1 03-Sep-2007  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 01-Aug-2003  skrll file ubsecvar.h was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.2.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.86.4 03-Dec-2017  jdolecek update from HEAD
 1.3.86.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.86.2 23-Jun-2013  tls resync from head
 1.3.86.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.3.76.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.76.1 30-Oct-2012  yamt sync with head
 1.5.2.1 18-May-2014  rmind sync with head
 1.7.2.1 10-Aug-2014  tls Rebase.
 1.9.4.1 06-Jun-2015  skrll Sync with HEAD
 1.67 29-Jun-2022  mlelstv Unmap device registers only when successfully mapped.
 1.66 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.65 24-Apr-2021  thorpej branches: 1.65.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.64 04-Jul-2020  jdolecek branches: 1.64.4;
switch to pci_intr_alloc() so this uses MSI/MSI-X if device supports it
 1.63 10-May-2018  msaitoh KNF. No binary change.
 1.62 09-Apr-2018  jakllsch Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.
 1.61 27-Apr-2017  msaitoh branches: 1.61.8;
Use {isa,pci}_intr_establish"_xname"() for intrctl(8).
 1.60 23-Apr-2016  skrll branches: 1.60.8;
Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
 1.59 19-Aug-2015  skrll Interrupt handlers aren't MP-safe yet so use IPL_USB which is IPL_VM
which takes the kernel lock.
 1.58 21-Sep-2014  christos branches: 1.58.2;
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.57 29-Mar-2014  christos branches: 1.57.4; 1.57.8;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.56 17-Mar-2013  martin branches: 1.56.6;
Track what parts of initialization were successfull and only revert those
during detach - prevents a panic on shutdown when, for example, interrupt
mapping failed. Problem reported by Raymond Phillips on port-i386.
 1.55 10-Jun-2012  mrg branches: 1.55.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.
 1.54 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.53 04-Apr-2011  dyoung branches: 1.53.4; 1.53.8;
Deregister PMF handlers during detachment. Complete the host controller
shutdown.
 1.52 25-May-2010  cegger branches: 1.52.2;
build fix: revert rev. 1.51
 1.51 24-May-2010  pgoyette Update all callers of the pci_find{vendor,product} routines to now call
these routines through their global pointers.
 1.50 24-Feb-2010  dyoung branches: 1.50.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.49 08-Jan-2010  dyoung branches: 1.49.2;
Expand PMF_FN_* macros.
 1.48 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.47 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.46 17-Apr-2009  dyoung Disable interrupts on the h/w before detaching the interrupt
handler. Protects against the problem described in
<http://mail-index.netbsd.org/port-i386/2009/04/10/msg001317.html>,
Xintr_ioapic_levelN jumps to 0 during shutdown.
 1.45 07-Apr-2009  dyoung Detach ehci(4) and uhci(4) at shutdown.
 1.44 28-Apr-2008  martin branches: 1.44.8; 1.44.14;
Remove clause 3 and 4 from TNF licenses
 1.43 28-Mar-2008  drochner branches: 1.43.2; 1.43.4;
split device/softc for USB host controllers and the usb (control)
device,
this is hairy stuff, and I've only tested with uhci/ehci at pci,
please test the rest and report problems
 1.42 07-Mar-2008  dyoung Use device_t and its accessors. In uhci_{pci,cardbus}_attach, use
`self' instead of casting the softc to void *.
 1.41 22-Feb-2008  dyoung Add a method to detach child.

Cosmetic: use device_t and accessors. Use aprint_*_dev(). Use
PMF_FN_{ARGS,CALL,PROTO}.
 1.40 09-Dec-2007  jmcneill branches: 1.40.6; 1.40.10;
Merge jmcneill-pm branch.
 1.39 25-Nov-2007  dsainty branches: 1.39.2; 1.39.4;
Minor typos in comments, no functional change.
 1.38 24-Nov-2007  gavan Be paranoid about disabling interrupts and acknowledging any pending
interrupts while attaching uhci. Fixes recent problems with uvm_fault
during uhci attach, which appear to be caused by a pending interrupt
left over from the device while it was operating in legacy support mode
under the control of the BIOS.

Patch by joerg@ because his was better than mine.
 1.37 19-Oct-2007  ad branches: 1.37.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.36 01-Aug-2007  christos branches: 1.36.2; 1.36.4; 1.36.8; 1.36.10;
Establish powerhooks in the proper order. From Anon Ymous
 1.35 10-Dec-2006  uwe branches: 1.35.6; 1.35.14; 1.35.16;
Convert to use aprint_*
 1.34 16-Nov-2006  christos branches: 1.34.2; 1.34.4;
__unused removal on arguments; approved by core.
 1.33 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.32 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.31 10-Mar-2006  jmcneill branches: 1.31.10; 1.31.12;
On suspend, capture PCI configuration registers. On resume, restore them
as well as explicitly reclaiming ownership of the UHCI/EHCI from the BIOS.
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.6; 1.30.8; 1.30.10;
merge ktrace-lwp.
 1.29 28-Jun-2005  thorpej branches: 1.29.2;
Use ANSI function decls and static.
 1.28 27-Feb-2005  perry nuke trailing whitespace
 1.27 02-Aug-2004  mycroft branches: 1.27.4; 1.27.6;
For the PCIVERBOSE case, separate vendors and products into separate tables.
Eliminating redundant pointers in the tables saves nearly 20K (20% of the table
size). In the process, add a pci_findproduct() and make that and
pci_findvendor() return a "const char *".
 1.26 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.25 22-Apr-2004  itojun sprintf -> snprintf
 1.24 02-Oct-2002  thorpej branches: 1.24.6;
Add trailing ; to CFATTACH_DECL.
 1.23 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.22 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.21 13-Nov-2001  lukem add RCSID
 1.20 06-Nov-2001  augustss Add some data structures to keep enable finding companion controllers
for EHCI.
 1.19 25-Oct-2001  augustss Force BIOS out of the game by setting the LEGSUP register to its default
value.
 1.18 28-Dec-2000  sommerfeld branches: 1.18.2; 1.18.4; 1.18.8;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.17 06-Sep-2000  augustss ANSIfy.
 1.16 27-Apr-2000  augustss Change my email address.
 1.15 25-Apr-2000  augustss Move the size of the mapped bus_space region into the bus independent softc.
 1.14 25-Jan-2000  augustss Make sure PIRQD enable bit is set. From FreeBSD.
 1.13 20-Nov-1999  augustss Propagate the USB revision number to the usb driver.
 1.12 12-Oct-1999  augustss branches: 1.12.2;
Deallocate resources (bus space and interrupts) when detaching from
the bus.
 1.11 15-Sep-1999  augustss branches: 1.11.2;
Add preliminary (untested) code for detaching the USB host controller
(needed for CardBus based controllers).
 1.10 14-Sep-1999  augustss Don't do IO before we have set the tag and handle.
 1.9 14-Sep-1999  augustss And commit two files I forgot in the rearrangement for testing for
interrupt context.
 1.8 21-Aug-1999  augustss Disable interrupts early.
 1.7 20-May-1999  augustss Keep track of vendor id and make sure the vendor string is NUL terminated.
 1.6 13-May-1999  thorpej Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>
 1.5 06-May-1999  thorpej Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.
 1.4 25-Nov-1998  augustss branches: 1.4.4;
Make the copyright header conform to the NetBSD template.
 1.3 25-Jul-1998  augustss Use PCI class/subclass/interface to match USB host controllers instead
of vendor/product id. This makes the probe find more controllers
without recompilation.
 1.2 25-Jul-1998  augustss I forgot to commit these when usb_mem was added.
 1.1 12-Jul-1998  augustss Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers
 1.4.4.2 28-Jun-1999  perry pullup 1.5->1.6 (wrstuden)
 1.4.4.1 06-May-1999  perry branches: 1.4.4.1.2; 1.4.4.1.4;
pullup 1.4->1.5 (thorpej)
 1.4.4.1.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.4.4.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18.8.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.18.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.18.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.24.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.24.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.6.1 03-Aug-2004  skrll Sync with HEAD
 1.27.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.27.4.1 29-Apr-2005  kent sync with -current
 1.29.2.8 17-Mar-2008  yamt sync with head.
 1.29.2.7 27-Feb-2008  yamt sync with head.
 1.29.2.6 21-Jan-2008  yamt sync with head
 1.29.2.5 07-Dec-2007  yamt sync with head
 1.29.2.4 27-Oct-2007  yamt sync with head.
 1.29.2.3 03-Sep-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.30.10.1 19-Apr-2006  elad sync with head.
 1.30.8.1 13-Mar-2006  yamt sync with head.
 1.30.6.1 22-Apr-2006  simonb Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.31.12.2 10-Dec-2006  yamt sync with head.
 1.31.12.1 22-Oct-2006  yamt sync with head
 1.31.10.2 12-Jan-2007  ad Sync with head.
 1.31.10.1 18-Nov-2006  ad Sync with head.
 1.34.4.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.34.2.1 01-Feb-2008  riz Pull up following revision(s) (requested by gavan in ticket #1000):
sys/dev/pci/uhci_pci.c: revision 1.38
Be paranoid about disabling interrupts and acknowledging any pending
interrupts while attaching uhci. Fixes recent problems with uvm_fault
during uhci attach, which appear to be caused by a pending interrupt
left over from the device while it was operating in legacy support mode
under the control of the BIOS.
Patch by joerg@ because his was better than mine.
 1.35.16.1 15-Aug-2007  skrll Sync with HEAD.
 1.35.14.1 22-May-2007  itohy Overhaul of USB stack, mostly DMA related

This applies to NetBSD 4.99.13 (March 1, 2007)

usbdi(9) interface is based on FreeBSD version, excluding
- removal of portability code

Patch most NetBSD changes, excluding
- DMA memory "reserve", since we don't need contiguous buffers any longer
- volatiles in DMA structure, since it should not be needed
with proper bus_dmamap_sync(9)s

DMA/non-DMA memory management overhaul
- Move all DMA related code to usb_mem.[ch]
(add usb_alloc_buffer_dma(), usb_free_buffer_dma(), etc.).
XXX Should usb_mem.[ch] be renamed as usb_mem_dma.[ch] ?
- Add corresponding non-DMA code to usb_mem_nodma.[ch] .
Currently just use malloc(9).
- Above files are conditionally used by config framework (added
attributes to conf/files and dev/usb/files.usb).
- Add diagnostic panics when resource allocation is requested
on interrupt context.
- Change memory allocations (that require context) from NOWAIT to WAITOK.

Allocate DMA/non-DMA buffer per host interface, not globally.
advantage: Buffers can be freed on detaching host interface.
Activity of a host interface does not affect others.
disadvantages: It possibly consumes more memory.

API changes
- usbd_alloc_xfer() is changed:
old: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev);
new: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev,
usbd_pipe_handle pipe);
- pipe argument of usbd_setup_*xfer() are now unused
XXX the pipe argument should be removed?
- add mapping APIs
- async request will be processed as a task (kernel thread context),
and delayed to some extent
- usbdivar.h: struct usbd_xfer: renamed a member "allocbuf" to "hcbuffer"
(mapped/allocated/refered buffer for HCI driver)
- usb_port.h: change usb_proc_ptr from struct ptoc * to struct lwp *
- usb_port.h: add usb_sigproc_ptr for psignal(9) (struct proc *)
- usb.h: add UE_MAXPKTSZ(ep) and UE_MAXPKTSZ_MASK macros for USB 2.0

changes to USB device drivers
- atu, aue, axe, cdce, cue, kue, rum, udav, upl, ural, url,
uaudio, ubt, ucom, ugen, uhidev, uirda, ulpt, umidi, urio,
uscanner, ustir, utoppy:
* catch up API change of usbd_alloc_xfer()
- umass, usscanner:
* catch up API change of usbd_alloc_xfer()
* eliminate memory copy for large transfer

ohci
- free resources on detach
- add lots of bus_dmamap_sync() operations
- simplify the code of loading std chain
- rewrite code of looking up TD/ITD from DMA addr by using allocation chunk
- add workaround for CMD Tech 670 and 673 chipsets
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

slhci
- allocate xfer and slhci_xfer at once, and simplify relevant code
- add slhci_detach()
- remove second arg of slhci_attach() since it is the same as the first arg.
- add support for "mapping" (no, it doesn't map since it doesn't do DMA)
buffer and mbuf
- add pcmcia frontend
- NOT TESTED, missing hardware

ehci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf
- done only simple test

uhci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

To do
- review, test, debug
- rewrite network drivers to utilize usbd_map_buffer_mbuf()
- rewrite uaudio(4) to eliminate memcpy
- "pipe" argument of usbd_setup_*xfer() should eventually be removed
 1.35.6.2 23-Oct-2007  ad Sync with head.
 1.35.6.1 20-Aug-2007  ad Sync with HEAD.
 1.36.10.2 01-Aug-2007  christos Establish powerhooks in the proper order. From Anon Ymous
 1.36.10.1 01-Aug-2007  christos file uhci_pci.c was added on branch matt-mips64 on 2007-08-01 10:39:44 +0000
 1.36.8.1 25-Oct-2007  bouyer Sync with HEAD.
 1.36.4.3 23-Mar-2008  matt sync with HEAD
 1.36.4.2 09-Jan-2008  matt sync with HEAD
 1.36.4.1 06-Nov-2007  matt sync with HEAD
 1.36.2.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.36.2.5 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.36.2.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.36.2.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.36.2.2 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.36.2.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.37.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.37.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.39.4.1 11-Dec-2007  yamt sync with head.
 1.39.2.1 26-Dec-2007  ad Sync with head.
 1.40.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.40.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.40.6.1 24-Mar-2008  keiichi sync with head.
 1.43.4.4 11-Mar-2010  yamt sync with head
 1.43.4.3 16-May-2009  yamt sync with head
 1.43.4.2 04-May-2009  yamt sync with head.
 1.43.4.1 16-May-2008  yamt sync with head.
 1.43.2.1 18-May-2008  yamt sync with head.
 1.44.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.44.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.49.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.50.2.1 21-Apr-2011  rmind sync with head
 1.52.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.53.8.2 18-Feb-2012  mrg merge to -current.
 1.53.8.1 09-Dec-2011  mrg - make pipe->close method take the thread lock

- convert usb_taskq to use mutex/cv

- convert needs_explore usage into a cv on the thread lock

- remove KERNEL_*LOCK from uaudio and umidi, since we're supposedly
MPSAFE here now

- use IPL_SCHED instead of IPL_USB (aka biglocked) interrupts

- drop the audio thread lock when calling into usb when it may sleep,
avoiding a deadlock between audiowrite and audioioctl. this fixes
mixerctl -a vs. playing hanging the system
XXX probably need to check this in a bunch more places.
 1.53.4.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.53.4.2 30-Oct-2012  yamt sync with head
 1.53.4.1 17-Apr-2012  yamt sync with head
 1.55.2.3 03-Dec-2017  jdolecek update from HEAD
 1.55.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.2.1 23-Jun-2013  tls resync from head
 1.56.6.1 18-May-2014  rmind sync with head
 1.57.8.2 14-Sep-2016  skrll Use IPL_USB for interrupt handler
 1.57.8.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.57.4.1 05-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1395):
share/man/man4/axe.4: netbsd-7-nhusb
share/man/man4/axen.4: netbsd-7-nhusb
share/man/man4/cdce.4: netbsd-7-nhusb
share/man/man4/uaudio.4: netbsd-7-nhusb
share/man/man4/ucom.4: netbsd-7-nhusb
share/man/man4/uep.4: netbsd-7-nhusb
share/man/man4/urtw.4: netbsd-7-nhusb
share/man/man4/usb.4: netbsd-7-nhusb
share/man/man4/uyap.4: netbsd-7-nhusb
share/man/man4/xhci.4: netbsd-7-nhusb
share/man/man9/usbdi.9: netbsd-7-nhusb
sys/arch/amd64/conf/ALL: netbsd-7-nhusb
sys/arch/amd64/conf/GENERIC: netbsd-7-nhusb
sys/arch/amiga/dev/slhci_zbus.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_otg.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_usb.c: netbsd-7-nhusb
sys/arch/arm/amlogic/amlogic_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/at91/at91ohci.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm2835_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm53xx_usb.c: netbsd-7-nhusb
sys/arch/arm/ep93xx/epohci.c: netbsd-7-nhusb
sys/arch/arm/gemini/obio_ehci.c: netbsd-7-nhusb
sys/arch/arm/imx/files.imx23: netbsd-7-nhusb
sys/arch/arm/imx/imxusb.c: netbsd-7-nhusb
sys/arch/arm/imx/imxusbreg.h: netbsd-7-nhusb
sys/arch/arm/omap/obio_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/omap3_ehci.c: netbsd-7-nhusb
sys/arch/arm/omap/omapl1x_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/tiotg.c: netbsd-7-nhusb
sys/arch/arm/s3c2xx0/ohci_s3c24x0.c: netbsd-7-nhusb
sys/arch/arm/samsung/exynos_usb.c: netbsd-7-nhusb
sys/arch/arm/xscale/pxa2x0_ohci.c: netbsd-7-nhusb
sys/arch/arm/zynq/zynq_usb.c: netbsd-7-nhusb
sys/arch/hpcarm/dev/nbp_slhci.c: netbsd-7-nhusb
sys/arch/hpcmips/dev/plumohci.c: netbsd-7-nhusb
sys/arch/i386/conf/ALL: netbsd-7-nhusb
sys/arch/i386/conf/GENERIC: netbsd-7-nhusb
sys/arch/i386/pci/gcscehci.c: netbsd-7-nhusb
sys/arch/luna68k/conf/GENERIC: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahci.c: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahcivar.h: netbsd-7-nhusb
sys/arch/mips/alchemy/dev/ohci_aubus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ehci_arbus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ohci_arbus.c: netbsd-7-nhusb
sys/arch/mips/conf/files.adm5120: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ehci.c: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ohci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ehci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ohci.c: netbsd-7-nhusb
sys/arch/playstation2/dev/ohci_sbus.c: netbsd-7-nhusb
sys/arch/powerpc/booke/dev/pq3ehci.c: netbsd-7-nhusb
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c: netbsd-7-nhusb
sys/arch/x68k/dev/slhci_intio.c: netbsd-7-nhusb
sys/conf/files: netbsd-7-nhusb
sys/dev/cardbus/ehci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/ohci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/uhci_cardbus.c: netbsd-7-nhusb
sys/dev/ic/sl811hs.c: netbsd-7-nhusb
sys/dev/ic/sl811hsvar.h: netbsd-7-nhusb
sys/dev/isa/slhci_isa.c: netbsd-7-nhusb
sys/dev/marvell/ehci_mv.c: netbsd-7-nhusb
sys/dev/pci/ehci_pci.c: netbsd-7-nhusb
sys/dev/pci/ohci_pci.c: netbsd-7-nhusb
sys/dev/pci/uhci_pci.c: netbsd-7-nhusb
sys/dev/pci/xhci_pci.c: netbsd-7-nhusb
sys/dev/pcmcia/slhci_pcmcia.c: netbsd-7-nhusb
sys/dev/usb/Makefile.usbdevs: netbsd-7-nhusb
sys/dev/usb/TODO: netbsd-7-nhusb
sys/dev/usb/TODO.usbmp: netbsd-7-nhusb
sys/dev/usb/aubtfwl.c: netbsd-7-nhusb
sys/dev/usb/auvitek.c: netbsd-7-nhusb
sys/dev/usb/auvitek_audio.c: netbsd-7-nhusb
sys/dev/usb/auvitek_dtv.c: netbsd-7-nhusb
sys/dev/usb/auvitek_i2c.c: netbsd-7-nhusb
sys/dev/usb/auvitek_video.c: netbsd-7-nhusb
sys/dev/usb/auvitekvar.h: netbsd-7-nhusb
sys/dev/usb/ehci.c: netbsd-7-nhusb
sys/dev/usb/ehcireg.h: netbsd-7-nhusb
sys/dev/usb/ehcivar.h: netbsd-7-nhusb
sys/dev/usb/emdtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_dtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_ir.c: netbsd-7-nhusb
sys/dev/usb/emdtvvar.h: netbsd-7-nhusb
sys/dev/usb/ezload.c: netbsd-7-nhusb
sys/dev/usb/ezload.h: netbsd-7-nhusb
sys/dev/usb/files.usb: netbsd-7-nhusb
sys/dev/usb/hid.c: netbsd-7-nhusb
sys/dev/usb/hid.h: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.c: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.h: netbsd-7-nhusb
sys/dev/usb/if_atu.c: netbsd-7-nhusb
sys/dev/usb/if_atureg.h: netbsd-7-nhusb
sys/dev/usb/if_aue.c: netbsd-7-nhusb
sys/dev/usb/if_auereg.h: netbsd-7-nhusb
sys/dev/usb/if_axe.c: netbsd-7-nhusb
sys/dev/usb/if_axen.c: netbsd-7-nhusb
sys/dev/usb/if_axenreg.h: netbsd-7-nhusb
sys/dev/usb/if_axereg.h: netbsd-7-nhusb
sys/dev/usb/if_cdce.c: netbsd-7-nhusb
sys/dev/usb/if_cdcereg.h: netbsd-7-nhusb
sys/dev/usb/if_cue.c: netbsd-7-nhusb
sys/dev/usb/if_cuereg.h: netbsd-7-nhusb
sys/dev/usb/if_kue.c: netbsd-7-nhusb
sys/dev/usb/if_kuereg.h: netbsd-7-nhusb
sys/dev/usb/if_otus.c: netbsd-7-nhusb
sys/dev/usb/if_otusvar.h: netbsd-7-nhusb
sys/dev/usb/if_rum.c: netbsd-7-nhusb
sys/dev/usb/if_rumreg.h: netbsd-7-nhusb
sys/dev/usb/if_rumvar.h: netbsd-7-nhusb
sys/dev/usb/if_run.c: netbsd-7-nhusb
sys/dev/usb/if_runvar.h: netbsd-7-nhusb
sys/dev/usb/if_smsc.c: netbsd-7-nhusb
sys/dev/usb/if_smscreg.h: netbsd-7-nhusb
sys/dev/usb/if_smscvar.h: netbsd-7-nhusb
sys/dev/usb/if_udav.c: netbsd-7-nhusb
sys/dev/usb/if_udavreg.h: netbsd-7-nhusb
sys/dev/usb/if_upgt.c: netbsd-7-nhusb
sys/dev/usb/if_upgtvar.h: netbsd-7-nhusb
sys/dev/usb/if_upl.c: netbsd-7-nhusb
sys/dev/usb/if_ural.c: netbsd-7-nhusb
sys/dev/usb/if_uralreg.h: netbsd-7-nhusb
sys/dev/usb/if_uralvar.h: netbsd-7-nhusb
sys/dev/usb/if_url.c: netbsd-7-nhusb
sys/dev/usb/if_urlreg.h: netbsd-7-nhusb
sys/dev/usb/if_urndis.c: netbsd-7-nhusb
sys/dev/usb/if_urndisreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtw.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn_data.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnvar.h: netbsd-7-nhusb
sys/dev/usb/if_urtwreg.h: netbsd-7-nhusb
sys/dev/usb/if_zyd.c: netbsd-7-nhusb
sys/dev/usb/if_zydreg.h: netbsd-7-nhusb
sys/dev/usb/irmce.c: netbsd-7-nhusb
sys/dev/usb/moscom.c: netbsd-7-nhusb
sys/dev/usb/motg.c: netbsd-7-nhusb
sys/dev/usb/motgvar.h: netbsd-7-nhusb
sys/dev/usb/ohci.c: netbsd-7-nhusb
sys/dev/usb/ohcireg.h: netbsd-7-nhusb
sys/dev/usb/ohcivar.h: netbsd-7-nhusb
sys/dev/usb/pseye.c: netbsd-7-nhusb
sys/dev/usb/slurm.c: netbsd-7-nhusb
sys/dev/usb/stuirda.c: netbsd-7-nhusb
sys/dev/usb/u3g.c: netbsd-7-nhusb
sys/dev/usb/uark.c: netbsd-7-nhusb
sys/dev/usb/uatp.c: netbsd-7-nhusb
sys/dev/usb/uaudio.c: netbsd-7-nhusb
sys/dev/usb/uberry.c: netbsd-7-nhusb
sys/dev/usb/ubsa.c: netbsd-7-nhusb
sys/dev/usb/ubsa_common.c: netbsd-7-nhusb
sys/dev/usb/ubsavar.h: netbsd-7-nhusb
sys/dev/usb/ubt.c: netbsd-7-nhusb
sys/dev/usb/uchcom.c: netbsd-7-nhusb
sys/dev/usb/ucom.c: netbsd-7-nhusb
sys/dev/usb/ucomvar.h: netbsd-7-nhusb
sys/dev/usb/ucycom.c: netbsd-7-nhusb
sys/dev/usb/udl.c: netbsd-7-nhusb
sys/dev/usb/udl.h: netbsd-7-nhusb
sys/dev/usb/udsbr.c: netbsd-7-nhusb
sys/dev/usb/udsir.c: netbsd-7-nhusb
sys/dev/usb/uep.c: netbsd-7-nhusb
sys/dev/usb/uftdi.c: netbsd-7-nhusb
sys/dev/usb/uftdireg.h: netbsd-7-nhusb
sys/dev/usb/ugen.c: netbsd-7-nhusb
sys/dev/usb/ugensa.c: netbsd-7-nhusb
sys/dev/usb/uhci.c: netbsd-7-nhusb
sys/dev/usb/uhcireg.h: netbsd-7-nhusb
sys/dev/usb/uhcivar.h: netbsd-7-nhusb
sys/dev/usb/uhid.c: netbsd-7-nhusb
sys/dev/usb/uhidev.c: netbsd-7-nhusb
sys/dev/usb/uhidev.h: netbsd-7-nhusb
sys/dev/usb/uhmodem.c: netbsd-7-nhusb
sys/dev/usb/uhso.c: netbsd-7-nhusb
sys/dev/usb/uhub.c: netbsd-7-nhusb
sys/dev/usb/uipad.c: netbsd-7-nhusb
sys/dev/usb/uipaq.c: netbsd-7-nhusb
sys/dev/usb/uirda.c: netbsd-7-nhusb
sys/dev/usb/uirdavar.h: netbsd-7-nhusb
sys/dev/usb/ukbd.c: netbsd-7-nhusb
sys/dev/usb/ukbdmap.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.h: netbsd-7-nhusb
sys/dev/usb/ulpt.c: netbsd-7-nhusb
sys/dev/usb/umass.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.h: netbsd-7-nhusb
sys/dev/usb/umass_quirks.c: netbsd-7-nhusb
sys/dev/usb/umass_quirks.h: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.c: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.h: netbsd-7-nhusb
sys/dev/usb/umassvar.h: netbsd-7-nhusb
sys/dev/usb/umcs.c: netbsd-7-nhusb
sys/dev/usb/umct.c: netbsd-7-nhusb
sys/dev/usb/umidi.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.h: netbsd-7-nhusb
sys/dev/usb/umodem.c: netbsd-7-nhusb
sys/dev/usb/umodem_common.c: netbsd-7-nhusb
sys/dev/usb/umodemvar.h: netbsd-7-nhusb
sys/dev/usb/ums.c: netbsd-7-nhusb
sys/dev/usb/uplcom.c: netbsd-7-nhusb
sys/dev/usb/urio.c: netbsd-7-nhusb
sys/dev/usb/urio.h: netbsd-7-nhusb
sys/dev/usb/usb.c: netbsd-7-nhusb
sys/dev/usb/usb.h: netbsd-7-nhusb
sys/dev/usb/usb_mem.c: netbsd-7-nhusb
sys/dev/usb/usb_mem.h: netbsd-7-nhusb
sys/dev/usb/usb_quirks.c: netbsd-7-nhusb
sys/dev/usb/usb_quirks.h: netbsd-7-nhusb
sys/dev/usb/usb_subr.c: netbsd-7-nhusb
sys/dev/usb/usbdevices.config: netbsd-7-nhusb
sys/dev/usb/usbdevs: netbsd-7-nhusb
sys/dev/usb/usbdevs.h: netbsd-7-nhusb
sys/dev/usb/usbdevs_data.h: netbsd-7-nhusb
sys/dev/usb/usbdi.c: netbsd-7-nhusb
sys/dev/usb/usbdi.h: netbsd-7-nhusb
sys/dev/usb/usbdi_util.c: netbsd-7-nhusb
sys/dev/usb/usbdi_util.h: netbsd-7-nhusb
sys/dev/usb/usbdivar.h: netbsd-7-nhusb
sys/dev/usb/usbhid.h: netbsd-7-nhusb
sys/dev/usb/usbhist.h: netbsd-7-nhusb
sys/dev/usb/usbroothub.c: netbsd-7-nhusb
sys/dev/usb/usbroothub.h: netbsd-7-nhusb
sys/dev/usb/usbroothub_subr.c: delete
sys/dev/usb/usbroothub_subr.h: delete
sys/dev/usb/uscanner.c: netbsd-7-nhusb
sys/dev/usb/uslsa.c: netbsd-7-nhusb
sys/dev/usb/usscanner.c: netbsd-7-nhusb
sys/dev/usb/ustir.c: netbsd-7-nhusb
sys/dev/usb/uthum.c: netbsd-7-nhusb
sys/dev/usb/utoppy.c: netbsd-7-nhusb
sys/dev/usb/uts.c: netbsd-7-nhusb
sys/dev/usb/uvideo.c: netbsd-7-nhusb
sys/dev/usb/uvisor.c: netbsd-7-nhusb
sys/dev/usb/uvscom.c: netbsd-7-nhusb
sys/dev/usb/uyap.c: netbsd-7-nhusb
sys/dev/usb/uyap_firmware.h: netbsd-7-nhusb
sys/dev/usb/uyurex.c: netbsd-7-nhusb
sys/dev/usb/x1input_rdesc.h: netbsd-7-nhusb
sys/dev/usb/xhci.c: netbsd-7-nhusb
sys/dev/usb/xhcireg.h: netbsd-7-nhusb
sys/dev/usb/xhcivar.h: netbsd-7-nhusb
sys/dev/usb/xinput_rdesc.h: netbsd-7-nhusb
sys/external/bsd/common/conf/files.linux: netbsd-7-nhusb
sys/external/bsd/common/include/linux/err.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/kernel.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/workqueue.h: netbsd-7-nhusb
sys/external/bsd/common/linux/linux_work.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/atombios_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/drm/files.drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/i915drm/files.i915drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/include/linux/err.h: delete
sys/external/bsd/drm2/include/linux/workqueue.h: delete
sys/external/bsd/drm2/linux/files.drmkms_linux: netbsd-7-nhusb
sys/external/bsd/drm2/linux/linux_work.c: delete
sys/external/bsd/dwc2/dwc2.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2var.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwctwo2netbsd: netbsd-7-nhusb
sys/external/bsd/dwc2/conf/files.dwc2: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_coreintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdddma.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hw.h: netbsd-7-nhusb
sys/modules/drmkms_linux/Makefile: netbsd-7-nhusb
sys/modules/i915drmkms/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libugenhc/ugenhc.c: netbsd-7-nhusb
sys/rump/dev/lib/libusb/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libusb/USB.ioconf: netbsd-7-nhusb
sys/rump/dev/lib/libusb/usb_at_ugenhc.c: delete
sys/rump/dev/lib/libusb/opt/opt_usb.h: delete
sys/rump/dev/lib/libusb/opt/opt_usbverbose.h: delete
sys/sys/mbuf.h: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.8: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.c: netbsd-7-nhusb
Merge netbsd-7-nhusb:
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
- Change the SOFTINT level from NET to SERIAL for the USB softint handler.
This gives the callback a chance of running when another softint handler
at SOFTINT_NET has blocked holding a lock, e.g. softnet_lock and most of
the network stack.
- kern/49065 - ifconfig tun0 ... sequence locks up system / lockup:
softnet_lock held across usb xfr
- kern/50491 - unkillable wait in usbd_transfer while using usmsc0
on raspberry pi 2
- kern/51395 - USB Ethernet makes xhci hang
- Various improvements to slhci(4)
- Various improvements to dwc2(4)
 1.58.2.5 28-Aug-2017  skrll Sync with HEAD
 1.58.2.4 22-Sep-2015  skrll Sync with HEAD
 1.58.2.3 05-Dec-2014  skrll Use int for return type for [eou]chi_init and motg_init.
 1.58.2.2 05-Dec-2014  skrll KNF. Remove ( ) from return statements.
 1.58.2.1 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.60.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.61.8.2 21-May-2018  pgoyette Sync with HEAD
 1.61.8.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.64.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.65.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 13-Aug-2006  jmcneill branches: 1.1.2; 1.1.6; 1.1.12;
Acceleration definitions (missed in previous commit).
 1.1.12.2 30-Dec-2006  yamt sync with head.
 1.1.12.1 13-Aug-2006  yamt file unichromeaccel.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.1.6.2 09-Sep-2006  rpaulo sync with head
 1.1.6.1 13-Aug-2006  rpaulo file unichromeaccel.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.2.2 03-Sep-2006  yamt sync with head.
 1.1.2.1 13-Aug-2006  yamt file unichromeaccel.h was added on branch yamt-pdpolicy on 2006-09-03 15:24:23 +0000
 1.2 13-Aug-2006  jmcneill branches: 1.2.4; 1.2.10;
Expose RGB palette tables.
 1.1 02-Aug-2006  jmcneill branches: 1.1.4;
Add work-in-progress framebuffer console driver for the VIA UniChrome
integrated graphics family.
 1.1.4.3 03-Sep-2006  yamt sync with head.
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 02-Aug-2006  yamt file unichromeconfig.h was added on branch yamt-pdpolicy on 2006-08-11 15:44:26 +0000
 1.2.10.2 30-Dec-2006  yamt sync with head.
 1.2.10.1 13-Aug-2006  yamt file unichromeconfig.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.2.4.2 09-Sep-2006  rpaulo sync with head
 1.2.4.1 13-Aug-2006  rpaulo file unichromeconfig.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.22 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.21 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.20 24-Apr-2021  thorpej branches: 1.20.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.19 25-Oct-2015  khorben branches: 1.19.34;
Remove references to SPLASHSCREEN_PROGRESS

To my knowledge this feature is no longer supported at the moment. The
manual page for wsdisplay(4) should probably also be updated to reflect
this situation.
 1.18 22-Jan-2011  cegger branches: 1.18.14; 1.18.32;
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.17 16-Dec-2010  cegger branches: 1.17.2; 1.17.4;
ioctl: KNF switch-case, remove useless brackets
 1.16 06-May-2009  cegger branches: 1.16.4;
struct device * -> device_t, no functional changes intended.
 1.15 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.14 05-May-2008  jmcneill branches: 1.14.14;
Change autoconf message 'direct rendering on dev unsupported' to
the more accurate 'drm at dev not configured'.
 1.13 05-May-2008  jmcneill Use 2-clause license.
 1.12 27-Mar-2008  jmcneill branches: 1.12.2; 1.12.4;
Split device_t and softc, aprintify
 1.11 12-Mar-2008  phx Make console drivers support PCI_IOC_CFGREAD/WRITE ioctls. This is useful for
XFree86, which can alternatively find the graphics card through /dev/ttyE0.
Approved by macallan.
 1.10 01-Dec-2007  ad branches: 1.10.10; 1.10.14;
Back out previous.
 1.9 01-Dec-2007  ad Noisy printfs.
 1.8 19-Oct-2007  ad branches: 1.8.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.7 23-Mar-2007  jmcneill branches: 1.7.8; 1.7.10; 1.7.14;
Make unichromefb(4) peacefully co-exist with viadrm(4).

Basically, when we switch from WSDISPLAYIO_MODE_EMUL to anything else, we
release any bus_space resources. When we return to WSDISPLAYIO_MODE_EMUL,
reclaim these resources and reinitialize the display.

Idea from macallan@
 1.6 04-Mar-2007  christos branches: 1.6.2; 1.6.4; 1.6.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 12-Jan-2007  ober branches: 1.5.2;
Update to compile properly.
OK jmcneill
 1.4 13-Aug-2006  jmcneill branches: 1.4.2; 1.4.4; 1.4.8; 1.4.10; 1.4.12;
Reclaim resources from an initial vga console on attach.
 1.3 13-Aug-2006  jmcneill Add accelerated putchar and cursor ops. Also fix a bug in copyrows that
caused scrolling down to always fail.
 1.2 13-Aug-2006  jmcneill Add acceleration support for the VIA UniChrome driver. While here, fix a
bug that caused the screen to be filled with annoying vertical lines.
 1.1 02-Aug-2006  jmcneill branches: 1.1.2; 1.1.4;
Add work-in-progress framebuffer console driver for the VIA UniChrome
integrated graphics family.
 1.1.4.3 03-Sep-2006  yamt sync with head.
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 02-Aug-2006  yamt file unichromefb.c was added on branch yamt-pdpolicy on 2006-08-11 15:44:26 +0000
 1.1.2.1 15-Aug-2006  ghen Pull up following revision(s) (requested by jmcneill in ticket #19):
sys/dev/pci/unichromefb.c: revision 1.2
Add acceleration support for the VIA UniChrome driver. While here, fix a
bug that caused the screen to be filled with annoying vertical lines.
 1.4.12.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.4.10.6 17-Mar-2008  yamt sync with head.
 1.4.10.5 27-Oct-2007  yamt sync with head.
 1.4.10.4 03-Sep-2007  yamt sync with head.
 1.4.10.3 26-Feb-2007  yamt sync with head.
 1.4.10.2 30-Dec-2006  yamt sync with head.
 1.4.10.1 13-Aug-2006  yamt file unichromefb.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.4.8.1 21-Jun-2007  liamjfoy Pull up following revision(s) (requested by sborrill in ticket #737):
sys/dev/pci/unichromefb.c: revision 1.5
Update to compile properly.
OK jmcneill
 1.4.4.2 09-Sep-2006  rpaulo sync with head
 1.4.4.1 13-Aug-2006  rpaulo file unichromefb.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.4.2.1 01-Feb-2007  ad Sync with head.
 1.5.2.2 24-Mar-2007  yamt sync with head.
 1.5.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.6.1 29-Mar-2007  reinoud Pullup to -current
 1.6.4.1 11-Jul-2007  mjf Sync with head.
 1.6.2.2 23-Oct-2007  ad Sync with head.
 1.6.2.1 10-Apr-2007  ad Sync with head.
 1.7.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.10.2 23-Mar-2008  matt sync with HEAD
 1.7.10.1 06-Nov-2007  matt sync with HEAD
 1.7.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.8.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.10.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.10.1 24-Mar-2008  keiichi sync with head.
 1.12.4.2 16-May-2009  yamt sync with head
 1.12.4.1 16-May-2008  yamt sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.14.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.4.1 05-Mar-2011  rmind sync with head
 1.17.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.32.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.18.14.1 03-Dec-2017  jdolecek update from HEAD
 1.19.34.3 24-Apr-2021  thorpej Make sure to explcitly specify the "wsemuldisplaydev" interface attribute
when attaching the wscons display instance, because these devices can
also attach children using the "drm" interface attribute.
 1.19.34.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.19.34.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.20.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 02-Aug-2006  jmcneill branches: 1.1.4; 1.1.8; 1.1.14;
Add work-in-progress framebuffer console driver for the VIA UniChrome
integrated graphics family.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 02-Aug-2006  yamt file unichromehw.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:48 +0000
 1.1.8.2 09-Sep-2006  rpaulo sync with head
 1.1.8.1 02-Aug-2006  rpaulo file unichromehw.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 02-Aug-2006  yamt file unichromehw.h was added on branch yamt-pdpolicy on 2006-08-11 15:44:26 +0000
 1.2 02-Feb-2024  andvar fix typos, mainly s/unsupport/unsupported/ in log messages.
 1.1 02-Aug-2006  jmcneill branches: 1.1.4; 1.1.8; 1.1.14;
Add work-in-progress framebuffer console driver for the VIA UniChrome
integrated graphics family.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 02-Aug-2006  yamt file unichromemode.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:49 +0000
 1.1.8.2 09-Sep-2006  rpaulo sync with head
 1.1.8.1 02-Aug-2006  rpaulo file unichromemode.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 02-Aug-2006  yamt file unichromemode.h was added on branch yamt-pdpolicy on 2006-08-11 15:44:26 +0000
 1.1 02-Aug-2006  jmcneill branches: 1.1.4; 1.1.8; 1.1.14;
Add work-in-progress framebuffer console driver for the VIA UniChrome
integrated graphics family.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 02-Aug-2006  yamt file unichromereg.h was added on branch yamt-lazymbuf on 2006-12-30 20:48:49 +0000
 1.1.8.2 09-Sep-2006  rpaulo sync with head
 1.1.8.1 02-Aug-2006  rpaulo file unichromereg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 02-Aug-2006  yamt file unichromereg.h was added on branch yamt-pdpolicy on 2006-08-11 15:44:26 +0000
 1.13 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.12 29-Mar-2014  christos branches: 1.12.28; 1.12.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.11 26-Nov-2009  njoly branches: 1.11.12; 1.11.22; 1.11.26;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.10 16-Mar-2009  dsl ANSIfy functions with function-pointer arguments
 1.9 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.8 19-Oct-2007  ad branches: 1.8.20; 1.8.28; 1.8.34;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.7 11-Dec-2005  christos branches: 1.7.30; 1.7.44; 1.7.46; 1.7.50;
merge ktrace-lwp.
 1.6 04-Feb-2005  perry branches: 1.6.6;
de-__P
 1.5 31-Jan-2003  thorpej branches: 1.5.2; 1.5.10; 1.5.12;
Use aprint_*().
 1.4 13-Nov-2001  lukem add RCSID
 1.3 28-Dec-2000  sommerfeld branches: 1.3.2; 1.3.4;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.2 12-Mar-2000  drochner branches: 1.2.6;
add support for DMA mapping, bus probes ala "badaddr" and VME interrupts,
improve diagnostic output
 1.1 25-Feb-2000  drochner add (minimal, PIO only) support for the popular "Tundra Universe"
PCI-VME interface chip and a frontend for the "Bit3 Mod. 2706"
PCI-VME adapter
 1.2.6.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 12-Mar-2000  bouyer file universe_pci.c was added on branch thorpej_scsipi on 2000-11-20 11:42:38 +0000
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.5.12.1 12-Feb-2005  yamt sync with head.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.6.6.1 27-Oct-2007  yamt sync with head.
 1.7.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.46.1 06-Nov-2007  matt sync with HEAD
 1.7.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.30.1 23-Oct-2007  ad Sync with head.
 1.8.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.20.2 11-Mar-2010  yamt sync with head
 1.8.20.1 04-May-2009  yamt sync with head.
 1.11.26.1 18-May-2014  rmind sync with head
 1.11.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.30.1 10-Jun-2019  christos Sync with HEAD
 1.12.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5 30-Jun-2011  wiz dependant -> dependent
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 04-Feb-2005  perry de-__P
 1.2 12-Mar-2000  drochner branches: 1.2.6; 1.2.30; 1.2.38; 1.2.40;
add support for DMA mapping, bus probes ala "badaddr" and VME interrupts,
improve diagnostic output
 1.1 25-Feb-2000  drochner add (minimal, PIO only) support for the popular "Tundra Universe"
PCI-VME interface chip and a frontend for the "Bit3 Mod. 2706"
PCI-VME adapter
 1.2.40.1 12-Feb-2005  yamt sync with head.
 1.2.38.1 29-Apr-2005  kent sync with -current
 1.2.30.1 04-Feb-2005  skrll Sync with HEAD.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 12-Mar-2000  bouyer file universe_pci_var.h was added on branch thorpej_scsipi on 2000-11-20 11:42:39 +0000
 1.9 31-Mar-2025  riastradh ehci(4): Make usb_*_rem work as noop on zero-initialized input.

This way, if some *hci_attach function fails before usb_*_add, the
caller need not maintain boolean state to decide whether to call
usb_*_rem on detach -- it'll just work without extra effort.

Cleanup in preparation for:

PR port-amd64/59180: System reboots instead of shutting down
 1.8 31-Mar-2025  riastradh ehci(4): Sprinkle KERNEL_LOCKED_P and KNF on usb_*_add/rem.

Mark with XXXSMP comments to be fixed later without the kernel lock.

No functional change intended: callers generally do this from
autoconf *_attach/detach routines, which run kernel-locked anyway
(for the moment).

Cleanup in preparation for:

PR port-amd64/59180: System reboots instead of shutting down
 1.7 28-Apr-2008  martin branches: 1.7.126;
Remove clause 3 and 4 from TNF licenses
 1.6 28-Mar-2008  drochner branches: 1.6.2; 1.6.4;
split device/softc for USB host controllers and the usb (control)
device,
this is hairy stuff, and I've only tested with uhci/ehci at pci,
please test the rest and report problems
 1.5 11-Dec-2005  christos branches: 1.5.70;
merge ktrace-lwp.
 1.4 21-Dec-2004  fvdl Implement an USB memory reserve. Allocate some memory per host controller
in the wanted bus_dma space. If an allocation fails during operation
(i.e. when hotplugging an umass device), fall back to using the reserve.

The amount can be configured as USB_MEM_RESERVE. The default value is
256k.

Ideally, there would be a way to steal pages in the desired area from
UVM, but that's far more complicated, and this is not intrusive, plus
it works.
 1.3 14-Feb-2002  augustss branches: 1.3.16; 1.3.22;
Use the correct years for copyright.
 1.2 12-Jan-2002  enami Make ehci_pci.c compiles again.
 1.1 09-Jan-2002  augustss branches: 1.1.2; 1.1.4;
Split out some code so you can have cardbus ehci without pci.
 1.1.4.3 17-Apr-2002  nathanw Catch up to -current.
 1.1.4.2 11-Jan-2002  nathanw More catchup.
 1.1.4.1 09-Jan-2002  nathanw file usb_pci.c was added on branch nathanw_sa on 2002-01-11 23:39:28 +0000
 1.1.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.1 09-Jan-2002  thorpej file usb_pci.c was added on branch kqueue on 2002-01-10 19:57:08 +0000
 1.3.22.1 13-May-2005  riz Pull up revision 1.4 (requested by bad in ticket #1479):
Implement an USB memory reserve. Allocate some memory per host controller
in the wanted bus_dma space. If an allocation fails during operation
(i.e. when hotplugging an umass device), fall back to using the reserve.
The amount can be configured as USB_MEM_RESERVE. The default value is
256k.
Ideally, there would be a way to steal pages in the desired area from
UVM, but that's far more complicated, and this is not intrusive, plus
it works.
 1.3.16.1 17-Jan-2005  skrll Sync with HEAD.
 1.5.70.2 02-Jun-2008  mjf Sync with HEAD.
 1.5.70.1 03-Apr-2008  mjf Sync with HEAD.
 1.6.4.1 16-May-2008  yamt sync with head.
 1.6.2.1 18-May-2008  yamt sync with head.
 1.7.126.1 02-Aug-2025  perseant Sync with HEAD
 1.7 09-Oct-2024  andvar s/compainion/companion/ in comments.
 1.6 11-Dec-2010  matt branches: 1.6.98;
Make ehci deal with pci devices that have multiple companion functions and
ehci functions. We can't assume that there will only be one ehci per device.
The existing code could not deal with:

Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured
 1.5 28-Apr-2008  martin branches: 1.5.18; 1.5.22; 1.5.26;
Remove clause 3 and 4 from TNF licenses
 1.4 28-Mar-2008  drochner branches: 1.4.2; 1.4.4;
split device/softc for USB host controllers and the usb (control)
device,
this is hairy stuff, and I've only tested with uhci/ehci at pci,
please test the rest and report problems
 1.3 14-Feb-2002  augustss branches: 1.3.114;
Use the correct years for copyright.
 1.2 12-Jan-2002  enami Make ehci_pci.c compiles again.
 1.1 06-Nov-2001  augustss branches: 1.1.2; 1.1.4; 1.1.6;
Add some data structures to keep enable finding companion controllers
for EHCI.
 1.1.6.4 16-Mar-2002  jdolecek Catch up with -current.
 1.1.6.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.1 06-Nov-2001  thorpej file usb_pci.h was added on branch kqueue on 2002-01-10 19:57:08 +0000
 1.1.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 06-Nov-2001  nathanw file usb_pci.h was added on branch nathanw_sa on 2001-11-14 19:15:32 +0000
 1.1.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.1.2.1 06-Nov-2001  thorpej file usb_pci.h was added on branch thorpej-mips-cache on 2001-11-12 21:18:23 +0000
 1.3.114.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.114.1 03-Apr-2008  mjf Sync with HEAD.
 1.4.4.1 16-May-2008  yamt sync with head.
 1.4.2.1 18-May-2008  yamt sync with head.
 1.5.26.1 07-Jan-2011  matt Deal with multifunction pci devices better in choosing companion devices.
 1.5.22.1 05-Mar-2011  rmind sync with head
 1.5.18.1 04-Jan-2012  matt Take changes from matt-nb5-pq3 which fixes how multiple ehci functions
on a pci device claim companion ohci controllers.
 1.6.98.1 02-Aug-2025  perseant Sync with HEAD
 1.59 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.58 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.57 24-Apr-2021  thorpej branches: 1.57.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.56 17-Jun-2020  jdolecek branches: 1.56.4;
explicitly disable INTx interrupts to avoid interrupt storm triggered by
unhandled adapter interrupts

fixes PR kern/46596 by Andreas Gustafsson, fix adopted from FreeBSD
 1.55 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.54 30-Jan-2012  drochner branches: 1.54.6; 1.54.24;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.53 22-Jan-2011  cegger branches: 1.53.4; 1.53.8;
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.52 16-Dec-2010  cegger branches: 1.52.2; 1.52.4;
ioctl: KNF switch-case, remove useless brackets
 1.51 19-Nov-2010  macallan add PCI_MAGIC_IO_RANGE so non-x86 machines can map the IO range belonging to
the console vga
thanks to nick for reminding me to commit this and for confirming that it works as intended
 1.50 09-Nov-2010  shattered PR/10000: disable fast scrolling on Cyrix GXLV (CS5530 chipset)

OK by wiz@
 1.49 24-Feb-2010  dyoung branches: 1.49.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.48 08-Jan-2010  dyoung branches: 1.48.2;
Expand PMF_FN_* macros.
 1.47 18-Aug-2009  jmcneill Adapt for NACPI -> NACPICA change.
 1.46 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.45 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.44 03-Aug-2008  joerg branches: 1.44.8;
Allow using VGA_POST without ACPI again.
 1.43 31-Jul-2008  joerg machdep.acpi_vbios_reset = 2 --> vga_pci_resume will use x86emu to do a
POST when options VGA_POST is present.
 1.42 18-May-2008  jmcneill branches: 1.42.4;
Add 'rescan' function for vga.
 1.41 05-May-2008  jmcneill branches: 1.41.2;
Change autoconf message 'direct rendering on dev unsupported' to
the more accurate 'drm at dev not configured'.
 1.40 14-Mar-2008  cube branches: 1.40.2; 1.40.4;
Split device_t and softc for all attachments of vga(4).
 1.39 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.38 25-Dec-2007  joerg branches: 1.38.2; 1.38.6;
Add initial version of calling VGA POST from vga_resume. This is the
equivalent to "vbetool post" using x86emu in the kernel.
 1.37 09-Dec-2007  jmcneill branches: 1.37.2;
Merge jmcneill-pm branch.
 1.36 01-Dec-2007  ad branches: 1.36.2; 1.36.4;
Back out previous.
 1.35 01-Dec-2007  ad Noisy printfs.
 1.34 01-Dec-2007  jmcneill aprintify
 1.33 26-Aug-2007  martin branches: 1.33.2; 1.33.8;
Allow 64bit memory BARs if we are compiling on 64bit archs.
 1.32 20-Mar-2007  drochner branches: 1.32.4; 1.32.8;
Import DRM drivers, brought into shape by Yorick Hardy, posted to tech-x11.
Minor modifications by me:
-use an mi device major number
-(coarsly) divided into pci card specific and less specific parts, moved
the latter to dev/drm
-renamed autoconf attributes to reflect this
Todo:
-adapt all card frontends but i915 to drm include file location
-review the mtrr change
-make the change to agp_i810.c coexist with the fix for buggy VESA
BIOSes which is commented out temporarily
-RCS IDs etc style stuff
-LKM support (rescan support for vga)
-test
 1.31 04-Mar-2007  christos branches: 1.31.2; 1.31.4; 1.31.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.30 16-Nov-2006  christos branches: 1.30.2; 1.30.4; 1.30.8;
__unused removal on arguments; approved by core.
 1.29 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.28 11-Dec-2005  christos branches: 1.28.20; 1.28.22;
merge ktrace-lwp.
 1.27 28-Jun-2005  thorpej branches: 1.27.2;
Use ANSI function decls and static.
 1.26 27-Feb-2005  perry nuke trailing whitespace
 1.25 11-May-2004  wiz branches: 1.25.4; 1.25.6;
Fix typo in comment; from Sergey Svishchev.
 1.24 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.23 29-Jun-2003  fvdl branches: 1.23.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.22 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.21 26-Feb-2003  salo Regen.
 1.20 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.19 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.18 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.17 08-Jul-2002  drochner there is at least one VGA chip (Silicon Motion Lynx EM+) where fast scrolling
by moving the display offset pointer doesn't work
 1.16 02-Jul-2002  drochner consider all ATI cards broken wrt font handling, as suggested by
Bang Jun-Young <junyoung@mogua.com>, but do it in way which allows
single cards to be declared O.K. in case we find one
 1.15 28-Jun-2002  drochner clean up font handling:
-treat the builtin font like any other font at runtime
-for that, copy it to malloc()'d memory during attach()
-in early console initialization, if we have to consider a broken card
(VGA_CONSOLE_ATI_BROKEN_FONTSEL), copy the builtin font to another
location in font ram; the attach() code will do the rest
put the "quirk" code into effect again
 1.14 27-Jun-2002  junyoung Whitespace KNF.
 1.13 27-Jun-2002  junyoung - Work around a hardware bug that loaded fonts don't work, which is
found on many (all?) of PCI-based ATI graphics cards. It is fully optional
and can be enabled by adding `options VGA_CONSOLE_ATI_BROKEN_FONTSEL'
to config file.
- Temporarily remove `quirk' mechanism. Similar code already exists
in pci_quirks.c.
 1.12 25-Jun-2002  drochner allow to overwrite the builtin VGA font if necessary,
make the number of available font slots variable,
set up a "quirk" mechanism to tell the generic vga code about crippled
VGA adapters which ignore the "fontsel" TS register,
initiate the quirk table with an ATI chip which happened to be on a board
I tested with.
Afaik quite a number of ATI chips suffers from the "loaded fonts don't
work" problem - these should be added.
Bad side effect of my change: The builtin font will be kicked out
always if a VGA_CONSOLE_SCREENTYPE is specified which needs a loaded
font. In early console initialization, we don't know much about the
graphics card, so we have to assume the worst (ie ATI:-).
 1.11 30-May-2002  drochner implement a check whether a BAR is present at all at a given configuration
space address and use it where the mappings of the VGA card are registered
before descenting too deep into "memory" type specific code
(pci_mem_find() gets noisy if it doesn't like the register)
 1.10 17-Mar-2002  atatat branches: 1.10.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.9 13-Dec-2001  junyoung ANSIfication & KNF fixes.
 1.8 13-Nov-2001  lukem add RCSID
 1.7 14-Sep-2001  thorpej Gather information about the mappable regions of the card at
attach time. Allow access to these regions in vga_pci_mmap().

Note: we also have to allow access to the legacy ISA "hole" in
vga_pci_mmap(), since the X server needs to be able to read
the legacy BIOS on many cards.

XXX Need to address the PCI Expansion ROM.

Based on changes from Simon Burge <simonb@wasabisystems.com>.
 1.6 14-Sep-2001  thorpej Add ioctl and mmap entry points for PCI VGA. ioctl provides
passthrough for PCI config space read/write. mmap currently
returns error (to be addressed in a future revision).
 1.5 14-Sep-2001  thorpej Allow bus front-end to provide both ioctl and mmap entry points,
and also the wsdisplay type.

Based on changes from Simon Burge <simonb@wasabisystems.com>.
 1.4 14-Aug-2000  thorpej branches: 1.4.2; 1.4.4; 1.4.6;
Just add the mmap argument to vga_common_attach(), don't bother
with vga_extended_attach().
 1.3 08-Jun-1998  thorpej branches: 1.3.14;
Nuke __BROKEN_INDIRECT_CONFIG.
 1.2 28-May-1998  drochner Put definitions and subroutines needed for all PC display adapters
(MGA/GCA and compatibles) into global headers / source files.
Let the VGA driver use them.
 1.1 22-Mar-1998  drochner PCI frontend for sys/dev/ic/vga.c
 1.3.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.7 18-Oct-2002  nathanw Catch up to -current.
 1.4.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.4.2.5 20-Jun-2002  nathanw Catch up to -current.
 1.4.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.4.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.10.4.2 15-Jul-2002  gehenna catch up with -current.
 1.10.4.1 20-Jun-2002  gehenna catch up with -current.
 1.23.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.23.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.23.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.23.2.2 03-Aug-2004  skrll Sync with HEAD
 1.23.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.25.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.25.4.1 29-Apr-2005  kent sync with -current
 1.27.2.6 17-Mar-2008  yamt sync with head.
 1.27.2.5 21-Jan-2008  yamt sync with head
 1.27.2.4 07-Dec-2007  yamt sync with head
 1.27.2.3 03-Sep-2007  yamt sync with head.
 1.27.2.2 30-Dec-2006  yamt sync with head.
 1.27.2.1 21-Jun-2006  yamt sync with head.
 1.28.22.2 10-Dec-2006  yamt sync with head.
 1.28.22.1 22-Oct-2006  yamt sync with head
 1.28.20.1 18-Nov-2006  ad Sync with head.
 1.30.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.30.4.2 24-Mar-2007  yamt sync with head.
 1.30.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.30.2.1 28-Aug-2007  liamjfoy Pull up following revision(s) (requested by martin in ticket #848):
sys/dev/pci/vga_pci.c: revision 1.33
Allow 64bit memory BARs if we are compiling on 64bit archs.
 1.31.6.1 29-Mar-2007  reinoud Pullup to -current
 1.31.4.1 11-Jul-2007  mjf Sync with head.
 1.31.2.2 09-Oct-2007  ad Sync with head.
 1.31.2.1 10-Apr-2007  ad Sync with head.
 1.32.8.6 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.32.8.5 01-Dec-2007  jmcneill Sync with HEAD.
 1.32.8.4 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.32.8.3 01-Oct-2007  joerg Extend device API by device_power_private and device_power_set_private.
The latter is a temporary mean until the pnp_register API itself is
overhault. This functions allow a generic power handler to store its
state independent of the driver.

Use this and revamp the PCI power handling. Pretty much all PCI devices
had power handlers that did the same thing, generalize this in
pci_generic_power_register/deregister and the handler. This interface
offers callbacks for the drivers to save and restore state on
transistions. After a long discussion with jmcneill@ it was considered
to be powerful enough until evidence is shown that devices can handle
D1/D2 with less code and higher speed than without the full
save/restore. The generic code is carefully written to handle device
without PCI-PM support and ensure that the correct registers are written
to when D3 loses all state.

Reimplement the generic PCI network device handling on
top of PCI generic power handling.

Introduce pci_disable_retry as used and implemented locally at least by
ath(4) and iwi(4). Use it in this drivers to restore behaviour from
before the introduction of generic PCI network handling.

Convert all PCI drivers that were using pnp_register to the new
framework. The only exception is vga(4) as it is commonly used as
console device. Add a note therein that this should be fixed later.
 1.32.8.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.32.8.1 03-Aug-2007  jmcneill Pull in power management changes from private branch.
 1.32.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.33.8.3 18-Feb-2008  mjf Sync with HEAD.
 1.33.8.2 27-Dec-2007  mjf Sync with HEAD.
 1.33.8.1 08-Dec-2007  mjf Sync with HEAD.
 1.33.2.2 23-Mar-2008  matt sync with HEAD
 1.33.2.1 09-Jan-2008  matt sync with HEAD
 1.36.4.1 11-Dec-2007  yamt sync with head.
 1.36.2.1 26-Dec-2007  ad Sync with head.
 1.37.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.38.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.38.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.38.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.38.2.1 24-Mar-2008  keiichi sync with head.
 1.40.4.5 11-Mar-2010  yamt sync with head
 1.40.4.4 19-Aug-2009  yamt sync with head.
 1.40.4.3 16-May-2009  yamt sync with head
 1.40.4.2 04-May-2009  yamt sync with head.
 1.40.4.1 16-May-2008  yamt sync with head.
 1.40.2.2 04-Jun-2008  yamt sync with head
 1.40.2.1 18-May-2008  yamt sync with head.
 1.41.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.41.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.42.4.1 19-Oct-2008  haad Sync with HEAD.
 1.44.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.48.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.49.2.1 05-Mar-2011  rmind sync with head
 1.52.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.52.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.53.8.1 18-Feb-2012  mrg merge to -current.
 1.53.4.1 17-Apr-2012  yamt sync with head
 1.54.24.1 09-Jul-2016  skrll Sync with HEAD
 1.54.6.1 03-Dec-2017  jdolecek update from HEAD
 1.56.4.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.57.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 20-Mar-2007  drochner Import DRM drivers, brought into shape by Yorick Hardy, posted to tech-x11.
Minor modifications by me:
-use an mi device major number
-(coarsly) divided into pci card specific and less specific parts, moved
the latter to dev/drm
-renamed autoconf attributes to reflect this
Todo:
-adapt all card frontends but i915 to drm include file location
-review the mtrr change
-make the change to agp_i810.c coexist with the fix for buggy VESA
BIOSes which is commented out temporarily
-RCS IDs etc style stuff
-LKM support (rescan support for vga)
-test
 1.4 11-Dec-2005  christos branches: 1.4.26; 1.4.30; 1.4.32; 1.4.34;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 04-Feb-2005  perry de-__P
 1.1 22-Mar-1998  drochner branches: 1.1.48; 1.1.56; 1.1.58;
PCI frontend for sys/dev/ic/vga.c
 1.1.58.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.58.1 12-Feb-2005  yamt sync with head.
 1.1.56.1 29-Apr-2005  kent sync with -current
 1.1.48.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.48.1 04-Feb-2005  skrll Sync with HEAD.
 1.3.4.1 03-Sep-2007  yamt sync with head.
 1.4.34.1 29-Mar-2007  reinoud Pullup to -current
 1.4.32.1 11-Jul-2007  mjf Sync with head.
 1.4.30.1 10-Apr-2007  ad Sync with head.
 1.4.26.1 24-Mar-2007  yamt sync with head.
 1.34 04-Mar-2018  jdolecek according to VT82C686A chip specs, the VIA Technologies device 0x3057
is more a Power Management controller, rename the pcidevs entry and device
macro

PR kern/31963 by Nicolas Joly
 1.33 11-Aug-2014  ozaki-r Add missing curly braces

It unbreaks the i386 build of ALL.
 1.32 10-Aug-2014  tls Merge tls-earlyentropy branch into HEAD.
 1.31 20-Jun-2011  pgoyette branches: 1.31.12; 1.31.26;
Initialize sensors states before registering.
 1.30 10-Dec-2010  phx branches: 1.30.6;
Initialize sc_iot early enough to avoid a crash when the hardware monitor
function was found disabled.
 1.29 30-Apr-2008  ad branches: 1.29.22;
Make various bits of debug code compile again.
 1.28 10-Apr-2008  cegger branches: 1.28.2; 1.28.4;
use aprint_*_dev and device_xname
 1.27 05-Mar-2008  xtraeme Split device_t/softc and other related cosmetic changes.
 1.26 19-Nov-2007  njoly branches: 1.26.10; 1.26.14;
Do sensors inits before trying to attach them on the sysmon_envsys
device.
 1.25 16-Nov-2007  xtraeme Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.24 19-Oct-2007  ad branches: 1.24.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.23 26-Aug-2007  xtraeme branches: 1.23.2; 1.23.6;
There's no need to add timecounter code inside of __HAVE_TIMECOUNTER
ifdefs.
 1.22 01-Jul-2007  xtraeme branches: 1.22.2; 1.22.6;
In the gtredata function, use the edata pointer rather than using
directly the edata array index in the softc.
 1.21 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.20 18-Feb-2007  xtraeme branches: 1.20.4; 1.20.6;
There's no need to use a simple_lock here, ok ad@.
 1.19 16-Feb-2007  njoly branches: 1.19.2;
Fix incorrect voltage sensors range. It was using 7 numbers, where the
driver support only 5 voltage sensors.

ok by xtraeme
 1.18 20-Jan-2007  xtraeme Updated viaenv(4) driver:

* Support for the VIA VT8231 Hardware monitor.
* Power Management Timer available for timecounters in both
VT86C686A and VT8231 (code simplified thanks to dev/ic/acpipmtimer).
* Remove viapm(4) code and manpage (which was a link to viaenv.4 anyway).

From OpenBSD, tested by some users.
 1.17 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.16 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.15 29-Jul-2006  riz branches: 1.15.4; 1.15.6;
Correct an error introduced in rev 1.3; if there are no sensors of a
given type, this is indicated by "low" > "high" in the envsys_range
struct - the comments (and revision 1.2 of this file) indicate there are
no sensors of type ENVSYS_SVOLTS_AC, so fix viaenv_ranges[] to agree
with this.
 1.14 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.14;
merge ktrace-lwp.
 1.12 23-Oct-2005  jmcneill If the temperature sensors are disabled, enable them rather than giving up.
 1.11 28-Jun-2005  thorpej branches: 1.11.2; 1.11.4;
Use ANSI function decls and static.
 1.10 27-Feb-2005  perry nuke trailing whitespace
 1.9 02-Oct-2002  thorpej branches: 1.9.6; 1.9.14; 1.9.16;
Add trailing ; to CFATTACH_DECL.
 1.8 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.7 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.6 25-Mar-2002  thorpej There is no need to use a kthread to read the VIA environment
sensors.
 1.5 13-Nov-2001  lukem add RCSID
 1.4 27-Aug-2001  ad Use PWAIT for the lock, not 0.
 1.3 24-Jun-2000  thorpej branches: 1.3.2; 1.3.4; 1.3.6;
Add a clearing-house pseudo-device for system monitoring devices
such as the LM78 and VT82C686A (and eventually ACPI). Multiple
sensor devices can be hooked registered with `sysmon', and eventually
sysmon will also handle hardware (and software) watchdog timers.

Convert the `lm' and `viaenv' drivers to the new interface.
 1.2 12-May-2000  thorpej branches: 1.2.4;
Apply indent(1).
 1.1 08-May-2000  joda VIA VT82C686A hardware monitor
 1.2.4.2 30-Sep-2001  he Pull up revision 1.4 (requested by ad):
Use PWAIT for the lock, not 0.
 1.2.4.1 30-Jul-2000  bouyer Pull up (requested by thorpej):
lm_pnpbios.c 1.2->1.3
files 1.374->1.375
nslm7x.c 1.3->1.4
nslm7xvar.h 1.2->1.3
lm_isa.c 1.2->1.3
files.pci 1.96->1.97
viaenv.c 1.2->1.3
sysmon.c 1.1
sysmonvar.h 1.1

Add a clearing-house pseudo-device for system monitoring devices
such as the LM78 and VT82C686A (and eventually ACPI). Multiple
sensor devices can be hooked registered with `sysmon', and eventually
sysmon will also handle hardware (and software) watchdog timers.

Convert the `lm' and `viaenv' drivers to the new interface.
 1.3.6.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.6.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.6.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.3.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.3.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.4.1 21-Sep-2001  nathanw Catch up to -current.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 24-Jun-2000  bouyer file viaenv.c was added on branch thorpej_scsipi on 2000-11-20 11:42:39 +0000
 1.9.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.14.1 29-Apr-2005  kent sync with -current
 1.9.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.6.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.4.1 26-Oct-2005  yamt sync with head
 1.11.2.7 17-Mar-2008  yamt sync with head.
 1.11.2.6 07-Dec-2007  yamt sync with head
 1.11.2.5 27-Oct-2007  yamt sync with head.
 1.11.2.4 03-Sep-2007  yamt sync with head.
 1.11.2.3 26-Feb-2007  yamt sync with head.
 1.11.2.2 30-Dec-2006  yamt sync with head.
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.13.14.1 19-Jun-2006  chap Sync with head.
 1.13.8.2 11-Aug-2006  yamt sync with head
 1.13.8.1 26-Jun-2006  yamt sync with head.
 1.13.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.15.6.2 10-Dec-2006  yamt sync with head.
 1.15.6.1 22-Oct-2006  yamt sync with head
 1.15.4.2 01-Feb-2007  ad Sync with head.
 1.15.4.1 18-Nov-2006  ad Sync with head.
 1.19.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.20.6.1 11-Jul-2007  mjf Sync with head.
 1.20.4.3 23-Oct-2007  ad Sync with head.
 1.20.4.2 09-Oct-2007  ad Sync with head.
 1.20.4.1 15-Jul-2007  ad Sync with head.
 1.22.6.3 21-Nov-2007  joerg Sync with HEAD.
 1.22.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.22.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.23.6.3 21-Nov-2007  bouyer Sync with HEAD
 1.23.6.2 18-Nov-2007  bouyer Sync with HEAD
 1.23.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.2.3 23-Mar-2008  matt sync with HEAD
 1.23.2.2 09-Jan-2008  matt sync with HEAD
 1.23.2.1 06-Nov-2007  matt sync with HEAD
 1.24.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.24.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.26.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.26.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.10.1 24-Mar-2008  keiichi sync with head.
 1.28.4.1 16-May-2008  yamt sync with head.
 1.28.2.1 18-May-2008  yamt sync with head.
 1.29.22.1 05-Mar-2011  rmind sync with head
 1.30.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.31.26.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.31.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.105 17-Oct-2025  andvar viaide(4): add UDMA support for VT8233C IDE controller.

The VT8233C is another obscure VIA southbridge and appears to be a variant of the
VT8233 rather than the VT8233A (which supports ATA133). The C variant was paired with
a 3Com network controller instead of VIA’s own NIC. Detect the ISA–PCI bridge and
enable UDMA100 capability for improved IDE performance.

Update the viaide(4) man page and refine the list of supported VIA controllers.
 1.104 04-Oct-2025  thorpej Use device_getprop_bool() for "use-compat-native-irq".
 1.103 01-Jun-2025  andvar branches: 1.103.2;
viaide(4): give a bit more context on why ISA bridge is used to identify VIA
IDE controllers. NFCI.
 1.102 01-Jun-2025  andvar viaide(4): explicitly enable channels for VT6410 add-in cards.

VT6410 and VT6415 have different reasons for "missing" enable bits.

VT6410 uses the standard 0x40 offset for channel enable bits, but some add-in
cards have both channels disabled by default. This requires explicitly
writing the enable bits; otherwise, devices will not be detected. The same
bug is present in Linux and OpenBSD, where the bits are also simulated.
It was reported in Linux but closed as no-fix due to an unidentified root cause.

VT6415 returns 0 at offsets 0x40-0x43 and likely uses a different location
for its single channel enable bit, or it may not expose it at all. Until
the correct offset is identified (if ever), the driver must simulate the
enable bits.
 1.101 31-May-2025  andvar viaide(4): use via_chip_map() to attach VT8261 SATA controller in RAID mode.

Similarly to VT8251 and CX700, VT8261 has two ports per channel, while
via_sata_chip_map supports only one drive per channel. This caused disks on
secondary ports (2, 4) to not be detected, which is addressed by this change.
 1.100 09-May-2025  andvar remove leading tab in the empty line. NFCI.
 1.99 20-Apr-2025  andvar viaide(4): use __func__ in via_setup_channel() ATADEBUG_PRINT message.
Fixes function name in debug message, otherwise NFCI.
 1.98 20-Apr-2025  andvar viaide(4): check if chip enable register returns 0 before emulating enable
bits.

At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
 1.97 20-Apr-2025  andvar viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.

Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).

Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.

Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.

For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html

Should fix and close PR kern/37517.

Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.

Reviewed by bad.
 1.96 05-Apr-2025  andvar viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.

The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.

Tested on ECS VX900-I.

Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
 1.95 03-Apr-2025  andvar viaide(4): Add support for VIA VT6415/VT6330 single-channel IDE controllers.

Beyond adding the usual identification code, several adjustments were required:

1) Introduced 'single_channel` to set 'nchannels` to 1 for this controller.

2) Added 'APO_IDECONF_ALWAYS_EN` definition and the 'no_ideconf` flag to mimic
enabled channel bits, as this controller's enable chip register is unset.
Applied the same to VT6410, following OpenBSD and Linux, since some
controllers are known to not set this register as well.

3) Combined all VIA controllers identified by PCI ID (not ISA bus) using switch
fallthrough, as they currently share the same UDMA setting. Consequently,
the VX900 name printing was moved to the device description and adjusted
to better reflect the device.

4) Moved setting interface bits for RAID controllers under the RAID capability
check, enabling the above fallthrough and paving the way for support of other
RAID-capable controllers in upcoming changes.

5) The VT6330 is a combo FireWire/IDE controller. Added its FireWire controller
PCI ID to pcidevs.

Tested on ASRock P5B-DE.

Reviewed by jak and bad.

Addresses PR kern/45917
 1.94 16-Mar-2025  andvar viaide(4): add IDE controller identification by the VT8237S ISA bridge.

The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.

Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

Pullups to netbsd-9 and netbsd-10 are needed.
 1.93 11-Mar-2025  andvar viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.

This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.

The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

Worth pulling up to netbsd-9, 10.
 1.92 03-Mar-2025  andvar viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.

Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.

via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.

Fixes PR kern/59010.

Pull-ups to netbsd-9, 10 are needed.

Reviewed and approved by jakllsch@.
 1.91 23-Jan-2025  andvar viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaur's demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.
 1.90 17-Oct-2024  andvar Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
 1.89 02-Jun-2019  jdolecek branches: 1.89.2; 1.89.28; 1.89.34;
updated patch from Andrius - update the chip map for CX700 to use
via_sata_chip_map_new, this seems to eliminate the ghost non-existing viaide1

XXX guess should use via_sata_chip_map_new for PCI_PRODUCT_VIATECH_CX700M2_IDE
XXX too, but this needs test on real hw

remove again the entries for VX800 and VX855 from pciide_via_products[],
as that part is untested with real hw

update for PR kern/43309
 1.88 01-Jun-2019  jdolecek match VIA Technologies VX800, VX855, and VT8237S in RAID mode

patch provided and testing done by Andrius Varanavicius via PR kern/43309
 1.87 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.86 20-Oct-2017  jdolecek branches: 1.86.2; 1.86.4;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.85 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.84 29-Mar-2014  christos branches: 1.84.18;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.83 31-Jul-2012  bouyer branches: 1.83.2; 1.83.4;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.82 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.81 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.80 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.79 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.78 18-Mar-2012  tsutsui Add UDMA support for VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.

This should be pulled up to netbsd-6, since ZOTAC ZBOX nano VD01
http://www.zotacusa.com/zbox-nano-vd01.html
exhibited at NetBSD booth in Open Source Conference 2012 Tokyo Spring
was favored by many people.
 1.77 28-Dec-2011  phx branches: 1.77.2;
Add VT6410 support, heavily based on a patch by Takahiro Kambe:
http://mail-index.netbsd.org/port-i386/2007/03/30/0000.html
The VT6410 is special, because it may exist without a VIA PCI-ISA bridge.
 1.76 10-Jul-2011  jakllsch branches: 1.76.2; 1.76.6;
Add complete support for all channels on VT6421A SATA/PATA controller to
viaide(4).
 1.75 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.74 10-May-2011  dyoung Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags
specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device." Only bus drivers have any business
modifying these.
 1.73 10-Apr-2011  jakllsch Fix regression introduced in 1.72.
(Attach arguments need to be copied before using the copy.)
 1.72 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.71 06-Nov-2010  jakllsch branches: 1.71.2;
Enable detachment.

Tested on nForce 4 IDE (compatiblity mapped) and SATA (native mapped).
 1.70 05-Nov-2010  jakllsch Pave the way for detachment of pciide(4)-family ATA controllers.
 1.69 22-Mar-2010  dyoung Activate PCI memory-mapped I/O access in the PCI Control and Status
Register if the PCI BAR is the memory-mapped type. The driver used to
decide whether to activate memory-mapped access by testing the truth of
pci_attach_args.pa_memt; that isn't MI, and it doesn't make sense.
 1.68 24-Feb-2010  dyoung branches: 1.68.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.67 08-Jan-2010  dyoung branches: 1.67.2;
Expand PMF_FN_* macros.
 1.66 23-Dec-2009  mrg enable mem space if it isn't already enabled. several bioses leave
this not enabled, and viaide kind of depends upon it.

fixes viaide(4) on several machines.

idea from PR 38011, but reworked a little.
 1.65 22-Dec-2009  tsutsui Don't forget to initialize data32iot and data32ioh in via_sata_chip_map_new().
This makes 32bit UDMA xfer work properly on VIA VT6421.
 1.64 21-Nov-2009  jakllsch Fix matching of CX700. Should address PR/39063.

Also,

Change bus_space_subregion() size for each SATA PHY register from 1 to 4,
as we do a bus_space_read_4() within these subregions.

Use PCI_MAPREG_START where appropriate.
 1.63 20-Nov-2009  jakllsch Switch VT8237R SATA to via_sata_chip_map_7(). via_sata_chip_map_7()
works fine and is consistent with the other VIA SATA controllers.

Tested on VT8237R+.

(Somewhat amazing that via_sata_chip_map_0() worked at all for the
second port.)
 1.62 18-Nov-2009  jakllsch Match VT8251 IDE controller and enable UDMA Mode 6 thereon.
Should fix PATA speed issue in PR/37517.
Due to lack of hardware, only compile tested at this point.
 1.61 19-Oct-2009  bouyer Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.60 26-Sep-2009  jmcneill Add PCI_PRODUCT_VIATECH_VT8237A_SATA_2 to list of product IDs.
 1.59 23-Aug-2009  jmcneill s/Advanced Micro Devices/AMD/ for device descriptions.
 1.58 21-Dec-2008  nonaka Add VT8237S Integrated SATA Controller support.
 1.57 06-Sep-2008  rmind branches: 1.57.2; 1.57.4; 1.57.10;
PR/39119: Jan Thorsson: Support for VIA CX700M2 IDE controller.
 1.56 17-Jun-2008  phx branches: 1.56.2;
Renamed via_pegasos_mapregs_native to via_mapregs_compat_native, after
discussion with simonb. There may be other architectures who want to use
this function.
 1.55 15-Jun-2008  phx Fixed system lockup in native mode with compat irq 14/15, which can be selected
with the use-compat-native-irq property. It was caused by handling irqs from
both channels at once with the wrong interrupt handler routine
(pciide_pci_intr). Now pciide_compat_intr is installed for each channel.
Also renamed the function to via_pegasos_mapregs_native(), which seems more
appropriate.
 1.54 14-May-2008  dholland branches: 1.54.2;
fix typo in error message
 1.53 18-Mar-2008  cube branches: 1.53.2; 1.53.4; 1.53.6;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.52 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.51 18-Jan-2008  joerg branches: 1.51.2; 1.51.6;
Add power management support. Untested due to lack of feedback.
 1.50 20-Dec-2007  phx VT8231 IDE workaround for native mode with "compatibility" interrupts 14/15.
This time done right by calling pciide_machdep_compat_intr_establish() to
get a MD interrupt handler.
Verified that it compiles for XEN again.
 1.49 17-Dec-2007  phx xen did no longer build.
Temporarily reverted to 1.47. Will need some time to find a good solution.
 1.48 16-Dec-2007  phx At least under certain (mis)configurations (e.g. on the "Pegasos" board)
the VT8231-IDE's native mode only works with irq 14/15, and cannot be
programmed to use a single native PCI irq alone. So we install an interrupt
handler for each channel, as in compatibility mode.
This behaviour has to be activated by the "use-compat-native-irq" property,
otherwise the driver works as before.
 1.47 14-Nov-2007  xtraeme branches: 1.47.2; 1.47.6;
emo-style: forgot to update the switch for MCP7[13] IDE.
 1.46 14-Nov-2007  xtraeme Attach to the NVIDIA MCP7[37] IDE Controllers.
 1.45 04-Oct-2007  xtraeme branches: 1.45.2; 1.45.4;
AMD CS5536 Companion Device is able to work in Ultra DMA Mode 5,
patch from Andreas Wrede in PR kern/37059.
 1.44 31-Aug-2007  xtraeme branches: 1.44.2;
Use a different case for the CX700 IDE Controller to print the
attach message and when setting the UDMA mode.
 1.43 31-Aug-2007  xtraeme - Proper VIA CX700 IDE Controller support (missed in previous).
- Attach to the NVIDIA MCP67 IDE and SATA controllers.
 1.42 31-Aug-2007  xtraeme Attach to the VIA CX700 IDE Controller.
 1.41 27-Mar-2007  garbled branches: 1.41.4; 1.41.8; 1.41.10;
The VT8237A SATA Controller uses chip_map_7, not 0, tested and confirmed
working on my machine. Also when a via controller is set to RAID mode,
it sets the pci_subclass to raid. Notice this and set ATAC_CAP_RAID.
 1.40 10-Feb-2007  mlelstv branches: 1.40.2; 1.40.6; 1.40.8; 1.40.10;
Add support for VT8237A/VT82C586A PCI-ISA-Bridge
Fixes PR kern/35314
 1.39 09-Feb-2007  ad Merge newlock2 to head.
 1.38 21-Jan-2007  isaki Add support for CS5536.
Reviewed by tsutsui@ on port-i386.
 1.37 16-Nov-2006  christos branches: 1.37.2;
__unused removal on arguments; approved by core.
 1.36 12-Nov-2006  bouyer Properly detect if BAR5 is IO or MEM type; avoid a message about not being
able to map the BAR on boot (note that it's just cosmetic, the registers were
mapped anyway). Tested by paul at whooppee.com; thanks !
 1.35 27-Oct-2006  bouyer Add SATA native registers support for VIA SATA controllers, so that
drives are probed using the SATA way (from FreeBSD). While here add the
VT8237A SATA Controller to the tables, should fix PR kern/34927.

Thanks to the C�sar Catri�n Carre�o and paul (at) whooppee.com for
tests.
 1.34 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.33 03-Sep-2006  xtraeme branches: 1.33.2; 1.33.4;
Add support for nvidia MCP61/65 IDE/SATA Controllers.
 1.32 01-Aug-2006  xtraeme branches: 1.32.2;
Match nForce3 250 SATA2.
 1.31 17-Jun-2006  xtraeme s/SATA/Serial ATA/
 1.30 17-Jun-2006  xtraeme Enable support for NVIDIA MCP04 and MCP55 IDE/SATA Controllers, tested
by rillig with MCP55.
 1.29 30-Apr-2006  xtraeme branches: 1.29.2; 1.29.4;
PR port-amd64/33393: viaide driver patch for VT8237R SATA.
 1.28 31-Jan-2006  xtraeme branches: 1.28.2; 1.28.4; 1.28.6; 1.28.8; 1.28.10;
The NVidia nForce430 IDE Controller supports Ultra-DMA Mode 6, enable it.
Patch from MASUDA Hideo via tech-kern.
 1.27 02-Jan-2006  manu Add support for nForce430 ATA133 and SATA controllers. My disks now run
at a decent speed.
 1.26 11-Dec-2005  christos branches: 1.26.2;
merge ktrace-lwp.
 1.25 24-May-2005  lukem branches: 1.25.2;
add __KERNEL_RCSID
 1.24 27-Feb-2005  perry branches: 1.24.2;
nuke trailing whitespace
 1.23 02-Feb-2005  abs Reminder not to trust cheap no-name packaging. VIA product 0x3249 is
a VT642*1* not VT642. Also add to list in viaide manpage and note
that drives need to be configured into RAID/JOBS sets via its BIOS.
http://www.via.com.tw/en/products/peripherals/serial-ata_raid/vt6421/
 1.22 01-Feb-2005  abs Add 'VT642 SATA RAID Controller'. It looks like a viaide, it smells
like a viaide... but you can only address the drives once you have
put two or more of them into a RAID or JBOD.
 1.21 27-Jan-2005  kent support for nForce 4 PATA and SATA
 1.20 13-Jan-2005  jdolecek branches: 1.20.2; 1.20.4;
match NVIDIA nForce2 Ultra 400 IDE and Serial ATA controller; only the IDE
controller actually tested
 1.19 06-Nov-2004  xtraeme Add support for:

NVIDIA nForce3 250 IDE Controller
NVIDIA nForce3 250 Serial ATA Controller

From Kouichirou Hiratsuka in PR 27843, ok'ed christos@
 1.18 21-Aug-2004  thorpej atastart() (called only at splbio(), and from interrupts) can change
drive_flags, to make sure all drive_flags manipulations are done at
splbio().
 1.17 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.16 19-Aug-2004  thorpej - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
ata_channel. (This one just hides a cast, and is really just for
consistency with the others.)
 1.15 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.14 13-Aug-2004  thorpej WDCDEBUG -> ATADEBUG.
 1.13 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.12 22-Jul-2004  drochner branches: 1.12.2;
Replace the hooribly overloaded use of pci_enumerate_bus() - to find out
the chipset revision - by pci_find_device().
While the latter isn't better technically (works around the otherwise
hierarchical device tree), using it doesn't require PCI configuration
functions to support stuff which philosophically doesn't belong there.
So we get the hands free to restructure things for better loadable
driver support.
(Actually, since this is about chipset internal IDE interfaces where
the PCI device/function numbers are well known, this all is unnecessary.)
 1.11 10-Mar-2004  bouyer branches: 1.11.4;
Enable ATA-133 for AMD8111. From Nicolas Joly in kern/24729.
pciide_apollo_reg.h already contains the Ultra133 timming values for amd.
 1.10 20-Feb-2004  fvdl Actually match the nforce3 as well..
 1.9 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.8 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.7 27-Nov-2003  fvdl There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

bus_space_write_4(tag, handle, offset, value)

becomes

bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
 1.6 24-Oct-2003  mycroft Remove IDE_PCI_CLASS_OVERRIDE -- it wasn't actually used anywhere. In lieu of
it, add a class/subclass check to drivers that do not (appear) to have a unique
ID for the IDE controller. This includes aceride, cypide and optiide.
 1.5 23-Oct-2003  fvdl * match the nForce3 controller
* search the whole current PCI bus for the VIA bridge, can't rely on
it to be function 0 of the same device
 1.4 18-Oct-2003  enami Factor out common code.
 1.3 18-Oct-2003  enami Whitespace nits.
 1.2 11-Oct-2003  thorpej Cosmetic changes:
- Use static to unexport symbols that don't need to be exported.
- ANSI'ify.
- Some whitespace nits.
 1.1 08-Oct-2003  bouyer Split pciide in per-chip family driver, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0007.html
We now have:
acardide* at pci? dev ? function ? # Acard IDE controllers
aceride* at pci? dev ? function ? # Acer Lab IDE controllers
cmdide* at pci? dev ? function ? # CMD tech IDE controllers
cypide* at pci? dev ? function ? # Cypress IDE controllers
hptide* at pci? dev ? function ? # Triones/HighPoint IDE controllers
optiide* at pci? dev ? function ? # Opti IDE controllers
piixide* at pci? dev ? function ? # Intel IDE controllers
pdcide* at pci? dev ? function ? # Promise IDE controllers
siside* at pci? dev ? function ? # SiS IDE controllers
slide* at pci? dev ? function ? # Symphony Labs IDE controllers
viaide* at pci? dev ? function ? # VIA/AMD/Nvidia IDE controllers
pciide* at pci? dev ? function ? flags 0x0000 # GENERIC pciide driver

serverworks driver not commited yet; there are still copyright issues about
it.
 1.11.4.2 05-May-2005  riz Pull up revision 1.22-1.23 (requested by abs in ticket #1153):
Add 'VT642 SATA RAID Controller'. It looks like a viaide, it smells
like a viaide... but you can only address the drives once you have
put two or more of them into a RAID or JBOD.
 1.11.4.1 07-Apr-2005  tron Pull up revision 1.19 via patch (requested by hira in ticket #1103):
Add support for:
NVIDIA nForce3 250 IDE Controller
NVIDIA nForce3 250 Serial ATA Controller
From Kouichirou Hiratsuka in PR 27843, ok'ed christos@
 1.12.2.10 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.12.2.8 04-Feb-2005  skrll Sync with HEAD.
 1.12.2.7 17-Jan-2005  skrll Sync with HEAD.
 1.12.2.6 14-Nov-2004  skrll Sync with HEAD.
 1.12.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.12.2.2 03-Aug-2004  skrll Sync with HEAD
 1.12.2.1 22-Jul-2004  skrll file viaide.c was added on branch ktrace-lwp on 2004-08-03 10:49:12 +0000
 1.20.4.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.4.1 12-Feb-2005  yamt sync with head.
 1.20.2.1 29-Apr-2005  kent sync with -current
 1.24.2.4 03-Aug-2006  tron Pull up following revision(s) (requested by xtraeme in ticket #1446):
sys/dev/pci/viaide.c: revision 1.32
Match nForce3 250 SATA2.
 1.24.2.3 30-Apr-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #1295):
sys/dev/pci/pcidevs: revision 1.785
sys/dev/pci/viaide.c: revision 1.29
PR port-amd64/33393: viaide driver patch for VT8237R SATA.
 1.24.2.2 01-Feb-2006  tron Pull up following revision(s) (requested by xtraeme in ticket #1149):
sys/dev/pci/viaide.c: revision 1.28
The NVidia nForce430 IDE Controller supports Ultra-DMA Mode 6, enable
it. Patch from MASUDA Hideo via tech-kern.
 1.24.2.1 05-Jan-2006  riz Pull up following revision(s) (requested by manu in ticket #1086):
sys/dev/pci/pcidevs: revision 1.755
sys/dev/pci/viaide.c: revision 1.27
Add support for nForce430 ATA133 and SATA controllers. My disks now run
at a decent speed.
 1.25.2.9 24-Mar-2008  yamt sync with head.
 1.25.2.8 17-Mar-2008  yamt sync with head.
 1.25.2.7 21-Jan-2008  yamt sync with head
 1.25.2.6 15-Nov-2007  yamt sync with head.
 1.25.2.5 27-Oct-2007  yamt sync with head.
 1.25.2.4 03-Sep-2007  yamt sync with head.
 1.25.2.3 26-Feb-2007  yamt sync with head.
 1.25.2.2 30-Dec-2006  yamt sync with head.
 1.25.2.1 21-Jun-2006  yamt sync with head.
 1.26.2.2 01-Feb-2006  yamt sync with head.
 1.26.2.1 15-Jan-2006  yamt sync with head.
 1.28.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.28.8.1 11-May-2006  elad sync with head
 1.28.6.4 03-Sep-2006  yamt sync with head.
 1.28.6.3 11-Aug-2006  yamt sync with head
 1.28.6.2 26-Jun-2006  yamt sync with head.
 1.28.6.1 24-May-2006  yamt sync with head.
 1.28.4.1 01-Jun-2006  kardel Sync with head.
 1.28.2.1 09-Sep-2006  rpaulo sync with head
 1.29.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.29.2.1 19-Jun-2006  chap Sync with head.
 1.32.2.1 07-Sep-2006  riz Pull up following revision(s) (requested by xtraeme in ticket #113):
sys/dev/pci/viaide.c: revision 1.33
share/man/man4/viaide.4: revision 1.7
sys/dev/pci/pcidevs: revision 1.825
sys/dev/pci/pcidevs: revision 1.826
- Add all pciids for nvidia MCP61/65 controllers, from obsd.
- Improve description in all them.
Erm forgot to add MCP61/65 SATA Controllers and sort them.
Add support for nvidia MCP61/65 IDE/SATA Controllers.
Mention MCP61/65... and bump date.
 1.33.4.2 10-Dec-2006  yamt sync with head.
 1.33.4.1 22-Oct-2006  yamt sync with head
 1.33.2.3 06-Feb-2007  ad Quiten noisy boot messages.
 1.33.2.2 01-Feb-2007  ad Sync with head.
 1.33.2.1 18-Nov-2006  ad Sync with head.
 1.37.2.4 11-Oct-2007  pavel Pull up following revision(s) (requested by xtraeme in ticket #922):
sys/dev/pci/viaide.c: revision 1.45
AMD CS5536 Companion Device is able to work in Ultra DMA Mode 5,
patch from Andreas Wrede in PR kern/37059.
 1.37.2.3 10-Jun-2007  bouyer Pull up following revision(s) (requested by hira in ticket #713):
sys/dev/pci/pcidevs: revision 1.863
sys/dev/pci/viaide.c: revision 1.38
share/man/man4/viaide.4: revision 1.8
Add PCI Ids for AMD Geode LX and CS5536.
Add support for CS5536 IDE.
 1.37.2.2 31-Mar-2007  bouyer branches: 1.37.2.2.2;
Pull up following revision(s) (requested by garbled in ticket #541):
sys/dev/pci/viaide.c: revision 1.41 via patch
The VT8237A SATA Controller uses chip_map_7, not 0, tested and confirmed
working on my machine. Also when a via controller is set to RAID mode,
it sets the pci_subclass to raid. Notice this and set ATAC_CAP_RAID.
 1.37.2.1 17-Feb-2007  tron Pull up following revision(s) (requested by mlelstv in ticket #449):
sys/dev/pci/pcidevs: revision 1.867
sys/dev/pci/viaide.c: revision 1.40
Add support for VT8237A/VT82C586A PCI-ISA-Bridge
Fixes PR kern/35314
 1.37.2.2.2.2 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.37.2.2.2.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.40.10.1 29-Mar-2007  reinoud Pullup to -current
 1.40.8.1 11-Jul-2007  mjf Sync with head.
 1.40.6.2 09-Oct-2007  ad Sync with head.
 1.40.6.1 10-Apr-2007  ad Sync with head.
 1.40.2.1 15-Apr-2007  yamt sync with head.
 1.41.10.3 23-Mar-2008  matt sync with HEAD
 1.41.10.2 09-Jan-2008  matt sync with HEAD
 1.41.10.1 06-Nov-2007  matt sync with HEAD
 1.41.8.3 14-Nov-2007  joerg Sync with HEAD.
 1.41.8.2 04-Oct-2007  joerg Sync with HEAD.
 1.41.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.41.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.44.2.1 06-Oct-2007  yamt sync with head.
 1.45.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.45.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.45.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.45.2.1 18-Nov-2007  bouyer Sync with HEAD
 1.47.6.2 19-Jan-2008  bouyer Sync with HEAD
 1.47.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.47.2.1 26-Dec-2007  ad Sync with head.
 1.51.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.51.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.51.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.51.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.51.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.51.2.1 24-Mar-2008  keiichi sync with head.
 1.53.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.53.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.53.4.5 11-Aug-2010  yamt sync with head.
 1.53.4.4 11-Mar-2010  yamt sync with head
 1.53.4.3 16-Sep-2009  yamt sync with head
 1.53.4.2 04-May-2009  yamt sync with head.
 1.53.4.1 16-May-2008  yamt sync with head.
 1.53.2.2 17-Jun-2008  yamt sync with head.
 1.53.2.1 18-May-2008  yamt sync with head.
 1.54.2.1 18-Jun-2008  simonb Sync with head.
 1.56.2.1 19-Oct-2008  haad Sync with HEAD.
 1.57.10.1 21-Apr-2010  matt sync to netbsd-5
 1.57.4.4 20-Jan-2013  bouyer Apply patch, requested by msaitoh in ticket #1842:
sys/dev/pci/pcidevs 1.969 via patch
sys/dev/pci/viaide.c 1.58

Add VT8237S Integrated SATA Controller support.
PR#47452.
 1.57.4.3 09-Jan-2010  snj Pull up following revision(s) (requested by mrg in ticket #1227):
sys/dev/pci/viaide.c: revision 1.66
enable mem space if it isn't already enabled. several bioses leave
this not enabled, and viaide kind of depends upon it.
fixes viaide(4) on several machines.
idea from PR 38011, but reworked a little.
 1.57.4.2 09-Jan-2010  snj Pull up following revision(s) (requested by tsutsui in ticket #1210):
sys/dev/pci/viaide.c: revision 1.65
Don't forget to initialize data32iot and data32ioh in via_sata_chip_map_new().
This makes 32bit UDMA xfer work properly on VIA VT6421.
 1.57.4.1 26-Sep-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #1021):
sys/dev/pci/viaide.c: revision 1.60
Add PCI_PRODUCT_VIATECH_VT8237A_SATA_2 to list of product IDs.
 1.57.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.67.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.67.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.68.2.4 31-May-2011  rmind sync with head
 1.68.2.3 21-Apr-2011  rmind sync with head
 1.68.2.2 05-Mar-2011  rmind sync with head
 1.68.2.1 30-May-2010  rmind sync with head
 1.71.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.76.6.2 05-Apr-2012  mrg sync to latest -current.
 1.76.6.1 18-Feb-2012  mrg merge to -current.
 1.76.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.76.2.2 30-Oct-2012  yamt sync with head
 1.76.2.1 17-Apr-2012  yamt sync with head
 1.77.2.1 03-Apr-2012  riz Pull up following revision(s) (requested by tsutsui in ticket #151):
sys/dev/pci/viaide.c: revision 1.78
sys/dev/pci/pcidevs: revision 1.1106
Add VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
Regen from pcidevs rev 1.1106:
Add VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
Add UDMA support for VIA VX900 media system processor IDE controller.
PR/46166 from Hiroshi Tokuda.
This should be pulled up to netbsd-6, since ZOTAC ZBOX nano VD01
http://www.zotacusa.com/zbox-nano-vd01.html
exhibited at NetBSD booth in Open Source Conference 2012 Tokyo Spring
was favored by many people.
 1.83.4.1 18-May-2014  rmind sync with head
 1.83.2.3 03-Dec-2017  jdolecek update from HEAD
 1.83.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.83.2.1 09-Oct-2012  bouyer Support transfers of up to MACHINE_MAXPHYS in all pciide variants, and ahci.
wd(4) limits its maxphys depending on the drives's capability (64k sectors
for LBA48, 256 sectors for LBA and 128 sectors for older devices).

I assumed all pciide controllers could do MACHINE_MAXPHYS transfers, but
this may not be true. The capabilities of each controller variants should be
looked at more closely.
 1.84.18.2 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.84.18.1 10-Apr-2017  jdolecek ATA infrastructure improvements to eventually support more outstanding
commands

patch by Matt Thomas
 1.86.4.1 10-Jun-2019  christos Sync with HEAD
 1.86.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.89.34.1 02-Aug-2025  perseant Sync with HEAD
 1.89.28.3 26-Oct-2025  martin Pull up following revision(s) (requested by andvar in ticket #1184):

share/man/man4/viaide.4: revision 1.13
sys/dev/pci/viaide.c: revision 1.105

viaide(4): add UDMA support for VT8233C IDE controller.

The VT8233C is another obscure VIA southbridge and appears to be a
variant of the
VT8233 rather than the VT8233A (which supports ATA133). The C variant
was paired with
a 3Com network controller instead of VIA's own NIC. Detect the ISA-PCI
bridge and
enable UDMA100 capability for improved IDE performance.

Update the viaide(4) man page and refine the list of supported VIA controllers.
 1.89.28.2 07-Jun-2025  martin Pull up following revision(s) (requested by andvar in ticket #1128):

sys/dev/pci/viaide.c: revision 1.101
sys/dev/pci/viaide.c: revision 1.102

viaide(4): use via_chip_map() to attach VT8261 SATA controller in RAID mode.

Similarly to VT8251 and CX700, VT8261 has two ports per channel, while
via_sata_chip_map supports only one drive per channel. This caused disks on
secondary ports (2, 4) to not be detected, which is addressed by this change.
viaide(4): explicitly enable channels for VT6410 add-in cards.

VT6410 and VT6415 have different reasons for "missing" enable bits.

VT6410 uses the standard 0x40 offset for channel enable bits, but some add-in
cards have both channels disabled by default. This requires explicitly
writing the enable bits; otherwise, devices will not be detected. The same
bug is present in Linux and OpenBSD, where the bits are also simulated.

It was reported in Linux but closed as no-fix due to an unidentified root cause.

VT6415 returns 0 at offsets 0x40-0x43 and likely uses a different location
for its single channel enable bit, or it may not expose it at all. Until
the correct offset is identified (if ever), the driver must simulate the
enable bits.
 1.89.28.1 09-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1101):

sys/dev/pci/viaide.c: revision 1.90
sys/dev/pci/ahcisata_pci.c: revision 1.72
sys/dev/pci/pciide_apollo_reg.h: revision 1.21
sys/dev/pci/viaide.c: revision 1.91
sys/dev/pci/viaide.c: revision 1.92
sys/dev/pci/viaide.c: revision 1.93
sys/dev/pci/viaide.c: revision 1.94
sys/dev/pci/viaide.c: revision 1.96
sys/dev/pci/viaide.c: revision 1.97
sys/dev/pci/viaide.c: revision 1.98
share/man/man4/viaide.4: revision 1.11
share/man/man4/viaide.4: revision 1.12

Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
Add VIA VT8261 southbridge SATA controller IDs and PCIB.
viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.
Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.
via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.
Fixes PR kern/59010.
Reviewed and approved by jakllsch@.

Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.
These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.
This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.
The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

viaide(4): add IDE controller identification by the VT8237S ISA bridge.
The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.
Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaurs demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.


viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.
The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.
Tested on ECS VX900-I.
Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.
Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).
Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.
Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.
For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html
Should fix and close PR kern/37517.
Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.
Reviewed by bad.
viaide(4): check if chip enable register returns 0 before emulating enable
bits.
At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
viaide(4): update the list of supported VIA controllers.
viaide(4): remove notes section about VT6421, it is not currently required to
setup RAID/JBOD sets to access drives.
 1.89.2.3 26-Oct-2025  martin Pull up following revision(s) (requested by andvar in ticket #1978):

share/man/man4/viaide.4: revision 1.13
sys/dev/pci/viaide.c: revision 1.105

viaide(4): add UDMA support for VT8233C IDE controller.

The VT8233C is another obscure VIA southbridge and appears to be a
variant of the
VT8233 rather than the VT8233A (which supports ATA133). The C variant
was paired with
a 3Com network controller instead of VIA's own NIC. Detect the ISA-PCI
bridge and
enable UDMA100 capability for improved IDE performance.

Update the viaide(4) man page and refine the list of supported VIA controllers.
 1.89.2.2 07-Jun-2025  martin Pull up following revision(s) (requested by andvar in ticket #1959):

sys/dev/pci/viaide.c: revision 1.101
sys/dev/pci/viaide.c: revision 1.102

viaide(4): use via_chip_map() to attach VT8261 SATA controller in RAID mode.

Similarly to VT8251 and CX700, VT8261 has two ports per channel, while
via_sata_chip_map supports only one drive per channel. This caused disks on
secondary ports (2, 4) to not be detected, which is addressed by this change.
viaide(4): explicitly enable channels for VT6410 add-in cards.

VT6410 and VT6415 have different reasons for "missing" enable bits.

VT6410 uses the standard 0x40 offset for channel enable bits, but some add-in
cards have both channels disabled by default. This requires explicitly
writing the enable bits; otherwise, devices will not be detected. The same
bug is present in Linux and OpenBSD, where the bits are also simulated.

It was reported in Linux but closed as no-fix due to an unidentified root cause.

VT6415 returns 0 at offsets 0x40-0x43 and likely uses a different location
for its single channel enable bit, or it may not expose it at all. Until
the correct offset is identified (if ever), the driver must simulate the
enable bits.
 1.89.2.1 09-May-2025  martin Pull up following revision(s) (requested by andvar in ticket #1944):

sys/dev/pci/viaide.c: revision 1.90
sys/dev/pci/ahcisata_pci.c: revision 1.72
sys/dev/pci/pciide_apollo_reg.h: revision 1.21
sys/dev/pci/viaide.c: revision 1.91
sys/dev/pci/viaide.c: revision 1.92
sys/dev/pci/viaide.c: revision 1.93
sys/dev/pci/viaide.c: revision 1.94
sys/dev/pci/viaide.c: revision 1.96
sys/dev/pci/viaide.c: revision 1.97
sys/dev/pci/viaide.c: revision 1.98
share/man/man4/viaide.4: revision 1.11
share/man/man4/viaide.4: revision 1.12

Use the chipset name to describe the IDE controller in order to avoid confusion.
VT800->VX800 and VT855->VX855.
Add VIA VT8261 southbridge SATA controller IDs and PCIB.
viaide(4): use via_chip_map() instead of via_sata_chip_map_new() to attach
CX700/VX800 IDE/SATA RAID controllers and set interface flags the same way as
the VT6410_RAID case for native interrupts required by RAID mode.
Device descriptions were moved to pciide_via_products and updated to cascade
VT6410_RAID and CX700_IDE options.
via_sata_chip_map_new previously worked more by "accident," as it did not
return early on failure to map SATA registers and defaulted to the generic
drive probe function. However, it failed to attach PATA drives (endless
timeouts) and incorrectly detected "three" channels as VT6421, despite the
controller having only two.
Fixes PR kern/59010.
Reviewed and approved by jakllsch@.

Update CX700_IDE and CX700M2_IDE descriptions to better reflect their actual
purpose.
These are not separate IDE controllers for CX700 and CX700M2 but rather the
IDE and RAID modes of the same controller in these chipsets (and few more).
viaide(4): check and add ATA RAID capability in via_sata_chip_map_new() used
by VT6241(A) RAID controller.
This is required for ataraid(4) to attach on this controller if RAID was
configured using its firwmare.
The conditions may be redundant for this controller, but it is uncertain what
variations exist in the wild.

viaide(4): add IDE controller identification by the VT8237S ISA bridge.
The controller's PATA interface uses PCI ID 0x0571, which is shared among
many VIA southbridges. The ISA bridge is used to identify capabilities,
including for the VT8237S.
Unknown PATA controllers disable UDMA by default. This change ensures PATA
drives attach at full speed.

viaide(4): Add support for VIA VT8261 IDE/SATA integrated controller.

The VT8261 southbridge, paired with the VN1000 chipset, is obscure and hard to
find. Besides some evaluation boards surfacing after Centaurs demise, at least
one rare production motherboard is known to exist.

Despite its rarity, the VT8261 is very similar to the VT8251. It uses separate
PCI IDs for PATA and SATA (IDE/RAID modes) with 4 SATA ports in total, 2 ports
sharing one channel, and maps registers through BAR5. This similarity made
adding basic support relatively simple (sharing same issues too).

Tested briefly on VIA VT8591B eval board.


viaide(4): Add RAID mode support for VIA VX900/VX11 SATA controllers.
The BIOS option to enable RAID is uncommon on systems using these chipsets;
however, at least two motherboards mention it in their manuals. The RAID
firmware does not provide management features, but it can recognize and boot
from preconfigured VIA RAID arrays.
Tested on ECS VX900-I.
Also add the VX11 chipset to the controller name, as it shares the same PCI ID.
viaide(4): Improve VT8251 integrated SATA controller support in IDE/RAID modes.
Use via_chip_map() to attach this controller in IDE and RAID modes, similarly
to VX800. This allows drives to be identified and attached successfully on all
four ports (two channels with master/slave ports).
Switch channel setup to sata_setup_channel(), replacing via_setup_channel().
This avoids writes to the 0x50 register, which is only relevant for IDE
controllers. Writes to SATA controller registers caused drives on the IDE
controller (0x0571) to fail to attach. Apply this fix also to VX900 and VT8261.
Rename VT8237R_SATA to VT8251_SATA (0x3349 is not used for VT8237R, AFAIK).
This PCI ID is used in RAID mode on newer (CE) chipset revision and in all
modes (IDE/RAID/AHCI) on older revision.
Add the 0x5287 PCI ID, used in IDE mode on newer (CE) chipset revision.
Rename VT8251_SATA to VT8251_AHCI (0x6287 is used only in AHCI mode).
Add VT8251_AHCI to the ahcisata(4) quirk list, same as VT8251_SATA.
For more details, see the tech-kern thread:
https://mail-index.netbsd.org/tech-kern/2025/04/13/msg030365.html
Should fix and close PR kern/37517.
Tested on Asus A8V-VM (CD) and MSI MS-7318 (CE) motherboards.
Reviewed by bad.
viaide(4): check if chip enable register returns 0 before emulating enable
bits.
At least some VT6410 controllers have register exposed. In fact, some
motherboards allow to control IDE channels (enable/disable them).
viaide(4): update the list of supported VIA controllers.
viaide(4): remove notes section about VT6421, it is not currently required to
setup RAID/JBOD sets to access drives.
 1.103.2.1 26-Oct-2025  martin Pull up following revision(s) (requested by andvar in ticket #71):

share/man/man4/viaide.4: revision 1.13
sys/dev/pci/viaide.c: revision 1.105

viaide(4): add UDMA support for VT8233C IDE controller.

The VT8233C is another obscure VIA southbridge and appears to be a
variant of the
VT8233 rather than the VT8233A (which supports ATA133). The C variant
was paired with
a 3Com network controller instead of VIA's own NIC. Detect the ISA-PCI
bridge and
enable UDMA100 capability for improved IDE performance.

Update the viaide(4) man page and refine the list of supported VIA controllers.
 1.17 20-Jan-2007  xtraeme Updated viaenv(4) driver:

* Support for the VIA VT8231 Hardware monitor.
* Power Management Timer available for timecounters in both
VT86C686A and VT8231 (code simplified thanks to dev/ic/acpipmtimer).
* Remove viapm(4) code and manpage (which was a link to viaenv.4 anyway).

From OpenBSD, tested by some users.
 1.16 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.15 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14 11-Dec-2005  christos branches: 1.14.20; 1.14.22;
merge ktrace-lwp.
 1.13 14-Sep-2004  drochner branches: 1.13.12;
fix botch in config_found conversion, found by Stefan Krueger
 1.12 13-Sep-2004  drochner a round of autoconf cleanup:
-convert submatch() style functions (passed to config_search() or
config_found_sm()) to the locator passing variants
-pass interface attributes in some cases
-make submatch() functions look uniformly as far as possible
-avoid macros which just hide cfdata members, and reduce dependencies
on "locators.h"
 1.11 25-Jul-2004  christos jason says that it is unclear if the new device is compatible with the old
one so disable it for now.
 1.10 25-Jul-2004  christos Match viatech's power controller (Sergio Jimenez)
 1.9 01-Jan-2003  thorpej branches: 1.9.2;
Use aprint_normal() in cfprint routines.
 1.8 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.7 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.4 25-Mar-2002  thorpej There is no need to use a kthread to read the VIA environment
sensors.
 1.3 13-Nov-2001  lukem add RCSID
 1.2 12-May-2000  thorpej branches: 1.2.6; 1.2.8; 1.2.10;
Apply indent(1).
 1.1 08-May-2000  joda VIA VT82C686A hardware monitor
 1.2.10.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.8.4 03-Jan-2003  thorpej Sync with HEAD.
 1.2.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.2.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.8.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 12-May-2000  bouyer file viapm.c was added on branch thorpej_scsipi on 2000-11-20 11:42:39 +0000
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.12.2 26-Feb-2007  yamt sync with head.
 1.13.12.1 30-Dec-2006  yamt sync with head.
 1.14.22.2 10-Dec-2006  yamt sync with head.
 1.14.22.1 22-Oct-2006  yamt sync with head
 1.14.20.2 01-Feb-2007  ad Sync with head.
 1.14.20.1 18-Nov-2006  ad Sync with head.
 1.5 20-Jan-2007  xtraeme Updated viaenv(4) driver:

* Support for the VIA VT8231 Hardware monitor.
* Power Management Timer available for timecounters in both
VT86C686A and VT8231 (code simplified thanks to dev/ic/acpipmtimer).
* Remove viapm(4) code and manpage (which was a link to viaenv.4 anyway).

From OpenBSD, tested by some users.
 1.4 11-Dec-2005  christos branches: 1.4.20;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 12-May-2000  thorpej branches: 1.2.6; 1.2.30; 1.2.38; 1.2.40;
Apply indent(1).
 1.1 08-May-2000  joda VIA VT82C686A hardware monitor
 1.2.40.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.38.1 29-Apr-2005  kent sync with -current
 1.2.30.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 12-May-2000  bouyer file viapmvar.h was added on branch thorpej_scsipi on 2000-11-20 11:42:39 +0000
 1.3.4.1 26-Feb-2007  yamt sync with head.
 1.4.20.1 01-Feb-2007  ad Sync with head.
 1.12 22-Apr-2025  ozaki-r vio9p: export tag via sysctl

With this change, we can see tags of virtio-9p devices via sysctl:
# sysctl hw.vio9p
hw.vio9p.vio9p0.tag = test
hw.vio9p.vio9p1.tag = test2

PR kern/59165
 1.11 23-Mar-2023  yamaguchi branches: 1.11.6;
Added functions to set interrupt handler and index into virtqueue
 1.10 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.9 20-Apr-2022  uwe branches: 1.9.4;
vio9p: avoid null pointer dereference on attach.

Pass "vqs" argument to virtio_child_attach_start(). The virtio API is
not quite clear to me here - there's also a separate setter
virtio_child_attach_set_vqs that performs some additional actions.

Queue setup for Virtio 1.0 accesses virtio_softc::sc_vqs and we didn't
set it. QEMU exposes only the old virtio interface, so it doesn't
trigger the problem.
 1.8 13-Apr-2022  uwe vio9p: Bump max tag len to match QEMU.

QEMU defines it to 32 but includes the final zero byte into the limit.
Our code counts the final zero byte separately, so adjust this define
appropriately.
 1.7 13-Apr-2022  uwe vio9p: Properly negotiate MOUNT_TAG feature.

I _think_ that this is what is intended here. The code used to
actually test for the presence of any random device independent
feature bits (the test would happen to succeed b/c of INDIRECT_DESC).
 1.6 13-Apr-2022  uwe vio9p: Add definition for the MOUNT_TAG feature bit.

From QEMU sources.
 1.5 31-Mar-2022  pgoyette For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence. This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

devsw_attach()
config_init_component() or config_cf*_attach()
...
config_fini_component() or config_cf*_detach()
devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
1. compile without build break
2. no related test failures from atf
3. modload/modunload work as well as
before.

No functional device testing done, since I don't have any
of these devices. Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken; see kern/56772. This commit does not break
any additional modules (as far as I know).
 1.4 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.3 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.2 18-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.1 28-Oct-2019  ozaki-r branches: 1.1.8; 1.1.10;
Implement a front-end driver of virtio-9p called vio9p

In conjunction with mount_9p, it enables a NetBSD system running as a VM guest
to mount an exported filesystem by the host via virtio-9p. It exports a 9p
end-point of virtio-9p via a character device file for mount_9p.

Reviewed by yamaguchi@
 1.1.10.2 03-Apr-2021  thorpej Sync with HEAD.
 1.1.10.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 28-Oct-2019  martin file vio9p.c was added on branch phil-wifi on 2020-04-13 08:04:45 +0000
 1.9.4.2 15-May-2025  martin Pull up following revision(s) (requested by ozaki-r in ticket #1115):

sys/dev/pci/vio9p.c: revision 1.12

vio9p: export tag via sysctl

With this change, we can see tags of virtio-9p devices via sysctl:
# sysctl hw.vio9p
hw.vio9p.vio9p0.tag = test
hw.vio9p.vio9p1.tag = test2

PR kern/59165
 1.9.4.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.11.6.1 02-Aug-2025  perseant Sync with HEAD
 1.2 04-Oct-2025  thorpej Use device_{get,set}prop_bool() for "is_console".
 1.1 26-Jul-2025  martin branches: 1.1.4;
PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 26-Jul-2025  perseant file viogpu.c was added on branch perseant-exfatfs on 2025-08-02 05:57:00 +0000
 1.1 26-Jul-2025  martin branches: 1.1.4;
PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 26-Jul-2025  perseant file viogpu.h was added on branch perseant-exfatfs on 2025-08-02 05:57:00 +0000
 1.17 25-Mar-2023  mlelstv Mark as MPSAFE.
 1.16 25-Mar-2023  mlelstv Fix 32bit overflow when calculating balloon size.
Don't make uvm_pglistalloc wait, it will wait forever. Instead rely on
the retries by this driver. This also allows to cancel the request.
Increase inflate speed by factor 10 (same as deflate).
 1.15 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.14 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.13 13-Apr-2022  uwe branches: 1.13.4;
virtio: use the new syntax for snprintb(3) format strings.

The old syntax is limited to 32 bits only (and has 1-based bit numbers
which is rather incovenient too).
 1.12 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.11 13-Jan-2021  reinoud Fix for virtios viomb memory balloon driver. The inflate_done() and
deflate_done() issued a wrong extent to bus_dmamap_sync() giving rise to
panics on aarch64s mmio backend.
 1.10 10-Dec-2019  ad branches: 1.10.8;
p->phys_addr -> VM_PAGE_TO_PHYS(p)
 1.9 10-Jun-2018  jakllsch branches: 1.9.2;
remove irrelevant pci(9) #includes from virtio child drivers
 1.8 25-Mar-2017  jdolecek branches: 1.8.12;
reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.7 27-Sep-2016  pgoyette branches: 1.7.2;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.6 07-Jul-2016  msaitoh branches: 1.6.2;
KNF. Remove extra spaces. No functional change.
 1.5 27-Oct-2015  christos Print the negotiated feature bits
 1.4 04-May-2015  ozaki-r Add NULL check for TAILQ_FIRST
 1.3 22-Jul-2014  ozaki-r branches: 1.3.4;
Introduce VIRTIO_F_PCI_INTR_MPSAFE for virtio

It is set by a child driver, e.g., if_vioif. If set, virtio sets
PCI_INTR_MPSAFE for pci_intr_establish.
 1.2 17-Oct-2013  christos branches: 1.2.2;
- remove unused variables
- move debugging code inside debugging sections
 1.1 30-Oct-2011  hannken branches: 1.1.2; 1.1.8; 1.1.14; 1.1.18;
Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.1.18.1 18-May-2014  rmind sync with head
 1.1.14.2 03-Dec-2017  jdolecek update from HEAD
 1.1.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.2 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.1.8.1 30-Oct-2011  riz file viomb.c was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.2.1 10-Aug-2014  tls Rebase.
 1.3.4.5 28-Aug-2017  skrll Sync with HEAD
 1.3.4.4 05-Oct-2016  skrll Sync with HEAD
 1.3.4.3 09-Jul-2016  skrll Sync with HEAD
 1.3.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.4.1 06-Jun-2015  skrll Sync with HEAD
 1.6.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.6.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.7.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.9.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.13.4.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.23 04-Nov-2025  nia KNF
 1.22 04-Aug-2023  riastradh entropy(9): Simplify stages. Split interrupt vs non-interrupt paths.

- Nix the entropy stage (cold, warm, hot). Just use the usual kernel
`cold' (cold: single-core, single-thread; interrupts may happen),
and don't make any three-way distinction about whether interrupts
or threads or other CPUs can be running.

Instead, while cold, use splhigh/splx or forbid paths to come from
interrupt context, and while warm, use mutex or the per-CPU hard
and soft interrupt paths for low latency. This comes at a small
cost to some interrupt latency, since we may stir the pool in
interrupt context -- but only for a very short window early at boot
between configure and configure2, so it's hard to imagine it
matters much.

- Allow rnd_add_uint32 to run in hard interrupt context or with spin
locks held, but defer processing to softint and drop samples on the
floor if buffer is full. This is mainly used for cheaply tossing
samples from drivers for non-HWRNG devices into the entropy pool,
so it is often used from interrupt context and/or under spin locks.

- New rnd_add_data_intr provides the interrupt-like data entry path
for arbitrary buffers and driver-specified entropy estimates: defer
processing to softint and drop samples on the floor if buffer is
full.

- Document that rnd_add_data is forbidden under spin locks outside
interrupt context (will crash in LOCKDEBUG), and inadvisable in
interrupt context (but technically permitted just in case there are
compatibility issues for now); later we can forbid it altogether in
interrupt context or under spin locks.

- Audit all uses of rnd_add_data to use rnd_add_data_intr where it
might be used in interrupt context or under a spin lock.

This fixes a regression from last year when the global entropy lock
was changed from IPL_VM (spin) to IPL_SOFTSERIAL (adaptive). Thought
I'd caught all the problems from that, but another one bit three
different people this week, presumably because of recent changes that
led to more non-HWRNG drivers entering the entropy consolidation
path from rnd_add_uint32.

In my attempt to preserve the rnd(9) API for the (now long-since
abandoned) prospect of pullup to netbsd-9 in my rewrite of the
entropy subsystem in 2020, I didn't introduce a separate entry point
for entering entropy from interrupt context or equivalent, i.e., spin
locks held, and instead made rnd_add_data rely on cpu_intr_p() to
decide whether to process the whole sample under a lock or only take
as much as there's buffer space for before scheduling a softint. In
retrospect, that was a mistake (though perhaps not as much of a
mistake as other entropy API decisions...), a mistake which is
finally getting rectified now by rnd_add_data_intr.

XXX pullup-10
 1.21 25-Mar-2023  mlelstv Mark as MPSAFE.
 1.20 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.19 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.18 14-Apr-2022  riastradh branches: 1.18.4;
Revert "viornd(4): Process host entropy in softint context."

Apparently this has the effect of sometimes making the network hang
on Google Compute Engine as used by syzbot, which has held up all the
syzkaller testing for weeks now. Let's revert this for now, and
separately try to figure out what's wrong with it.
 1.17 23-Mar-2022  riastradh viornd(4): Process host entropy in softint context.

Samples added to the entropy pool in hard interrupt context are only
buffered, never processed directly, and if they fill the buffer, the
sample is dropped -- this serves to encourage taking timing samples
in hard interrupt context because it's cheap, and we have no idea how
many samples we really need for full entropy so it's safer to err on
the side of `as many as we can get'.

But for viornd(4), we assume the host has full entropy so we only
need a single 32-byte sample, and we want to avoid dropping it so we
get full entropy ASAP. Entering the sample in a soft interrupt
rather than hard interrupt achieves this.
 1.16 19-Mar-2022  riastradh viornd(4): Revert IPL change for lock.

This lock is taken in hard interrupt context, so it needs to remain
at IPL_VM.
 1.15 19-Mar-2022  riastradh rnd(9): Adjust IPL of locks used by rndsource callbacks.

These no longer ever run from hard interrupt context or with a spin
lock held, so there is no longer any need to have them at IPL_VM to
block hard interrupts. Instead, lower them to IPL_SOFTSERIAL.
 1.14 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.13 30-Apr-2020  riastradh branches: 1.13.2;
rnd_attach_source calls the callback itself now.

No need for every driver to explicitly call it to prime the pool.

Eliminate now-unused <sys/rndpool.h>.
 1.12 10-Jun-2018  jakllsch remove irrelevant pci(9) #includes from virtio child drivers
 1.11 25-Mar-2017  jdolecek branches: 1.11.12; 1.11.14;
reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.10 30-Nov-2016  christos branches: 1.10.2;
Don't call virtio_enqueue_abort when virtio_enqueue_reserve fails.
Pointed out by uwe@
 1.9 27-Oct-2015  christos branches: 1.9.2;
Print the negotiated feature bits
 1.8 05-May-2015  ozaki-r Use NULL for initialization of sc_config_change
 1.7 13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.6 08-Apr-2015  riastradh Don't forget to bus_dmamap_unload.
 1.5 06-Nov-2014  pooka branches: 1.5.2;
put the "asked for" print also behind VIORNG_DEBUG
 1.4 06-Nov-2014  pooka Abort only actually initialized slots.
 1.3 06-Nov-2014  pooka disable debug print by default
 1.2 06-Nov-2014  pooka Print attachment \n's so that we don't get junky lines
(this driver now matches ld)
 1.1 26-Oct-2014  tls branches: 1.1.2;
Add viornd(4), a driver for the VirtIO entropy source available on
QEMU, KVM, and Google Compute Engine. From OpenBSD.
 1.1.2.3 06-Nov-2015  riz Pull up following revision(s) (requested by riastradh in ticket #995):
sys/dev/pci/viornd.c: revision 1.3
disable debug print by default
 1.1.2.2 02-Nov-2014  martin Pull up following revision(s) (requested by tls in ticket #174):
doc/CHANGES: revision 1.2005
sys/dev/pci/viornd.c: revision 1.1
sys/dev/pci/files.pci: revision 1.372
sys/arch/amd64/conf/GENERIC: revision 1.401
share/man/man4/viornd.4: revision 1.1
Add viornd(4), a driver for the VirtIO entropy source available on
QEMU, KVM, and Google Compute Engine. From OpenBSD.
 1.1.2.1 26-Oct-2014  martin file viornd.c was added on branch netbsd-7 on 2014-11-02 10:09:44 +0000
 1.5.2.4 28-Aug-2017  skrll Sync with HEAD
 1.5.2.3 05-Dec-2016  skrll Sync with HEAD
 1.5.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5.2.1 06-Jun-2015  skrll Sync with HEAD
 1.9.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.9.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.14.1 25-Jun-2018  pgoyette Sync with HEAD
 1.11.12.2 03-Dec-2017  jdolecek update from HEAD
 1.11.12.1 25-Mar-2017  jdolecek file viornd.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.13.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.18.4.2 11-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #319):

sys/dev/pci/ubsec.c: revision 1.64
sys/dev/pci/hifn7751.c: revision 1.82
lib/libc/gen/getentropy.3: revision 1.5
lib/libc/gen/getentropy.3: revision 1.6
share/man/man4/rnd.4: revision 1.41
lib/libc/sys/getrandom.2: revision 1.2
lib/libc/sys/getrandom.2: revision 1.3
share/man/man5/rc.conf.5: revision 1.193
share/man/man7/entropy.7: revision 1.5
share/man/man7/entropy.7: revision 1.6
share/man/man7/entropy.7: revision 1.7
share/man/man7/entropy.7: revision 1.8
etc/security: revision 1.130
share/man/man7/entropy.7: revision 1.9
etc/security: revision 1.131
sys/crypto/cprng_fast/cprng_fast.c: revision 1.19
sys/sys/rndio.h: revision 1.3
tests/lib/libc/sys/t_getrandom.c: revision 1.5
etc/defaults/rc.conf: revision 1.164
etc/defaults/rc.conf: revision 1.165
sys/sys/rndsource.h: revision 1.10
sys/kern/kern_entropy.c: revision 1.62
sys/kern/kern_entropy.c: revision 1.63
sys/kern/kern_entropy.c: revision 1.64
sys/kern/subr_cprng.c: revision 1.44
sys/kern/kern_entropy.c: revision 1.65
sys/kern/kern_clock.c: revision 1.149
sys/dev/pci/viornd.c: revision 1.22
share/man/man9/rnd.9: revision 1.32
sys/kern/subr_prf.c: revision 1.202
sys/sys/rndsource.h: revision 1.8
sys/sys/rndsource.h: revision 1.9
share/man/man7/entropy.7: revision 1.10

1. Reinstate netbsd<=9 entropy estimator to unblock /dev/random, in
parallel with assessment of only confident entropy sources (seed,
HWRNG) for security warnings like sshd keys in motd and daily
insecurity report.

2. Make multiuser boot wait for first /dev/random output soon after
loading a seed and configuring rndctl, so that getentropy(3) meets
its contract starting early at boot without introducing blocking
paths that could cause hangs in init(8) or single-user mode.
Operators can choose to disable this wait in rc.conf.

3. Fix some bugs left over from reducing the global entropy lock from
a spin lock at IPL_VM to an adaptive lock at IPL_SOFTSERIAL.

4. Update man pages.
 1.18.4.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.36 25-Mar-2023  mlelstv Mark as MPSAFE.
 1.35 25-Mar-2023  mlelstv A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.
 1.34 25-Mar-2023  mlelstv restore fetch of qsize.
 1.33 24-Mar-2023  yamaguchi Added check of pointer for allocated memory before release of resource
 1.32 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.31 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.30 11-Oct-2022  andvar branches: 1.30.2;
fix typos in log messages s/bus_dmamem_create/bus_dmamap_create/ and
s/bus_dmamem_load/bus_dmamap_load/.
Inspired by recent similar fixes in OpenBSD.
 1.29 27-Jan-2022  jakllsch We no need for PQUIRK_FORCELUNS now that we try REPORT LUNS.
 1.28 12-Nov-2021  skrll Trailing whitespace
 1.27 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.26 24-Apr-2021  thorpej branches: 1.26.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.25 20-Jan-2021  reinoud branches: 1.25.2;
Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.24 19-Sep-2020  kim branches: 1.24.2;
Update the Proxmox comment with link to their bugzilla
 1.23 18-Sep-2020  jakllsch Probe all LUNs on vioscsi(4) until scsi(4) can do REPORT LUNS.
 1.22 12-Jul-2020  kim Fix off-by-one SCSI target reporting

Use max_target as the controller ID instead of zero, so that the device
located at SCSI ID zero (e.g. a disk) is not obscured through not being
probed by scsi_probe_bus() (which skips the controller ID).

Copy the target requested onto the wire without decrementing it by one.

ok christos@
 1.21 13-Apr-2019  maxv branches: 1.21.4;
Fix use-after-free. If we're not polling, virtio_enqueue_commit() will send
the transaction, and it means 'xs' can be immediately freed. So, save the
value of xs_control beforehand.

Detected by KASAN, ok jdolecek@.

Fixes PR/54008
Reported-by: syzbot+6513c4afe66237d7207f@syzkaller.appspotmail.com
 1.20 10-Jun-2018  jakllsch branches: 1.20.2;
remove irrelevant pci(9) #includes from virtio child drivers
 1.19 15-May-2017  jdolecek branches: 1.19.2; 1.19.8; 1.19.10;
free the virtio slot _before_ calling scsipi_done(), so that driver is able
to accept another request immediatelly and doesn't trigger spurious
XS_RESOURCE_SHORTAGE

part of fix for PR kern/52199
 1.18 13-May-2017  jdolecek refactor error handling in vioscsi_scsipi_request() to avoid the goto maze,
and add missing virtio_enqueue_abort() call when bus_dmamap_load() fails;
abort is only done implicitely when virtio_enqueue_reserve() fails,
must do it explicitely if there is other reason

also now always print error when bus_dmamap_load() or virtio_enqueue_reserve()
fail - the former shouldn't fail due to BUS_DMA_ALLOCNOW, and the latter
shouldn't ever fail now after the maxnsegs fix for virtio_alloc_vq(), so
error there means driver bug
 1.17 13-May-2017  jdolecek fix number of maximum segments in the queue allocation so that
MAXPHYS-sized tranfer fits inside the indirect descriptor; avoids the
!indirect path in virtio_enqueue_reserve() for these transfers,
which runs out of the vq_entries and triggers XS_RESOURCE_SHORTAGE for
bigger number of outstanding tranfers

fixes PR kern/52199 by MB
 1.16 25-Mar-2017  christos branches: 1.16.4;
fix printf format.
 1.15 25-Mar-2017  jdolecek add support for loading vioscsi driver dynamically
 1.14 25-Mar-2017  jdolecek cap also adapt_nchannels to 1, we only attach one
 1.13 25-Mar-2017  jdolecek cap adapt_openings to minimum of cmd_per_lun and qsize, so that we don't
overpromise to the upper layer

cap ntargets and nluns to 16 and 1024 as avoid spending excessive time
probing for nonexistent devices; e.g. qemu defaults to 255/16383 causing
the probe to take about a minute
 1.12 25-Mar-2017  jdolecek reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.11 13-Mar-2017  jdolecek several small tweaks:
- use MSIX if available
- fix off-by-one for nluns/ntargets (code inspection, not actual effect)
- when virtio_enqueue_reserve() fails, do not execute vioscsi_req_put()
and hence virtio_dequeue_commit() as there is nothing to commit, just
unload the xs and return; also report XS_RESOURCE_SHORTAGE, it's
semi-normal situation
- set status/resid in vioscsi_req_done() before the switch, so that
the override for VIRTIO_SCSI_S_BAD_TARGET actually has effect
- g/c vioscsi_req_put(), call the appropriate cleanup routines directly
- stop initializing id/task_attr in vioscsi_req_get(), it's overwritten
in vioscsi_scsipi_request() anyway
 1.10 13-Mar-2017  jdolecek replace req queue offset with define, only set & start the req interrupt for
that queue; add some masks for the lun for visibility; use slot as tag number

no actual functional change, just small cleanup
 1.9 07-Mar-2017  jdolecek allocate bus dma maps during attachment, rather than creating and destroying
them for each request; besides being faster, bus_dmamap_destroy() is not
safe to be called from interrupt context

adresses PR kern/52034 by Benny Siegert
 1.8 04-Oct-2016  jdolecek branches: 1.8.2; 1.8.4; 1.8.6;
react on ADAPTER_REQ_SET_XFER_MODE so that we set tagged queuing

pass tag type and set id
 1.7 04-Oct-2016  jdolecek vioscsi_req_get()/virtio_enqueue_prep() failing is actually perfectly
normal - observed failures included 10, 27, 61 in-flight commands,
so probably depends on particular command mix; return with
XS_RESOURCE_SHORTAGE rather then panic

do vioscsi_req_put() when initial bus_dmamap_load() fails, as suggested
by the XXX; the vq_done hook is called by virtio, but in that case we never
get to commit the request to it
 1.6 01-Nov-2015  pooka branches: 1.6.2; 1.6.4;
Use SCSIPI_CHAN_NOSETTLE.
 1.5 31-Oct-2015  christos fix the status return.
 1.4 30-Oct-2015  christos Fake mode sense data for illegal targets. qemu reports 256 targets...
 1.3 30-Oct-2015  christos kill some more debugging.
 1.2 30-Oct-2015  christos this is working now, remove debugging.
 1.1 29-Oct-2015  christos Add vioscsi, compile tested only (toxic)
 1.6.4.3 26-Apr-2017  pgoyette Sync with HEAD
 1.6.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.6.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.6.2.4 28-Aug-2017  skrll Sync with HEAD
 1.6.2.3 05-Dec-2016  skrll Sync with HEAD
 1.6.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.6.2.1 01-Nov-2015  skrll file vioscsi.c was added on branch nick-nhusb on 2015-12-27 12:09:57 +0000
 1.8.6.2 18-Jan-2017  skrll Sync with netbsd-5
 1.8.6.1 04-Oct-2016  skrll file vioscsi.c was added on branch netbsd-7-nhusb on 2017-01-18 08:46:42 +0000
 1.8.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.2.2 23-Dec-2016  snj Pull up following revision(s) (requested by bsiegert in ticket #1338):
sys/arch/amd64/conf/GENERIC: revision 1.418
sys/dev/pci/files.pci: revision 1.379
sys/dev/pci/vioscsi.c: revisions 1.1-1.8
sys/dev/pci/vioscsireg.h: revision 1.1
sys/dev/pci/virtioreg.h: revisions 1.5, 1.6
add the common flag bits
--
Add vioscsi, compile tested only (toxic)
--
this is working now, remove debugging.
--
add vioscsi
--
kill some more debugging.
--
Fake mode sense data for illegal targets. qemu reports 256 targets...
--
fix the status return.
--
Use SCSIPI_CHAN_NOSETTLE.
--
vioscsi_req_get()/virtio_enqueue_prep() failing is actually perfectly
normal - observed failures included 10, 27, 61 in-flight commands,
so probably depends on particular command mix; return with
XS_RESOURCE_SHORTAGE rather then panic
do vioscsi_req_put() when initial bus_dmamap_load() fails, as suggested
by the XXX; the vq_done hook is called by virtio, but in that case we
never get to commit the request to it
--
react on ADAPTER_REQ_SET_XFER_MODE so that we set tagged queuing
pass tag type and set id
 1.8.2.1 04-Oct-2016  snj file vioscsi.c was added on branch netbsd-7 on 2016-12-23 06:33:56 +0000
 1.16.4.1 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.19.10.1 25-Jun-2018  pgoyette Sync with HEAD
 1.19.8.2 03-Dec-2017  jdolecek update from HEAD
 1.19.8.1 15-May-2017  jdolecek file vioscsi.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.19.2.2 13-Jul-2020  martin Pull up following revision(s) (requested by kim in ticket #1572):

sys/dev/pci/vioscsi.c: revision 1.22

Fix off-by-one SCSI target reporting

Use max_target as the controller ID instead of zero, so that the device
located at SCSI ID zero (e.g. a disk) is not obscured through not being
probed by scsi_probe_bus() (which skips the controller ID).

Copy the target requested onto the wire without decrementing it by one.

ok christos@
 1.19.2.1 15-Jul-2019  martin Pull up following revision(s) (requested by maxv in ticket #1289):

sys/dev/pci/vioscsi.c: revision 1.21

Fix use-after-free. If we're not polling, virtio_enqueue_commit() will send
the transaction, and it means 'xs' can be immediately freed. So, save the
value of xs_control beforehand.

Detected by KASAN, ok jdolecek@.
Fixes PR/54008
 1.20.2.1 10-Jun-2019  christos Sync with HEAD
 1.21.4.1 13-Jul-2020  martin Pull up following revision(s) (requested by kim in ticket #1001):

sys/dev/pci/vioscsi.c: revision 1.22

Fix off-by-one SCSI target reporting

Use max_target as the controller ID instead of zero, so that the device
located at SCSI ID zero (e.g. a disk) is not obscured through not being
probed by scsi_probe_bus() (which skips the controller ID).

Copy the target requested onto the wire without decrementing it by one.

ok christos@
 1.24.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.25.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.26.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.30.2.2 02-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #914):

sys/dev/pci/virtio_pci.c: revision 1.50
sys/dev/pci/virtio_pci.c: revision 1.51
sys/dev/pci/virtio_pci.c: revision 1.52
sys/dev/pci/virtio_pci.c: revision 1.53
sys/dev/pci/virtio_pci.c: revision 1.54
sys/dev/pci/vioscsi.c: revision 1.35
sys/dev/pci/ld_virtio.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.34
sys/dev/virtio/viocon.c: revision 1.9
sys/dev/pci/ld_virtio.c: revision 1.35
sys/dev/pci/virtio.c: revision 1.80
sys/dev/pci/virtio.c: revision 1.81
sys/dev/pci/virtio.c: revision 1.82
sys/dev/pci/virtio_pci.c: revision 1.45
sys/dev/pci/virtio_pci.c: revision 1.46
sys/dev/pci/virtio_pci.c: revision 1.47
sys/dev/pci/virtio_pci.c: revision 1.48
sys/dev/pci/virtio_pci.c: revision 1.49
sys/dev/pci/virtio.c: revision 1.79

A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.

viocon(4): Show error in assertion failure.

virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
fix spelling mistakes, mainly in comments and log messages.

Split KASSERT(A && B) into KASSERT(A); KASSERT(B).

Fix typo in error message.

Modify a confused expression in ld_virtio_attach().

VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.

ld@virtio(4): Fix maximum size parameters.
- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.
The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.
=> Don't add two extra segments in the dmamap vr_payload for the
header and status -- we already have a separate dmamap vr_cmdsts
for that.
=> Don't recalculate payload dmamap parameters based on division by
NBPG, just use the ones specified by the host.
=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
MAXPHYS.
Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.
PR kern/58338

virtio_pci.c: Nix trailing whitespace.

virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.
PR kern/58335

virtio@pci: Nix useless sc_mapped_iosize.
This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.
Prompted by PR kern/58335.

virtio@pci: Don't detach on shutdown.
The virtio bus does not keep state in memory that needs to flushed to
persistent storage. Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).
Prompted by PR kern/58335.

virtio@pci: Zero sc_bars_iosize[i] on unmap.
No functional change intended, but this makes the code less brittle.
Prompted by PR kern/58335.

virtio_pci.c: Sort includes.
No functional change intended.

virtio_pci.c: Omit needless blank lines and commented code.
No functional change intended.

virtio_pci.c: Sprinkle KNF.
- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
virtio_pci.c: Sprinkle const.
No functional change intended.

virtio_pci.c: Use container_of, not cast.
virtio(4): Assert child attach finished before we allow queueing.
Should help catch mistakes like:
PR kern/58555: Kernel panic during boot when using viocon with PCIe
 1.30.2.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.2 26-Aug-2021  andvar Add missing RCSID in header files and one __KERNEL_RCSID().
 1.1 29-Oct-2015  christos branches: 1.1.2; 1.1.6; 1.1.10; 1.1.22;
Add vioscsi, compile tested only (toxic)
 1.1.22.2 03-Dec-2017  jdolecek update from HEAD
 1.1.22.1 29-Oct-2015  jdolecek file vioscsireg.h was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.1.10.2 18-Jan-2017  skrll Sync with netbsd-5
 1.1.10.1 29-Oct-2015  skrll file vioscsireg.h was added on branch netbsd-7-nhusb on 2017-01-18 08:46:42 +0000
 1.1.6.2 23-Dec-2016  snj Pull up following revision(s) (requested by bsiegert in ticket #1338):
sys/arch/amd64/conf/GENERIC: revision 1.418
sys/dev/pci/files.pci: revision 1.379
sys/dev/pci/vioscsi.c: revisions 1.1-1.8
sys/dev/pci/vioscsireg.h: revision 1.1
sys/dev/pci/virtioreg.h: revisions 1.5, 1.6
add the common flag bits
--
Add vioscsi, compile tested only (toxic)
--
this is working now, remove debugging.
--
add vioscsi
--
kill some more debugging.
--
Fake mode sense data for illegal targets. qemu reports 256 targets...
--
fix the status return.
--
Use SCSIPI_CHAN_NOSETTLE.
--
vioscsi_req_get()/virtio_enqueue_prep() failing is actually perfectly
normal - observed failures included 10, 27, 61 in-flight commands,
so probably depends on particular command mix; return with
XS_RESOURCE_SHORTAGE rather then panic
do vioscsi_req_put() when initial bus_dmamap_load() fails, as suggested
by the XXX; the vq_done hook is called by virtio, but in that case we
never get to commit the request to it
--
react on ADAPTER_REQ_SET_XFER_MODE so that we set tagged queuing
pass tag type and set id
 1.1.6.1 29-Oct-2015  snj file vioscsireg.h was added on branch netbsd-7 on 2016-12-23 06:33:56 +0000
 1.1.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.1 29-Oct-2015  skrll file vioscsireg.h was added on branch nick-nhusb on 2015-12-27 12:09:57 +0000
 1.84 06-Sep-2025  riastradh virtio(4): Use paravirt_membar_sync(9) where needed.

PR kern/59618: occasional virtio block device lock ups/hangs
 1.83 26-Jul-2025  martin branches: 1.83.2;
PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.82 05-Aug-2024  riastradh virtio(4): Assert child attach finished before we allow queueing.

Should help catch mistakes like:

PR kern/58555: Kernel panic during boot when using viocon with PCIe
 1.81 10-Feb-2024  isaki branches: 1.81.2;
Split KASSERT(A && B) into KASSERT(A); KASSERT(B).
 1.80 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.79 07-Nov-2023  rin virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb

Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

Thanks ozaki-r@ for comments.

XXX Centralize?
See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
 1.78 21-Apr-2023  yamaguchi virtio(4): change members of struct vring_desc_extra before free a slot

This prevents the following race condition.
1. Thread-A: calls virtio_dequeue_commit() and
puts a slot into free descriptor chain in vq_free_slot()
2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A
3. Thread-B: calls virtio_enqueue_reserve() and
changes desc_base and desc_free_idx for the slot
4. Thread-A: changes the same members updated by Thread-B

reported by hannken, thanks.
 1.77 19-Apr-2023  yamaguchi virtio(4): change variable name, nfc
 1.76 19-Apr-2023  yamaguchi Fix not to allocate unnecessary descriptor

fixes PR/57358
 1.75 19-Apr-2023  yamaguchi Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc

pointed out by riastradh, thanks.
fixes PR/57357
 1.74 31-Mar-2023  yamaguchi Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().
 1.73 31-Mar-2023  yamaguchi Use descriptor chain for free slots instead of vq_entry list

Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.
The chain is also used for unused descriptors to make virtio(4)
simpler.
 1.72 29-Mar-2023  riastradh virtio(4): Fix sizing of virtqueue allocation.

vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.

Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.

XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.

PR kern/57304

Reported-by: syzbot+7fb1047f5dfa33b26331@syzkaller.appspotmail.com
 1.71 27-Mar-2023  nakayama Use PRIuBUSSIZE to print bus_size_t variables.
 1.70 27-Mar-2023  riastradh virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.

No functional change intended.
 1.69 25-Mar-2023  yamaguchi Setup virtqueues after registering them to virtio_softc
 1.68 24-Mar-2023  yamaguchi Added check of pointer for allocated memory before release of resource
 1.67 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.66 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.65 03-Jan-2023  jakllsch Subtly adjust criteria for notification of Virtio devices in
VIRTIO_F_RING_EVENT_IDX mode.

This fixes stalls in the vioif(4) transmit path that would happen sooner
or later, depending on interface transmit utilization, and were
particularly noticable with a NetBSD guest transmitting to its x86 KVM
host at multi-gigabit speeds.
 1.64 30-Dec-2022  jakllsch Fix dmamap_syncs more; the number of ring elements is vq->vq_num, not
sc->sc_nvqs.
 1.63 31-Oct-2022  simonb branches: 1.63.2;
Use PRIx64 in a debug print macro to print a uint64_t.
 1.62 18-Oct-2022  skrll KNF
 1.61 17-Oct-2022  skrll Fix previous by using roundup (and not howmany).
 1.60 15-Oct-2022  riastradh virtio(4): Use howmany from sys/param.h instead of open-coding it.

howmany will divide by VIRTIO_PAGE_SIZE instead of doing &
~(VIRTIO_PAGE_SIZE - 1), but it's a constant 4096 so this should make
no difference in the compiled output except possibly at -O0.

No functional change intended.
 1.59 15-Oct-2022  riastradh virtio(4): Sprinkle KNF.

No functional change intended.
 1.58 14-Aug-2022  riastradh virtio(4): Print numeric device type, even if unrecognized.
 1.57 12-Aug-2022  riastradh virtio(4): Membar and bus_dmamap_sync audit.

- Don't use membar_* for DMA.

- Sync only the header and payload of the rings separately as needed.
If we bounce, this avoids large memcpy when we only care about the
header.

- Sync uring with PREREAD before triggering anything that will return
data in it.

=> Move uring PREREAD in virtio_enqueue_commit to _before_ updating
vq->vq_avail->idx, which is the pointat which the DMA read is
triggered in the `device' (host).

=> Omit needless membar_consumer in virtio_enqueue_commit -- may not
work with DMA memory, and even if it does, redundant with
bus_dmamap_sync uring PREREAD here.

=> XXX Does the device/host ever return unsolicited entries in the
queue, or only solicited ones? If only solicited ones, the
PREREAD in virtio_init_vq is redundant.

- Sync uring with POSTREAD before we read from it. This way the DMA
read into our buffer has finished before we read from the buffer.

=> Add missing uring POSTREAD in virtio_vq_is_enqueued, between read of
vq->vq_used_idx and return to caller, so that the caller can
safely use virtio_dequeue.

=> Add missing uring POSTREADs in virtio_start_vq_intr:
. between entry from caller and the read of vq->vq_used_idx
. between the read of vq->vq_used_idx and return to caller,
so that the caller can safely use virtio_dequeue, just like
virtio_vq_is_enqueued

=> Move uring POSTREADs in virtio_enqueue_commit to _before_ reading
vq->vq_used->flags or *vq->vq_avail_event, not after.

- After we write to aring, sync it with PREWRITE. This way we finish
writing to our buffer before the DMA write from it.

=> Omit needless PREWRITE in virtio_init_vq -- we do the appropriate
PREWRITE in virtio_enqueue_commit now.

=> Convert membar_producer to bus_dmamap_sync PREWRITE in
virtio_enqueue_commit.

=> Omit incorrect aring POSTWRITE in virtio_enqueue_commit -- no need
because the DMA write may not have completed yet at this point,
and we already do a POSTWRITE in virtio_vq_is_enqueued.

=> Omit needless membar_producer in virtio_postpone_intr -- may not
work with DMA memory, and even if it does, redundant with
bus_dmamap_sync PREWRITE here.

- After xfers to aring have completed, sync it with POSTWRITE.

=> Add missing aring POSTWRITE in virtio_free_vq, in case there are
paths from virtio_enqueue_commit to here that don't go through
virtio_is_enqueued. (If there are no such paths, then maybe we
should KASSERT(vq->vq_queued == 0) in virtio_free_vq.)
 1.56 09-Aug-2022  riastradh virtio(4): Move comment for virtio_vq_intr.

No functional change intended.
 1.55 18-Jun-2022  andvar fix typos in word "functions" in comments, mainly s/fuctions/functions/.
 1.54 24-Apr-2022  uwe virtio: cosmetics - use (*pfn)(...) syntax.

Some people prefer to call function pointers without an explicit
dereference (that is purely cosmetic in this position), especially to
create faux c++ s->pfn(...) with function pointers in struct members.
Some prefer explicit dereference (that requires parens around it).

(pfn)(...) without dereference but with parens looks odd to both, so
make it conform to one of the established alternatives.

Same object code is generated.
 1.53 28-Oct-2021  yamaguchi virtio: stop reinit for safety when a device resetting is failed
 1.52 21-Oct-2021  yamaguchi virtio: fix missing release of interrupt resources
 1.51 21-Oct-2021  yamaguchi virtio: reconfigure MSI-X vector on re-initialization

This may fix a problem that some interrupts, for example
link-state change of vioif(4) are not notified.
 1.50 21-Oct-2021  yamaguchi divide setup routine of virtio interrupts
into establishment and device configuration
 1.49 07-Feb-2021  skrll In virtio_alloc_vq change BUS_DMA_NOWAIT to BUS_DMA_WAITOK. It's always
called from attach routines.
 1.48 07-Feb-2021  skrll Trailing whitespace
 1.47 05-Feb-2021  reinoud Better reading of 4.1.3.1, it seems that using 32 bit reads/writes is
mandatory for non-legacy devices.
 1.46 05-Feb-2021  reinoud Second round of cleaning up endian code. No more tailored code to maintain.
 1.45 28-Jan-2021  reinoud Rewrite and streamline virtio device config read/write and explicitly cater
for the Aarch64-eb bus problem with Qemu. This removes lots of bus_space
`magic' and cleans up the code.
 1.44 20-Jan-2021  reinoud Remove the virtio child driver finalisation check KASSERT that, while it
should never trigger, a possible bug in a child driver shouldn't have to panic
the kernel. Instead report the internal error.
 1.43 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.42 17-Sep-2020  jakllsch branches: 1.42.2;
Fix word-o of function name in comment
 1.41 25-May-2020  yamaguchi Set handlers implemented in child device of virtio(4) to virtqueue
instead of the commonized function
 1.40 25-May-2020  yamaguchi Register an interrupt handler for virtqueue to that for pci
to reduce function call
 1.39 25-May-2020  yamaguchi Remove VIRTIO_F_PCI_INTR_SOFTINT support for multiqueue

The functionality is no longer used by obsolating VIOIF_SOFTINT_INTR.
 1.38 01-Oct-2019  chs in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.37 14-Jan-2019  yamaguchi branches: 1.37.4;
Add multiqueue support, virtio(4)
 1.36 30-Sep-2018  jmcneill Suppress "not configured" message when no device is present
 1.35 15-Jun-2018  jakllsch branches: 1.35.2;
Add cfprint_t virtiobusprint() and use it for virtio_mmio.
 1.34 15-Jun-2018  jakllsch Fix queue address setup bug introduced in 1.31.

This use-before-initialization problem resulted in non-zero queues never
being initialized with their virtqueue pointer, and queue zero's pointer
to be clobbered with the virtqueue pointer for the higest-indexed ring.
 1.33 06-Jun-2018  jakllsch remove now-irrelevant <dev/pci> includes
 1.32 06-Jun-2018  jakllsch fix up virtio module for current structure; add virtio_pci module
 1.31 02-Jun-2018  jakllsch Begin to detangle virtio from its PCI attachment
 1.30 14-Feb-2018  uwe branches: 1.30.2;
Cosmetic - consistently use #define<SPACE>
 1.29 02-Aug-2017  cherry Reorg the virtio(4) config(9) code to be explicitly pci specific.

We'll later use this for a non-pci virtio(4) usecase.

ok martin
 1.28 01-Jun-2017  chs branches: 1.28.2;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.27 28-Mar-2017  ozaki-r Handle config change interrupts to inhibit sending packets while link down

PR kern/52103 by s-yamaguchi@IIJ
 1.26 26-Mar-2017  jdolecek fix pasto for nbo_bus_space_write_4() - value needs to be uint32_t
 1.25 26-Mar-2017  martin Duh, remove accidently left over debug printfs
 1.24 26-Mar-2017  martin Backout previous, no need for these accessor in MD code
 1.23 26-Mar-2017  martin Provide an accessor for the pci attach args of a virtio device (if
available - future non-pci attachments may return NULL).
Sparc64 MD code needs this to match the OF node of the virtio device
for boot device recognition.
 1.22 25-Mar-2017  jdolecek reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.21 25-Mar-2017  jdolecek use ipl level specified by child when attaching interrupts, instead of always
using IPL_NET
 1.20 25-Mar-2017  martin PR kern/52107: for now (while we still use the legacy virtio spec) at least
hack around the endianess issues with that.
 1.19 29-Nov-2016  uwe branches: 1.19.2;
Fix the "typical usage" example for enqueuing a request - if
bus_dmamap_load(9) fails, we shouldn't call bus_dmamap_unload(9).
 1.18 27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.17 14-Aug-2016  tron Prevent a panic during system shutdown when vioif(4) is used
 1.16 11-Jul-2016  knakahara branches: 1.16.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.15 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.14 10-Jan-2016  christos PR/50636: Ryo ONODERA: Fix incorrect kmem_free()
 1.13 30-Oct-2015  christos more device names
 1.12 27-Oct-2015  christos use dma64 if available so we don't have do bounce around too much.
 1.11 26-Oct-2015  ozaki-r Support MSI-X in virtio

Currently only vioif(4) uses the feature.

knakahara@ helped to migrate to pci_intr_alloc(9). Thanks!
 1.10 15-Oct-2015  ozaki-r Name the interrupt handler for intrctl
 1.9 05-May-2015  ozaki-r Remove a garbage blank line
 1.8 19-Dec-2014  ozaki-r Implement softint-based interrupt handling in if_vioif

Softint-based interrupt handling is considered as a future direction
of the (network) device driver architecture in NetBSD. pq3etsec of
ppc is already implemented based on the architecture (unlike pq3etsec,
this change doesn't include softint-based if_start). In this
architecture, a hardware interrupt handler just schedules a softint
and the softint performs actual interrupt processing. It reduces
processing in hardware interrupt context and allows Layer 2 network
stack (e.g., bridge, vlan and even bpf) run in softint context,
which makes it easy to implement fine-grain locking in the layer.

This is an experimental implementation of the architecture in if_viof.

virtio introduces a new flag VIRTIO_F_PCI_INTR_SOFTINT. If a driver
of virtio sets it to sc_flags of virtio_softc, virtio calls
softint_schedule in virtio_intr instead of directly calling the
interrupt handler of the driver.

When VIOIF_SOFTINT_INTR is on, vioif doesn't use the existing softint
(vioif_rx_softint) that is called from vioif_rx_vq_done. Because
vioif_rx_softint already runs in softint context and another softint
isn't needed. This change actually improves performance in some cases.

The feature is disabled by default and enabled when SOFTINT_INTR is
set somewhere (normally in a kernel configuration).
 1.7 06-Oct-2014  mlelstv branches: 1.7.2;
use correct macro to handle subsys ids. Functional there is no
change, as both macros select the same bits.
 1.6 22-Jul-2014  ozaki-r branches: 1.6.2; 1.6.6;
Introduce VIRTIO_F_PCI_INTR_MPSAFE for virtio

It is set by a child driver, e.g., if_vioif. If set, virtio sets
PCI_INTR_MPSAFE for pci_intr_establish.
 1.5 29-Mar-2014  christos branches: 1.5.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.4 10-Aug-2013  tsutsui Make sure to check if the driver has a valid intr handler in virtio_detach().

Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio,
as reported in PR kern/48105 by Richard Hansen.

Should be pulled up to netbsd-6 branches.
 1.3 02-Nov-2011  njoly branches: 1.3.6; 1.3.8; 1.3.12; 1.3.14; 1.3.16; 1.3.22;
Small typo in symbolic name.
 1.2 02-Nov-2011  jakllsch branches: 1.2.2;
Use symbolic PCI_PRODUCTs.
 1.1 30-Oct-2011  hannken Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.2.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.2.1 10-Nov-2011  yamt sync with head
 1.3.22.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by tsutsui in ticket #931):
sys/dev/pci/virtio.c: revision 1.4
Make sure to check if the driver has a valid intr handler in virtio_detach().
Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio,
as reported in PR kern/48105 by Richard Hansen.
Should be pulled up to netbsd-6 branches.
 1.3.16.2 18-May-2014  rmind sync with head
 1.3.16.1 28-Aug-2013  rmind sync with head
 1.3.14.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by tsutsui in ticket #931):
sys/dev/pci/virtio.c: revision 1.4
Make sure to check if the driver has a valid intr handler in virtio_detach().
Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio,
as reported in PR kern/48105 by Richard Hansen.
Should be pulled up to netbsd-6 branches.
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.8.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by tsutsui in ticket #931):
sys/dev/pci/virtio.c: revision 1.4
Make sure to check if the driver has a valid intr handler in virtio_detach().
Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio,
as reported in PR kern/48105 by Richard Hansen.
Should be pulled up to netbsd-6 branches.
 1.3.6.2 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.3.6.1 02-Nov-2011  riz file virtio.c was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.5.2.1 10-Aug-2014  tls Rebase.
 1.6.6.1 18-Jan-2017  skrll Sync with netbsd-5
 1.6.2.1 23-Dec-2016  snj Pull up following revision(s) (requested by bsiegert in ticket #1337):
sys/dev/pci/if_vioif.c: revision 1.21
sys/dev/pci/virtio.c: revision 1.14
PR/50636: Ryo ONODERA: Fix incorrect kmem_free()
--
PR/50636: Ryo ONODERA: Reduce memory use
 1.7.2.8 28-Aug-2017  skrll Sync with HEAD
 1.7.2.7 05-Dec-2016  skrll Sync with HEAD
 1.7.2.6 05-Oct-2016  skrll Sync with HEAD
 1.7.2.5 09-Jul-2016  skrll Sync with HEAD
 1.7.2.4 19-Mar-2016  skrll Sync with HEAD
 1.7.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.7.2.2 06-Jun-2015  skrll Sync with HEAD
 1.7.2.1 06-Apr-2015  skrll Sync with HEAD
 1.16.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.16.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.16.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.19.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.28.2.3 23-Sep-2020  martin Pull up following revision(s) (requested by jakllsch in ticket #1609):

sys/dev/pci/virtio_pci.c: revision 1.13 (patch)
(applied to sys/dev/pci/virtio.c)

Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.

The virtio device config space moves out from under us when MSI-X
remains enabled, and/or INTx interrupts are masked if we don't ensure
this.

This un-breaks virtio devices that run out of MSI-X interrupts.
Particularly a problem on uniproc x86, where there are only 8 or 9
vectors available, allowing for only about 4 virtio devices to use
MSI-X.
 1.28.2.2 20-Sep-2020  martin Pull up following revision(s) (requested by jakllsch in ticket #1608):

sys/dev/pci/virtio_pci.c: revision 1.12

Ensure interrupt handles buffer is zeroed on allocation
Prevents crashes trying to deallocate interrupts at shutdown.

Found by kim and mlelstv, confirmed by me
 1.28.2.1 19-Feb-2018  snj Pull up following revision(s) (requested by uwe in ticket #553):
sys/dev/pci/virtio_pci.c: 1.2 via patch to sys/dev/pci/virtio.c
Explicitly enable PCI_COMMAND_MASTER_ENABLE and PCI_COMMAND_IO_ENABLE.
Recent versions of VirtualBox do not enable bus-mastering by default -
this will be fixed, but it doesn't hurt to do it ourselves too.
 1.30.2.3 18-Jan-2019  pgoyette Synch with HEAD
 1.30.2.2 20-Oct-2018  pgoyette Sync with head
 1.30.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.35.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.35.2.1 10-Jun-2019  christos Sync with HEAD
 1.37.4.1 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #1977):

sys/dev/pci/virtio.c: revision 1.84 (patch)

virtio(4): Use paravirt_membar_sync(9) where needed.

PR kern/59618: occasional virtio block device lock ups/hangs
 1.42.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.63.2.7 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #1178):

sys/dev/pci/virtio.c: revision 1.84

virtio(4): Use paravirt_membar_sync(9) where needed.

PR kern/59618: occasional virtio block device lock ups/hangs
 1.63.2.6 02-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #914):

sys/dev/pci/virtio_pci.c: revision 1.50
sys/dev/pci/virtio_pci.c: revision 1.51
sys/dev/pci/virtio_pci.c: revision 1.52
sys/dev/pci/virtio_pci.c: revision 1.53
sys/dev/pci/virtio_pci.c: revision 1.54
sys/dev/pci/vioscsi.c: revision 1.35
sys/dev/pci/ld_virtio.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.34
sys/dev/virtio/viocon.c: revision 1.9
sys/dev/pci/ld_virtio.c: revision 1.35
sys/dev/pci/virtio.c: revision 1.80
sys/dev/pci/virtio.c: revision 1.81
sys/dev/pci/virtio.c: revision 1.82
sys/dev/pci/virtio_pci.c: revision 1.45
sys/dev/pci/virtio_pci.c: revision 1.46
sys/dev/pci/virtio_pci.c: revision 1.47
sys/dev/pci/virtio_pci.c: revision 1.48
sys/dev/pci/virtio_pci.c: revision 1.49
sys/dev/pci/virtio.c: revision 1.79

A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.

viocon(4): Show error in assertion failure.

virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
fix spelling mistakes, mainly in comments and log messages.

Split KASSERT(A && B) into KASSERT(A); KASSERT(B).

Fix typo in error message.

Modify a confused expression in ld_virtio_attach().

VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.

ld@virtio(4): Fix maximum size parameters.
- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.
The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.
=> Don't add two extra segments in the dmamap vr_payload for the
header and status -- we already have a separate dmamap vr_cmdsts
for that.
=> Don't recalculate payload dmamap parameters based on division by
NBPG, just use the ones specified by the host.
=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
MAXPHYS.
Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.
PR kern/58338

virtio_pci.c: Nix trailing whitespace.

virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.
PR kern/58335

virtio@pci: Nix useless sc_mapped_iosize.
This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.
Prompted by PR kern/58335.

virtio@pci: Don't detach on shutdown.
The virtio bus does not keep state in memory that needs to flushed to
persistent storage. Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).
Prompted by PR kern/58335.

virtio@pci: Zero sc_bars_iosize[i] on unmap.
No functional change intended, but this makes the code less brittle.
Prompted by PR kern/58335.

virtio_pci.c: Sort includes.
No functional change intended.

virtio_pci.c: Omit needless blank lines and commented code.
No functional change intended.

virtio_pci.c: Sprinkle KNF.
- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
virtio_pci.c: Sprinkle const.
No functional change intended.

virtio_pci.c: Use container_of, not cast.
virtio(4): Assert child attach finished before we allow queueing.
Should help catch mistakes like:
PR kern/58555: Kernel panic during boot when using viocon with PCIe
 1.63.2.5 03-Jun-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #186):

sys/dev/pci/virtio_pci.c: revision 1.41
sys/dev/pci/virtio_pci.c: revision 1.42
sys/dev/virtio/virtio_mmio.c: revision 1.10
sys/dev/pci/virtiovar.h: revision 1.29
sys/dev/pci/virtio.c: revision 1.75
sys/dev/pci/virtio.c: revision 1.76
sys/dev/pci/virtio.c: revision 1.77
sys/dev/pci/virtio.c: revision 1.78

virtio@pci: Fix assertion on detach.

If the child never attached in the first place, it's OK for it to not
have detached.

XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.

XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.

PR kern/57357


Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc
pointed out by riastradh, thanks.
fixes PR/57357

Fix not to allocate unnecessary descriptor
fixes PR/57358

virtio(4): change variable name, nfc

virtio(4): change members of struct vring_desc_extra before free a slot

This prevents the following race condition.
1. Thread-A: calls virtio_dequeue_commit() and
puts a slot into free descriptor chain in vq_free_slot()
2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A
3. Thread-B: calls virtio_enqueue_reserve() and
changes desc_base and desc_free_idx for the slot
4. Thread-A: changes the same members updated by Thread-B
reported by hannken, thanks.
 1.63.2.4 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.63.2.3 02-Apr-2023  martin Backout attempts to build fix for ticket #128 for this file, needs
other changes.
 1.63.2.2 01-Apr-2023  martin Additionally pull up the following for ticket #128 to fix the build:

sys/dev/pci/if_vioif.c: revision 1.107
sys/dev/pci/virtio.c: revision 1.71

Use PRIuBUSSIZE to print bus_size_t variables.
 1.63.2.1 13-Jan-2023  martin Pull up following revision(s) (requested by jakllsch in ticket #48):

sys/dev/pci/virtio.c: revision 1.64
sys/dev/pci/virtio.c: revision 1.65

Fix dmamap_syncs more; the number of ring elements is vq->vq_num, not
sc->sc_nvqs.

Subtly adjust criteria for notification of Virtio devices in
VIRTIO_F_RING_EVENT_IDX mode.

This fixes stalls in the vioif(4) transmit path that would happen sooner
or later, depending on interface transmit utilization, and were
particularly noticable with a NetBSD guest transmitting to its x86 KVM
host at multi-gigabit speeds.
 1.81.2.1 02-Aug-2025  perseant Sync with HEAD
 1.83.2.1 19-Oct-2025  martin Pull up following revision(s) (requested by riastradh in ticket #62):

sys/dev/pci/virtio.c: revision 1.84

virtio(4): Use paravirt_membar_sync(9) where needed.

PR kern/59618: occasional virtio block device lock ups/hangs
 1.55 25-Sep-2024  christos Wrong byte order of config space write in big-endian (gorg)

In virtio_pci.c, the function virtio_pci_bus_space_write_8 writes
the first 4 bytes and second 4 bytes of an 8-byte value in the same
or swapped order within the device's config space depending on the
endianness of the system it is compiled for. However, the BUS_ADDR_LO32
and BUS_ADDR_HI32 always produce the least-significant and
most-significant 4 bytes of an 8-byte value, respectively, regardless
of the endianness of the system. Since virtio_pci_bus_space_write_8
is always used only for writing to little-endian parts of the config
space, the least significant 4 bytes must always be written to the
first 4 bytes in the config space value, and the most significant
4 bytes must always be written to the last 4 bytes of the config
space value. Therefore, swapping the byte order produces incorrect
behaviour on big-endian systems.

The incorrect behaviour seems to have been introduced in revision
1.19 of virtio_pci.c, which this change would mostly reversed
 1.54 25-Jun-2024  riastradh branches: 1.54.2;
virtio_pci.c: Use container_of, not cast.
 1.53 25-Jun-2024  riastradh virtio_pci.c: Sprinkle const.

No functional change intended.
 1.52 25-Jun-2024  riastradh virtio_pci.c: Sprinkle KNF.

- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
 1.51 25-Jun-2024  riastradh virtio_pci.c: Omit needless blank lines and commented code.

No functional change intended.
 1.50 25-Jun-2024  riastradh virtio_pci.c: Sort includes.

No functional change intended.
 1.49 25-Jun-2024  riastradh virtio@pci: Zero sc_bars_iosize[i] on unmap.

No functional change intended, but this makes the code less brittle.

Prompted by PR kern/58335.
 1.48 25-Jun-2024  riastradh virtio@pci: Don't detach on shutdown.

The virtio bus does not keep state in memory that needs to flushed to
persistent storage. Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).

Prompted by PR kern/58335.
 1.47 25-Jun-2024  riastradh virtio@pci: Nix useless sc_mapped_iosize.

This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.

Prompted by PR kern/58335.
 1.46 25-Jun-2024  riastradh virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.

PR kern/58335
 1.45 25-Jun-2024  riastradh virtio_pci.c: Nix trailing whitespace.
 1.44 19-Nov-2023  thorpej On alpha and sparc64, use VirtIO 1.0 and VIRTIO_F_ACCESS_PLATFORM so
that DMA to PCI-attached VirtIO devices works properly. This is needed
for Qemu to select the appropriate address space for PCI DMA.
 1.43 07-Jul-2023  rin virtio(4): Fix byte order of DMA data for armeb in the same manner as
aarch64eb.

Fix comments to explain what is going on for {arm,aarch64}eb on QEMU.
This is not due to QEMU bugs; it correctly configures everything for
little-endian environment, and we forcibly change byte order only for
CPU cores during kernel bootstrap.
 1.42 19-Apr-2023  yamaguchi Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc

pointed out by riastradh, thanks.
fixes PR/57357
 1.41 16-Apr-2023  riastradh virtio@pci: Fix assertion on detach.

If the child never attached in the first place, it's OK for it to not
have detached.

XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.

XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.

PR kern/57357

XXX pullup-10
 1.40 31-Mar-2023  yamaguchi Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().
 1.39 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.38 30-May-2022  riastradh branches: 1.38.4;
virtio at pci: Provide attribution in debug message.

Also make it only happen in the error case so success doesn't clutter
up the console output.
 1.37 13-Apr-2022  uwe virtio_pci: Don't use a cast for upcasting.

Same object code is generated.
 1.36 17-Mar-2022  uwe virtio_pci_bus_space_write_8: don't use bus_space_write_8.

The standard says:

4.1.3.1 Driver Requirements: PCI Device Layout

For device configuration access, the driver MUST use ... 32-bit
wide and aligned accesses for ... 64-bit wide fields. For 64-bit
fields, the driver MAY access each of the high and low 32-bit parts
of the field independently.

NB: "MAY" in this text refers to "independently" (i.e. the order of
accesses) not "32-bit" (which is restricted by the earlier "MUST").

Note also that virtio_{read,write}_device_config_8 in virtio.c already
uses two 32-bit accesses.
 1.35 17-Mar-2022  uwe virtio_pci.c: use PCI_BAR macro instead of open-coding it.
 1.34 14-Mar-2022  uwe virtio_pci_match: add TODO about PCI Revision ID.

The standard says:

Transitional devices MUST have a PCI Revision ID of 0.

Non-transitional devices SHOULD have a PCI Revision ID of 1 or higher.
Drivers MUST match any PCI Revision ID value.

so we must not check the revision id for non-transitional devices.
The code in attach relies on the revision being specifically(NB!) 1 so
this calls for a revision, but I can't test this properly at the
moment, so just leave a reminder. Comment change only.
 1.33 28-Oct-2021  yamaguchi virtio: stop reinit for safety when a device resetting is failed
 1.32 21-Oct-2021  yamaguchi virtio: reconfigure MSI-X vector on re-initialization

This may fix a problem that some interrupts, for example
link-state change of vioif(4) are not notified.
 1.31 21-Oct-2021  yamaguchi divide setup routine of virtio interrupts
into establishment and device configuration
 1.30 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.29 24-Apr-2021  thorpej branches: 1.29.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.28 05-Feb-2021  reinoud branches: 1.28.2;
Second round of cleaning up endian code. No more tailored code to maintain.
 1.27 28-Jan-2021  reinoud Rewrite and streamline virtio device config read/write and explicitly cater
for the Aarch64-eb bus problem with Qemu. This removes lots of bus_space
`magic' and cleans up the code.
 1.26 26-Jan-2021  reinoud Fix indexing bug in clean up code on error in virtio PCI v1.0 attach code.
Thanks go to Rin Okuyama for spotting it.
 1.25 24-Jan-2021  reinoud Remove incorrect comment. It would violate the specs.

VirtIO PCI v1.0 attachments can only happen on revision 1 devices as they have
a radical different register layout. Transitional devices have to use revision
0 and have to use the VirtIO PCI v0.9 attachment method but can allow for
features to be negotiated normally found in later versions.
 1.24 24-Jan-2021  thorpej Redefining bus_space functions in drivers is a bad idea, and we just
should't be in the habit of doing so. Besides, the previous "solutions"
still did not compile correctly, and this does, so let's be done with
this nonsense, shall we?
 1.23 24-Jan-2021  reinoud On error unmap the pci_mapreg_map()d regions using bus_space_unmap() as
suggested by jak@
 1.22 24-Jan-2021  reinoud Move definition of NMAPREG to the start
 1.21 24-Jan-2021  reinoud Prevent potential buffer over runs in number of BARS
 1.20 24-Jan-2021  christos Add a comment explaining why bus_space_write_8 is limited to virtio.
 1.19 23-Jan-2021  christos Provide a generic bus_space_write_8 function that is bi-endian.
 1.18 21-Jan-2021  reinoud Remove dependency on bus_space_write_8() for i386 and instead implement it as
two bus_space_write_4()'s as allowed in the spec.
 1.17 21-Jan-2021  martin Use PRIxBUSSIZE to print a bus_size_t value.
 1.16 20-Jan-2021  reinoud Remove the virtio child driver finalisation check KASSERT that, while it
should never trigger, a possible bug in a child driver shouldn't have to panic
the kernel. Instead report the internal error.
 1.15 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.14 23-Sep-2020  jakllsch branches: 1.14.2;
whitespace fix
 1.13 17-Sep-2020  jakllsch Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.

The virtio device config space moves out from under us when MSI-X
remains enabled, and/or INTx interrupts are masked if we don't ensure
this.

This un-breaks virtio devices that run out of MSI-X interrupts.
Particularly a problem on uniproc x86, where there are only 8 or 9
vectors available, allowing for only about 4 virtio devices to use
MSI-X.
 1.12 17-Sep-2020  jakllsch Ensure interrupt handles buffer is zeroed on allocation

Prevents crashes trying to deallocate interrupts at shutdown.

Found by kim and mlelstv, confirmed by me
 1.11 27-May-2020  yamaguchi Fix to allocate resources actuall used around interrupts
 1.10 25-May-2020  yamaguchi Set handlers implemented in child device of virtio(4) to virtqueue
instead of the commonized function
 1.9 25-May-2020  yamaguchi Register an interrupt handler for virtqueue to that for pci
to reduce function call
 1.8 25-May-2020  yamaguchi Remove VIRTIO_F_PCI_INTR_SOFTINT support for multiqueue

The functionality is no longer used by obsolating VIOIF_SOFTINT_INTR.
 1.7 27-Jan-2019  pgoyette branches: 1.7.4;
Merge the [pgoyette-compat] branch
 1.6 14-Jan-2019  yamaguchi Add multiqueue support, virtio(4)
 1.5 06-Jun-2018  jakllsch branches: 1.5.2;
fix up virtio module for current structure; add virtio_pci module
 1.4 02-Jun-2018  jakllsch Begin to detangle virtio from its PCI attachment
 1.3 02-Jun-2018  jakllsch fix CVS keyword in __KERNEL_RCSID
 1.2 15-Feb-2018  uwe branches: 1.2.2;
Explicitly enable PCI_COMMAND_MASTER_ENABLE and PCI_COMMAND_IO_ENABLE.
Recent versions of VirtualBox do not enable bus-mastering by default -
this will be fixed, but it doesn't hurt to do it ourselves too.
 1.1 02-Aug-2017  cherry branches: 1.1.2; 1.1.4;
Reorg the virtio(4) config(9) code to be explicitly pci specific.

We'll later use this for a non-pci virtio(4) usecase.

ok martin
 1.1.4.2 03-Dec-2017  jdolecek update from HEAD
 1.1.4.1 02-Aug-2017  jdolecek file virtio_pci.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.1.2.2 28-Aug-2017  skrll Sync with HEAD
 1.1.2.1 02-Aug-2017  skrll file virtio_pci.c was added on branch nick-nhusb on 2017-08-28 17:52:25 +0000
 1.2.2.2 18-Jan-2019  pgoyette Synch with HEAD
 1.2.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.7.4.2 20-Sep-2020  martin Pull up following revision(s) (requested by jakllsch in ticket #1090):

sys/dev/pci/virtio_pci.c: revision 1.13

Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.

The virtio device config space moves out from under us when MSI-X
remains enabled, and/or INTx interrupts are masked if we don't ensure
this.

This un-breaks virtio devices that run out of MSI-X interrupts.
Particularly a problem on uniproc x86, where there are only 8 or 9
vectors available, allowing for only about 4 virtio devices to use
MSI-X.
 1.7.4.1 20-Sep-2020  martin Pull up following revision(s) (requested by jakllsch in ticket #1089):

sys/dev/pci/virtio_pci.c: revision 1.12

Ensure interrupt handles buffer is zeroed on allocation
Prevents crashes trying to deallocate interrupts at shutdown.

Found by kim and mlelstv, confirmed by me
 1.14.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.28.2.1 27-Mar-2021  thorpej - config_found_ia() -> config_found().
- virtio only carries a single interface attribute, so no need to
specify it explicitly.
 1.29.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.38.4.6 31-Dec-2024  snj Pull up following revision(s) (requested by martin in ticket #1032):
sys/dev/pci/virtioreg.h: 1.13
sys/dev/pci/virtio_pci.c: 1.44
Define the VIRTIO_F_ACCESS_PLATFORM, VIRTIO_F_RING_PACKED,
VIRTIO_F_ORDER_PLATFORM, and VIRTIO_F_SR_IOV feature bits.
--
On alpha and sparc64, use VirtIO 1.0 and VIRTIO_F_ACCESS_PLATFORM so
that DMA to PCI-attached VirtIO devices works properly. This is needed
for Qemu to select the appropriate address space for PCI DMA.
 1.38.4.5 28-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1018):

sys/dev/pci/virtio_pci.c: revision 1.55

Wrong byte order of config space write in big-endian (gorg)

In virtio_pci.c, the function virtio_pci_bus_space_write_8 writes
the first 4 bytes and second 4 bytes of an 8-byte value in the same
or swapped order within the device's config space depending on the
endianness of the system it is compiled for. However, the BUS_ADDR_LO32
and BUS_ADDR_HI32 always produce the least-significant and
most-significant 4 bytes of an 8-byte value, respectively, regardless
of the endianness of the system. Since virtio_pci_bus_space_write_8
is always used only for writing to little-endian parts of the config
space, the least significant 4 bytes must always be written to the
first 4 bytes in the config space value, and the most significant
4 bytes must always be written to the last 4 bytes of the config
space value. Therefore, swapping the byte order produces incorrect
behaviour on big-endian systems.

The incorrect behaviour seems to have been introduced in revision
1.19 of virtio_pci.c, which this change would mostly reversed
 1.38.4.4 02-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #914):

sys/dev/pci/virtio_pci.c: revision 1.50
sys/dev/pci/virtio_pci.c: revision 1.51
sys/dev/pci/virtio_pci.c: revision 1.52
sys/dev/pci/virtio_pci.c: revision 1.53
sys/dev/pci/virtio_pci.c: revision 1.54
sys/dev/pci/vioscsi.c: revision 1.35
sys/dev/pci/ld_virtio.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.34
sys/dev/virtio/viocon.c: revision 1.9
sys/dev/pci/ld_virtio.c: revision 1.35
sys/dev/pci/virtio.c: revision 1.80
sys/dev/pci/virtio.c: revision 1.81
sys/dev/pci/virtio.c: revision 1.82
sys/dev/pci/virtio_pci.c: revision 1.45
sys/dev/pci/virtio_pci.c: revision 1.46
sys/dev/pci/virtio_pci.c: revision 1.47
sys/dev/pci/virtio_pci.c: revision 1.48
sys/dev/pci/virtio_pci.c: revision 1.49
sys/dev/pci/virtio.c: revision 1.79

A single SCSI request may require multiple slots in the virtio queue
but the queue isn't sized for the theoretical maximum. So just use
XS_BUSY to pace the scsipi layer.

viocon(4): Show error in assertion failure.

virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix
corrupted read for, e.g., sc_taglen for vio9p(4).

As described as comments in virtio_pci.c, big-endian aarch64 and
armv7 (armeb) are somewhat special. At the moment, all supported
virtual/real machines are configured as little-endian, and only
CPU cores are switched to big-endian mode during early boot stage.

Most peripheral buses for armeb are LSB as a result, and their
default bus_space(9) functions swap byte-order. Therefore, PIOed
data from memory-mapped devices, as well as pci(4) ones, are
actually LSB, but observed as MSB for armeb.

Therefore, we should not swap byte-order further in
virtio_read_device_config_le_[24] on armeb.

See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
fix spelling mistakes, mainly in comments and log messages.

Split KASSERT(A && B) into KASSERT(A); KASSERT(B).

Fix typo in error message.

Modify a confused expression in ld_virtio_attach().

VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments,
so I rename it to VIRTIO_BLK_CTRL_SEGMENTS.
PR kern/57981.

ld@virtio(4): Fix maximum size parameters.
- SEG_MAX is the maximum number of segments.
- SIZE_MAX is the maximum number of bytes in a single segment.
The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX.
=> Don't add two extra segments in the dmamap vr_payload for the
header and status -- we already have a separate dmamap vr_cmdsts
for that.
=> Don't recalculate payload dmamap parameters based on division by
NBPG, just use the ones specified by the host.
=> Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >=
MAXPHYS.
Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to
clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it
determines the dmamap sizes and bounce buffer allocation and there's
no sense in allocating those larger than ld will use anyway.
PR kern/58338

virtio_pci.c: Nix trailing whitespace.

virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.
PR kern/58335

virtio@pci: Nix useless sc_mapped_iosize.
This appears to have been a mistaken attempt to pass the subregion
length through to bus_space_unmap, which doesn't make any sense --
bus_space_subregion does not allocate anything and the resulting
handle must not be passed to bus_space_unmap.

Once we pass the size that was actually returned by pci_mapreg_map to
bus_space_unmap, which matches the size passed internally by
pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
and can be flushed.
Prompted by PR kern/58335.

virtio@pci: Don't detach on shutdown.
The virtio bus does not keep state in memory that needs to flushed to
persistent storage. Typically DVF_DETACH_SHUTDOWN is only needed by,
e.g., disk drivers to flush disk caches (although really, vfs sync
should do that anyway, so maybe we should just nix the option
altogether).
Prompted by PR kern/58335.

virtio@pci: Zero sc_bars_iosize[i] on unmap.
No functional change intended, but this makes the code less brittle.
Prompted by PR kern/58335.

virtio_pci.c: Sort includes.
No functional change intended.

virtio_pci.c: Omit needless blank lines and commented code.
No functional change intended.

virtio_pci.c: Sprinkle KNF.
- No parameter names in function prototypes.
- Fix indentation.
- Break overlong lines.
- Blank line between declarations and rest of block.
virtio_pci.c: Sprinkle const.
No functional change intended.

virtio_pci.c: Use container_of, not cast.
virtio(4): Assert child attach finished before we allow queueing.
Should help catch mistakes like:
PR kern/58555: Kernel panic during boot when using viocon with PCIe
 1.38.4.3 09-Jul-2023  martin Pull up following revision(s) (requested by rin in ticket #229):

sys/dev/pci/virtio_pci.c: revision 1.43
sys/dev/virtio/virtio_mmio.c: revision 1.11

virtio(4): Fix byte order of DMA data for armeb in the same manner as
aarch64eb.

Fix comments to explain what is going on for {arm,aarch64}eb on QEMU.
This is not due to QEMU bugs; it correctly configures everything for
little-endian environment, and we forcibly change byte order only for
CPU cores during kernel bootstrap.
 1.38.4.2 03-Jun-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #186):

sys/dev/pci/virtio_pci.c: revision 1.41
sys/dev/pci/virtio_pci.c: revision 1.42
sys/dev/virtio/virtio_mmio.c: revision 1.10
sys/dev/pci/virtiovar.h: revision 1.29
sys/dev/pci/virtio.c: revision 1.75
sys/dev/pci/virtio.c: revision 1.76
sys/dev/pci/virtio.c: revision 1.77
sys/dev/pci/virtio.c: revision 1.78

virtio@pci: Fix assertion on detach.

If the child never attached in the first place, it's OK for it to not
have detached.

XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.

XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.

PR kern/57357


Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc
pointed out by riastradh, thanks.
fixes PR/57357

Fix not to allocate unnecessary descriptor
fixes PR/57358

virtio(4): change variable name, nfc

virtio(4): change members of struct vring_desc_extra before free a slot

This prevents the following race condition.
1. Thread-A: calls virtio_dequeue_commit() and
puts a slot into free descriptor chain in vq_free_slot()
2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A
3. Thread-B: calls virtio_enqueue_reserve() and
changes desc_base and desc_free_idx for the slot
4. Thread-A: changes the same members updated by Thread-B
reported by hannken, thanks.
 1.38.4.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.54.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 20-Jan-2021  reinoud branches: 1.1.4;
Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.1.4.2 03-Apr-2021  thorpej Sync with HEAD.
 1.1.4.1 20-Jan-2021  thorpej file virtio_pcireg.h was added on branch thorpej-futex on 2021-04-03 22:28:49 +0000
 1.14 26-Jul-2025  martin PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.13 19-Nov-2023  thorpej branches: 1.13.2;
Define the VIRTIO_F_ACCESS_PLATFORM, VIRTIO_F_RING_PACKED,
VIRTIO_F_ORDER_PLATFORM, and VIRTIO_F_SR_IOV feature bits.
 1.12 29-Mar-2023  riastradh virtio(4): Use flexible array members, not zero-length arrays.

This enables the compiler to detect sizeof mistakes like
PR kern/57304.
 1.11 15-Oct-2022  riastradh branches: 1.11.2;
virtio(4): Use __BIT, not inline shift.

Reduces need for cast.
 1.10 13-Apr-2022  uwe virtio: Use UINT64_C() instead of explicit ULL suffix.
 1.9 13-Apr-2022  uwe virtio: G/c accidentally committed comment in previous.

The format spec for the V1 bit was to be committed as a separate
followup commit, but I forgot to take it out. Sorry...
 1.8 13-Apr-2022  uwe virtio: use the new syntax for snprintb(3) format strings.

The old syntax is limited to 32 bits only (and has 1-based bit numbers
which is rather incovenient too).
 1.7 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.6 29-Oct-2015  christos branches: 1.6.32;
Add vioscsi, compile tested only (toxic)
 1.5 27-Oct-2015  christos add the common flag bits
 1.4 26-Oct-2015  ozaki-r Support MSI-X in virtio

Currently only vioif(4) uses the feature.

knakahara@ helped to migrate to pci_intr_alloc(9). Thanks!
 1.3 04-May-2015  ozaki-r Fix configuration offset when MSI is enabled

24 is correct.
 1.2 06-Dec-2013  yamt branches: 1.2.4; 1.2.6; 1.2.10;
virtio: move a comment to a more appropriate place

no functional changes.
 1.1 30-Oct-2011  hannken branches: 1.1.2; 1.1.8; 1.1.14; 1.1.18;
Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.1.18.1 18-May-2014  rmind sync with head
 1.1.14.2 03-Dec-2017  jdolecek update from HEAD
 1.1.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.2 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.1.8.1 30-Oct-2011  riz file virtioreg.h was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.10.1 18-Jan-2017  skrll Sync with netbsd-5
 1.2.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.6.1 06-Jun-2015  skrll Sync with HEAD
 1.2.4.1 23-Dec-2016  snj Pull up following revision(s) (requested by bsiegert in ticket #1338):
sys/arch/amd64/conf/GENERIC: revision 1.418
sys/dev/pci/files.pci: revision 1.379
sys/dev/pci/vioscsi.c: revisions 1.1-1.8
sys/dev/pci/vioscsireg.h: revision 1.1
sys/dev/pci/virtioreg.h: revisions 1.5, 1.6
add the common flag bits
--
Add vioscsi, compile tested only (toxic)
--
this is working now, remove debugging.
--
add vioscsi
--
kill some more debugging.
--
Fake mode sense data for illegal targets. qemu reports 256 targets...
--
fix the status return.
--
Use SCSIPI_CHAN_NOSETTLE.
--
vioscsi_req_get()/virtio_enqueue_prep() failing is actually perfectly
normal - observed failures included 10, 27, 61 in-flight commands,
so probably depends on particular command mix; return with
XS_RESOURCE_SHORTAGE rather then panic
do vioscsi_req_put() when initial bus_dmamap_load() fails, as suggested
by the XXX; the vq_done hook is called by virtio, but in that case we
never get to commit the request to it
--
react on ADAPTER_REQ_SET_XFER_MODE so that we set tagged queuing
pass tag type and set id
 1.6.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.11.2.2 31-Dec-2024  snj Pull up following revision(s) (requested by martin in ticket #1032):
sys/dev/pci/virtioreg.h: 1.13
sys/dev/pci/virtio_pci.c: 1.44
Define the VIRTIO_F_ACCESS_PLATFORM, VIRTIO_F_RING_PACKED,
VIRTIO_F_ORDER_PLATFORM, and VIRTIO_F_SR_IOV feature bits.
--
On alpha and sparc64, use VirtIO 1.0 and VIRTIO_F_ACCESS_PLATFORM so
that DMA to PCI-attached VirtIO devices works properly. This is needed
for Qemu to select the appropriate address space for PCI DMA.
 1.11.2.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.30 26-Jul-2025  martin PR 58681: add a port of the OpenBSD viogpu(4) driver written by
Joshua Stein <jcs@openbsd.org>.
Port by George Matsumura with help from Jiaxun Yang.
 1.29 19-Apr-2023  yamaguchi branches: 1.29.6;
Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc

pointed out by riastradh, thanks.
fixes PR/57357
 1.28 31-Mar-2023  yamaguchi Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().
 1.27 31-Mar-2023  yamaguchi Use descriptor chain for free slots instead of vq_entry list

Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.
The chain is also used for unused descriptors to make virtio(4)
simpler.
 1.26 23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.25 23-Mar-2023  yamaguchi Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.
 1.24 24-Mar-2022  andvar branches: 1.24.4;
s/interupt/interrupt/ in comments.
also add missing RCS ID in bcm53xx_reg.h and fix one more typo in there.
 1.23 28-Oct-2021  yamaguchi virtio: stop reinit for safety when a device resetting is failed
 1.22 21-Oct-2021  yamaguchi virtio: reconfigure MSI-X vector on re-initialization

This may fix a problem that some interrupts, for example
link-state change of vioif(4) are not notified.
 1.21 21-Oct-2021  yamaguchi divide setup routine of virtio interrupts
into establishment and device configuration
 1.20 05-Feb-2021  reinoud Second round of cleaning up endian code. No more tailored code to maintain.
 1.19 28-Jan-2021  reinoud Rewrite and streamline virtio device config read/write and explicitly cater
for the Aarch64-eb bus problem with Qemu. This removes lots of bus_space
`magic' and cleans up the code.
 1.18 20-Jan-2021  reinoud Remove the virtio child driver finalisation check KASSERT that, while it
should never trigger, a possible bug in a child driver shouldn't have to panic
the kernel. Instead report the internal error.
 1.17 20-Jan-2021  reinoud Add VirtIO PCI v1.0 attachments and fix the drivers affected.

The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and
tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64,
aarch64 and aarch64-eb. ACPI/FDT attachments also tested on
aarch64/aarch64-eb.

Known issues

* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI
attachment. PCI and ACPI/FDT attachment works on aarch64-eb.

* virtio on sparc64 attaches but is it not functioning though not a
regression.
 1.16 25-May-2020  yamaguchi branches: 1.16.2;
Set handlers implemented in child device of virtio(4) to virtqueue
instead of the commonized function
 1.15 25-May-2020  yamaguchi Register an interrupt handler for virtqueue to that for pci
to reduce function call
 1.14 25-May-2020  yamaguchi Remove VIRTIO_F_PCI_INTR_SOFTINT support for multiqueue

The functionality is no longer used by obsolating VIOIF_SOFTINT_INTR.
 1.13 14-Jan-2019  yamaguchi Add multiqueue support, virtio(4)
 1.12 15-Jun-2018  jakllsch branches: 1.12.2;
Add cfprint_t virtiobusprint() and use it for virtio_mmio.
 1.11 02-Jun-2018  jakllsch Begin to detangle virtio from its PCI attachment
 1.10 02-Aug-2017  cherry branches: 1.10.2;
Reorg the virtio(4) config(9) code to be explicitly pci specific.

We'll later use this for a non-pci virtio(4) usecase.

ok martin
 1.9 26-Mar-2017  martin Backout previous, no need for these accessor in MD code
 1.8 26-Mar-2017  martin Provide an accessor for the pci attach args of a virtio device (if
available - future non-pci attachments may return NULL).
Sparc64 MD code needs this to match the OF node of the virtio device
for boot device recognition.
 1.7 25-Mar-2017  jdolecek reorganize the attachment process for virtio child devices, so that
more common code is shared among the drivers, and it's possible for
the drivers to be correctly dynamically loaded; forbid direct access
to struct virtio_softc from the child driver code
 1.6 27-Sep-2016  pgoyette branches: 1.6.2;
Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.5 26-Oct-2015  ozaki-r branches: 1.5.2;
Support MSI-X in virtio

Currently only vioif(4) uses the feature.

knakahara@ helped to migrate to pci_intr_alloc(9). Thanks!
 1.4 19-Dec-2014  ozaki-r Implement softint-based interrupt handling in if_vioif

Softint-based interrupt handling is considered as a future direction
of the (network) device driver architecture in NetBSD. pq3etsec of
ppc is already implemented based on the architecture (unlike pq3etsec,
this change doesn't include softint-based if_start). In this
architecture, a hardware interrupt handler just schedules a softint
and the softint performs actual interrupt processing. It reduces
processing in hardware interrupt context and allows Layer 2 network
stack (e.g., bridge, vlan and even bpf) run in softint context,
which makes it easy to implement fine-grain locking in the layer.

This is an experimental implementation of the architecture in if_viof.

virtio introduces a new flag VIRTIO_F_PCI_INTR_SOFTINT. If a driver
of virtio sets it to sc_flags of virtio_softc, virtio calls
softint_schedule in virtio_intr instead of directly calling the
interrupt handler of the driver.

When VIOIF_SOFTINT_INTR is on, vioif doesn't use the existing softint
(vioif_rx_softint) that is called from vioif_rx_vq_done. Because
vioif_rx_softint already runs in softint context and another softint
isn't needed. This change actually improves performance in some cases.

The feature is disabled by default and enabled when SOFTINT_INTR is
set somewhere (normally in a kernel configuration).
 1.3 22-Jul-2014  ozaki-r branches: 1.3.4;
Introduce VIRTIO_F_PCI_INTR_MPSAFE for virtio

It is set by a child driver, e.g., if_vioif. If set, virtio sets
PCI_INTR_MPSAFE for pci_intr_establish.
 1.2 06-Dec-2013  yamt branches: 1.2.2;
virtio: move a comment to a more appropriate place

no functional changes.
 1.1 30-Oct-2011  hannken branches: 1.1.2; 1.1.8; 1.1.14; 1.1.18;
Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org>
with minor changes to make it compile an run on -current. This driver
speeds up disk and network access in virtual environments like KVM.

Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.

See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
 1.1.18.1 18-May-2014  rmind sync with head
 1.1.14.2 03-Dec-2017  jdolecek update from HEAD
 1.1.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.2 25-Jan-2012  riz Pull up following revision(s) (requested by hannken in ticket #1715):
- Be robust against an invalid timer period value.
sys/dev/ic/hpetreg.h Rev. 1.4
sys/dev/ic/hpet.c Rev. 1.8

- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK
sys/arch/x86/include/i82489reg.h Rev. 1.11

- Add virtio driver - speed up disk and network access in virtual environments
sys/arch/i386/conf/GENERIC Rev. 1.1055
sys/arch/i386/conf/ALL Rev. 1.325
sys/arch/amd64/conf/GENERIC Rev. 1.338
sys/dev/pci/files.pci Rev. 1.350
sys/dev/pci/if_vioif.c Rev. 0-1.2
sys/dev/pci/ld_virtio.c Rev. 0-1.4
sys/dev/pci/viomb.c Rev. 0-1.1
sys/dev/pci/virtio.c Rev. 0-1.3
sys/dev/pci/virtioreg.h Rev. 0-1.1
sys/dev/pci/virtiovar.h Rev. 0-1.1
distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358
share/man/man4/Makefile Rev. 1.573 and 1.575
share/man/man4/ld.4 Rev. 1.19
share/man/man4/virtio.4 Rev. 0-1.4
share/man/man4/vioif.4 Rev. 0-1.2
share/man/man4/viomb.4 Rev. 0-1.2

Allow NetBSD to run unmodified under Linux/kvm.
 1.1.8.1 30-Oct-2011  riz file virtiovar.h was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.2.1 10-Aug-2014  tls Rebase.
 1.3.4.4 28-Aug-2017  skrll Sync with HEAD
 1.3.4.3 05-Oct-2016  skrll Sync with HEAD
 1.3.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.4.1 06-Apr-2015  skrll Sync with HEAD
 1.5.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.5.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.6.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.10.2.2 18-Jan-2019  pgoyette Synch with HEAD
 1.10.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.12.2.1 10-Jun-2019  christos Sync with HEAD
 1.16.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.24.4.2 03-Jun-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #186):

sys/dev/pci/virtio_pci.c: revision 1.41
sys/dev/pci/virtio_pci.c: revision 1.42
sys/dev/virtio/virtio_mmio.c: revision 1.10
sys/dev/pci/virtiovar.h: revision 1.29
sys/dev/pci/virtio.c: revision 1.75
sys/dev/pci/virtio.c: revision 1.76
sys/dev/pci/virtio.c: revision 1.77
sys/dev/pci/virtio.c: revision 1.78

virtio@pci: Fix assertion on detach.

If the child never attached in the first place, it's OK for it to not
have detached.

XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.

XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.

PR kern/57357


Use enumeration for state of a child driver instead of flags
and check its detaching by using sc->sc_child in virtio_softc
pointed out by riastradh, thanks.
fixes PR/57357

Fix not to allocate unnecessary descriptor
fixes PR/57358

virtio(4): change variable name, nfc

virtio(4): change members of struct vring_desc_extra before free a slot

This prevents the following race condition.
1. Thread-A: calls virtio_dequeue_commit() and
puts a slot into free descriptor chain in vq_free_slot()
2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A
3. Thread-B: calls virtio_enqueue_reserve() and
changes desc_base and desc_free_idx for the slot
4. Thread-A: changes the same members updated by Thread-B
reported by hannken, thanks.
 1.24.4.1 13-May-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #139):

sys/dev/pci/vioscsi.c: revision 1.31
sys/dev/pci/vio9p.c: revision 1.10
sys/dev/pci/vioscsi.c: revision 1.32
sys/dev/pci/vio9p.c: revision 1.11
sys/dev/pci/vioscsi.c: revision 1.33
sys/dev/pci/ld_virtio.c: revision 1.31
sys/dev/virtio/viocon.c: revision 1.6
sys/dev/pci/vioscsi.c: revision 1.34
sys/dev/pci/ld_virtio.c: revision 1.32
sys/dev/virtio/viocon.c: revision 1.7
sys/dev/virtio/viocon.c: revision 1.8
sys/dev/pci/vioscsi.c: revision 1.36
sys/dev/pci/virtioreg.h: revision 1.12
sys/dev/pci/viornd.c: revision 1.19
sys/dev/pci/virtio.c: revision 1.66
sys/dev/pci/virtio.c: revision 1.67
sys/dev/pci/virtio.c: revision 1.68
sys/dev/pci/if_vioif.c: revision 1.103
sys/dev/pci/virtio.c: revision 1.69
sys/dev/pci/if_vioif.c: revision 1.104
sys/dev/pci/virtio_pci.c: revision 1.40
sys/dev/virtio/virtio_mmio.c: revision 1.8
sys/dev/virtio/virtio_mmio.c: revision 1.9
sys/dev/pci/viomb.c: revision 1.14
sys/dev/pci/viomb.c: revision 1.15
sys/dev/pci/viomb.c: revision 1.17
sys/dev/pci/viornd.c: revision 1.20
sys/dev/pci/viornd.c: revision 1.21
sys/dev/pci/virtiovar.h: revision 1.25
sys/dev/pci/virtiovar.h: revision 1.26
sys/dev/pci/virtiovar.h: revision 1.27
sys/dev/pci/virtiovar.h: revision 1.28
sys/dev/pci/virtio.c: revision 1.70
sys/dev/pci/virtio.c: revision 1.71
sys/dev/pci/virtio.c: revision 1.72
sys/dev/pci/virtio.c: revision 1.73
sys/dev/pci/virtio.c: revision 1.74
sys/dev/pci/virtio_pci.c: revision 1.39

Set virtqueues in virtio_child_attach_finish

The number of virtqueue maybe change in a part of VirtIO devices
(e.g. vioif(4)). And it is fixed after negotiation of features.
So the configuration is moved into the function.

viocon(4): fix not to allocate unused virtqueue

viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.

Added functions to set interrupt handler and index into virtqueue

Added check of pointer for allocated memory before release of resource

Setup virtqueues after registering them to virtio_softc
restore fetch of qsize.

Mark as MPSAFE.

virtio(4): Avoid name collision with global intrhand on sparc64.

Pacifies -Werror=shadow.
No functional change intended.

Use PRIuBUSSIZE to print bus_size_t variables.

virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero;
likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this
and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for
trouble like this, and C99 has a standard way to express what we're
actually trying to get at it, flexible array members.
PR kern/57304

virtio(4): Use flexible array members, not zero-length arrays.
This enables the compiler to detect sizeof mistakes like
PR kern/57304.

Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to
avail ring or used ring are already chained. But it was not used
for unused descriptors and another linked list structure named
vq_entry was used.

The chain is also used for unused descriptors to make virtio(4)
simpler.

Added flags to store status of attaching a virtio device

This prevents a panic on reboot after a virtio device had called
virtio_child_attach_failed().

Fix wrong variable names
This fixes build errors in virtio_mmio.c
 1.29.6.1 02-Aug-2025  perseant Sync with HEAD
 1.56 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.55 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.54 24-Apr-2021  thorpej branches: 1.54.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.53 22-Dec-2019  thorpej branches: 1.53.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.52 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.51 11-Jul-2016  msaitoh branches: 1.51.16; 1.51.18;
KNF. No functional change.
 1.50 16-Sep-2015  macallan prop_dictionary_get_bool() doesn't return FALSE if the property doesn't
exist, so initialize things first.
No more console stealing on sparc64.
 1.49 24-Jul-2014  macallan branches: 1.49.4;
fix a bunch of bugs & tpyos:
- keep track of registers being mapped or not to avoid double (un)mapping when
switching between WSDISPLAYIO_MODE_DUMBFB and _MAPPED
- distinguish between _DUMBFB and _MAPPED
- actually map the framebuffer at offset 0 in _DUMBFB
- set BUS_SPACE_MAP_PREFETCHABLE when mmap()ing video memory
now Xorg + xf86-video-wsfb work on top of voodoofb
 1.48 29-Mar-2014  christos branches: 1.48.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.47 19-Nov-2013  macallan (hopefully) shut up warnings about set-but-unused variables.
 1.46 09-Oct-2013  macallan support WSDISPLAYIO_GET_FBINFO
 1.45 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.44 02-Jul-2013  joerg Fix memset arguments.
 1.43 09-Nov-2012  rkujawa branches: 1.43.2;
Differentiate between Voodoo 3 and Voodoo Banshee (MAX_CLOCK).
Ok'd by macallan@.
 1.42 09-Nov-2012  rkujawa The voodoofb driver also works with Voodoo Banshee. Tested using card from
martin@. Should be modified to take different MAX_CLOCK value into account.
 1.41 23-Apr-2012  macallan branches: 1.41.2;
initialize a variable before using it
found by uebayasi@
now why did gcc warn him on x86 but not me on macppc?
 1.40 15-Mar-2012  macallan we need to zap the glyph cache when re-initializing after X
 1.39 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.38 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.37 25-Jan-2012  macallan add a simple glyph cacheing scheme
Glyphs which use the default attribute will be saved into offscreen video
memory the first time they're used and subsequent uses will just copy them
from there instead of rendering them every time.
This should give a nice speedup especially on slow CPUs.
 1.36 25-Jan-2012  macallan sprinkle sc_ to make it consistent
 1.35 22-Jan-2012  macallan clear the screen when returning from X
 1.34 19-Jan-2012  macallan support anti-aliased fonts in 8 bit using host blits
 1.33 18-Jan-2012  macallan do some mode validation - for now reject everything above 1680x1200 until
I find out why these don't work ( 1680x1200 works but not 1920x1080 ).
Also use sync polarity info from videomode instead of guessing.
Finally, if there is no useble preferred mode, be a little smarter trying
to find the next best mode.
 1.32 17-Jan-2012  macallan we don't access video memory directly, no need to map it
 1.31 17-Jan-2012  macallan support DDC2, pick an appropriate video mode if a data are found
 1.30 17-Jan-2012  macallan get rid of HAVE_OPENFIRMWARE
 1.29 11-Jan-2012  macallan use rasops_init(0, 0)
 1.28 08-Oct-2011  kiyohara branches: 1.28.2; 1.28.6;
Change get parameters(width,height...) from prop_dictionary, like genfb. tested on ofppc only.
 1.27 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.26 25-Dec-2010  macallan branches: 1.26.2; 1.26.4;
remove some ancient, unused debug code
 1.25 16-Dec-2010  cegger ioctl: KNF switch-case, remove useless brackets
 1.24 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.23 12-Oct-2010  macallan make higher resolutions than 1024x768 work
 1.22 04-May-2010  macallan use alternate font if available ( for autogenerated box drawing characters )
 1.21 26-Nov-2009  njoly branches: 1.21.2; 1.21.4;
Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.20 20-Aug-2009  macallan use vcons_replay_msgbuf() when appropriate
 1.19 06-May-2009  elad Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.18 09-Jul-2008  joerg branches: 1.18.8;
- device/softc split
 1.17 08-May-2008  macallan branches: 1.17.2; 1.17.4;
nuke clause 3
 1.16 05-May-2008  jmcneill branches: 1.16.2;
Change autoconf message 'direct rendering on dev unsupported' to
the more accurate 'drm at dev not configured'.
 1.15 10-Apr-2008  cegger branches: 1.15.2; 1.15.4;
use aprint_*_dev and device_xname
 1.14 24-Mar-2008  elad Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.

This and similar requests will be replaced Soon, but these two in
particular should be pulled up to netbsd-4, and to allow doing that
smoothly, we're first introducing the "issuser" version.

Discussed with and okay macallan@.
 1.13 27-Feb-2008  macallan get rid of the last #ifdef macppc and use PCI_MAGIC_IO_RANGE to select
at which offset we mmap PCI IO space
 1.12 01-Dec-2007  ad branches: 1.12.10; 1.12.14;
Back out previous.
 1.11 01-Dec-2007  ad Noisy printfs.
 1.10 12-Jun-2007  xtraeme branches: 1.10.6; 1.10.8; 1.10.14;
Fix a typo in voodoofb_drm_unmap(), requested by garbled.
cvs: ----------------------------------------------------------------------
 1.9 27-Mar-2007  jmcneill Make this compatible with tdfxdrm.
 1.8 04-Mar-2007  christos branches: 1.8.2; 1.8.4; 1.8.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 20-Jan-2007  he branches: 1.7.2;
Unify the declaration of OF_interpret() between sparc{,64} and macppc
by adding the "nargs" argument to the macppc version, and fix the macppc
ports uses of OF_interpret() accordingly.

Also move the declaration of OF_interpt() from macppc's autoconf.h to
ofw/openfirm.h. This fixes the build of the macppc port.

Approved by macallan@.
 1.6 13-Jan-2007  cube Complete initializer, and make it compile on (lesser?) archs that don't
have OpenFirmware.
 1.5 04-May-2006  simonb branches: 1.5.4; 1.5.6; 1.5.10; 1.5.14; 1.5.16; 1.5.20;
Add missing "return 0;" from WSDISPLAYIO_SMODE case in voodoofb_ioctl().
 1.4 15-Apr-2006  jmmv branches: 1.4.2; 1.4.4;
Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.3 12-Apr-2006  macallan whitespace nits
( no, perry didn't steal my account )
 1.2 12-Apr-2006  jmmv Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.1 11-Apr-2006  macallan A driver for 3Dfx Voodoo3 graphics boards, may or may not work with Voodoo4,
Voodoo5 or Banshee boards.

So far it supports:
- full acceleration in 8bit graphics mode
- video mode switching
- virtual consoles via vcons

So far it hasn't been tested on anything else than macppc and even there it
needs a hack to overload ofb.

TODO:
- test on i386
- don't hardcode video mode
 1.4.4.3 01-Jun-2006  kardel Sync with head.
 1.4.4.2 22-Apr-2006  simonb Sync with head.
 1.4.4.1 15-Apr-2006  simonb file voodoofb.c was added on branch simonb-timecounters on 2006-04-22 11:39:16 +0000
 1.4.2.3 11-May-2006  elad sync with head
 1.4.2.2 19-Apr-2006  elad sync with head.
 1.4.2.1 15-Apr-2006  elad file voodoofb.c was added on branch elad-kernelauth on 2006-04-19 03:25:38 +0000
 1.5.20.2 24-Mar-2008  bouyer Pull up following revision(s) (requested by elad in ticket #1107):
sys/dev/pci/machfb.c: revision 1.51
sys/dev/pci/voodoofb.c: revision 1.14
Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.
Discussed with and okay macallan@.
 1.5.20.1 10-Mar-2007  bouyer branches: 1.5.20.1.2; 1.5.20.1.6;
Apply patch (requested by macallan in ticket #503):
sys/dev/pci/voodoofb.c patch
Add missing include; should fix macppc build.
 1.5.20.1.6.1 24-Mar-2008  bouyer Pull up following revision(s) (requested by elad in ticket #1107):
sys/dev/pci/machfb.c: revision 1.51
sys/dev/pci/voodoofb.c: revision 1.14
Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.
Discussed with and okay macallan@.
 1.5.20.1.2.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.5.16.2 09-Sep-2006  rpaulo sync with head
 1.5.16.1 04-May-2006  rpaulo file voodoofb.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.5.14.1 01-Feb-2007  ad Sync with head.
 1.5.10.5 17-Mar-2008  yamt sync with head.
 1.5.10.4 03-Sep-2007  yamt sync with head.
 1.5.10.3 26-Feb-2007  yamt sync with head.
 1.5.10.2 21-Jun-2006  yamt sync with head.
 1.5.10.1 04-May-2006  yamt file voodoofb.c was added on branch yamt-lazymbuf on 2006-06-21 15:05:07 +0000
 1.5.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.6.1 04-May-2006  tron file voodoofb.c was added on branch peter-altq on 2006-05-24 15:50:28 +0000
 1.5.4.2 24-May-2006  yamt sync with head.
 1.5.4.1 04-May-2006  yamt file voodoofb.c was added on branch yamt-pdpolicy on 2006-05-24 10:58:01 +0000
 1.7.2.2 15-Apr-2007  yamt sync with head.
 1.7.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.6.1 29-Mar-2007  reinoud Pullup to -current
 1.8.4.1 11-Jul-2007  mjf Sync with head.
 1.8.2.2 15-Jul-2007  ad Sync with head.
 1.8.2.1 10-Apr-2007  ad Sync with head.
 1.10.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.8.1 23-Mar-2008  matt sync with HEAD
 1.10.6.1 03-Dec-2007  joerg Sync with HEAD.
 1.12.14.3 28-Sep-2008  mjf Sync with HEAD.
 1.12.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.10.1 24-Mar-2008  keiichi sync with head.
 1.15.4.6 11-Aug-2010  yamt sync with head.
 1.15.4.5 11-Mar-2010  yamt sync with head
 1.15.4.4 16-Sep-2009  yamt sync with head
 1.15.4.3 16-May-2009  yamt sync with head
 1.15.4.2 04-May-2009  yamt sync with head.
 1.15.4.1 16-May-2008  yamt sync with head.
 1.15.2.1 18-May-2008  yamt sync with head.
 1.16.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.16.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.4.1 19-Oct-2008  haad Sync with HEAD.
 1.17.2.1 18-Jul-2008  simonb Sync with head.
 1.18.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.4.2 05-Mar-2011  rmind sync with head
 1.21.4.1 30-May-2010  rmind sync with head
 1.21.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.21.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.26.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.26.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.6.3 29-Apr-2012  mrg sync to latest -current.
 1.28.6.2 05-Apr-2012  mrg sync to latest -current.
 1.28.6.1 18-Feb-2012  mrg merge to -current.
 1.28.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.28.2.2 23-May-2012  yamt sync with head.
 1.28.2.1 17-Apr-2012  yamt sync with head
 1.41.2.3 03-Dec-2017  jdolecek update from HEAD
 1.41.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.41.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.43.2.2 18-May-2014  rmind sync with head
 1.43.2.1 28-Aug-2013  rmind sync with head
 1.48.2.1 10-Aug-2014  tls Rebase.
 1.49.4.2 05-Oct-2016  skrll Sync with HEAD
 1.49.4.1 22-Sep-2015  skrll Sync with HEAD
 1.51.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.51.18.1 10-Jun-2019  christos Sync with HEAD
 1.51.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.53.10.2 31-Mar-2021  thorpej There are two interface attriubtues on this device, so we need to be
explcit about it in BOTH config_found() calls.
 1.53.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.54.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 21-Jan-2012  jakllsch Silence "large integer implicitly truncated to unsigned type" warning on LP64.
 1.3 19-Jan-2012  macallan support anti-aliased fonts in 8 bit using host blits
 1.2 18-Jan-2012  macallan do some mode validation - for now reject everything above 1680x1200 until
I find out why these don't work ( 1680x1200 works but not 1920x1080 ).
Also use sync polarity info from videomode instead of guessing.
Finally, if there is no useble preferred mode, be a little smarter trying
to find the next best mode.
 1.1 11-Apr-2006  macallan branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.14; 1.1.20; 1.1.110; 1.1.114;
A driver for 3Dfx Voodoo3 graphics boards, may or may not work with Voodoo4,
Voodoo5 or Banshee boards.

So far it supports:
- full acceleration in 8bit graphics mode
- video mode switching
- virtual consoles via vcons

So far it hasn't been tested on anything else than macppc and even there it
needs a hack to overload ofb.

TODO:
- test on i386
- don't hardcode video mode
 1.1.114.1 18-Feb-2012  mrg merge to -current.
 1.1.110.1 17-Apr-2012  yamt sync with head
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 11-Apr-2006  rpaulo file voodoofbreg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:52:19 +0000
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 11-Apr-2006  yamt file voodoofbreg.h was added on branch yamt-lazymbuf on 2006-06-21 15:05:07 +0000
 1.1.10.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.10.1 11-Apr-2006  tron file voodoofbreg.h was added on branch peter-altq on 2006-05-24 15:50:28 +0000
 1.1.8.2 24-May-2006  yamt sync with head.
 1.1.8.1 11-Apr-2006  yamt file voodoofbreg.h was added on branch yamt-pdpolicy on 2006-05-24 10:58:01 +0000
 1.1.4.2 22-Apr-2006  simonb Sync with head.
 1.1.4.1 11-Apr-2006  simonb file voodoofbreg.h was added on branch simonb-timecounters on 2006-04-22 11:39:16 +0000
 1.1.2.2 19-Apr-2006  elad sync with head.
 1.1.2.1 11-Apr-2006  elad file voodoofbreg.h was added on branch elad-kernelauth on 2006-04-19 03:25:38 +0000
 1.20 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.19 15-Jul-2025  macallan no need to provide our own i2c bus lock and acquire/releade methods anymore
 1.18 25-Sep-2022  thorpej branches: 1.18.10;
Remove unnecessary include of <sys/malloc.h>.
 1.17 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.16 24-Apr-2021  thorpej branches: 1.16.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.15 22-Dec-2019  thorpej branches: 1.15.10;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.14 21-Apr-2019  maya wether -> whether
 1.13 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.12 16-Nov-2016  macallan branches: 1.12.14; 1.12.16;
pass clockframe aropund in voyager_intr()
 1.11 01-Jan-2016  macallan branches: 1.11.2;
zero out struct i2cbus_attach_args and i2c_controller before messing with
them
 1.10 29-Mar-2014  christos branches: 1.10.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.9 30-Jan-2012  drochner branches: 1.9.6; 1.9.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.8 13-Dec-2011  macallan only try to attach child drivers if they're actually present
 1.7 07-Dec-2011  macallan consolidate bit twiddling functions into one generic case and a bunch of
macros, use them
 1.6 20-Oct-2011  macallan branches: 1.6.2; 1.6.6;
include opt_voyager.h
 1.5 18-Oct-2011  macallan add functions to control gpio usage and to program PWM timers
also add basic interrupt support ( not used yet )
 1.4 06-Sep-2011  macallan add a function to mess with gpios which locks against the i2c stuff
 1.3 01-Sep-2011  macallan some i2c devices we're going to deal with need a little delay after each
write. Also make sure the gpios we're using are outputs.
 1.2 01-Sep-2011  macallan only attach the i2c bus if the gpio pins we're using are actually
configured as gpio
while there remove some accidentially left in debug code
 1.1 31-Aug-2011  macallan split up voyagerfb into the framebuffer portion and a pseudo bus that we can
attach all the other sub-devices to
while there attach an i2c bus
 1.6.6.1 18-Feb-2012  mrg merge to -current.
 1.6.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.2.1 17-Apr-2012  yamt sync with head
 1.9.10.1 18-May-2014  rmind sync with head
 1.9.6.2 03-Dec-2017  jdolecek update from HEAD
 1.9.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.6.2 05-Dec-2016  skrll Sync with HEAD
 1.10.6.1 19-Mar-2016  skrll Sync with HEAD
 1.11.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12.16.1 10-Jun-2019  christos Sync with HEAD
 1.12.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.15.10.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.16.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.18.10.1 02-Aug-2025  perseant Sync with HEAD
 1.10 31-Aug-2011  macallan the framebuffer part lives on in voyager/voyagerfb.c
 1.9 30-Aug-2011  macallan contrary to the manual the right-to-left flag also causes the blitter to
work bottom-to-top
Now all copy*() methods should work properly in all directions.
 1.8 30-Aug-2011  macallan fix thinko in downward scrolling ( never had a chance to test it until now... )
 1.7 22-Jan-2011  cegger Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.6 23-Dec-2010  cegger branches: 1.6.2; 1.6.4;
read 32bits instead of 64bits and truncate the upper 32bits
 1.5 16-Dec-2010  cegger ioctl: KNF switch-case, remove useless brackets
 1.4 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.3 04-May-2010  macallan use alternate font if available ( for autogenerated box drawing characters )
 1.2 20-Aug-2009  macallan branches: 1.2.2; 1.2.4;
use vcons_replay_msgbuf() when appropriate
 1.1 12-Aug-2009  macallan branches: 1.1.2;
add voyagerfb, a driver for the Gdium Liberty 1000's onboard graphics chip
 1.1.2.4 11-Aug-2010  yamt sync with head.
 1.1.2.3 16-Sep-2009  yamt sync with head
 1.1.2.2 19-Aug-2009  yamt sync with head.
 1.1.2.1 12-Aug-2009  yamt file voyagerfb.c was added on branch yamt-nfs-mp on 2009-08-19 18:47:18 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 30-May-2010  rmind sync with head
 1.2.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.6 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.5 19-Apr-2018  christos branches: 1.5.14;
s/static inline/static __inline/g for consistency.
 1.4 07-Dec-2011  macallan branches: 1.4.46;
consolidate bit twiddling functions into one generic case and a bunch of
macros, use them
 1.3 18-Oct-2011  macallan branches: 1.3.2; 1.3.6;
add functions to control gpio usage and to program PWM timers
also add basic interrupt support ( not used yet )
 1.2 06-Sep-2011  macallan add a function to mess with gpios which locks against the i2c stuff
 1.1 31-Aug-2011  macallan split up voyagerfb into the framebuffer portion and a pseudo bus that we can
attach all the other sub-devices to
while there attach an i2c bus
 1.3.6.1 18-Feb-2012  mrg merge to -current.
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.46.1 22-Apr-2018  pgoyette Sync with HEAD
 1.5.14.1 20-Apr-2020  bouyer Sync with HEAD
 1.22 04-Oct-2025  thorpej Use device_{get,set}prop_bool() for "is_console".
 1.21 17-Jul-2022  riastradh wsdisplay(4): Factor out WSDISPLAY_SCROLLSUPPORT logic.

Should find a way to avoid the #ifdefs in the .h file, but this makes
the code a good deal more legible and easier to maitain, at least.
No functional change intended.
 1.20 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.19 24-Apr-2021  thorpej branches: 1.19.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.18 01-Jun-2017  chs branches: 1.18.26;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.17 24-Mar-2017  macallan support screen blanking
 1.16 24-Mar-2017  macallan missed one line of debug spam...
 1.15 24-Mar-2017  macallan - clean up some testing & debugging goop
- 0xff is transparent, so restrict ourself to just 4 bit colour, all we need
for wscons
- support WSDISPLAYIO_GET_FBINFO etc. for wsfb, allow mmap()ing the fb etc.
 1.14 14-Jul-2016  msaitoh branches: 1.14.2; 1.14.4;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.13 20-Mar-2015  macallan fix copyright & license, make it explicit that this driver is based on
OpenBSD's ifb driver
 1.12 09-Oct-2012  macallan branches: 1.12.14;
add acceleration support, for Sun XVR-1200 and compatible only so far
adapted from OpenBSD with various improvements, no support for Expert3D has
been added
this is still suboptimal since we have to sync the engine all the time but
it's an improvement over software-only operation
 1.11 13-Mar-2012  elad branches: 1.11.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.10 30-Jan-2012  drochner Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.9 11-Jan-2012  macallan use rasops_init(0, 0)
 1.8 22-Jan-2011  cegger branches: 1.8.4; 1.8.8;
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.7 16-Dec-2010  cegger branches: 1.7.2; 1.7.4;
ioctl: KNF switch-case, remove useless brackets
 1.6 10-Mar-2010  macallan branches: 1.6.2; 1.6.4; 1.6.6;
- move register definition in their own header, reduce magic numbers
- get geometry and framebuffer layout from the chip instead of hardcoding
- get rid of some now superfluous leftovers
- remove some debug code
- clean things up a bit
- dump registers with WCFB_DEBUG even if we're not the console
 1.5 10-Mar-2010  macallan forgot to include opt_wsdisplay_compat.h for WSDISPLAY_SCROLLSUPPORT
 1.4 09-Mar-2010  macallan now we also draw a cursor
 1.3 09-Mar-2010  macallan Use a shadow framebuffer instead of doing every operation twice ( once for
each framebuffer ) - this gives quite a dramatic speedup and hides the funky
effects previously seen.
Almost there, now we need to actually draw a cursor.
 1.2 25-Feb-2010  macallan some cleanup
 1.1 25-Feb-2010  macallan a very preliminary driver for Wildcat 5110 / Sun XVR-500 graphics boards
Since we don't have any documentationthis driver is unaccelerated and thanks
to the insane state we get the hardware in it's also slow and scrolling
looks weird.
Some hardware info came from OpenBSD's ifb driver.
 1.6.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.6.1 10-Mar-2010  uebayasi file wcfb.c was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.6.2.2 11-Mar-2010  yamt sync with head
 1.6.2.1 10-Mar-2010  yamt file wcfb.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:59 +0000
 1.7.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.7.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.8.2 05-Apr-2012  mrg sync to latest -current.
 1.8.8.1 18-Feb-2012  mrg merge to -current.
 1.8.4.2 30-Oct-2012  yamt sync with head
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.11.2.2 03-Dec-2017  jdolecek update from HEAD
 1.11.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.12.14.3 28-Aug-2017  skrll Sync with HEAD
 1.12.14.2 05-Oct-2016  skrll Sync with HEAD
 1.12.14.1 06-Apr-2015  skrll Sync with HEAD
 1.14.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.14.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.18.26.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.19.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 09-Oct-2012  macallan add acceleration support, for Sun XVR-1200 and compatible only so far
adapted from OpenBSD with various improvements, no support for Expert3D has
been added
this is still suboptimal since we have to sync the engine all the time but
it's an improvement over software-only operation
 1.1 10-Mar-2010  macallan branches: 1.1.2; 1.1.6; 1.1.14; 1.1.24;
- move register definition in their own header, reduce magic numbers
- get geometry and framebuffer layout from the chip instead of hardcoding
- get rid of some now superfluous leftovers
- remove some debug code
- clean things up a bit
- dump registers with WCFB_DEBUG even if we're not the console
 1.1.24.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1.14.1 30-Oct-2012  yamt sync with head
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 10-Mar-2010  uebayasi file wcfbreg.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 10-Mar-2010  yamt file wcfbreg.h was added on branch yamt-nfs-mp on 2010-03-11 15:03:59 +0000
 1.3 10-Nov-1998  thorpej File is obsolete.
 1.2 08-Jun-1998  thorpej Nuke __BROKEN_INDIRECT_CONFIG.
 1.1 04-Mar-1998  cgd PCI IDE glue. Right now, just glues 'wdc's to PCI IDE controller
channels. Eventually should do things like support PCI IDE DMA (it _DOES
NOT_ do that now).
 1.16 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.15 17-Oct-2013  christos branches: 1.15.6;
- remove unused variables
- move debugging code inside debugging sections
 1.14 18-Mar-2009  cegger branches: 1.14.12; 1.14.22; 1.14.26;
bzero -> memset
 1.13 09-Jul-2008  joerg branches: 1.13.2; 1.13.8;
- device/softc split
 1.12 28-Apr-2008  martin branches: 1.12.2; 1.12.4; 1.12.6;
Remove clause 3 and 4 from TNF licenses
 1.11 10-Apr-2008  cegger branches: 1.11.2; 1.11.4;
use aprint_*_dev and device_xname
 1.10 19-Oct-2007  ad branches: 1.10.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.9 16-Nov-2006  christos branches: 1.9.8; 1.9.22; 1.9.24; 1.9.28;
__unused removal on arguments; approved by core.
 1.8 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.7 11-Dec-2005  christos branches: 1.7.20; 1.7.22;
merge ktrace-lwp.
 1.6 28-Jun-2005  thorpej branches: 1.6.2;
Use ANSI function decls and static.
 1.5 27-Feb-2005  perry nuke trailing whitespace
 1.4 02-Oct-2002  thorpej branches: 1.4.6; 1.4.14; 1.4.16;
Add trailing ; to CFATTACH_DECL.
 1.3 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 01-Jan-2002  hpeyerl branches: 1.1.2; 1.1.4;
Watchdog back-end driver for PC Weasel/PCI serial console and remote
management board. Written by hpeyerl@realweasel.com and
thorpej@wasabisystems.com. Requires Weasel firmware v2.04 and later.
 1.1.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 01-Jan-2002  thorpej file weasel_pci.c was added on branch kqueue on 2002-01-10 19:57:09 +0000
 1.1.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 01-Jan-2002  nathanw file weasel_pci.c was added on branch nathanw_sa on 2002-01-08 00:31:19 +0000
 1.4.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.14.1 29-Apr-2005  kent sync with -current
 1.4.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.6.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.2 27-Oct-2007  yamt sync with head.
 1.6.2.1 30-Dec-2006  yamt sync with head.
 1.7.22.2 10-Dec-2006  yamt sync with head.
 1.7.22.1 22-Oct-2006  yamt sync with head
 1.7.20.1 18-Nov-2006  ad Sync with head.
 1.9.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.9.24.1 06-Nov-2007  matt sync with HEAD
 1.9.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.9.8.1 23-Oct-2007  ad Sync with head.
 1.10.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.10.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.4.2 04-May-2009  yamt sync with head.
 1.11.4.1 16-May-2008  yamt sync with head.
 1.11.2.1 18-May-2008  yamt sync with head.
 1.12.6.1 19-Oct-2008  haad Sync with HEAD.
 1.12.4.1 18-Jul-2008  simonb Sync with head.
 1.12.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.14.26.1 18-May-2014  rmind sync with head
 1.14.22.2 03-Dec-2017  jdolecek update from HEAD
 1.14.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.6.1 09-Jul-2016  skrll Sync with HEAD
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 01-Jan-2002  hpeyerl branches: 1.1.2; 1.1.4; 1.1.118; 1.1.120; 1.1.122;
Watchdog back-end driver for PC Weasel/PCI serial console and remote
management board. Written by hpeyerl@realweasel.com and
thorpej@wasabisystems.com. Requires Weasel firmware v2.04 and later.
 1.1.122.1 16-May-2008  yamt sync with head.
 1.1.120.1 18-May-2008  yamt sync with head.
 1.1.118.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 01-Jan-2002  thorpej file weaselreg.h was added on branch kqueue on 2002-01-10 19:57:09 +0000
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 01-Jan-2002  nathanw file weaselreg.h was added on branch nathanw_sa on 2002-01-08 00:31:19 +0000
 1.1 22-Jan-2011  cegger branches: 1.1.2; 1.1.4; 1.1.8;
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 22-Jan-2011  jruoho file wsdisplay_pci.c was added on branch jruoho-x86intr on 2011-06-06 09:08:28 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 22-Jan-2011  rmind file wsdisplay_pci.c was added on branch rmind-uvmplock on 2011-03-05 20:53:59 +0000
 1.1.2.2 08-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 22-Jan-2011  bouyer file wsdisplay_pci.c was added on branch bouyer-quota2 on 2011-02-08 16:19:53 +0000
 1.1 22-Jan-2011  cegger branches: 1.1.2; 1.1.4; 1.1.8;
Implement new WSDISPLAYIO_GET_BUSID ioctl.
It returns the bus id and allows userland (like Xorg) to create mapping
of ttyE? and bus id. For now only PCI is implemented.

First discussed with macallan@ then public on tech-kern@ and tech-x11@
 1.1.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.8.1 22-Jan-2011  jruoho file wsdisplay_pci.h was added on branch jruoho-x86intr on 2011-06-06 09:08:29 +0000
 1.1.4.2 05-Mar-2011  rmind sync with head
 1.1.4.1 22-Jan-2011  rmind file wsdisplay_pci.h was added on branch rmind-uvmplock on 2011-03-05 20:53:59 +0000
 1.1.2.2 08-Feb-2011  bouyer Sync with HEAD
 1.1.2.1 22-Jan-2011  bouyer file wsdisplay_pci.h was added on branch bouyer-quota2 on 2011-02-08 16:19:53 +0000
 1.33 24-Jan-2023  mlelstv Consistently use cached chipset tag value.
 1.32 28-Oct-2022  riastradh branches: 1.32.2;
xhci(4): Mark PCI interrupt handler MP-safe.

xhci_intr has its own intr lock to coordinate with the MP-safe
softint it defers all its work to, other than reading and writing a
few registers to get and acknowledge the interrupt status.
 1.31 11-Oct-2022  msaitoh There is an xHCI device which has USB 2 port only. Support it.

- Example:

xhci4 at pci17 dev 0 function 0: AMD product 15b8 (rev. 0x00)
xhci4: 64-bit DMA
allocated pic msix10 type edge pin 0 level 6 to cpu0 slot 32 idt entry 107
xhci4: interrupting at msix10 vec 0
xhci4: xHCI version 1.20
xhci4: hcs1=1000840 hcs2=140000f1 hcs3=7000a
xhci4: hcc=0x110ffc5<XECP=0x110,MAXPSA=0xf,CFC,SEC,SPC,PAE,NSS,LTC,CSZ,AC64>
xhci4: xECP 440
xhci4: hcc2=0x3f<CIC,LEC,CTC,FSC,CMC,U3C>
xhci4: ECR: 0x00000401
xhci4: ECR: 0x02000402
xhci4: SP: 0x02000402 0x20425355 0x00180101 0x00000000
xhci4: hs ports 1 - 1
xhci4: ECR: 0x000f000a
xhci4: PAGESIZE 0x00000001
xhci4: sc_pgsz 0x00001000
xhci4: sc_maxslots 0x00000040
xhci4: sc_maxports 1
xhci4: sc_maxspbuf 2
xhci4: eventst: 0x000000013ee60fc0 0xffffb08826f5afc0 1000
xhci4: dcbaa: 0x000000013ee63000 0xffffb08826f5b000 1000
xhci4: current IMOD 0
(snip)
usb8 at xhci4: USB revision 3.1
usb9 at xhci4: USB revision 2.0
uhub8 at usb8: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 3.00/1.00, addr 0
uhub8: 0 ports with 0 removable, self powered
uhub8: no ports, hub ignored
uhub8: WARNING: power management not supported
autoconfiguration error: usb8: root device is not a hub
usb8: WARNING: power management not supported
uhub9 at usb9: NetBSD (0x0000) xHCI root hub (0x0000), class 9/0, rev 2.00/1.00, addr 0
uhub9: 1 port with 1 removable, self powered

- To resolve this problem, keep number of ports of SS and HS and use
it to attach child device(s).
- Tested on ASUS TUF GAMING X670E-PLUS.
- OK'd by skrll@.
 1.30 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.29 24-Apr-2021  thorpej branches: 1.29.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.28 07-Feb-2021  ryoon branches: 1.28.2;
Allow MSIX and MSI for interrupt type
 1.27 07-Feb-2021  dbj xhci_pci.c: reimplement XHCI_DISABLE_MSI and XHCI_DISABLE_MSIX
 1.26 09-Dec-2020  jakllsch xhci_pci: avoid potential double free of interrupt handles

Found by Kouichi Hashikawa in PR 55855.
 1.25 27-Oct-2020  skrll branches: 1.25.2;
Report HW DMA capability and if the DMA tag limits it.
 1.24 02-Dec-2019  msaitoh Use PCI_MSIX_"TBL"BIR_MASK instead of PCI_MSIX_"PBA"BIR_MASK for MSI-X table.
This is not a real bug because both macros have the same value.
 1.23 14-Nov-2019  msaitoh Revert previous. Sorry.
 1.22 14-Nov-2019  msaitoh Add D-Link DGE-530T C1 and TP-Link TG-3468 v2.
 1.21 23-Jan-2019  msaitoh branches: 1.21.4;
Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them expilicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.20 18-Jan-2019  skrll Default to USBREV_3_0 if usbrev is unknown.
 1.19 07-Dec-2018  msaitoh xHCI uses BAR0 to map memory space. If a chip has MSI-X capability and it
points to BAR0, reserve the space. Almost the same as nvme_pci.c.

XXX Is it possible to make a nice API?
 1.18 30-Nov-2018  jdolecek simplify intr establish code - rely on pci_intr_alloc() to allow
also MSI-X, and to return interrupt types which are possible for
pci_intr_establish(); remove fallbacks to retry with MSI/MSI-X
explicitly disabled

discussed on tech-kern@

https://mail-index.netbsd.org/tech-kern/2018/11/27/msg024240.html
 1.17 24-Nov-2018  skrll Fixup the retry loop wrt with XHCI_DISABLE_MSI{,X}
 1.16 15-Nov-2018  jdolecek remove #ifdef DEBUG printf, it seems to have outlived it's usefulness
 1.15 31-Oct-2018  jmcneill Add MSI-X support.
 1.14 18-Sep-2018  mrg deal with partial attach failures in usb_attach vs usb_detach aka PR 53598.

- make sure xhci's sc->sc_ios is NULL if failure happens.
- rearrange usb_attach() / usb_doattach() to make it simpler to clean up.
- move usb_async_intr softint into usb_once_init(). previously, each USB
controller would start a new one, and leave the old one leaked.
- handle controller interrupts without a bus attached
 1.13 29-Jun-2018  msaitoh Detect USB 3.1.
 1.12 09-Apr-2018  jakllsch branches: 1.12.2;
Stop potential misuse of vendor names and USB vendor IDs in root hub
device and string descriptors.

Firstly: Few vendors have identical PCI-SIG vendor IDs and USB-IF vendor
IDs. As such, using the PCI vendor ID as a USB vendor ID may trample
on whomever is allocated that USB vendor ID.

Secondly: The vendor of the host controller hardware implementation has
little to nothing to do with our usbroothub implementation. Thus we
should not potentially associate any problems therewith to such third
party.

This change will result in root hubs being identified by USB Vendor ID
0x0000. Root hub vendor string will now be "NetBSD" (or, specifically:
ostype). Product ID (0x0000) and product strings remain unchanged.
 1.11 28-Dec-2017  msaitoh branches: 1.11.2;
- Fix panic in xhci_pci_detach() if xhci_pci_attach() failed.
- Fallback from MSI to INTx correctly.
 1.10 25-Dec-2017  msaitoh - Fix a panic while cleaning PCI interrupt.
- Fallback to INTx if MSI allocation succeeded but the establish failed.
 1.9 05-Sep-2017  skrll Add an XHCI_DISABLE_MSI option
 1.8 19-Jan-2017  skrll branches: 1.8.6;
Pull across xhci(4) improvemnts from nick-nhusb
 1.7 13-Oct-2016  jdolecek branches: 1.7.2;
provide intr xname
 1.6 03-May-2016  skrll branches: 1.6.2;
Kill XHCI_QUIRK_FORCE_INTR and surrounding code
 1.5 23-Apr-2016  skrll Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
 1.4 21-Sep-2014  christos branches: 1.4.2;
Merge the 3 copies of devlist2h.awk that deal with 16 bit key and value
pairs to the compressed one that matt wrote.
 1.3 29-Mar-2014  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.10; 1.3.14;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.2 10-Mar-2014  skrll Don't abuse usbd_status in xhci_init
 1.1 14-Sep-2013  jakllsch branches: 1.1.2;
Add work-in-progress xhci(4) driver code. Currently (mostly) supports
interrupt-driven control, interrupt and bulk transfers at the three USB
2.0 speeds on root hub ports.
 1.1.2.2 05-Nov-2013  matt Pull down xhci support from HEAD
 1.1.2.1 14-Sep-2013  matt file xhci_pci.c was added on branch matt-nb5-mips64 on 2013-11-05 18:36:31 +0000
 1.3.14.2 26-Jan-2017  skrll Sync with HEAD/nhusb
 1.3.14.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.3.10.3 03-Dec-2017  jdolecek update from HEAD
 1.3.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.10.1 29-Mar-2014  tls file xhci_pci.c was added on branch tls-maxphys on 2014-08-20 00:03:48 +0000
 1.3.8.1 05-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1395):
share/man/man4/axe.4: netbsd-7-nhusb
share/man/man4/axen.4: netbsd-7-nhusb
share/man/man4/cdce.4: netbsd-7-nhusb
share/man/man4/uaudio.4: netbsd-7-nhusb
share/man/man4/ucom.4: netbsd-7-nhusb
share/man/man4/uep.4: netbsd-7-nhusb
share/man/man4/urtw.4: netbsd-7-nhusb
share/man/man4/usb.4: netbsd-7-nhusb
share/man/man4/uyap.4: netbsd-7-nhusb
share/man/man4/xhci.4: netbsd-7-nhusb
share/man/man9/usbdi.9: netbsd-7-nhusb
sys/arch/amd64/conf/ALL: netbsd-7-nhusb
sys/arch/amd64/conf/GENERIC: netbsd-7-nhusb
sys/arch/amiga/dev/slhci_zbus.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_otg.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_usb.c: netbsd-7-nhusb
sys/arch/arm/amlogic/amlogic_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/at91/at91ohci.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm2835_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm53xx_usb.c: netbsd-7-nhusb
sys/arch/arm/ep93xx/epohci.c: netbsd-7-nhusb
sys/arch/arm/gemini/obio_ehci.c: netbsd-7-nhusb
sys/arch/arm/imx/files.imx23: netbsd-7-nhusb
sys/arch/arm/imx/imxusb.c: netbsd-7-nhusb
sys/arch/arm/imx/imxusbreg.h: netbsd-7-nhusb
sys/arch/arm/omap/obio_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/omap3_ehci.c: netbsd-7-nhusb
sys/arch/arm/omap/omapl1x_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/tiotg.c: netbsd-7-nhusb
sys/arch/arm/s3c2xx0/ohci_s3c24x0.c: netbsd-7-nhusb
sys/arch/arm/samsung/exynos_usb.c: netbsd-7-nhusb
sys/arch/arm/xscale/pxa2x0_ohci.c: netbsd-7-nhusb
sys/arch/arm/zynq/zynq_usb.c: netbsd-7-nhusb
sys/arch/hpcarm/dev/nbp_slhci.c: netbsd-7-nhusb
sys/arch/hpcmips/dev/plumohci.c: netbsd-7-nhusb
sys/arch/i386/conf/ALL: netbsd-7-nhusb
sys/arch/i386/conf/GENERIC: netbsd-7-nhusb
sys/arch/i386/pci/gcscehci.c: netbsd-7-nhusb
sys/arch/luna68k/conf/GENERIC: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahci.c: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahcivar.h: netbsd-7-nhusb
sys/arch/mips/alchemy/dev/ohci_aubus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ehci_arbus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ohci_arbus.c: netbsd-7-nhusb
sys/arch/mips/conf/files.adm5120: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ehci.c: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ohci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ehci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ohci.c: netbsd-7-nhusb
sys/arch/playstation2/dev/ohci_sbus.c: netbsd-7-nhusb
sys/arch/powerpc/booke/dev/pq3ehci.c: netbsd-7-nhusb
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c: netbsd-7-nhusb
sys/arch/x68k/dev/slhci_intio.c: netbsd-7-nhusb
sys/conf/files: netbsd-7-nhusb
sys/dev/cardbus/ehci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/ohci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/uhci_cardbus.c: netbsd-7-nhusb
sys/dev/ic/sl811hs.c: netbsd-7-nhusb
sys/dev/ic/sl811hsvar.h: netbsd-7-nhusb
sys/dev/isa/slhci_isa.c: netbsd-7-nhusb
sys/dev/marvell/ehci_mv.c: netbsd-7-nhusb
sys/dev/pci/ehci_pci.c: netbsd-7-nhusb
sys/dev/pci/ohci_pci.c: netbsd-7-nhusb
sys/dev/pci/uhci_pci.c: netbsd-7-nhusb
sys/dev/pci/xhci_pci.c: netbsd-7-nhusb
sys/dev/pcmcia/slhci_pcmcia.c: netbsd-7-nhusb
sys/dev/usb/Makefile.usbdevs: netbsd-7-nhusb
sys/dev/usb/TODO: netbsd-7-nhusb
sys/dev/usb/TODO.usbmp: netbsd-7-nhusb
sys/dev/usb/aubtfwl.c: netbsd-7-nhusb
sys/dev/usb/auvitek.c: netbsd-7-nhusb
sys/dev/usb/auvitek_audio.c: netbsd-7-nhusb
sys/dev/usb/auvitek_dtv.c: netbsd-7-nhusb
sys/dev/usb/auvitek_i2c.c: netbsd-7-nhusb
sys/dev/usb/auvitek_video.c: netbsd-7-nhusb
sys/dev/usb/auvitekvar.h: netbsd-7-nhusb
sys/dev/usb/ehci.c: netbsd-7-nhusb
sys/dev/usb/ehcireg.h: netbsd-7-nhusb
sys/dev/usb/ehcivar.h: netbsd-7-nhusb
sys/dev/usb/emdtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_dtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_ir.c: netbsd-7-nhusb
sys/dev/usb/emdtvvar.h: netbsd-7-nhusb
sys/dev/usb/ezload.c: netbsd-7-nhusb
sys/dev/usb/ezload.h: netbsd-7-nhusb
sys/dev/usb/files.usb: netbsd-7-nhusb
sys/dev/usb/hid.c: netbsd-7-nhusb
sys/dev/usb/hid.h: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.c: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.h: netbsd-7-nhusb
sys/dev/usb/if_atu.c: netbsd-7-nhusb
sys/dev/usb/if_atureg.h: netbsd-7-nhusb
sys/dev/usb/if_aue.c: netbsd-7-nhusb
sys/dev/usb/if_auereg.h: netbsd-7-nhusb
sys/dev/usb/if_axe.c: netbsd-7-nhusb
sys/dev/usb/if_axen.c: netbsd-7-nhusb
sys/dev/usb/if_axenreg.h: netbsd-7-nhusb
sys/dev/usb/if_axereg.h: netbsd-7-nhusb
sys/dev/usb/if_cdce.c: netbsd-7-nhusb
sys/dev/usb/if_cdcereg.h: netbsd-7-nhusb
sys/dev/usb/if_cue.c: netbsd-7-nhusb
sys/dev/usb/if_cuereg.h: netbsd-7-nhusb
sys/dev/usb/if_kue.c: netbsd-7-nhusb
sys/dev/usb/if_kuereg.h: netbsd-7-nhusb
sys/dev/usb/if_otus.c: netbsd-7-nhusb
sys/dev/usb/if_otusvar.h: netbsd-7-nhusb
sys/dev/usb/if_rum.c: netbsd-7-nhusb
sys/dev/usb/if_rumreg.h: netbsd-7-nhusb
sys/dev/usb/if_rumvar.h: netbsd-7-nhusb
sys/dev/usb/if_run.c: netbsd-7-nhusb
sys/dev/usb/if_runvar.h: netbsd-7-nhusb
sys/dev/usb/if_smsc.c: netbsd-7-nhusb
sys/dev/usb/if_smscreg.h: netbsd-7-nhusb
sys/dev/usb/if_smscvar.h: netbsd-7-nhusb
sys/dev/usb/if_udav.c: netbsd-7-nhusb
sys/dev/usb/if_udavreg.h: netbsd-7-nhusb
sys/dev/usb/if_upgt.c: netbsd-7-nhusb
sys/dev/usb/if_upgtvar.h: netbsd-7-nhusb
sys/dev/usb/if_upl.c: netbsd-7-nhusb
sys/dev/usb/if_ural.c: netbsd-7-nhusb
sys/dev/usb/if_uralreg.h: netbsd-7-nhusb
sys/dev/usb/if_uralvar.h: netbsd-7-nhusb
sys/dev/usb/if_url.c: netbsd-7-nhusb
sys/dev/usb/if_urlreg.h: netbsd-7-nhusb
sys/dev/usb/if_urndis.c: netbsd-7-nhusb
sys/dev/usb/if_urndisreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtw.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn_data.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnvar.h: netbsd-7-nhusb
sys/dev/usb/if_urtwreg.h: netbsd-7-nhusb
sys/dev/usb/if_zyd.c: netbsd-7-nhusb
sys/dev/usb/if_zydreg.h: netbsd-7-nhusb
sys/dev/usb/irmce.c: netbsd-7-nhusb
sys/dev/usb/moscom.c: netbsd-7-nhusb
sys/dev/usb/motg.c: netbsd-7-nhusb
sys/dev/usb/motgvar.h: netbsd-7-nhusb
sys/dev/usb/ohci.c: netbsd-7-nhusb
sys/dev/usb/ohcireg.h: netbsd-7-nhusb
sys/dev/usb/ohcivar.h: netbsd-7-nhusb
sys/dev/usb/pseye.c: netbsd-7-nhusb
sys/dev/usb/slurm.c: netbsd-7-nhusb
sys/dev/usb/stuirda.c: netbsd-7-nhusb
sys/dev/usb/u3g.c: netbsd-7-nhusb
sys/dev/usb/uark.c: netbsd-7-nhusb
sys/dev/usb/uatp.c: netbsd-7-nhusb
sys/dev/usb/uaudio.c: netbsd-7-nhusb
sys/dev/usb/uberry.c: netbsd-7-nhusb
sys/dev/usb/ubsa.c: netbsd-7-nhusb
sys/dev/usb/ubsa_common.c: netbsd-7-nhusb
sys/dev/usb/ubsavar.h: netbsd-7-nhusb
sys/dev/usb/ubt.c: netbsd-7-nhusb
sys/dev/usb/uchcom.c: netbsd-7-nhusb
sys/dev/usb/ucom.c: netbsd-7-nhusb
sys/dev/usb/ucomvar.h: netbsd-7-nhusb
sys/dev/usb/ucycom.c: netbsd-7-nhusb
sys/dev/usb/udl.c: netbsd-7-nhusb
sys/dev/usb/udl.h: netbsd-7-nhusb
sys/dev/usb/udsbr.c: netbsd-7-nhusb
sys/dev/usb/udsir.c: netbsd-7-nhusb
sys/dev/usb/uep.c: netbsd-7-nhusb
sys/dev/usb/uftdi.c: netbsd-7-nhusb
sys/dev/usb/uftdireg.h: netbsd-7-nhusb
sys/dev/usb/ugen.c: netbsd-7-nhusb
sys/dev/usb/ugensa.c: netbsd-7-nhusb
sys/dev/usb/uhci.c: netbsd-7-nhusb
sys/dev/usb/uhcireg.h: netbsd-7-nhusb
sys/dev/usb/uhcivar.h: netbsd-7-nhusb
sys/dev/usb/uhid.c: netbsd-7-nhusb
sys/dev/usb/uhidev.c: netbsd-7-nhusb
sys/dev/usb/uhidev.h: netbsd-7-nhusb
sys/dev/usb/uhmodem.c: netbsd-7-nhusb
sys/dev/usb/uhso.c: netbsd-7-nhusb
sys/dev/usb/uhub.c: netbsd-7-nhusb
sys/dev/usb/uipad.c: netbsd-7-nhusb
sys/dev/usb/uipaq.c: netbsd-7-nhusb
sys/dev/usb/uirda.c: netbsd-7-nhusb
sys/dev/usb/uirdavar.h: netbsd-7-nhusb
sys/dev/usb/ukbd.c: netbsd-7-nhusb
sys/dev/usb/ukbdmap.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.h: netbsd-7-nhusb
sys/dev/usb/ulpt.c: netbsd-7-nhusb
sys/dev/usb/umass.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.h: netbsd-7-nhusb
sys/dev/usb/umass_quirks.c: netbsd-7-nhusb
sys/dev/usb/umass_quirks.h: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.c: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.h: netbsd-7-nhusb
sys/dev/usb/umassvar.h: netbsd-7-nhusb
sys/dev/usb/umcs.c: netbsd-7-nhusb
sys/dev/usb/umct.c: netbsd-7-nhusb
sys/dev/usb/umidi.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.h: netbsd-7-nhusb
sys/dev/usb/umodem.c: netbsd-7-nhusb
sys/dev/usb/umodem_common.c: netbsd-7-nhusb
sys/dev/usb/umodemvar.h: netbsd-7-nhusb
sys/dev/usb/ums.c: netbsd-7-nhusb
sys/dev/usb/uplcom.c: netbsd-7-nhusb
sys/dev/usb/urio.c: netbsd-7-nhusb
sys/dev/usb/urio.h: netbsd-7-nhusb
sys/dev/usb/usb.c: netbsd-7-nhusb
sys/dev/usb/usb.h: netbsd-7-nhusb
sys/dev/usb/usb_mem.c: netbsd-7-nhusb
sys/dev/usb/usb_mem.h: netbsd-7-nhusb
sys/dev/usb/usb_quirks.c: netbsd-7-nhusb
sys/dev/usb/usb_quirks.h: netbsd-7-nhusb
sys/dev/usb/usb_subr.c: netbsd-7-nhusb
sys/dev/usb/usbdevices.config: netbsd-7-nhusb
sys/dev/usb/usbdevs: netbsd-7-nhusb
sys/dev/usb/usbdevs.h: netbsd-7-nhusb
sys/dev/usb/usbdevs_data.h: netbsd-7-nhusb
sys/dev/usb/usbdi.c: netbsd-7-nhusb
sys/dev/usb/usbdi.h: netbsd-7-nhusb
sys/dev/usb/usbdi_util.c: netbsd-7-nhusb
sys/dev/usb/usbdi_util.h: netbsd-7-nhusb
sys/dev/usb/usbdivar.h: netbsd-7-nhusb
sys/dev/usb/usbhid.h: netbsd-7-nhusb
sys/dev/usb/usbhist.h: netbsd-7-nhusb
sys/dev/usb/usbroothub.c: netbsd-7-nhusb
sys/dev/usb/usbroothub.h: netbsd-7-nhusb
sys/dev/usb/usbroothub_subr.c: delete
sys/dev/usb/usbroothub_subr.h: delete
sys/dev/usb/uscanner.c: netbsd-7-nhusb
sys/dev/usb/uslsa.c: netbsd-7-nhusb
sys/dev/usb/usscanner.c: netbsd-7-nhusb
sys/dev/usb/ustir.c: netbsd-7-nhusb
sys/dev/usb/uthum.c: netbsd-7-nhusb
sys/dev/usb/utoppy.c: netbsd-7-nhusb
sys/dev/usb/uts.c: netbsd-7-nhusb
sys/dev/usb/uvideo.c: netbsd-7-nhusb
sys/dev/usb/uvisor.c: netbsd-7-nhusb
sys/dev/usb/uvscom.c: netbsd-7-nhusb
sys/dev/usb/uyap.c: netbsd-7-nhusb
sys/dev/usb/uyap_firmware.h: netbsd-7-nhusb
sys/dev/usb/uyurex.c: netbsd-7-nhusb
sys/dev/usb/x1input_rdesc.h: netbsd-7-nhusb
sys/dev/usb/xhci.c: netbsd-7-nhusb
sys/dev/usb/xhcireg.h: netbsd-7-nhusb
sys/dev/usb/xhcivar.h: netbsd-7-nhusb
sys/dev/usb/xinput_rdesc.h: netbsd-7-nhusb
sys/external/bsd/common/conf/files.linux: netbsd-7-nhusb
sys/external/bsd/common/include/linux/err.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/kernel.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/workqueue.h: netbsd-7-nhusb
sys/external/bsd/common/linux/linux_work.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/atombios_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/drm/files.drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/i915drm/files.i915drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/include/linux/err.h: delete
sys/external/bsd/drm2/include/linux/workqueue.h: delete
sys/external/bsd/drm2/linux/files.drmkms_linux: netbsd-7-nhusb
sys/external/bsd/drm2/linux/linux_work.c: delete
sys/external/bsd/dwc2/dwc2.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2var.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwctwo2netbsd: netbsd-7-nhusb
sys/external/bsd/dwc2/conf/files.dwc2: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_coreintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdddma.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hw.h: netbsd-7-nhusb
sys/modules/drmkms_linux/Makefile: netbsd-7-nhusb
sys/modules/i915drmkms/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libugenhc/ugenhc.c: netbsd-7-nhusb
sys/rump/dev/lib/libusb/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libusb/USB.ioconf: netbsd-7-nhusb
sys/rump/dev/lib/libusb/usb_at_ugenhc.c: delete
sys/rump/dev/lib/libusb/opt/opt_usb.h: delete
sys/rump/dev/lib/libusb/opt/opt_usbverbose.h: delete
sys/sys/mbuf.h: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.8: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.c: netbsd-7-nhusb
Merge netbsd-7-nhusb:
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
- Change the SOFTINT level from NET to SERIAL for the USB softint handler.
This gives the callback a chance of running when another softint handler
at SOFTINT_NET has blocked holding a lock, e.g. softnet_lock and most of
the network stack.
- kern/49065 - ifconfig tun0 ... sequence locks up system / lockup:
softnet_lock held across usb xfr
- kern/50491 - unkillable wait in usbd_transfer while using usmsc0
on raspberry pi 2
- kern/51395 - USB Ethernet makes xhci hang
- Various improvements to slhci(4)
- Various improvements to dwc2(4)
 1.3.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.6.1 29-Mar-2014  yamt file xhci_pci.c was added on branch yamt-pagecache on 2014-05-22 11:40:34 +0000
 1.3.4.2 18-May-2014  rmind sync with head
 1.3.4.1 29-Mar-2014  rmind file xhci_pci.c was added on branch rmind-smpnet on 2014-05-18 17:45:44 +0000
 1.4.2.8 02-Jan-2017  skrll Parse the extended capabilies to and log each controller port to SS/HS
bus root hub ports.

Create/attach the two buses and adapt the xhci_roothub_ctrl to deal with
both buses and sets of roothub ports.

XXX the roothub ub_devices entry needs work to interact with usbdevs(1)
XXX correctly
 1.4.2.7 05-Dec-2016  skrll Sync with HEAD
 1.4.2.6 29-May-2016  skrll Sync with HEAD
 1.4.2.5 05-Apr-2016  skrll Switch PCI xhci(4) attachment from pci_intr_map() to
pci_intr_alloc()/pci_intr_release().

This enables MSI where available.
 1.4.2.4 31-Aug-2015  skrll Various improvements from t-hash (very very slightly tweaked by me)

+ Use usbd_xfer_isread().
+ Change mutex to be initialized at IPL_USB.
+ Add vendor init/portsc hook.
+ Modify xhci_trb_put() to take host byte order arguments and
convert them to little endian byte order.
+ Return PCI vendor ID of xhci instead of NetBSD(0x0) as a root hub
vendor ID like other HCs do.
+ Move sc_ih in struct xhci_softc to struct xhci_pci_softc.
+ Improve debug message.
 1.4.2.3 27-May-2015  skrll Add patch for intel chips quirk from ryoon@ in
https://mail-index.netbsd.org/netbsd-bugs/2014/08/31/msg038109.html
slightly modified to set quirks before calling xhci_init.

Set special IMOD value and route ports to xhci for intel chips.

From Takahiro HAYASHI.
 1.4.2.2 06-Apr-2015  skrll Remove useless break;
 1.4.2.1 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.6.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.6.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.7.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.6.4 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1787:

sys/dev/pci/xhci_pci.c 1.31 via patch
sys/dev/usb/xhci.c 1.173-1.175
sys/dev/usb/xhcivar.h 1.22

Support xHCI device which has USB 2 port only.
 1.8.6.3 16-Nov-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1443:

sys/arch/arm/nvidia/tegra_xusb.c 1.13-1.14 via patch
sys/dev/pci/xhci_pci.c 1.13
sys/dev/usb/usb.c 1.169
sys/dev/usb/usbdivar.h 1.116
sys/dev/usb/xhci.c 1.93, 1.95, 1.97
sys/dev/usb/xhcireg.h 1.11-1.12

Detect USB 3.1
 1.8.6.2 27-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1172):

sys/dev/pci/nvme_pci.c: revision 1.26
sys/dev/pci/xhci_pci.c: revision 1.21
sys/dev/pci/ixgbe/ixv.c: revision 1.108
sys/dev/pci/ixgbe/ixgbe.c: revision 1.171
sys/dev/pci/if_fxp_pci.c: revision 1.84
sys/dev/pci/if_fxp_pci.c: revision 1.85
sys/dev/pci/xhci_pci.c: revision 1.16

remove #ifdef DEBUG printf, it seems to have outlived it's usefulness

-

KNF. No functional change.

-

Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them explicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.8.6.1 27-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1037):

sys/dev/usb/uhub.c: revision 1.139
sys/external/bsd/dwc2/dwc2.c: revision 1.55
sys/ddb/db_output.c: revision 1.34
sys/ddb/db_command.c: revision 1.160
sys/dev/usb/ehci.c: revision 1.264
sys/dev/usb/xhci.c: revision 1.99
sys/dev/usb/ehci.c: revision 1.265
sys/kern/subr_userconf.c: revision 1.27
sys/dev/usb/ehcivar.h: revision 1.46
sys/dev/usb/ohci.c: revision 1.287
sys/dev/usb/uhci.c: revision 1.284
sys/dev/usb/usbdi.c: revision 1.178
sys/dev/usb/usb.c: revision 1.172
sys/dev/pci/xhci_pci.c: revision 1.14
sys/dev/usb/usb.c: revision 1.173
sys/dev/usb/usb.c: revision 1.174
share/man/man4/usb.4: revision 1.110
sys/ddb/db_command.c: revision 1.159
sys/dev/usb/usb_subr.c: revision 1.227
sys/dev/usb/uhcivar.h: revision 1.56
(all via patch)

consolidate the handling of polling across HC drivers, and generic USB:
- don't take mutexes if polling
- normalise the code across all drivers
- add some not yet code to block discovery to/from polling
- minor CSE
- adjust comment for usbd_set_polling() to reality now i properly
understand what it is used for and why.

this, with a hack to make RB_ASKNAME to wait 5 seconds allows boot -a
work with USB keyboards. there are still multiple issues remaining:
- discovery and polling need to be mutually exclusive
- attachment of ukbd and wskbd is not handled by config_pending, and
the 5 second delay isn't going to always be enough.

call cnpollc(1) and cnpollc(0) around cngetc().
(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still). not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)


When this file is used when not building the kernel (eg: /usr/sbin/crash)
make cnpollc() go away.


reorder some struct members to remove holes.


add config_pending usage to uhub and general USB device attachment.
- call config_pending_incr() and config_pending_decr() around attaching
devices against "usbdevif" attribute.

uhub:
- convert sc_explorepending and sc_running to bool. add new sc_first_explore.
- call config_pending_incr() at the start of uhub_attach(). dropped in
uhub_explore(), if this is the first explore.


implement a gross hack to fix "boot -a" on systems with usb keyboards on
systems with ehci handover to uhci (and maybe ohci), and fix a similar
problem for "boot -s".

there is effort to ensure that all devices attached via USB are probed
before RB_ASKNAME or RB_SINGLE attempts to ask any questions on the console,
and largely this works, often by chance, today, for USB disks and root.
i've recently pushed this more into uhub and general USB device attachment
as well, and kept a config_pending reference across the first explore of
a bus. these fix many issues with directly attached hubs.

however, on systems where devices connected to ehci ports are handed over
to a companion uhci or ohci port, it may not be the first, or even second,
bus explore that finds the device finally before attachment, and at this
point all config_pending references are dropped.

there is no direct communication between drivers, the potentials are
looked up but their device_t is only used for generic things like the name,
so informing the correct companion to expect a device and deal with the
config_pending references is not possible without some fairly ugly layer
violations or multi-level callbacks (eg, we have "ehci0", and usually an
the relevant companion, eg, "uhci2", but it is the uhub that uhci2 has
attached that will deal with the device attachment.)

with the above fixes to generic USB code, the disown happens during the
first explore. the hack works by, at this point, checking if (a) root
is not mounted, (b) single user or ask name are set, and (c) if the hack
as not been triggered already. if all 3 conditions are true, then a
config_pending_incr() is called and a callback is triggered for (default)
5 seconds to call config_pending_decr(). ehci detach pauses waiting for
this callback if scheduled.

this allows enough time for the uhub and the ukbd/wskbd to attach before
the RK_ASKROOT prompts appear. testing shows it takes between 1.5 and
2 seconds for the keyboard to appear after the disown occurs.

Index: dev/usb/ehcivar.c
- new sc_compcallout, sc_compcallout, sc_complock, and a state for th
handover hack.

Index: dev/usb/ehci.c
ehci_init():
- use aprint_normal_dev() instead of manual device_xname().
- initialise sc_compcallout, sc_compcallout, sc_complock, and sc_comp_state.
ehci_detach():
- if there are companion controllers, tear own the above, including waiting
if there is a callback scheduled.
ehci_disown_callback():
- new callout to call config_pending_decr() in the the future.
schedule this ca
ehci_disown_sched_callback():
- if booting to single user or asking names, call config_pending_incr() and
schedule the callout above, default 5 second delay.
ehci_disown():
- if disowning a port call ehci_disown_sched_callback().
deal with partial attach failures in usb_attach vs usb_detach aka PR 53598.
- make sure xhci's sc->sc_ios is NULL if failure happens.
- rearrange usb_attach() / usb_doattach() to make it simpler to clean up.
- move usb_async_intr softint into usb_once_init(). previously, each USB
controller would start a new one, and leave the old one leaked.
- handle controller interrupts without a bus attached


remove usb(4)'s "flags 1" code. it has been dead for a while,
as it runs during the interrupts part of configuration now,
and all the devices try attach as early as possible, including
any root or boot required disk or keyboard device, which is
what this flag was for.
 1.11.2.8 26-Jan-2019  pgoyette Sync with HEAD
 1.11.2.7 18-Jan-2019  pgoyette Synch with HEAD
 1.11.2.6 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.11.2.5 26-Nov-2018  pgoyette And one more missed conflict. (I think this is the last one.)
 1.11.2.4 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.11.2.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.11.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.11.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.12.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12.2.1 10-Jun-2019  christos Sync with HEAD
 1.21.4.2 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1570:

sys/dev/pci/xhci_pci.c 1.31 via patch
sys/dev/usb/xhci.c 1.173-1.175
sys/dev/usb/xhcivar.h 1.22

Support xHCI device which has USB 2 port only.
 1.21.4.1 17-May-2021  martin Pull up following revision(s) (requested by jakllsch in ticket #1273):

sys/dev/pci/xhci_pci.c: revision 1.26

xhci_pci: avoid potential double free of interrupt handles

Found by Kouichi Hashikawa in PR 55855.
 1.25.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.25.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.28.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.29.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.32.2.1 11-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #632):

sys/dev/pci/xhci_pci.c: revision 1.33

Consistently use cached chipset tag value.
 1.17 27-Oct-2022  riastradh branches: 1.17.6;
wwanc(4): Convert to ttylock/ttyunlock.
 1.16 12-Feb-2022  thorpej Don't dig into the guts of selinfo.
 1.15 12-Feb-2022  thorpej Add inline functions to manipulate the klists that link up knotes
via kn_selnext:

- klist_init()
- klist_fini()
- klist_insert()
- klist_remove()

These provide some API insulation from the implementation details of these
lists (but not completely; see vn_knote_attach() and vn_knote_detach()).
Currently just a wrapper around SLIST(9).

This will make it significantly easier to switch kn_selnext linkage
to a different kind of list.
 1.14 12-Feb-2022  riastradh sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.
 1.13 18-Oct-2021  hannken Use a local static variable to hold "pktq_rps_hash_default"
like the other devices do.

Kernel ALL/amd64 compiles again.

OK: Kengo NAKAHARA <knakahara@netbsd.org>
 1.12 11-Oct-2021  knakahara Make pktq_rps_hash() pluggable for each interface type. Reviewed by gdt@n.o, thorpej@n.o, and riastradh@n.o, thanks.
 1.11 11-Oct-2021  thorpej Setting EV_EOF requires modifying kn->kn_flags. However, that relies on
holding the kq_lock of that note's kq. Rather than exposing this directly,
add new knote_set_eof() and knote_clear_eof() functions that handle the
necessary locking and don't leak as many implementation details to modules.

NetBSD 9.99.91
 1.10 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.9 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.8 16-Jul-2021  andvar branches: 1.8.2;
Add missing RCSID, remove non-breaking space characters in copyright, remove vim modeline (from yambo in IRC).
ok riastradh
 1.7 24-Apr-2021  thorpej branches: 1.7.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.6 29-Jul-2020  jdolecek branches: 1.6.4;
fix xmm7360_os_msleep() macro to actually work when not wrapped inside a block

from genua
 1.5 29-Jul-2020  jdolecek sprinkle __diagused so this compiles without DIAGNOSTIC
 1.4 29-Jul-2020  jdolecek adjust OpenBSD mbuf handling so tcpdump(1) works there; from genua

keep code as-is for NetBSD, DLT_RAW works there
 1.3 27-Jul-2020  riastradh Nix trailing whitespace.

Helpful hint:

(setq show-trailing-whitespace t)
 1.2 26-Jul-2020  jdolecek fix attribution - I was confused what was the correct final version
 1.1 26-Jul-2020  jdolecek Add driver for Intel XMM7360 LTE modem, based upon Linux driver available
at https://github.com/xmm7360/xmm7360-pci

This version works on Linux, OpenBSD, and NetBSD.

OpenBSD port written for genua GmbH

Modem requires python script from the master site to initialize the network,
it will be added to pkgsrc shortly
 1.6.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.7.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.8.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.17.6.1 15-Nov-2023  thorpej Rename ifq_enqueue() -> if_enqueue(), ifq_enqueue2() -> if_enqueue2().
 1.70 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.69 08-Jan-2024  chs mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.68 07-Aug-2021  thorpej branches: 1.68.6;
Merge thorpej-cfargs2.
 1.67 24-Apr-2021  thorpej branches: 1.67.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.66 06-Feb-2021  isaki branches: 1.66.2;
Remove an extra mutex_spin_exit() in yds_resume().
This one has been moved to before yds_init() in rev 1.59.
 1.65 29-Feb-2020  isaki branches: 1.65.6;
Remove rounding by 4 bytes on round_blocksize().
For drivers which supports only 16bit * 2channels sampling,
rounding by 4 bytes no longer meaningful.
 1.64 08-Jun-2019  isaki branches: 1.64.4;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.63 25-May-2019  isaki Fix yds_intr. It has not worked well since netbsd-8.
- Read data offset before set ACTV2.
- The interrupts occur every hardware block, not blocksize specified
by round_blocksize. The hardware block may span (upper layer's)
two blocks. So bus_dmamap_sync'ing each (upper layer's) block is
not enough.
XXX To fix this, Use only 48kHz and drop other frequencies. It can
make blocksize fixed. Then the hardware block aligns to upper layer's
block alignment.
Analyzed by Y.Sugahara.
 1.62 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.61 08-Apr-2019  isaki branches: 1.61.2;
Fix minor bugs.
- sc_lock should use an adaptive lock.
- yds_round_blocksize: fix typo.
- yds_trigger_output: fix typo. SlotControlData is pbankoff.
ptbloff points to ControlData.
- yds_halt_input: fix wrong and extra sc_rec.intr.
 1.60 09-Dec-2018  jdolecek use pci_intr_establish_xname() everywhere
 1.59 25-Jun-2017  christos branches: 1.59.4; 1.59.6;
PR/52331: ydc driver: sleep-under-spin-mutex bugs in yds_allocmem
Don't hold the spin interrupt mutex while calling yds_init from resume.
Instead use a flag to short-circuit the interrupt while disabled.
 1.58 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.57 14-Jul-2016  msaitoh KNF. No functional change.
 1.56 17-Aug-2014  tsutsui branches: 1.56.2;
Use C99 struct initializer. Also tweak some inconsistent TAB/space.

No binary change on i386.
 1.55 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.54 17-Oct-2013  christos __USE a debugging var
 1.53 30-Jan-2012  drochner branches: 1.53.6; 1.53.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.52 24-Nov-2011  mrg branches: 1.52.2;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.51 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.50 26-Jul-2010  jym branches: 1.50.8; 1.50.10;
Add PAE to ALL kernel, so that most paddr_t format string errors get caught
during compilation.

While here, fix the compilation for ALL.
 1.49 24-Feb-2010  dyoung branches: 1.49.2;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.48 08-Jan-2010  dyoung branches: 1.48.2;
Expand PMF_FN_* macros.
 1.47 26-Nov-2009  njoly Cleanup interrupt establish error messages. Do not mix
aprint_error/aprint_normal/printf calls for a single line.
 1.46 06-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.45 17-Dec-2008  cegger branches: 1.45.2;
make this compile with AUDIO_DEBUG
 1.44 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.43 09-Jul-2008  joerg branches: 1.43.2; 1.43.6;
- device/softc split
 1.42 10-Apr-2008  cegger branches: 1.42.4; 1.42.6; 1.42.8; 1.42.10;
use aprint_*_dev and device_xname
 1.41 01-Apr-2008  xtraeme Fix fallout from device_t/softc split to mpu(4):
always pass the mpu_softc to mpu_intr(). Found by Takeshi Nakayama.
 1.40 29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.39 09-Dec-2007  jmcneill branches: 1.39.6; 1.39.10;
Merge jmcneill-pm branch.
 1.38 19-Oct-2007  ad branches: 1.38.4; 1.38.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.37 16-Nov-2006  christos branches: 1.37.6; 1.37.8; 1.37.22; 1.37.24; 1.37.28;
__unused removal on arguments; approved by core.
 1.36 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.35 24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.34 03-Sep-2006  christos branches: 1.34.2; 1.34.4;
add missing initializer.
 1.33 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.32 19-Jun-2006  jmcneill Restore yds(4) state on resume.
 1.31 07-Jun-2006  nakayama branches: 1.31.2;
Add void cast to functions whose return values are ignored.
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.6; 1.30.8; 1.30.14;
merge ktrace-lwp.
 1.29 28-Jun-2005  thorpej branches: 1.29.2;
Use ANSI function decls and static.
 1.28 30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.27 15-Jan-2005  kent ansify and KNF
 1.26 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.25 13-Nov-2004  kent branches: 1.25.2;
adopt auconv_set_converter()
 1.24 09-Nov-2004  kent remove mixer setting code in yds_attach() because ac97_attach() does it.
 1.23 08-Nov-2004  kent ANSIfy and style fixes
 1.22 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.21 22-Sep-2004  kent ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case.

PR: kern/26973
 1.20 09-Jul-2004  mycroft There's no need to halt the input and output pipes in the close routine --
audio_close() takes care of this.
 1.19 23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.18 29-Sep-2003  wiz branches: 1.18.2;
available, not avaliable. From miod@openbsd.
 1.17 12-Mar-2003  minoura branches: 1.17.2;
Disable ISA DMA emulation for SoundBlaster module explicitly.
This fixes the floppy access problem on some hardware.
Problem reported by Miroslav Kure via Jason Wright <jason [at]
thought [dot] net> of OpenBSD. Thanks.

Fix from ALSA driver; although this setting is undocumented but
according to Jaroslav Kysela <perex [at] suse [dot] cz> of ALSA,
there's no error reported so far.
 1.16 01-Feb-2003  thorpej Add extensible malloc types, adapted from FreeBSD. This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
 1.15 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.14 30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.13 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.12 10-Jun-2002  someya Make the yds driver work on big-endian systems.
 1.11 10-Jan-2002  someya branches: 1.11.8; 1.11.10;
remove a unnecessary message print
 1.10 30-Dec-2001  someya add powerhook support to resume correctly, fix PR#13079.
 1.9 25-Dec-2001  someya add 600 times dummy read from codec for YMF744 (revision < 2).
 1.8 13-Nov-2001  lukem add RCSID
 1.7 03-Oct-2001  augustss Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.6 07-Jul-2001  thorpej branches: 1.6.2; 1.6.4;
bzero -> memset
 1.5 21-May-2001  minoura Correct an easy mistake in initializing gain registers.
This will fix the L-R imbalance.
Suggested by Ryo HAYASAKA <ryoh@jaist.ac.jp>.
 1.4 15-May-2001  lukem delint: need ; between goto label and }
 1.3 05-Apr-2001  minoura branches: 1.3.2; 1.3.4; 1.3.6;
Make this compile on alpha with DIAGNOSTIC.
Thanks to atatat.
 1.2 30-Mar-2001  minoura Update TODO list.
 1.1 30-Mar-2001  minoura Yamaha YMF724/740/744/754 (DS-1) PCI audio driver.
 1.3.6.4 29-Jul-2001  he Apply patch (requested by minoura):
Correct argument to pci_intr_map(). Fixes PR#13508.
 1.3.6.3 26-May-2001  he Pull up revision 1.5 (requested by minoura):
Correct bug in initializing gain registers. Fixes L-R imbalance.
 1.3.6.2 01-May-2001  he Pull up revisions 1.1-1.3 (new, via patch, requested by minoura):
Add Yamaha YMF724/740/744/745-based sound driver and
its subordinates.
 1.3.6.1 05-Apr-2001  he file yds.c was added on branch netbsd-1-5 on 2001-05-01 11:45:46 +0000
 1.3.4.2 21-Apr-2001  bouyer Sync with HEAD
 1.3.4.1 05-Apr-2001  bouyer file yds.c was added on branch thorpej_scsipi on 2001-04-21 17:49:32 +0000
 1.3.2.11 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.10 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.9 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.8 11-Jan-2002  nathanw More catchup.
 1.3.2.7 08-Jan-2002  nathanw Catch up to -current.
 1.3.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.5 08-Oct-2001  nathanw Catch up to -current.
 1.3.2.4 24-Aug-2001  nathanw Catch up with -current.
 1.3.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.3.2.1 05-Apr-2001  nathanw file yds.c was added on branch nathanw_sa on 2001-04-09 01:57:14 +0000
 1.6.4.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.6.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.6.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.10.1 19-Jun-2003  grant Pull up revision 1.17 (requested by hubertf in ticket #1322):

Disable ISA DMA emulation for SoundBlaster module explicitly.
This fixes the floppy access problem on some hardware.
Problem reported by Miroslav Kure via Jason Wright <jason [at]
thought [dot] net> of OpenBSD. Thanks.

Fix from ALSA driver; although this setting is undocumented but
according to Jaroslav Kysela <perex [at] suse [dot] cz> of ALSA,
there's no error reported so far.
 1.11.8.1 20-Jun-2002  gehenna catch up with -current.
 1.17.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.8 17-Jan-2005  skrll Sync with HEAD.
 1.17.2.7 29-Nov-2004  skrll Sync with HEAD.
 1.17.2.6 14-Nov-2004  skrll Sync with HEAD.
 1.17.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.17.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.17.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.2.1 22-Sep-2004  jmc Pullup rev 1.21 (requested by kent in ticket #867)

ac97_host_if::reset() returns non-zero value if codec reset fails, and
ac97 is not attached in that case. PR#26973
 1.25.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.25.2.1 02-Jan-2005  kent * adopt the filter pipeline framework
* follow ac97_attach() change
 1.29.2.5 17-Mar-2008  yamt sync with head.
 1.29.2.4 21-Jan-2008  yamt sync with head
 1.29.2.3 27-Oct-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.30.14.2 22-Jun-2006  chap Complete a sync sys/ with head.
 1.30.14.1 19-Jun-2006  chap Sync with head.
 1.30.8.3 14-Sep-2006  yamt sync with head.
 1.30.8.2 03-Sep-2006  yamt sync with head.
 1.30.8.1 26-Jun-2006  yamt sync with head.
 1.30.6.1 07-Jun-2006  kardel Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.31.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.34.4.2 10-Dec-2006  yamt sync with head.
 1.34.4.1 22-Oct-2006  yamt sync with head
 1.34.2.1 18-Nov-2006  ad Sync with head.
 1.37.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.37.24.3 23-Mar-2008  matt sync with HEAD
 1.37.24.2 09-Jan-2008  matt sync with HEAD
 1.37.24.1 06-Nov-2007  matt sync with HEAD
 1.37.22.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.37.22.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.37.22.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.37.22.1 05-Oct-2007  joerg Convert yds(4) to PNP power management.
 1.37.8.1 23-Oct-2007  ad Sync with head.
 1.37.6.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.38.6.1 11-Dec-2007  yamt sync with head.
 1.38.4.1 26-Dec-2007  ad Sync with head.
 1.39.10.4 17-Jan-2009  mjf Sync with HEAD.
 1.39.10.3 28-Sep-2008  mjf Sync with HEAD.
 1.39.10.2 02-Jun-2008  mjf Sync with HEAD.
 1.39.10.1 03-Apr-2008  mjf Sync with HEAD.
 1.39.6.1 24-Mar-2008  keiichi sync with head.
 1.42.10.1 19-Oct-2008  haad Sync with HEAD.
 1.42.8.1 18-Jul-2008  simonb Sync with head.
 1.42.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.42.4.4 11-Aug-2010  yamt sync with head.
 1.42.4.3 11-Mar-2010  yamt sync with head
 1.42.4.2 16-May-2009  yamt sync with head
 1.42.4.1 04-May-2009  yamt sync with head.
 1.43.6.2 12-Dec-2008  ad Checkpoint work in progress.
 1.43.6.1 11-Dec-2008  ad Checkpoint work in progress.
 1.43.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.45.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.48.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.48.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.49.2.1 05-Mar-2011  rmind sync with head
 1.50.10.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.50.10.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.50.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.50.8.1 17-Apr-2012  yamt sync with head
 1.52.2.1 18-Feb-2012  mrg merge to -current.
 1.53.10.1 18-May-2014  rmind sync with head
 1.53.6.2 03-Dec-2017  jdolecek update from HEAD
 1.53.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56.2.2 28-Aug-2017  skrll Sync with HEAD
 1.56.2.1 05-Oct-2016  skrll Sync with HEAD
 1.59.6.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.59.6.1 10-Jun-2019  christos Sync with HEAD
 1.59.4.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.61.2.4 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.61.2.3 04-May-2019  isaki Remove obsoleted methods in audio_hw_if.
- drain: is handled in audio upper layer now.
- mappage: is handled in audio upper layer now.
- setfd: no one uses and it's meaningless now.
 1.61.2.2 29-Apr-2019  isaki Adapt to audio2.
 1.61.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.64.4.1 29-Feb-2020  ad Sync with head.
 1.65.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.66.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.67.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.68.6.1 14-Jan-2024  martin Pull up following revision(s) (requested by chs in ticket #542):

sys/dev/pci/yds.c: revision 1.69
sys/dev/pci/cmpci.c: revision 1.61
sys/dev/pci/sv.c: revision 1.62
sys/dev/pci/fms.c: revision 1.50

mpu / opl: add an interface attribute to config_found() calls for these

specify an interface attribute when attaching mpu and opl devices.
the PCI devices that are the parents of these midi devices
(cmpci, eso, fms, sv, yds) have two interface attributes:
"audiobus", and also one named the same as the parent device,
eg. "cmpci" has an interface attribute named "cmpci".
we must specify the latter one to attach these children.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 15-Jan-2005  kent ansify and KNF
 1.4 12-Mar-2003  minoura branches: 1.4.2;
Disable ISA DMA emulation for SoundBlaster module explicitly.
This fixes the floppy access problem on some hardware.
Problem reported by Miroslav Kure via Jason Wright <jason [at]
thought [dot] net> of OpenBSD. Thanks.

Fix from ALSA driver; although this setting is undocumented but
according to Jaroslav Kysela <perex [at] suse [dot] cz> of ALSA,
there's no error reported so far.
 1.3 12-Mar-2003  minoura Typo.
Register value symbols YDS_PCI_EX_LEGACY_SBMOD_* ->
YDS_PCI_EX_LEGACY_SMOD_*.
 1.2 04-Nov-2002  kent Add power-management register definitions.
 1.1 30-Mar-2001  minoura branches: 1.1.2; 1.1.4; 1.1.6; 1.1.22;
Yamaha YMF724/740/744/754 (DS-1) PCI audio driver.
 1.1.22.1 19-Jun-2003  grant Pull up revisions 1.3-1.4 (requested by hubertf in ticket #1322):

Typo.
Register value symbols YDS_PCI_EX_LEGACY_SBMOD_* ->
YDS_PCI_EX_LEGACY_SMOD_*.

Disable ISA DMA emulation for SoundBlaster module explicitly.
This fixes the floppy access problem on some hardware.
Problem reported by Miroslav Kure via Jason Wright <jason [at]
thought [dot] net> of OpenBSD. Thanks.

Fix from ALSA driver; although this setting is undocumented but
according to Jaroslav Kysela <perex [at] suse [dot] cz> of ALSA,
there's no error reported so far.
 1.1.6.2 01-May-2001  he Pull up revision 1.1 (new, requested by minoura):
Add Yamaha YMF724/740/744/745-based sound driver and
its subordinates.
 1.1.6.1 30-Mar-2001  he file ydsreg.h was added on branch netbsd-1-5 on 2001-05-01 11:45:26 +0000
 1.1.4.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.1 30-Mar-2001  bouyer file ydsreg.h was added on branch thorpej_scsipi on 2001-04-21 17:49:32 +0000
 1.1.2.3 11-Nov-2002  nathanw Catch up to -current
 1.1.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.1 30-Mar-2001  nathanw file ydsreg.h was added on branch nathanw_sa on 2001-04-09 01:57:14 +0000
 1.4.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.13 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.12 25-Jun-2017  christos branches: 1.12.6; 1.12.10;
PR/52331: ydc driver: sleep-under-spin-mutex bugs in yds_allocmem
Don't hold the spin interrupt mutex while calling yds_init from resume.
Instead use a flag to short-circuit the interrupt while disabled.
 1.11 23-Nov-2011  jmcneill branches: 1.11.8; 1.11.26;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.10 09-Jul-2008  joerg branches: 1.10.6; 1.10.28; 1.10.30;
- device/softc split
 1.9 01-Apr-2008  xtraeme branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10;
Fix fallout from device_t/softc split to mpu(4):
always pass the mpu_softc to mpu_intr(). Found by Takeshi Nakayama.
 1.8 04-Mar-2007  christos branches: 1.8.36;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 19-Jun-2006  jmcneill branches: 1.7.10; 1.7.12;
Restore yds(4) state on resume.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.8; 1.6.14; 1.6.16;
merge ktrace-lwp.
 1.5 15-Jan-2005  kent branches: 1.5.10;
ansify and KNF
 1.4 13-Nov-2004  kent adopt auconv_set_converter()
 1.3 08-Nov-2004  kent ANSIfy and style fixes
 1.2 25-Dec-2001  someya branches: 1.2.16;
add 600 times dummy read from codec for YMF744 (revision < 2).
 1.1 30-Mar-2001  minoura branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Yamaha YMF724/740/744/754 (DS-1) PCI audio driver.
 1.1.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.2 01-May-2001  he Pull up revision 1.1 (new, requested by minoura):
Add Yamaha YMF724/740/744/745-based sound driver and
its subordinates.
 1.1.6.1 30-Mar-2001  he file ydsvar.h was added on branch netbsd-1-5 on 2001-05-01 11:45:27 +0000
 1.1.4.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.1 30-Mar-2001  bouyer file ydsvar.h was added on branch thorpej_scsipi on 2001-04-21 17:49:33 +0000
 1.1.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.1 30-Mar-2001  nathanw file ydsvar.h was added on branch nathanw_sa on 2001-04-09 01:57:15 +0000
 1.2.16.3 17-Jan-2005  skrll Sync with HEAD.
 1.2.16.2 29-Nov-2004  skrll Sync with HEAD.
 1.2.16.1 14-Nov-2004  skrll Sync with HEAD.
 1.5.10.2 03-Sep-2007  yamt sync with head.
 1.5.10.1 21-Jun-2006  yamt sync with head.
 1.6.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.14.1 22-Jun-2006  chap Complete a sync sys/ with head.
 1.6.8.1 26-Jun-2006  yamt sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.12.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.7.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.36.2 28-Sep-2008  mjf Sync with HEAD.
 1.8.36.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.10.1 19-Oct-2008  haad Sync with HEAD.
 1.9.8.1 18-Jul-2008  simonb Sync with head.
 1.9.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.9.4.1 04-May-2009  yamt sync with head.
 1.10.30.1 19-Nov-2011  jmcneill port ad-audiomp2 branch changes to 5.99.56
todo:
- port ad-audiomp2 pcppi changes
- these drivers need to be fixed:
- emuxki
- gcscaudio
- hdafg
- uaudio
- umidi
- MD audio drivers
 1.10.28.1 17-Apr-2012  yamt sync with head
 1.10.6.1 11-Dec-2008  ad Checkpoint work in progress.
 1.11.26.1 28-Aug-2017  skrll Sync with HEAD
 1.11.8.1 03-Dec-2017  jdolecek update from HEAD
 1.12.10.1 29-Apr-2019  isaki Adapt to audio2.
 1.12.6.1 10-Jun-2019  christos Sync with HEAD
 1.4 12-Mar-2003  wiz Merge first bktr-sf import.
 1.3 01-Jul-2000  wiz branches: 1.3.2;
re-add README that got lost in 2.12-to-2.14 merge.
 1.2 01-Jul-2000  wiz resolve conflicts.
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.2 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 01-Jul-2000  bouyer file README was added on branch thorpej_scsipi on 2000-11-20 22:35:45 +0000
 1.7 12-Mar-2003  wiz Remove some.
 1.6 29-Nov-2001  wiz Update note about ioctl tsleep error with error report.
 1.5 28-Oct-2000  wiz branches: 1.5.2; 1.5.4; 1.5.6;
Replace remaining vm_offset_t's in NetBSD code by vaddr_t; remove now
unnecessary casts added by thorpej in 1.11 of bktr_core.c. Strike one
from the TODO list.
 1.4 03-Sep-2000  wiz remove one
 1.3 07-May-2000  wiz man page is written, remove it from TODO
 1.2 07-May-2000  wiz add one
 1.1 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.5.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.4.1 08-Jan-2002  nathanw Catch up to -current.
 1.5.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.5.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.1 28-Oct-2000  bouyer file TODO was added on branch thorpej_scsipi on 2000-11-20 22:35:45 +0000
 1.7 08-Sep-2024  rillig normalize wording in import helpers
 1.6 30-Apr-2008  martin branches: 1.6.126;
Convert TNF licenses to new 2 clause variant
 1.5 21-Mar-2007  isaki branches: 1.5.30; 1.5.32; 1.5.34;
Fix mis-substitution of RCS Id, and avoid it.
Reviewed by wiz@.
 1.4 12-Mar-2003  wiz branches: 1.4.18; 1.4.56; 1.4.60; 1.4.62; 1.4.64;
Update script for bktr-sf imports.
 1.3 28-Oct-2000  wiz branches: 1.3.2;
Delete more files before import.
 1.2 07-May-2000  wiz multiple inclusion protection
 1.1 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.3.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 28-Oct-2000  bouyer file bktr2netbsd was added on branch thorpej_scsipi on 2000-11-20 22:35:45 +0000
 1.4.64.1 29-Mar-2007  reinoud Pullup to -current
 1.4.62.1 11-Jul-2007  mjf Sync with head.
 1.4.60.1 15-Jul-2007  ad Sync with head.
 1.4.56.1 24-Mar-2007  yamt sync with head.
 1.4.18.1 03-Sep-2007  yamt sync with head.
 1.5.34.1 16-May-2008  yamt sync with head.
 1.5.32.1 18-May-2008  yamt sync with head.
 1.5.30.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.126.1 02-Aug-2025  perseant Sync with HEAD
 1.20 19-Dec-2021  andvar fix various typos in bktr driver comments.
 1.19 07-Dec-2012  msaitoh - sprintf() -> snprintf()
- Fix typo in comment.
 1.18 16-Jan-2008  jmcneill branches: 1.18.44; 1.18.54;
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.17 19-Oct-2007  ad branches: 1.17.2; 1.17.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 24-Nov-2006  wiz branches: 1.16.2; 1.16.8; 1.16.16; 1.16.22; 1.16.24; 1.16.28;
s/existance/existence/, from Zafer.
 1.15 08-Mar-2006  lukem branches: 1.15.10; 1.15.12;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.14 06-Dec-2005  wiz branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10;
Handle MSP3435G the same as MSP3430G. From Scott Presnell in PR 28682.
 1.13 12-May-2004  wiz branches: 1.13.10; 1.13.12;
Fix typo in comment; from Robert Nagy via OpenBSD.
 1.12 12-Mar-2003  wiz branches: 1.12.2;
Merge some more.
 1.11 12-Mar-2003  wiz Merge first bktr-sf import.
 1.10 04-Jan-2003  wiz Spell output with two ts.
 1.9 13-Nov-2001  lukem add RCSIDs
 1.8 30-Dec-2000  wiz branches: 1.8.2; 1.8.4;
Merge 2.18 to trunk.
 1.7 28-Oct-2000  wiz branches: 1.7.2;
Merge 2.17 changes to trunk.
 1.6 01-Jul-2000  wiz resolve conflicts.
 1.5 21-May-2000  wiz branches: 1.5.4;
Use bktr_softc.bktr_dev.dv_xname instead of "bktr0" when printf'ing as
requested by Klaus Klein in kern/10166.
Also add device instance name to all printf's that didn't have it.
 1.4 07-May-2000  veego It is a bad idea to declare a static bootverbose variable here. Remove it.
 1.3 07-May-2000  wiz remove unnecessary output to console
 1.2 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.5 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.4 30-Dec-2000  wiz Import release 2.18 of the bktr driver. Changes since 2.17:
o Add new ioctls to allow userland programs fuller access to the I2C
bus, BT848_MSP_READ BT848_MSP_WRITE and BT848_MSP_RESET.
o Add tuner type 0x2a. Remove 0x2c which was incorrect.
o Christian Gusenbauer <Christian.Gusenbauer@netway.at> added support
for audio on Hauppauge cards without the audio mux. The MSP is used
for audio selection. (the 44xxx models)
 1.1.1.3 28-Oct-2000  wiz Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.5.4.1 03-Jul-2000  wiz Pull up revision 1.6 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.7.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.7.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 28-Oct-2000  bouyer file bktr_audio.c was added on branch thorpej_scsipi on 2000-11-20 22:35:45 +0000
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.2 07-Jan-2003  thorpej Sync with HEAD.
 1.8.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.12.2.4 11-Dec-2005  christos Sync with head.
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.12.4 21-Jan-2008  yamt sync with head
 1.13.12.3 27-Oct-2007  yamt sync with head.
 1.13.12.2 30-Dec-2006  yamt sync with head.
 1.13.12.1 21-Jun-2006  yamt sync with head.
 1.13.10.1 07-Dec-2005  riz Pull up following revision(s) (requested by wiz in ticket #1035):
sys/dev/pci/bktr/bktr_audio.c: revision 1.14
Handle MSP3435G the same as MSP3430G. From Scott Presnell in PR 28682.
 1.14.10.1 19-Apr-2006  elad sync with head.
 1.14.8.1 13-Mar-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.12.1 10-Dec-2006  yamt sync with head.
 1.15.10.1 12-Jan-2007  ad Sync with head.
 1.16.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.24.2 23-Mar-2008  matt sync with HEAD
 1.16.24.1 06-Nov-2007  matt sync with HEAD
 1.16.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.16.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.16.8.1 23-Oct-2007  ad Sync with head.
 1.16.2.1 21-Jan-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1046):
sys/dev/pci/bktr/bktr_reg.h: revision 1.18
sys/dev/pci/bktr/bktr_audio.c: revision 1.18
sys/dev/pci/bktr/bktr_os.c: revision 1.49
sys/dev/pci/bktr/bktr_core.c: revision 1.46
sys/dev/ic/bt8xx.h: revision 1.9
sys/dev/pci/bktr/bktr_core.h: revision 1.10
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.17.8.1 19-Jan-2008  bouyer Sync with HEAD
 1.17.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.54.1 25-Feb-2013  tls resync with head
 1.18.44.1 16-Jan-2013  yamt sync with (a bit old) head
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 12-May-2004  wiz Fix typo in comment; from Robert Nagy via OpenBSD.
 1.2 12-Mar-2003  wiz branches: 1.2.2;
Merge first bktr-sf import.
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.2 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.1 07-May-2000  wiz branches: 1.1.1.1.6;
Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.1.1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.6.1 07-May-2000  bouyer file bktr_audio.h was added on branch thorpej_scsipi on 2000-11-20 22:35:46 +0000
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.25 16-Oct-2013  christos remove unused variables.
 1.24 19-Oct-2007  ad branches: 1.24.54; 1.24.64; 1.24.70;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.23 16-Nov-2006  christos branches: 1.23.8; 1.23.22; 1.23.24; 1.23.28;
__unused removal on arguments; approved by core.
 1.22 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.21 06-Dec-2005  wiz branches: 1.21.20; 1.21.22;
Add support for two models of Terratec TValue cards.
From FreeBSD problem report 53383, submitted by Tanja Wittke,
updated by Simon Barner. Adapted for NetBSD by Alexander Becher,
via port-i386.
 1.20 30-May-2005  christos branches: 1.20.2;
- avoid variable shadowing
- add const
 1.19 24-Jul-2004  mrg match LeadTek's original PCI vendor ID as well as the 3-alternates
when setting CARD_LEADTEK. now with just

options BKTR_SYSTEM_DEFAULT=BROOKTREE_PAL

i get a shiny happy working card on my macppc box:

bktr0 at pci1 dev 18 function 0
bktr0: interrupting at irq 52
bktr0: Leadtek WinFast TV2000/VC100, Philips FR1216 PAL FM tuner.
 1.18 12-May-2004  wiz Add one more unofficial leadtek PCI vendor id; from Robert Nagy
via OpenBSD.
 1.17 23-Apr-2004  simonb s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
 1.16 30-Oct-2003  simonb Remove some assigned-to but otherwise unused variables.
 1.15 12-Mar-2003  wiz branches: 1.15.2;
Merge first bktr-sf import.
 1.14 14-Jan-2003  wiz Recognise tuner on WinTV-GO-FM. From PR 19844 by Wolfgang S. Rupprecht.
 1.13 10-Jan-2003  mjl Make this work on big endian platforms (mostly from OpenBSD):
Uploaded scripts work better if they are little endian, as the
card's engine expects, so convert to le first.

Also clean up attach routine a bit (use pa_id and PCI_REVISION
instead of fetching it ourselves).

This makes the driver work on my macppc G4, it can decode and
display video and tuner input. Sound does not seem to work, but
this may be my wonky formac bktr-for-macintosh card.
 1.12 23-Mar-2002  hamajima add WinFast VC100
 1.11 13-Nov-2001  lukem add RCSIDs
 1.10 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.9 30-Dec-2000  wiz branches: 1.9.2; 1.9.4; 1.9.6;
Merge 2.18 to trunk.
 1.8 28-Oct-2000  wiz branches: 1.8.2;
Merge 2.17 changes to trunk.
 1.7 03-Sep-2000  wiz Use NetBSD's pcidevs file for vendors/cards as much as possible.
Recognize Pinnacle Studio PCTV Rave as Miro card, tested by rh@netbsd.org.
 1.6 01-Jul-2000  wiz resolve conflicts.
 1.5 21-May-2000  wiz branches: 1.5.4;
Use bktr_softc.bktr_dev.dv_xname instead of "bktr0" when printf'ing as
requested by Klaus Klein in kern/10166.
Also add device instance name to all printf's that didn't have it.
 1.4 20-May-2000  augustss Add a missing bktr%d: in one of the attach messages.

(When is this code going to be KNFed?)
 1.3 07-May-2000  veego It is a bad idea to declare a static bootverbose variable here. Remove it.
 1.2 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.5 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.4 30-Dec-2000  wiz Import release 2.18 of the bktr driver. Changes since 2.17:
o Add new ioctls to allow userland programs fuller access to the I2C
bus, BT848_MSP_READ BT848_MSP_WRITE and BT848_MSP_RESET.
o Add tuner type 0x2a. Remove 0x2c which was incorrect.
o Christian Gusenbauer <Christian.Gusenbauer@netway.at> added support
for audio on Hauppauge cards without the audio mux. The MSP is used
for audio selection. (the 44xxx models)
 1.1.1.3 28-Oct-2000  wiz Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.5.4.1 03-Jul-2000  wiz Pull up revision 1.6 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.8.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.8.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.8.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.2.1 28-Oct-2000  bouyer file bktr_card.c was added on branch thorpej_scsipi on 2000-11-20 22:35:46 +0000
 1.9.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.9.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.4 15-Jan-2003  thorpej Sync with HEAD.
 1.9.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.9.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.9.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.15.2.5 11-Dec-2005  christos Sync with head.
 1.15.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.20.2.3 27-Oct-2007  yamt sync with head.
 1.20.2.2 30-Dec-2006  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.21.22.2 10-Dec-2006  yamt sync with head.
 1.21.22.1 22-Oct-2006  yamt sync with head
 1.21.20.1 18-Nov-2006  ad Sync with head.
 1.23.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.24.1 06-Nov-2007  matt sync with HEAD
 1.23.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.23.8.1 23-Oct-2007  ad Sync with head.
 1.24.70.1 18-May-2014  rmind sync with head
 1.24.64.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.54.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6 24-Aug-2012  msaitoh Fix typos
 1.5 06-Dec-2005  wiz branches: 1.5.110;
Add support for two models of Terratec TValue cards.
From FreeBSD problem report 53383, submitted by Tanja Wittke,
updated by Simon Barner. Adapted for NetBSD by Alexander Becher,
via port-i386.
 1.4 12-Mar-2003  wiz branches: 1.4.2; 1.4.18;
Merge first bktr-sf import.
 1.3 01-Jul-2000  wiz branches: 1.3.2;
resolve conflicts.
 1.2 07-May-2000  wiz branches: 1.2.4;
Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.3 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.2.4.1 03-Jul-2000  wiz Pull up revision 1.3 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 01-Jul-2000  bouyer file bktr_card.h was added on branch thorpej_scsipi on 2000-11-20 22:35:46 +0000
 1.4.18.1 21-Jun-2006  yamt sync with head.
 1.4.2.1 11-Dec-2005  christos Sync with head.
 1.5.110.1 30-Oct-2012  yamt sync with head
 1.60 27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.59 19-Dec-2021  andvar branches: 1.59.10;
fix various typos in bktr driver comments.
 1.58 23-May-2020  ad Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.57 23-Feb-2020  skrll typo in comment
 1.56 03-Feb-2019  mrg branches: 1.56.6;
- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.55 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.54 14-Dec-2012  joerg branches: 1.54.36; 1.54.38;
bt848_format is only defined in a __FreeBSD__ section of bktr_os.c and
overriding the local (static) definition with extern is bogus.
 1.53 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.52 30-Jun-2011  wiz branches: 1.52.2; 1.52.12;
dependant -> dependent
 1.51 13-Nov-2010  uebayasi Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.
 1.50 18-Mar-2009  cegger branches: 1.50.4;
bzero -> memset
 1.49 24-Apr-2008  ad branches: 1.49.2; 1.49.10; 1.49.16;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.48 10-Apr-2008  cegger branches: 1.48.2;
use aprint_*_dev and device_xname
 1.47 01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.46 16-Jan-2008  jmcneill branches: 1.46.2; 1.46.6;
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.45 04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.44 19-Oct-2007  ad branches: 1.44.2; 1.44.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.43 09-Jul-2007  ad branches: 1.43.6; 1.43.8; 1.43.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.42 04-Mar-2007  christos branches: 1.42.2; 1.42.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.41 09-Feb-2007  ad branches: 1.41.2;
Merge newlock2 to head.
 1.40 16-Nov-2006  christos branches: 1.40.2; 1.40.4;
__unused removal on arguments; approved by core.
 1.39 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.38 03-Sep-2006  bouyer branches: 1.38.2; 1.38.4;
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.37 28-Aug-2006  christos remove unreachable code.
 1.36 11-Dec-2005  christos branches: 1.36.4; 1.36.8; 1.36.18;
merge ktrace-lwp.
 1.35 30-May-2005  wiz branches: 1.35.2;
Fix replaco in comment.
 1.34 30-May-2005  christos - avoid variable shadowing
- add const
 1.33 29-Jun-2003  fvdl branches: 1.33.2; 1.33.16;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.32 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.31 03-May-2003  wiz DMA, not dma nor Dma.
 1.30 28-Apr-2003  fvdl Quell a strict-alias warning by applying the same cast to '&target' as
already done in all other cases.
 1.29 12-Mar-2003  wiz Merge some more.
 1.28 12-Mar-2003  wiz Merge first bktr-sf import.
 1.27 10-Jan-2003  mjl Make this work on big endian platforms (mostly from OpenBSD):
Uploaded scripts work better if they are little endian, as the
card's engine expects, so convert to le first.

Also clean up attach routine a bit (use pa_id and PCI_REVISION
instead of fetching it ourselves).

This makes the driver work on my macppc G4, it can decode and
display video and tuner input. Sound does not seem to work, but
this may be my wonky formac bktr-for-macintosh card.
 1.26 25-Dec-2002  toshii Fix broken programming of VSCALE_HI registers in yuv422_prog.
 1.25 25-Dec-2002  toshii Consistently use BKTR_GEN_IRQ and BKTR_RESYNC instead of numbers.
Also, do some whitespace cleanup.
 1.24 25-Dec-2002  toshii Merge FreeBSD rev.1.122:
Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.
 1.23 26-Nov-2002  christos si_ -> sel_
 1.22 28-Aug-2002  toshii Remove a superfluous interrupt request bit in yuvpack_prog,
which confuses the state machine in common_bktr_intr.
This makes "mplayer -tv ..." work (but only with NTSC).
 1.21 22-May-2002  wiz bcmp -> memcmp.
 1.20 13-Nov-2001  lukem branches: 1.20.8;
add RCSIDs
 1.19 28-Sep-2001  chs don't depend on other headers to include sys/proc.h for us.
 1.18 18-Sep-2001  wiz Give initiali[sz]e all the "i"s it deserves.
 1.17 03-Mar-2001  mjl branches: 1.17.2; 1.17.4; 1.17.6;
Correct wrong error return in mmap fn.
 1.16 01-Mar-2001  mjl Fix typo to make this compile even w/ debug defines.
 1.15 18-Jan-2001  jdolecek constify
 1.14 30-Dec-2000  wiz Merge 2.18 to trunk.
 1.13 28-Oct-2000  wiz branches: 1.13.2;
Replace remaining vm_offset_t's in NetBSD code by vaddr_t; remove now
unnecessary casts added by thorpej in 1.11 of bktr_core.c. Strike one
from the TODO list.
 1.12 28-Oct-2000  wiz Merge 2.17 changes to trunk.
 1.11 06-Sep-2000  thorpej Cast the argument to vtophys() to vaddr_t.
 1.10 03-Sep-2000  wiz Use NetBSD's pcidevs file for vendors/cards as much as possible.
Recognize Pinnacle Studio PCTV Rave as Miro card, tested by rh@netbsd.org.
 1.9 01-Jul-2000  wiz remove unnecessary #ifdef __NetBSD__'s in #ifdef __FreeBSD__;
move one #include <vm/vm.h> into #ifndef __NetBSD__
 1.8 01-Jul-2000  wiz resolve conflicts.
 1.7 30-Jun-2000  veego Move the include of <vm/vm.h> into the ifndef __NetBSD__ part.
 1.6 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.5 22-May-2000  wiz branches: 1.5.4;
Replaced overlooked BROOKTREE_SYSTEM_DEFAULT with BKTR_SYSTEM_DEFAULT,
as noted by Roger Hardiman.
 1.4 21-May-2000  wiz Use bktr_softc.bktr_dev.dv_xname instead of "bktr0" when printf'ing as
requested by Klaus Klein in kern/10166.
Also add device instance name to all printf's that didn't have it.
 1.3 07-May-2000  veego It is a bad idea to declare a static bootverbose variable here. Remove it.
 1.2 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.5 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.4 30-Dec-2000  wiz Import release 2.18 of the bktr driver. Changes since 2.17:
o Add new ioctls to allow userland programs fuller access to the I2C
bus, BT848_MSP_READ BT848_MSP_WRITE and BT848_MSP_RESET.
o Add tuner type 0x2a. Remove 0x2c which was incorrect.
o Christian Gusenbauer <Christian.Gusenbauer@netway.at> added support
for audio on Hauppauge cards without the audio mux. The MSP is used
for audio selection. (the 44xxx models)
 1.1.1.3 28-Oct-2000  wiz Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.5.4.1 03-Jul-2000  wiz Pull up revision 1.9 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.13.2.6 12-Mar-2001  bouyer Sync with HEAD.
 1.13.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.13.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.13.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.13.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.2.1 28-Oct-2000  bouyer file bktr_core.c was added on branch thorpej_scsipi on 2000-11-20 22:35:46 +0000
 1.17.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.17.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.17.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.17.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.2.8 15-Jan-2003  thorpej Sync with HEAD.
 1.17.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.17.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.17.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.17.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.17.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.17.2.2 08-Oct-2001  nathanw Catch up to -current.
 1.17.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.20.8.2 29-Aug-2002  gehenna catch up with -current.
 1.20.8.1 30-May-2002  gehenna Catch up with -current.
 1.33.16.2 18-Nov-2006  bouyer Apply patch (requested by aymeric in ticket #1587)
fix bug introduced by missing braces around a if() block in
ticket #1511
 1.33.16.1 16-Sep-2006  ghen branches: 1.33.16.1.2;
Pull up following revision(s) (requested by bouyer in ticket #1511):
sys/dev/pci/bktr/bktr_core.c: revision 1.38
sys/dev/pci/bktr/bktr_os.c: revision 1.43
sys/dev/pci/bktr/bktr_core.h: revision 1.8
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.33.16.1.2.1 18-Nov-2006  bouyer Apply patch (requested by aymeric in ticket #1587)
fix bug introduced by missing braces around a if() block in
ticket #1511
 1.33.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.33.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.33.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.35.2.7 17-Mar-2008  yamt sync with head.
 1.35.2.6 21-Jan-2008  yamt sync with head
 1.35.2.5 27-Oct-2007  yamt sync with head.
 1.35.2.4 03-Sep-2007  yamt sync with head.
 1.35.2.3 26-Feb-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.36.18.1 14-Sep-2006  riz Pull up following revision(s) (requested by bouyer in ticket #151):
sys/dev/pci/bktr/bktr_core.c: revision 1.38
sys/dev/pci/bktr/bktr_os.c: revision 1.43
sys/dev/pci/bktr/bktr_core.h: revision 1.8
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.36.8.2 14-Sep-2006  yamt sync with head.
 1.36.8.1 03-Sep-2006  yamt sync with head.
 1.36.4.1 09-Sep-2006  rpaulo sync with head
 1.38.4.2 10-Dec-2006  yamt sync with head.
 1.38.4.1 22-Oct-2006  yamt sync with head
 1.38.2.2 19-Jan-2007  ad Acquire proclist_mutex before sending signals.
 1.38.2.1 18-Nov-2006  ad Sync with head.
 1.40.4.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.40.2.1 21-Jan-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1046):
sys/dev/pci/bktr/bktr_reg.h: revision 1.18
sys/dev/pci/bktr/bktr_audio.c: revision 1.18
sys/dev/pci/bktr/bktr_os.c: revision 1.49
sys/dev/pci/bktr/bktr_core.c: revision 1.46
sys/dev/ic/bt8xx.h: revision 1.9
sys/dev/pci/bktr/bktr_core.h: revision 1.10
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.41.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.42.4.1 11-Jul-2007  mjf Sync with head.
 1.42.2.2 23-Oct-2007  ad Sync with head.
 1.42.2.1 10-Apr-2007  ad Changes to select/poll:

- Make them MP safe and decouple from the proc locks.
- selwakeup: don't call p_find, or traverse per-proc LWP lists (ouch).
- selwakeup: don't lock the sleep queue unless we need to.
 1.43.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.43.8.3 23-Mar-2008  matt sync with HEAD
 1.43.8.2 09-Jan-2008  matt sync with HEAD
 1.43.8.1 06-Nov-2007  matt sync with HEAD
 1.43.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.44.8.2 19-Jan-2008  bouyer Sync with HEAD
 1.44.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.44.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.46.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.46.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.46.2.1 24-Mar-2008  keiichi sync with head.
 1.48.2.1 18-May-2008  yamt sync with head.
 1.49.16.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.49.10.1 28-Apr-2009  skrll Sync with HEAD.
 1.49.2.1 04-May-2009  yamt sync with head.
 1.50.4.1 05-Mar-2011  rmind sync with head
 1.52.12.2 25-Feb-2013  tls resync with head
 1.52.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.52.2.2 23-Jan-2013  yamt sync with head
 1.52.2.1 30-Oct-2012  yamt sync with head
 1.54.38.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.54.38.1 10-Jun-2019  christos Sync with HEAD
 1.54.36.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.56.6.1 29-Feb-2020  ad Sync with head.
 1.59.10.1 02-Aug-2025  perseant Sync with HEAD
 1.12 22-May-2022  andvar fix various small typos, mainly in comments.
 1.11 19-Dec-2021  andvar fix various typos in bktr driver comments.
 1.10 16-Jan-2008  jmcneill Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.9 04-Mar-2007  christos branches: 1.9.16; 1.9.22; 1.9.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.8 03-Sep-2006  bouyer branches: 1.8.6; 1.8.8; 1.8.12;
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.8; 1.7.18;
merge ktrace-lwp.
 1.6 29-Jun-2003  fvdl branches: 1.6.2; 1.6.16; 1.6.18;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.5 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.4 12-Mar-2003  wiz Merge first bktr-sf import.
 1.3 01-Jul-2000  wiz branches: 1.3.2;
resolve conflicts.
 1.2 21-May-2000  wiz branches: 1.2.4;
Use bktr_softc.bktr_dev.dv_xname instead of "bktr0" when printf'ing as
requested by Klaus Klein in kern/10166.
Also add device instance name to all printf's that didn't have it.
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.3 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.2.4.1 03-Jul-2000  wiz Pull up revision 1.3 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 01-Jul-2000  bouyer file bktr_core.h was added on branch thorpej_scsipi on 2000-11-20 22:35:47 +0000
 1.6.18.4 21-Jan-2008  yamt sync with head
 1.6.18.3 03-Sep-2007  yamt sync with head.
 1.6.18.2 30-Dec-2006  yamt sync with head.
 1.6.18.1 21-Jun-2006  yamt sync with head.
 1.6.16.1 16-Sep-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1511):
sys/dev/pci/bktr/bktr_core.c: revision 1.38
sys/dev/pci/bktr/bktr_os.c: revision 1.43
sys/dev/pci/bktr/bktr_core.h: revision 1.8
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.7.18.1 14-Sep-2006  riz Pull up following revision(s) (requested by bouyer in ticket #151):
sys/dev/pci/bktr/bktr_core.c: revision 1.38
sys/dev/pci/bktr/bktr_os.c: revision 1.43
sys/dev/pci/bktr/bktr_core.h: revision 1.8
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.7.8.1 14-Sep-2006  yamt sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.12.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.8.8.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.6.1 21-Jan-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1046):
sys/dev/pci/bktr/bktr_reg.h: revision 1.18
sys/dev/pci/bktr/bktr_audio.c: revision 1.18
sys/dev/pci/bktr/bktr_os.c: revision 1.49
sys/dev/pci/bktr/bktr_core.c: revision 1.46
sys/dev/ic/bt8xx.h: revision 1.9
sys/dev/pci/bktr/bktr_core.h: revision 1.10
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.9.28.1 19-Jan-2008  bouyer Sync with HEAD
 1.9.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.16.1 23-Mar-2008  matt sync with HEAD
 1.5 18-Mar-2009  cegger bzero -> memset
 1.4 04-Mar-2007  christos branches: 1.4.40; 1.4.50; 1.4.56;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 12-Mar-2003  wiz branches: 1.3.18; 1.3.56;
Merge first bktr-sf import.
 1.2 13-Nov-2001  lukem add RCSIDs
 1.1 28-Oct-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.2 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.1 28-Oct-2000  wiz branches: 1.1.1.1.2; 1.1.1.1.4; 1.1.1.1.6;
Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.1.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.1.1.4.1 14-Nov-2001  nathanw Catch up to -current.
 1.1.1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.1.1.2.1 28-Oct-2000  bouyer file bktr_mem.c was added on branch thorpej_scsipi on 2000-11-22 16:04:30 +0000
 1.3.56.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.18.1 03-Sep-2007  yamt sync with head.
 1.4.56.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.50.1 28-Apr-2009  skrll Sync with HEAD.
 1.4.40.1 04-May-2009  yamt sync with head.
 1.2 12-Mar-2003  wiz Merge first bktr-sf import.
 1.1 28-Oct-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.2 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.1 28-Oct-2000  wiz branches: 1.1.1.1.2;
Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.1.1.2.1 28-Oct-2000  bouyer file bktr_mem.h was added on branch thorpej_scsipi on 2000-11-22 16:04:31 +0000
 1.69 23-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev/pci;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

XXX XXX XXX
Compile test only (for amd64/ALL).

Thanks riastradh@ for double check.
 1.68 09-Dec-2018  jdolecek use pci_intr_establish_xname()
 1.67 14-Jul-2016  msaitoh branches: 1.67.16; 1.67.18;
- Use aprint*() more in xxx_attach().
- Add missing aprint_naive("\n").
- Remove extra spaces and tabs.
- KNF.
 1.66 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.65 25-Jul-2014  dholland branches: 1.65.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.64 29-Mar-2014  christos branches: 1.64.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.63 16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.62 10-Aug-2013  dholland Redo -r1.53 correctly.
 1.61 27-Oct-2012  chs branches: 1.61.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.60 30-Jun-2011  wiz branches: 1.60.2; 1.60.12;
dependant -> dependent
 1.59 23-Apr-2010  macallan don't try to print a bus_space_handle_t
now this at least compiles on sparc64
 1.58 22-Mar-2010  dyoung MI code must not printf() a bus_space_tag_t, so don't do that.
 1.57 06-May-2009  cegger branches: 1.57.2; 1.57.4;
struct device * -> device_t, no functional changes intended.
 1.56 06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.55 15-Mar-2009  cegger ansify function definitions
 1.54 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.53 24-Jun-2008  gmcgarry branches: 1.53.4; 1.53.10;
Both legs of a digraph must return the same type. Therefore, replace digraph.
 1.52 08-Jun-2008  tsutsui branches: 1.52.2;
Use device_lookup_private() rather than using cd_devs[] directly to get softc.

XXX maybe we should change a type of cd_devs[] in struct cfdriver
from (void *) to device_t.
 1.51 10-Apr-2008  cegger branches: 1.51.2; 1.51.4; 1.51.6;
use aprint_*_dev and device_xname
 1.50 01-Mar-2008  rmind Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.49 16-Jan-2008  jmcneill branches: 1.49.2; 1.49.6;
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.48 19-Oct-2007  ad branches: 1.48.2; 1.48.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.47 25-Sep-2007  ad branches: 1.47.2;
Use selinit() / seldestroy().
 1.46 04-Mar-2007  christos branches: 1.46.2; 1.46.14; 1.46.16; 1.46.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.45 16-Nov-2006  christos branches: 1.45.2; 1.45.4; 1.45.8;
__unused removal on arguments; approved by core.
 1.44 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.43 03-Sep-2006  bouyer branches: 1.43.2; 1.43.4;
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.42 28-Aug-2006  christos remove unreachable code.
 1.41 28-Aug-2006  christos add missing initializer.
 1.40 28-Mar-2006  thorpej branches: 1.40.6;
Use device_unit().
 1.39 11-Dec-2005  christos branches: 1.39.4; 1.39.6; 1.39.8; 1.39.10; 1.39.12;
merge ktrace-lwp.
 1.38 29-Oct-2004  yamt branches: 1.38.10; 1.38.12;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.37 29-Jun-2003  fvdl branches: 1.37.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.36 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.35 12-Mar-2003  wiz Merge first bktr-sf import.
 1.34 10-Jan-2003  mjl Make this work on big endian platforms (mostly from OpenBSD):
Uploaded scripts work better if they are little endian, as the
card's engine expects, so convert to le first.

Also clean up attach routine a bit (use pa_id and PCI_REVISION
instead of fetching it ourselves).

This makes the driver work on my macppc G4, it can decode and
display video and tuner input. Sound does not seem to work, but
this may be my wonky formac bktr-for-macintosh card.
 1.33 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.32 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.31 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.30 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.29 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.28 07-Jan-2002  jmcneill branches: 1.28.8;
Re-enable radio at bktr, only if NRADIO > 0 and an FM tuner is present.
 1.27 07-Jan-2002  tron Disable broken radio(4) support for bktr(4). The configuration code doesn't
even check if the TV card has a radio tuner.
 1.26 07-Jan-2002  tron Clean up preprocess handling of optional radio(4) support a little bit.
 1.25 06-Jan-2002  tron Compile in radio(4) only it is activated in the kernel configuration.
 1.24 06-Jan-2002  jmcneill Add missing definition of STATUSBIT_STEREO.
 1.23 06-Jan-2002  jmcneill Add basic support for the radio(4) interface.
 1.22 13-Nov-2001  lukem add RCSIDs
 1.21 18-Oct-2001  wiz Fix check in device open.
Patch by KUROSAWA Takahiro in kern/14289.
 1.20 18-Sep-2001  wiz Give initiali[sz]e all the "i"s it deserves.
 1.19 15-Mar-2001  ross branches: 1.19.2; 1.19.4;
LP64 a kprintf(9)
 1.18 03-Mar-2001  mjl branches: 1.18.2;
Correct wrong error return in mmap fn.
 1.17 30-Dec-2000  wiz Undo pci_intr_map change in non-NetBSD part of the file.
 1.16 30-Dec-2000  wiz Merge 2.18 to trunk.
 1.15 28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.14 28-Oct-2000  wiz branches: 1.14.2;
Replace remaining vm_offset_t's in NetBSD code by vaddr_t; remove now
unnecessary casts added by thorpej in 1.11 of bktr_core.c. Strike one
from the TODO list.
 1.13 28-Oct-2000  wiz Merge 2.17 changes to trunk.
 1.12 03-Sep-2000  wiz Use NetBSD's pcidevs file for vendors/cards as much as possible.
Recognize Pinnacle Studio PCTV Rave as Miro card, tested by rh@netbsd.org.
 1.11 01-Jul-2000  wiz remove unnecessary #ifdef __NetBSD__'s in #ifdef __FreeBSD__;
move one #include <vm/vm.h> into #ifndef __NetBSD__
 1.10 01-Jul-2000  wiz resolve conflicts.
 1.9 30-Jun-2000  veego Move the include of <vm/vm.h> into the ifndef __NetBSD__ part.
 1.8 27-Jun-2000  simonb Revert some of the previous mmap() changes that were in "#ifdef FreeBSD"
parts of this file.
 1.7 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.6 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.5 21-May-2000  wiz branches: 1.5.4;
Use bktr_softc.bktr_dev.dv_xname instead of "bktr0" when printf'ing as
requested by Klaus Klein in kern/10166.
Also add device instance name to all printf's that didn't have it.
 1.4 07-May-2000  veego It is a bad idea to declare a static bootverbose variable here. Remove it.
 1.3 07-May-2000  wiz compilation fix
 1.2 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.5 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.4 30-Dec-2000  wiz Import release 2.18 of the bktr driver. Changes since 2.17:
o Add new ioctls to allow userland programs fuller access to the I2C
bus, BT848_MSP_READ BT848_MSP_WRITE and BT848_MSP_RESET.
o Add tuner type 0x2a. Remove 0x2c which was incorrect.
o Christian Gusenbauer <Christian.Gusenbauer@netway.at> added support
for audio on Hauppauge cards without the audio mux. The MSP is used
for audio selection. (the 44xxx models)
 1.1.1.3 28-Oct-2000  wiz Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.5.4.3 24-Oct-2001  jhawk Pull up revision 1.21 (requested by lukem):
Check unit count correctly (correct fencepost error)
on device open.
 1.5.4.2 03-Jul-2000  wiz Pull up revision 1.11 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.5.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.14.2.6 27-Mar-2001  bouyer Sync with HEAD.
 1.14.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.14.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.14.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.14.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.14.2.1 28-Oct-2000  bouyer file bktr_os.c was added on branch thorpej_scsipi on 2000-11-20 22:35:47 +0000
 1.18.2.10 15-Jan-2003  thorpej Sync with HEAD.
 1.18.2.9 11-Nov-2002  nathanw Catch up to -current
 1.18.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.18.2.7 17-Sep-2002  nathanw Catch up to -current.
 1.18.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.18.2.5 11-Jan-2002  nathanw More catchup.
 1.18.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.18.2.3 22-Oct-2001  nathanw Catch up to -current.
 1.18.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.18.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.19.4.3 01-Oct-2001  fvdl Catch up with -current.
 1.19.4.2 26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.19.4.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.19.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.19.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.28.8.1 16-May-2002  gehenna Add the character device switch.
 1.37.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.37.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.37.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.37.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.38.12.6 17-Mar-2008  yamt sync with head.
 1.38.12.5 21-Jan-2008  yamt sync with head
 1.38.12.4 27-Oct-2007  yamt sync with head.
 1.38.12.3 03-Sep-2007  yamt sync with head.
 1.38.12.2 30-Dec-2006  yamt sync with head.
 1.38.12.1 21-Jun-2006  yamt sync with head.
 1.38.10.1 16-Sep-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1511):
sys/dev/pci/bktr/bktr_core.c: revision 1.38
sys/dev/pci/bktr/bktr_os.c: revision 1.43
sys/dev/pci/bktr/bktr_core.h: revision 1.8
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.39.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.39.10.1 19-Apr-2006  elad sync with head.
 1.39.8.3 14-Sep-2006  yamt sync with head.
 1.39.8.2 03-Sep-2006  yamt sync with head.
 1.39.8.1 01-Apr-2006  yamt sync with head.
 1.39.6.1 22-Apr-2006  simonb Sync with head.
 1.39.4.1 09-Sep-2006  rpaulo sync with head
 1.40.6.1 14-Sep-2006  riz Pull up following revision(s) (requested by bouyer in ticket #151):
sys/dev/pci/bktr/bktr_core.c: revision 1.38
sys/dev/pci/bktr/bktr_os.c: revision 1.43
sys/dev/pci/bktr/bktr_core.h: revision 1.8
stop attaching when a bus_dma operation fails, instead of using bogus
addresses.
Remplace vtophys() with proper bus_dma(9) use.
This driver now works properly on Xen
 1.43.4.2 10-Dec-2006  yamt sync with head.
 1.43.4.1 22-Oct-2006  yamt sync with head
 1.43.2.1 18-Nov-2006  ad Sync with head.
 1.45.8.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.45.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.45.2.1 21-Jan-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1046):
sys/dev/pci/bktr/bktr_reg.h: revision 1.18
sys/dev/pci/bktr/bktr_audio.c: revision 1.18
sys/dev/pci/bktr/bktr_os.c: revision 1.49
sys/dev/pci/bktr/bktr_core.c: revision 1.46
sys/dev/ic/bt8xx.h: revision 1.9
sys/dev/pci/bktr/bktr_core.h: revision 1.10
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.46.18.1 06-Oct-2007  yamt sync with head.
 1.46.16.2 23-Mar-2008  matt sync with HEAD
 1.46.16.1 06-Nov-2007  matt sync with HEAD
 1.46.14.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.14.1 02-Oct-2007  joerg Sync with HEAD.
 1.46.2.2 23-Oct-2007  ad Sync with head.
 1.46.2.1 09-Oct-2007  ad Sync with head.
 1.47.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.48.8.1 19-Jan-2008  bouyer Sync with HEAD
 1.48.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.49.6.4 29-Jun-2008  mjf Sync with HEAD.
 1.49.6.3 02-Jun-2008  mjf Sync with HEAD.
 1.49.6.2 05-Apr-2008  mjf - add "file-system DEVFS" and "pseudo-device devfsctl" to conf/std seeing
as these are always needed.

- convert many, many drivers over to the New Devfs World Order. For a
list of device drivers yet to be converted see,
http://www.netbsd.org/~mjf/devfs-todo.html.

- add a new device_unregister_all(device_t) function to remove all device
names associated with a device_t, which saves us having to construct
device names when the driver is detached.

- add a DEV_AUDIO type for devices.
 1.49.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.49.2.1 24-Mar-2008  keiichi sync with head.
 1.51.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.51.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.4.3 11-Aug-2010  yamt sync with head.
 1.51.4.2 16-May-2009  yamt sync with head
 1.51.4.1 04-May-2009  yamt sync with head.
 1.51.2.1 17-Jun-2008  yamt sync with head.
 1.52.2.1 27-Jun-2008  simonb Sync with head.
 1.53.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.57.4.1 30-May-2010  rmind sync with head
 1.57.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.60.12.3 03-Dec-2017  jdolecek update from HEAD
 1.60.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.60.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.60.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.60.2.1 30-Oct-2012  yamt sync with head
 1.61.2.2 18-May-2014  rmind sync with head
 1.61.2.1 28-Aug-2013  rmind sync with head
 1.64.2.1 10-Aug-2014  tls Rebase.
 1.65.4.2 05-Oct-2016  skrll Sync with HEAD
 1.65.4.1 09-Jul-2016  skrll Sync with HEAD
 1.67.18.1 10-Jun-2019  christos Sync with HEAD
 1.67.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7 30-Jun-2011  wiz dependant -> dependent
 1.6 12-Mar-2003  wiz Merge first bktr-sf import.
 1.5 16-Mar-2001  ross Sigh.

Revert the revert. Naturally, I considered OpenBSD and FreeBSD when I fixed
the incorrect use of the spl*() interface. The change I made is _required_
for both NetBSD _and_ OpenBSD, or the code won't even COMPILE except on
i386, and it is acceptable on FreeBSD. Your revert and mod rebroke it on
OpenBSD and tangled things up on NetBSD. It made no difference on FreeBSD.

In particular, there are 2,895 uses of splx() within the FreeBSD kernel,
and only a mere 21, that's "twenty one" uses of intrmask_t, and those are
almost exclusively in the guts of the interrupt implementation, _not_ in
the _use_ of the exported spl*() functions. It's perfectly OK to `int s
= spltty()' in a portable driver in FreeBSD.

For that matter, FreeBSD (-current at least) does not even *use* spl*()
any more and stubs them all out with inlines that do _nothing_ except return
0, making intrmask_t vs int _even less_ important there than it already
was.

I think it's great that you want to start hacking on the kernel, but do
note that this is certainly the most simple of the kernel interfaces. It
just gets worse from here. Be careful out there!
 1.4 16-Mar-2001  wiz Restore non-NetBSD parts -- we're still sharing this code.
 1.3 15-Mar-2001  ross Do critical sections a better way.
 1.2 28-Oct-2000  wiz branches: 1.2.2; 1.2.4;
Replace remaining vm_offset_t's in NetBSD code by vaddr_t; remove now
unnecessary casts added by thorpej in 1.11 of bktr_core.c. Strike one
from the TODO list.
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.3 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz branches: 1.1.1.1.4;
Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.1.1.1.4.1 03-Jul-2000  wiz Pull up revision 1.1.1.2 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.2.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.2.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.2.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 28-Oct-2000  bouyer file bktr_os.h was added on branch thorpej_scsipi on 2000-11-20 22:35:47 +0000
 1.22 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.21 26-Jan-2011  dyoung branches: 1.21.4; 1.21.14;
unifdef -U__bsdi__ -U__FreeBSD__ -D__NetBSD__. No functional change
intended.
 1.20 06-May-2009  cegger branches: 1.20.4; 1.20.6; 1.20.8;
struct device * -> device_t, no functional changes intended.
 1.19 24-Apr-2008  ad branches: 1.19.2; 1.19.16;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.18 16-Jan-2008  jmcneill branches: 1.18.6; 1.18.8;
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.17 19-Oct-2007  ad branches: 1.17.2; 1.17.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.16 30-Dec-2005  mjl branches: 1.16.24; 1.16.30; 1.16.38; 1.16.44; 1.16.46; 1.16.50;
This part got lost during merging with the sourceforge bktr
driver: "Also make those variables int instead of char so it
can actually hold 454...".
 1.15 11-Dec-2005  christos merge ktrace-lwp.
 1.14 30-May-2005  christos branches: 1.14.2;
- avoid variable shadowing
- add const
 1.13 12-Mar-2003  wiz branches: 1.13.2;
Merge first bktr-sf import.
 1.12 10-Jan-2003  mjl Make this work on big endian platforms (mostly from OpenBSD):
Uploaded scripts work better if they are little endian, as the
card's engine expects, so convert to le first.

Also clean up attach routine a bit (use pa_id and PCI_REVISION
instead of fetching it ourselves).

This makes the driver work on my macppc G4, it can decode and
display video and tuner input. Sound does not seem to work, but
this may be my wonky formac bktr-for-macintosh card.
 1.11 23-Oct-2002  christos remove duplicate cpp defs.
 1.10 18-Sep-2001  wiz Give initiali[sz]e all the "i"s it deserves.
 1.9 30-Dec-2000  wiz branches: 1.9.2; 1.9.4; 1.9.6;
Merge 2.18 to trunk.
 1.8 28-Oct-2000  wiz branches: 1.8.2;
Merge 2.17 changes to trunk.
 1.7 24-Sep-2000  jdolecek use new generic bootverbose instead of local definition
 1.6 03-Sep-2000  wiz Use NetBSD's pcidevs file for vendors/cards as much as possible.
Recognize Pinnacle Studio PCTV Rave as Miro card, tested by rh@netbsd.org.
 1.5 01-Jul-2000  wiz resolve conflicts.
 1.4 07-May-2000  veego branches: 1.4.4;
Change one 0 for bootverbose to 1 if DEBUG is defined.
 1.3 07-May-2000  veego Add a dummy bootverbose.
 1.2 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.5 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.4 30-Dec-2000  wiz Import release 2.18 of the bktr driver. Changes since 2.17:
o Add new ioctls to allow userland programs fuller access to the I2C
bus, BT848_MSP_READ BT848_MSP_WRITE and BT848_MSP_RESET.
o Add tuner type 0x2a. Remove 0x2c which was incorrect.
o Christian Gusenbauer <Christian.Gusenbauer@netway.at> added support
for audio on Hauppauge cards without the audio mux. The MSP is used
for audio selection. (the 44xxx models)
 1.1.1.3 28-Oct-2000  wiz Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.4.4.1 03-Jul-2000  wiz Pull up revision 1.5 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.8.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.8.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.8.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.2.1 28-Oct-2000  bouyer file bktr_reg.h was added on branch thorpej_scsipi on 2000-11-20 22:35:47 +0000
 1.9.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.9.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.2.3 15-Jan-2003  thorpej Sync with HEAD.
 1.9.2.2 11-Nov-2002  nathanw Catch up to -current
 1.9.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.13.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.3 21-Jan-2008  yamt sync with head
 1.14.2.2 27-Oct-2007  yamt sync with head.
 1.14.2.1 21-Jun-2006  yamt sync with head.
 1.16.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.16.46.2 23-Mar-2008  matt sync with HEAD
 1.16.46.1 06-Nov-2007  matt sync with HEAD
 1.16.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.16.38.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.16.30.1 23-Oct-2007  ad Sync with head.
 1.16.24.1 21-Jan-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1046):
sys/dev/pci/bktr/bktr_reg.h: revision 1.18
sys/dev/pci/bktr/bktr_audio.c: revision 1.18
sys/dev/pci/bktr/bktr_os.c: revision 1.49
sys/dev/pci/bktr/bktr_core.c: revision 1.46
sys/dev/ic/bt8xx.h: revision 1.9
sys/dev/pci/bktr/bktr_core.h: revision 1.10
Don't assume that sizeof(long) == sizeof(int); makes bktr work on amd64.
 1.17.8.1 19-Jan-2008  bouyer Sync with HEAD
 1.17.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.18.8.1 18-May-2008  yamt sync with head.
 1.18.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.16.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.2.1 16-May-2009  yamt sync with head
 1.20.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.20.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.4.1 05-Mar-2011  rmind sync with head
 1.21.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.4.1 30-Oct-2012  yamt sync with head
 1.13 19-Dec-2021  andvar fix various typos in bktr driver comments.
 1.12 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 28-Dec-2005  wiz branches: 1.11.30; 1.11.44; 1.11.46; 1.11.50;
Sync with SourceForge 1.5:
revision 1.5
date: 2003/03/13 22:21:04; author: emsi; state: Exp; lines: +17 -18
Fill in band switch crosspoints and use that instead of hardcoded
values in the band switching code. For now fill in the formerly
hard-coded values 160 and 454 until we can find out the real values
for each tuner. Also make those variables int instead of char
so it can actually hold 454...
 1.10 12-Mar-2003  wiz branches: 1.10.18;
Merge first bktr-sf import.
 1.9 13-Nov-2001  lukem add RCSIDs
 1.8 18-Jan-2001  jdolecek branches: 1.8.2; 1.8.4;
constify
 1.7 30-Dec-2000  wiz Merge 2.18 to trunk.
 1.6 28-Oct-2000  wiz branches: 1.6.2;
Merge 2.17 changes to trunk.
 1.5 01-Jul-2000  wiz resolve conflicts.
 1.4 25-Jun-2000  wiz printf argument was in wrong position. Noted by Roger Hardiman
<roger@cs.strath.ac.uk>. (This code was ifdef'd out by default.)
 1.3 21-May-2000  wiz branches: 1.3.4;
Use bktr_softc.bktr_dev.dv_xname instead of "bktr0" when printf'ing as
requested by Klaus Klein in kern/10166.
Also add device instance name to all printf's that didn't have it.
 1.2 07-May-2000  wiz Some NetBSD specific changes; also TODO, and import script, based
on bind2netbsd by Bernd Ernesti
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.5 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.4 30-Dec-2000  wiz Import release 2.18 of the bktr driver. Changes since 2.17:
o Add new ioctls to allow userland programs fuller access to the I2C
bus, BT848_MSP_READ BT848_MSP_WRITE and BT848_MSP_RESET.
o Add tuner type 0x2a. Remove 0x2c which was incorrect.
o Christian Gusenbauer <Christian.Gusenbauer@netway.at> added support
for audio on Hauppauge cards without the audio mux. The MSP is used
for audio selection. (the 44xxx models)
 1.1.1.3 28-Oct-2000  wiz Import release 2.17 of the bktr driver.
Changes: Integration of some NetBSD changes. (FreeBSD version now is also
usable as a KLD (~= LKM).)
 1.1.1.2 01-Jul-2000  wiz Import release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.
 1.1.1.1 07-May-2000  wiz Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.3.4.1 03-Jul-2000  wiz Pull up revision 1.5 (requested by wiz):
Sync with release 2.14 of the bktr driver. Changes: mostly integration
of NetBSD changes; support for new Hauppauge tuner types.

Approved by thorpej.
 1.6.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.6.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.6.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.6.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.1 28-Oct-2000  bouyer file bktr_tuner.c was added on branch thorpej_scsipi on 2000-11-20 22:35:47 +0000
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.10.18.2 27-Oct-2007  yamt sync with head.
 1.10.18.1 21-Jun-2006  yamt sync with head.
 1.11.50.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.46.1 06-Nov-2007  matt sync with HEAD
 1.11.44.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.30.1 23-Oct-2007  ad Sync with head.
 1.2 12-Mar-2003  wiz Merge first bktr-sf import.
 1.1 07-May-2000  wiz branches: 1.1.1;
Initial revision
 1.1.1.2 12-Mar-2003  wiz Import of current state of bktr(4) in sourceforge repository.
Changes since last import:
. lots of whitespace cleanups
. typo fixes (e.g. hz, compatibilty)
. fix brightness ioctl return value
. wait for int ready using DELAY() instead of tight loop
 1.1.1.1 07-May-2000  wiz branches: 1.1.1.1.6;
Import of (finally busspaced) bktr-driver from FreeBSD (part 1).
This version is from the location specified in the README, modified
by bktr2netbsd, to be committed later.
 1.1.1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.1.1.6.1 07-May-2000  bouyer file bktr_tuner.h was added on branch thorpej_scsipi on 2000-11-20 22:35:47 +0000
 1.5 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.4 19-Apr-2018  christos branches: 1.4.2;
s/static inline/static __inline/g for consistency.
 1.3 27-Oct-2012  chs branches: 1.3.36;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.2 18-May-2011  dyoung branches: 1.2.4; 1.2.14;
MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_adapter.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_adapter.h was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_adapter.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.4.1 30-Oct-2012  yamt sync with head
 1.3.36.1 22-Apr-2018  pgoyette Sync with HEAD
 1.4.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_ael1002.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_ael1002.c was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_ael1002.c was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.4 29-Jul-2022  andvar s/collissions/collisions/
 1.3 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.2 23-Jan-2013  joerg branches: 1.2.36;
Make cxgb at least compilable. Fix _rt_key usage.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14; 1.1.24;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.24.1 25-Feb-2013  tls resync with head
 1.1.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_common.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_common.h was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_common.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2.36.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_config.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_config.h was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_config.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_ctl_defs.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_ctl_defs.h was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_ctl_defs.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2 02-Jun-2024  andvar Fix various typos, mainly triple letters.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_firmware_exports.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_firmware_exports.h was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_firmware_exports.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2 11-Apr-2019  kamil Fix CVS Id usage
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.66;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.66.1 10-Jun-2019  christos Sync with HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_include.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_include.h was added on branch rmind-uvmplock on 2010-05-30 05:17:39 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_include.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.24; 1.1.42;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.42.1 22-Sep-2015  skrll Sync with HEAD
 1.1.24.1 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_ioctl.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_ioctl.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_ioctl.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.3 19-Jun-2025  andvar s/partilar/particular/ in comment.
 1.2 19-Apr-2018  christos branches: 1.2.40;
s/static inline/static __inline/g for consistency.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.64;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.64.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_jhash.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_jhash.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_jhash.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2.40.1 02-Aug-2025  perseant Sync with HEAD
 1.5 22-Dec-2018  maxv Replace M_ALIGN and MH_ALIGN by m_align.
 1.4 11-Oct-2016  maxv branches: 1.4.14; 1.4.16;
There are two memory leaks here, found by mootja; just add some XXXs.
 1.3 25-Mar-2014  christos branches: 1.3.6; 1.3.10;
kill sprintf
 1.2 23-Jan-2013  joerg branches: 1.2.2;
Make cxgb at least compilable. Fix _rt_key usage.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14; 1.1.24;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.24.3 03-Dec-2017  jdolecek update from HEAD
 1.1.24.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.24.1 25-Feb-2013  tls resync with head
 1.1.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_l2t.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_l2t.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_l2t.c was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2.2.1 18-May-2014  rmind sync with head
 1.3.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.3.6.1 05-Dec-2016  skrll Sync with HEAD
 1.4.16.1 10-Jun-2019  christos Sync with HEAD
 1.4.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.2 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.64;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.64.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_l2t.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_l2t.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_l2t.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2 18-May-2011  dyoung MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_lro.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_lro.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_lro.c was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.10 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.9 24-Apr-2021  thorpej branches: 1.9.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.8 04-Feb-2020  thorpej branches: 1.8.8;
Use ifmedia_fini().
 1.7 09-Dec-2018  jdolecek branches: 1.7.6;
use pci_intr_establish_xname()

XXX due to 2008-01-17 '10 gigabit Chelsio cards now compile and work, although
XXX not very well yet' commit this looks like having worked in past, but since
XXX ~2010 received only mechanical updates, and currently it's unreferenced
XXX and uncompilable - does it make sense to keep the driver around?
 1.6 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.5 26-Jun-2018  msaitoh branches: 1.5.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.4 23-Jan-2013  joerg branches: 1.4.36;
Make cxgb at least compilable. Fix _rt_key usage.
 1.3 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.2 18-May-2011  dyoung branches: 1.2.4; 1.2.14;
MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_main.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:05 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_main.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_main.c was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2.14.2 25-Feb-2013  tls resync with head
 1.2.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.1 30-Oct-2012  yamt sync with head
 1.4.36.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.4.36.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4.36.1 28-Jul-2018  pgoyette Sync with HEAD
 1.5.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.7.6.1 29-Feb-2020  ad Sync with head.
 1.8.8.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.8.8.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.9.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_mbuf.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_mbuf.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_mbuf.h was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.2 08-Feb-2018  dholland Typos.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_mc5.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_mc5.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_mc5.c was added on branch uebayasi-xip on 2010-04-30 14:43:44 +0000
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_mv88e1xxx.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_mv88e1xxx.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_mv88e1xxx.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.3 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.2 02-Oct-2016  christos branches: 1.2.14;
MFREE -> m_free
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.24; 1.1.42; 1.1.46;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.46.1 04-Nov-2016  pgoyette Sync with HEAD
 1.1.42.1 05-Oct-2016  skrll Sync with HEAD
 1.1.24.1 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_mvec.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_mvec.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_mvec.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2.14.1 22-Apr-2018  pgoyette Sync with HEAD
 1.7 08-Aug-2021  andvar s/propely/properly/
 1.6 27-Dec-2019  msaitoh s/suport/support/
 1.5 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.4 21-Sep-2014  christos branches: 1.4.18; 1.4.20;
comment out code that was never used, but probably intended to be used.
 1.3 25-Mar-2014  christos branches: 1.3.4;
kill sprintf
 1.2 18-May-2011  dyoung branches: 1.2.4; 1.2.14; 1.2.18;
MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_offload.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_offload.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_offload.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2.18.1 18-May-2014  rmind sync with head
 1.2.14.2 03-Dec-2017  jdolecek update from HEAD
 1.2.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.4.1 30-Oct-2014  martin Pull up following revision(s) (requested by maxv in ticket #164):
sys/dev/ieee1394/fwcrom.c: revision 1.15
sys/dev/ieee1394/fwcrom.c: revision 1.16
sys/dev/marvell/if_gfe.c: revision 1.43
sys/dev/usb/stuirda.c: revision 1.16
sys/dev/pci/cxgb/cxgb_offload.c: revision 1.4
sys/dev/pci/twa.c: revision 1.51
sys/dev/pci/twa.c: revision 1.52
Various fixes in dev/: remove dead code and fix two inconsistencies.
 1.4.20.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.20.1 10-Jun-2019  christos Sync with HEAD
 1.4.18.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.64;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.64.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_offload.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_offload.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_offload.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2 18-May-2011  dyoung MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_osdep.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_osdep.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_osdep.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.7 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.6 19-Apr-2018  christos branches: 1.6.2;
s/static inline/static __inline/g for consistency.
 1.5 25-May-2016  ozaki-r branches: 1.5.16;
Use M_GETCTX and M_SETCTX

No functional change.
 1.4 20-Mar-2014  skrll branches: 1.4.6;
Mechanically replace simplelock with kmutex_t.
 1.3 23-Jan-2013  joerg branches: 1.3.2;
Make cxgb at least compilable. Fix _rt_key usage.
 1.2 18-May-2011  dyoung branches: 1.2.4; 1.2.14;
MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_osdep.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_osdep.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_osdep.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2.14.3 03-Dec-2017  jdolecek update from HEAD
 1.2.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.14.1 25-Feb-2013  tls resync with head
 1.2.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.2.1 18-May-2014  rmind sync with head
 1.4.6.1 29-May-2016  skrll Sync with HEAD
 1.5.16.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.5.16.1 22-Apr-2018  pgoyette Sync with HEAD
 1.6.2.1 10-Jun-2019  christos Sync with HEAD
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_regs.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_regs.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_regs.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.8 28-May-2025  andvar fix few typos in comments.
 1.7 22-Dec-2018  maxv branches: 1.7.36;
Replace M_ALIGN and MH_ALIGN by m_align.
 1.6 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.5 26-Sep-2017  knakahara branches: 1.5.2; 1.5.4;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.4 10-Jun-2016  ozaki-r branches: 1.4.10;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.3 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.2 18-May-2011  dyoung branches: 1.2.14; 1.2.32;
MI code must #include <sys/bus.h>, not <machine/bus.h>.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_sge.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.3 31-May-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_sge.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_sge.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2.32.2 09-Jul-2016  skrll Sync with HEAD
 1.2.32.1 19-Mar-2016  skrll Sync with HEAD
 1.2.14.1 03-Dec-2017  jdolecek update from HEAD
 1.4.10.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.5.4.1 10-Jun-2019  christos Sync with HEAD
 1.5.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.7.36.1 02-Aug-2025  perseant Sync with HEAD
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_sge_defs.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_sge_defs.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_sge_defs.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_t3_cpl.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_t3_cpl.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_t3_cpl.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.9 29-Aug-2024  andvar s/Perfoms/Performs/ in comment.
 1.8 23-May-2024  andvar branches: 1.8.2;
s/separare/separate/ and s/separete/separate/ in comments.
 1.7 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.6 10-Nov-2021  msaitoh s/endianess/endianness/
 1.5 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.4 29-Sep-2020  msaitoh s/occurence/occurrence/
 1.3 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.2 08-Feb-2018  dholland branches: 1.2.2; 1.2.4;
Typos.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_t3_hw.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_t3_hw.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_t3_hw.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2.4.1 10-Jun-2019  christos Sync with HEAD
 1.2.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_tcb.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_tcb.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_tcb.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.2 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.64;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.64.1 22-Apr-2018  pgoyette Sync with HEAD
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_toedev.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_toedev.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_toedev.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_version.h was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_version.h was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_version.h was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_vsc7323.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_vsc7323.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_vsc7323.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_vsc8211.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:06 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_vsc8211.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_vsc8211.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.3 26-Mar-2023  andvar fix various typos in documentation, comments and sysctl device description.
mainly aion -> ation and inlude -> include.
 1.2 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.1 21-Mar-2010  jklos branches: 1.1.2; 1.1.4; 1.1.6; 1.1.64; 1.1.66;
Reorganizing all Chelsio 10 gig files into separate directory.
 1.1.66.1 10-Jun-2019  christos Sync with HEAD
 1.1.64.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 21-Mar-2010  yamt file cxgb_xgmac.c was added on branch yamt-nfs-mp on 2010-08-11 22:54:07 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 21-Mar-2010  rmind file cxgb_xgmac.c was added on branch rmind-uvmplock on 2010-05-30 05:17:40 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 21-Mar-2010  uebayasi file cxgb_xgmac.c was added on branch uebayasi-xip on 2010-04-30 14:43:45 +0000
 1.23 21-Oct-2025  pgoyette cut&paste error - forgot to fix the function name
 1.22 21-Oct-2025  pgoyette It helps to include the sys/module.h header file,
 1.21 21-Oct-2025  pgoyette Add MODULE glue and build infrasructure.

XXX We won't actually build or install it due to kern/59716 but
XXX it can be manually built and installed if you want.
 1.20 01-Jun-2025  rin igc(4): Merge and clean up igc_{tx_ctx,tso}_setup(), NFC
 1.19 01-Jun-2025  rin igc(4): TSOv[46]: Fix and register into capabilities

by syncing TX mbuf **after** L3/L4 headers are fixed up.

Will be pulled up into netbsd-10.
 1.18 07-May-2025  rin igc(4): igc_detach_counters: Correct sizes for kmem_free(9)

Now, igc(4) can be successfully detached by `drvctl -d`.
 1.17 24-Nov-2024  mlelstv MBUFTRACE
 1.16 05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.15 29-Jun-2024  riastradh branches: 1.15.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.14 12-Jun-2024  rin igc: Add missing '\n' to a DPRINTF message
 1.13 21-Feb-2024  msaitoh igc(4): Print EtrackID.
 1.12 21-Feb-2024  msaitoh igc(4): Modify dmesg output of PHY and NVM info.

- Print PHY info first and then print NVM info.
- Remove debug output.
 1.11 08-Feb-2024  msaitoh igc: Add missing igc_check_for_link() call.

It's required to set the collision distance, configure flow control
from the negotiated result and set the LTR thresholds.
With this change, ifconfig igcN show the flow control status correctly.
 1.10 25-Jan-2024  msaitoh igc(4): Count iqdrops.

TODO: RQDPC should be visible via evcnt(9).
 1.9 20-Dec-2023  skrll Remove unnecssary #include
 1.8 02-Nov-2023  rin igc(4): Notify which of 64- or 32-bit DMA is used
 1.7 15-Oct-2023  oster Fix build of the MODULAR kernel, which explicitly excludes vlans.
 1.6 12-Oct-2023  rin igc(4): igc_init: Enable interrupt after everything is set up

Inspired by "ixgbe: Enable interrupt after setting IFF_RUNNING.":
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/pci/ixgbe/ixgbe.c#rev1.337

Just for sure, callout_schedule(9) for igc_tick() is also postponed.
This is NFC for now, although.

XXX
Check other drivers.
 1.5 11-Oct-2023  riastradh igc(4): `nvm_ver & ...' has type int, so use %x, not %hx.

This happens even though nvm_ver is unsigned short (uint16_t),
because of the integer promotions.

Should fix clang build.

XXX pullup-10
 1.4 10-Oct-2023  msaitoh igc(4): Fix half duplex setting

From FreeBSD: 3b8d04f845b416d29a258658b8a48d1afb4a2e81
 1.3 04-Oct-2023  rin branches: 1.3.2;
igc(4): XXX: Temporally disable 64-bit DMA for aarch64

Until PR port-arm/57643 is properly addressed.
 1.2 04-Oct-2023  rin igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.3.2.7 01-Jun-2025  martin Pull up following revision(s) (requested by rin in ticket #1125):

sys/dev/pci/igc/if_igc.c: revision 1.19
sys/dev/pci/igc/if_igc.c: revision 1.20
share/man/man4/igc.4: revision 1.3

igc(4): TSOv[46]: Fix and register into capabilities
by syncing TX mbuf **after** L3/L4 headers are fixed up.

igc(4): Merge and clean up igc_{tx_ctx,tso}_setup(), NFC

igc.4: TSO is supported now. Bump date.
 1.3.2.6 09-May-2025  martin Pull up following revision(s) (requested by rin in ticket #1110):

sys/dev/pci/igc/if_igc.c: revision 1.18

igc(4): igc_detach_counters: Correct sizes for kmem_free(9)

Now, igc(4) can be successfully detached by `drvctl -d`.
 1.3.2.5 21-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #713):

sys/dev/pci/igc/if_igc.c: revision 1.14
sys/dev/pci/igc/if_igc.c: revision 1.7
sys/dev/pci/igc/if_igc.c: revision 1.8
sys/dev/pci/igc/if_igc.c: revision 1.9

Fix build of the MODULAR kernel, which explicitly excludes vlans.

igc(4): Notify which of 64- or 32-bit DMA is used

Remove unnecssary #include

igc: Add missing '\n' to a DPRINTF message
 1.3.2.4 23-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #605):

sys/dev/pci/igc/if_igc.c: revision 1.12
sys/dev/pci/igc/if_igc.c: revision 1.13
sys/dev/pci/igc/igc_defines.h: revision 1.3
sys/dev/pci/igc/if_igc.c: revision 1.10
sys/dev/pci/igc/if_igc.c: revision 1.11

igc(4): Count iqdrops.

TODO: RQDPC should be visible via evcnt(9).

igc: Add missing igc_check_for_link() call.

It's required to set the collision distance, configure flow control
from the negotiated result and set the LTR thresholds.

With this change, ifconfig igcN show the flow control status correctly.

igc(4): Modify dmesg output of PHY and NVM info.
- Print PHY info first and then print NVM info.
- Remove debug output.

igc(4): Print EtrackID.
 1.3.2.3 14-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #410):

sys/dev/pci/igc/if_igc.c: revision 1.4
sys/dev/pci/igc/if_igc.c: revision 1.5
sys/dev/pci/igc/if_igc.c: revision 1.6

igc(4): Fix half duplex setting
From FreeBSD: 3b8d04f845b416d29a258658b8a48d1afb4a2e81

igc(4): `nvm_ver & ...' has type int, so use %x, not %hx.
This happens even though nvm_ver is unsigned short (uint16_t),
because of the integer promotions.
Should fix clang build.

igc(4): igc_init: Enable interrupt after everything is set up
Inspired by "ixgbe: Enable interrupt after setting IFF_RUNNING.":
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/pci/ixgbe/ixgbe.c#rev1.337

Just for sure, callout_schedule(9) for igc_tick() is also postponed.
This is NFC for now, although.
 1.3.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.3.2.1 04-Oct-2023  martin file if_igc.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.15.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 27-Jun-2024  rin igc: Use __HAVE_ATOMIC64_LOADSTORE instead of __HAVE_ATOMIC64_OPS

to detect atomic_loadstore(9) is applicable to 64-bit integers.

Thanks riastradh@ for explanation in PR kern/58340
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.3 27-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #729):

sys/dev/pci/igc/if_igc.h: revision 1.3

igc: Use __HAVE_ATOMIC64_LOADSTORE instead of __HAVE_ATOMIC64_OPS
to detect atomic_loadstore(9) is applicable to 64-bit integers.

Thanks riastradh@ for explanation in PR kern/58340
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file if_igc.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_api.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_api.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_base.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_base.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.4 22-Aug-2024  andvar s/Shfit/Shift/ in comment.
 1.3 21-Feb-2024  msaitoh branches: 1.3.2;
igc(4): Print EtrackID.
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.4 12-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #853):

sys/dev/pci/igc/igc_defines.h: revision 1.4
share/man/man4/igc.4: revision 1.2

Fix typo in email.
s/Shfit/Shift/ in comment.
 1.2.2.3 23-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #605):

sys/dev/pci/igc/if_igc.c: revision 1.12
sys/dev/pci/igc/if_igc.c: revision 1.13
sys/dev/pci/igc/igc_defines.h: revision 1.3
sys/dev/pci/igc/if_igc.c: revision 1.10
sys/dev/pci/igc/if_igc.c: revision 1.11

igc(4): Count iqdrops.

TODO: RQDPC should be visible via evcnt(9).

igc: Add missing igc_check_for_link() call.

It's required to set the collision distance, configure flow control
from the negotiated result and set the LTR thresholds.

With this change, ifconfig igcN show the flow control status correctly.

igc(4): Modify dmesg output of PHY and NVM info.
- Print PHY info first and then print NVM info.
- Remove debug output.

igc(4): Print EtrackID.
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_defines.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 04-Oct-2023  rin branches: 1.1.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.1.2.1 04-Oct-2023  martin file igc_evcnt.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_hw.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.3 25-Feb-2025  andvar Fix a few typos in the word 'offset' in comments and error message.
 1.2 04-Oct-2023  rin branches: 1.2.2; 1.2.8;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_i225.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_i225.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_mac.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_mac.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_nvm.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_nvm.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_phy.c was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_phy.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 04-Oct-2023  rin branches: 1.2.2;
igc(4): Add support to Intel I225 / I226 series ethernet devices

Originally written by kevlo@o for OpenBSD, and ported by knakahara@,
msaitoh@, and myself.

The driver is *EXPERIMENTAL* at the moment, as some minor error
handling paths are not fully implemented.

Hardware VLAN tagging and TSO are not supported yet.

Although, we have never observed strange behaviors at least on amd64,
aarch64{,eb}, and evbppc (IBM405), except for PR port-arm/57643.

We will send pullup request to netbsd-10, after successful snapshot
build for -current.
 1.1 04-Oct-2023  rin branches: 1.1.1;
Initial revision
 1.1.1.1 04-Oct-2023  rin Import igc(4) from OpenBSD-current as of 2023-10-04
 1.2.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #393):

sys/dev/pci/igc/if_igc.c up to 1.3
sys/dev/pci/igc/if_igc.h up to 1.2
sys/dev/pci/igc/igc_api.c up to 1.2
sys/dev/pci/igc/igc_api.h up to 1.2
sys/dev/pci/igc/igc_base.c up to 1.2
sys/dev/pci/igc/igc_base.h up to 1.2
sys/dev/pci/igc/igc_defines.h up to 1.2
sys/dev/pci/igc/igc_evcnt.h up to 1.1
sys/dev/pci/igc/igc_hw.h up to 1.2
sys/dev/pci/igc/igc_i225.c up to 1.2
sys/dev/pci/igc/igc_i225.h up to 1.2
sys/dev/pci/igc/igc_mac.c up to 1.2
sys/dev/pci/igc/igc_mac.h up to 1.2
sys/dev/pci/igc/igc_nvm.c up to 1.2
sys/dev/pci/igc/igc_nvm.h up to 1.2
sys/dev/pci/igc/igc_phy.c up to 1.2
sys/dev/pci/igc/igc_phy.h up to 1.2
sys/dev/pci/igc/igc_regs.h up to 1.2
distrib/sets/lists/man/mi: revision 1.1766
sys/arch/amd64/conf/GENERIC: revision 1.606
sys/arch/evbppc/conf/DHT: revision 1.5
sys/arch/evbarm/conf/GENERIC64: revision 1.213
share/man/man4/Makefile: revision 1.733
sys/arch/amd64/conf/ALL: revision 1.181
share/man/man4/igc.4: revision 1.1
sys/dev/pci/files.pci: revision 1.447
sys/arch/amd64/conf/XEN3_DOM0: revision 1.200
doc/CHANGES (apply patch)

Add igc(4) for Intel I225/I226 series ethernet devices
 1.2.2.1 04-Oct-2023  martin file igc_regs.h was added on branch netbsd-10 on 2023-10-08 13:19:34 +0000
 1.2 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.1 21-Jan-2014  mlelstv branches: 1.1.4; 1.1.6; 1.1.10; 1.1.36; 1.1.40;
one more file needed
 1.1.40.1 05-May-2019  isaki Remove obsoleted au{,rate,vol}conv and mulaw attributes.
audio provides the equivalent of them inseparably.
 1.1.36.1 10-Jun-2019  christos Sync with HEAD
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 21-Jan-2014  tls file files.igma was added on branch tls-maxphys on 2014-08-20 00:03:48 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 21-Jan-2014  yamt file files.igma was added on branch yamt-pagecache on 2014-05-22 11:40:34 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 21-Jan-2014  rmind file files.igma was added on branch rmind-smpnet on 2014-05-18 17:45:45 +0000
 1.5 04-Oct-2025  thorpej Use device_{get,set}prop_bool() for "is_console".
 1.4 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.3 24-Apr-2021  thorpej branches: 1.3.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.2 24-Feb-2020  rin branches: 1.2.8;
0x%p --> %p for non-external codes.
 1.1 21-Jan-2014  mlelstv branches: 1.1.4; 1.1.6; 1.1.10; 1.1.36; 1.1.44;
wscons driver for Intel Graphics Media Accelerator.
Initial commit that already works for a couple of Notebooks
based on G35, G45, Sandy Bridge and Ivy Bridge chips.

Despite the word 'Accelerator' there is nothing acclerated yet.
 1.1.44.1 29-Feb-2020  ad Sync with head.
 1.1.36.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 21-Jan-2014  tls file igmafb.c was added on branch tls-maxphys on 2014-08-20 00:03:48 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 21-Jan-2014  yamt file igmafb.c was added on branch yamt-pagecache on 2014-05-22 11:40:34 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 21-Jan-2014  rmind file igmafb.c was added on branch rmind-smpnet on 2014-05-18 17:45:45 +0000
 1.2.8.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.3.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.3 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.2 24-Apr-2015  msaitoh branches: 1.2.2;
Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.2 05-Dec-2016  skrll Sync with HEAD
 1.1.30.1 06-Jun-2015  skrll Sync with HEAD
 1.1.28.1 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.3 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.2 05-Aug-2015  msaitoh branches: 1.2.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.2 05-Dec-2016  skrll Sync with HEAD
 1.1.30.1 22-Sep-2015  skrll Sync with HEAD
 1.1.28.1 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.9 17-Aug-2021  andvar branches: 1.9.4;
fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.8 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.7 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.6 12-Aug-2020  msaitoh branches: 1.6.6;
Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.
 1.5 16-Dec-2019  msaitoh No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.4 04-Apr-2018  msaitoh branches: 1.4.2; 1.4.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.3 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.2 22-Nov-2017  msaitoh branches: 1.2.2; 1.2.4; 1.2.6;
Fix a bug that bypass adapter's sysctls aren't set. Tested with non-genuine
X550-T2 bypass adapter:
- Call ixgbe_sysctl_instance() in ixgbe_bypass_init() to get sysctl's top node
correctly.
- ixgbe_init_device_features() refers adapter->hw.bus.func for bypass adapter.
Call set_lan_id() to set adapter->hw.bus.func before calling
ixgbe_init_device_features(). Without this, bypass sysctl's are added to
both the first and second port.
- Initalize node.sysctl_data before calling sysctl_lookup() to read correct
value.
 1.1 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.2.6.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.2.6.1 15-Mar-2018  pgoyette Synch with HEAD
 1.2.4.8 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.2.4.7 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.2.4.6 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1600):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

-

Minor change.
- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.2.4.5 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.2.4.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.2.4.3 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.2.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.2.4.1 22-Nov-2017  snj file if_bypass.c was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 22-Nov-2017  jdolecek file if_bypass.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.4.8.4 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.4.8.3 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.4.8.2 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1070):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

-

Minor change.
- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.4.8.1 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.4.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.6.1 13-May-2021  thorpej Sync with HEAD.
 1.9.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.6 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.5 30-Apr-2021  msaitoh branches: 1.5.14;
Add missing __KERNEL_RCSID().
 1.4 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.3 07-Sep-2020  msaitoh branches: 1.3.6;
- Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@.
- Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers().
- Add KASSERT() to functions who are called from ixgbe_handle_admin().
 1.2 04-Apr-2018  msaitoh branches: 1.2.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.6.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.4.5 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file if_fdir.c was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file if_fdir.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.2.8.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.2.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.3.6.1 13-May-2021  thorpej Sync with HEAD.
 1.5.14.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.18 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.17 24-Dec-2021  msaitoh branches: 1.17.4;
Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.16 24-Dec-2021  msaitoh Change the first argument of ixgbe_send_vf_msg(). No functional change.

- This is a part of FreeBSD ix-3.2.17.
 1.15 24-Dec-2021  msaitoh Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}.

- Sync with FreeBSD ix-3.3.18.
- No functional change.
 1.14 10-Dec-2021  msaitoh Move PF mailbox initialization from ixgbe_attach() to ixgbe_init_iov().

From FreeBSD ix-3.3.18. No functional change.
 1.13 10-Dec-2021  msaitoh Change argument. No functional change. This file is not used in NetBSD.
 1.12 10-Dec-2021  msaitoh Remove unused argument. Note that this file is not used in NetBSD.
 1.11 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.10 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.9 25-Jan-2021  mrg branches: 1.9.4;
s/boolean_t/bool/. boolean_t is obsolete (from Mach), and this
also fixes a new build issue in libkvm on sparc*.
 1.8 07-Sep-2020  msaitoh branches: 1.8.2;
- Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@.
- Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers().
- Add KASSERT() to functions who are called from ixgbe_handle_admin().
 1.7 25-Jun-2020  msaitoh Reduce ixgbe's busy loop using with workqueue and kpause.

- Use workqueue instead of softint to make some functions sleepable.
- Use new workqueue and enqueue it in ixgbe_local_timer() and
ixgbe_recovery_mode_timer() to make them sleepable.
- Make new ixgbe_delay() and use it. This functions sleeps if the time is
more than equals 1 tick. If it's not, do delay().
 1.6 27-Jun-2019  msaitoh branches: 1.6.2;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.5 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.4 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.3 04-Apr-2018  msaitoh branches: 1.3.2;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.2 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.6.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.6.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.6.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.6.1 15-Mar-2018  pgoyette Synch with HEAD
 1.1.4.9 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.8 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.1.4.7 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.4.6 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.5 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.1.4.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.1.4.3 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file if_sriov.c was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file if_sriov.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.3.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.2.1 10-Jun-2019  christos Sync with HEAD
 1.6.2.4 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.6.2.3 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.6.2.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.6.2.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.8.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9.4.1 13-May-2021  thorpej Sync with HEAD.
 1.17.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.117 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.116 30-Dec-2023  msaitoh ixgbe: Use #ifdef RSC

This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.115 29-Dec-2023  msaitoh ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
 1.114 28-Dec-2023  msaitoh ixgbe: Use kmem_zalloc() instead of malloc(,M_ZERO).
 1.113 28-Dec-2023  msaitoh ixgbe: Simplify. No functional change.

The descriptor ring size and the alignment are tested in the attach
function, so it's not required to use roundup2(size, DBA_ALIGN).
 1.112 28-Dec-2023  msaitoh ixgbe: Use #ifdef IXGBE_FDIR more

Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
 1.111 13-Dec-2023  msaitoh ixgbe: micro-optimize ixgbe_txeof()

Update txr->packets outside the loop in ixgbe_txeof().
 1.110 08-Dec-2023  msaitoh ixgbe: Update if_opackets outside the loop in ixgbe_txeof().
 1.109 08-Dec-2023  msaitoh ixgbe: micro-optimize ixgbe_txeof()

Update txr->tx_avail and txr->txr_no_space outside the loop in ixgbe_txeof().
 1.108 16-Nov-2023  msaitoh ixgbe: Modify for the readability. No functional change.
 1.107 14-Nov-2023  msaitoh ixgbe(4): Modify comment. No functional change.

ixgbe_tx_ctx_setup() may or may not consume one TX descriptor.
 1.106 14-Nov-2023  msaitoh ixgbe(4): Move assignment of TXD. NFCI.
 1.105 02-Nov-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.104 12-Oct-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.103 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.102 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.101 03-Oct-2023  msaitoh Remove obsolete comment.
 1.100 16-Sep-2022  knakahara branches: 1.100.4;
ixg(4) add an option for Tx to use deferred softint regardless of whether can get txq lock or not.

That imporve (7%) and stabilize throughput. But that can cause
latency degradation, so off by default.

ok'ed by msaitoh@n.o.
 1.99 07-Aug-2022  andvar fix typos in comments.
 1.98 11-May-2022  bouyer bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.
 1.97 25-Apr-2022  msaitoh Use cached rx_copy_len in ixgbe_rxeof().
 1.96 25-Apr-2022  msaitoh Modify comment for consistency. No functional change.
 1.95 25-Jan-2022  msaitoh Use atomic_{load,store}_relaxed() for event counters.
 1.94 08-Sep-2021  msaitoh Reduce bus_dmamap_sync() cost.

- Don't sync whole descriptor ring but limited counts(rx_process_limit)
descriptors.
- Dont' sync every loop.
 1.93 08-Sep-2021  msaitoh Don't pre-allocate a cluster not to do m_freem() it on RXCOPY case.
 1.92 07-Sep-2021  msaitoh Don't increment no_mbuf evcnt(9) when discarding multi-descriptor packet.
 1.91 07-Sep-2021  msaitoh Sprinkle __predict_false() in the RX path.
 1.90 03-Sep-2021  msaitoh Save the discard_multidesc state to not to forget the state by exiting rxeof().
 1.89 03-Sep-2021  msaitoh Rename variable. No functional change.
 1.88 26-Aug-2021  msaitoh Remove "j" or "jumbo" because we always use MCLBYTES sized buffer.
 1.87 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.86 19-Aug-2021  msaitoh Use m_adj(ETHER_ALIGN) more. Tested by me (amd64,aarch64) and rin (alpha).

- Align with ETHER_ALIGN everywhere where mbuf is allocated.
- Remove extra setting of M_PKTHDR. No functional change.
- Add comment.
 1.85 19-Aug-2021  msaitoh KNF. No functional change.
 1.84 19-Aug-2021  msaitoh Don't use fixed value. No functional change.
 1.83 19-Aug-2021  msaitoh Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent panic.

If an mbuf is ETHER_ALIGNed, the packet size may be shorter than MCLBYTES.
For example, if the max frame size is 2048 by changing the interface's MTU,
an mbuf's max length is 2046. So, don't use rx_mbuf_sz for bus_dmamap_sync.
 1.82 18-Aug-2021  msaitoh Refresh unrefreshed descriptors' buffers correctly.

- Update next_to_refresh at least before ixgbe_rx_unrefresed() to detect
the unrefreshed status correctly in ixgbe_rxeof().
- next_to_refresh points to the previous entry of the first unrefreshed
descriptor, so fix a loop variable to point to the correct one in
ixgbe_refresh_mbufs().
- Without the above two fixes, RX ring may have some unrefreshed entries
which have inconsistent state. On such state, "ifconfig down up" causes
panic in bus_dmamap_sync() on aarch64.
- Tested on amd64 and aarch64. OK'd by knakahara.
 1.81 07-Jul-2021  msaitoh Add new sysctl "rx_copy_len".

ixgbe_rxeof() has an optimization "RX_COPY" to reduce costs of
bus_dmamap_load_mbuf() and bus_dmamap_unload() by copying a mbuf cluster's
memory to a newly allocated mbuf's MH_databuf[] and recycle the original map.
The optimization is used when a length of a packet is smaller than a specific
value. The value is calculated based on MHLEN. The size of MHLEN is
architecture specific. It's 256 or 512. Make the threshold controllable by
adding a new sysctl.
 1.80 07-Jul-2021  msaitoh Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().

ixgbe_setup_receive_ring() fully allocates rx buffers. When a
descriptor ring is full, rxr->next_to_refresh should point to
rxr_next_to_check -1. Before this change, rxr->next_to_refresh
is set to 0 and ixgbe_refresh_mbufs() wastefully loops in
ixgbe_refresh_mbufs() because it means the ring is empty.
 1.79 27-May-2021  msaitoh Do no_jmbuf++ when ixgbe_getjcl() failed in ixgbe_setup_receive_ring(), too.
 1.78 20-May-2021  ryo fix little-endian dependence
 1.77 20-May-2021  msaitoh Use uint64_t instead of bus_addr_t for the TX descriptor's buffer address.
At least, this change is required for macppc (sizeof(bus_addr_t) == 4) to
make TX work.
 1.76 20-May-2021  ryo Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability on aarch64.

In ixgbe, TX/RX descriptor rings are configured in 16-byte units.
If BUS_DMA_COHERENT is not specified, cpu cache (writeback/invalidate)
operations by bus_dmamap_sync() in aarch64 (arm/arm32/bus_dma.c) are done per
cache line size (usually 64 bytes). As a result, adjacent descriptors conflict
with the DMA operation, resulting in unstable operation.

To avoid this, descriptors area should be mapped as non-cache with BUS_DMA_COHERENT.


thanks to msaitoh@ for his help in debugging.
 1.75 18-May-2021  msaitoh - Cleanup an rxbuf entry when bus_dmamap_load_mbuf() failed to prevent panic.
- Print error number when error occurred.
 1.74 14-May-2021  msaitoh Keep m_len and m_pkthdr.len consistent to prevent panic on arm.

Arm's bus_dmamap_load_mbuf() keeps a pointer to the original mbuf
and bus_dmamap_sync() refers it. ixgbe_rxeof() modified mbuf's m_len
inconsistently with m_pkthdr and dm_mapsize. "ifconfig down up" made
panic by referring the inconsistent mbuf length.
 1.73 14-May-2021  knakahara Comment out flow director processing in fast path.

ixgbe_xmit() is per-queue fast path. It should reduce access to
per-device data (adapter->feat_en).
 1.72 11-May-2021  rin Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change).

Otherwise, MMU fault occurs for some bus_dma(9) implementations.

With this fix, X550-T1 and X540-T1 work fine on alpha (at least
DS10 with PCI-PCIe reverse bridge).

Discussed with msaitoh. Thanks!
 1.71 30-Apr-2021  msaitoh branches: 1.71.2;
Add missing __KERNEL_RCSID().
 1.70 31-Mar-2021  msaitoh branches: 1.70.2;
KNF a bit. No functional change.
 1.69 12-Mar-2021  knakahara branches: 1.69.2;
Refactor rxr->next_to_check updating.
 1.68 12-Mar-2021  knakahara Remove extra unlock/lock processing around if_percpuq_enqueue().

same as if_wm.c:r1.700
 1.67 09-Mar-2021  msaitoh Modify some parameters to reduce packet dropping.

- Background: ixgbe doesn't use common MCLGET() interface and use the
driver specific cluster allocation mechanism (jcl). The cluster is
pre-allocated with a fixed number and the current number per queue
is num_rx_desc * 2 (2048*2=4096). It's too small. It also has a problem
that the max length of the pcq which is used in the TX path is big
(4096). Example:

100M <----- [ixg0 ixg1] <----- 1G
2048 TX descs <--- 4096 pcqs <---- 2048 RX descs

If a machine forwards a traffic from 1G interface to 100M interface,
It would require 2048+4096+2048=8192 descriptors, but the current number
is 2048*2=4096. It's too small. Even if the both interface's link speed
is the same and only small number of packet is queued in the pcq, 4096
jcl is small because 2048(RX)+TX(2048)=4096. If jcl is exhausted, not only
forwarding from ixg1 to ixg0 is dropped, but also another forwarding path
from ixg1 to another interface(e.g. wm0) is also dropped. Sockets also
queue packets, so if a lot of sockets are used and/or a socket buffer
size is changed to bigger one, it'll also become a problem. If the jcl
is exhausted, evcnt(9) counter "ixgX qY Rx no jumbo mbuf" is incremented.
Example:
vmstat -ev | grep ixg1 | grep "no jumbo"
ixg1 q0 Rx no jumbo mbuf 0 0 misc
ixg1 q1 Rx no jumbo mbuf 0 0 misc
ixg1 q2 Rx no jumbo mbuf 141326 0 misc
ixg1 q3 Rx no jumbo mbuf 0 0 misc


- To solve this problem:
- Add new config parameter IXGBE_JCLNUM_MULTI and set the default to 3
(2048 * 3). The minimum number is 2. The total number of jcl per queue
is available with hw.ixgN.num_jcl_per_queue sysctl.
- Reduce the max length of the pcq() which is used in the TX path from
4096 to 2048.

- Reviewed by knakahara@ and ozaki-r@.

- TODO: Use MCLGET().
 1.66 08-Mar-2021  msaitoh Use no_jmbuf evcnt for the failure case of ixgbe_getjcl().
 1.65 02-Mar-2021  msaitoh Fix jcl's starvation case in ixgbe_rxeof() again.

ix_txrx.c rev.1.64 preallocates jcl to prevent starvation but it's not
perfect. Don't use ixgbe_rx_discard() and just update the old descriptor
for reuse. It's also required for multiple descriptors case to refresh
subsequent descriptor(s). Reviewed by knakahara@.
 1.64 18-Jan-2021  knakahara Fix ixg(4) Rx interrupt stall when Rx buffers are exhausted.

Current ixgbe_rxeof() implementation calls ixgbe_refresh_mbufs()(and
ixgbe_getjcl()) after ixgbe_rx_input()(and if_percpuq_enqueue()).
And ixg(4) uses its own m_ext structure. That causes Rx interrupt
stall when Rx buffers are exhausted. e.g. TCP iperf3 with large
windows size. Furthermore, Rx descriptor problem has occurred
after stoppping the load.

To fix that problem, ixgbe_rxeof() must call ixgbe_getjcl() before
ixgbe_rx_input(), and must discard the new packet when ixgbe_getjcl()
fails.

By the way, ixg(4) should use MCLGET() instead of own m_ext structure.

ok'ed by msaitoh@n.o, thanks.
 1.63 17-Apr-2020  msaitoh branches: 1.63.2;
No functional change:
- modify comment
- whitespace fix
 1.62 05-Feb-2020  msaitoh branches: 1.62.4;
No functional change:

- Add debug printf()s.
- Remove unused macros.
- Remove extra newline.
 1.61 30-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.60 21-Jan-2020  msaitoh Fix the freeing code for some error paths. Found and tested by Patrick Welche.
 1.59 20-Jan-2020  msaitoh Free jumbo mem structure correctly. Found by yamaguchi@ using with LOCKDEBUG.
 1.58 16-Dec-2019  msaitoh branches: 1.58.2;
No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.57 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.56 16-Oct-2019  knakahara Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.55 04-Sep-2019  msaitoh printf -> device_printf
 1.54 04-Jul-2019  msaitoh branches: 1.54.2;
Fix hung queue check when the queue number >= 31.
 1.53 27-Jun-2019  msaitoh Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.52 22-Feb-2019  msaitoh Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.51 20-Dec-2018  knakahara Apply the same fix as if_wm.c:r1.606 to ixg(4). Pointed out by msaitoh@n.o, thanks.

XXX pullup-8
 1.50 06-Sep-2018  msaitoh Fix a bug that ixgbe_mq_start(an if_transmit function) returned wrong
vaue on error. pcq_put returns false on error, so returning it to caller
indicated no error.

XXX pullup-8
 1.49 31-Jul-2018  msaitoh Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.48 26-Jun-2018  msaitoh branches: 1.48.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.47 23-May-2018  msaitoh Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
 1.46 23-May-2018  msaitoh Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.

Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
 1.45 18-May-2018  msaitoh Revert new watchdog timer commits. The new watchdog timer made stability
worse than before. It seems unknown problems exists.

http://mail-index.netbsd.org/source-changes/2018/05/08/msg095020.html
http://mail-index.netbsd.org/source-changes/2018/05/16/msg095240.html
 1.44 16-May-2018  msaitoh Whitespace fix. No functional change.
 1.43 16-May-2018  msaitoh Fix a problem that the watchdog timer sometimes mistakenly fires. Restore
TX sending check in the end of ixgbe_txeof which was wrongly removed in
ix_txrx.c rev. 1.42.
 1.42 08-May-2018  msaitoh - Fix broken watchdog timer. This change detects TX device timeout correctly.
NOTE: It's supporsed not to be called {ixgbe,ixv}_rearm_queues() in the
timer. Those are not required if any chip have no bug. In reality,
ixgbe_rearm_queues() is required on 82599 and newer chip AND other than
queue 0 to prevent device timeout. When it occured, packet was sent but the
descriptor's DD bit wasn't set even though IXGBE_TXD_CMD_EOP and
IXGBE_TXD_CMD_RS were set. After forcing interrupt by writing EICS register
in ixgbe_rearm_queues(), DD is set. Why? Is this an undocumented errata? It
might be possible not call rearm_queues on 82598 or queue 0, we call in any
cases in case the problem occurs. On ixv(4), I have not seen this problem yet
(though I tested only on X550_X(Xeon D 12xx)'s virtual function), but we
do rearm in case TX device timeout happen.
- ixv(4): Call callout_stop() earlier in ixv_stop() like ixgbe_stop().
- KNF.
 1.41 25-Apr-2018  msaitoh Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
 1.40 17-Apr-2018  msaitoh Remove unused structure entries. No functional change.
 1.39 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.38 02-Apr-2018  knakahara Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time

ok by msaitoh@n.o.
 1.37 30-Mar-2018  knakahara Don't write EIMC directly. It is required to manage with struct ix_queue status.

XXX pullup-8
 1.36 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.35 09-Mar-2018  msaitoh Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.34 02-Mar-2018  knakahara branches: 1.34.2;
ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.
 1.33 26-Feb-2018  knakahara Fix poll mode assumption breaking.

ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.

E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.

This fix may have 1% or 2% performance impact at short packets.

XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.

ok by msaitoh@n.o.
 1.32 22-Feb-2018  msaitoh Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.31 20-Feb-2018  msaitoh Increment rxr->packets correctly in ixgbe_rxeof() to calculate ITR value
of AIM (Auto Interrupt Moderation) correctly. See also ixgbe.c rev. 1.124.

XXX pullup-8
 1.30 04-Dec-2017  msaitoh - Fixes two problem:
1) RX may accesses freed area.
2) if_init() takes long time on many core machine.
Call ixgbe_jcl_reinit() not in ixgbe_setup_receive_ring() but in the
biginning of ixgbe_setup_receive_structures(). It was OK for pre multiqueue,
but it's not OK now because we support multiqueue.
- Fix comment of ixgbe_free_receive_ring().
 1.29 26-Sep-2017  knakahara branches: 1.29.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.28 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.27 13-Jun-2017  msaitoh Sync with FreeBSD r316541:

> Fix a double free in ixgbe_rxeof()
>
> Submitted by: rstone
> MFC after: 1 week
> Differential Revision: https://reviews.freebsd.org/D10255
 1.26 13-Jun-2017  msaitoh Fix the partial chain check in ixgbe_rx_discard(). This bug was addded in
rev. 1.33.
 1.25 09-Jun-2017  msaitoh Increase total number of RX buffers on multiqueue.
 1.24 18-May-2017  msaitoh branches: 1.24.2;
Fix a bug that number of input packet counted twice. This bug was added
since sys/net/if.c rev.1.368.
http://mail-index.netbsd.org/source-changes/2016/12/15/msg079882.html
 1.23 08-May-2017  msaitoh Fix a bug that if_obytes and if_omcasts aren't counted. This bug was added
in ixgbe.c rev. 1.27 by me. Reported by Uwe Toenjes.
 1.22 02-Mar-2017  msaitoh branches: 1.22.4;
Fix a problem that m_defrag() isn't called in if_transmit path. Now both
if_start and if_transmit do m_defrag() correctly. This change improves the
performance of TSO.
 1.21 02-Mar-2017  msaitoh Fix a bug that TSO doesn't work correctly. This bug was added in
ix_txrx.c rev. 1.17.
 1.20 13-Feb-2017  msaitoh Use percpuq.
 1.19 10-Feb-2017  msaitoh - Both mbuf_defrag_failed and m_defrag_failed existed. Remove m_defrag_failed.
- rx_irq, dropped_pkts, morerx, moretx and txloops counters are uncounted, so
remove them.
- Count handleq in ixv_handle_que().
- Detach event counters correctly.
- Set some per-queue event names correctly.
 1.18 01-Feb-2017  msaitoh TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h
 1.17 30-Jan-2017  msaitoh - Count tso_err again. It was accidentally removed in ixgbe.c rev. 1.28.
- ixgbe.h: Sort entries to reduce diff against FreeBSD.
 1.16 19-Jan-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.15 18-Jan-2017  msaitoh Call ixgbe_free_transmit_buffers instead of ixgbe_free_transmit_structures()
in ixgbe_allocate_transmit_buffers()...
 1.14 05-Jan-2017  msaitoh branches: 1.14.2; 1.14.4;
Fix INIT_DEBUGOUT() messages.
 1.13 16-Dec-2016  msaitoh The rx_bytes event counter is cleared when if_init() is called, but not for
rx_packets. It's inconsistent. It makes rx_packets is bigger than rx_bytes.
IMHO, it's not required to clear them. At least the above comment says
"/* Setup our descriptor indices */". It's not descriptor indice...
 1.12 15-Dec-2016  ozaki-r Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.11 14-Dec-2016  msaitoh Fix ip[46]csum-tx doesn't work other than TCP and UDP.
 1.10 05-Dec-2016  msaitoh branches: 1.10.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.9 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r294578:
- Fixup SFP module insertion on the 82599 when insertion happens after
the system is booted and running. Add PHY detection logic to
ixgbe_handle_mod() and add locking to ixgbe_handle_msf() as well.
FreeBSD r293334.
- Fix ix advertise value after media change. When ifconfig sets media then the
values displayed by the advertise_speed value are invalidated.
Fix this by setting the bits correctly including setting advertise to 0 for
media = auto. FreeBSD r294578.
- Some others (e.g. LRO(not used by NetBSD)).
 1.8 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.7 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r289238:
- Add support for sysctl knobs to live tune the per interrupt rx/tx packet
processing limits in ixgbe(4)
- Some others (netmap, etc.)
 1.6 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r285590:
- Fix igxbe SRIOV VF (if_ixv) initialization bugs. The MAC address for
an if_ixv instance can now set at creation time, and the receive ring
tail pointer is correctly initialized (previously, things still worked
because the receive ring tail pointer was being fixed up as a side
effect of other activity).
 1.5 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r283881:
- SRIOV support (not enabled because NetBSD doesn't support it).
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.3 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.2 30-Nov-2016  msaitoh Extra "buf->map = NULL;"s in ixgbe_txeof() were removed in FreeBSD r282299.
This was fixed in NetBSD's ixgbe.c rev. 1.28. Remove our comment.
 1.1 28-Nov-2016  msaitoh FreeBSD r280182 made new file ix_txrx.c and moved ixgbe.c and ixv's common
code into it. Before sync with whole of them, just move ixgbe.c and ixv.c's
common code into ix_txrx.c from ixgbe.c. In this commit, only ixgbe.c is split
into the device dependent part and the common part. ixv.c isn't change to make
this commit no functional change. To use ixv.c with ix_txrx.c, it's required
to modify the common part's API and functions themselves.

This commit is done to make the next change easy to understand.
 1.10.2.4 28-Aug-2017  skrll Sync with HEAD
 1.10.2.3 05-Feb-2017  skrll Sync with HEAD
 1.10.2.2 05-Dec-2016  skrll Sync with HEAD
 1.10.2.1 05-Dec-2016  skrll file ix_txrx.c was added on branch nick-nhusb on 2016-12-05 10:55:16 +0000
 1.14.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.14.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.14.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.14.2.1 05-Jan-2017  pgoyette file ix_txrx.c was added on branch pgoyette-localcount on 2017-01-07 08:56:40 +0000
 1.22.4.2 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.22.4.1 11-May-2017  pgoyette Sync with HEAD
 1.24.2.31 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1933:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.24.2.30 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.24.2.29 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.24.2.28 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.24.2.27 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.24.2.26 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.24.2.25 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98
sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.24.2.24 30-May-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1744:

sys/dev/pci/ixgbe/ixgbe.c 1.270,1.280,1.307-1.311,
1.313-1.314 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.96-1.97
sys/dev/pci/ixgbe/ixv.c 1.179-1.180 via patch


- ixg(4): Print Printed Board Assembly (PBA) number.
- ixg(4): Add IFF_RUNNING check in ixgbe_legacy_irq() again. this might
fix small race but it's not so dangerous.
- Add value check for {tx,rx}_process_limit sysctl to avoid setting
wrong value.
- Add missing num_tx_desc sysctl.
- No functional change:
- KNF a bit.
- Simplify setting of EIAC register.
- Move the definition of eicr_mask variable.
- Enclose flow director stuff in ixgbe_intr_admin_common() with
IXGBE_FIR which is not defined in NetBSD.
- Modify comment for consistency.
- Use cached rx_copy_len in ixgbe_rxeof().
 1.24.2.23 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1708:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.24.2.22 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.24.2.21 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.24.2.20 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.24.2.19 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.24.2.18 10-Nov-2019  martin Pull up following revision(s) (requested by knakahara in ticket #1431):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.56

Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.24.2.17 05-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367, to pull up the following
revisions:

sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixgbe.c 1.180,1.203-1.204,
1.207-1.208 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.55
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.10
sys/dev/pci/ixgbe/ixgbe_common.c 1.25
sys/dev/pci/ixgbe/ixv.c 1.129-1.130

- X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
- An interrupt might not arrive when a module is inserted. When an link
status change interrupt occurred and the driver still regard SFP as
unplugged, issue the module softint before issuing LSC softint.
- Add 10000BASE-LX media if it's 1000BASE-BX.
- printf -> device_printf
- Avoid undefined behavior of VLAN filter setting.
- Simplify code.
- Fix typo in unused code.
- Fix typo in comment. Found by Wataru Ashihara.
 1.24.2.16 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.24.2.15 01-Mar-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1199):

sys/dev/pci/ixgbe/ixv.c: revision 1.109
sys/dev/pci/ixgbe/ixgbe.h: revision 1.54
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.174

Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.24.2.14 20-Dec-2018  martin Pull up following revision(s) (requested by knakahara in ticket #1141):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.51

Apply the same fix as if_wm.c:r1.606 to ixg(4). Pointed out by msaitoh@n.o, thanks.

XXX pullup-8
 1.24.2.13 07-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1014):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.50

Fix a bug that ixgbe_mq_start(an if_transmit function) returned wrong
value on error. pcq_put returns false on error, so returning it to caller
indicated no error.

XXX pullup-8
 1.24.2.12 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.24.2.11 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.24.2.10 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.24.2.9 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.24.2.8 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.24.2.7 13-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #626):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.134
sys/dev/pci/ixgbe/ixgbe.h: revision 1.35
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.35
sys/dev/pci/ixgbe/ixv.c: revision 1.87
Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.24.2.6 06-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #605):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe.h: revision 1.33
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.34
sys/dev/pci/ixgbe/ixgbe.c: revision 1.128
sys/dev/pci/ixgbe/ixv.c: revision 1.83
sys/dev/pci/ixgbe/ixv.c: revision 1.84

Add hw.ixvM.q[01].{interrupt_rate,[tr]xd_head,[tr]xd_tail} sysctls as ixg(4).

ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.

ixv(4) also supports workqueue poll mode, but not enabled by default yet, either.
ok by msaitoh@n.o.

Move the location of "struct work" as FreeBSD's "struct task" in ixgbe.h.
No functional change.
 1.24.2.5 01-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #597):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.c: revision 1.127
sys/dev/pci/ixgbe/ixv.c: revision 1.82
Fix poll mode assumption breaking.
ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.
E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.
This fix may have 1% or 2% performance impact at short packets.
XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.
ok by msaitoh@n.o.
Apply ixgbe.c:r1.127 to ixv.c. Pointed out by msaitoh@n.o.
 1.24.2.4 26-Feb-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #592):
sys/dev/pci/ixgbe/ixv.c: revision 1.79
sys/dev/pci/ixgbe/ixgbe.h: revision 1.30
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.31
sys/dev/pci/ixgbe/ixgbe.c: revision 1.120
sys/dev/pci/ixgbe/ixgbe.c: revision 1.121
sys/dev/pci/ixgbe/ixgbe.c: revision 1.123
sys/dev/pci/ixgbe/ixgbe.c: revision 1.124
sys/dev/pci/ixgbe/ixgbe.c: revision 1.125
sys/dev/pci/ixgbe/ixgbe.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.80
sys/dev/pci/ixgbe/ixv.c: revision 1.81
CID-1427719: Integer handling issues (BAD_SHIFT). Print bus/slot info
correctly on 82599_SFP_SF_QP(DID 0x154a) and 82599_QSFP_SF_QP(DID 0x1558).
Fix a bug that RX may stall on heavy load on ixg(4). ixgbe_rxeof() has loop
limit and the function returns true if a packet are still in the RX ring.
ixgbe_handle_que() didn't check the return value. Check the return vaule
and issue a softint.
This bug is derived from FreeBSD and ixv(4) has no this bug.
XXX pullup-8
Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().
XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
- Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:
sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)
Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:
int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |
The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.
While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!
This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.
(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.
- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.
XXX pullup-8
Increment rxr->packets correctly in ixgbe_rxeof() to calculate ITR value
of AIM (Auto Interrupt Moderation) correctly. See also ixgbe.c rev. 1.124.
XXX pullup-8
Improve a comment about reading EICS register defined write-only by spec.
It seems that is workaround for silicon errata.
ok by msaitoh@n.o.
- Apply ixgbe.c rev. 1.124 to ixv.c. Fix a bug that RX may stall on heavy load
on ixv(4) derived from FreeBSD's AIM (Auto Interrupt Moderation) bug.
ITR_INTERVAL value must be larger than 4us.
- The bitfield of EITR register is different between 82598 and others.
ixv.c had a bug that it accessed 82598's way even though only 82599 and
newer support virtual function. Fix it using with new ixv_eitr_write()
function.
Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.24.2.3 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.24.2.2 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.24.2.1 05-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #175):
sys/dev/pci/ixgbe/ix_txrx.c: 1.25-1.27
sys/dev/pci/ixgbe/ixgbe.c: 1.91-1.95
sys/dev/pci/ixgbe/ixgbe_type.h: 1.23-1.25
sys/dev/pci/ixgbe/ixgbe_api.c: 1.16
sync ixg(4) up to ixgbe.c rev. 1.95:
- Increase total number of RX buffers on multiqueue.
- Fix the partial chain check in ixgbe_rx_discard(). This bug was
added in ixgbe.c rev. 1.33.
- Fix a double free in ixgbe_rxeof().
- Print verbose output in ixgbe_update_link_status() correctly on 5Gbps
and 2.5Gbps (NBASE-T) for X550T[12] and newer.
- Change hw.ixgN.ts to hw.ixgN.thermal_test. Same as FreeBSD.
- Fix a bug that ifconfig ixgN media 1000baseT and 10Gbase-T advertised
additional unwanted speeds.
- Print PHY ID.
- Remove unused variable.
 1.29.2.2 03-Dec-2017  jdolecek update from HEAD
 1.29.2.1 26-Sep-2017  jdolecek file ix_txrx.c was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.34.2.11 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.34.2.10 30-Sep-2018  pgoyette Ssync with HEAD
 1.34.2.9 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.34.2.8 28-Jul-2018  pgoyette Sync with HEAD
 1.34.2.7 25-Jun-2018  pgoyette Sync with HEAD
 1.34.2.6 21-May-2018  pgoyette Sync with HEAD
 1.34.2.5 02-May-2018  pgoyette Synch with HEAD
 1.34.2.4 22-Apr-2018  pgoyette Sync with HEAD
 1.34.2.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.34.2.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.34.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.48.2.4 21-Apr-2020  martin Sync with HEAD
 1.48.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.48.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48.2.1 10-Jun-2019  christos Sync with HEAD
 1.54.2.15 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1792:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.54.2.14 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.54.2.13 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.54.2.12 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.54.2.11 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.54.2.10 30-May-2022  martin Pull up the following revisions, requested by msaitoh:

sys/dev/pci/ixgbe/ixgbe.c 1.270,1.280,1.307-1.311,
1.313-1.314 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.96-1.97
sys/dev/pci/ixgbe/ixv.c 1.158,1.179-1.180 via patch


- ixg(4): Print Printed Board Assembly (PBA) number.
- ixg(4): Add IFF_RUNNING check in ixgbe_legacy_irq() again. this might
fix small race but it's not so dangerous.
- Add value check for {tx,rx}_process_limit sysctl to avoid setting
wrong value.
- Add missing num_tx_desc sysctl.
- No functional change:
- KNF a bit.
- Simplify setting of EIAC register.
- Move the definition of eicr_mask variable.
- Enclose flow director stuff in ixgbe_intr_admin_common() with
IXGBE_FIR which is not defined in NetBSD.
- Modify comment for consistency.
- Use cached rx_copy_len in ixgbe_rxeof().
 1.54.2.9 13-May-2022  martin Pull up following revision(s) (requested by bouyer in ticket #1445):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.
 1.54.2.8 02-Feb-2022  martin Pull up the following revisions (requested by msaitoh in ticket #1424):

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.305 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixv.c 1.178 via patch

Use atomic_{load,store}_relaxed() for event counters.
 1.54.2.7 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1374:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.54.2.6 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.54.2.5 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.54.2.4 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.54.2.3 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.54.2.2 01-Nov-2019  martin Pull up following revision(s) (requested by knakahara in ticket #387):

sys/net/if_gre.c: revision 1.176
sys/net/if_l2tp.c: revision 1.40
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.56
sys/net/if_tap.c: revision 1.114

Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.54.2.1 05-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #180):

sys/dev/pci/ixgbe/ixv.c: revision 1.130
sys/dev/pci/ixgbe/ixgbe.c: revision 1.207
sys/dev/pci/ixgbe/ixgbe.c: revision 1.208
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.55
sys/dev/pci/ixgbe/ixv.c: revision 1.129
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.10

printf -> device_printf

Set IFM_1000_BX10 correctly.

Use aprint_*() in the attach function.
 1.58.2.2 29-Feb-2020  ad Sync with head.
 1.58.2.1 25-Jan-2020  ad Sync with head.
 1.62.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.63.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.69.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.70.2.3 01-Aug-2021  thorpej Sync with HEAD.
 1.70.2.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.70.2.1 13-May-2021  thorpej Sync with HEAD.
 1.71.2.1 31-May-2021  cjep sync with head
 1.100.4.5 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #563):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.110
sys/dev/pci/ixgbe/ixgbe.c: revision 1.345
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.111
sys/dev/pci/ixgbe/ixgbe.c: revision 1.346
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.112
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.62
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.113
sys/dev/pci/ixgbe/ixgbe.c: revision 1.348
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.114
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.115
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.116
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.105
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.106
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.107
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.108
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.109
sys/dev/pci/ixgbe/ixv.c: revision 1.193
sys/dev/pci/ixgbe/ixv.c: revision 1.195
sys/dev/pci/ixgbe/ixv.c: revision 1.196
sys/dev/pci/ixgbe/ixgbe.h: revision 1.94
sys/dev/pci/ixgbe/ixgbe.h: revision 1.95
sys/dev/pci/ixgbe/ixgbe.h: revision 1.96
sys/dev/pci/ixgbe/ixgbe.h: revision 1.97
sys/dev/pci/ixgbe/ixgbe.h: revision 1.98

ixgbe: Fix comment. No functional change.
ixgbe: Whitespace. No functional change.
ixgbe(4): Move assignment of TXD. NFCI.
ixgbe(4): Modify comment. No functional change.
ixgbe_tx_ctx_setup() may or may not consume one TX descriptor.
ixv(4): Remove unused IFF_OACTIVE. No functional change.
ixgbe: Clear the WTHRESH bit field before writing it.
ixgbe: Modify for the readability. No functional change.
ixgbe: micro-optimize ixgbe_txeof()
Update txr->tx_avail and txr->txr_no_space outside the loop in ixgbe_txeof().
ixgbe: Update if_opackets outside the loop in ixgbe_txeof().
ixgbe: micro-optimize ixgbe_txeof()
Update txr->packets outside the loop in ixgbe_txeof().
ixgbe: Use #ifdef IXGBE_FDIR more
Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
ixgbe: Simplify. No functional change.
The descriptor ring size and the alignment are tested in the attach
function, so it's not required to use roundup2(size, DBA_ALIGN).
ixgbe: Use kmem_zalloc() instead of malloc(,M_ZERO).
ixgbe: Remove unused to reduce the size of struct rx_ring.
ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
ixgbe: Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring and rx_ring
because of the alignment.
ixgbe: Use #ifdef RSC
This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.100.4.4 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #420):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.340
sys/dev/pci/ixgbe/ixgbe.c: revision 1.341
sys/dev/pci/ixgbe/ixgbe.c: revision 1.342
sys/dev/pci/ixgbe/ixgbe.c: revision 1.343
sys/dev/pci/ixgbe/ixgbe.c: revision 1.344
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.61
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.104
sys/dev/pci/ixgbe/ixv.c: revision 1.190
sys/dev/pci/ixgbe/ixv.c: revision 1.191
sys/dev/pci/ixgbe/ixv.c: revision 1.192
sys/dev/pci/ixgbe/ixgbe.h: revision 1.93

ixg(4): Print DEVICE_CAPS register.

ixgbe: Whitespace. No functional change.

ixg(4): Don't print wrong error message about ixgbe_num_queues.
Don't override the ixgbe_num_queues global variable. It's the default
value of the number of queues and should not override it because it
will be referenced by later device attach. For example, the number of
MSI-X vector is 64 on X540 and 18 on 82599. When both cards are inserted
to a machine that the number of CPU is 24 and X540 is probed earlier,
ixgbe_num_queues is overridden to 24 and the following error message is
printed when attaching 82599:
ixg2: autoconfiguration error: ixgbe_num_queues (24) is too large,
using reduced amount (17).

Note that the number of queues is in sc->num_queuss and referenced
by hw.ixgN.num_queues sysctl.

ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.

ixgbe: Whitespace. No functional change.
 1.100.4.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.100.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.100.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.354 10-Jul-2024  msaitoh ixgbe: Remove ifdef NET_MPSAFE. Make ixgbe MP-scalable by default.

Same as wm(4).
 1.353 10-Jul-2024  msaitoh ixgbe: ixgbe is always MP-safe, so remove IXGBE_MPSAFE macro.

Before this change, IXGBE_MPSAFE is not defined if NET_MPSAFE is not set.
In this case, the PCI_INTR_MPSAFE flag is not set by pci_intr_setattr()
and interrupt_distribute() fails on arm. Always enable IXGBE_MPSAFE
funciton by removing the macro.
 1.352 29-Jun-2024  riastradh branches: 1.352.2;
if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.351 30-May-2024  msaitoh Move RECOVERY_MODE feature test code for readability. No functional change.

ixgbe.c rev. 1.169 inserted RECOVERY_MODE feature test in between
MSI-X allocation and legacy allocation. To improve code readability,
move it to earlier location.
 1.350 13-May-2024  msaitoh Modify comment. The number of queues is not limited to 8.

The number of queue is calculated from both the number of CPUs and
the number of MSI-X vectors.
 1.349 24-Jan-2024  msaitoh ixgbe: Add QPRDC into iqdrops.

A receive packet might drop at two different locations.
One is the packet buffer that packets are received into the chip first.
If the packet buffer is overflowed, the MPC register is incremented.
It's currently added to iqdrops. It's no problem.
Another is descriptor ring(s). A packet from the packet buffer is DMA'ed
into main memory base on the descriptor ring. If the ring is full, the packet
is dropped and the QPRDC register is incremented. It should be added to
iqdrops but it was not done. Fix it.
Reported by ozaki-r@.
 1.348 15-Nov-2023  msaitoh ixgbe: Clear the WTHRESH bit field before writing it.
 1.347 02-Nov-2023  yamaguchi Use ether_bpf_mtap only when the device supports vlan harware tagging

The function is bpf_mtap() for ethernet devices and *currently*
it is just handling VLAN tag stripped by the hardware.
 1.346 02-Nov-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.345 30-Oct-2023  msaitoh ixgbe: Fix comment. No functional change.
 1.344 18-Oct-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.343 12-Oct-2023  msaitoh ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.
 1.342 12-Oct-2023  msaitoh ixg(4): Don't print wrong error message about ixgbe_num_queues.

Don't override the ixgbe_num_queues global variable. It's the default
value of the number of queues and should not override it because it
will be referenced by later device attach. For example, the number of
MSI-X vector is 64 on X540 and 18 on 82599. When both cards are inserted
to a machine that the number of CPU is 24 and X540 is probed earlier,
ixgbe_num_queues is overridden to 24 and the following error message is
printed when attaching 82599:

ixg2: autoconfiguration error: ixgbe_num_queues (24) is too large,
using reduced amount (17).

Note that the number of queues is in sc->num_queuss and referenced
by hw.ixgN.num_queues sysctl.
 1.341 12-Oct-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.340 11-Oct-2023  msaitoh ixg(4): Print DEVICE_CAPS register.
 1.339 11-Oct-2023  msaitoh ixg(4): Whitespace. No functional change.
 1.338 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.337 06-Oct-2023  msaitoh ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.
 1.336 06-Oct-2023  msaitoh ixgbe: Modify error message of wrong TX/RX descriptor size.

- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.
 1.335 06-Oct-2023  msaitoh ixgbe: Simplify definitions. No functional change.

Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.
 1.334 06-Oct-2023  msaitoh ixg(4): Add 82599 LS once again.

- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.
 1.333 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.332 06-Oct-2023  msaitoh ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.

From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.331 14-Sep-2023  msaitoh ixg(4): Rename some descriptions of flow control related event conters.
 1.330 14-Sep-2023  msaitoh ixg(4): Reorder some flow control related event counters for readability.
 1.329 13-Sep-2023  msaitoh ixg(4): Count Queue Bytes {Transmit, Receive} counter.
 1.328 13-Sep-2023  msaitoh ixg(4): Rename some descriptions of event counters.

- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.
 1.327 13-Sep-2023  msaitoh ixgbe: Reorder some event counters for readability.
 1.326 15-May-2023  msaitoh Count the number of link down events in the MAC using with LINK_DN_CNT.

- Add new event counter "link_dn_cnt" to count the number of link down
events in the MAC.
- The LINK_DN_CNT register (at 0x0403c) is described only in the
Denverton's datasheet, so use it only on ixgbe_mac_X550EM_a.
 1.325 03-Feb-2023  msaitoh Use thermal sensor code for IXGBE_DEV_ID_X550EM_A_10G_T, too.

PCI device ID 0x15c8 also use X557-AT PHY, so create the thermal sensor
sysctl for it, too.
 1.324 28-Oct-2022  msaitoh branches: 1.324.2;
Make three "Unsupported SFP+ module..." messages the same.
 1.323 06-Jul-2022  msaitoh Call txeof first, then rxeof for the consistency.

There are three functions where the txeof and rxeof are called. The legacy
interrupt function and MSI-X function call rxeof first, then rxeof.
For the workqueue function. rxeof is called first. Modify it to match with
other two.
 1.322 18-Jun-2022  skrll aprintf_normal -> aprint_normal
 1.321 02-Jun-2022  msaitoh Modify comment. ixgbe_enable_queue() can be used on both MSI-X and legacy intr.
 1.320 02-Jun-2022  msaitoh KNF. Modify comment. No functional change.
 1.319 02-Jun-2022  msaitoh KNF. No functional change.
 1.318 01-Jun-2022  msaitoh Correctly enter the recovery mode. Not tested.
 1.317 01-Jun-2022  msaitoh Correctly re-enable queue interrupt in ixgbe_legacy_irq().

- Don't enable queue 1-15 interrupt.
- Don't enable queue 0 interrupt when the queue work is being scheduled.
- OK'd by knakahara.
 1.316 01-Jun-2022  msaitoh Simplify ixgbe_msix_que(). No functional change.
 1.315 30-May-2022  msaitoh Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.
 1.314 25-Apr-2022  msaitoh Add missing num_tx_desc sysctl.
 1.313 25-Apr-2022  msaitoh Limit {tx,rx}_process_limit sysctl values from 1 to num_{tx,rx}_desc.
 1.312 10-Mar-2022  msaitoh Print ECC, PHY and temp error log using with ratecheck().

- The ratecheck() is for just in case. All of the interrupts might occur
only once, but I don't know whether it's true or not. For the fan failure,
it seems it occurs only once.
- All of the interval is 60s.
 1.311 10-Mar-2022  msaitoh Enclose flow director stuff in ixgbe_intr_admin_common() with IXGBE_FIR.
 1.310 10-Mar-2022  msaitoh Move the definition of eicr_mask variable. No functional change.
 1.309 10-Mar-2022  msaitoh Modify comment to clarify EIAC setting.
 1.308 10-Mar-2022  msaitoh Add IFF_RUNNING check in ixgbe_legacy_irq() again.

- This change might fix small race between ifconfig down and an interrupt.
If the race really exists, txeof() is called and it's not so dangerous.
The rxeof is blocked in the beginning of ixgbe_handle_que().
- This change makes consistent with ixgbe_handle_que().
- Found and OK'd by knakahara.
 1.307 16-Feb-2022  msaitoh Print Printed Board Assembly (PBA) number.
 1.306 01-Feb-2022  msaitoh Increment legacy interrupt counter after checking INTx sharing.
 1.305 25-Jan-2022  msaitoh Use atomic_{load,store}_relaxed() for event counters.
 1.304 18-Jan-2022  msaitoh Use 64bit for lxon + lxoff.
 1.303 17-Jan-2022  msaitoh Fix ierror counting again.

ixgbe.c rev. 1.298 added total values kept in evcnt(9) instead of
incremental values read from registers. Fix it.
 1.302 31-Dec-2021  riastradh sys: Use if_init wrapper function.

Exception: Not in kern_pmf.c, for the kind of silly reason that it
avoids having kern_pmf.c refer to symbols defined only in net; this
avoids a pain in the rump.
 1.301 24-Dec-2021  msaitoh Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.300 16-Dec-2021  msaitoh Print NVM image version on 82598.

FreeBSD ix-3.3.29 added code to decode NVM version. On 82598, the NVM
offset is NVM_EEP_OFFSET_82598(== 0x2a). My own three different 82598
cards' value in NVM_EEP_OFFSET_82598 are 0xffff. Instead, the dev starter
version (0x29) has the value. Two of them have 0x1070 and another has 0x2090.
The 82598 specification update notes about 2.9.0.
 1.299 15-Dec-2021  msaitoh Improve PHY's dmesg output for non-MIIVERBOSE case.
 1.298 14-Dec-2021  msaitoh Add some missing error counters to ierror.

- FreeBSD: afb1aa4e6df245d38fd2ba683fa521d5dabe8392 or ix-ix-3.3.22
- Note that the checksum error is not added to the ierror.
 1.297 10-Dec-2021  msaitoh Move PF mailbox initialization from ixgbe_attach() to ixgbe_init_iov().

From FreeBSD ix-3.3.18. No functional change.
 1.296 10-Dec-2021  msaitoh No functional change.

- Sync with FreeBSD ix-3.3.18.
- Rename ixgbe_get_advertise() to ixgbe_get_default_advertise.
- Sort lines, modify comment and whitespace to reduce diff against FreeBSD.
 1.295 07-Dec-2021  andvar fix typos in word "instead", mainly in log messages.
 1.294 12-Nov-2021  skrll KNF
 1.293 30-Sep-2021  yamaguchi Remove vlan_ifdetach() from ixgbe_detach()

The removed function is called in ether_ifdetach().
And ether_ifdetach is changed to be called before a device
is stopped, because vlan_ifdetach called from ether_ifdetach
configures VLAN settings.
 1.292 16-Sep-2021  msaitoh Fix a bug that an mbuf chain which has more than 63488bytes MAY fail on TX.

- Currently, The TX buffer dmamap's max number of segments is set to 32.
MCLBYTES(== 2048) * 32 = 65536 and it's enough for IP_MAXPACKET(65535).
If an mbuf chain has more than 32 mbufs, we call m_defrag() to make
it lower than equal to 32, but it might not work. The reason is that
our m_defrag() don't modify the first mbuf entry of the chain. e.g.:
if an mbuf chain contains 63600bytes data and the first mbuf has 100bytes
in the m_data, the new chain has 100+2048+2048+...+12 and the total number
of the chain is not 32 but 33. It result in 43 TCP packets will drop.
- One of the way to fix this problem is to change m_defrag() which add a
new mbuf cluster to the first mbuf. It's need discussion.
- Another solution is to change the max number of the TX DMA segment.
It should be at least 33 to avoid the m_defrag()'s current limitation.
The document (82599-X550 DS 7.2.1.1 "Transmit Storage in system Memory")
says that a packet can be fragmented into 40 - WTHRESH - 2 (for 82598,
the document say nothing and some people and code says it's unlimited).
Currently WTHRESH is set to 8. 40 - 8 - 2 = 30. !?!?!? {Net,Free,Open}BSD
and Linux use 32. Is that safe? Anyway, we change WTHRESH from 8 to 5
to fit it. The added comment in ixgbe.h is based on DragonFly's
though they don't use WTHRESH.
- Yet another solution is to use the Tx Head Pointer Write Back function
instead of WTHRESH based write back (see 82599-X550 DS 7.2.3.5.2
"Tx Head Pointer Write Back" or 82598 "Transmit Completions Head Write Back"
). DragonFly, illumos and DPDK use it.
- Yet yet another solution is to add tso_maxsize entry to struct ifnet
and use it in the TCP stack.
 1.291 16-Sep-2021  msaitoh Use IXGBE_TXDCTL_WTHRESH_SHIFT macro. No functional change.
 1.290 26-Aug-2021  msaitoh Remove "j" or "jumbo" because we always use MCLBYTES sized buffer.
 1.289 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.288 20-Aug-2021  andvar fix various typos in comments and log messages.
 1.287 15-Jul-2021  msaitoh Add a new sysctl to read rxr->next_to_refresh.
 1.286 07-Jul-2021  msaitoh Add new sysctl "rx_copy_len".

ixgbe_rxeof() has an optimization "RX_COPY" to reduce costs of
bus_dmamap_load_mbuf() and bus_dmamap_unload() by copying a mbuf cluster's
memory to a newly allocated mbuf's MH_databuf[] and recycle the original map.
The optimization is used when a length of a packet is smaller than a specific
value. The value is calculated based on MHLEN. The size of MHLEN is
architecture specific. It's 256 or 512. Make the threshold controllable by
adding a new sysctl.
 1.285 29-Jun-2021  pgoyette Rework the xxxVERBOSE option to share the common module-hook-based
verbose mechanism with MIIVERBOSE. This reduces some duplicated code
and allows us to once again permit auto-unload of MIIVERBOSE.

Change details:
* Update dev/devlist2h.awk to accomodate miidevs, including generation
of MII_STR_oui_model definitions and use of oui and model rather than
vendor and product. This also changes the compressed data in the
xxxdevs_data.h files to uint32_t (since mii oui's are up to 6 hex
digits long)
* Update a couple of phy drivers to use new calls to get verbose data
* Regen all of the xxxdevs{,_data}.h files (separate commit, coming
very soon)
* Update mii/mii_verbose.[ch] and mii/mii_physubr.c to use the various
DEV_VERBOSE_xxx macros
* Update the pci, usb, and hdaudio code as needed, to #include the
xxxdevs.h files (in order to get the proper printf format strings)
* Since dev/dev_verbose.c now uses non-literal printf format strings,
(to deal with the vendor/product vs oui/model issue), we need to
make sure it gets compiled with -Wno-error=format-nonliteral, even
in userland's libpci and librumpdev!
* Bump kernel version for the change in module interfaces

Welcome to 9.99.86!

XXX It might be useful in the future to extend the MII_STR_oui_model
XXX definitions to PCI as well (and perhaps USB and HDAUDIO). This
XXX would allow for a single centralized location for the products'
XXX descriptions, rather than being dispersed among individual
XXX drivers' xxx_match tables.
 1.284 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.283 18-May-2021  msaitoh - Cleanup an rxbuf entry when bus_dmamap_load_mbuf() failed to prevent panic.
- Print error number when error occurred.
 1.282 07-May-2021  msaitoh branches: 1.282.2;
Print the error value of ixgbe_reset_hw() for debugging.
 1.281 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.280 31-Mar-2021  msaitoh branches: 1.280.2;
KNF a bit. No functional change.
 1.279 09-Mar-2021  msaitoh branches: 1.279.2;
Modify some parameters to reduce packet dropping.

- Background: ixgbe doesn't use common MCLGET() interface and use the
driver specific cluster allocation mechanism (jcl). The cluster is
pre-allocated with a fixed number and the current number per queue
is num_rx_desc * 2 (2048*2=4096). It's too small. It also has a problem
that the max length of the pcq which is used in the TX path is big
(4096). Example:

100M <----- [ixg0 ixg1] <----- 1G
2048 TX descs <--- 4096 pcqs <---- 2048 RX descs

If a machine forwards a traffic from 1G interface to 100M interface,
It would require 2048+4096+2048=8192 descriptors, but the current number
is 2048*2=4096. It's too small. Even if the both interface's link speed
is the same and only small number of packet is queued in the pcq, 4096
jcl is small because 2048(RX)+TX(2048)=4096. If jcl is exhausted, not only
forwarding from ixg1 to ixg0 is dropped, but also another forwarding path
from ixg1 to another interface(e.g. wm0) is also dropped. Sockets also
queue packets, so if a lot of sockets are used and/or a socket buffer
size is changed to bigger one, it'll also become a problem. If the jcl
is exhausted, evcnt(9) counter "ixgX qY Rx no jumbo mbuf" is incremented.
Example:
vmstat -ev | grep ixg1 | grep "no jumbo"
ixg1 q0 Rx no jumbo mbuf 0 0 misc
ixg1 q1 Rx no jumbo mbuf 0 0 misc
ixg1 q2 Rx no jumbo mbuf 141326 0 misc
ixg1 q3 Rx no jumbo mbuf 0 0 misc


- To solve this problem:
- Add new config parameter IXGBE_JCLNUM_MULTI and set the default to 3
(2048 * 3). The minimum number is 2. The total number of jcl per queue
is available with hw.ixgN.num_jcl_per_queue sysctl.
- Reduce the max length of the pcq() which is used in the TX path from
4096 to 2048.

- Reviewed by knakahara@ and ozaki-r@.

- TODO: Use MCLGET().
 1.278 14-Jan-2021  msaitoh Add "TX " to "Queue No Descriptor Available" to make it more understandable.
 1.277 31-Dec-2020  msaitoh Reduce code duplication. No functional change.

Add new ixgbe_intr_admin_common() and use it in both ixgbe_msix_admin()
and ixgbe_legacy_irq().
 1.276 26-Dec-2020  msaitoh Copy & paste some missing part (flow director, ECC and temp sensor) from
ixgbe_msix_admin() to ixgbe_legacy_irq(). Now it's ready to make a new
function to share the common part. It'll be done in near future.
 1.275 26-Dec-2020  msaitoh Don't return in the middle of ixgbe_msix_admin() when an flow director reinit
failed. NetBSD currently doesn't support flow director, so this is not a real
bug.
 1.274 26-Dec-2020  msaitoh Disable some interrupt in ixgbe_{legacy_irq,msix_admin}() to prevent log spam.
 1.273 26-Dec-2020  msaitoh Disable/enable the OTHER interrupts correctly.

The OTHER interrupt was not blocked correctly when MSI-X is used.
ixgbe.c rev. 1.260 added new mutex to avoid the race but it didn't
disable the interrupt itself.

Calling ixgbe_enable_intr() enables all interrupts, so it's not good to
call it when some interrupt sources should not be enabled (e.g.:
calling ixgbe_enable_intr() in ixgbe_handle_admin() enables queue
interrupt).

IXGBE_REQUEST_TASK_NEED_ACKINTR doesn't work as expected because
ixgbe_handle_admin() can't know which task is enqueued from the
interrupt context and can't re-enable a specific EIMS bit.

Solve the above three problems by the following two changes:

- MSI-X: Disable the OTHER interrupts in the biginning of
ixgbe_msix_admin().

- Set mask bits correctly at the end of ixgbe_legacy_irq() and
ixgbe_msix_admin() using with eim_orig, eims_enable and eims_disable.

- Remove IXGBE_REQUEST_TASK_NEED_ACKINTR and add
IXGBE_REQUEST_TASK_{MOD,MSF}_WOI.
 1.272 26-Dec-2020  msaitoh Check EICR's queue bit instead of IFF_RUNNING. This change fixes a bug that
it might incorrectly enable interrupt when IFF_RUNNING is not set. It also
changes that the TX/RX is not processed if a queue interrupt isn't occurred.
 1.271 26-Dec-2020  msaitoh Don't use "more" flag for simplify in ixgbe_legacy_irq().
No functional change intended.
 1.270 24-Dec-2020  msaitoh Simplify setting of EIAC register. No functional change intended.
 1.269 24-Dec-2020  msaitoh Fix a bug that INTx is disabled if the INTx line is shared with other device.
ixgbe.c rev. 1.264 was not correct.

Restore EIMS before return. To read ECIR, clearing EIMC is required for
an errata, so
0) save the original EIMS value
1) clear EIMS
2) read EICR
3) restore with the saved value.
 1.268 24-Dec-2020  msaitoh The EICR register are cleared in the beginning of the ixgbe_legacy_irq(),
so it's not required to clear each bit later in the function.
 1.267 24-Dec-2020  msaitoh The EICR register's all OTHER interrupt bits are cleared in the beginning of
the ixgbe_msix_admin(), so it's not required to clear each bit later in the
function.
 1.266 24-Dec-2020  msaitoh Reorder some code to reduce diff between ixgbe_legacy_irq() and
ixgbe_msix_admin. No functional change intended.
 1.265 24-Dec-2020  msaitoh Add some debug printf()s and modify comments.
 1.264 24-Dec-2020  msaitoh Remove strange ixgbe_enable_intr() in ixgbe_legacy_irq().

If the interface is UP and the INTx line is shared with other devices,
it result in enabling all interrupt sources even if some of them are
disabled for the workqueue. Delete ixgbe_enable_intr() in ixgbe_legacy_irq().
 1.263 22-Dec-2020  msaitoh Correctly ACK the fan failure interrupt in ixgbe_legacy_irq().
 1.262 11-Dec-2020  msaitoh Don't use EIMC_OTHER bit because it's read only other than 82598.

Documents say:

82598:
All of bit 31(OTHER bit) of EIxx are reserved. In reality, at least
EIMS_OTHER and EIMC_OTHER exist and the OTHER interrupt doesn't work
without EIMS_OTHER.

Other than 82598:
EIMS_OTHER is read only and EIMC_OTHER doesn't exist. If one of
bit 29..16 is set, EIMS_OTHER is set to 1 (Note that bit 30(TCP timer
isn't included)). Even if write bit 31 of EIMC to 1, it's ignored
(EIMS_OTHER doesn't set).

We introduced new spin mutex in ixgbe.c rev. 1.260, so it's OK to remove
EIMC_OTHER stuff. We already set EIMS_OTHER in if_init(), so keep it for
82598. No functional change other than 82598.

Another solution is to control bit 30..16 directly to mask/unmask interrupt
instead of the mutex.

TODO:
Some MSI-X interrupt(LSC, module insertion/removal etc.)'s mask/unmask
code between ixgbe_msix_admin() and ixgbe_handle_admin() may be wrong.
It'll be fixed later.
 1.261 30-Nov-2020  msaitoh Apply ixgbe.c rev. 1.204 which was for ixgbe_msix_admin() to
ixgbe_legacy_irq(), too.

> An interrupt might not arrive when a module is inserted. When an link
> status change interrupt occurred and the driver still regard SFP as
> unplugged, issue the module softint before issuing LSC interrupt.

TODO: Reduce duplicated code.
 1.260 17-Nov-2020  knakahara Add new spin mutex to avoid race between ixgbe_msix_admin() and ixgbe_handle_admin().

At first, it seems "IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER)"
cannot stop interrupts, because 31th bit is reserved for 82598, 82599,
X540 and X550. So, the current following design
(1) ixgbe_msix_admin() disables interrupts
(2) ixgbe_msix_admin() calls workqueue_enqueue() for ixgbe_handle_admin()
(3) ixgbe_handle_admin() does interrupt processing
(4) after ixgbe_handle_admin() has done all interrupt processings,
ixgbe_handle_admin() enables interrupts
does not work correctly, that is, interrupts can be lost while
ixgbe_handle_admin() is running.

To fix that, add new spin mutex(adapter->admmin_mtx) which protects
atomically the following two members.
- adapter->admin_pending
- adapter->task_requests

The unnecessary "IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER)"
code will be removed later.

Reviewed and tested by hikaru@n.o and msaitoh@n.o, thanks.
 1.259 13-Nov-2020  msaitoh Fix a bug that some advertise speeds can't be set with hw.ixgN.advertise_speed
if both 2.5G and 5G are set. Fix the error message, too.
 1.258 07-Sep-2020  knakahara branches: 1.258.2;
Fix race between ixgbe_msix_admin() and ixgbe_handle_admin(), pointed out by ozaki-r@n.o.

The race is caused by the following.
CPU#A processes workqueue, CPU#B processes admin interrupt.
(0) one of CPUs already calls ixgbe_schedule_admin_tasklet()
such as ixgbe_handle_timer()
(1) CPU#A: read adapter->task_requests
(2) CPU#B: set adapter->task_requests
(3) CPU#B: read(and try to set) adapter->admin_pending
but adapter->admin_pending is set, so does not
call workqueue_enqueue()
(4) CPU#A: clear adapter->admin_pending
that is, the tasks set by (2) is not processed as missfire workqueue by (3).
 1.257 07-Sep-2020  msaitoh - Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@.
- Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers().
- Add KASSERT() to functions who are called from ixgbe_handle_admin().
 1.256 07-Sep-2020  msaitoh __predict_false() should be __predict_true() for adapter->osdep.detaching
== false check.
 1.255 07-Sep-2020  msaitoh Don't schedule admin work while shutdown like the recovery mode timer.

The admin workqueue also runs while !IFF_UP like the recovery mode timer.
Apply the same change of ixgbe.c 1.254 to ixgbe_schedule_admin_tasklet()
to prevent panic. Found by ozaki-r@.
 1.254 01-Sep-2020  msaitoh Fix a panic on shutdown on a machine which use the recovery mode timer.

The recovery mode timer is first issued by the callout and it schedule
the workqueue. The workqueue then reschedule the callout. It's hard to
stop both of them without race only with callout_stop() and workqueue_wait.
To solve this problem. add new "detaching" flag and use it.

The situation is almost the same as schedule_wqs_ok for the local_timer's
callout and workqueue, but the difference is that the local_timer isn't
required to run if the interface is not up. If it's not important to prevent
running timer while !IFF_UP, the flag can be integrated into one.
 1.253 01-Sep-2020  msaitoh Call ixgbe_ifstop() instead of ixgbe_stop_locked() in
ixgbe_setup_low_power_mode() to stop the timer workqueue.
 1.252 31-Aug-2020  msaitoh Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional change.
 1.251 31-Aug-2020  msaitoh If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.
This change eliminate long timeout.

Reduce code duplication using with ixgbe_sfp_cage_full(hw).
 1.250 31-Aug-2020  msaitoh Fix typo in comment.
 1.249 31-Aug-2020  msaitoh Fix 82598 SFP+ problems.

On 82598, SFP+'s MOD_ABS isn't connected to the MAC's GPIO pin, so we can't
call ixgbe_sfp_cage_full(). Always issue TASK_MOD from ixgbe_handle_timer()
on 82598.

Fix ixgbe_identify_sfp_module_generic() for ixgbe_phy_nl. In the driver,
hw->phy.type sometimes be compared with ixgbe_phy_nl.
In ixgbe_identify_sfp_module_generic(), hw->phy.type may be overridden with
another value. For ixgbe_phy_nl, some code don't override phy.type but others
were not. Make it consistently keep ixgbe_phy_nl. This change fixes a problem
that ixgbe_is_sfp() change the return value true to false when any SFP+
devices are connected to the cage on 82598 and never recover from it.

Don't schedule MSF(multi speed fiber) task from ixgbe_handle_mod() on 82598.
This task is only for devices which support multi speed fiber and 82598
doesn't support it. Before ixgbe.c rev. 1.237, ixgbe_handle_mod() isn't
called on 82598 because 82598 has no SFP+ module insertion/removal interrupt.
ixgbe.c rev. 1.237 changed to call the function via timer on 82598.
This change fixes a bug that 82598 DA interface's link flaps.
 1.248 27-Aug-2020  msaitoh Limit MA10-ST0's quirk only for on-chip devices.
 1.247 27-Aug-2020  msaitoh Fix compile error.
 1.246 27-Aug-2020  msaitoh Minor change.

- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.245 27-Aug-2020  msaitoh ADD SFP+ MOD_ABS inversion quirk.

On X550 EM, GPIO(SDP) and SFP+'s MOD_ABS is directly connected. It has
no inverter. GIGABYTE MA10-ST0 has a inverter, so add new quirk for it.
 1.244 24-Aug-2020  msaitoh Fix handling of IXGBE_REQUEST_TASK_NEED_ACKINTR again...
 1.243 24-Aug-2020  msaitoh The admin workqueue can be used even if the interface is not up.
OK'd by thorpej@. Will fixes PR#55534 reported by Shinichi Doyashiki
 1.242 24-Aug-2020  msaitoh Fix ixgbe_sfp_cage_full() on X550EM_A.

In ixgbe_handle_mod():

switch (hw->mac.type) {
case ixgbe_mac_82599EB:
cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
IXGBE_ESDP_SDP2;
break;
case ixgbe_mac_X550EM_x:
case ixgbe_mac_X550EM_a:
cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
IXGBE_ESDP_SDP0;
break;
default:
break;
}

so I had thought that IXGBE_ESDP_SDP0 bit is 1 on cage is full.
In reality, at least, X550EM_A's SFP+ cage is 0 on cage is full.
So invert the logic of ixgbe_sfp_cage_full() on X550EM_A
 1.241 24-Aug-2020  msaitoh Fix race in ixgbe_detach() to prevent panic on shutdown.
 1.240 24-Aug-2020  msaitoh Fix handling of IXGBE_REQUEST_TASK_NEED_ACKINTR in ixgbe_handle_admin().
 1.239 17-Aug-2020  msaitoh Simplify SFP+ check. No functional change.
 1.238 17-Aug-2020  msaitoh Re-enabling interrupt is required only when a work is scheduled form the
interrput context.
 1.237 17-Aug-2020  msaitoh Fix a bug that the driver sometimes missed module insertion.

The ixgbe_sfp_probe() function was only for 82598 and other chips had no
way to poll SFP+ cage. The ixgbe_handle_mod() already has function to treat
module insertion/removal for all chips, so enqueue the work if the cage
status changed. All of ixgbe chips' SFP+ module interrupt is only on the
inserstion. This change also detect the removal by the timer.
 1.236 17-Aug-2020  msaitoh Add missing workqueue_wait() for the recovery_mode_timer workqueue.
 1.235 13-Aug-2020  msaitoh Set recovery_mode_timer workqueue's name correctly.
 1.234 13-Aug-2020  msaitoh Use atomic_cas_uint() and atomic_store_relaxed(). Advised by thorpej@.
Tested by me. OK'd by knakahara.
 1.233 25-Jun-2020  msaitoh Reduce ixgbe's busy loop using with workqueue and kpause.

- Use workqueue instead of softint to make some functions sleepable.
- Use new workqueue and enqueue it in ixgbe_local_timer() and
ixgbe_recovery_mode_timer() to make them sleepable.
- Make new ixgbe_delay() and use it. This functions sleeps if the time is
more than equals 1 tick. If it's not, do delay().
 1.232 18-Jun-2020  msaitoh Modify a liitle to reduce diff between ixgbe.c and ixv.c. No functional change.
 1.231 17-Jun-2020  msaitoh Add missing callout_stop() for recovery_mode_timer.

NOTE: One of the difference between the local_timer and recovery_mode_timer
is that local_timer runs only when IFF_UP and recovery_mode_timer always runs
(it's enabled on attach).
 1.230 12-Jun-2020  msaitoh - Remove extra kpreempt_disable() -> kpreempt_enable() because
ixgbe_handle_msf() was changed from softint to workqueue.
- Set schedule_wqs_ok before enabling interrupt to prevent the race.
- Fix comment.
 1.229 11-Jun-2020  msaitoh Fix typo. No functional change.
 1.228 17-Apr-2020  msaitoh No functional change:
- modify comment
- whitespace fix
 1.227 15-Mar-2020  thorpej branches: 1.227.2;
Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.226 06-Feb-2020  thorpej Ensure we don't call workqueue_enqueue() if the pluggable optics
handler is already pending.
 1.225 05-Feb-2020  msaitoh No functional change:

- Add debug printf()s.
- Remove unused macros.
- Remove extra newline.
 1.224 05-Feb-2020  msaitoh Update comment in ixgbe_update_stats_counters() to clarify why we update
if_iqdrops and if_ierrors only. No functional change.
OK'd by knakahara and thorpej.
 1.223 04-Feb-2020  thorpej - Fix locking problem with optics module interrupts: ifmedia_add()
may block on memory allocation, and so it cannot be safely done from
a softint nor can it be done while holding a spin lock. Fix this by
using a workqueue rather than a softint, and hold the IFNET_LOCK
across the entire handler, and the CORE_LOCK only across the code that
needs to serialize access to the hardware state.
- Use ifmedia_fini().

Tested in a variety of devices by msaitoh@. (Thanks!)
 1.222 01-Feb-2020  thorpej Adopt <net/if_stats.h>.

XXX This driver needs some work in this regard (practually no
stats are reported).
 1.221 21-Jan-2020  msaitoh Fix the freeing code for some error paths. Found and tested by Patrick Welche.
 1.220 03-Jan-2020  pgoyette branches: 1.220.2;
Fix some typos in comments.

From vezhlys on freenode IRC.
 1.219 23-Dec-2019  msaitoh Add recovery code for unsupported SFP+.

Before this commit:
If an unsuppored SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.218 23-Dec-2019  msaitoh Add missing core lock in ixgbe_handle_mod().
 1.217 17-Dec-2019  msaitoh Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.
 1.216 18-Nov-2019  msaitoh Print MAC address.

XXX Should we move such type of printf() to ether_ifattach?
 1.215 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.214 16-Oct-2019  msaitoh Apply FreeBSD r353599:

> ixgbe: Disable EEE for backplane X550EM_X
>
> From Zach:
> Intel documentation indicates that backplane X550EM_X KR devices do not
> support Energy Efficient Ethernet. Prior to this patch, X552 devices
> (device ID 0x15AB) will crash the system when transitioning EEE state
> via sysctl.
>
> Signed-off-by: Zach Vargas <zvargas@xes-inc.com>
>
> PR: 240320
> Submitted by: Zach Vargas <zvargas@xes-inc.com>
> Reviewed by: erj@
> MFC after: 3 days
> Differential Revision: https://reviews.freebsd.org/D21673
 1.213 18-Sep-2019  msaitoh s/ixgbe_set_multi/ixgbe_set_rxfilter/. No functional change.
 1.212 18-Sep-2019  msaitoh Remove ixgbe_set_promisc() and use ixgbe_set_multi() to reduce code
duplication.
 1.211 18-Sep-2019  msaitoh Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
Changing "<" with "<=" fixes this problem, but it's better to check
ETHER_F_ALLMULTI than it because it's straightforward.
 1.210 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.209 05-Sep-2019  msaitoh Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and X550EM_A.
The register is for X550 and newer.
 1.208 04-Sep-2019  msaitoh Set IFM_1000_BX10 correctly.
 1.207 04-Sep-2019  msaitoh printf -> device_printf
 1.206 29-Aug-2019  knakahara Fix panic when ncpu == 1 && sysctl -w hw.ixg0.txrx_workqueue=1. Reported by nonaka@n.o.

ok by msaitoh@n.o and nonaka@n.o

pullup-8, pullup-9
 1.205 29-Aug-2019  knakahara fix typo in error handling of ixgbe_allocate_legacy().

ok by msaitoh@n.o

pullup-8, pullup-9
 1.204 28-Aug-2019  msaitoh An interrupt might not arrive when a module is inserted. When an link status
change interrupt occurred and the driver still regard SFP as unplugged, link
becomes up and the real media type is unknown. e.g:

% ifconfig -m ixg0
(snip)
media: Ethernet autoselect (autoselect rxpause,txpause)
status: active
supported Ethernet media:
media none
media autoselect
(snip)

To resolve this problem, when an link status change interrupt occurred and the
driver still regard SFP as unplugged, issue the module softint before issuing
LSC interrupt.
 1.203 28-Aug-2019  msaitoh X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
 1.202 21-Aug-2019  msaitoh Simplify ix{gbe,v}_[un]register_vlan() API suggestesd by knakahara.

The API was the same as FreeBSD's pre-iflib's. They use iflib now and it's
not required for us to keep the old API.
 1.201 21-Aug-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() suggested by knakahara.
 1.200 20-Aug-2019  msaitoh Fix a bug that VLAN HW "tagging" enable/disable may not refrect correctly.

- Always call ec_vlan_cb() if it exists.
- Some (or all?) ethernet drivers don't enable HW tagging if no any vlan is
attached. ixgbe is one of them. Check the the transition and update
VLAN HW tagging function.

XXX pullup-9
 1.199 30-Jul-2019  msaitoh branches: 1.199.2;
ixgbe_setup_low_power_mode() calls ixgbe_stop() in it. ixgbe_detach() first
called ixgbe_stop() and then called ixgbe_setup_low_power_mode() which resulted
in calling ixgbe_stop() twice. Call only ixgbe_setup_low_power_mode() first to
remove extra ixgbe_stop() call.
 1.198 26-Jul-2019  msaitoh Set IVAR (Interrupt Vector Allocation Register) correctly for 82598 in
ixgbe_set_ivar(). Found by KUBSan.
 1.197 26-Jul-2019  msaitoh Simplify code. No functional change intended.
 1.196 25-Jul-2019  msaitoh Fix VLAN hardware filter initialization. Use unsigned. Found by KUBSan.
 1.195 25-Jul-2019  msaitoh Fix VLAN filter setting. Found by KUBSan.
 1.194 24-Jul-2019  msaitoh Fix some problems found by KUBSan:
- Set TQSM and RQSM (TX/RX queue statistics mapping) correctly.
- Set IVAR (Interrupt Vector Allocation Register) correctly in
ixgbe_set_ivar().
- Define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART correctly. This macro is used
in ixgbe_restart_an_internal_phy_x550em().
- Define IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN correctly. This macro is used
in ixgbe_setup_ixfi_x550em_x().
- Define IXGBE_SB_IOSF_CTRL_BUSY correctly. This macro is used in
ixgbe_iosf_wait() (X550EM only).
 1.193 17-Jul-2019  msaitoh Implement VLAN hardware filter function(ETHERCAP_VLAN_HWFILTER).
First proposed by jmcneill in 2017 and modified by me.

How to use:

- Set callback function:

ether_set_vlan_cb(struct ethercom *, ether_vlancb_t)

- Callback. This function is called when a vlan is attached/detached to the
parent interface:

int (*ether_vlancb_t)(struct ethercom *ec, uint16_t vlanid, bool set);

- ifconfig(8)

ifconfig ixg0 [-]vlan-hwfilter

Note that ETHERCAP_VLAN_HWFILTER is set by default on ixg(4) because
the PF driver usually enable "all block" filter by default.
 1.192 04-Jul-2019  msaitoh On ENETRESET case, not continue and quit the ifflags_cb() function because
if_init() will do the same thing.
 1.191 02-Jul-2019  msaitoh Sync with FreeBSD ix-3.3.10 part 2:
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
 1.190 02-Jul-2019  msaitoh Sync with FreeBSD ix-3.3.10 part 1. No functional change in this part:
- "(u64)1" -> "1ULL"
- Add some not-yet-used register definitions.
 1.189 27-Jun-2019  msaitoh Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.188 04-Jun-2019  msaitoh Match the follwing devices:

82598_BX (0x1508)
82599_KR (0x1517)
82599_SFP_EM (0x1507)
X550EM_X_XFI (0x15b0)
X550EM_A_QSFP (0x15ca)
X550EM_A_QSFP_N(0x15cc)
 1.187 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.186 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.185 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.184 17-May-2019  msaitoh Use new media types.
 1.183 15-May-2019  ozaki-r Store IFF_ALLMULTI in ec_flags instead of if_flags to avoid data races

IFF_ALLMULTI is set/unset to if_flags via if_mcast_op. To avoid data races on
if_flags, IFNET_LOCK was added for if_mcast_op. Unfortunately it produces
a deadlock so we want to remove added IFNET_LOCK by avoiding the data races by
another approach.

This fix introduces ec_flags to struct ethercom and stores IFF_ALLMULTI to it.
ec_flags is protected by ETHER_LOCK and thus IFNET_LOCK is no longer necessary
for if_mcast_op. Note that the fix is applied only to MP-safe drivers that
the data races matter.

In the kernel, IFF_ALLMULTI is set by a driver and used by the driver itself.
So changing the storing place doesn't break anything. One exception is
ioctl(SIOCGIFFLAGS); we have to include IFF_ALLMULTI in a result if needed to
export the flag as well as before.

A upcoming commit will remove IFNET_LOCK.

PR kern/54189
 1.182 14-May-2019  ozaki-r Remove unnecessary checks of IFF_ALLMULTI

IFF_ALLMULTI is changed by only driver itself, so we don't need to check its
change on ec_ifflags_cb.

This is part of PR kern/54189. NFCI.
 1.181 13-May-2019  msaitoh Fix a bug that manual setting of 10GBASE-SR or 10GBASE-CX4 didn't work
if IFM_ETH_XTYPE was set. We don't use IFM_ETH_XTYPE macro, so this was not a
real bug.
 1.180 10-May-2019  msaitoh Fix typo. This code is not used yet.
 1.179 18-Mar-2019  msaitoh s/pakcet/packet/ in comment.
 1.178 15-Mar-2019  msaitoh - Simplily. Suggested by knakahara.
- Modify comment. Per queue VLAN enable flags is on 82599 and later.
- Fix typo in comment.
 1.177 13-Mar-2019  msaitoh - Fix a bug that the VLAN HW tagging function is not correctly disabled
when all vlan is detached.
- Fix a bug that VLAN HW tagging function is not correctly controlled on 82598.
- Control VLAN HW filter function correctly.
- Don't clear IXGBE_VLNCTRL_CFIEN bit When ETHERCAP_VLAN_HWFILTER is set.
I think it's not required (and Linux doesn't do it). This change has no
effect to NetBSD because ETHERCAP_VLAN_HWFILTER is not supported yet.
 1.176 05-Mar-2019  msaitoh It's not required to calculate unused queues' statistics.
 1.175 05-Mar-2019  msaitoh NetBSD currently uses traffic class 0 only. Other traffic classes aren't used
yet. When IXGBE_TC_COUNTER_NUM is set to lower than IXGBE_DCB_MAX_TRAFFIC_CLASS
(e.g. 1), other traffic classes' counters are not used. It means we don't
generate evcnt for them and don't add the values in
ixgbe_update_stats_counters().
 1.174 22-Feb-2019  msaitoh Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.173 23-Jan-2019  msaitoh - Move the location of calling setup_eee() in ixgbe_attach(). The previous
location was too early. The new location is before calling
ixgbe_set_phy_power().
- Restore call of setup_eee() in ixgbe_init_locked(). It was removed in
rev. 1.99 (FreeBSD r320688).
- When calling setup_eee(), pass enable/disable correctly.
 1.172 23-Jan-2019  msaitoh Call ixgbe_init_swfw_semaphore(hw) before calling ixgbe_check_wol_support()
because ixgbe_check_wol_support()->ixgbe_check_wol_support()->
ixgbe_get_device_caps() accesses semaphore.
 1.171 23-Jan-2019  msaitoh Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them expilicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.170 08-Dec-2018  msaitoh Don't call callout_halt() if it's not initialzied.
 1.169 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.168 03-Dec-2018  msaitoh Some counters are not per queue but per traffic class. Make new evcnt group
"ixgM tcN" (N = 0..7) and move those counters into it. We are using only
traffic class 0, so we will see only tc0's counter are updated.
 1.167 27-Sep-2018  msaitoh Don't set LRO capability flags because we don't support it yet.
This doesn't change any behavior other than if_capabilities' visibility
(e.g. ifconfig).
 1.166 14-Sep-2018  msaitoh - Fix a bug that Denverton accessed wrong register in
ixgbe_setup_low_power_mode(). The location of some registers in Denverton
were changed. The GRC register is one of them, so use IXGBE_GRC_BY_MAC(hw)
instead of IXGBE_GRC.
- ixgbe_check_wol_support() tests the capability of WOL, but the sysctl
knobs for WOL were added only for IXGBE_DEV_ID_X550EM_X_10G_T. Add the
knobs when adapter->wol_support is not 0.

XXX pullup-8
 1.165 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.164 29-Aug-2018  msaitoh Fix a bug that media change may fail. I noticed that ifconfig ixgN media XXX
took a 10 or more seconds on a Denverton machie. I occurred by trying take a
lock and timed out. The reason was that ixgbe_media_change() didn't take
CORE_LOCK. Do it.

This problem was from FreeBSD's pre-iflib ixgbe (I don't know whether this
problem really occurs on FreeBSD or not). Post-iflib ixgbe has no problem
because iflib_media_change() takes a lock.

XXX pullup-8
 1.163 06-Jul-2018  msaitoh Add force_10_100_autonego sysctl. The default vaule is 0(false).
This sysctl is only for 550EM_a with PHY firmware for a while.
 1.162 03-Jul-2018  msaitoh Remove nmbclusters check. We don't use the mbuf cluster. The old code also had
a bug that ixgbe_total_ports adds two every port and never decrement in
the detach path. Found by hikaru@.

The code was removed in FreeBSD when it switched to use iflib and OpenBSD
removed the code 8 years ago.
 1.161 06-Jun-2018  kamil branches: 1.161.2;
Comment out unused functions in order to fix Clang build

ixv_rearm_queues() and ixgbe_rearm_queues() are unused.

Sponsored by <The NetBSD Foundation>
 1.160 04-Jun-2018  msaitoh Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().

ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.

ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.
One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.159 03-Jun-2018  maxv Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
 1.158 30-May-2018  msaitoh Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
 1.157 30-May-2018  msaitoh Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.

This change itself doesn't fix PR#53294.
 1.156 25-May-2018  ozaki-r Ensure to call if_register after interface initializations finish
 1.155 23-May-2018  msaitoh Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
 1.154 23-May-2018  msaitoh Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
 1.153 18-May-2018  msaitoh Revert new watchdog timer commits. The new watchdog timer made stability
worse than before. It seems unknown problems exists.

http://mail-index.netbsd.org/source-changes/2018/05/08/msg095020.html
http://mail-index.netbsd.org/source-changes/2018/05/16/msg095240.html
 1.152 15-May-2018  msaitoh The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
 1.151 10-May-2018  msaitoh Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
 1.150 08-May-2018  msaitoh - Fix broken watchdog timer. This change detects TX device timeout correctly.
NOTE: It's supporsed not to be called {ixgbe,ixv}_rearm_queues() in the
timer. Those are not required if any chip have no bug. In reality,
ixgbe_rearm_queues() is required on 82599 and newer chip AND other than
queue 0 to prevent device timeout. When it occured, packet was sent but the
descriptor's DD bit wasn't set even though IXGBE_TXD_CMD_EOP and
IXGBE_TXD_CMD_RS were set. After forcing interrupt by writing EICS register
in ixgbe_rearm_queues(), DD is set. Why? Is this an undocumented errata? It
might be possible not call rearm_queues on 82598 or queue 0, we call in any
cases in case the problem occurs. On ixv(4), I have not seen this problem yet
(though I tested only on X550_X(Xeon D 12xx)'s virtual function), but we
do rearm in case TX device timeout happen.
- ixv(4): Call callout_stop() earlier in ixv_stop() like ixgbe_stop().
- KNF.
 1.149 19-Apr-2018  msaitoh Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
 1.148 17-Apr-2018  msaitoh Remove unused structure entries. No functional change.
 1.147 17-Apr-2018  knakahara Fix panic when "sysctl -w hw.ixg0.txrx_workqueue=[01]" while there is traffic.

The operation is not supported, however causing panic is problem.
 1.146 12-Apr-2018  msaitoh Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.145 04-Apr-2018  msaitoh Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.144 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.143 04-Apr-2018  msaitoh Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.142 02-Apr-2018  msaitoh Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.
 1.141 02-Apr-2018  knakahara Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time

ok by msaitoh@n.o.
 1.140 30-Mar-2018  msaitoh - Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.

Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))

Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.

- Change some functions static.
 1.139 30-Mar-2018  knakahara Don't write EIMC directly. It is required to manage with struct ix_queue status.

XXX pullup-8
 1.138 30-Mar-2018  knakahara Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.

XXX pullup-8
 1.137 26-Mar-2018  msaitoh - Add link related softint's counter.
- Fix indent.
 1.136 20-Mar-2018  knakahara Fix race about writing adapter->link_active for ixg(4).

adapter->link_active is updated by ixgbe_update_link_status() only.
The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.
 1.135 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.134 09-Mar-2018  msaitoh Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.133 08-Mar-2018  knakahara Reduce duplicated code which schedule deferred packet processing. No functional change.
 1.132 08-Mar-2018  knakahara Fix INTx/MSI handler did not schedule workqueue. Pointed out by msaitoh@n.o.
 1.131 07-Mar-2018  knakahara Fix another poll mode assumption breaking. Implemented by msaitoh@n.o, I just commit by proxy.

ixgbe_rearm_queues() writes EICS register(s). 82599, X540 and X550
specifications say "Following a write of 1b to any bit in the EICS register
(interrupt cause set), its corresponding bit in the EIMS register is auto
set as well enabling its interrupt." in "Extended Interrupt Auto Mask Enable
(EIAM) Register" section. That is, ixgbe_rearm_queues() causes interrupts
regardless of the status managed by ixgbe_enable_queue()/ixgbe_disable_queue().
That can break poll mode assumption.

In fact, the problem occurs in the following situation
- CPU#A has high load traffic, in contrast, CPU#B has not so high load traffic
- CPU#A is occurred interrupt by its NIC queue
- CPU#A calls ixgbe_disable_queue() in interrupt handler(ixgbe_msix_que())
- CPU#A kick softint handler(ixgbe_handle_que())
- CPU#A begins softint
- CPU#A's NIC queue is set que->txr->busy flag
- With some reason, CPU#A can do ixg interrupt handler
E.g. when one of CPU#A's softnet handlers sleeps, ipl is lowered
- CPU#B starts callout
- CPU#B calls ixgbe_local_timer1()
- CPU#B writes EICS bit corresponding CPU#A's NIC queue bit
- CPU#A's NIC queue causes interrupt whie CPU#A is running in poll mode
- CPU#A calls ixgbe_disable_queue() in interrupt handler *again*
- CPU#A has done polling, and then CPU#A calls ixgbe_enable_queue() *once*
- CPU#A's NIC queue interrupt is disabled until ixg is detached as
ixgbe_disable_queue() is called twice though ixgbe_disable_queue() is
called once only

NOTE:
82598 does not say so, but it is treated in the same way because of no harm.

By the way, we will refactor ixgbe_local_timer(watchdog processing) later.

XXX pullup-8
 1.130 07-Mar-2018  msaitoh Don't increment que->req.ev_count in MSI-X interrupt because it's not
reschedule.
 1.129 07-Mar-2018  msaitoh - Make "Handled queue in softint" and "Requeued in softint" evcnt(9) per queue
and count them correctly.
- Remove #if 0'ed code.
 1.128 02-Mar-2018  knakahara branches: 1.128.2;
ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.
 1.127 26-Feb-2018  knakahara Fix poll mode assumption breaking.

ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.

E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.

This fix may have 1% or 2% performance impact at short packets.

XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.

ok by msaitoh@n.o.
 1.126 22-Feb-2018  msaitoh Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.125 20-Feb-2018  knakahara Improve a comment about reading EICS register defined write-only by spec.

It seems that is workaround for silicon errata.

ok by msaitoh@n.o.
 1.124 20-Feb-2018  msaitoh - Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:

sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)

Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:

int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |

The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.

While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!

This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.

(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.

- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.

XXX pullup-8
 1.123 16-Feb-2018  msaitoh Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().

XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
 1.122 16-Feb-2018  knakahara Apply RSS utility to ixg(4) and ixv(4).

ok by msaitoh@n.o.
 1.121 14-Feb-2018  msaitoh Fix a bug that RX may stall on heavy load on ixg(4). ixgbe_rxeof() has loop
limit and the function returns true if a packet are still in the RX ring.
ixgbe_handle_que() didn't check the return value. Check the return vaule
and issue a softint.

This bug is derived from FreeBSD and ixv(4) has no this bug.

XXX pullup-8
 1.120 26-Jan-2018  msaitoh CID-1427719: Integer handling issues (BAD_SHIFT). Print bus/slot info
correctly on 82599_SFP_SF_QP(DID 0x154a) and 82599_QSFP_SF_QP(DID 0x1558).
 1.119 28-Dec-2017  msaitoh Fallback from MSI-X to MSI or INTx if MSI-X setup failed.
 1.118 21-Dec-2017  msaitoh - If MSI can't be used on some environment, fallback to INTx correctly.
- Use single vector MSI when number of CPU is 1 to save interrupt slot.
 1.117 21-Dec-2017  msaitoh Fix panic when only link interrupt can't be established.
 1.116 20-Dec-2017  msaitoh Don't panic when resource shortage occured. Fixes PR#52820 reported by
kardel@:
- Don't use if_free() because ixgbe(4) don't use if_alloc().
- Move location of {ixgbe,ixv}_setup_interface() call at a position that
any error don't occur. One of the reason is that it should be. Another
reason is that it's hard to call ether_ifdetach() and if_detach() when
cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
and maybe more).
 1.115 06-Dec-2017  msaitoh Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.114 24-Nov-2017  msaitoh On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
 1.113 22-Nov-2017  msaitoh Fix a bug that bypass adapter's sysctls aren't set. Tested with non-genuine
X550-T2 bypass adapter:
- Call ixgbe_sysctl_instance() in ixgbe_bypass_init() to get sysctl's top node
correctly.
- ixgbe_init_device_features() refers adapter->hw.bus.func for bypass adapter.
Call set_lan_id() to set adapter->hw.bus.func before calling
ixgbe_init_device_features(). Without this, bypass sysctl's are added to
both the first and second port.
- Initalize node.sysctl_data before calling sysctl_lookup() to read correct
value.
 1.112 16-Nov-2017  ozaki-r Unify IFEF_*_MPSAFE into IFEF_MPSAFE

There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.

Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).

Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.

Proposed on tech-kern@ and tech-net@
 1.111 12-Nov-2017  msaitoh Remove obsoleted comment. This comment should have been removed in rev. 1.97.
 1.110 09-Nov-2017  msaitoh On device which has SFP(+) cage and a module is inserted, hw->phy.id is not
MII PHY id but SFF 8024 ID. So checking hw->phy.id with 0 doesn't work.
Print PHY ID only for copper PHY.
 1.109 02-Nov-2017  msaitoh - Handle hw.ixgN.advertise_speed correctly.
- Fix hw.ixgN.advertise_speed sysctl's description.
 1.108 26-Oct-2017  msaitoh - Remove all half duplex setting.
- Remove special handling of IXGBE_DEV_ID_82598AT's 1000BaseT. The PHY is
compliant with clause 45, so the media is added in the beginning of
ixgbe_add_media_types().
 1.107 25-Oct-2017  msaitoh - For X550 and newer, print NVM Image Version with %u.%02x (e.g. "0.05").
- Fix value check of OEM_NVM_IMAGE_VER.
 1.106 23-Oct-2017  msaitoh If if_initialize() failed in the attach function, free resources and return.
 1.105 18-Oct-2017  msaitoh Protect ec_multi* with mutex like other MP safe Ethernet drivers.
See if_ether.h rev. 1.66 and related stuff:
http://mail-index.netbsd.org/source-changes/2016/12/28/msg080289.html
 1.104 13-Oct-2017  msaitoh Set baudrate correctly. A device which use mii(4) interface can set
if_baudrate atomatically by mii_phy_statusmsg(). ixg(4) and ixv(4) don't
use mii(4), so calling ifmedia_baudrate() directly is required.

XXX need the same same work for wm(4)'s TBI and SERDEV devices.
 1.103 04-Oct-2017  msaitoh - Remove half-duplex setting for more than 1000Mbps in ixgbe_add_media_types()
because those medias are not in the spec.
- Add 2.5GBASE-T and 5GBASE-T support. Tested with X550-T1.

Example:
ixg0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
capabilities=fff80<TSO4,IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx>
capabilities=fff80<TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx,TCP6CSUM_Rx>
capabilities=fff80<TCP6CSUM_Tx,UDP6CSUM_Rx,UDP6CSUM_Tx,TSO6,LRO>
enabled=7ff80<TSO4,IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx>
enabled=7ff80<TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx,TCP6CSUM_Rx>
enabled=7ff80<TCP6CSUM_Tx,UDP6CSUM_Rx,UDP6CSUM_Tx,TSO6>
ec_capabilities=7<VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU>
ec_enabled=7<VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU>
address: a0:36:9f:b0:f5:b0
media: Ethernet 2.5GBASE-T full-duplex
status: active
supported Ethernet media:
media 10Gbase-T
media 10Gbase-T mediaopt full-duplex
media 1000baseT
media 1000baseT mediaopt full-duplex
media 100baseTX
media 100baseTX mediaopt full-duplex
media 2.5GBASE-T mediaopt full-duplex
media 5GBASE-T mediaopt full-duplex
media autoselect
inet 172.16.0.1/24 broadcast 172.16.0.255 flags 0x0
inet6 fe80::a236:9fff:feb0:f5b0%ixg0/64 flags 0x0 scopeid 0x1
 1.102 04-Oct-2017  msaitoh Fix a bug that X550EM (Denverton) can't force 10BaseT.
 1.101 27-Sep-2017  msaitoh Print device name in ixv_attach().
 1.100 31-Aug-2017  msaitoh Fix 2500 KX media setting in last commit.
 1.99 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.98 30-Aug-2017  msaitoh FreeBSD r320688 sorted a lot of functions. Merging that change by one commit
makes difficult to know what was really changed. To make change understandable,
commit only function sort and white space changes before real change.
 1.97 30-Aug-2017  msaitoh Don't limit number of queue pair to 8. Take max TX queues and max RX queues
into account. 82598 has 32 TX queue and 64 RX queues. Others has 128 TX queues
and 128 RX queues. Number of MSI-X table entries is 64, so the max queue pairs
is 63 (64 minus the Others (e.g. link status change)).
 1.96 24-Aug-2017  msaitoh Remove unused counters.
 1.95 03-Jul-2017  msaitoh Print PHY ID.
 1.94 27-Jun-2017  msaitoh Fix a bug of ixg(4)'s media setting.

Before:
ifconfig ixg0 media 100baseTX -> advertise 100Mbps only
ifconfig ixg0 media 1000baseT -> advertise 1Gbps and 1000Mbps (NG)
ifconfig ixg0 media 10Gbase-T -> advertise all (NG)
ifconfig ixg0 media auto -> advertise all

After:
ifconfig ixg0 media 100baseTX -> advertise 100Mbps only
ifconfig ixg0 media 1000baseT -> advertise 1Gbps only
ifconfig ixg0 media 10Gbase-T -> advertise 10Gbps only
ifconfig ixg0 media auto -> advertise all
 1.93 27-Jun-2017  msaitoh Reduce diff against FreeBSD. change hw.ixgN.ts to hw.ixgN.thermal_test
(FreeBSD r282289).
 1.92 27-Jun-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.91 23-Jun-2017  msaitoh Print verbose outout in ixgbe_update_link_status() correctly on 5Gbps and
2.5Gbps (NBASE-T) for X550T[12] and newer.
 1.90 23-Jun-2017  msaitoh Use IFM_1000_KX more.
 1.89 12-Jun-2017  msaitoh Use IFM_1000_KX and IFM_2500_KX.
 1.88 02-Jun-2017  msaitoh branches: 1.88.2;
- Print NVM Image Version, PHY FW Revision, NVM Map version and OEM NVM
Image version
- s/TrackID/ETrackID/
 1.87 26-May-2017  msaitoh Add missing {ixgbe,ixv}_stop() in the detach function. Without this change,
shutdown won't finish or panic on heay traffic.
 1.86 26-May-2017  msaitoh Count Bad SFD (Start Frame Delimiter). X550 and newer have this register.
 1.85 26-May-2017  msaitoh Clear all event counters when SIOCZIFDATA(ifconfig -z) is called.
 1.84 22-May-2017  msaitoh Fix a bug that the driver prints "Link is up 1 Gbps" even if the link is
100Mbps. This change is the same as a part of ixv.c rev. 1.42.
 1.83 22-May-2017  msaitoh Document says M[LR]FC are valid when link is up and 10Gbps, so:
- Add those values when link is up and 10Gbps
- Discard those vaules when link becomes up and the speed is 10Gbps
 1.82 18-May-2017  msaitoh - Count "Total Packets Missed" by evcnt(9)
- Call evcnt_attach_dynamic()/detach() for stats->mngpdc
(Management Packets Dropped).
- Make stats->rnbc (Receive No Buffers) evcnt(9). Only 82598 has this register.
- Set RQSMR, TQSM (or TQSMR on 82598) to count qprc, qptc, qbrc, qbtc and qprdc
in each queue counter. Without this change, all queue's counts are counted in
queue 0's. Even if with this change, only MPC[0] is counted and other MPCs
are not counted.
 1.81 28-Apr-2017  msaitoh Fix a bug that reading hw.ixgM.qN.interrupt_rate cause the interrupt
throtting rate register to 0. Check sysctl read/write correctly...
 1.80 03-Mar-2017  msaitoh branches: 1.80.4;
Set PCI_INTR_MPSAFE, SOFTINT_MPSAFE, CALLOUT_MPSAFE and IFEF_START_MPSAFE
if NET_MPSAFE is defined.
 1.79 24-Feb-2017  msaitoh Print mac.type and the TrackID.
 1.78 16-Feb-2017  msaitoh Do if_snd check even if IXGBE_LEGACY_TX is used. It's used by ALTQ.
 1.77 16-Feb-2017  msaitoh txt_si softint is used only for multiqueue (ixgbe_mq_start_locked()), so don't
schedule it in ixgbe_legacy_irq().
 1.76 13-Feb-2017  msaitoh Remove more ix*_start_locked() from interrupt context like previous commit.
> Fix a bug that ix*_start_locked() is called in interrput context
> (ix*_msix_que). The function is called in softint(ix*_handle_que()). OK'd by
>k-nakahara.
 1.75 13-Feb-2017  msaitoh Use percpuq.
 1.74 13-Feb-2017  msaitoh Fix a bug that ix*_start_locked() is called in interrput context
(ix*_msix_que). The function is called in softint(ix*_handle_que()). OK'd by
k-nakahara.
 1.73 10-Feb-2017  msaitoh Change the Interrupt Moderation flag from global variable to per device.
 1.72 10-Feb-2017  msaitoh - Both mbuf_defrag_failed and m_defrag_failed existed. Remove m_defrag_failed.
- rx_irq, dropped_pkts, morerx, moretx and txloops counters are uncounted, so
remove them.
- Count handleq in ixv_handle_que().
- Detach event counters correctly.
- Set some per-queue event names correctly.
 1.71 08-Feb-2017  msaitoh Print CPU number correctly.
 1.70 08-Feb-2017  msaitoh Call IFQ_SET_MAXLEN() even if TX multiqueue is used. ALTQ uses it.
 1.69 08-Feb-2017  msaitoh Add queue number into interrupt name.
 1.68 08-Feb-2017  msaitoh Set ifm_active to IFM_NONE when the physical interface's link is down.
Now ifconfig shows "media: Ethernet autoselect '(none)'".
 1.67 01-Feb-2017  msaitoh TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h
 1.66 25-Jan-2017  msaitoh Call ixgbe_get_supported_physical_layer() before ixgbe_add_media_types() to
set new media types correctly.
 1.65 25-Jan-2017  msaitoh Remove debug printf()s.
 1.64 25-Jan-2017  msaitoh Fix SFP+ insersion or replacement stuff.
 1.63 19-Jan-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.62 18-Jan-2017  msaitoh Now we can use multiqueue. It's default on ixg(4). Not yet for ixv(4).
 1.61 18-Jan-2017  msaitoh Fix sysctl stuff. Make the top sysctl node and keep the pointer.
 1.60 18-Jan-2017  msaitoh Use 64bit DMA tag. If not, a lot of bounce buffer is allocated.
Fixes PR#49968 reported by Hauke.

XXX pullup-[67].
 1.59 05-Jan-2017  msaitoh branches: 1.59.2;
Fix INIT_DEBUGOUT() messages.
 1.58 28-Dec-2016  msaitoh Fix a bug that hw.ixgN.wol_enable=0 doesn't work correctly. Clear the WUC
and WUFC register if wol_enable is 0. ixgbe_setup_low_power_mode() calls
ixgbe_stop() and it resets the chip. The reset change WUC and WUFC registers to
the default, so clearing WUC and WUFC should be done after ixgbe_stop().
 1.57 28-Dec-2016  msaitoh Allow 0 as the defalut of hw.ixgN.advertise_speed sysctl.
 1.56 27-Dec-2016  msaitoh Fix flow control setting sysctl. I don't know why disabling autonego when
the flow control parameter is changed. Now the ixgN.fc sysctl works as
expected.
 1.55 16-Dec-2016  msaitoh Add missing IFM_FDX.
 1.54 16-Dec-2016  msaitoh Remove extra newline in debug printfs. ixgbe's *DEBUGOUT* macros automatically
add newline.
 1.53 05-Dec-2016  msaitoh - Fix wol_enable, fc and wufc sysctls to work correctly.
- Fix RCS Id.
 1.52 05-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.51 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r294578:
- Fixup SFP module insertion on the 82599 when insertion happens after
the system is booted and running. Add PHY detection logic to
ixgbe_handle_mod() and add locking to ixgbe_handle_msf() as well.
FreeBSD r293334.
- Fix ix advertise value after media change. When ifconfig sets media then the
values displayed by the advertise_speed value are invalidated.
Fix this by setting the bits correctly including setting advertise to 0 for
media = auto. FreeBSD r294578.
- Some others (e.g. LRO(not used by NetBSD)).
 1.50 02-Dec-2016  msaitoh Fix ix{gbe,v}_set_sysctlvalue().
 1.49 02-Dec-2016  msaitoh - Add missing pmf_device_deregister() in ixgbe_detach()
- Remove extra newline from an sysctl description.
- Fix dmesg output when the number of PCIe lane can't get.
 1.48 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.47 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r289238:
- Add support for sysctl knobs to live tune the per interrupt rx/tx packet
processing limits in ixgbe(4)
- Some others (netmap, etc.)
 1.46 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r285590:
- Fix igxbe SRIOV VF (if_ixv) initialization bugs. The MAC address for
an if_ixv instance can now set at creation time, and the receive ring
tail pointer is correctly initialized (previously, things still worked
because the receive ring tail pointer was being fixed up as a side
effect of other activity).
 1.45 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r283881:
- SRIOV support (not enabled because NetBSD doesn't support it).
 1.44 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.43 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.42 28-Nov-2016  msaitoh FreeBSD r280182 made new file ix_txrx.c and moved ixgbe.c and ixv's common
code into it. Before sync with whole of them, just move ixgbe.c and ixv.c's
common code into ix_txrx.c from ixgbe.c. In this commit, only ixgbe.c is split
into the device dependent part and the common part. ixv.c isn't change to make
this commit no functional change. To use ixv.c with ix_txrx.c, it's required
to modify the common part's API and functions themselves.

This commit is done to make the next change easy to understand.
 1.41 25-Nov-2016  msaitoh Remove #ifdef NETBSD_MSI_OR_MSIX to be simple. ixv(4) isn't attached if
__HAVE_PCI_MSI_MSIX isn't set because MSI-X must be used.
 1.40 13-Oct-2016  jdolecek provide intr xname
 1.39 11-Jul-2016  knakahara branches: 1.39.2;
pci_intr_type() is required pci_chipset_tag_t argument by other than x86.

pointed out by nonaka@n.o.
 1.38 10-Jun-2016  ozaki-r Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.37 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.36 17-Aug-2015  knakahara Add kernel code to support intrctl(8).
 1.35 13-Aug-2015  msaitoh Reduce diff against FreeBSD r280181.
 1.34 13-Aug-2015  msaitoh - Add MSI/MSI-X support. The multiqueue function is not supported yet.
- Make ixv.c compilable. _NOT_TESTED_YET_
 1.33 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.32 05-Aug-2015  msaitoh Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent panic.
 1.31 03-Aug-2015  msaitoh Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
 1.30 09-May-2015  christos remove unreachable code.
 1.29 06-May-2015  msaitoh Fixes link error without vlan. PR#49879.
 1.28 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.27 14-Apr-2015  msaitoh Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
 1.26 14-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r243716:
- A lot of bugfixes. Some of them are realted to multi queue and those
have not affected in NetBSD because we have not used it yet.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Improve performance.
 1.25 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.24 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.23 25-Mar-2015  msaitoh Fix a bug that vlan setting may not apply to the parent interface correctly.
 1.22 19-Mar-2015  msaitoh Sync ixg(4) up to FreeBSD r230572.

- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
 1.21 24-Feb-2015  msaitoh Add 82599EN_SFP and 82599_SFP_SF_QP. Not tested.
 1.20 24-Feb-2015  msaitoh Change macro name IXGBE_DEV_ID_82599_SFP_DELL to IXGBE_DEV_ID_82599_SFP_SF2.
Same as OpenBSD and Linux. No binary change.
 1.19 07-Feb-2015  christos disable preemption while scheduling the softint to configure the link.
 1.18 04-Feb-2015  msaitoh Fix mutex related problem reported by Uwe Toenjes in PR#49328:
- Revert ixgbe_netbsd.c rev. 1.2
- make CORE_LOCK adaptive
- Release spin lock while reinitializing the jumb buffer structure.
 1.17 04-Feb-2015  msaitoh Remove extra IXGBE_TX_LOCK()/IXGBE_TX_UNLOCK() from
ixgbe_free_transmit_structures(). This function is called in the end of
the detach function. if_stop was called and almost all resources were
freed, so it's not required to block the TX stuff.
 1.16 04-Feb-2015  msaitoh Add missing IXGBE_RX_LOCK_DESTROY() for the detach path.
 1.15 13-Jan-2015  msaitoh Fix a legacy interrupt problem. If the INTx line was shared with another
device, the ixgbe_legacy_irq() enabled the interrupt even if the interface
was down. Check the interface state and call functions appropriately.
 1.14 21-Apr-2014  chs branches: 1.14.2; 1.14.4;
only attach/detach stats->mngptc once.
remove a low-value printf().
 1.13 17-Apr-2014  christos CID/1008347, CID/1008348, CID/1008349: overflow before widen
CID/1203198, CID/1203199: Uninitialized scalar variable
 1.12 15-Apr-2014  hannken Add __diagused.
 1.11 11-Apr-2014  joerg Mark ixgbe_disable_queue as unused.
 1.10 08-Apr-2014  christos Add dell's flavor (from uwe, in current-users@)
 1.9 30-Mar-2014  skrll branches: 1.9.2;
Make this compile

- Fix pci_intr_string usage
- Remove ununsed
- define variables with their usage

kern/48690: ixg* driver doesn't compile

Untested.
 1.8 29-Mar-2014  christos make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.7 25-Feb-2014  pooka Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.6 09-Feb-2014  njoly Remove a few noisy debug printf.
 1.5 18-Jun-2012  dsl branches: 1.5.2; 1.5.4;
Missed one of the (void *) casts on the args to sysctl_createv().
 1.4 16-Jun-2012  dsl Add explicit (void *) casts for when sysctl_createv() is passed
CTLTYPE_INT but the address of a structure (and a function).
 1.3 02-Jun-2012  dsl Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.2 19-Nov-2011  tls branches: 1.2.4;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.1 12-Aug-2011  dyoung branches: 1.1.2;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.2 30-Oct-2012  yamt sync with head
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.2.4.1 25-Mar-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #1439):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.60 via patch
Use 64bit DMA tag. If not, a lot of bounce buffer is allocated.
Fixes PR#49968 reported by Hauke.
 1.5.4.1 18-May-2014  rmind sync with head
 1.5.2.2 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 10-Aug-2014  tls Rebase.
 1.14.4.9 28-Aug-2017  skrll Sync with HEAD
 1.14.4.8 05-Feb-2017  skrll Sync with HEAD
 1.14.4.7 05-Dec-2016  skrll Sync with HEAD
 1.14.4.6 05-Oct-2016  skrll Sync with HEAD
 1.14.4.5 09-Jul-2016  skrll Sync with HEAD
 1.14.4.4 19-Mar-2016  skrll Sync with HEAD
 1.14.4.3 22-Sep-2015  skrll Sync with HEAD
 1.14.4.2 06-Jun-2015  skrll Sync with HEAD
 1.14.4.1 06-Apr-2015  skrll Sync with HEAD
 1.14.2.7 09-Mar-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #1370):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.60
Use 64bit DMA tag. If not, a lot of bounce buffer is allocated.
Fixes PR#49968 reported by Hauke.
 1.14.2.6 14-Jun-2016  snj branches: 1.14.2.6.2;
Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.14.2.5 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.14.2.4 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.14.2.3 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.14.2.2 24-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #545):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.19
Add missing IXGBE_RX_LOCK_DESTROY() for the detach path.
Remove extra IXGBE_TX_LOCK()/IXGBE_TX_UNLOCK() from
ixgbe_free_transmit_structures(). This function is called in the end of
the detach function. if_stop was called and almost all resources were
freed, so it's not required to block the TX stuff.
Fix mutex related problem reported by Uwe Toenjes in PR#49328:
- Revert ixgbe_netbsd.c rev. 1.2
- make CORE_LOCK adaptive
- Release spin lock while reinitializing the jumb buffer structure.
disable preemption while scheduling the softint to configure the link.
 1.14.2.1 17-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #527):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.15
Fix a legacy interrupt problem. If the INTx line was shared with another
device, the ixgbe_legacy_irq() enabled the interrupt even if the interface
was down. Check the interface state and call functions appropriately.
 1.14.2.6.2.1 13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.39.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.39.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.39.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.59.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.80.4.2 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.80.4.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.88.2.59 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1933:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.88.2.58 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.88.2.57 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.88.2.56 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.88.2.55 21-Jun-2023  martin Pullup the following revisions, requested by msaitoh in ticket #1828:

sys/dev/pci/ixgbe/ixgbe.c 1.325-1.326 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.44
sys/dev/pci/ixgbe/ixgbe_type.h 1.56

- PCI device ID 0x15c8 also uses X557-AT PHY, so create the thermal
sensor sysctl for it, too.
- Count the number of link down events in the MAC using with
LINK_DN_CNT register.
 1.88.2.54 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.88.2.53 06-Jun-2022  martin Apply patch, requested by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ixgbe.c (apply patch)

Fix the location of "break" statement. No functional change intended.
 1.88.2.52 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.88.2.51 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98
sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.88.2.50 30-May-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1744:

sys/dev/pci/ixgbe/ixgbe.c 1.270,1.280,1.307-1.311,
1.313-1.314 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.96-1.97
sys/dev/pci/ixgbe/ixv.c 1.179-1.180 via patch


- ixg(4): Print Printed Board Assembly (PBA) number.
- ixg(4): Add IFF_RUNNING check in ixgbe_legacy_irq() again. this might
fix small race but it's not so dangerous.
- Add value check for {tx,rx}_process_limit sysctl to avoid setting
wrong value.
- Add missing num_tx_desc sysctl.
- No functional change:
- KNF a bit.
- Simplify setting of EIAC register.
- Move the definition of eicr_mask variable.
- Enclose flow director stuff in ixgbe_intr_admin_common() with
IXGBE_FIR which is not defined in NetBSD.
- Modify comment for consistency.
- Use cached rx_copy_len in ixgbe_rxeof().
 1.88.2.49 01-Feb-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1734:

sys/dev/pci/ixgbe/ixgbe.c 1.264,1.269,1.272,
1.306 via patch

Four INTx related fixes:
- Fix a bug that the all interrupt sources are enabled when the
interface is UP and the INTx line is shared with other devices.
- Fix a bug that it might incorrectly enable interrupt when
IFF_RUNNING is not set.
- Don't process TX/RX if a queue interrupt isn't occurred.
- Increment legacy interrupt counter after checking INTx sharing.
 1.88.2.48 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.88.2.47 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.88.2.46 29-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1724:

sys/dev/pci/ixgbe/ixgbe.c 1.298, 1.303 via patch

Add some missing error counters to ierror.
 1.88.2.45 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1708:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.88.2.44 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.88.2.43 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.88.2.42 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.88.2.41 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1600):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

-

Minor change.
- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.88.2.40 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.88.2.39 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.88.2.38 26-Dec-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1478):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.218

Add missing core lock in ixgbe_handle_mod().
 1.88.2.37 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1451):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.216
sys/dev/pci/ixgbe/ixv.c: revision 1.141

Print MAC address.

XXX Should we move such type of printf() to ether_ifattach?
 1.88.2.36 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1408):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.214

Apply FreeBSD r353599:
> ixgbe: Disable EEE for backplane X550EM_X
>
> From Zach:
> Intel documentation indicates that backplane X550EM_X KR devices do not
> support Energy Efficient Ethernet. Prior to this patch, X552 devices
> (device ID 0x15AB) will crash the system when transitioning EEE state
> via sysctl.
>
> Signed-off-by: Zach Vargas <zvargas@xes-inc.com>
>
> PR: 240320
> Submitted by: Zach Vargas <zvargas@xes-inc.com>
> Reviewed by: erj@
> MFC after: 3 days
> Differential Revision: https://reviews.freebsd.org/D21673
 1.88.2.35 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1389:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213 via patch
sys/dev/pci/ixgbe/ixv.c 1.131-1.138 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58 via patch
share/man/man4/ixv.4 1.5 via patch

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
 1.88.2.34 06-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367:

fix mistake in previous.
 1.88.2.33 05-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367, to pull up the following
revisions:

sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixgbe.c 1.180,1.203-1.204,
1.207-1.208 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.55
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.10
sys/dev/pci/ixgbe/ixgbe_common.c 1.25
sys/dev/pci/ixgbe/ixv.c 1.129-1.130

- X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
- An interrupt might not arrive when a module is inserted. When an link
status change interrupt occurred and the driver still regard SFP as
unplugged, issue the module softint before issuing LSC softint.
- Add 10000BASE-LX media if it's 1000BASE-BX.
- printf -> device_printf
- Avoid undefined behavior of VLAN filter setting.
- Simplify code.
- Fix typo in unused code.
- Fix typo in comment. Found by Wataru Ashihara.
 1.88.2.32 29-Aug-2019  martin Pull up following revision(s) (requested by knakahara in ticket #1347):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.205
sys/dev/pci/ixgbe/ixgbe.c: revision 1.206

fix typo in error handling of ixgbe_allocate_legacy().
ok by msaitoh@n.o
pullup-8, pullup-9

-

Fix panic when ncpu == 1 && sysctl -w hw.ixg0.txrx_workqueue=1. Reported by nonaka@n.o.

ok by msaitoh@n.o and nonaka@n.o
pullup-8, pullup-9
 1.88.2.31 01-Aug-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1313:

sys/dev/pci/ixgbe/ixgbe_type.h 1.41
sys/dev/pci/ixgbe/ixgbe.c 1.194,1.197-1.199
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.24
sys/dev/pci/ixgbe/ixv.c 1.121,1.124-1.125

- Avoid undefined behavior of interrupt vector setting.
- Avoid undefined behavior of TX/RX queue statistics calculation.
- Avoid undefined behavior of X550EM's PHY accesses.
- Avoid undefined behavior of Flow Control Transmit Timer setting.
- Don't call {ixgbe,ixv}_stop() twice while detaching.
 1.88.2.30 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.88.2.29 01-Apr-2019  martin Pull up the following, requested by msaitohin ticket #1225:

sys/dev/pci/ixgbe/ixgbe.c 1.175-1.178
sys/dev/pci/ixgbe/ixv.c 1.110-1.111 via patch

- NetBSD currently uses traffic class 0 only. Other traffic classes
aren't used yet. When IXGBE_TC_COUNTER_NUM is set to lower than
IXGBE_DCB_MAX_TRAFFIC_CLASS (e.g. 1), other traffic classes' counters
are not used. It means we don't generate evcnt for them and don't
add the values in ixgbe_update_stats_counters().
- It's not required to calculate unused queues' statistics.
- Fix a bug that the VLAN HW tagging function is not correctly disabled
when all vlan is detached.
- Fix a bug that VLAN HW tagging function is not correctly controlled
on 82598.
- Control VLAN HW filter function correctly. Note that currently
VLAN HW filter function doesn't work because NetBSD doesn't support
it yet.
- Don't clear IXGBE_VLNCTRL_CFIEN bit When ETHERCAP_VLAN_HWFILTER is
set. I think it's not required (and Linux doesn't do it). This change
has no effect to NetBSD because ETHERCAP_VLAN_HWFILTER is not
supported yet.
 1.88.2.28 01-Mar-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1199):

sys/dev/pci/ixgbe/ixv.c: revision 1.109
sys/dev/pci/ixgbe/ixgbe.h: revision 1.54
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.174

Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.88.2.27 28-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1171):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.168
sys/dev/pci/ixgbe/ixgbe.h: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.172
sys/dev/pci/ixgbe/ixgbe.c: revision 1.173

Some counters are not per queue but per traffic class. Make new evcnt group
"ixgM tcN" (N = 0..7) and move those counters into it. We are using only
traffic class 0, so we will see only tc0's counter are updated.

-

Call ixgbe_init_swfw_semaphore(hw) before calling ixgbe_check_wol_support()
because ixgbe_check_wol_support()->ixgbe_check_wol_support()->
ixgbe_get_device_caps() accesses semaphore.

-

- Move the location of calling setup_eee() in ixgbe_attach(). The previous
location was too early. The new location is before calling
ixgbe_set_phy_power().
- Restore call of setup_eee() in ixgbe_init_locked(). It was removed in
rev. 1.99 (FreeBSD r320688).
- When calling setup_eee(), pass enable/disable correctly.
 1.88.2.26 27-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1172):

sys/dev/pci/nvme_pci.c: revision 1.26
sys/dev/pci/xhci_pci.c: revision 1.21
sys/dev/pci/ixgbe/ixv.c: revision 1.108
sys/dev/pci/ixgbe/ixgbe.c: revision 1.171
sys/dev/pci/if_fxp_pci.c: revision 1.84
sys/dev/pci/if_fxp_pci.c: revision 1.85
sys/dev/pci/xhci_pci.c: revision 1.16

remove #ifdef DEBUG printf, it seems to have outlived it's usefulness

-

KNF. No functional change.

-

Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them explicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.88.2.25 08-Nov-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1084):

sys/dev/pci/ixgbe/ixv.c: revision 1.107
sys/dev/pci/ixgbe/ixgbe.c: revision 1.167

Don't set LRO capability flag because we don't support it yet.

This doesn't change any behavior other than if_capabilities' visibility
(e.g. ifconfig).
 1.88.2.24 23-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1029):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.166

- Fix a bug that Denverton accessed wrong register in
ixgbe_setup_low_power_mode(). The location of some registers in Denverton
were changed. The GRC register is one of them, so use IXGBE_GRC_BY_MAC(hw)
instead of IXGBE_GRC.

- ixgbe_check_wol_support() tests the capability of WOL, but the sysctl
knobs for WOL were added only for IXGBE_DEV_ID_X550EM_X_10G_T. Add the
knobs when adapter->wol_support is not 0.

XXX pullup-8
 1.88.2.23 05-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1006):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.164

Fix a bug that media change may fail. I noticed that ifconfig ixgN media XXX
took a 10 or more seconds on a Denverton machie. I occurred by trying take a
lock and timed out. The reason was that ixgbe_media_change() didn't take
CORE_LOCK. Do it.

This problem was from FreeBSD's pre-iflib ixgbe (I don't know whether this
problem really occurs on FreeBSD or not). Post-iflib ixgbe has no problem
because iflib_media_change() takes a lock.
XXX pullup-8
 1.88.2.22 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.88.2.21 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #935):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.162
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.35
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.16
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
--
Remove nmbclusters check. We don't use the mbuf cluster. The old code also had
a bug that ixgbe_total_ports adds two every port and never decrement in
the detach path. Found by hikaru@.
The code was removed in FreeBSD when it switched to use iflib and OpenBSD
removed the code 8 years ago.
 1.88.2.20 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.88.2.19 07-Jun-2018  martin Pull up following revision(s) (requested by ozaki-r in ticket #843):

sys/dev/pci/ixgbe/ixv.c: revision 1.101
sys/net/if_bridge.c: revision 1.156
sys/net/if_pppoe.c: revision 1.138
sys/dev/pci/if_wm.c: revision 1.580
sys/dev/pci/ixgbe/ixgbe.c: revision 1.156
sys/net/if_gif.c: revision 1.142

Ensure to call if_register after interface initializations finish
 1.88.2.18 17-Apr-2018  martin Pull up following revision(s) (requested by knakahara in ticket #769):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.147
sys/dev/pci/ixgbe/ixgbe.h: revision 1.42

Fix panic when "sysctl -w hw.ixg0.txrx_workqueue=[01]" while there is traffic.
The operation is not supported, however causing panic is problem.
 1.88.2.17 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.88.2.16 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.88.2.15 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.88.2.14 13-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #626):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.134
sys/dev/pci/ixgbe/ixgbe.h: revision 1.35
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.35
sys/dev/pci/ixgbe/ixv.c: revision 1.87
Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.88.2.13 08-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #612):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.129-1.133
sys/dev/pci/ixgbe/ixgbe.h: revision 1.34
sys/dev/pci/ixgbe/ixv.c: revision 1.85,1.86

- Make "Handled queue in softint" and "Requeued in softint" evcnt(9) per queue
and count them correctly.
- Remove #if 0'ed code.

Don't increment que->req.ev_count in MSI-X interrupt because it's not
reschedule.

Fix another poll mode assumption breaking. Implemented by msaitoh@n.o, I just commit by proxy.
ixgbe_rearm_queues() writes EICS register(s). 82599, X540 and X550
specifications say "Following a write of 1b to any bit in the EICS register
(interrupt cause set), its corresponding bit in the EIMS register is auto
set as well enabling its interrupt." in "Extended Interrupt Auto Mask Enable
(EIAM) Register" section. That is, ixgbe_rearm_queues() causes interrupts
regardless of the status managed by ixgbe_enable_queue()/ixgbe_disable_queue().

That can break poll mode assumption.

In fact, the problem occurs in the following situation
- CPU#A has high load traffic, in contrast, CPU#B has not so high load traffic
- CPU#A is occurred interrupt by its NIC queue
- CPU#A calls ixgbe_disable_queue() in interrupt handler(ixgbe_msix_que())
- CPU#A kick softint handler(ixgbe_handle_que())
- CPU#A begins softint
- CPU#A's NIC queue is set que->txr->busy flag
- With some reason, CPU#A can do ixg interrupt handler
E.g. when one of CPU#A's softnet handlers sleeps, ipl is lowered
- CPU#B starts callout
- CPU#B calls ixgbe_local_timer1()
- CPU#B writes EICS bit corresponding CPU#A's NIC queue bit
- CPU#A's NIC queue causes interrupt whie CPU#A is running in poll mode
- CPU#A calls ixgbe_disable_queue() in interrupt handler *again*
- CPU#A has done polling, and then CPU#A calls ixgbe_enable_queue() *once*
- CPU#A's NIC queue interrupt is disabled until ixg is detached as
ixgbe_disable_queue() is called twice though ixgbe_disable_queue() is
called once only
NOTE:
82598 does not say so, but it is treated in the same way because of no harm.
By the way, we will refactor ixgbe_local_timer(watchdog processing) later.

Fix INTx/MSI handler did not schedule workqueue. Pointed out by msaitoh@n.o.

Reduce duplicated code which schedule deferred packet processing. No functional change.
 1.88.2.12 06-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #605):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe.h: revision 1.33
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.34
sys/dev/pci/ixgbe/ixgbe.c: revision 1.128
sys/dev/pci/ixgbe/ixv.c: revision 1.83
sys/dev/pci/ixgbe/ixv.c: revision 1.84

Add hw.ixvM.q[01].{interrupt_rate,[tr]xd_head,[tr]xd_tail} sysctls as ixg(4).

ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.

ixv(4) also supports workqueue poll mode, but not enabled by default yet, either.
ok by msaitoh@n.o.

Move the location of "struct work" as FreeBSD's "struct task" in ixgbe.h.
No functional change.
 1.88.2.11 01-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #597):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.c: revision 1.127
sys/dev/pci/ixgbe/ixv.c: revision 1.82
Fix poll mode assumption breaking.
ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.
E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.
This fix may have 1% or 2% performance impact at short packets.
XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.
ok by msaitoh@n.o.
Apply ixgbe.c:r1.127 to ixv.c. Pointed out by msaitoh@n.o.
 1.88.2.10 26-Feb-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #592):
sys/dev/pci/ixgbe/ixv.c: revision 1.79
sys/dev/pci/ixgbe/ixgbe.h: revision 1.30
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.31
sys/dev/pci/ixgbe/ixgbe.c: revision 1.120
sys/dev/pci/ixgbe/ixgbe.c: revision 1.121
sys/dev/pci/ixgbe/ixgbe.c: revision 1.123
sys/dev/pci/ixgbe/ixgbe.c: revision 1.124
sys/dev/pci/ixgbe/ixgbe.c: revision 1.125
sys/dev/pci/ixgbe/ixgbe.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.80
sys/dev/pci/ixgbe/ixv.c: revision 1.81
CID-1427719: Integer handling issues (BAD_SHIFT). Print bus/slot info
correctly on 82599_SFP_SF_QP(DID 0x154a) and 82599_QSFP_SF_QP(DID 0x1558).
Fix a bug that RX may stall on heavy load on ixg(4). ixgbe_rxeof() has loop
limit and the function returns true if a packet are still in the RX ring.
ixgbe_handle_que() didn't check the return value. Check the return vaule
and issue a softint.
This bug is derived from FreeBSD and ixv(4) has no this bug.
XXX pullup-8
Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().
XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
- Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:
sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)
Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:
int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |
The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.
While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!
This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.
(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.
- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.
XXX pullup-8
Increment rxr->packets correctly in ixgbe_rxeof() to calculate ITR value
of AIM (Auto Interrupt Moderation) correctly. See also ixgbe.c rev. 1.124.
XXX pullup-8
Improve a comment about reading EICS register defined write-only by spec.
It seems that is workaround for silicon errata.
ok by msaitoh@n.o.
- Apply ixgbe.c rev. 1.124 to ixv.c. Fix a bug that RX may stall on heavy load
on ixv(4) derived from FreeBSD's AIM (Auto Interrupt Moderation) bug.
ITR_INTERVAL value must be larger than 4us.
- The bitfield of EITR register is different between 82598 and others.
ixv.c had a bug that it accessed 82598's way even though only 82599 and
newer support virtual function. Fix it using with new ixv_eitr_write()
function.
Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.88.2.9 26-Feb-2018  snj Pull up following revision(s) (requested by knakahara in ticket #567):
distrib/sets/lists/comp/mi: 1.2182-1.2183
sys/dev/pci/if_wm.c: 1.564
sys/dev/pci/ixgbe/ixgbe.c: 1.122
sys/dev/pci/ixgbe/ixgbe_rss.h: 1.3
sys/dev/pci/ixgbe/ixv.c: 1.78
sys/net/Makefile: 1.35-1.36
sys/net/files.net: 1.15
sys/net/rss_config.c: 1.1
sys/net/rss_config.h: 1.1
Introduce very simple Receive Side Scaling (RSS) utility.
ok by msaitoh@n.o.
--
Apply RSS utility to wm(4).
ok by msaitoh@n.o.
--
Apply RSS utility to ixg(4) and ixv(4).
ok by msaitoh@n.o.
--
Fix build failure, sorry.
--
Currently, it is not necessary to install rss_config.h. Pointed out by msaitoh@n.o.
 1.88.2.8 13-Jan-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #490):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.116-1.119
sys/dev/pci/ixgbe/ixv.c: revision 1.76-1.77
Don't panic when resource shortage occured. Fixes PR#52820 reported by
kardel@:
- Don't use if_free() because ixgbe(4) don't use if_alloc().
- Move location of {ixgbe,ixv}_setup_interface() call at a position that
any error don't occur. One of the reason is that it should be. Another
reason is that it's hard to call ether_ifdetach() and if_detach() when
cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
and maybe more).
--
Don't panic when resource shortage occured. Like ixgbe.c rev. 1.116.
- Move location of {ixgbe,ixv}_setup_interface() call at a position that
any error don't occur. One of the reason is that it should be. Another
reason is that it's hard to call ether_ifdetach() and if_detach() when
cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
and maybe more).
--
Fix panic when only link interrupt can't be established.
--
- If MSI can't be used on some environment, fallback to INTx correctly.
- Use single vector MSI when number of CPU is 1 to save interrupt slot.
--
Fallback from MSI-X to MSI or INTx if MSI-X setup failed.
 1.88.2.7 02-Jan-2018  snj Pull up following revision(s) (requested by ozaki-r in ticket #456):
sys/arch/arm/sunxi/sunxi_emac.c: 1.9
sys/dev/ic/dwc_gmac.c: 1.43-1.44
sys/dev/pci/if_iwm.c: 1.75
sys/dev/pci/if_wm.c: 1.543
sys/dev/pci/ixgbe/ixgbe.c: 1.112
sys/dev/pci/ixgbe/ixv.c: 1.74
sys/kern/sys_socket.c: 1.75
sys/net/agr/if_agr.c: 1.43
sys/net/bpf.c: 1.219
sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
sys/net/if_etherip.c: 1.40
sys/net/if_ethersubr.c: 1.243, 1.246
sys/net/if_faith.c: 1.57
sys/net/if_gif.c: 1.132
sys/net/if_l2tp.c: 1.15, 1.17
sys/net/if_loop.c: 1.98-1.101
sys/net/if_media.c: 1.35
sys/net/if_pppoe.c: 1.131-1.132
sys/net/if_spppsubr.c: 1.176-1.177
sys/net/if_tun.c: 1.142
sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
sys/net/npf/npf_ifaddr.c: 1.3
sys/net/npf/npf_os.c: 1.8-1.9
sys/net/rtsock.c: 1.230
sys/netcan/if_canloop.c: 1.3-1.5
sys/netinet/if_arp.c: 1.255
sys/netinet/igmp.c: 1.65
sys/netinet/in.c: 1.210-1.211
sys/netinet/in_pcb.c: 1.180
sys/netinet/ip_carp.c: 1.92, 1.94
sys/netinet/ip_flow.c: 1.81
sys/netinet/ip_input.c: 1.362
sys/netinet/ip_mroute.c: 1.147
sys/netinet/ip_output.c: 1.283, 1.285, 1.287
sys/netinet6/frag6.c: 1.61
sys/netinet6/in6.c: 1.251, 1.255
sys/netinet6/in6_pcb.c: 1.162
sys/netinet6/ip6_flow.c: 1.35
sys/netinet6/ip6_input.c: 1.183
sys/netinet6/ip6_output.c: 1.196
sys/netinet6/mld6.c: 1.90
sys/netinet6/nd6.c: 1.239-1.240
sys/netinet6/nd6_nbr.c: 1.139
sys/netinet6/nd6_rtr.c: 1.136
sys/netipsec/ipsec_output.c: 1.65
sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
 1.88.2.6 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.88.2.5 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.88.2.4 21-Nov-2017  martin Revert the pullup of the following revision(s) (requested by msaitoh in ticket #361):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.97
Revert a part of ticket #248 because it panics when attaching.
It is hard to fix with a small change.
 1.88.2.3 31-Aug-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #248):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.25
sys/dev/pci/ixgbe/ixgbe.c: revision 1.96
sys/dev/pci/ixgbe/ixgbe.c: revision 1.97
Remove unused counters.
Don't limit number of queue pair to 8. Take max TX queues and max RX queues
into account. 82598 has 32 TX queue and 64 RX queues. Others has 128 TX queues
and 128 RX queues. Number of MSI-X table entries is 64, so the max queue pairs
is 63 (64 minus the Others (e.g. link status change)).
 1.88.2.2 05-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #175):
sys/dev/pci/ixgbe/ix_txrx.c: 1.25-1.27
sys/dev/pci/ixgbe/ixgbe.c: 1.91-1.95
sys/dev/pci/ixgbe/ixgbe_type.h: 1.23-1.25
sys/dev/pci/ixgbe/ixgbe_api.c: 1.16
sync ixg(4) up to ixgbe.c rev. 1.95:
- Increase total number of RX buffers on multiqueue.
- Fix the partial chain check in ixgbe_rx_discard(). This bug was
added in ixgbe.c rev. 1.33.
- Fix a double free in ixgbe_rxeof().
- Print verbose output in ixgbe_update_link_status() correctly on 5Gbps
and 2.5Gbps (NBASE-T) for X550T[12] and newer.
- Change hw.ixgN.ts to hw.ixgN.thermal_test. Same as FreeBSD.
- Fix a bug that ifconfig ixgN media 1000baseT and 10Gbase-T advertised
additional unwanted speeds.
- Print PHY ID.
- Remove unused variable.
 1.88.2.1 04-Jul-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #81):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.89
sys/dev/pci/if_wm.c: revision 1.509
sys/dev/pci/ixgbe/ixgbe.c: revision 1.90
Use IFM_1000_KX and IFM_2500_KX.
Use IFM_1000_KX more.
 1.128.2.13 26-Jan-2019  pgoyette Sync with HEAD
 1.128.2.12 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.128.2.11 30-Sep-2018  pgoyette Ssync with HEAD
 1.128.2.10 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.128.2.9 28-Jul-2018  pgoyette Sync with HEAD
 1.128.2.8 25-Jun-2018  pgoyette Sync with HEAD
 1.128.2.7 21-May-2018  pgoyette Sync with HEAD
 1.128.2.6 22-Apr-2018  pgoyette Sync with HEAD
 1.128.2.5 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.128.2.4 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.128.2.3 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.128.2.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.128.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.161.2.3 21-Apr-2020  martin Sync with HEAD
 1.161.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.161.2.1 10-Jun-2019  christos Sync with HEAD
 1.199.2.30 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1792:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.199.2.29 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.199.2.28 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.199.2.27 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.199.2.26 21-Jun-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1647:

sys/dev/pci/ixgbe/ixgbe.c 1.325-1.326 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.44
sys/dev/pci/ixgbe/ixgbe_type.h 1.56

- PCI device ID 0x15c8 also uses X557-AT PHY, so create the thermal
sensor sysctl for it, too.
- Count the number of link down events in the MAC using with
LINK_DN_CNT register.
 1.199.2.25 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.199.2.24 03-Jun-2022  snj Pull up following revision(s) (requested by msaitoh in ticket #1460):
sys/dev/pci/ixgbe/ixgbe.c: patch
Fix previous to re-enable legacy interrupt correctly. It's a part of
ixgbe.c rev. 1.273.
 1.199.2.23 02-Jun-2022  martin Pull up the following revisions, all via patch, requested by msaitoh
in ticket #1459:

sys/dev/pci/ixgbe/ixgbe.c 1.261,1.265-1.268,1.273,1.275-1.277,
1.312,1.316-1.319 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.182

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Fix typos in comment.
- KNF.
 1.199.2.22 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1458):

sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.199.2.21 30-May-2022  martin Pull up the following revisions, requested by msaitoh:

sys/dev/pci/ixgbe/ixgbe.c 1.270,1.280,1.307-1.311,
1.313-1.314 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.96-1.97
sys/dev/pci/ixgbe/ixv.c 1.158,1.179-1.180 via patch


- ixg(4): Print Printed Board Assembly (PBA) number.
- ixg(4): Add IFF_RUNNING check in ixgbe_legacy_irq() again. this might
fix small race but it's not so dangerous.
- Add value check for {tx,rx}_process_limit sysctl to avoid setting
wrong value.
- Add missing num_tx_desc sysctl.
- No functional change:
- KNF a bit.
- Simplify setting of EIAC register.
- Move the definition of eicr_mask variable.
- Enclose flow director stuff in ixgbe_intr_admin_common() with
IXGBE_FIR which is not defined in NetBSD.
- Modify comment for consistency.
- Use cached rx_copy_len in ixgbe_rxeof().
 1.199.2.20 02-Feb-2022  martin Pull up the following revisions (requested by msaitoh in ticket #1424):

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.305 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixv.c 1.178 via patch

Use atomic_{load,store}_relaxed() for event counters.
 1.199.2.19 01-Feb-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1420:

sys/dev/pci/ixgbe/ixgbe.c 1.264,1.269,1.272,
1.306 via patch

Four INTx related fixes:
- Fix a bug that the all interrupt sources are enabled when the
interface is UP and the INTx line is shared with other devices.
- Fix a bug that it might incorrectly enable interrupt when
IFF_RUNNING is not set.
- Don't process TX/RX if a queue interrupt isn't occurred.
- Increment legacy interrupt counter after checking INTx sharing.
 1.199.2.18 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.199.2.17 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.199.2.16 29-Jan-2022  martin Pullup the following revisions, requested by msaitoh:

sys/dev/pci/ixgbe/ixgbe.c 1.298, 1.303 via patch

Add some missing error counters to ierror.
 1.199.2.15 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1374:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.199.2.14 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.199.2.13 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.199.2.12 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1070):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

-

Minor change.
- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.199.2.11 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.199.2.10 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #664):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.199.2.9 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.199.2.8 24-Dec-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #580):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.217
sys/dev/pci/ixgbe/ixgbe.c: revision 1.218
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.6
sys/dev/pci/ixgbe/ixv.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.25

Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.

Add missing core lock in ixgbe_handle_mod().
 1.199.2.7 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #453):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.216
sys/dev/pci/ixgbe/ixv.c: revision 1.141

Print MAC address.

XXX Should we move such type of printf() to ether_ifattach?
 1.199.2.6 17-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #348):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.214

Apply FreeBSD r353599:
> ixgbe: Disable EEE for backplane X550EM_X
>
> From Zach:
> Intel documentation indicates that backplane X550EM_X KR devices do not
> support Energy Efficient Ethernet. Prior to this patch, X552 devices
> (device ID 0x15AB) will crash the system when transitioning EEE state
> via sysctl.
>
> Signed-off-by: Zach Vargas <zvargas@xes-inc.com>
>
> PR: 240320
> Submitted by: Zach Vargas <zvargas@xes-inc.com>
> Reviewed by: erj@
> MFC after: 3 days
> Differential Revision: https://reviews.freebsd.org/D21673
 1.199.2.5 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.199.2.4 05-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #180):

sys/dev/pci/ixgbe/ixv.c: revision 1.130
sys/dev/pci/ixgbe/ixgbe.c: revision 1.207
sys/dev/pci/ixgbe/ixgbe.c: revision 1.208
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.55
sys/dev/pci/ixgbe/ixv.c: revision 1.129
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.10

printf -> device_printf

Set IFM_1000_BX10 correctly.

Use aprint_*() in the attach function.
 1.199.2.3 01-Sep-2019  martin Pull up following revision(s) (requested by knakahara in ticket #136):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.205
sys/dev/pci/ixgbe/ixgbe.c: revision 1.206

fix typo in error handling of ixgbe_allocate_legacy().
ok by msaitoh@n.o

pullup-8, pullup-9

-

Fix panic when ncpu == 1 && sysctl -w hw.ixg0.txrx_workqueue=1. Reported by nonaka@n.o.

ok by msaitoh@n.o and nonaka@n.o

pullup-8, pullup-9
 1.199.2.2 01-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #134):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.202
sys/dev/pci/ixgbe/ixgbe.c: revision 1.203
sys/dev/pci/ixgbe/ixgbe.c: revision 1.204
sys/dev/pci/ixgbe/ixv.c: revision 1.128

Simplify ix{gbe,v}_[un]register_vlan() API suggested by knakahara.

The API was the same as FreeBSD's pre-iflib's. They use iflib now and it's
not required for us to keep the old API.
X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.

An interrupt might not arrive when a module is inserted. When an link status
change interrupt occurred and the driver still regard SFP as unplugged, link
becomes up and the real media type is unknown. e.g:

% ifconfig -m ixg0
(snip)
media: Ethernet autoselect (autoselect rxpause,txpause)
status: active
supported Ethernet media:
media none
media autoselect
(snip)

To resolve this problem, when an link status change interrupt occurred and the
driver still regard SFP as unplugged, issue the module softint before issuing
LSC interrupt.
 1.199.2.1 01-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #133):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.200
sys/dev/pci/ixgbe/ixgbe.c: revision 1.201
sys/dev/pci/ixgbe/ixv.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.127
sys/net/if_vlan.c: revision 1.142
sys/net/if_vlan.c: revision 1.143
sys/net/if_vlan.c: revision 1.144
sys/net/if_vlan.c: revision 1.145
sys/net/if_vlan.c: revision 1.146

Check ec_capenable instead of ec_capabilities to control TX side of VLAN HW
tagging correctly.
XXX pullup-9

Add missing IFNET_LOCK() and IFNET_UNLOCK() in vlan_config().
XXX pullup-9

Fix a bug that VLAN HW "tagging" enable/disable may not reflect correctly.
- Always call ec_vlan_cb() if it exists.
- Some (or all?) ethernet drivers don't enable HW tagging if no any vlan is
attached. ixgbe is one of them. Check the the transition and update
VLAN HW tagging function.
XXX pullup-9

Use ETHER_LOCK()/ETHER_UNLOCK() suggested by knakahara.
- kmem_alloc(,KM_SLEEP) never return NULL, so remove NULL check.
- VLAN ID is never duplicated, so break the loop when found. Also move
kmen_free() outside of ETHER_LOCK(ec)/ETHER_UNLOCK(ec) to reduce the hold
time. suggested by ozaki-r.
- Whitespace fix.
 1.220.2.2 29-Feb-2020  ad Sync with head.
 1.220.2.1 25-Jan-2020  ad Sync with head.
 1.227.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.258.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.258.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.258.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.279.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.280.2.3 01-Aug-2021  thorpej Sync with HEAD.
 1.280.2.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.280.2.1 13-May-2021  thorpej Sync with HEAD.
 1.282.2.1 31-May-2021  cjep sync with head
 1.324.2.8 23-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #604):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.349

ixgbe: Add QPRDC into iqdrops.

A receive packet might drop at two different locations.

One is the packet buffer that packets are received into the chip first.
If the packet buffer is overflowed, the MPC register is incremented.
It's currently added to iqdrops. It's no problem.

Another is descriptor ring(s). A packet from the packet buffer is DMA'ed
into main memory base on the descriptor ring. If the ring is full, the packet
is dropped and the QPRDC register is incremented. It should be added to
iqdrops but it was not done. Fix it.

Reported by ozaki-r@.
 1.324.2.7 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #563):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.110
sys/dev/pci/ixgbe/ixgbe.c: revision 1.345
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.111
sys/dev/pci/ixgbe/ixgbe.c: revision 1.346
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.112
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.62
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.113
sys/dev/pci/ixgbe/ixgbe.c: revision 1.348
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.114
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.115
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.116
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.105
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.106
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.107
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.108
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.109
sys/dev/pci/ixgbe/ixv.c: revision 1.193
sys/dev/pci/ixgbe/ixv.c: revision 1.195
sys/dev/pci/ixgbe/ixv.c: revision 1.196
sys/dev/pci/ixgbe/ixgbe.h: revision 1.94
sys/dev/pci/ixgbe/ixgbe.h: revision 1.95
sys/dev/pci/ixgbe/ixgbe.h: revision 1.96
sys/dev/pci/ixgbe/ixgbe.h: revision 1.97
sys/dev/pci/ixgbe/ixgbe.h: revision 1.98

ixgbe: Fix comment. No functional change.
ixgbe: Whitespace. No functional change.
ixgbe(4): Move assignment of TXD. NFCI.
ixgbe(4): Modify comment. No functional change.
ixgbe_tx_ctx_setup() may or may not consume one TX descriptor.
ixv(4): Remove unused IFF_OACTIVE. No functional change.
ixgbe: Clear the WTHRESH bit field before writing it.
ixgbe: Modify for the readability. No functional change.
ixgbe: micro-optimize ixgbe_txeof()
Update txr->tx_avail and txr->txr_no_space outside the loop in ixgbe_txeof().
ixgbe: Update if_opackets outside the loop in ixgbe_txeof().
ixgbe: micro-optimize ixgbe_txeof()
Update txr->packets outside the loop in ixgbe_txeof().
ixgbe: Use #ifdef IXGBE_FDIR more
Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
ixgbe: Simplify. No functional change.
The descriptor ring size and the alignment are tested in the attach
function, so it's not required to use roundup2(size, DBA_ALIGN).
ixgbe: Use kmem_zalloc() instead of malloc(,M_ZERO).
ixgbe: Remove unused to reduce the size of struct rx_ring.
ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
ixgbe: Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring and rx_ring
because of the alignment.
ixgbe: Use #ifdef RSC
This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.324.2.6 03-Nov-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #455):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.347
sys/net/if_l2tp.c: revision 1.49
tests/net/if_vlan/t_vlan.sh: revision 1.25
sys/net/if_vlan.c: revision 1.171
sys/net/if_ethersubr.c: revision 1.326
sys/dev/pci/ixgbe/ixv.c: revision 1.194
Use ether_bpf_mtap only when the device supports vlan harware tagging
The function is bpf_mtap() for ethernet devices and *currently*
it is just handling VLAN tag stripped by the hardware.
l2tp(4): use ether_ifattach() to initialize ethercom
Support vlan(4) over l2tp(4)
Added the test for vlan over l2tp
 1.324.2.5 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #420):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.340
sys/dev/pci/ixgbe/ixgbe.c: revision 1.341
sys/dev/pci/ixgbe/ixgbe.c: revision 1.342
sys/dev/pci/ixgbe/ixgbe.c: revision 1.343
sys/dev/pci/ixgbe/ixgbe.c: revision 1.344
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.61
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.104
sys/dev/pci/ixgbe/ixv.c: revision 1.190
sys/dev/pci/ixgbe/ixv.c: revision 1.191
sys/dev/pci/ixgbe/ixv.c: revision 1.192
sys/dev/pci/ixgbe/ixgbe.h: revision 1.93

ixg(4): Print DEVICE_CAPS register.

ixgbe: Whitespace. No functional change.

ixg(4): Don't print wrong error message about ixgbe_num_queues.
Don't override the ixgbe_num_queues global variable. It's the default
value of the number of queues and should not override it because it
will be referenced by later device attach. For example, the number of
MSI-X vector is 64 on X540 and 18 on 82599. When both cards are inserted
to a machine that the number of CPU is 24 and X540 is probed earlier,
ixgbe_num_queues is overridden to 24 and the following error message is
printed when attaching 82599:
ixg2: autoconfiguration error: ixgbe_num_queues (24) is too large,
using reduced amount (17).

Note that the number of queues is in sc->num_queuss and referenced
by hw.ixgN.num_queues sysctl.

ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.

ixgbe: Whitespace. No functional change.
 1.324.2.4 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.324.2.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.324.2.2 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.324.2.1 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #202):

sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.56
sys/dev/pci/ixgbe/ixgbe.c: revision 1.325
sys/dev/pci/ixgbe/ixgbe.c: revision 1.326
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.44

Use thermal sensor code for IXGBE_DEV_ID_X550EM_A_10G_T, too.
PCI device ID 0x15c8 also use X557-AT PHY, so create the thermal sensor
sysctl for it, too.

Count the number of link down events in the MAC using with LINK_DN_CNT.
- Add new event counter "link_dn_cnt" to count the number of link down
events in the MAC.
- The LINK_DN_CNT register (at 0x0403c) is described only in the
Denverton's datasheet, so use it only on ixgbe_mac_X550EM_a.
 1.352.2.1 02-Aug-2025  perseant Sync with HEAD
 1.100 26-Feb-2025  andvar Fix typos in comments, mainly s/calcurate/calculate/.
 1.99 19-Sep-2024  andvar s/trafic/traffic/ and s/Crrently/Currently/ in comments.
 1.98 30-Dec-2023  msaitoh branches: 1.98.2;
ixgbe: Use #ifdef RSC

This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.97 30-Dec-2023  msaitoh ixgbe: Change "me" from 32bit to 8bit because the max is 128.

This commit doesn't change the real size of ix_queue, tx_ring and rx_ring
because of the alignment.
 1.96 29-Dec-2023  msaitoh ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
 1.95 29-Dec-2023  msaitoh ixgbe: Remove unused to reduce the size of struct rx_ring.
 1.94 28-Dec-2023  msaitoh ixgbe: Use #ifdef IXGBE_FDIR more

Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
 1.93 12-Oct-2023  msaitoh ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.
 1.92 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.91 06-Oct-2023  msaitoh ixgbe: Simplify definitions. No functional change.

Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.
 1.90 06-Oct-2023  msaitoh ixg(4): Remove unused and old function. No functional change.

- From FreeBSD's ix-3.3.32.
 1.89 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.88 06-Oct-2023  msaitoh ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.

PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.
 1.87 13-Sep-2023  msaitoh ixgbe: Reorder some event counters for readability.
 1.86 30-May-2022  msaitoh branches: 1.86.4;
Remove unused adapter->msix_mem.
 1.85 10-Mar-2022  msaitoh Print ECC, PHY and temp error log using with ratecheck().

- The ratecheck() is for just in case. All of the interrupts might occur
only once, but I don't know whether it's true or not. For the fan failure,
it seems it occurs only once.
- All of the interval is 60s.
 1.84 10-Dec-2021  msaitoh No functional change.

- Sync with FreeBSD ix-3.3.18.
- Rename ixgbe_get_advertise() to ixgbe_get_default_advertise.
- Sort lines, modify comment and whitespace to reduce diff against FreeBSD.
 1.83 17-Nov-2021  msaitoh s/dataseet/datasheet/ in comment.
 1.82 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.81 16-Sep-2021  msaitoh Fix a bug that an mbuf chain which has more than 63488bytes MAY fail on TX.

- Currently, The TX buffer dmamap's max number of segments is set to 32.
MCLBYTES(== 2048) * 32 = 65536 and it's enough for IP_MAXPACKET(65535).
If an mbuf chain has more than 32 mbufs, we call m_defrag() to make
it lower than equal to 32, but it might not work. The reason is that
our m_defrag() don't modify the first mbuf entry of the chain. e.g.:
if an mbuf chain contains 63600bytes data and the first mbuf has 100bytes
in the m_data, the new chain has 100+2048+2048+...+12 and the total number
of the chain is not 32 but 33. It result in 43 TCP packets will drop.
- One of the way to fix this problem is to change m_defrag() which add a
new mbuf cluster to the first mbuf. It's need discussion.
- Another solution is to change the max number of the TX DMA segment.
It should be at least 33 to avoid the m_defrag()'s current limitation.
The document (82599-X550 DS 7.2.1.1 "Transmit Storage in system Memory")
says that a packet can be fragmented into 40 - WTHRESH - 2 (for 82598,
the document say nothing and some people and code says it's unlimited).
Currently WTHRESH is set to 8. 40 - 8 - 2 = 30. !?!?!? {Net,Free,Open}BSD
and Linux use 32. Is that safe? Anyway, we change WTHRESH from 8 to 5
to fit it. The added comment in ixgbe.h is based on DragonFly's
though they don't use WTHRESH.
- Yet another solution is to use the Tx Head Pointer Write Back function
instead of WTHRESH based write back (see 82599-X550 DS 7.2.3.5.2
"Tx Head Pointer Write Back" or 82598 "Transmit Completions Head Write Back"
). DragonFly, illumos and DPDK use it.
- Yet yet another solution is to add tso_maxsize entry to struct ifnet
and use it in the TCP stack.
 1.80 03-Sep-2021  msaitoh Save the discard_multidesc state to not to forget the state by exiting rxeof().
 1.79 26-Aug-2021  msaitoh Remove "j" or "jumbo" because we always use MCLBYTES sized buffer.
 1.78 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.77 19-Aug-2021  msaitoh Add forgotten commit for previous. Change IXGBE_RX_COPY_LEN_MAX.
 1.76 07-Jul-2021  msaitoh Add new sysctl "rx_copy_len".

ixgbe_rxeof() has an optimization "RX_COPY" to reduce costs of
bus_dmamap_load_mbuf() and bus_dmamap_unload() by copying a mbuf cluster's
memory to a newly allocated mbuf's MH_databuf[] and recycle the original map.
The optimization is used when a length of a packet is smaller than a specific
value. The value is calculated based on MHLEN. The size of MHLEN is
architecture specific. It's 256 or 512. Make the threshold controllable by
adding a new sysctl.
 1.75 09-Mar-2021  msaitoh branches: 1.75.4;
Modify some parameters to reduce packet dropping.

- Background: ixgbe doesn't use common MCLGET() interface and use the
driver specific cluster allocation mechanism (jcl). The cluster is
pre-allocated with a fixed number and the current number per queue
is num_rx_desc * 2 (2048*2=4096). It's too small. It also has a problem
that the max length of the pcq which is used in the TX path is big
(4096). Example:

100M <----- [ixg0 ixg1] <----- 1G
2048 TX descs <--- 4096 pcqs <---- 2048 RX descs

If a machine forwards a traffic from 1G interface to 100M interface,
It would require 2048+4096+2048=8192 descriptors, but the current number
is 2048*2=4096. It's too small. Even if the both interface's link speed
is the same and only small number of packet is queued in the pcq, 4096
jcl is small because 2048(RX)+TX(2048)=4096. If jcl is exhausted, not only
forwarding from ixg1 to ixg0 is dropped, but also another forwarding path
from ixg1 to another interface(e.g. wm0) is also dropped. Sockets also
queue packets, so if a lot of sockets are used and/or a socket buffer
size is changed to bigger one, it'll also become a problem. If the jcl
is exhausted, evcnt(9) counter "ixgX qY Rx no jumbo mbuf" is incremented.
Example:
vmstat -ev | grep ixg1 | grep "no jumbo"
ixg1 q0 Rx no jumbo mbuf 0 0 misc
ixg1 q1 Rx no jumbo mbuf 0 0 misc
ixg1 q2 Rx no jumbo mbuf 141326 0 misc
ixg1 q3 Rx no jumbo mbuf 0 0 misc


- To solve this problem:
- Add new config parameter IXGBE_JCLNUM_MULTI and set the default to 3
(2048 * 3). The minimum number is 2. The total number of jcl per queue
is available with hw.ixgN.num_jcl_per_queue sysctl.
- Reduce the max length of the pcq() which is used in the TX path from
4096 to 2048.

- Reviewed by knakahara@ and ozaki-r@.

- TODO: Use MCLGET().
 1.74 26-Dec-2020  msaitoh Disable/enable the OTHER interrupts correctly.

The OTHER interrupt was not blocked correctly when MSI-X is used.
ixgbe.c rev. 1.260 added new mutex to avoid the race but it didn't
disable the interrupt itself.

Calling ixgbe_enable_intr() enables all interrupts, so it's not good to
call it when some interrupt sources should not be enabled (e.g.:
calling ixgbe_enable_intr() in ixgbe_handle_admin() enables queue
interrupt).

IXGBE_REQUEST_TASK_NEED_ACKINTR doesn't work as expected because
ixgbe_handle_admin() can't know which task is enqueued from the
interrupt context and can't re-enable a specific EIMS bit.

Solve the above three problems by the following two changes:

- MSI-X: Disable the OTHER interrupts in the biginning of
ixgbe_msix_admin().

- Set mask bits correctly at the end of ixgbe_legacy_irq() and
ixgbe_msix_admin() using with eim_orig, eims_enable and eims_disable.

- Remove IXGBE_REQUEST_TASK_NEED_ACKINTR and add
IXGBE_REQUEST_TASK_{MOD,MSF}_WOI.
 1.73 19-Nov-2020  msaitoh Add comment.
 1.72 17-Nov-2020  knakahara Add new spin mutex to avoid race between ixgbe_msix_admin() and ixgbe_handle_admin().

At first, it seems "IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER)"
cannot stop interrupts, because 31th bit is reserved for 82598, 82599,
X540 and X550. So, the current following design
(1) ixgbe_msix_admin() disables interrupts
(2) ixgbe_msix_admin() calls workqueue_enqueue() for ixgbe_handle_admin()
(3) ixgbe_handle_admin() does interrupt processing
(4) after ixgbe_handle_admin() has done all interrupt processings,
ixgbe_handle_admin() enables interrupts
does not work correctly, that is, interrupts can be lost while
ixgbe_handle_admin() is running.

To fix that, add new spin mutex(adapter->admmin_mtx) which protects
atomically the following two members.
- adapter->admin_pending
- adapter->task_requests

The unnecessary "IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EIMC_OTHER)"
code will be removed later.

Reviewed and tested by hikaru@n.o and msaitoh@n.o, thanks.
 1.71 31-Aug-2020  msaitoh branches: 1.71.2;
If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.
This change eliminate long timeout.

Reduce code duplication using with ixgbe_sfp_cage_full(hw).
 1.70 27-Aug-2020  msaitoh ADD SFP+ MOD_ABS inversion quirk.

On X550 EM, GPIO(SDP) and SFP+'s MOD_ABS is directly connected. It has
no inverter. GIGABYTE MA10-ST0 has a inverter, so add new quirk for it.
 1.69 17-Aug-2020  msaitoh Re-enabling interrupt is required only when a work is scheduled form the
interrput context.
 1.68 17-Aug-2020  msaitoh Fix a bug that the driver sometimes missed module insertion.

The ixgbe_sfp_probe() function was only for 82598 and other chips had no
way to poll SFP+ cage. The ixgbe_handle_mod() already has function to treat
module insertion/removal for all chips, so enqueue the work if the cage
status changed. All of ixgbe chips' SFP+ module interrupt is only on the
inserstion. This change also detect the removal by the timer.
 1.67 25-Jun-2020  msaitoh Reduce ixgbe's busy loop using with workqueue and kpause.

- Use workqueue instead of softint to make some functions sleepable.
- Use new workqueue and enqueue it in ixgbe_local_timer() and
ixgbe_recovery_mode_timer() to make them sleepable.
- Make new ixgbe_delay() and use it. This functions sleeps if the time is
more than equals 1 tick. If it's not, do delay().
 1.66 23-Jun-2020  msaitoh KNF. No functional change.
 1.65 06-Feb-2020  thorpej Ensure we don't call workqueue_enqueue() if the pluggable optics
handler is already pending.
 1.64 05-Feb-2020  msaitoh No functional change:

- Add debug printf()s.
- Remove unused macros.
- Remove extra newline.
 1.63 04-Feb-2020  thorpej - Fix locking problem with optics module interrupts: ifmedia_add()
may block on memory allocation, and so it cannot be safely done from
a softint nor can it be done while holding a spin lock. Fix this by
using a workqueue rather than a softint, and hold the IFNET_LOCK
across the entire handler, and the CORE_LOCK only across the code that
needs to serialize access to the hardware state.
- Use ifmedia_fini().

Tested in a variety of devices by msaitoh@. (Thanks!)
 1.62 21-Jan-2020  msaitoh Fix the freeing code for some error paths. Found and tested by Patrick Welche.
 1.61 20-Jan-2020  msaitoh Free jumbo mem structure correctly. Found by yamaguchi@ using with LOCKDEBUG.
 1.60 16-Dec-2019  msaitoh branches: 1.60.2;
No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.59 30-Oct-2019  msaitoh G.C. (if_ipackets)
 1.58 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.57 12-Sep-2019  msaitoh - Make SIOCADDMULTI returns ENOSPC when the Ethenet multicast address list
exceeds the limit.
- State "Ethernet" multicast address.
- Use macro.
 1.56 17-Jul-2019  msaitoh branches: 1.56.2;
Implement VLAN hardware filter function(ETHERCAP_VLAN_HWFILTER).
First proposed by jmcneill in 2017 and modified by me.

How to use:

- Set callback function:

ether_set_vlan_cb(struct ethercom *, ether_vlancb_t)

- Callback. This function is called when a vlan is attached/detached to the
parent interface:

int (*ether_vlancb_t)(struct ethercom *ec, uint16_t vlanid, bool set);

- ifconfig(8)

ifconfig ixg0 [-]vlan-hwfilter

Note that ETHERCAP_VLAN_HWFILTER is set by default on ixg(4) because
the PF driver usually enable "all block" filter by default.
 1.55 27-Jun-2019  msaitoh Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.54 22-Feb-2019  msaitoh Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.53 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.52 03-Dec-2018  msaitoh Some counters are not per queue but per traffic class. Make new evcnt group
"ixgM tcN" (N = 0..7) and move those counters into it. We are using only
traffic class 0, so we will see only tc0's counter are updated.
 1.51 31-Jul-2018  msaitoh Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.50 25-Jun-2018  msaitoh branches: 1.50.2;
Remove duplicated inclusion of net/bpf.h.
 1.49 23-May-2018  msaitoh Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
 1.48 18-May-2018  msaitoh Revert new watchdog timer commits. The new watchdog timer made stability
worse than before. It seems unknown problems exists.

http://mail-index.netbsd.org/source-changes/2018/05/08/msg095020.html
http://mail-index.netbsd.org/source-changes/2018/05/16/msg095240.html
 1.47 08-May-2018  msaitoh - Fix broken watchdog timer. This change detects TX device timeout correctly.
NOTE: It's supporsed not to be called {ixgbe,ixv}_rearm_queues() in the
timer. Those are not required if any chip have no bug. In reality,
ixgbe_rearm_queues() is required on 82599 and newer chip AND other than
queue 0 to prevent device timeout. When it occured, packet was sent but the
descriptor's DD bit wasn't set even though IXGBE_TXD_CMD_EOP and
IXGBE_TXD_CMD_RS were set. After forcing interrupt by writing EICS register
in ixgbe_rearm_queues(), DD is set. Why? Is this an undocumented errata? It
might be possible not call rearm_queues on 82598 or queue 0, we call in any
cases in case the problem occurs. On ixv(4), I have not seen this problem yet
(though I tested only on X550_X(Xeon D 12xx)'s virtual function), but we
do rearm in case TX device timeout happen.
- ixv(4): Call callout_stop() earlier in ixv_stop() like ixgbe_stop().
- KNF.
 1.46 25-Apr-2018  msaitoh Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
 1.45 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.44 19-Apr-2018  msaitoh Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
 1.43 17-Apr-2018  msaitoh Remove unused structure entries. No functional change.
 1.42 17-Apr-2018  knakahara Fix panic when "sysctl -w hw.ixg0.txrx_workqueue=[01]" while there is traffic.

The operation is not supported, however causing panic is problem.
 1.41 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.40 02-Apr-2018  knakahara Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time

ok by msaitoh@n.o.
 1.39 30-Mar-2018  knakahara Don't write EIMC directly. It is required to manage with struct ix_queue status.

XXX pullup-8
 1.38 30-Mar-2018  knakahara Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.

XXX pullup-8
 1.37 26-Mar-2018  msaitoh - Add link related softint's counter.
- Fix indent.
 1.36 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.35 09-Mar-2018  msaitoh Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.34 07-Mar-2018  msaitoh - Make "Handled queue in softint" and "Requeued in softint" evcnt(9) per queue
and count them correctly.
- Remove #if 0'ed code.
 1.33 06-Mar-2018  msaitoh Move the location of "struct work" as FreeBSD's "struct task" in ixgbe.h.
No functional change.
 1.32 02-Mar-2018  knakahara branches: 1.32.2;
ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.
 1.31 26-Feb-2018  knakahara Fix poll mode assumption breaking.

ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.

E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.

This fix may have 1% or 2% performance impact at short packets.

XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.

ok by msaitoh@n.o.
 1.30 22-Feb-2018  msaitoh Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.29 06-Dec-2017  msaitoh Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.28 22-Nov-2017  msaitoh Fix a bug that bypass adapter's sysctls aren't set. Tested with non-genuine
X550-T2 bypass adapter:
- Call ixgbe_sysctl_instance() in ixgbe_bypass_init() to get sysctl's top node
correctly.
- ixgbe_init_device_features() refers adapter->hw.bus.func for bypass adapter.
Call set_lan_id() to set adapter->hw.bus.func before calling
ixgbe_init_device_features(). Without this, bypass sysctl's are added to
both the first and second port.
- Initalize node.sysctl_data before calling sysctl_lookup() to read correct
value.
 1.27 02-Nov-2017  msaitoh - Handle hw.ixgN.advertise_speed correctly.
- Fix hw.ixgN.advertise_speed sysctl's description.
 1.26 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.25 24-Aug-2017  msaitoh Remove unused counters.
 1.24 13-Feb-2017  msaitoh branches: 1.24.6;
Use percpuq.
 1.23 10-Feb-2017  msaitoh - Both mbuf_defrag_failed and m_defrag_failed existed. Remove m_defrag_failed.
- rx_irq, dropped_pkts, morerx, moretx and txloops counters are uncounted, so
remove them.
- Count handleq in ixv_handle_que().
- Detach event counters correctly.
- Set some per-queue event names correctly.
 1.22 01-Feb-2017  msaitoh TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h
 1.21 30-Jan-2017  msaitoh - Count tso_err again. It was accidentally removed in ixgbe.c rev. 1.28.
- ixgbe.h: Sort entries to reduce diff against FreeBSD.
 1.20 25-Jan-2017  msaitoh Fix SFP+ insersion or replacement stuff.
 1.19 18-Jan-2017  msaitoh Fix sysctl stuff. Make the top sysctl node and keep the pointer.
 1.18 05-Dec-2016  msaitoh branches: 1.18.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.17 02-Dec-2016  msaitoh - Add missing pmf_device_deregister() in ixgbe_detach()
- Remove extra newline from an sysctl description.
- Fix dmesg output when the number of PCIe lane can't get.
 1.16 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.15 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r289238:
- Add support for sysctl knobs to live tune the per interrupt rx/tx packet
processing limits in ixgbe(4)
- Some others (netmap, etc.)
 1.14 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r285590:
- Fix igxbe SRIOV VF (if_ixv) initialization bugs. The MAC address for
an if_ixv instance can now set at creation time, and the receive ring
tail pointer is correctly initialized (previously, things still worked
because the receive ring tail pointer was being fixed up as a side
effect of other activity).
 1.13 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r283881:
- SRIOV support (not enabled because NetBSD doesn't support it).
 1.12 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.11 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.10 28-Nov-2016  msaitoh FreeBSD r280182 made new file ix_txrx.c and moved ixgbe.c and ixv's common
code into it. Before sync with whole of them, just move ixgbe.c and ixv.c's
common code into ix_txrx.c from ixgbe.c. In this commit, only ixgbe.c is split
into the device dependent part and the common part. ixv.c isn't change to make
this commit no functional change. To use ixv.c with ix_txrx.c, it's required
to modify the common part's API and functions themselves.

This commit is done to make the next change easy to understand.
 1.9 17-Aug-2015  knakahara branches: 1.9.2;
Add kernel code to support intrctl(8).
 1.8 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.7 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.6 14-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r243716:
- A lot of bugfixes. Some of them are realted to multi queue and those
have not affected in NetBSD because we have not used it yet.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Improve performance.
 1.5 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.4 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.3 10-Mar-2015  msaitoh Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.2 04-Feb-2015  msaitoh Fix mutex related problem reported by Uwe Toenjes in PR#49328:
- Revert ixgbe_netbsd.c rev. 1.2
- make CORE_LOCK adaptive
- Release spin lock while reinitializing the jumb buffer structure.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.6 28-Aug-2017  skrll Sync with HEAD
 1.1.30.5 05-Feb-2017  skrll Sync with HEAD
 1.1.30.4 05-Dec-2016  skrll Sync with HEAD
 1.1.30.3 22-Sep-2015  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.5 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.28.4 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.3 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.28.2 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.1.28.1 24-Feb-2015  martin Pull up following revision(s) (requested by msaitoh in ticket #545):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.19
Add missing IXGBE_RX_LOCK_DESTROY() for the detach path.
Remove extra IXGBE_TX_LOCK()/IXGBE_TX_UNLOCK() from
ixgbe_free_transmit_structures(). This function is called in the end of
the detach function. if_stop was called and almost all resources were
freed, so it's not required to block the TX stuff.
Fix mutex related problem reported by Uwe Toenjes in PR#49328:
- Revert ixgbe_netbsd.c rev. 1.2
- make CORE_LOCK adaptive
- Release spin lock while reinitializing the jumb buffer structure.
disable preemption while scheduling the softint to configure the link.
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.9.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.9.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.24.6.30 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1933:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.24.6.29 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.24.6.28 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.24.6.27 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.24.6.26 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.24.6.25 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98
sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.24.6.24 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.24.6.23 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1708:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.24.6.22 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.24.6.21 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.24.6.20 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.24.6.19 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.24.6.18 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1389:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213 via patch
sys/dev/pci/ixgbe/ixv.c 1.131-1.138 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58 via patch
share/man/man4/ixv.4 1.5 via patch

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
 1.24.6.17 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.24.6.16 01-Mar-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1199):

sys/dev/pci/ixgbe/ixv.c: revision 1.109
sys/dev/pci/ixgbe/ixgbe.h: revision 1.54
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.174

Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.24.6.15 28-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1171):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.168
sys/dev/pci/ixgbe/ixgbe.h: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.172
sys/dev/pci/ixgbe/ixgbe.c: revision 1.173

Some counters are not per queue but per traffic class. Make new evcnt group
"ixgM tcN" (N = 0..7) and move those counters into it. We are using only
traffic class 0, so we will see only tc0's counter are updated.

-

Call ixgbe_init_swfw_semaphore(hw) before calling ixgbe_check_wol_support()
because ixgbe_check_wol_support()->ixgbe_check_wol_support()->
ixgbe_get_device_caps() accesses semaphore.

-

- Move the location of calling setup_eee() in ixgbe_attach(). The previous
location was too early. The new location is before calling
ixgbe_set_phy_power().
- Restore call of setup_eee() in ixgbe_init_locked(). It was removed in
rev. 1.99 (FreeBSD r320688).
- When calling setup_eee(), pass enable/disable correctly.
 1.24.6.14 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.24.6.13 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.24.6.12 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.24.6.11 17-Apr-2018  martin Pull up following revision(s) (requested by knakahara in ticket #769):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.147
sys/dev/pci/ixgbe/ixgbe.h: revision 1.42

Fix panic when "sysctl -w hw.ixg0.txrx_workqueue=[01]" while there is traffic.
The operation is not supported, however causing panic is problem.
 1.24.6.10 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.24.6.9 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.24.6.8 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.24.6.7 13-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #626):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.134
sys/dev/pci/ixgbe/ixgbe.h: revision 1.35
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.35
sys/dev/pci/ixgbe/ixv.c: revision 1.87
Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.24.6.6 08-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #612):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.129-1.133
sys/dev/pci/ixgbe/ixgbe.h: revision 1.34
sys/dev/pci/ixgbe/ixv.c: revision 1.85,1.86

- Make "Handled queue in softint" and "Requeued in softint" evcnt(9) per queue
and count them correctly.
- Remove #if 0'ed code.

Don't increment que->req.ev_count in MSI-X interrupt because it's not
reschedule.

Fix another poll mode assumption breaking. Implemented by msaitoh@n.o, I just commit by proxy.
ixgbe_rearm_queues() writes EICS register(s). 82599, X540 and X550
specifications say "Following a write of 1b to any bit in the EICS register
(interrupt cause set), its corresponding bit in the EIMS register is auto
set as well enabling its interrupt." in "Extended Interrupt Auto Mask Enable
(EIAM) Register" section. That is, ixgbe_rearm_queues() causes interrupts
regardless of the status managed by ixgbe_enable_queue()/ixgbe_disable_queue().

That can break poll mode assumption.

In fact, the problem occurs in the following situation
- CPU#A has high load traffic, in contrast, CPU#B has not so high load traffic
- CPU#A is occurred interrupt by its NIC queue
- CPU#A calls ixgbe_disable_queue() in interrupt handler(ixgbe_msix_que())
- CPU#A kick softint handler(ixgbe_handle_que())
- CPU#A begins softint
- CPU#A's NIC queue is set que->txr->busy flag
- With some reason, CPU#A can do ixg interrupt handler
E.g. when one of CPU#A's softnet handlers sleeps, ipl is lowered
- CPU#B starts callout
- CPU#B calls ixgbe_local_timer1()
- CPU#B writes EICS bit corresponding CPU#A's NIC queue bit
- CPU#A's NIC queue causes interrupt whie CPU#A is running in poll mode
- CPU#A calls ixgbe_disable_queue() in interrupt handler *again*
- CPU#A has done polling, and then CPU#A calls ixgbe_enable_queue() *once*
- CPU#A's NIC queue interrupt is disabled until ixg is detached as
ixgbe_disable_queue() is called twice though ixgbe_disable_queue() is
called once only
NOTE:
82598 does not say so, but it is treated in the same way because of no harm.
By the way, we will refactor ixgbe_local_timer(watchdog processing) later.

Fix INTx/MSI handler did not schedule workqueue. Pointed out by msaitoh@n.o.

Reduce duplicated code which schedule deferred packet processing. No functional change.
 1.24.6.5 06-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #605):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe.h: revision 1.33
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.34
sys/dev/pci/ixgbe/ixgbe.c: revision 1.128
sys/dev/pci/ixgbe/ixv.c: revision 1.83
sys/dev/pci/ixgbe/ixv.c: revision 1.84

Add hw.ixvM.q[01].{interrupt_rate,[tr]xd_head,[tr]xd_tail} sysctls as ixg(4).

ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.

ixv(4) also supports workqueue poll mode, but not enabled by default yet, either.
ok by msaitoh@n.o.

Move the location of "struct work" as FreeBSD's "struct task" in ixgbe.h.
No functional change.
 1.24.6.4 01-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #597):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.c: revision 1.127
sys/dev/pci/ixgbe/ixv.c: revision 1.82
Fix poll mode assumption breaking.
ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.
E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.
This fix may have 1% or 2% performance impact at short packets.
XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.
ok by msaitoh@n.o.
Apply ixgbe.c:r1.127 to ixv.c. Pointed out by msaitoh@n.o.
 1.24.6.3 26-Feb-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #592):
sys/dev/pci/ixgbe/ixv.c: revision 1.79
sys/dev/pci/ixgbe/ixgbe.h: revision 1.30
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.31
sys/dev/pci/ixgbe/ixgbe.c: revision 1.120
sys/dev/pci/ixgbe/ixgbe.c: revision 1.121
sys/dev/pci/ixgbe/ixgbe.c: revision 1.123
sys/dev/pci/ixgbe/ixgbe.c: revision 1.124
sys/dev/pci/ixgbe/ixgbe.c: revision 1.125
sys/dev/pci/ixgbe/ixgbe.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.80
sys/dev/pci/ixgbe/ixv.c: revision 1.81
CID-1427719: Integer handling issues (BAD_SHIFT). Print bus/slot info
correctly on 82599_SFP_SF_QP(DID 0x154a) and 82599_QSFP_SF_QP(DID 0x1558).
Fix a bug that RX may stall on heavy load on ixg(4). ixgbe_rxeof() has loop
limit and the function returns true if a packet are still in the RX ring.
ixgbe_handle_que() didn't check the return value. Check the return vaule
and issue a softint.
This bug is derived from FreeBSD and ixv(4) has no this bug.
XXX pullup-8
Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().
XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
- Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:
sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)
Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:
int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |
The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.
While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!
This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.
(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.
- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.
XXX pullup-8
Increment rxr->packets correctly in ixgbe_rxeof() to calculate ITR value
of AIM (Auto Interrupt Moderation) correctly. See also ixgbe.c rev. 1.124.
XXX pullup-8
Improve a comment about reading EICS register defined write-only by spec.
It seems that is workaround for silicon errata.
ok by msaitoh@n.o.
- Apply ixgbe.c rev. 1.124 to ixv.c. Fix a bug that RX may stall on heavy load
on ixv(4) derived from FreeBSD's AIM (Auto Interrupt Moderation) bug.
ITR_INTERVAL value must be larger than 4us.
- The bitfield of EITR register is different between 82598 and others.
ixv.c had a bug that it accessed 82598's way even though only 82599 and
newer support virtual function. Fix it using with new ixv_eitr_write()
function.
Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.24.6.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.24.6.1 31-Aug-2017  martin Pull up following revision(s) (requested by msaitoh in ticket #248):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.25
sys/dev/pci/ixgbe/ixgbe.c: revision 1.96
sys/dev/pci/ixgbe/ixgbe.c: revision 1.97
Remove unused counters.
Don't limit number of queue pair to 8. Take max TX queues and max RX queues
into account. 82598 has 32 TX queue and 64 RX queues. Others has 128 TX queues
and 128 RX queues. Number of MSI-X table entries is 64, so the max queue pairs
is 63 (64 minus the Others (e.g. link status change)).
 1.32.2.9 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.32.2.8 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.32.2.7 25-Jun-2018  pgoyette Sync with HEAD
 1.32.2.6 21-May-2018  pgoyette Sync with HEAD
 1.32.2.5 02-May-2018  pgoyette Synch with HEAD
 1.32.2.4 22-Apr-2018  pgoyette Sync with HEAD
 1.32.2.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.32.2.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.32.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.50.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.2.1 10-Jun-2019  christos Sync with HEAD
 1.56.2.13 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1792:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.56.2.12 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.56.2.11 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.56.2.10 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.56.2.9 02-Jun-2022  martin Pull up the following revisions, all via patch, requested by msaitoh
in ticket #1459:

sys/dev/pci/ixgbe/ixgbe.c 1.261,1.265-1.268,1.273,1.275-1.277,
1.312,1.316-1.319 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.182

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Fix typos in comment.
- KNF.
 1.56.2.8 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1458):

sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.56.2.7 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.56.2.6 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1374:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.56.2.5 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.56.2.4 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.56.2.3 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.56.2.2 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.56.2.1 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.60.2.2 29-Feb-2020  ad Sync with head.
 1.60.2.1 25-Jan-2020  ad Sync with head.
 1.71.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.71.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.71.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.75.4.1 01-Aug-2021  thorpej Sync with HEAD.
 1.86.4.5 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #563):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.110
sys/dev/pci/ixgbe/ixgbe.c: revision 1.345
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.111
sys/dev/pci/ixgbe/ixgbe.c: revision 1.346
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.112
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.62
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.113
sys/dev/pci/ixgbe/ixgbe.c: revision 1.348
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.114
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.115
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.116
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.105
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.106
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.107
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.108
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.109
sys/dev/pci/ixgbe/ixv.c: revision 1.193
sys/dev/pci/ixgbe/ixv.c: revision 1.195
sys/dev/pci/ixgbe/ixv.c: revision 1.196
sys/dev/pci/ixgbe/ixgbe.h: revision 1.94
sys/dev/pci/ixgbe/ixgbe.h: revision 1.95
sys/dev/pci/ixgbe/ixgbe.h: revision 1.96
sys/dev/pci/ixgbe/ixgbe.h: revision 1.97
sys/dev/pci/ixgbe/ixgbe.h: revision 1.98

ixgbe: Fix comment. No functional change.
ixgbe: Whitespace. No functional change.
ixgbe(4): Move assignment of TXD. NFCI.
ixgbe(4): Modify comment. No functional change.
ixgbe_tx_ctx_setup() may or may not consume one TX descriptor.
ixv(4): Remove unused IFF_OACTIVE. No functional change.
ixgbe: Clear the WTHRESH bit field before writing it.
ixgbe: Modify for the readability. No functional change.
ixgbe: micro-optimize ixgbe_txeof()
Update txr->tx_avail and txr->txr_no_space outside the loop in ixgbe_txeof().
ixgbe: Update if_opackets outside the loop in ixgbe_txeof().
ixgbe: micro-optimize ixgbe_txeof()
Update txr->packets outside the loop in ixgbe_txeof().
ixgbe: Use #ifdef IXGBE_FDIR more
Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
ixgbe: Simplify. No functional change.
The descriptor ring size and the alignment are tested in the attach
function, so it's not required to use roundup2(size, DBA_ALIGN).
ixgbe: Use kmem_zalloc() instead of malloc(,M_ZERO).
ixgbe: Remove unused to reduce the size of struct rx_ring.
ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
ixgbe: Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring and rx_ring
because of the alignment.
ixgbe: Use #ifdef RSC
This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.86.4.4 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #420):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.340
sys/dev/pci/ixgbe/ixgbe.c: revision 1.341
sys/dev/pci/ixgbe/ixgbe.c: revision 1.342
sys/dev/pci/ixgbe/ixgbe.c: revision 1.343
sys/dev/pci/ixgbe/ixgbe.c: revision 1.344
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.61
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.104
sys/dev/pci/ixgbe/ixv.c: revision 1.190
sys/dev/pci/ixgbe/ixv.c: revision 1.191
sys/dev/pci/ixgbe/ixv.c: revision 1.192
sys/dev/pci/ixgbe/ixgbe.h: revision 1.93

ixg(4): Print DEVICE_CAPS register.

ixgbe: Whitespace. No functional change.

ixg(4): Don't print wrong error message about ixgbe_num_queues.
Don't override the ixgbe_num_queues global variable. It's the default
value of the number of queues and should not override it because it
will be referenced by later device attach. For example, the number of
MSI-X vector is 64 on X540 and 18 on 82599. When both cards are inserted
to a machine that the number of CPU is 24 and X540 is probed earlier,
ixgbe_num_queues is overridden to 24 and the following error message is
printed when attaching 82599:
ixg2: autoconfiguration error: ixgbe_num_queues (24) is too large,
using reduced amount (17).

Note that the number of queues is in sc->num_queuss and referenced
by hw.ixgN.num_queues sysctl.

ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.

ixgbe: Whitespace. No functional change.
 1.86.4.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.86.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.86.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.98.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 06-Jun-2022  msaitoh s/filer/filter/ in comment. No functional change.
 1.18 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.17 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.16 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.15 25-Jun-2020  msaitoh branches: 1.15.6;
Use unsigned to avoid undefined behavior in ixgbe_fc_enable_generic().
Same as ixgbe_common.c rev. 1.24. Found by KUBSan.
 1.14 03-Jan-2020  pgoyette Fix some typos in comments.

From vezhlys on freenode IRC.
 1.13 23-Dec-2019  msaitoh Add recovery code for unsupported SFP+.

Before this commit:
If an unsuppored SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.12 04-Apr-2018  msaitoh branches: 1.12.2; 1.12.8;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.11 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.10 06-Dec-2017  msaitoh branches: 1.10.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.9 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.8 02-Dec-2016  msaitoh branches: 1.8.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.7 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.6 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.5 05-Aug-2015  msaitoh branches: 1.5.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.4 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.3 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.4 05-Dec-2016  skrll Sync with HEAD
 1.1.30.3 22-Sep-2015  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.28.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.8.8 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.8.8.7 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.8.8.6 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.8.8.5 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.8.8.4 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.8.8.3 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.8.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.8.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.10.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.12.8.6 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.12.8.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.12.8.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.12.8.3 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.12.8.2 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #664):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.12.8.1 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.12.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.6.1 13-May-2021  thorpej Sync with HEAD.
 1.9 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.8 04-Apr-2018  msaitoh branches: 1.8.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.7 06-Dec-2017  msaitoh branches: 1.7.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.6 30-Aug-2017  msaitoh branches: 1.6.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.5 01-Dec-2016  msaitoh branches: 1.5.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.3 24-Apr-2015  msaitoh branches: 1.3.2;
Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.2 02-Apr-2015  msaitoh branches: 1.2.2; 1.2.4;
Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.1 27-Mar-2015  msaitoh Add some forgotten files in last commit.
 1.2.4.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.4.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.2.4.1 02-Apr-2015  riz file ixgbe_82598.h was added on branch netbsd-7 on 2015-04-19 14:42:14 +0000
 1.2.2.4 05-Dec-2016  skrll Sync with HEAD
 1.2.2.3 06-Jun-2015  skrll Sync with HEAD
 1.2.2.2 06-Apr-2015  skrll Sync with HEAD
 1.2.2.1 02-Apr-2015  skrll file ixgbe_82598.h was added on branch nick-nhusb on 2015-04-06 15:18:12 +0000
 1.3.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.5.8.3 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.5.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.5.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.6.2.2 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 30-Aug-2017  jdolecek file ixgbe_82598.h was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.7.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.8.8.1 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.32 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.31 06-Oct-2023  msaitoh ixg(4): Add 82599 LS once again.

- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.
 1.30 04-Oct-2023  msaitoh ixgbe: Fix typo in comment. No functional change.
 1.29 24-Dec-2021  msaitoh branches: 1.29.4;
Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.28 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.27 14-Dec-2021  msaitoh Add IPv6 mask for flow director.

- FreeBSD: c4f73d5d6a6c0117e08a03920cce69202865ba13 or ix-3.3.18
DPDK: 21feefa2fcd5899ee26a10be405c17c0a1109860

Write FDIRIP6M register to allow flow director filter
to set ipv6 rules without setting ipv6 source/destination address.

- No functional change because NetBSD doesn't support flow director.
 1.26 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.25 10-Dec-2021  msaitoh Remove unnecessary return value check.

FreeBSD: 3a89005394bc5d82ce9b6baa9e7f8dee362354ae
DPDK: 4b0ee6529b7897c2a08dd56669f07ac1f46a8474
 1.24 10-Dec-2021  msaitoh Add typecast for type mismatch.

FreeBSD: 994dd6328c66fc277438ad51ed074f3c52096147
DPDK: d8e52b2cf771c31b523b46852fd86225b5a2c721
 1.23 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.22 23-Dec-2019  msaitoh branches: 1.22.12;
Add recovery code for unsupported SFP+.

Before this commit:
If an unsuppored SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.21 06-Dec-2018  msaitoh branches: 1.21.4;
Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.20 11-Jun-2018  msaitoh branches: 1.20.2;
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
 1.19 04-Apr-2018  msaitoh Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.18 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.17 30-Mar-2018  msaitoh - Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.

Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))

Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.

- Change some functions static.
 1.16 06-Dec-2017  msaitoh branches: 1.16.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.15 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.14 02-Dec-2016  msaitoh branches: 1.14.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.13 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.12 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.11 13-Aug-2015  msaitoh branches: 1.11.2;
- Add MSI/MSI-X support. The multiqueue function is not supported yet.
- Make ixv.c compilable. _NOT_TESTED_YET_
 1.10 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.9 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.8 14-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r243716:
- A lot of bugfixes. Some of them are realted to multi queue and those
have not affected in NetBSD because we have not used it yet.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Improve performance.
 1.7 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.6 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.5 24-Feb-2015  msaitoh Add 82599EN_SFP and 82599_SFP_SF_QP. Not tested.
 1.4 24-Feb-2015  msaitoh Change macro name IXGBE_DEV_ID_82599_SFP_DELL to IXGBE_DEV_ID_82599_SFP_SF2.
Same as OpenBSD and Linux. No binary change.
 1.3 17-Apr-2014  christos branches: 1.3.2; 1.3.4;
CID 140077: Add missing break and FALLTHROUGH
 1.2 08-Apr-2014  christos Add dell's flavor (from uwe, in current-users@)
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.26;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.26.1 10-Aug-2014  tls Rebase.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.4.4 05-Dec-2016  skrll Sync with HEAD
 1.3.4.3 22-Sep-2015  skrll Sync with HEAD
 1.3.4.2 06-Jun-2015  skrll Sync with HEAD
 1.3.4.1 06-Apr-2015  skrll Sync with HEAD
 1.3.2.4 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.3.2.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.3.2.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.3.2.1 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.11.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.14.8.11 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.14.8.10 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.14.8.9 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.14.8.8 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.14.8.7 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.14.8.6 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.14.8.5 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.14.8.4 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #935):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.162
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.35
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.16
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
--
Remove nmbclusters check. We don't use the mbuf cluster. The old code also had
a bug that ixgbe_total_ports adds two every port and never decrement in
the detach path. Found by hikaru@.
The code was removed in FreeBSD when it switched to use iflib and OpenBSD
removed the code 8 years ago.
 1.14.8.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.14.8.2 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.14.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.16.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.16.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.16.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.20.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.20.2.1 10-Jun-2019  christos Sync with HEAD
 1.21.4.6 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.21.4.5 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.21.4.4 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.21.4.3 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.21.4.2 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.21.4.1 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #664):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.22.12.1 13-May-2021  thorpej Sync with HEAD.
 1.29.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.29.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.8 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.7 04-Apr-2018  msaitoh branches: 1.7.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.6 06-Dec-2017  msaitoh branches: 1.6.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.5 30-Aug-2017  msaitoh branches: 1.5.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.4 01-Dec-2016  msaitoh branches: 1.4.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.3 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.2 24-Apr-2015  msaitoh branches: 1.2.2;
Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.1 27-Mar-2015  msaitoh branches: 1.1.2; 1.1.4;
Add some forgotten files in last commit.
 1.1.4.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.4.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.4.1 27-Mar-2015  riz file ixgbe_82599.h was added on branch netbsd-7 on 2015-04-19 14:42:14 +0000
 1.1.2.4 05-Dec-2016  skrll Sync with HEAD
 1.1.2.3 06-Jun-2015  skrll Sync with HEAD
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 27-Mar-2015  skrll file ixgbe_82599.h was added on branch nick-nhusb on 2015-04-06 15:18:12 +0000
 1.2.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.8.3 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.4.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.4.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.5.2.2 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 30-Aug-2017  jdolecek file ixgbe_82599.h was added on branch tls-maxphys on 2017-12-03 11:37:29 +0000
 1.6.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.7.8.1 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.29 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.28 06-Jun-2022  msaitoh branches: 1.28.4;
s/filer/filter/ in comment. No functional change.
 1.27 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.26 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.25 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.24 03-Jan-2020  pgoyette branches: 1.24.12;
Fix some typos in comments.

From vezhlys on freenode IRC.
 1.23 27-Jun-2019  msaitoh branches: 1.23.2;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.22 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.21 11-Jun-2018  msaitoh branches: 1.21.2;
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
 1.20 04-Apr-2018  msaitoh Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.19 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.18 06-Dec-2017  msaitoh branches: 1.18.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.17 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.16 27-Jun-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.15 05-Dec-2016  msaitoh branches: 1.15.8;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.14 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.13 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.12 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.11 06-Feb-2016  riastradh branches: 1.11.2;
Avoid shadowing global `min'.
 1.10 06-Feb-2016  riastradh Avoid shadowing global `min'.
 1.9 13-Aug-2015  msaitoh Reduce diff against FreeBSD r280181.
 1.8 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.7 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.6 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.5 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.4 24-Feb-2015  msaitoh Add 82599EN_SFP and 82599_SFP_SF_QP. Not tested.
 1.3 24-Feb-2015  msaitoh Change macro name IXGBE_DEV_ID_82599_SFP_DELL to IXGBE_DEV_ID_82599_SFP_SF2.
Same as OpenBSD and Linux. No binary change.
 1.2 08-Apr-2014  christos branches: 1.2.2; 1.2.4;
Add dell's flavor (from uwe, in current-users@)
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.26;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.26.1 10-Aug-2014  tls Rebase.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.7 28-Aug-2017  skrll Sync with HEAD
 1.2.4.6 05-Feb-2017  skrll Sync with HEAD
 1.2.4.5 05-Dec-2016  skrll Sync with HEAD
 1.2.4.4 19-Mar-2016  skrll Sync with HEAD
 1.2.4.3 22-Sep-2015  skrll Sync with HEAD
 1.2.4.2 06-Jun-2015  skrll Sync with HEAD
 1.2.4.1 06-Apr-2015  skrll Sync with HEAD
 1.2.2.4 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.2.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.2.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.2.2.1 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.11.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15.8.10 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.15.8.9 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.15.8.8 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.15.8.7 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.15.8.6 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.15.8.5 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.15.8.4 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #935):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.162
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.35
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.16
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
--
Remove nmbclusters check. We don't use the mbuf cluster. The old code also had
a bug that ixgbe_total_ports adds two every port and never decrement in
the detach path. Found by hikaru@.
The code was removed in FreeBSD when it switched to use iflib and OpenBSD
removed the code 8 years ago.
 1.15.8.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.15.8.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.15.8.1 05-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #175):
sys/dev/pci/ixgbe/ix_txrx.c: 1.25-1.27
sys/dev/pci/ixgbe/ixgbe.c: 1.91-1.95
sys/dev/pci/ixgbe/ixgbe_type.h: 1.23-1.25
sys/dev/pci/ixgbe/ixgbe_api.c: 1.16
sync ixg(4) up to ixgbe.c rev. 1.95:
- Increase total number of RX buffers on multiqueue.
- Fix the partial chain check in ixgbe_rx_discard(). This bug was
added in ixgbe.c rev. 1.33.
- Fix a double free in ixgbe_rxeof().
- Print verbose output in ixgbe_update_link_status() correctly on 5Gbps
and 2.5Gbps (NBASE-T) for X550T[12] and newer.
- Change hw.ixgN.ts to hw.ixgN.thermal_test. Same as FreeBSD.
- Fix a bug that ifconfig ixgN media 1000baseT and 10Gbase-T advertised
additional unwanted speeds.
- Print PHY ID.
- Remove unused variable.
 1.18.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.18.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.18.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.21.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.21.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.2.1 10-Jun-2019  christos Sync with HEAD
 1.23.2.5 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.23.2.4 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.23.2.3 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.23.2.2 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.23.2.1 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.24.12.1 13-May-2021  thorpej Sync with HEAD.
 1.28.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.17 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.16 24-Dec-2021  msaitoh branches: 1.16.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.15 27-Jun-2019  msaitoh branches: 1.15.2;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.14 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.13 04-Apr-2018  msaitoh branches: 1.13.2;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.12 30-Mar-2018  knakahara Don't write EIMC directly. It is required to manage with struct ix_queue status.

XXX pullup-8
 1.11 06-Dec-2017  msaitoh branches: 1.11.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.10 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.9 02-Dec-2016  msaitoh branches: 1.9.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.8 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.7 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.6 13-Aug-2015  msaitoh branches: 1.6.2;
Reduce diff against FreeBSD r280181.
 1.5 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.4 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.3 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.4 05-Dec-2016  skrll Sync with HEAD
 1.1.30.3 22-Sep-2015  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.28.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.8.6 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.9.8.5 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.9.8.4 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.9.8.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.9.8.2 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.9.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.11.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.11.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.11.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.13.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.2.1 10-Jun-2019  christos Sync with HEAD
 1.15.2.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.15.2.1 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.16.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.5 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.4 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.3 24-Dec-2021  msaitoh branches: 1.3.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.2 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.14; 1.1.26;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.26.1 13-May-2021  thorpej Sync with HEAD.
 1.1.14.4 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.1.14.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.14.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.14.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.6 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.1.4.5 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.4.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file ixgbe_bypass.h was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_bypass.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.3.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.3.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.48 17-Feb-2025  andvar s/bye/byte/ in comments.
 1.47 06-Oct-2023  msaitoh branches: 1.47.6;
ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.46 06-Oct-2023  msaitoh ixg(4): Filter out spurious link up indication

- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.
 1.45 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.44 15-May-2023  msaitoh Count the number of link down events in the MAC using with LINK_DN_CNT.

- Add new event counter "link_dn_cnt" to count the number of link down
events in the MAC.
- The LINK_DN_CNT register (at 0x0403c) is described only in the
Denverton's datasheet, so use it only on ixgbe_mac_X550EM_a.
 1.43 06-Jun-2022  msaitoh branches: 1.43.4;
s/filer/filter/ in comment. No functional change.
 1.42 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.41 14-Dec-2021  msaitoh Wait longer for link after fiber MAC setup.

- FreeBSD:
aaa3af802f90d93fdffb99100fe56f0bc3dda119
96ef6eb3ae9d622906fb838c82ede3074f864cdc

DPDK:
64f1c8539c8ce99214b9eb1fb728a2c6745f3300
73247f1ced303c16987bb366d38a2d8a0fc40db4

After setting up the link on a fiber port, the maximum wait time for
the link to come up is 500 ms in ixgbe_setup_mac_link_multispeed_fiber().
On an x550 SFP+ port, this is often not sufficiently long for the link
to come up. This can result in never being able to retrieve accurate
link status for the port using rte_eth_link_get_nowait().

Increase the maximum wait time in ixgbe_setup_mac_link_multispeed_fiber()
to 1 s.
 1.40 14-Dec-2021  msaitoh Use macro. No functional change. Same as FreeBSD.
 1.39 14-Dec-2021  msaitoh Change error level in ixgbe_fc_autoneg().

- FreeBSD: f511cd22586a9c0358b86334a51e3db60ca2db01 or ix-3.3.18
DPDK: ab6ac48d483ef7f906b90f45182f2ddf3254d876

- No functional change in NetBSD.
 1.38 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.37 10-Dec-2021  msaitoh Fix infinite recursion on PCIe link down.

- FreeBSD: 8270b7174c48417a4d5f3effa4a4f4588205e687 or ix-3.3.14
- DPDK: 2d04b9e856125197ec8e967471426d56ab7efcf0

In some corner cases the functions ixgbe_clear_rar_generic and
ixgbe_clear_vmdq_generic may call one another leading to infinite
recursion.

When ixgbe_clear_vmdq_generic is called with IXGBE_CLEAR_VMDQ_ALL
flag, it's going to clear MPSAR registers, and proceed to call
ixgbe_clear_rar_generic, which in turn will clear the RAR registers,
and recursively call back ixgbe_clear_vmdq_generic. Normally, the
latter would detect that MPSAR registers have already been cleared
and terminate the recursion.

However, when PCIe link is down, and before the driver has had the
opportunity to shut itself down, all register reads return 0xFFFFFFFF,
and all register writes fail silently. In such case, because
ixgbe_clear_vmdq_generic blindly assumes that clearing MPSAR registers
succeeded, it's going to always call ixgbe_clear_rar_generic, which
in turn will always call back ixgbe_clear_vmdq_generic, creating
infinite recursion.

This patch re-reads MPSAR register values after they had been cleared.
In case of PCIe link failure, the values read will be non-zero, which
will terminate the recursion. On the other hand, under normal
circumstances the value read from MPSAR registers is going to be equal
to the value previously written, so this patch is expected not to cause
any regressions.

- Note that NetBSD doesn't support VMDQ.
 1.36 10-Dec-2021  msaitoh Remove debug error message.
 1.35 10-Dec-2021  msaitoh Remove unnecessary return value check.

FreeBSD: 3a89005394bc5d82ce9b6baa9e7f8dee362354ae
DPDK: 4b0ee6529b7897c2a08dd56669f07ac1f46a8474
 1.34 10-Dec-2021  msaitoh Add typecast for type mismatch.

FreeBSD: 994dd6328c66fc277438ad51ed074f3c52096147
DPDK: d8e52b2cf771c31b523b46852fd86225b5a2c721
 1.33 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.32 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.31 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.30 31-Aug-2020  msaitoh branches: 1.30.6;
Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional change.
 1.29 31-Aug-2020  msaitoh If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.
This change eliminate long timeout.

Reduce code duplication using with ixgbe_sfp_cage_full(hw).
 1.28 27-Aug-2020  msaitoh Minor change.

- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.27 05-Feb-2020  msaitoh No functional change:

- Add debug printf()s.
- Remove unused macros.
- Remove extra newline.
 1.26 16-Dec-2019  msaitoh branches: 1.26.2;
No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.25 25-Jul-2019  msaitoh branches: 1.25.2;
Fix VLAN filter setting. Found by KUBSan.
 1.24 25-Jul-2019  msaitoh Set FCTTV(Flow Control Transmit Timer Value) register correctly in
ixgbe_fc_enable_generic(). Found by KUBSan.
 1.23 27-Jun-2019  msaitoh Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.22 04-Apr-2018  msaitoh branches: 1.22.2;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.21 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.20 30-Mar-2018  msaitoh - Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.

Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))

Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.

- Change some functions static.
 1.19 30-Mar-2018  knakahara Don't write EIMC directly. It is required to manage with struct ix_queue status.

XXX pullup-8
 1.18 16-Mar-2018  msaitoh - Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.
 1.17 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.16 06-Dec-2017  msaitoh branches: 1.16.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.15 13-Oct-2017  msaitoh Show 2.5GBASE-T and 5GBASE-T correctly on ixv(4). Tested on a virtual function
on X550 T1.
 1.14 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.13 26-May-2017  msaitoh branches: 1.13.2;
Count Bad SFD (Start Frame Delimiter). X550 and newer have this register.
 1.12 19-Jan-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.11 05-Dec-2016  msaitoh branches: 1.11.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.10 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.9 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.8 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.7 06-Feb-2016  riastradh branches: 1.7.2;
Avoid shadowing global `min'.
 1.6 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.5 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.4 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.3 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.2 17-Apr-2014  christos branches: 1.2.2; 1.2.4;
CID 141398: Fix incorrect test
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.26;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.26.1 10-Aug-2014  tls Rebase.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.7 28-Aug-2017  skrll Sync with HEAD
 1.2.4.6 05-Feb-2017  skrll Sync with HEAD
 1.2.4.5 05-Dec-2016  skrll Sync with HEAD
 1.2.4.4 19-Mar-2016  skrll Sync with HEAD
 1.2.4.3 22-Sep-2015  skrll Sync with HEAD
 1.2.4.2 06-Jun-2015  skrll Sync with HEAD
 1.2.4.1 06-Apr-2015  skrll Sync with HEAD
 1.2.2.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.2.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.2.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.7.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.7.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.11.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.13.2.16 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.13.2.15 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.13.2.14 21-Jun-2023  martin Pullup the following revisions, requested by msaitoh in ticket #1828:

sys/dev/pci/ixgbe/ixgbe.c 1.325-1.326 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.44
sys/dev/pci/ixgbe/ixgbe_type.h 1.56

- PCI device ID 0x15c8 also uses X557-AT PHY, so create the thermal
sensor sysctl for it, too.
- Count the number of link down events in the MAC using with
LINK_DN_CNT register.
 1.13.2.13 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.13.2.12 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.13.2.11 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.13.2.10 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1600):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

-

Minor change.
- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.13.2.9 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.13.2.8 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.13.2.7 05-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367, to pull up the following
revisions:

sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixgbe.c 1.180,1.203-1.204,
1.207-1.208 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.55
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.10
sys/dev/pci/ixgbe/ixgbe_common.c 1.25
sys/dev/pci/ixgbe/ixv.c 1.129-1.130

- X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
- An interrupt might not arrive when a module is inserted. When an link
status change interrupt occurred and the driver still regard SFP as
unplugged, issue the module softint before issuing LSC softint.
- Add 10000BASE-LX media if it's 1000BASE-BX.
- printf -> device_printf
- Avoid undefined behavior of VLAN filter setting.
- Simplify code.
- Fix typo in unused code.
- Fix typo in comment. Found by Wataru Ashihara.
 1.13.2.6 01-Aug-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1313:

sys/dev/pci/ixgbe/ixgbe_type.h 1.41
sys/dev/pci/ixgbe/ixgbe.c 1.194,1.197-1.199
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.24
sys/dev/pci/ixgbe/ixv.c 1.121,1.124-1.125

- Avoid undefined behavior of interrupt vector setting.
- Avoid undefined behavior of TX/RX queue statistics calculation.
- Avoid undefined behavior of X550EM's PHY accesses.
- Avoid undefined behavior of Flow Control Transmit Timer setting.
- Don't call {ixgbe,ixv}_stop() twice while detaching.
 1.13.2.5 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.13.2.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.13.2.3 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.13.2.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.13.2.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.16.2.4 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.16.2.3 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.16.2.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.16.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.22.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.25.2.9 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.25.2.8 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.25.2.7 21-Jun-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1647:

sys/dev/pci/ixgbe/ixgbe.c 1.325-1.326 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.44
sys/dev/pci/ixgbe/ixgbe_type.h 1.56

- PCI device ID 0x15c8 also uses X557-AT PHY, so create the thermal
sensor sysctl for it, too.
- Count the number of link down events in the MAC using with
LINK_DN_CNT register.
 1.25.2.6 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.25.2.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.25.2.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.25.2.3 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1070):

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

-

Minor change.
- Print "X550EM X" instead of "X550EM" for Xeon D devices.
- Fix typo in comment. Same as FreeBSD.
 1.25.2.2 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.25.2.1 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.26.2.1 29-Feb-2020  ad Sync with head.
 1.30.6.2 01-Aug-2021  thorpej Sync with HEAD.
 1.30.6.1 13-May-2021  thorpej Sync with HEAD.
 1.43.4.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.43.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.43.4.1 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #202):

sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.56
sys/dev/pci/ixgbe/ixgbe.c: revision 1.325
sys/dev/pci/ixgbe/ixgbe.c: revision 1.326
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.44

Use thermal sensor code for IXGBE_DEV_ID_X550EM_A_10G_T, too.
PCI device ID 0x15c8 also use X557-AT PHY, so create the thermal sensor
sysctl for it, too.

Count the number of link down events in the MAC using with LINK_DN_CNT.
- Add new event counter "link_dn_cnt" to count the number of link down
events in the MAC.
- The LINK_DN_CNT register (at 0x0403c) is described only in the
Denverton's datasheet, so use it only on ixgbe_mac_X550EM_a.
 1.47.6.1 02-Aug-2025  perseant Sync with HEAD
 1.18 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.17 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.16 24-Dec-2021  msaitoh branches: 1.16.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.15 10-Dec-2021  msaitoh Remove unnecessary return value check.

FreeBSD: 3a89005394bc5d82ce9b6baa9e7f8dee362354ae
DPDK: 4b0ee6529b7897c2a08dd56669f07ac1f46a8474
 1.14 27-Jun-2019  msaitoh branches: 1.14.2;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.13 04-Apr-2018  msaitoh branches: 1.13.2;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.12 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.11 30-Mar-2018  msaitoh - Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.

Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))

Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.

- Change some functions static.
 1.10 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.9 06-Dec-2017  msaitoh branches: 1.9.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.8 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.7 01-Dec-2016  msaitoh branches: 1.7.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.6 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.5 05-Aug-2015  msaitoh branches: 1.5.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.4 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.3 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.4 05-Dec-2016  skrll Sync with HEAD
 1.1.30.3 22-Sep-2015  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.28.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.8.8 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.7.8.7 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.7.8.6 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.7.8.5 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.7.8.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.7.8.3 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.7.8.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.7.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.9.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.9.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.13.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.2.3 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.14.2.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.14.2.1 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.16.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.16.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.15 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.14 06-Oct-2023  msaitoh ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.

From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.
 1.13 24-Dec-2021  msaitoh branches: 1.13.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.12 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.11 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.10 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.9 03-Sep-2018  riastradh branches: 1.9.4; 1.9.16;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.8 04-Apr-2018  msaitoh branches: 1.8.2;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.7 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.6 06-Dec-2017  msaitoh branches: 1.6.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.5 30-Aug-2017  msaitoh branches: 1.5.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.4 02-Dec-2016  msaitoh branches: 1.4.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.3 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.2 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.1 05-Aug-2015  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
Add some files.
 1.1.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.2 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.1 05-Aug-2015  snj file ixgbe_dcb.c was added on branch netbsd-7 on 2016-06-14 08:42:34 +0000
 1.1.2.3 05-Dec-2016  skrll Sync with HEAD
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 05-Aug-2015  skrll file ixgbe_dcb.c was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.4.8.5 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.4.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.4.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.4.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.4.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.5.2.2 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 30-Aug-2017  jdolecek file ixgbe_dcb.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.6.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.8.2.1 10-Jun-2019  christos Sync with HEAD
 1.9.16.1 13-May-2021  thorpej Sync with HEAD.
 1.9.4.3 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.9.4.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.9.4.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.13.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.9 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.8 15-Dec-2021  msaitoh Change DCB credit parameters. No functional change.

- From FreeBSD ix-3.3.24.
- No functional change because NetBSD doesn't support DCB.
 1.7 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.6 04-Apr-2018  msaitoh branches: 1.6.8; 1.6.20;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.5 06-Dec-2017  msaitoh branches: 1.5.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.4 30-Aug-2017  msaitoh branches: 1.4.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.3 01-Dec-2016  msaitoh branches: 1.3.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.2 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.1 05-Aug-2015  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
Add some files.
 1.1.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.2 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.1 05-Aug-2015  snj file ixgbe_dcb.h was added on branch netbsd-7 on 2016-06-14 08:42:34 +0000
 1.1.2.3 05-Dec-2016  skrll Sync with HEAD
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 05-Aug-2015  skrll file ixgbe_dcb.h was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.3.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.3.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.3.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.3.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 30-Aug-2017  jdolecek file ixgbe_dcb.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.5.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.6.20.1 13-May-2021  thorpej Sync with HEAD.
 1.6.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.6.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.13 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.12 24-Dec-2021  msaitoh branches: 1.12.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.11 15-Dec-2021  msaitoh Remove dead code. No functional change.

FreeBSD: 0b487fb4547ad1a939be0d523e555557c94b7cd1
DPDK: a6395d471e14e5a7432875dad8fb3533238c5167
 1.10 10-Dec-2021  msaitoh Add typecast for type mismatch.

FreeBSD: 994dd6328c66fc277438ad51ed074f3c52096147
DPDK: d8e52b2cf771c31b523b46852fd86225b5a2c721
 1.9 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.8 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.7 04-Apr-2018  msaitoh branches: 1.7.8; 1.7.20;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.6 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.5 06-Dec-2017  msaitoh branches: 1.5.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.4 30-Aug-2017  msaitoh branches: 1.4.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.3 01-Dec-2016  msaitoh branches: 1.3.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.2 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.1 05-Aug-2015  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
Add some files.
 1.1.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.2 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.1 05-Aug-2015  snj file ixgbe_dcb_82598.c was added on branch netbsd-7 on 2016-06-14 08:42:34 +0000
 1.1.2.3 05-Dec-2016  skrll Sync with HEAD
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 05-Aug-2015  skrll file ixgbe_dcb_82598.c was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.3.8.5 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.3.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.3.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.3.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.3.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 30-Aug-2017  jdolecek file ixgbe_dcb_82598.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.5.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.7.20.1 13-May-2021  thorpej Sync with HEAD.
 1.7.8.3 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.7.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.7.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.12.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.8 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.7 19-May-2021  msaitoh No functional change:

- Add NetBSD RCS IDs.
- KNF.
 1.6 04-Apr-2018  msaitoh branches: 1.6.8; 1.6.20; 1.6.22;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.5 06-Dec-2017  msaitoh branches: 1.5.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.4 30-Aug-2017  msaitoh branches: 1.4.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.3 01-Dec-2016  msaitoh branches: 1.3.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.2 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.1 05-Aug-2015  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
Add some files.
 1.1.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.2 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.1 05-Aug-2015  snj file ixgbe_dcb_82598.h was added on branch netbsd-7 on 2016-06-14 08:42:34 +0000
 1.1.2.3 05-Dec-2016  skrll Sync with HEAD
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 05-Aug-2015  skrll file ixgbe_dcb_82598.h was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.3.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.3.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.3.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.3.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 30-Aug-2017  jdolecek file ixgbe_dcb_82598.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.5.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.6.22.1 31-May-2021  cjep sync with head
 1.6.20.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.6.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.6.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.12 15-Jul-2023  andvar fix tripple "p" (ppp) to double "p" (pp) in some words in comments.
 1.11 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.10 10-Dec-2021  msaitoh Add typecast for type mismatch.

FreeBSD: 994dd6328c66fc277438ad51ed074f3c52096147
DPDK: d8e52b2cf771c31b523b46852fd86225b5a2c721
 1.9 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.8 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.7 04-Apr-2018  msaitoh branches: 1.7.8; 1.7.20;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.6 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.5 06-Dec-2017  msaitoh branches: 1.5.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.4 30-Aug-2017  msaitoh branches: 1.4.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.3 01-Dec-2016  msaitoh branches: 1.3.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.2 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.1 05-Aug-2015  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
Add some files.
 1.1.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.2 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.1 05-Aug-2015  snj file ixgbe_dcb_82599.c was added on branch netbsd-7 on 2016-06-14 08:42:34 +0000
 1.1.2.3 05-Dec-2016  skrll Sync with HEAD
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 05-Aug-2015  skrll file ixgbe_dcb_82599.c was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.3.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.3.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.3.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.3.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 30-Aug-2017  jdolecek file ixgbe_dcb_82599.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.5.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.7.20.1 13-May-2021  thorpej Sync with HEAD.
 1.7.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.7.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.8 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.7 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.6 04-Apr-2018  msaitoh branches: 1.6.8; 1.6.20;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.5 06-Dec-2017  msaitoh branches: 1.5.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.4 30-Aug-2017  msaitoh branches: 1.4.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.3 01-Dec-2016  msaitoh branches: 1.3.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.2 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.1 05-Aug-2015  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
Add some files.
 1.1.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.2 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.1 05-Aug-2015  snj file ixgbe_dcb_82599.h was added on branch netbsd-7 on 2016-06-14 08:42:34 +0000
 1.1.2.3 05-Dec-2016  skrll Sync with HEAD
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 05-Aug-2015  skrll file ixgbe_dcb_82599.h was added on branch nick-nhusb on 2015-09-22 12:05:59 +0000
 1.3.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.3.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.3.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.3.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.4.2.2 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 30-Aug-2017  jdolecek file ixgbe_dcb_82599.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.5.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.6.20.1 13-May-2021  thorpej Sync with HEAD.
 1.6.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.6.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.5 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.4 24-Dec-2021  msaitoh branches: 1.4.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.3 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.2 04-Apr-2018  msaitoh branches: 1.2.8; 1.2.20;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.6.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.4.6 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.5 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.4.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file ixgbe_fdir.h was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_fdir.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.2.20.1 13-May-2021  thorpej Sync with HEAD.
 1.2.8.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.2.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.2.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.4.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.4 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.3 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.2 06-Dec-2018  msaitoh branches: 1.2.4; 1.2.16;
Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.8.1 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.4.5 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.4.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file ixgbe_features.h was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_features.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.2.16.1 13-May-2021  thorpej Sync with HEAD.
 1.2.4.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.2.4.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.19 25-Jan-2022  msaitoh Use atomic_{load,store}_relaxed() for event counters.
 1.18 18-Jan-2022  msaitoh Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.17 18-Jan-2022  msaitoh Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
 1.16 24-Dec-2021  msaitoh Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.15 24-Dec-2021  msaitoh Restore some mailbox related functions. No functional change.

- Revert some part of ixgbe_mbx.c rev. 1.7 and ixgbe_mbx.h rev. 1.11.
It's also part of FreeBSD 3f66b96d8658f8721e6b1c6f035611bec44675b9.
- This change reduces diff against FreeBSD ix-3.3.14.
 1.14 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.13 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.12 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.11 27-Jun-2019  msaitoh branches: 1.11.2; 1.11.14;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.10 04-Apr-2018  msaitoh branches: 1.10.2;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.9 06-Dec-2017  msaitoh branches: 1.9.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.8 03-Oct-2017  msaitoh Make mailbox statistic counters evcnt(9).
Example:
> ixv0 message TXs 23 0 misc
> ixv0 message RXs 2911 0 misc
> ixv0 ACKs 23 0 misc
> ixv0 REQs 22 0 misc
> ixv0 RSTs 0 0 misc
 1.7 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.6 05-Dec-2016  msaitoh branches: 1.6.8;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.5 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.3 02-Apr-2015  msaitoh branches: 1.3.2;
Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.3 05-Feb-2017  skrll Sync with HEAD
 1.1.30.2 05-Dec-2016  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.8.7 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.6.8.6 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.6.8.5 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.6.8.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.6.8.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.6.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.6.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.9.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.10.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11.14.1 13-May-2021  thorpej Sync with HEAD.
 1.11.2.4 02-Feb-2022  martin Pull up the following revisions (requested by msaitoh in ticket #1424):

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.305 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixv.c 1.178 via patch

Use atomic_{load,store}_relaxed() for event counters.
 1.11.2.3 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.11.2.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.11.2.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.20 06-Oct-2023  msaitoh ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.

PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.
 1.19 24-Dec-2021  msaitoh branches: 1.19.4;
Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.18 24-Dec-2021  msaitoh Restore some mailbox related functions. No functional change.

- Revert some part of ixgbe_mbx.c rev. 1.7 and ixgbe_mbx.h rev. 1.11.
It's also part of FreeBSD 3f66b96d8658f8721e6b1c6f035611bec44675b9.
- This change reduces diff against FreeBSD ix-3.3.14.
 1.17 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.16 24-Dec-2021  msaitoh Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}.

- Sync with FreeBSD ix-3.3.18.
- No functional change.
 1.15 24-Dec-2021  msaitoh Move some definitions. No functional change. Part of FreeBSD ix-3.3.18.
 1.14 27-Jun-2019  msaitoh branches: 1.14.2;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.13 04-Apr-2018  msaitoh branches: 1.13.2;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.12 06-Dec-2017  msaitoh branches: 1.12.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.11 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.10 02-Dec-2016  msaitoh branches: 1.10.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.9 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r289238:
- Add support for sysctl knobs to live tune the per interrupt rx/tx packet
processing limits in ixgbe(4)
- Some others (netmap, etc.)
 1.8 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r285590:
- Fix igxbe SRIOV VF (if_ixv) initialization bugs. The MAC address for
an if_ixv instance can now set at creation time, and the receive ring
tail pointer is correctly initialized (previously, things still worked
because the receive ring tail pointer was being fixed up as a side
effect of other activity).
 1.7 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r283881:
- SRIOV support (not enabled because NetBSD doesn't support it).
 1.6 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.5 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.4 24-Apr-2015  msaitoh branches: 1.4.2;
Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.3 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.3 05-Dec-2016  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.4.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.8.6 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.10.8.5 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.10.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.10.8.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.10.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.10.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.12.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.13.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.2.3 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.14.2.2 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.14.2.1 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.19.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.17 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.16 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.15 25-Jun-2020  msaitoh branches: 1.15.6;
Reduce ixgbe's busy loop using with workqueue and kpause.

- Use workqueue instead of softint to make some functions sleepable.
- Use new workqueue and enqueue it in ixgbe_local_timer() and
ixgbe_recovery_mode_timer() to make them sleepable.
- Make new ixgbe_delay() and use it. This functions sleeps if the time is
more than equals 1 tick. If it's not, do delay().
 1.14 17-Apr-2020  msaitoh No functional change:
- modify comment
- whitespace fix
 1.13 01-Feb-2020  riastradh branches: 1.13.4;
Use atomic_load_acquire for FreeBSDish atomic_load_acq_uint shim.
 1.12 21-Jan-2020  msaitoh Fix the freeing code for some error paths. Found and tested by Patrick Welche.
 1.11 20-Jan-2020  msaitoh Free jumbo mem structure correctly. Found by yamaguchi@ using with LOCKDEBUG.
 1.10 04-Sep-2019  msaitoh branches: 1.10.2;
printf -> device_printf
 1.9 06-Dec-2018  msaitoh branches: 1.9.4;
Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.8 31-Jul-2018  msaitoh Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.7 25-Apr-2018  msaitoh branches: 1.7.2;
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
 1.6 01-Jun-2017  chs branches: 1.6.2; 1.6.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.5 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.3 04-Feb-2015  msaitoh branches: 1.3.2;
Fix mutex related problem reported by Uwe Toenjes in PR#49328:
- Revert ixgbe_netbsd.c rev. 1.2
- make CORE_LOCK adaptive
- Release spin lock while reinitializing the jumb buffer structure.
 1.2 28-Jan-2015  christos PR/49328: Uwe Toenjes: This driver allocates memory always with NOWAIT, except
in the NetBSD-specific code. This happens from ioctl, and usually there is
enough memory there since we just freed our resources and we are getting them
back. We could even check and not do it again if sizes did not change, but
this is how the rest of the code is structured so we follow suit.
XXX: pullup-7
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.3 28-Aug-2017  skrll Sync with HEAD
 1.1.30.2 05-Dec-2016  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.8.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.6.8.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.8.1 02-May-2018  pgoyette Synch with HEAD
 1.6.2.7 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.6.2.6 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.6.2.5 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.6.2.4 05-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367, to pull up the following
revisions:

sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixgbe.c 1.180,1.203-1.204,
1.207-1.208 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.55
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.10
sys/dev/pci/ixgbe/ixgbe_common.c 1.25
sys/dev/pci/ixgbe/ixv.c 1.129-1.130

- X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
- An interrupt might not arrive when a module is inserted. When an link
status change interrupt occurred and the driver still regard SFP as
unplugged, issue the module softint before issuing LSC softint.
- Add 10000BASE-LX media if it's 1000BASE-BX.
- printf -> device_printf
- Avoid undefined behavior of VLAN filter setting.
- Simplify code.
- Fix typo in unused code.
- Fix typo in comment. Found by Wataru Ashihara.
 1.6.2.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.6.2.2 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.6.2.1 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.7.2.4 21-Apr-2020  martin Sync with HEAD
 1.7.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1 10-Jun-2019  christos Sync with HEAD
 1.9.4.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.9.4.3 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.9.4.2 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.9.4.1 05-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #180):

sys/dev/pci/ixgbe/ixv.c: revision 1.130
sys/dev/pci/ixgbe/ixgbe.c: revision 1.207
sys/dev/pci/ixgbe/ixgbe.c: revision 1.208
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.55
sys/dev/pci/ixgbe/ixv.c: revision 1.129
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.10

printf -> device_printf

Set IFM_1000_BX10 correctly.

Use aprint_*() in the attach function.
 1.10.2.2 29-Feb-2020  ad Sync with head.
 1.10.2.1 25-Jan-2020  ad Sync with head.
 1.13.4.1 20-Apr-2020  bouyer Sync with HEAD
 1.15.6.1 13-May-2021  thorpej Sync with HEAD.
 1.17 16-Sep-2022  knakahara ixg(4) add an option for Tx to use deferred softint regardless of whether can get txq lock or not.

That imporve (7%) and stabilize throughput. But that can cause
latency degradation, so off by default.

ok'ed by msaitoh@n.o.
 1.16 25-Jan-2022  msaitoh Fix compile error for non __HAVE_ATOMIC64_LOADSTORE arch.
 1.15 25-Jan-2022  msaitoh Use atomic_{load,store}_relaxed() for event counters.
 1.14 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.13 19-May-2021  msaitoh No functional change:

- Add NetBSD RCS IDs.
- KNF.
 1.12 09-Mar-2021  msaitoh branches: 1.12.4; 1.12.6;
Modify some parameters to reduce packet dropping.

- Background: ixgbe doesn't use common MCLGET() interface and use the
driver specific cluster allocation mechanism (jcl). The cluster is
pre-allocated with a fixed number and the current number per queue
is num_rx_desc * 2 (2048*2=4096). It's too small. It also has a problem
that the max length of the pcq which is used in the TX path is big
(4096). Example:

100M <----- [ixg0 ixg1] <----- 1G
2048 TX descs <--- 4096 pcqs <---- 2048 RX descs

If a machine forwards a traffic from 1G interface to 100M interface,
It would require 2048+4096+2048=8192 descriptors, but the current number
is 2048*2=4096. It's too small. Even if the both interface's link speed
is the same and only small number of packet is queued in the pcq, 4096
jcl is small because 2048(RX)+TX(2048)=4096. If jcl is exhausted, not only
forwarding from ixg1 to ixg0 is dropped, but also another forwarding path
from ixg1 to another interface(e.g. wm0) is also dropped. Sockets also
queue packets, so if a lot of sockets are used and/or a socket buffer
size is changed to bigger one, it'll also become a problem. If the jcl
is exhausted, evcnt(9) counter "ixgX qY Rx no jumbo mbuf" is incremented.
Example:
vmstat -ev | grep ixg1 | grep "no jumbo"
ixg1 q0 Rx no jumbo mbuf 0 0 misc
ixg1 q1 Rx no jumbo mbuf 0 0 misc
ixg1 q2 Rx no jumbo mbuf 141326 0 misc
ixg1 q3 Rx no jumbo mbuf 0 0 misc


- To solve this problem:
- Add new config parameter IXGBE_JCLNUM_MULTI and set the default to 3
(2048 * 3). The minimum number is 2. The total number of jcl per queue
is available with hw.ixgN.num_jcl_per_queue sysctl.
- Reduce the max length of the pcq() which is used in the TX path from
4096 to 2048.

- Reviewed by knakahara@ and ozaki-r@.

- TODO: Use MCLGET().
 1.11 05-Mar-2019  msaitoh branches: 1.11.4; 1.11.12;
Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.10 21-Dec-2018  msaitoh Remove ETHERCAP_VLAN_HWFILTER.
 1.9 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.8 25-Apr-2018  msaitoh branches: 1.8.2;
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
 1.7 08-Feb-2017  msaitoh branches: 1.7.6; 1.7.12;
Enable TX multiqueue by default on both ixg(4) and ixv(4).
 1.6 01-Feb-2017  msaitoh TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h
 1.5 01-Dec-2016  msaitoh branches: 1.5.2;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.3 24-Apr-2015  msaitoh branches: 1.3.2;
Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.2 17-Apr-2014  christos branches: 1.2.2; 1.2.4;
CID/1008347, CID/1008348, CID/1008349: overflow before widen
CID/1203198, CID/1203199: Uninitialized scalar variable
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.26;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.26.1 10-Aug-2014  tls Rebase.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.4 28-Aug-2017  skrll Sync with HEAD
 1.2.4.3 05-Feb-2017  skrll Sync with HEAD
 1.2.4.2 05-Dec-2016  skrll Sync with HEAD
 1.2.4.1 06-Jun-2015  skrll Sync with HEAD
 1.2.2.1 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.3.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.3.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.5.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.7.12.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7.12.1 02-May-2018  pgoyette Synch with HEAD
 1.7.6.6 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.7.6.5 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.7.6.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.7.6.3 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.7.6.2 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.7.6.1 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.8.2.1 10-Jun-2019  christos Sync with HEAD
 1.11.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.11.4.4 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.11.4.3 02-Feb-2022  martin Pull up the following revisions (requested by msaitoh in ticket #1424):

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.305 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixv.c 1.178 via patch

Use atomic_{load,store}_relaxed() for event counters.
 1.11.4.2 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.11.4.1 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.12.6.1 31-May-2021  cjep sync with head
 1.12.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.6 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.5 10-Dec-2021  msaitoh branches: 1.5.4;
ifdef D(ebug)? From FreeBSD ix-3.3.14.
 1.4 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.3 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.2 27-Jun-2019  msaitoh branches: 1.2.2; 1.2.14;
Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.8;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.8.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.6 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.5 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.4.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file ixgbe_netmap.c was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_netmap.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.2.14.1 13-May-2021  thorpej Sync with HEAD.
 1.2.2.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.2.2.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.2.2.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.5.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.3 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.2 30-Apr-2021  msaitoh branches: 1.2.14;
Add NetBSD RCS IDs. No functional change.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.14; 1.1.26;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.26.1 13-May-2021  thorpej Sync with HEAD.
 1.1.14.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.14.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.4 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file ixgbe_netmap.h was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_netmap.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.2.14.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.9 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.8 24-Dec-2021  msaitoh branches: 1.8.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.7 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.6 17-Dec-2019  msaitoh branches: 1.6.12;
Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.
 1.5 16-Dec-2019  msaitoh No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.4 04-Apr-2018  msaitoh branches: 1.4.2; 1.4.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.3 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.2 30-Aug-2017  msaitoh branches: 1.2.2; 1.2.4;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1 02-Dec-2016  msaitoh branches: 1.1.2; 1.1.4; 1.1.12;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.1.12.7 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.12.6 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.12.5 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.12.4 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.1.12.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.1.12.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.1.12.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.4.1 02-Dec-2016  pgoyette file ixgbe_osdep.c was added on branch pgoyette-localcount on 2017-01-07 08:56:40 +0000
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 02-Dec-2016  skrll file ixgbe_osdep.c was added on branch nick-nhusb on 2016-12-05 10:55:17 +0000
 1.2.4.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.2.4.1 15-Mar-2018  pgoyette Synch with HEAD
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 30-Aug-2017  jdolecek file ixgbe_osdep.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.4.8.5 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.4.8.4 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.4.8.3 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.4.8.2 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.4.8.1 24-Dec-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #580):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.217
sys/dev/pci/ixgbe/ixgbe.c: revision 1.218
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.6
sys/dev/pci/ixgbe/ixv.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.25

Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.

Add missing core lock in ixgbe_handle_mod().
 1.4.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.12.1 13-May-2021  thorpej Sync with HEAD.
 1.8.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.31 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.30 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.29 19-Aug-2021  msaitoh Use m_adj(ETHER_ALIGN) more. Tested by me (amd64,aarch64) and rin (alpha).

- Align with ETHER_ALIGN everywhere where mbuf is allocated.
- Remove extra setting of M_PKTHDR. No functional change.
- Add comment.
 1.28 01-Sep-2020  msaitoh Fix a panic on shutdown on a machine which use the recovery mode timer.

The recovery mode timer is first issued by the callout and it schedule
the workqueue. The workqueue then reschedule the callout. It's hard to
stop both of them without race only with callout_stop() and workqueue_wait.
To solve this problem. add new "detaching" flag and use it.

The situation is almost the same as schedule_wqs_ok for the local_timer's
callout and workqueue, but the difference is that the local_timer isn't
required to run if the interface is not up. If it's not important to prevent
running timer while !IFF_UP, the flag can be integrated into one.
 1.27 25-Jun-2020  msaitoh Reduce ixgbe's busy loop using with workqueue and kpause.

- Use workqueue instead of softint to make some functions sleepable.
- Use new workqueue and enqueue it in ixgbe_local_timer() and
ixgbe_recovery_mode_timer() to make them sleepable.
- Make new ixgbe_delay() and use it. This functions sleeps if the time is
more than equals 1 tick. If it's not, do delay().
 1.26 11-Jun-2020  msaitoh Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem was
only on X550*. Not tested on big endian machine.
 1.25 17-Dec-2019  msaitoh Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.
 1.24 16-Dec-2019  msaitoh No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.23 31-Jul-2018  msaitoh branches: 1.23.6;
Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.22 25-Apr-2018  msaitoh branches: 1.22.2;
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
 1.21 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.20 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.19 06-Dec-2017  msaitoh branches: 1.19.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.18 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.17 18-Jan-2017  msaitoh branches: 1.17.6;
Now we can use multiqueue. It's default on ixg(4). Not yet for ixv(4).
 1.16 05-Dec-2016  msaitoh branches: 1.16.2;
- Fix wol_enable, fc and wufc sysctls to work correctly.
- Fix RCS Id.
 1.15 05-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.14 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.13 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.12 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.11 25-Nov-2016  msaitoh Remove #ifdef NETBSD_MSI_OR_MSIX to be simple. ixv(4) isn't attached if
__HAVE_PCI_MSI_MSIX isn't set because MSI-X must be used.
 1.10 13-Aug-2015  msaitoh branches: 1.10.2;
- Add MSI/MSI-X support. The multiqueue function is not supported yet.
- Make ixv.c compilable. _NOT_TESTED_YET_
 1.9 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.8 05-Aug-2015  msaitoh Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent panic.
 1.7 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.6 14-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r243716:
- A lot of bugfixes. Some of them are realted to multi queue and those
have not affected in NetBSD because we have not used it yet.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Improve performance.
 1.5 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.4 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.3 18-Mar-2014  riastradh branches: 1.3.4; 1.3.6;
Merge riastradh-drm2 to HEAD.
 1.2 17-Jul-2013  soren Fix ixb(4) build.
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.24;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.24.1 23-Jul-2013  riastradh sync with HEAD
 1.1.16.1 28-Aug-2013  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.6.5 05-Feb-2017  skrll Sync with HEAD
 1.3.6.4 05-Dec-2016  skrll Sync with HEAD
 1.3.6.3 22-Sep-2015  skrll Sync with HEAD
 1.3.6.2 06-Jun-2015  skrll Sync with HEAD
 1.3.6.1 06-Apr-2015  skrll Sync with HEAD
 1.3.4.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.3.4.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.3.4.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.10.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.10.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.16.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.17.6.9 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.17.6.8 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.17.6.7 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.17.6.6 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.17.6.5 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.17.6.4 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.17.6.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.17.6.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.17.6.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.19.2.4 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.19.2.3 02-May-2018  pgoyette Synch with HEAD
 1.19.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.19.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.22.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.22.2.1 10-Jun-2019  christos Sync with HEAD
 1.23.6.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.23.6.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.23.6.3 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.23.6.2 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.23.6.1 24-Dec-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #580):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.217
sys/dev/pci/ixgbe/ixgbe.c: revision 1.218
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.6
sys/dev/pci/ixgbe/ixv.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.25

Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.

Add missing core lock in ixgbe_handle_mod().
 1.29 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.28 15-Dec-2021  msaitoh Match X550_PHY_ID correctly on X550.

- Sync with FreeBSD ix-3.3.18.
- phy_id's revision field is cleared, so use new X550_PHY_ID.
- Before this commit, phy_id was set to ixgbe_phy_cu_unknown on X550.
Now it's set to ixgbe_phy_aq.
 1.27 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.26 10-Dec-2021  msaitoh Move increments after evaluations.

FreeBSD: dc11ba4eb3fe5cce615f361de83e85e07005ca24 or ix-3.3.14
DPDK: 390445ec30b4c52a3d2887c3d2a202d9cf37ea8e

The retry variable was being incremented before it was evaluated by the
subsequent conditional against the maximum retries to figure out which
message to print. So we'll move the increment op to the end.
 1.25 10-Dec-2021  msaitoh Remove unnecessary return value check.

FreeBSD: 3a89005394bc5d82ce9b6baa9e7f8dee362354ae
DPDK: 4b0ee6529b7897c2a08dd56669f07ac1f46a8474
 1.24 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.23 31-Aug-2020  msaitoh branches: 1.23.6;
If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.
This change eliminate long timeout.

Reduce code duplication using with ixgbe_sfp_cage_full(hw).
 1.22 31-Aug-2020  msaitoh Fix 82598 SFP+ problems.

On 82598, SFP+'s MOD_ABS isn't connected to the MAC's GPIO pin, so we can't
call ixgbe_sfp_cage_full(). Always issue TASK_MOD from ixgbe_handle_timer()
on 82598.

Fix ixgbe_identify_sfp_module_generic() for ixgbe_phy_nl. In the driver,
hw->phy.type sometimes be compared with ixgbe_phy_nl.
In ixgbe_identify_sfp_module_generic(), hw->phy.type may be overridden with
another value. For ixgbe_phy_nl, some code don't override phy.type but others
were not. Make it consistently keep ixgbe_phy_nl. This change fixes a problem
that ixgbe_is_sfp() change the return value true to false when any SFP+
devices are connected to the cage on 82598 and never recover from it.

Don't schedule MSF(multi speed fiber) task from ixgbe_handle_mod() on 82598.
This task is only for devices which support multi speed fiber and 82598
doesn't support it. Before ixgbe.c rev. 1.237, ixgbe_handle_mod() isn't
called on 82598 because 82598 has no SFP+ module insertion/removal interrupt.
ixgbe.c rev. 1.237 changed to call the function via timer on 82598.
This change fixes a bug that 82598 DA interface's link flaps.
 1.21 17-Apr-2020  msaitoh No functional change:
- modify comment
- whitespace fix
 1.20 23-Dec-2019  msaitoh branches: 1.20.6;
Add recovery code for unsupported SFP+.

Before this commit:
If an unsuppored SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.19 16-Dec-2019  msaitoh No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.18 06-Dec-2018  msaitoh branches: 1.18.4;
Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.17 04-Apr-2018  msaitoh branches: 1.17.2;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.16 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.15 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.14 06-Dec-2017  msaitoh branches: 1.14.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.13 07-Nov-2017  msaitoh Fix a bug that X550T(1) didn't linkup if it forces 100BaseTX-FDX.
Popular switches and OSes don't use auto-negotiation if the media is
100BASE-TX (and 10BASE-T). Do the same thig.

Another fix is required for Denverton's _T device which use firmware.
 1.12 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.11 19-Jan-2017  msaitoh branches: 1.11.6;
Reduce diff against FreeBSD. No functional change.
 1.10 05-Dec-2016  msaitoh branches: 1.10.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.9 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.8 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.7 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.6 05-Aug-2015  msaitoh branches: 1.6.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.5 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.4 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.3 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.2 17-Apr-2014  christos branches: 1.2.2; 1.2.4;
CIT 744275: Increase max_retry so we retry once.
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.26;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.26.1 10-Aug-2014  tls Rebase.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.5 05-Feb-2017  skrll Sync with HEAD
 1.2.4.4 05-Dec-2016  skrll Sync with HEAD
 1.2.4.3 22-Sep-2015  skrll Sync with HEAD
 1.2.4.2 06-Jun-2015  skrll Sync with HEAD
 1.2.4.1 06-Apr-2015  skrll Sync with HEAD
 1.2.2.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.2.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.2.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.6.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.6.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.6.9 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.11.6.8 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.11.6.7 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.11.6.6 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.11.6.5 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.11.6.4 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.11.6.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.11.6.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.11.6.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.14.2.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.14.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.14.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.17.2.3 21-Apr-2020  martin Sync with HEAD
 1.17.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.17.2.1 10-Jun-2019  christos Sync with HEAD
 1.18.4.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.18.4.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.18.4.3 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.18.4.2 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #664):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.18.4.1 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.20.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.23.6.1 13-May-2021  thorpej Sync with HEAD.
 1.13 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.12 31-Aug-2020  msaitoh If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.
This change eliminate long timeout.

Reduce code duplication using with ixgbe_sfp_cage_full(hw).
 1.11 04-Apr-2018  msaitoh branches: 1.11.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.10 06-Dec-2017  msaitoh branches: 1.10.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.9 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.8 02-Dec-2016  msaitoh branches: 1.8.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.7 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.6 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.5 05-Aug-2015  msaitoh branches: 1.5.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.4 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.3 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.4 05-Dec-2016  skrll Sync with HEAD
 1.1.30.3 22-Sep-2015  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.28.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.8.3 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.8.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.8.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.10.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.11.8.1 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.6 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.5 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.4 04-Apr-2018  msaitoh branches: 1.4.8; 1.4.20;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.3 16-Feb-2018  knakahara branches: 1.3.2;
Apply RSS utility to ixg(4) and ixv(4).

ok by msaitoh@n.o.
 1.2 06-Dec-2017  msaitoh branches: 1.2.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.1 30-Aug-2017  msaitoh branches: 1.1.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_rss.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.2.2.6 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.2.2.5 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.2.2.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.2.2.3 26-Feb-2018  snj Pull up following revision(s) (requested by knakahara in ticket #567):
distrib/sets/lists/comp/mi: 1.2182-1.2183
sys/dev/pci/if_wm.c: 1.564
sys/dev/pci/ixgbe/ixgbe.c: 1.122
sys/dev/pci/ixgbe/ixgbe_rss.h: 1.3
sys/dev/pci/ixgbe/ixv.c: 1.78
sys/net/Makefile: 1.35-1.36
sys/net/files.net: 1.15
sys/net/rss_config.c: 1.1
sys/net/rss_config.h: 1.1
Introduce very simple Receive Side Scaling (RSS) utility.
ok by msaitoh@n.o.
--
Apply RSS utility to wm(4).
ok by msaitoh@n.o.
--
Apply RSS utility to ixg(4) and ixv(4).
ok by msaitoh@n.o.
--
Fix build failure, sorry.
--
Currently, it is not necessary to install rss_config.h. Pointed out by msaitoh@n.o.
 1.2.2.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.2.2.1 06-Dec-2017  snj file ixgbe_rss.h was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.3.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.4.20.1 13-May-2021  thorpej Sync with HEAD.
 1.4.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.4.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.6 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.5 24-Dec-2021  msaitoh branches: 1.5.4;
Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.4 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.3 04-Apr-2018  msaitoh branches: 1.3.8; 1.3.20;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.2 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.1 30-Aug-2017  msaitoh branches: 1.1.2; 1.1.4; 1.1.6;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.1.6.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.6.1 15-Mar-2018  pgoyette Synch with HEAD
 1.1.4.7 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.1.4.6 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.1.4.5 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.1.4.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.1.4.3 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.1.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.1.4.1 30-Aug-2017  snj file ixgbe_sriov.h was added on branch netbsd-8 on 2017-12-21 19:28:54 +0000
 1.1.2.2 03-Dec-2017  jdolecek update from HEAD
 1.1.2.1 30-Aug-2017  jdolecek file ixgbe_sriov.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.3.20.1 13-May-2021  thorpej Sync with HEAD.
 1.3.8.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.3.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.3.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.5.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.62 15-Nov-2023  msaitoh ixgbe: Clear the WTHRESH bit field before writing it.
 1.61 11-Oct-2023  msaitoh ixg(4): Print DEVICE_CAPS register.
 1.60 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.59 06-Oct-2023  msaitoh ixg(4): Add 82599 LS once again.

- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.
 1.58 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.57 06-Oct-2023  msaitoh ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.

PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.
 1.56 15-May-2023  msaitoh Count the number of link down events in the MAC using with LINK_DN_CNT.

- Add new event counter "link_dn_cnt" to count the number of link down
events in the MAC.
- The LINK_DN_CNT register (at 0x0403c) is described only in the
Denverton's datasheet, so use it only on ixgbe_mac_X550EM_a.
 1.55 24-Dec-2021  msaitoh branches: 1.55.4;
Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.54 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.53 24-Dec-2021  msaitoh Move some definitions. No functional change. Part of FreeBSD ix-3.3.18.
 1.52 15-Dec-2021  msaitoh Match X550_PHY_ID correctly on X550.

- Sync with FreeBSD ix-3.3.18.
- phy_id's revision field is cleared, so use new X550_PHY_ID.
- Before this commit, phy_id was set to ixgbe_phy_cu_unknown on X550.
Now it's set to ixgbe_phy_aq.
 1.51 10-Dec-2021  msaitoh Add some unused macros. Sync with FreeBSD ix-3.3.14.
 1.50 01-Nov-2021  andvar fix typos, mainly in words minimum and maximum, but also few others.
 1.49 19-May-2021  msaitoh No functional change:

- Add NetBSD RCS IDs.
- KNF.
 1.48 26-Dec-2020  msaitoh branches: 1.48.4; 1.48.6;
Disable some interrupt in ixgbe_{legacy_irq,msix_admin}() to prevent log spam.
 1.47 26-Dec-2020  msaitoh Disable/enable the OTHER interrupts correctly.

The OTHER interrupt was not blocked correctly when MSI-X is used.
ixgbe.c rev. 1.260 added new mutex to avoid the race but it didn't
disable the interrupt itself.

Calling ixgbe_enable_intr() enables all interrupts, so it's not good to
call it when some interrupt sources should not be enabled (e.g.:
calling ixgbe_enable_intr() in ixgbe_handle_admin() enables queue
interrupt).

IXGBE_REQUEST_TASK_NEED_ACKINTR doesn't work as expected because
ixgbe_handle_admin() can't know which task is enqueued from the
interrupt context and can't re-enable a specific EIMS bit.

Solve the above three problems by the following two changes:

- MSI-X: Disable the OTHER interrupts in the biginning of
ixgbe_msix_admin().

- Set mask bits correctly at the end of ixgbe_legacy_irq() and
ixgbe_msix_admin() using with eim_orig, eims_enable and eims_disable.

- Remove IXGBE_REQUEST_TASK_NEED_ACKINTR and add
IXGBE_REQUEST_TASK_{MOD,MSF}_WOI.
 1.46 11-Dec-2020  msaitoh Don't use EIMC_OTHER bit because it's read only other than 82598.

Documents say:

82598:
All of bit 31(OTHER bit) of EIxx are reserved. In reality, at least
EIMS_OTHER and EIMC_OTHER exist and the OTHER interrupt doesn't work
without EIMS_OTHER.

Other than 82598:
EIMS_OTHER is read only and EIMC_OTHER doesn't exist. If one of
bit 29..16 is set, EIMS_OTHER is set to 1 (Note that bit 30(TCP timer
isn't included)). Even if write bit 31 of EIMC to 1, it's ignored
(EIMS_OTHER doesn't set).

We introduced new spin mutex in ixgbe.c rev. 1.260, so it's OK to remove
EIMC_OTHER stuff. We already set EIMS_OTHER in if_init(), so keep it for
82598. No functional change other than 82598.

Another solution is to control bit 30..16 directly to mask/unmask interrupt
instead of the mutex.

TODO:
Some MSI-X interrupt(LSC, module insertion/removal etc.)'s mask/unmask
code between ixgbe_msix_admin() and ixgbe_handle_admin() may be wrong.
It'll be fixed later.
 1.45 31-Aug-2020  msaitoh branches: 1.45.2;
If an SFP+ module is not inserted, don't try to access SFP+ EEPROM.
This change eliminate long timeout.

Reduce code duplication using with ixgbe_sfp_cage_full(hw).
 1.44 23-Dec-2019  msaitoh Add recovery code for unsupported SFP+.

Before this commit:
If an unsuppored SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.43 20-Sep-2019  msaitoh - Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- If a multicast entry has range, use ALLMULTI like others.
- Remove ixv_set_promisc() and use ixv_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter(). Same as ixgbe.c.
- The promisc mode can't be enabled if the PF is not in promisc mode.
Identify that state and report it as "the PF may not in promisc mode"
(though it might not be perfect).
 1.42 12-Sep-2019  msaitoh Add support ALLMULTI on ixv(4):
- Negotiate API version up to 1.3.
- On linux's PF driver implementation, the PF replies VF's XCAST_MODE_ALLMULTI
message not with NACK but with ACK even if the virtual function is NOT
marked "trust" and act as XCAST_MODE_"MULTI". If ixv(4) simply check the
return vaule of update_xcast_mode(XCAST_MODE_ALLMULTI), SIOCSADDMULTI
success and the user may have trouble with some addresses. Fortunately,
the Linux's PF driver's "ACK" message has not XCAST_MODE_"ALL"MULTI but
XCAST_MODE_MULTI, so we can check this state by checking if the send
message's argument and the reply message's argument are different.
- Noy yet for PROMISC.
 1.41 24-Jul-2019  msaitoh branches: 1.41.2;
Fix some problems found by KUBSan:
- Set TQSM and RQSM (TX/RX queue statistics mapping) correctly.
- Set IVAR (Interrupt Vector Allocation Register) correctly in
ixgbe_set_ivar().
- Define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART correctly. This macro is used
in ixgbe_restart_an_internal_phy_x550em().
- Define IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN correctly. This macro is used
in ixgbe_setup_ixfi_x550em_x().
- Define IXGBE_SB_IOSF_CTRL_BUSY correctly. This macro is used in
ixgbe_iosf_wait() (X550EM only).
 1.40 02-Jul-2019  msaitoh Sync with FreeBSD ix-3.3.10 part 1. No functional change in this part:
- "(u64)1" -> "1ULL"
- Add some not-yet-used register definitions.
 1.39 27-Jun-2019  msaitoh Sync with FreeBSD ix-3.3.8 part 1. No functional change in this part:
- Move ixgbe_toggle_txdctl() to ixgbe_common.c and modify a bit.
No functional change because this function is currently used for SR-IOV
and it's not used in NetBSD.
- Some modification to match the latest netmap API.
- Modify ixgbe_hic_unlocked(). No functional change because neither
IXGBE_HOST_INTERFACE_APPLY_UPDATE_CMD(0x38) nor
IXGBE_HOST_INTERFACE_SHADOW_RAM_READ_CMD(0x31) are used.
- Add ixgbe_clear_mbx(). No functional change because this function is not
used yet.
- Add some not-yet-used register definitions.
- Whitespace fixes.
 1.38 05-Mar-2019  msaitoh NetBSD currently uses traffic class 0 only. Other traffic classes aren't used
yet. When IXGBE_TC_COUNTER_NUM is set to lower than IXGBE_DCB_MAX_TRAFFIC_CLASS
(e.g. 1), other traffic classes' counters are not used. It means we don't
generate evcnt for them and don't add the values in
ixgbe_update_stats_counters().
 1.37 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.36 06-Jul-2018  msaitoh Add force_10_100_autonego sysctl. The default vaule is 0(false).
This sysctl is only for 550EM_a with PHY firmware for a while.
 1.35 11-Jun-2018  msaitoh branches: 1.35.2;
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
 1.34 04-Apr-2018  msaitoh Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.33 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.32 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.31 20-Feb-2018  msaitoh branches: 1.31.2;
- Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:

sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)

Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:

int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |

The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.

While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!

This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.

(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.

- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.

XXX pullup-8
 1.30 06-Dec-2017  msaitoh Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.29 04-Oct-2017  msaitoh Add 2.5GBASE-T and 5GBASE-T support. (forgotten in the last commit)
 1.28 03-Oct-2017  msaitoh Make mailbox statistic counters evcnt(9).
Example:
> ixv0 message TXs 23 0 misc
> ixv0 message RXs 2911 0 misc
> ixv0 ACKs 23 0 misc
> ixv0 REQs 22 0 misc
> ixv0 RSTs 0 0 misc
 1.27 14-Sep-2017  msaitoh Quick hack to fix ixv(4)'s hardware counter. ixgbe_rx_checksum() passes
"struct ixgbe_hw_stats *" even if its a virtual function. The layout between
ixgbe_hw_stats and ixgbevf_hw_stats are different, so ixgbe_rx_checksum()
wrote wrong area if a device is a virtual function. To fix this problem with
small change, move the location of ipcs, ipcs_bad, l4cs and l4cs_bad of
struct ixgbe(vf)_hw_stats to the same location at the biggining of the struct.
 1.26 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.25 28-Jun-2017  msaitoh Add IXGBE_TIPG_IPGT_MASK and IXGBE_PAP_PACE_MASK for packet pacing.
 1.24 27-Jun-2017  msaitoh Add some register definitions for X550 and newer.
 1.23 23-Jun-2017  msaitoh Remove unused "cached_autoc". It was removed in ixgbe_82599.c rev.1.12
(FreeBSD r280182).
 1.22 02-Jun-2017  msaitoh branches: 1.22.2;
- Print NVM Image Version, PHY FW Revision, NVM Map version and OEM NVM
Image version
- s/TrackID/ETrackID/
 1.21 26-May-2017  msaitoh Count Bad SFD (Start Frame Delimiter). X550 and newer have this register.
 1.20 18-May-2017  msaitoh - Count "Total Packets Missed" by evcnt(9)
- Call evcnt_attach_dynamic()/detach() for stats->mngpdc
(Management Packets Dropped).
- Make stats->rnbc (Receive No Buffers) evcnt(9). Only 82598 has this register.
- Set RQSMR, TQSM (or TQSMR on 82598) to count qprc, qptc, qbrc, qbtc and qprdc
in each queue counter. Without this change, all queue's counts are counted in
queue 0's. Even if with this change, only MPC[0] is counted and other MPCs
are not counted.
 1.19 24-Feb-2017  msaitoh branches: 1.19.4;
Print mac.type and the TrackID.
 1.18 19-Jan-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.17 05-Dec-2016  msaitoh branches: 1.17.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.16 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.15 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.14 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.13 13-Aug-2015  msaitoh branches: 1.13.2;
Reduce diff against FreeBSD r280181.
 1.12 13-Aug-2015  msaitoh - Add MSI/MSI-X support. The multiqueue function is not supported yet.
- Make ixv.c compilable. _NOT_TESTED_YET_
 1.11 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.10 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.9 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.8 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.7 24-Feb-2015  msaitoh Add 82599EN_SFP and 82599_SFP_SF_QP. Not tested.
 1.6 24-Feb-2015  msaitoh Change macro name IXGBE_DEV_ID_82599_SFP_DELL to IXGBE_DEV_ID_82599_SFP_SF2.
Same as OpenBSD and Linux. No binary change.
 1.5 24-Feb-2015  msaitoh Enclose macro argument correctly. Same as *BSDs. No binary change.
 1.4 24-Feb-2015  msaitoh Modify comments to make difference among *BSDs small. No binary change.
 1.3 24-Feb-2015  msaitoh Change tabs and spaces to make difference among *BSDs small. No binary change.
 1.2 08-Apr-2014  christos branches: 1.2.2; 1.2.4;
Add dell's flavor (from uwe, in current-users@)
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16; 1.1.26;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.26.1 10-Aug-2014  tls Rebase.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.6 28-Aug-2017  skrll Sync with HEAD
 1.2.4.5 05-Feb-2017  skrll Sync with HEAD
 1.2.4.4 05-Dec-2016  skrll Sync with HEAD
 1.2.4.3 22-Sep-2015  skrll Sync with HEAD
 1.2.4.2 06-Jun-2015  skrll Sync with HEAD
 1.2.4.1 06-Apr-2015  skrll Sync with HEAD
 1.2.2.4 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.2.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.2.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.2.2.1 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.13.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.13.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.19.4.1 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.22.2.22 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1933:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.22.2.21 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.22.2.20 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.22.2.19 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.22.2.18 21-Jun-2023  martin Pullup the following revisions, requested by msaitoh in ticket #1828:

sys/dev/pci/ixgbe/ixgbe.c 1.325-1.326 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.44
sys/dev/pci/ixgbe/ixgbe_type.h 1.56

- PCI device ID 0x15c8 also uses X557-AT PHY, so create the thermal
sensor sysctl for it, too.
- Count the number of link down events in the MAC using with
LINK_DN_CNT register.
 1.22.2.17 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.22.2.16 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.22.2.15 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.22.2.14 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1708:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.22.2.13 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.22.2.12 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.22.2.11 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1389:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213 via patch
sys/dev/pci/ixgbe/ixv.c 1.131-1.138 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58 via patch
share/man/man4/ixv.4 1.5 via patch

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
 1.22.2.10 01-Aug-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1313:

sys/dev/pci/ixgbe/ixgbe_type.h 1.41
sys/dev/pci/ixgbe/ixgbe.c 1.194,1.197-1.199
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.24
sys/dev/pci/ixgbe/ixv.c 1.121,1.124-1.125

- Avoid undefined behavior of interrupt vector setting.
- Avoid undefined behavior of TX/RX queue statistics calculation.
- Avoid undefined behavior of X550EM's PHY accesses.
- Avoid undefined behavior of Flow Control Transmit Timer setting.
- Don't call {ixgbe,ixv}_stop() twice while detaching.
 1.22.2.9 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.22.2.8 01-Apr-2019  martin Pull up the following, requested by msaitohin ticket #1225:

sys/dev/pci/ixgbe/ixgbe.c 1.175-1.178
sys/dev/pci/ixgbe/ixv.c 1.110-1.111 via patch

- NetBSD currently uses traffic class 0 only. Other traffic classes
aren't used yet. When IXGBE_TC_COUNTER_NUM is set to lower than
IXGBE_DCB_MAX_TRAFFIC_CLASS (e.g. 1), other traffic classes' counters
are not used. It means we don't generate evcnt for them and don't
add the values in ixgbe_update_stats_counters().
- It's not required to calculate unused queues' statistics.
- Fix a bug that the VLAN HW tagging function is not correctly disabled
when all vlan is detached.
- Fix a bug that VLAN HW tagging function is not correctly controlled
on 82598.
- Control VLAN HW filter function correctly. Note that currently
VLAN HW filter function doesn't work because NetBSD doesn't support
it yet.
- Don't clear IXGBE_VLNCTRL_CFIEN bit When ETHERCAP_VLAN_HWFILTER is
set. I think it's not required (and Linux doesn't do it). This change
has no effect to NetBSD because ETHERCAP_VLAN_HWFILTER is not
supported yet.
 1.22.2.7 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.22.2.6 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #935):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.162
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.35
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.16
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
--
Remove nmbclusters check. We don't use the mbuf cluster. The old code also had
a bug that ixgbe_total_ports adds two every port and never decrement in
the detach path. Found by hikaru@.
The code was removed in FreeBSD when it switched to use iflib and OpenBSD
removed the code 8 years ago.
 1.22.2.5 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.22.2.4 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.22.2.3 26-Feb-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #592):
sys/dev/pci/ixgbe/ixv.c: revision 1.79
sys/dev/pci/ixgbe/ixgbe.h: revision 1.30
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.31
sys/dev/pci/ixgbe/ixgbe.c: revision 1.120
sys/dev/pci/ixgbe/ixgbe.c: revision 1.121
sys/dev/pci/ixgbe/ixgbe.c: revision 1.123
sys/dev/pci/ixgbe/ixgbe.c: revision 1.124
sys/dev/pci/ixgbe/ixgbe.c: revision 1.125
sys/dev/pci/ixgbe/ixgbe.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.80
sys/dev/pci/ixgbe/ixv.c: revision 1.81
CID-1427719: Integer handling issues (BAD_SHIFT). Print bus/slot info
correctly on 82599_SFP_SF_QP(DID 0x154a) and 82599_QSFP_SF_QP(DID 0x1558).
Fix a bug that RX may stall on heavy load on ixg(4). ixgbe_rxeof() has loop
limit and the function returns true if a packet are still in the RX ring.
ixgbe_handle_que() didn't check the return value. Check the return vaule
and issue a softint.
This bug is derived from FreeBSD and ixv(4) has no this bug.
XXX pullup-8
Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().
XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
- Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:
sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)
Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:
int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |
The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.
While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!
This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.
(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.
- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.
XXX pullup-8
Increment rxr->packets correctly in ixgbe_rxeof() to calculate ITR value
of AIM (Auto Interrupt Moderation) correctly. See also ixgbe.c rev. 1.124.
XXX pullup-8
Improve a comment about reading EICS register defined write-only by spec.
It seems that is workaround for silicon errata.
ok by msaitoh@n.o.
- Apply ixgbe.c rev. 1.124 to ixv.c. Fix a bug that RX may stall on heavy load
on ixv(4) derived from FreeBSD's AIM (Auto Interrupt Moderation) bug.
ITR_INTERVAL value must be larger than 4us.
- The bitfield of EITR register is different between 82598 and others.
ixv.c had a bug that it accessed 82598's way even though only 82599 and
newer support virtual function. Fix it using with new ixv_eitr_write()
function.
Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.22.2.2 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.22.2.1 05-Aug-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #175):
sys/dev/pci/ixgbe/ix_txrx.c: 1.25-1.27
sys/dev/pci/ixgbe/ixgbe.c: 1.91-1.95
sys/dev/pci/ixgbe/ixgbe_type.h: 1.23-1.25
sys/dev/pci/ixgbe/ixgbe_api.c: 1.16
sync ixg(4) up to ixgbe.c rev. 1.95:
- Increase total number of RX buffers on multiqueue.
- Fix the partial chain check in ixgbe_rx_discard(). This bug was
added in ixgbe.c rev. 1.33.
- Fix a double free in ixgbe_rxeof().
- Print verbose output in ixgbe_update_link_status() correctly on 5Gbps
and 2.5Gbps (NBASE-T) for X550T[12] and newer.
- Change hw.ixgN.ts to hw.ixgN.thermal_test. Same as FreeBSD.
- Fix a bug that ifconfig ixgN media 1000baseT and 10Gbase-T advertised
additional unwanted speeds.
- Print PHY ID.
- Remove unused variable.
 1.31.2.5 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.31.2.4 28-Jul-2018  pgoyette Sync with HEAD
 1.31.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.31.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.31.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.35.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.35.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.2.1 10-Jun-2019  christos Sync with HEAD
 1.41.2.12 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1792:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.41.2.11 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.41.2.10 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.41.2.9 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.41.2.8 21-Jun-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1647:

sys/dev/pci/ixgbe/ixgbe.c 1.325-1.326 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.44
sys/dev/pci/ixgbe/ixgbe_type.h 1.56

- PCI device ID 0x15c8 also uses X557-AT PHY, so create the thermal
sensor sysctl for it, too.
- Count the number of link down events in the MAC using with
LINK_DN_CNT register.
 1.41.2.7 02-Jun-2022  martin Pull up the following revisions, all via patch, requested by msaitoh
in ticket #1459:

sys/dev/pci/ixgbe/ixgbe.c 1.261,1.265-1.268,1.273,1.275-1.277,
1.312,1.316-1.319 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.182

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Fix typos in comment.
- KNF.
 1.41.2.6 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.41.2.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.41.2.4 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1374:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.41.2.3 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.41.2.2 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #664):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.41.2.1 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.45.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.45.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.48.6.1 31-May-2021  cjep sync with head
 1.48.4.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.55.4.6 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #563):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.110
sys/dev/pci/ixgbe/ixgbe.c: revision 1.345
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.111
sys/dev/pci/ixgbe/ixgbe.c: revision 1.346
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.112
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.62
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.113
sys/dev/pci/ixgbe/ixgbe.c: revision 1.348
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.114
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.115
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.116
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.105
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.106
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.107
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.108
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.109
sys/dev/pci/ixgbe/ixv.c: revision 1.193
sys/dev/pci/ixgbe/ixv.c: revision 1.195
sys/dev/pci/ixgbe/ixv.c: revision 1.196
sys/dev/pci/ixgbe/ixgbe.h: revision 1.94
sys/dev/pci/ixgbe/ixgbe.h: revision 1.95
sys/dev/pci/ixgbe/ixgbe.h: revision 1.96
sys/dev/pci/ixgbe/ixgbe.h: revision 1.97
sys/dev/pci/ixgbe/ixgbe.h: revision 1.98

ixgbe: Fix comment. No functional change.
ixgbe: Whitespace. No functional change.
ixgbe(4): Move assignment of TXD. NFCI.
ixgbe(4): Modify comment. No functional change.
ixgbe_tx_ctx_setup() may or may not consume one TX descriptor.
ixv(4): Remove unused IFF_OACTIVE. No functional change.
ixgbe: Clear the WTHRESH bit field before writing it.
ixgbe: Modify for the readability. No functional change.
ixgbe: micro-optimize ixgbe_txeof()
Update txr->tx_avail and txr->txr_no_space outside the loop in ixgbe_txeof().
ixgbe: Update if_opackets outside the loop in ixgbe_txeof().
ixgbe: micro-optimize ixgbe_txeof()
Update txr->packets outside the loop in ixgbe_txeof().
ixgbe: Use #ifdef IXGBE_FDIR more
Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
ixgbe: Simplify. No functional change.
The descriptor ring size and the alignment are tested in the attach
function, so it's not required to use roundup2(size, DBA_ALIGN).
ixgbe: Use kmem_zalloc() instead of malloc(,M_ZERO).
ixgbe: Remove unused to reduce the size of struct rx_ring.
ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
ixgbe: Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring and rx_ring
because of the alignment.
ixgbe: Use #ifdef RSC
This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.55.4.5 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #420):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.340
sys/dev/pci/ixgbe/ixgbe.c: revision 1.341
sys/dev/pci/ixgbe/ixgbe.c: revision 1.342
sys/dev/pci/ixgbe/ixgbe.c: revision 1.343
sys/dev/pci/ixgbe/ixgbe.c: revision 1.344
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.61
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.104
sys/dev/pci/ixgbe/ixv.c: revision 1.190
sys/dev/pci/ixgbe/ixv.c: revision 1.191
sys/dev/pci/ixgbe/ixv.c: revision 1.192
sys/dev/pci/ixgbe/ixgbe.h: revision 1.93

ixg(4): Print DEVICE_CAPS register.

ixgbe: Whitespace. No functional change.

ixg(4): Don't print wrong error message about ixgbe_num_queues.
Don't override the ixgbe_num_queues global variable. It's the default
value of the number of queues and should not override it because it
will be referenced by later device attach. For example, the number of
MSI-X vector is 64 on X540 and 18 on 82599. When both cards are inserted
to a machine that the number of CPU is 24 and X540 is probed earlier,
ixgbe_num_queues is overridden to 24 and the following error message is
printed when attaching 82599:
ixg2: autoconfiguration error: ixgbe_num_queues (24) is too large,
using reduced amount (17).

Note that the number of queues is in sc->num_queuss and referenced
by hw.ixgN.num_queues sysctl.

ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.

ixgbe: Whitespace. No functional change.
 1.55.4.4 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.55.4.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.55.4.2 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.55.4.1 21-Jun-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #202):

sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.56
sys/dev/pci/ixgbe/ixgbe.c: revision 1.325
sys/dev/pci/ixgbe/ixgbe.c: revision 1.326
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.44

Use thermal sensor code for IXGBE_DEV_ID_X550EM_A_10G_T, too.
PCI device ID 0x15c8 also use X557-AT PHY, so create the thermal sensor
sysctl for it, too.

Count the number of link down events in the MAC using with LINK_DN_CNT.
- Add new event counter "link_dn_cnt" to count the number of link down
events in the MAC.
- The LINK_DN_CNT register (at 0x0403c) is described only in the
Denverton's datasheet, so use it only on ixgbe_mac_X550EM_a.
 1.33 06-Oct-2023  msaitoh ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.

PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.
 1.32 06-Oct-2023  msaitoh ixv(4): Improve error check.

ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.
 1.31 24-Dec-2021  msaitoh branches: 1.31.4;
Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.30 24-Dec-2021  msaitoh Whitespace fix. Remove old comment. No functional change.

- From FreeBSD ixv-1.5.22.
 1.29 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.28 24-Dec-2021  msaitoh Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}.

- Sync with FreeBSD ix-3.3.18.
- No functional change.
 1.27 30-Apr-2021  msaitoh Add missing __KERNEL_RCSID().
 1.26 20-Jan-2021  msaitoh branches: 1.26.4;
The max number of queue(pair) is not 7 but 8. Inspired by DPDK.
 1.25 30-Nov-2020  msaitoh s/ we we / we /
 1.24 22-Jul-2020  msaitoh branches: 1.24.2;
s/reseting/resetting/
 1.23 05-Feb-2020  msaitoh No functional change:

- Fix typos.
- Remove extra newline.
 1.22 20-Sep-2019  msaitoh branches: 1.22.2;
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- If a multicast entry has range, use ALLMULTI like others.
- Remove ixv_set_promisc() and use ixv_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter(). Same as ixgbe.c.
- The promisc mode can't be enabled if the PF is not in promisc mode.
Identify that state and report it as "the PF may not in promisc mode"
(though it might not be perfect).
 1.21 12-Sep-2019  msaitoh Add support ALLMULTI on ixv(4):
- Negotiate API version up to 1.3.
- On linux's PF driver implementation, the PF replies VF's XCAST_MODE_ALLMULTI
message not with NACK but with ACK even if the virtual function is NOT
marked "trust" and act as XCAST_MODE_"MULTI". If ixv(4) simply check the
return vaule of update_xcast_mode(XCAST_MODE_ALLMULTI), SIOCSADDMULTI
success and the user may have trouble with some addresses. Fortunately,
the Linux's PF driver's "ACK" message has not XCAST_MODE_"ALL"MULTI but
XCAST_MODE_MULTI, so we can check this state by checking if the send
message's argument and the reply message's argument are different.
- Noy yet for PROMISC.
 1.20 12-Sep-2019  msaitoh - Make SIOCADDMULTI returns ENOSPC when the Ethenet multicast address list
exceeds the limit.
- State "Ethernet" multicast address.
- Use macro.
 1.19 11-Sep-2019  msaitoh Print message when the number of multicast addresses exceeded the limit (30).
 1.18 02-Jul-2019  msaitoh branches: 1.18.2;
Other than IXGBE_VF_RESET should wait ACK, so use ixgbevf_write_msg_read_ack()
instead of write_posted() in ixgbe_update_mc_addr_list_vf().
 1.17 04-Apr-2018  msaitoh branches: 1.17.2;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.16 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.15 06-Dec-2017  msaitoh branches: 1.15.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.14 13-Oct-2017  msaitoh Show 2.5GBASE-T and 5GBASE-T correctly on ixv(4). Tested on a virtual function
on X550 T1.
 1.13 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.12 02-Dec-2016  msaitoh branches: 1.12.8;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.11 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r289238:
- Add support for sysctl knobs to live tune the per interrupt rx/tx packet
processing limits in ixgbe(4)
- Some others (netmap, etc.)
 1.10 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r285590:
- Fix igxbe SRIOV VF (if_ixv) initialization bugs. The MAC address for
an if_ixv instance can now set at creation time, and the receive ring
tail pointer is correctly initialized (previously, things still worked
because the receive ring tail pointer was being fixed up as a side
effect of other activity).
 1.9 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r283881:
- SRIOV support (not enabled because NetBSD doesn't support it).
 1.8 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.7 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.6 06-Feb-2016  riastradh branches: 1.6.2;
Convert bool to target type before shift.
 1.5 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.4 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.3 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.2 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.5 05-Dec-2016  skrll Sync with HEAD
 1.1.30.4 19-Mar-2016  skrll Sync with HEAD
 1.1.30.3 22-Sep-2015  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.28.2 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.1 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12.8.10 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.12.8.9 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.12.8.8 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.12.8.7 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.12.8.6 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.12.8.5 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.12.8.4 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1389:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213 via patch
sys/dev/pci/ixgbe/ixv.c 1.131-1.138 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58 via patch
share/man/man4/ixv.4 1.5 via patch

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
 1.12.8.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.12.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.12.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.15.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.17.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.2.7 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.18.2.6 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.18.2.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.18.2.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.18.2.3 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.18.2.2 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.18.2.1 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.22.2.1 29-Feb-2020  ad Sync with head.
 1.24.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.24.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.26.4.1 13-May-2021  thorpej Sync with HEAD.
 1.31.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.18 06-Oct-2023  msaitoh ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.

PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.
 1.17 24-Jan-2022  msaitoh branches: 1.17.4;
Use 32bit for 32bit counter.
 1.16 19-Jan-2022  msaitoh Improve ixv(4)'s some event counters.

- The virtual function's packet counter registers are not cleared on read.
To solve this problem, <REGNAME>, base_<REGNAME>, last_<REGNAME> and
saved_reset_<REGNAME> are in the struct ixgbevf_hw_stats and some
functions use them. However, saved_reset_<REGNAME> is set but never
referenced. base_<REGNAME> is set and it's only used for
saved_reset_<REGNAME>, so it's also unused in reality. THERE ARE A LOT
OF GARBAGE. Remove them.
- Call ixv_init_stats() in ixv_clear_evcnt() to make ifconfig -z ixvN
work correctly.
 1.15 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.14 12-Sep-2019  msaitoh - Make SIOCADDMULTI returns ENOSPC when the Ethenet multicast address list
exceeds the limit.
- State "Ethernet" multicast address.
- Use macro.
 1.13 04-Apr-2018  msaitoh branches: 1.13.2; 1.13.8;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.12 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.11 06-Dec-2017  msaitoh branches: 1.11.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.10 14-Sep-2017  msaitoh Quick hack to fix ixv(4)'s hardware counter. ixgbe_rx_checksum() passes
"struct ixgbe_hw_stats *" even if its a virtual function. The layout between
ixgbe_hw_stats and ixgbevf_hw_stats are different, so ixgbe_rx_checksum()
wrote wrong area if a device is a virtual function. To fix this problem with
small change, move the location of ipcs, ipcs_bad, l4cs and l4cs_bad of
struct ixgbe(vf)_hw_stats to the same location at the biggining of the struct.
 1.9 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.8 10-Feb-2017  msaitoh branches: 1.8.6;
- Both mbuf_defrag_failed and m_defrag_failed existed. Remove m_defrag_failed.
- rx_irq, dropped_pkts, morerx, moretx and txloops counters are uncounted, so
remove them.
- Count handleq in ixv_handle_que().
- Detach event counters correctly.
- Set some per-queue event names correctly.
 1.7 01-Dec-2016  msaitoh branches: 1.7.2;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.6 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.5 24-Apr-2015  msaitoh branches: 1.5.2;
Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.4 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.3 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.2 10-Mar-2015  msaitoh Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
 1.1 12-Aug-2011  dyoung branches: 1.1.12; 1.1.28; 1.1.30;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.30.4 28-Aug-2017  skrll Sync with HEAD
 1.1.30.3 05-Dec-2016  skrll Sync with HEAD
 1.1.30.2 06-Jun-2015  skrll Sync with HEAD
 1.1.30.1 06-Apr-2015  skrll Sync with HEAD
 1.1.28.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.28.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.28.1 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.1.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.5.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.6.7 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.8.6.6 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.8.6.5 29-Jan-2022  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1725:

sys/dev/pci/ixgbe/ixgbe_vf.h 1.16-1.17
sys/dev/pci/ixgbe/ixv.c 1.176-1.177

Make ifconfig -z ixvN clear event counter.
 1.8.6.4 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1389:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213 via patch
sys/dev/pci/ixgbe/ixv.c 1.131-1.138 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58 via patch
share/man/man4/ixv.4 1.5 via patch

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
 1.8.6.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.8.6.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.8.6.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.11.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.11.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.13.8.4 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.13.8.3 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.13.8.2 29-Jan-2022  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1408:

sys/dev/pci/ixgbe/ixgbe_vf.h 1.16-1.17
sys/dev/pci/ixgbe/ixv.c 1.176-1.177

Make ifconfig -z ixvN clear event counter.
 1.13.8.1 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.13.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.24 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.23 24-Dec-2021  msaitoh branches: 1.23.4;
Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.22 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.21 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.20 10-Dec-2021  msaitoh Remove unnecessary return value check.

FreeBSD: 3a89005394bc5d82ce9b6baa9e7f8dee362354ae
DPDK: 4b0ee6529b7897c2a08dd56669f07ac1f46a8474
 1.19 19-May-2021  msaitoh No functional change:

- Add NetBSD RCS IDs.
- KNF.
 1.18 30-Apr-2021  msaitoh branches: 1.18.2;
Add missing __KERNEL_RCSID().
 1.17 13-Nov-2020  msaitoh branches: 1.17.4;
Fix typo in a debug message.
 1.16 11-Jun-2018  msaitoh branches: 1.16.8; 1.16.16;
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
 1.15 04-Apr-2018  msaitoh Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.14 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.13 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.12 06-Dec-2017  msaitoh branches: 1.12.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.11 04-Oct-2017  msaitoh branches: 1.11.2;
Add 2.5GBASE-T and 5GBASE-T support. (forgotten in the last commit)
 1.10 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.9 19-Jan-2017  msaitoh branches: 1.9.6;
Reduce diff against FreeBSD. No functional change.
 1.8 05-Dec-2016  msaitoh branches: 1.8.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.7 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.6 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.5 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.4 05-Aug-2015  msaitoh branches: 1.4.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.3 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.2 02-Apr-2015  msaitoh branches: 1.2.2; 1.2.4;
Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.1 27-Mar-2015  msaitoh Add some forgotten files in last commit.
 1.2.4.4 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.4.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.4.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.2.4.1 02-Apr-2015  riz file ixgbe_x540.c was added on branch netbsd-7 on 2015-04-19 14:42:14 +0000
 1.2.2.6 05-Feb-2017  skrll Sync with HEAD
 1.2.2.5 05-Dec-2016  skrll Sync with HEAD
 1.2.2.4 22-Sep-2015  skrll Sync with HEAD
 1.2.2.3 06-Jun-2015  skrll Sync with HEAD
 1.2.2.2 06-Apr-2015  skrll Sync with HEAD
 1.2.2.1 02-Apr-2015  skrll file ixgbe_x540.c was added on branch nick-nhusb on 2015-04-06 15:18:12 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.9.6.9 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.9.6.8 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.9.6.7 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.9.6.6 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.9.6.5 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.9.6.4 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #935):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.162
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.35
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.16
Apply changes of FreeBSD ix-3.2.18.tgz:
- Add IXGBE_DEV_ID_82599_LS(0x154f) support.
- Increase timeout for newer than ixgbe_mac_X550 (i.e. Xeon-D and Denverton)
in ixgbe_acquire_swfw_sync_X540().
- Add some unused macros (IXGBE_FW_LESM_*).
--
Remove nmbclusters check. We don't use the mbuf cluster. The old code also had
a bug that ixgbe_total_ports adds two every port and never decrement in
the detach path. Found by hikaru@.
The code was removed in FreeBSD when it switched to use iflib and OpenBSD
removed the code 8 years ago.
 1.9.6.3 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.9.6.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.9.6.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.11.2.2 03-Dec-2017  jdolecek update from HEAD
 1.11.2.1 04-Oct-2017  jdolecek file ixgbe_x540.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.12.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.12.2.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.12.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.16.16.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.16.8.5 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.16.8.4 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.16.8.3 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.16.8.2 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.16.8.1 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.17.4.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.17.4.1 13-May-2021  thorpej Sync with HEAD.
 1.18.2.1 31-May-2021  cjep sync with head
 1.23.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.10 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.9 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.8 04-Apr-2018  msaitoh branches: 1.8.8; 1.8.20;
Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.7 06-Dec-2017  msaitoh branches: 1.7.2;
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.6 30-Aug-2017  msaitoh branches: 1.6.2;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.5 01-Dec-2016  msaitoh branches: 1.5.8;
Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.4 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.3 05-Aug-2015  msaitoh branches: 1.3.2;
Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.2 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.1 27-Mar-2015  msaitoh branches: 1.1.2; 1.1.4;
Add some forgotten files in last commit.
 1.1.4.4 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.1.4.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.1.4.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.1.4.1 27-Mar-2015  riz file ixgbe_x540.h was added on branch netbsd-7 on 2015-04-19 14:42:15 +0000
 1.1.2.5 05-Dec-2016  skrll Sync with HEAD
 1.1.2.4 22-Sep-2015  skrll Sync with HEAD
 1.1.2.3 06-Jun-2015  skrll Sync with HEAD
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 27-Mar-2015  skrll file ixgbe_x540.h was added on branch nick-nhusb on 2015-04-06 15:18:12 +0000
 1.3.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.5.8.4 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.5.8.3 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.5.8.2 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.5.8.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.6.2.2 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 30-Aug-2017  jdolecek file ixgbe_x540.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.7.2.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.8.20.1 13-May-2021  thorpej Sync with HEAD.
 1.8.8.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.8.8.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.28 06-Oct-2023  msaitoh ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.27 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.26 31-May-2022  andvar branches: 1.26.4;
s/disbale/disable/ and s/enbale/enable/ in comments. also one more typo fix.
 1.25 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.24 15-Dec-2021  msaitoh Check host interface return status. No functional change on NetBSD.

- FreeBSD: c1a56b6f5ffd6f3180a654d058c1783ccb808e8b or ix-3.3.18
DPDK: db18e37090a3b9af47d6a6886248520f6b220bf9

Writing to read-only fields returns a non-OK Return Status
for shadow RAM write command for X550.
This information was previously discarded.

- No functional change on NetBSD because our ixg has no interface to
write the NVM.
 1.23 10-Dec-2021  msaitoh Whitespace fix. Sync with FreeBSD ix-3.3.14.
 1.22 10-Dec-2021  msaitoh Add typecast for type mismatch.

FreeBSD: 994dd6328c66fc277438ad51ed074f3c52096147
DPDK: d8e52b2cf771c31b523b46852fd86225b5a2c721
 1.21 10-Dec-2021  msaitoh Initialize data field in struct buffer.

FreeBSD: b3ebe337ffa06b0f1f460bf8f1e42fb55db77d0b or ix-3.3.14
DPDK: 40543be5376ca415b2a7e196315d0555725b8bdf

While sending request using ixgbe_hic_unlocked() the data field in
buffer struct is not used. It is set when the struct is overwritten by
FW to deliver the response. To not pass random data to FW the whole
structure should be zeroed before use.
 1.20 19-May-2021  msaitoh No functional change:

- Add NetBSD RCS IDs.
- KNF.
 1.19 30-Apr-2021  msaitoh branches: 1.19.2;
Add missing __KERNEL_RCSID().
 1.18 05-Feb-2020  msaitoh branches: 1.18.10;
No functional change:

- Fix typos.
- Remove extra newline.
 1.17 23-Dec-2019  msaitoh branches: 1.17.2;
Add recovery code for unsupported SFP+.

Before this commit:
If an unsuppored SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching drvier (drvctl -d && drvctl -r pciN).
After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.16 06-Aug-2019  msaitoh Fix typo in comment. Found by Wataru Ashihara.
 1.15 27-Jun-2019  msaitoh branches: 1.15.2;
Sync with FreeBSD ix-3.3.8 part 2:
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
 1.14 06-Dec-2018  msaitoh Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.13 06-Jul-2018  msaitoh Add force_10_100_autonego sysctl. The default vaule is 0(false).
This sysctl is only for 550EM_a with PHY firmware for a while.
 1.12 04-Apr-2018  msaitoh branches: 1.12.2;
Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.11 04-Apr-2018  msaitoh Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.10 30-Mar-2018  msaitoh - Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.

Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))

Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.

- Change some functions static.
 1.9 16-Mar-2018  msaitoh - Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.
 1.8 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.7 08-Nov-2017  msaitoh branches: 1.7.2; 1.7.4;
Fix a bug that Denverton which uses firmware don't linkup if the media is
forced to 100baseTX-FDX or 10baseT-FDX. As I wrote in ixgbe_phy.c rev. 1.13,
popular switches and OSes don't use auto-negotiation if the media is forced to
100BASE-TX or 10BASE-T. Do the same thing. But, if we don't set
FW_PHY_ACT_SETUP_LINK_AN in ixgbe_setup_fw_link(), the firmware wrongly set
BMCR register. Two problems are observed:

a) FDX may not be set.
b) BMCR_SPEED1 (bit 6) is always cleard.

+ -------+------+-----------+-----+
|request | BMCR | BMCR spd | BMCR |
| | (HEX)| (in bits)| FDX |
+--------+------+----------+------+
| 10M | 0000 | 10M(00) | 0 |
| 10M | 2100 | 100M(01) | 1 |
| 100M | 0000 | 10M(00) | 0 |
| 100M | 0100 | 10M(00) | 1 |
+--------------------------+------+

To avoid this problem, after sending request to firmware, check BMCR register
and fix the setting if it's required.

Before this change:

+------------------+---------------------------------------------+
| | denverton |
| +---------+--------+---------+----------------+
| | auto | 1G FDX | 100 FDX | 10 FDX |
+---------+--------+---------+--------+---------+----------------+
| | auto | 1G FDX | 1G FDX | 100 FDX | 10FDX/down(NG) |
| +--------+---------+--------+---------+----------------+
| | 1G FDX | 1G FDX | 1G FDX | down | down |
| link +--------+---------+--------+---------+----------------+
| partner |100 FDX | down(*1)| down | down(NG)| down |
| +--------+---------+--------+---------+----------------+
| | 10 FDX | down(*1)| down | down | down(NG) |
+---------+--------+---------+--------+---------+----------------+
(Observed on: NVM Image Version 0.05 ID 0x8, NVM Map version 1.16,
OEM NVM Image version 0.06, ETrackID 8000087c)

After this change:

+------------------+---------------------------------------------+
| | denverton |
| +---------+--------+---------+----------------+
| | auto | 1G FDX | 100 FDX | 10 FDX |
+---------+--------+---------+--------+---------+----------------+
| | auto | 1G FDX | 1G FDX | 100 FDX | 10 FDX |
| +--------+---------+--------+---------+----------------+
| | 1G FDX | 1G FDX | 1G FDX | down | down |
| link +--------+---------+--------+---------+----------------+
| partner |100 FDX | down(*1)| down | 100 FDX | down |
| +--------+---------+--------+---------+----------------+
| | 10 FDX | down(*1)| down | down | 10 FDX |
+---------+--------+---------+--------+---------+----------------+
*1): may be correct because ixg doesn't support half duplex.
 1.6 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.5 19-Jan-2017  msaitoh branches: 1.5.6;
Reduce diff against FreeBSD. No functional change.
 1.4 27-Dec-2016  msaitoh branches: 1.4.2; 1.4.4;
Fix DEBUGFUNC() output in ixgbe_disable_rx_x550().
 1.3 05-Dec-2016  msaitoh branches: 1.3.2;
Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.2 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.1 01-Dec-2016  msaitoh Add forgotten ixgbe_x550.c and ixgbe_x550.h.
 1.3.2.3 05-Feb-2017  skrll Sync with HEAD
 1.3.2.2 05-Dec-2016  skrll Sync with HEAD
 1.3.2.1 05-Dec-2016  skrll file ixgbe_x550.c was added on branch nick-nhusb on 2016-12-05 10:55:17 +0000
 1.4.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.2.1 27-Dec-2016  pgoyette file ixgbe_x550.c was added on branch pgoyette-localcount on 2017-01-07 08:56:40 +0000
 1.5.6.14 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.5.6.13 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.5.6.12 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.5.6.11 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.5.6.10 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.5.6.9 02-Sep-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1601):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.5.6.8 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.5.6.7 05-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367, to pull up the following
revisions:

sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixgbe.c 1.180,1.203-1.204,
1.207-1.208 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.55
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.10
sys/dev/pci/ixgbe/ixgbe_common.c 1.25
sys/dev/pci/ixgbe/ixv.c 1.129-1.130

- X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
- An interrupt might not arrive when a module is inserted. When an link
status change interrupt occurred and the driver still regard SFP as
unplugged, issue the module softint before issuing LSC softint.
- Add 10000BASE-LX media if it's 1000BASE-BX.
- printf -> device_printf
- Avoid undefined behavior of VLAN filter setting.
- Simplify code.
- Fix typo in unused code.
- Fix typo in comment. Found by Wataru Ashihara.
 1.5.6.6 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.5.6.5 07-Aug-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #961):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.h: revision 1.51
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.23
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe.c: revision 1.163
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.49

Add force_10_100_autonego sysctl. The default value is 0(false).

This sysctl is only for 550EM_a with PHY firmware for a while.

Make jcl allocation per queue to reduce mutex spin. Tested by me and
knakahara.
 1.5.6.4 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.5.6.3 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.5.6.2 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.5.6.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.7.4.5 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.7.4.4 28-Jul-2018  pgoyette Sync with HEAD
 1.7.4.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.7.4.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.7.4.1 15-Mar-2018  pgoyette Synch with HEAD
 1.7.2.2 03-Dec-2017  jdolecek update from HEAD
 1.7.2.1 08-Nov-2017  jdolecek file ixgbe_x550.c was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.12.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12.2.1 10-Jun-2019  christos Sync with HEAD
 1.15.2.8 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.15.2.7 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.15.2.6 02-Jun-2022  martin Pull up the following revisions, all via patch, requested by msaitoh
in ticket #1459:

sys/dev/pci/ixgbe/ixgbe.c 1.261,1.265-1.268,1.273,1.275-1.277,
1.312,1.316-1.319 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.182

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Fix typos in comment.
- KNF.
 1.15.2.5 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.15.2.4 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.15.2.3 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.15.2.2 28-Jan-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #664):

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
If an unsupported SFP module is inserted before booting, the driver attach
failed and there was no way to recover form it without rebooting or
detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
We can automatically recover any time by replacing it with a supported
module.
 1.15.2.1 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.17.2.1 29-Feb-2020  ad Sync with head.
 1.18.10.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.18.10.1 13-May-2021  thorpej Sync with HEAD.
 1.19.2.1 31-May-2021  cjep sync with head
 1.26.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.26.4.1 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.7 24-Dec-2021  msaitoh Update copyright to 2020.

FreeBSD: 8455e365f77f5b66ac9521dbcd690f79345ce147
 1.6 30-Apr-2021  msaitoh Add NetBSD RCS IDs. No functional change.
 1.5 06-Dec-2018  msaitoh branches: 1.5.4; 1.5.16;
Apply FreeBSD ix-3.3.6.tar.gz's change to NetBSD. Tested on C3000 and X550-T1,
but not tested on Xeon D:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM (C3000):
- FreeBSD always set IXGBE_FEATURE_RECOVERY_MODE without checking the
NVM image version. We compare it against 2.0 to not to make new callout and
not to call extra atomic operations.
- In some FreeBSD's sysctl functions, atomic_load_acq_int() is called
before a null pointer check. We call it after null pointer check.
- Before calling atomic_load_acq_uint(), check adapter->feat_en flags
to save atomic operation call.
- We don't check recovery_mode in ixgbe_set_sysctl_value() because this
function doesn't touch any hardware register.
- NetBSD don't have FreeBSD's atomic_load_acq_int()-like function, so do it
with membar_sync(). Thanks riastradh@ for the advice.
- FreeBSD's ix-3.3.6 changed ixgbe_enable_aim from TRUE to FALSE, but we will
keep it as TRUE because we have already fixed some bugs.
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and removed in
ix-3.3.6.tar.gz.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em() has
extra check (e.g. exclude 1G copper).
- if_sriov.c's change doesn't affect to NetBSD because we don't support
SR-IOV PF function.
 1.4 30-Mar-2018  msaitoh branches: 1.4.2;
- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.

Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))

Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.

- Change some functions static.
 1.3 30-Aug-2017  msaitoh branches: 1.3.2; 1.3.4;
- Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.2 02-Dec-2016  msaitoh branches: 1.2.2; 1.2.4; 1.2.12;
Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.1 01-Dec-2016  msaitoh Add forgotten ixgbe_x550.c and ixgbe_x550.h.
 1.2.12.5 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.2.12.4 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.2.12.3 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.2.12.2 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.2.12.1 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.2.4.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.4.1 02-Dec-2016  pgoyette file ixgbe_x550.h was added on branch pgoyette-localcount on 2017-01-07 08:56:40 +0000
 1.2.2.2 05-Dec-2016  skrll Sync with HEAD
 1.2.2.1 02-Dec-2016  skrll file ixgbe_x550.h was added on branch nick-nhusb on 2016-12-05 10:55:17 +0000
 1.3.4.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.3.4.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.3.2.2 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 30-Aug-2017  jdolecek file ixgbe_x550.h was added on branch tls-maxphys on 2017-12-03 11:37:30 +0000
 1.4.2.1 10-Jun-2019  christos Sync with HEAD
 1.5.16.1 13-May-2021  thorpej Sync with HEAD.
 1.5.4.2 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.5.4.1 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.198 10-Jul-2024  msaitoh ixgbe: Remove ifdef NET_MPSAFE. Make ixgbe MP-scalable by default.

Same as wm(4).
 1.197 10-Jul-2024  msaitoh ixgbe: ixgbe is always MP-safe, so remove IXGBE_MPSAFE macro.

Before this change, IXGBE_MPSAFE is not defined if NET_MPSAFE is not set.
In this case, the PCI_INTR_MPSAFE flag is not set by pci_intr_setattr()
and interrupt_distribute() fails on arm. Always enable IXGBE_MPSAFE
funciton by removing the macro.
 1.196 15-Nov-2023  msaitoh branches: 1.196.2;
ixgbe: Clear the WTHRESH bit field before writing it.
 1.195 15-Nov-2023  msaitoh ixv(4): Remove unused IFF_OACTIVE. No functional change.
 1.194 02-Nov-2023  yamaguchi Use ether_bpf_mtap only when the device supports vlan harware tagging

The function is bpf_mtap() for ethernet devices and *currently*
it is just handling VLAN tag stripped by the hardware.
 1.193 02-Nov-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.192 18-Oct-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.191 12-Oct-2023  msaitoh ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.
 1.190 12-Oct-2023  msaitoh ixgbe: Whitespace. No functional change.
 1.189 06-Oct-2023  msaitoh ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.
 1.188 06-Oct-2023  msaitoh ixgbe: Modify error message of wrong TX/RX descriptor size.

- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.
 1.187 06-Oct-2023  msaitoh ixgbe: Simplify definitions. No functional change.

Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.
 1.186 06-Oct-2023  msaitoh ixgbe: Rename some definitions, modify comment. No functional change.

Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block
 1.185 06-Oct-2023  msaitoh ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.

PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.
 1.184 13-Sep-2023  msaitoh ixgbe: Reorder some event counters for readability.
 1.183 06-Jul-2022  msaitoh branches: 1.183.4;
Call txeof first, then rxeof for the consistency.

There are three functions where the txeof and rxeof are called. The legacy
interrupt function and MSI-X function call rxeof first, then rxeof.
For the workqueue function. rxeof is called first. Modify it to match with
other two.
 1.182 02-Jun-2022  msaitoh KNF. No functional change.
 1.181 30-May-2022  msaitoh Remove unused adapter->msix_mem.
 1.180 25-Apr-2022  msaitoh Add missing num_{tx,rx}_desc sysctl to sync with ixgbe.c.
 1.179 25-Apr-2022  msaitoh Limit {tx,rx}_process_limit sysctl values from 1 to num_{tx,rx}_desc.
 1.178 25-Jan-2022  msaitoh Use atomic_{load,store}_relaxed() for event counters.
 1.177 24-Jan-2022  msaitoh Fix ixv.c rev. 1.176. Calculate 36bit counter correctly.
 1.176 19-Jan-2022  msaitoh Improve ixv(4)'s some event counters.

- The virtual function's packet counter registers are not cleared on read.
To solve this problem, <REGNAME>, base_<REGNAME>, last_<REGNAME> and
saved_reset_<REGNAME> are in the struct ixgbevf_hw_stats and some
functions use them. However, saved_reset_<REGNAME> is set but never
referenced. base_<REGNAME> is set and it's only used for
saved_reset_<REGNAME>, so it's also unused in reality. THERE ARE A LOT
OF GARBAGE. Remove them.
- Call ixv_init_stats() in ixv_clear_evcnt() to make ifconfig -z ixvN
work correctly.
 1.175 18-Jan-2022  msaitoh Update ixv_print_debug_info() to print similar data to ixg(4).

The old hw.ixvN.debug=1 printed evcnt(9) data. The same values are printed
by vmstat -e, so it's not worth to print. Remove all of the old output and
make it similar to ixgbe_print_debug_info().
 1.174 18-Jan-2022  msaitoh Don't expose garbage data of hw.ixvN.debug.
 1.173 24-Dec-2021  msaitoh Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.
 1.172 24-Dec-2021  msaitoh Add code to support API version 1.5. No functional change.

- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.
 1.171 24-Dec-2021  msaitoh Whitespace fix. Remove old comment. No functional change.

- From FreeBSD ixv-1.5.22.
 1.170 14-Dec-2021  msaitoh Use adapter->mta for the multicast array memory instead of the on-stack array.

- Same as ixv-1.5.22.
- Same as ixg(4).
 1.169 30-Sep-2021  yamaguchi Remove vlan_ifdetach() from ixv_detach()

The removed function is called in ether_ifdetach().
 1.168 16-Sep-2021  msaitoh Fix a bug that an mbuf chain which has more than 63488bytes MAY fail on TX.

- Currently, The TX buffer dmamap's max number of segments is set to 32.
MCLBYTES(== 2048) * 32 = 65536 and it's enough for IP_MAXPACKET(65535).
If an mbuf chain has more than 32 mbufs, we call m_defrag() to make
it lower than equal to 32, but it might not work. The reason is that
our m_defrag() don't modify the first mbuf entry of the chain. e.g.:
if an mbuf chain contains 63600bytes data and the first mbuf has 100bytes
in the m_data, the new chain has 100+2048+2048+...+12 and the total number
of the chain is not 32 but 33. It result in 43 TCP packets will drop.
- One of the way to fix this problem is to change m_defrag() which add a
new mbuf cluster to the first mbuf. It's need discussion.
- Another solution is to change the max number of the TX DMA segment.
It should be at least 33 to avoid the m_defrag()'s current limitation.
The document (82599-X550 DS 7.2.1.1 "Transmit Storage in system Memory")
says that a packet can be fragmented into 40 - WTHRESH - 2 (for 82598,
the document say nothing and some people and code says it's unlimited).
Currently WTHRESH is set to 8. 40 - 8 - 2 = 30. !?!?!? {Net,Free,Open}BSD
and Linux use 32. Is that safe? Anyway, we change WTHRESH from 8 to 5
to fit it. The added comment in ixgbe.h is based on DragonFly's
though they don't use WTHRESH.
- Yet another solution is to use the Tx Head Pointer Write Back function
instead of WTHRESH based write back (see 82599-X550 DS 7.2.3.5.2
"Tx Head Pointer Write Back" or 82598 "Transmit Completions Head Write Back"
). DragonFly, illumos and DPDK use it.
- Yet yet another solution is to add tso_maxsize entry to struct ifnet
and use it in the TCP stack.
 1.167 16-Sep-2021  msaitoh Use IXGBE_TXDCTL_WTHRESH_SHIFT macro. No functional change.
 1.166 26-Aug-2021  msaitoh Remove "j" or "jumbo" because we always use MCLBYTES sized buffer.
 1.165 25-Aug-2021  msaitoh Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.

- Before this commit, resource shortage was easily occurred because the total
number of the clusters is small.

- Reviewed by knakahara and ryo.
 1.164 15-Jul-2021  msaitoh Add a new sysctl to read rxr->next_to_refresh.
 1.163 07-Jul-2021  msaitoh Add new sysctl "rx_copy_len".

ixgbe_rxeof() has an optimization "RX_COPY" to reduce costs of
bus_dmamap_load_mbuf() and bus_dmamap_unload() by copying a mbuf cluster's
memory to a newly allocated mbuf's MH_databuf[] and recycle the original map.
The optimization is used when a length of a packet is smaller than a specific
value. The value is calculated based on MHLEN. The size of MHLEN is
architecture specific. It's 256 or 512. Make the threshold controllable by
adding a new sysctl.
 1.162 16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.161 19-May-2021  msaitoh No functional change:

- Add NetBSD RCS IDs.
- KNF.
 1.160 18-May-2021  msaitoh - Cleanup an rxbuf entry when bus_dmamap_load_mbuf() failed to prevent panic.
- Print error number when error occurred.
 1.159 30-Apr-2021  msaitoh branches: 1.159.2;
Add missing __KERNEL_RCSID().
 1.158 31-Mar-2021  msaitoh branches: 1.158.2;
KNF a bit. No functional change.
 1.157 31-Mar-2021  msaitoh Modify error message to sync with ixgbe.c
 1.156 11-Mar-2021  msaitoh branches: 1.156.2;
Add "TX " to "Queue No Descriptor Available" to make it more understandable.
Same as ixgbe.c rev. 1.278.
 1.155 09-Mar-2021  msaitoh Modify some parameters to reduce packet dropping.

- Background: ixgbe doesn't use common MCLGET() interface and use the
driver specific cluster allocation mechanism (jcl). The cluster is
pre-allocated with a fixed number and the current number per queue
is num_rx_desc * 2 (2048*2=4096). It's too small. It also has a problem
that the max length of the pcq which is used in the TX path is big
(4096). Example:

100M <----- [ixg0 ixg1] <----- 1G
2048 TX descs <--- 4096 pcqs <---- 2048 RX descs

If a machine forwards a traffic from 1G interface to 100M interface,
It would require 2048+4096+2048=8192 descriptors, but the current number
is 2048*2=4096. It's too small. Even if the both interface's link speed
is the same and only small number of packet is queued in the pcq, 4096
jcl is small because 2048(RX)+TX(2048)=4096. If jcl is exhausted, not only
forwarding from ixg1 to ixg0 is dropped, but also another forwarding path
from ixg1 to another interface(e.g. wm0) is also dropped. Sockets also
queue packets, so if a lot of sockets are used and/or a socket buffer
size is changed to bigger one, it'll also become a problem. If the jcl
is exhausted, evcnt(9) counter "ixgX qY Rx no jumbo mbuf" is incremented.
Example:
vmstat -ev | grep ixg1 | grep "no jumbo"
ixg1 q0 Rx no jumbo mbuf 0 0 misc
ixg1 q1 Rx no jumbo mbuf 0 0 misc
ixg1 q2 Rx no jumbo mbuf 141326 0 misc
ixg1 q3 Rx no jumbo mbuf 0 0 misc


- To solve this problem:
- Add new config parameter IXGBE_JCLNUM_MULTI and set the default to 3
(2048 * 3). The minimum number is 2. The total number of jcl per queue
is available with hw.ixgN.num_jcl_per_queue sysctl.
- Reduce the max length of the pcq() which is used in the TX path from
4096 to 2048.

- Reviewed by knakahara@ and ozaki-r@.

- TODO: Use MCLGET().
 1.154 07-Sep-2020  msaitoh branches: 1.154.2;
- Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@.
- Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers().
- Add KASSERT() to functions who are called from ixgbe_handle_admin().
 1.153 31-Aug-2020  msaitoh Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional change.
 1.152 13-Aug-2020  msaitoh Use atomic_cas_uint() and atomic_store_relaxed(). Advised by thorpej@.
Tested by me. OK'd by knakahara.
 1.151 25-Jun-2020  msaitoh Reduce ixgbe's busy loop using with workqueue and kpause.

- Use workqueue instead of softint to make some functions sleepable.
- Use new workqueue and enqueue it in ixgbe_local_timer() and
ixgbe_recovery_mode_timer() to make them sleepable.
- Make new ixgbe_delay() and use it. This functions sleeps if the time is
more than equals 1 tick. If it's not, do delay().
 1.150 18-Jun-2020  msaitoh Modify a liitle to reduce diff between ixgbe.c and ixv.c. No functional change.
 1.149 11-Jun-2020  msaitoh Fix typo. No functional change.
 1.148 17-Apr-2020  msaitoh No functional change:
- modify comment
- whitespace fix
 1.147 15-Mar-2020  thorpej branches: 1.147.2;
Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.
 1.146 05-Feb-2020  msaitoh Modify note in ixv_update_stats(). VF doesn't count errors by hardware.
 1.145 04-Feb-2020  thorpej Use ifmedia_fini().
 1.144 21-Jan-2020  msaitoh Fix the freeing code for some error paths. Found and tested by Patrick Welche.
 1.143 17-Dec-2019  msaitoh branches: 1.143.2;
Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.
 1.142 16-Dec-2019  msaitoh No functional change:

- Remove unused code.
- Remove extra spaces.
- KNF.
 1.141 18-Nov-2019  msaitoh Print MAC address.

XXX Should we move such type of printf() to ether_ifattach?
 1.140 06-Nov-2019  msaitoh ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.
 1.139 01-Oct-2019  msaitoh Set MTU correctly if mtu > 1500.
 1.138 20-Sep-2019  msaitoh - Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- If a multicast entry has range, use ALLMULTI like others.
- Remove ixv_set_promisc() and use ixv_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter(). Same as ixgbe.c.
- The promisc mode can't be enabled if the PF is not in promisc mode.
Identify that state and report it as "the PF may not in promisc mode"
(though it might not be perfect).
 1.137 13-Sep-2019  msaitoh Add PROMISC support.
 1.136 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.135 13-Sep-2019  msaitoh - Return EPERM when the interface is not trusted.
- Treat IXGBE_ERR_FEATURE_NOT_SUPPORTED.
 1.134 12-Sep-2019  msaitoh Add support ALLMULTI on ixv(4):
- Negotiate API version up to 1.3.
- On linux's PF driver implementation, the PF replies VF's XCAST_MODE_ALLMULTI
message not with NACK but with ACK even if the virtual function is NOT
marked "trust" and act as XCAST_MODE_"MULTI". If ixv(4) simply check the
return vaule of update_xcast_mode(XCAST_MODE_ALLMULTI), SIOCSADDMULTI
success and the user may have trouble with some addresses. Fortunately,
the Linux's PF driver's "ACK" message has not XCAST_MODE_"ALL"MULTI but
XCAST_MODE_MULTI, so we can check this state by checking if the send
message's argument and the reply message's argument are different.
- Noy yet for PROMISC.
 1.133 12-Sep-2019  msaitoh Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
 1.132 12-Sep-2019  msaitoh - Make SIOCADDMULTI returns ENOSPC when the Ethenet multicast address list
exceeds the limit.
- State "Ethernet" multicast address.
- Use macro.
 1.131 05-Sep-2019  msaitoh Add support SIOCZIFDATA as ixgbe.c.

BUGS
The following event counters are not cleared by SIOCZIFDATA because the
corresponding registers are read only and not cleared on read:

Good Packets Received
Good Octets Received
Multicast Packets Received
Good Packets Transmitted
Good Octets Transmitted
 1.130 04-Sep-2019  msaitoh Use aprint_*() in the attach function.
 1.129 04-Sep-2019  msaitoh printf -> device_printf
 1.128 21-Aug-2019  msaitoh Simplify ix{gbe,v}_[un]register_vlan() API suggestesd by knakahara.

The API was the same as FreeBSD's pre-iflib's. They use iflib now and it's
not required for us to keep the old API.
 1.127 21-Aug-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() suggested by knakahara.
 1.126 20-Aug-2019  msaitoh Fix a bug that VLAN HW "tagging" enable/disable may not refrect correctly.

- Always call ec_vlan_cb() if it exists.
- Some (or all?) ethernet drivers don't enable HW tagging if no any vlan is
attached. ixgbe is one of them. Check the the transition and update
VLAN HW tagging function.

XXX pullup-9
 1.125 30-Jul-2019  msaitoh branches: 1.125.2;
It's not required to call ixv_stop() twice in ixv_detach().
 1.124 26-Jul-2019  msaitoh Simplify and avoid undefined behavior. This is not a real bug because
the max number of queue is 2.
 1.123 25-Jul-2019  msaitoh Fix VLAN hardware filter initialization. Use unsigned. Found by KUBSan.
 1.122 25-Jul-2019  msaitoh Fix VLAN filter setting. Found by KUBSan.
 1.121 25-Jul-2019  msaitoh Set IVAR (Interrupt Vector Allocation Register) correctly in ixgbe_set_ivar().
Found by KUBSan.
 1.120 17-Jul-2019  msaitoh Implement VLAN hardware filter function(ETHERCAP_VLAN_HWFILTER).
First proposed by jmcneill in 2017 and modified by me.

How to use:

- Set callback function:

ether_set_vlan_cb(struct ethercom *, ether_vlancb_t)

- Callback. This function is called when a vlan is attached/detached to the
parent interface:

int (*ether_vlancb_t)(struct ethercom *ec, uint16_t vlanid, bool set);

- ifconfig(8)

ifconfig ixg0 [-]vlan-hwfilter

Note that ETHERCAP_VLAN_HWFILTER is set by default on ixg(4) because
the PF driver usually enable "all block" filter by default.
 1.119 17-Jul-2019  msaitoh KNF. No functional change.
 1.118 04-Jul-2019  msaitoh On ENETRESET case, not continue and quit the ifflags_cb() function because
if_init() will do the same thing.
 1.117 02-Jul-2019  msaitoh Sync with FreeBSD's ixv-1.5.17:
- When ixv_check_link() failed in the watchdog function, reset the interface.
- Remove RXCSUM register modification in ixv_initialize_receive_units().
It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Modify to match the newer NETMAP interface. No functional change.
 1.116 27-Jun-2019  msaitoh Don't call set_vfta() if any VLAN is attached.
XXX pullup-8.
 1.115 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.114 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.113 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.112 18-Mar-2019  msaitoh s/pakcet/packet/ in comment.
 1.111 15-Mar-2019  msaitoh - Simplily. Suggested by knakahara.
- Modify comment. Per queue VLAN enable flags is on 82599 and later.
- Fix typo in comment.
 1.110 13-Mar-2019  msaitoh Fix a bug that the VLAN HW tagging function is not correctly disabled when
all vlan is detached. Part of ixgbe.c rev. 1.177.
 1.109 22-Feb-2019  msaitoh Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.108 23-Jan-2019  msaitoh Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them expilicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.107 27-Sep-2018  msaitoh Don't set LRO capability flags because we don't support it yet.
This doesn't change any behavior other than if_capabilities' visibility
(e.g. ifconfig).
 1.106 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.105 06-Jun-2018  kamil branches: 1.105.2;
Comment out unused functions in order to fix Clang build

ixv_rearm_queues() and ixgbe_rearm_queues() are unused.

Sponsored by <The NetBSD Foundation>
 1.104 04-Jun-2018  msaitoh Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().

ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.

ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.
One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.103 03-Jun-2018  maxv Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
 1.102 30-May-2018  msaitoh Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.

This change itself doesn't fix PR#53294.
 1.101 25-May-2018  ozaki-r Ensure to call if_register after interface initializations finish
 1.100 23-May-2018  msaitoh Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
 1.99 23-May-2018  msaitoh Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
 1.98 18-May-2018  msaitoh Revert new watchdog timer commits. The new watchdog timer made stability
worse than before. It seems unknown problems exists.

http://mail-index.netbsd.org/source-changes/2018/05/08/msg095020.html
http://mail-index.netbsd.org/source-changes/2018/05/16/msg095240.html
 1.97 14-May-2018  msaitoh Fix panic or hangup when "sysctl -w hw.ixgN.debug=1".

XXX pullup-8
 1.96 08-May-2018  msaitoh - Fix broken watchdog timer. This change detects TX device timeout correctly.
NOTE: It's supporsed not to be called {ixgbe,ixv}_rearm_queues() in the
timer. Those are not required if any chip have no bug. In reality,
ixgbe_rearm_queues() is required on 82599 and newer chip AND other than
queue 0 to prevent device timeout. When it occured, packet was sent but the
descriptor's DD bit wasn't set even though IXGBE_TXD_CMD_EOP and
IXGBE_TXD_CMD_RS were set. After forcing interrupt by writing EICS register
in ixgbe_rearm_queues(), DD is set. Why? Is this an undocumented errata? It
might be possible not call rearm_queues on 82598 or queue 0, we call in any
cases in case the problem occurs. On ixv(4), I have not seen this problem yet
(though I tested only on X550_X(Xeon D 12xx)'s virtual function), but we
do rearm in case TX device timeout happen.
- ixv(4): Call callout_stop() earlier in ixv_stop() like ixgbe_stop().
- KNF.
 1.95 19-Apr-2018  msaitoh Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
 1.94 17-Apr-2018  msaitoh Remove unused structure entries. No functional change.
 1.93 12-Apr-2018  msaitoh Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.92 04-Apr-2018  msaitoh Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.
 1.91 04-Apr-2018  msaitoh Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.
 1.90 30-Mar-2018  knakahara Don't write EIMC directly. It is required to manage with struct ix_queue status.

XXX pullup-8
 1.89 20-Mar-2018  knakahara Fix race about writing adapter->link_active for ixv(4).

adapter->link_active is updated by ixv_update_link_status() only.
The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.
 1.88 15-Mar-2018  msaitoh Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.
Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:
- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
 1.87 09-Mar-2018  msaitoh Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.86 07-Mar-2018  msaitoh Don't increment que->req.ev_count in MSI-X interrupt because it's not
reschedule.
 1.85 07-Mar-2018  msaitoh - Make "Handled queue in softint" and "Requeued in softint" evcnt(9) per queue
and count them correctly.
- Remove #if 0'ed code.
 1.84 02-Mar-2018  knakahara branches: 1.84.2;
ixv(4) also supports workqueue poll mode, but not enabled by default yet, either.

ok by msaitoh@n.o.
 1.83 27-Feb-2018  msaitoh Add hw.ixvM.q[01].{interrupt_rate,[tr]xd_head,[tr]xd_tail} sysctls as ixg(4).
 1.82 26-Feb-2018  knakahara Apply ixgbe.c:r1.127 to ixv.c. Pointed out by msaitoh@n.o.
 1.81 22-Feb-2018  msaitoh Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.80 22-Feb-2018  msaitoh - Apply ixgbe.c rev. 1.124 to ixv.c. Fix a bug that RX may stall on heavy load
on ixv(4) derived from FreeBSD's AIM (Auto Interrupt Moderation) bug.
ITR_INTERVAL value must be larger than 4us.

- The bitfield of EITR register is different between 82598 and others.
ixv.c had a bug that it accessed 82598's way even though only 82599 and
newer support virtual function. Fix it using with new ixv_eitr_write()
function.
 1.79 16-Feb-2018  msaitoh Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().

XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
 1.78 16-Feb-2018  knakahara Apply RSS utility to ixg(4) and ixv(4).

ok by msaitoh@n.o.
 1.77 21-Dec-2017  msaitoh Fix panic when only link interrupt can't be established.
 1.76 21-Dec-2017  msaitoh Don't panic when resource shortage occured. Like ixgbe.c rev. 1.116.
- Move location of {ixgbe,ixv}_setup_interface() call at a position that
any error don't occur. One of the reason is that it should be. Another
reason is that it's hard to call ether_ifdetach() and if_detach() when
cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
and maybe more).
 1.75 06-Dec-2017  msaitoh Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
has no influence to netbsd because it's enabled by default and NetBSD has
no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier
 1.74 16-Nov-2017  ozaki-r Unify IFEF_*_MPSAFE into IFEF_MPSAFE

There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.

Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).

Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.

Proposed on tech-kern@ and tech-net@
 1.73 23-Oct-2017  msaitoh If if_initialize() failed in the attach function, free resources and return.
 1.72 18-Oct-2017  msaitoh Protect ec_multi* with mutex like other MP safe Ethernet drivers.
See if_ether.h rev. 1.66 and related stuff:
http://mail-index.netbsd.org/source-changes/2016/12/28/msg080289.html
 1.71 13-Oct-2017  msaitoh Show 2.5GBASE-T and 5GBASE-T correctly on ixv(4). Tested on a virtual function
on X550 T1.
 1.70 13-Oct-2017  msaitoh Set baudrate correctly. A device which use mii(4) interface can set
if_baudrate atomatically by mii_phy_statusmsg(). ixg(4) and ixv(4) don't
use mii(4), so calling ifmedia_baudrate() directly is required.

XXX need the same same work for wm(4)'s TBI and SERDEV devices.
 1.69 04-Oct-2017  msaitoh - ixv_enableintr(): Fix a bug that ixv_enable_queue() is called with incorrect
argument. This bug was added in rev. 1.68.
- Don't check neither VTEICR nor VTEICS same as Linux. It seems that both
registers can't be used to check which MSI-X vector is triggered. A bit is
set on very low probability and the bit location is incorrect. Is this an
errata?
 1.68 03-Oct-2017  msaitoh Fix a problem that mailbox interrupt never occured. Bit definitions of PF's
interrupt related registers and VF's interrupt registers a completely
different. VF's registers (VF{EICR, EICS, EIMS, EIMC, EIAC, EIAM})'s bits are
just MSI-X vector bitmask, so read/write correctly. Read VTEICR instead of
VTEICS in ixv_msix_mbx (note that "PF" has a errata that EICS is required to
read the cause). Don't write IXGBE_VTEICR in ixv_msix_mbx() because we use
auto-clear for mailbox interrupt.

We have gotten link status change by timer instead of interrupt before
this fix...
 1.67 03-Oct-2017  msaitoh Make mailbox statistic counters evcnt(9).
Example:
> ixv0 message TXs 23 0 misc
> ixv0 message RXs 2911 0 misc
> ixv0 ACKs 23 0 misc
> ixv0 REQs 22 0 misc
> ixv0 RSTs 0 0 misc
 1.66 27-Sep-2017  msaitoh Print device name in ixv_attach().
 1.65 15-Sep-2017  msaitoh xv(4) VLAN fixes:
- Dirty hack for VID mask bits. On ixg(4), VLAN filter is disabled. So any
vlan ID's packet passes RX filter. On ixv(4), usually, PF driver uses
VLAN filter enabled. There is no way to disable PF's VLAN filter function
itself. NetBSD's Ethernet driver has currently no API to know which VLAN ID
should be accepted. To avoid this proble, enable all VIDs... Yes, I know
this is dirty hack. We should rethink.
- Call ixv_setup_vlan_support() in ixv_ifflags_cb().
- Don't use global ixv_shadow_vfta[].
- Use local variable (rxr->) to reduce diff against ixgbe.c. No functional
change.
 1.64 15-Sep-2017  msaitoh Make ixv(4) TX/RX descriptors size the same as ixg(4).
 1.63 13-Sep-2017  msaitoh - Print driver feature capabilities and enable bits when verbose boot as
ixgbe.c rev. 1.99.
- Whitespace fix.
 1.62 13-Sep-2017  msaitoh Set get_link_status to true in ixv_init_locked() to get the first link status
correctly.
 1.61 12-Sep-2017  msaitoh Fix panic caused by rev. 1.58's change. Don't if_start from interrupt context.
The restart code exists in ixv_handle_que().
 1.60 11-Sep-2017  msaitoh Print Mailbox API version.
 1.59 11-Sep-2017  msaitoh Use cprng_strong64() insread of cprng_fast64() to prevent panic.
 1.58 30-Aug-2017  msaitoh - Sync with FreeBSD r320688 (and up to r322865):
- Add C3000(Denvertion(-NS)) support.
- Add bypass function support for bypass adapters. Sysctls are provided.
Not tested because I have no any bypass adapter.
- ixv(4): set RSS mapping.
- Change EEE sysctl.
- ixv(4): Add TSOv6.
- ixv(4): Mailbox API 1.2 and more are implemented and comment says it
negotiate with 1.2 but it really does 1.1...
- Remove thermal test sysctl.
- Fix unknown bugs.
- Print driver feature capabilities and enable bits when verbose boot.
 1.57 30-Aug-2017  msaitoh FreeBSD r320688 sorted a lot of functions. Merging that change by one commit
makes difficult to know what was really changed. To make change understandable,
commit only function sort and white space changes before real change.
 1.56 26-May-2017  msaitoh branches: 1.56.2;
Add missing {ixgbe,ixv}_stop() in the detach function. Without this change,
shutdown won't finish or panic on heay traffic.
 1.55 03-Mar-2017  msaitoh Set PCI_INTR_MPSAFE, SOFTINT_MPSAFE, CALLOUT_MPSAFE and IFEF_START_MPSAFE
if NET_MPSAFE is defined.
 1.54 16-Feb-2017  msaitoh Do if_snd check even if IXGBE_LEGACY_TX is used. It's used by ALTQ.
 1.53 13-Feb-2017  msaitoh Remove more ix*_start_locked() from interrupt context like previous commit.
> Fix a bug that ix*_start_locked() is called in interrput context
> (ix*_msix_que). The function is called in softint(ix*_handle_que()). OK'd by
>k-nakahara.
 1.52 13-Feb-2017  msaitoh Use percpuq.
 1.51 13-Feb-2017  msaitoh Fix a bug that ix*_start_locked() is called in interrput context
(ix*_msix_que). The function is called in softint(ix*_handle_que()). OK'd by
k-nakahara.
 1.50 10-Feb-2017  msaitoh Change the Interrupt Moderation flag from global variable to per device.
 1.49 10-Feb-2017  msaitoh - Both mbuf_defrag_failed and m_defrag_failed existed. Remove m_defrag_failed.
- rx_irq, dropped_pkts, morerx, moretx and txloops counters are uncounted, so
remove them.
- Count handleq in ixv_handle_que().
- Detach event counters correctly.
- Set some per-queue event names correctly.
 1.48 10-Feb-2017  msaitoh No functional change:
- Rename ixv_sysctl_attach() to ixv_add_device_sysctls().
- Move sysct and evcnt related functions to match ixgbe.c.
 1.47 08-Feb-2017  msaitoh Print CPU number correctly.
 1.46 08-Feb-2017  msaitoh - Fix aprint_*()s in ixv_allocate_msix().
- Style fix. Reduce diff against ixgbe.c. No functional change.
 1.45 08-Feb-2017  msaitoh Call IFQ_SET_MAXLEN() even if TX multiqueue is used. ALTQ uses it.
 1.44 08-Feb-2017  msaitoh Enable multiqueue.
 1.43 08-Feb-2017  msaitoh Use dmat64 if available. Same as ixgbe.c rev. 1.60.
 1.42 08-Feb-2017  msaitoh Fix a bug that 1Gbps is printed even if the phyiscal media is at 100Mbps.
 1.41 08-Feb-2017  msaitoh Fix detach path:
- Call softint_disestablish() and pci_intr_disestablish() for all queues
correctly.
- Add missing sysctl_teardown() to delete sysctl entries.
- Call pci_intr_release(). Now NETBSD_MSI_OR_MSIX is completely deleted.
 1.40 08-Feb-2017  msaitoh Add queue number into interrupt name.
 1.39 08-Feb-2017  msaitoh Set ifm_active to IFM_NONE when the physical interface's link is down.
Now ifconfig shows "media: Ethernet autoselect '(none)'".
 1.38 07-Feb-2017  msaitoh Set IFM_10G_T on 10G...
 1.37 07-Feb-2017  msaitoh Fix link status stuff:
- Set get_link_status in ixv_init_locked() to get link status correctly.
- Don't discard checked speed in ixv_config_link()...
 1.36 07-Feb-2017  msaitoh Fix device attach:
- Even if ixgbevf_negotiate_api_version() failed, continue attaching.
Same as Linux. Tested on ESXi 6.0.
- Fix argument of pci_msix_alloc_exact().
- Use different intr_xname for each interrupt.
- Add missing pci_intr_release() on error.
- Add missign kcpuset_destroy().
- Calculate MSI-X vectors correctly.
 1.35 01-Feb-2017  msaitoh TX multiqueue. If you want to disable it, enable IXGBE_LEGACY_TX
in ixgbe_netbsd.h
 1.34 30-Jan-2017  msaitoh Fix to use softint-based if_input in ixv(4).

See:
http://mail-index.netbsd.org/source-changes/2016/02/09/msg072521.html
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html
 1.33 19-Jan-2017  msaitoh Reduce diff against FreeBSD. No functional change.
 1.32 18-Jan-2017  msaitoh Now we can use multiqueue. It's default on ixg(4). Not yet for ixv(4).
 1.31 05-Jan-2017  msaitoh branches: 1.31.2;
Fix INIT_DEBUGOUT() messages.
 1.30 16-Dec-2016  msaitoh Remove extra newline in debug printfs. ixgbe's *DEBUGOUT* macros automatically
add newline.
 1.29 05-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r303890:
- Configure ixgbe phy & gbic power.
Setup phy and gbic power as per Linux 4.3.13 driver.
This fixes link not detected on X540-AT2 after booting to Linux which
turns the phy power off on detach. (FreeBSD r295093)
- Fixup DA cable detection routine. (FreeBSD r303032)
- Some minor changes
 1.28 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r294578:
- Fixup SFP module insertion on the 82599 when insertion happens after
the system is booted and running. Add PHY detection logic to
ixgbe_handle_mod() and add locking to ixgbe_handle_msf() as well.
FreeBSD r293334.
- Fix ix advertise value after media change. When ifconfig sets media then the
values displayed by the advertise_speed value are invalidated.
Fix this by setting the bits correctly including setting advertise to 0 for
media = auto. FreeBSD r294578.
- Some others (e.g. LRO(not used by NetBSD)).
 1.27 02-Dec-2016  msaitoh Fix ix{gbe,v}_set_sysctlvalue().
 1.26 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r292674:
- Add X552 SFP+ and X550T single port.
- Bug fixes.
 1.25 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r289238:
- Add support for sysctl knobs to live tune the per interrupt rx/tx packet
processing limits in ixgbe(4)
- Some others (netmap, etc.)
 1.24 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r285590:
- Fix igxbe SRIOV VF (if_ixv) initialization bugs. The MAC address for
an if_ixv instance can now set at creation time, and the receive ring
tail pointer is correctly initialized (previously, things still worked
because the receive ring tail pointer was being fixed up as a side
effect of other activity).
 1.23 02-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r283881:
- SRIOV support (not enabled because NetBSD doesn't support it).
 1.22 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r282299:
- Add support for X55x.
- ADD EEE support (not tested).
- Add WOL support (not tested).
- Add suspend/resume support (not testd).
- Add LPLU support (not tested).
- Add DMA Coalescing (note verified).
- Not tested well for sysctls.
- Fix ixgbe_set_advertise() a bit. At least, FreeBSD r294578 is required
to work hw.ixg0.advertise_speed sysctl correctly.
 1.21 01-Dec-2016  msaitoh Update ixg(4) and ixv(4) up to FreeBSD r280197:
- Add support for 82599_QSFP_SF_QP and X540T1.
- Add partial support for X55x. It's required to sync with FreeBSD r282299
to support X55x.
- Bugfixes.
 1.20 28-Nov-2016  msaitoh Fix vlan check bug in ixv_setup_vlan_support().
 1.19 28-Nov-2016  knakahara fix build of ixv enabled NO_PCI_MSI_MSIX option.
 1.18 25-Nov-2016  msaitoh Remove #ifdef NETBSD_MSI_OR_MSIX to be simple. ixv(4) isn't attached if
__HAVE_PCI_MSI_MSIX isn't set because MSI-X must be used.
 1.17 10-Jun-2016  ozaki-r branches: 1.17.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.16 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.15 17-Aug-2015  knakahara Add kernel code to support intrctl(8).
 1.14 14-Aug-2015  martin Make it compilable without DIAGNOSTIC
 1.13 14-Aug-2015  msaitoh - Fix uninitialized data.
- include vlan.h and check NVLAN.
 1.12 13-Aug-2015  msaitoh Reduce diff against FreeBSD r280181.
 1.11 13-Aug-2015  msaitoh - Add MSI/MSI-X support. The multiqueue function is not supported yet.
- Make ixv.c compilable. _NOT_TESTED_YET_
 1.10 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.9 21-May-2015  rtr remove duplicated assignment of mh->m_len
 1.8 24-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
 1.7 14-Apr-2015  msaitoh Sync ixg(4) up to FreeBSD r243716:
- A lot of bugfixes. Some of them are realted to multi queue and those
have not affected in NetBSD because we have not used it yet.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Improve performance.
 1.6 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.5 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.4 19-Mar-2015  msaitoh Sync ixg(4) up to FreeBSD r230572.

- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
 1.3 10-Mar-2015  msaitoh Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
 1.2 25-Mar-2014  christos branches: 1.2.4; 1.2.6;
kill sprintf
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12; 1.1.16;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.16.1 18-May-2014  rmind sync with head
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.6.8 28-Aug-2017  skrll Sync with HEAD
 1.2.6.7 05-Feb-2017  skrll Sync with HEAD
 1.2.6.6 05-Dec-2016  skrll Sync with HEAD
 1.2.6.5 09-Jul-2016  skrll Sync with HEAD
 1.2.6.4 19-Mar-2016  skrll Sync with HEAD
 1.2.6.3 22-Sep-2015  skrll Sync with HEAD
 1.2.6.2 06-Jun-2015  skrll Sync with HEAD
 1.2.6.1 06-Apr-2015  skrll Sync with HEAD
 1.2.4.4 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.4.3 06-May-2015  riz Pull up following revisions (requested by msaitoh in ticket #734):
sys/dev/pci/ixgbe/LICENSE 1.2
sys/dev/pci/ixgbe/ixgbe.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe.h 1.7
sys/dev/pci/ixgbe/ixgbe_82598.c 1.4
sys/dev/pci/ixgbe/ixgbe_82598.h 1.3
sys/dev/pci/ixgbe/ixgbe_82599.c 1.9
sys/dev/pci/ixgbe/ixgbe_82599.h 1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.7
sys/dev/pci/ixgbe/ixgbe_api.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.5
sys/dev/pci/ixgbe/ixgbe_common.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.4
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.3
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.7
sys/dev/pci/ixgbe/ixgbe_phy.c 1.5
sys/dev/pci/ixgbe/ixgbe_phy.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.10
sys/dev/pci/ixgbe/ixgbe_vf.c 1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.5
sys/dev/pci/ixgbe/ixgbe_x540.c 1.3
sys/dev/pci/ixgbe/ixgbe_x540.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.8

- Sync ixg(4) up to FreeBSD r250108:
- Cleanup some unused counters and some unused code.
- Improve performance.
- Fix flow control - don't override user value on re-init
- Fix to make 1G optics work correctly
- Change to interrupt enabling - some bits were incorrect
for certain hardware.
- Certain stats fixes, remove a duplicate increment of
ierror, thanks to Scott Long for pointing these out.
- Fix the setting of RX which related to multicast.
- Some netmap related fixes.
- Fixes link error without vlan. PR#49879 reported by Hauke Fath.
[msaitoh, ticket #734]
 1.2.4.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.2.4.1 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.17.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.17.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.31.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.56.2.44 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1933:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.56.2.43 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1914:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192 via patch

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.56.2.42 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1912):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.56.2.41 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe.c 1.327-1.332 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.87-1.88
sys/dev/pci/ixgbe/ixv.c 1.184-1.185
sys/dev/pci/ixgbe/ix_txrx.c 1.101
sys/dev/pci/ixgbe/ixgbe_82599.c 1.30
sys/dev/pci/ixgbe/ixgbe_vf.c 1.32-1.33
sys/dev/pci/ixgbe/ixgbe_vf.h 1.18
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.20
sys/dev/pci/ixgbe/ixgbe_type.h 1.57

- Reorder some event counters for readability.
- Rename some descriptions of event counters.
- Count Queue Bytes {Transmit, Receive} counter.
- Improve error check in ixgbe_check_mac_link_vf().
- Add new IXGBE_VF_GET_LINK_STATE message support.
The VF's link state can be forced to down by PF.
- Update FCTRL after writing multicast filter.
- Update comments.
 1.56.2.40 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1796:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.56.2.39 03-Jun-2022  martin Pull up the following revisions, requestes by msaitoh in ticket #1746:

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.261,1.263,
1.265-1.268,1.273,
1.275-1.277,1.305,
1.312,
1.316-1.321 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.178,1.182 via patch

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Use macro.
- Fix typos in comment.
- KNF.
 1.56.2.38 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.98
sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

bus_dmamem_unmap() before bus_dmamem_free(), otherwise we may give back meomry
which is still (and will stay) mapped.

Fixes one instance of "panic: HYPERVISOR_mmu_update failed" on Xen.
There may be others.

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.56.2.37 30-May-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1744:

sys/dev/pci/ixgbe/ixgbe.c 1.270,1.280,1.307-1.311,
1.313-1.314 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.96-1.97
sys/dev/pci/ixgbe/ixv.c 1.179-1.180 via patch


- ixg(4): Print Printed Board Assembly (PBA) number.
- ixg(4): Add IFF_RUNNING check in ixgbe_legacy_irq() again. this might
fix small race but it's not so dangerous.
- Add value check for {tx,rx}_process_limit sysctl to avoid setting
wrong value.
- Add missing num_tx_desc sysctl.
- No functional change:
- KNF a bit.
- Simplify setting of EIAC register.
- Move the definition of eicr_mask variable.
- Enclose flow director stuff in ixgbe_intr_admin_common() with
IXGBE_FIR which is not defined in NetBSD.
- Modify comment for consistency.
- Use cached rx_copy_len in ixgbe_rxeof().
 1.56.2.36 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1730):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.56.2.35 30-Jan-2022  martin Pull up the following, requested by msaitoh in ticket #1729:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.56.2.34 29-Jan-2022  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1725:

sys/dev/pci/ixgbe/ixgbe_vf.h 1.16-1.17
sys/dev/pci/ixgbe/ixv.c 1.176-1.177

Make ifconfig -z ixvN clear event counter.
 1.56.2.33 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1708:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.56.2.32 15-Sep-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1696:

sysdev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sysdev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sysdev/pci/ixgbe/ix_txrx.c 1.68-1.93
sysdev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sysdev/pci/ixgbe/if_bypass.c 1.7-1.9
sysdev/pci/ixgbe/if_fdir.c 1.4-1.5
sysdev/pci/ixgbe/if_sriov.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_82598.c 1.16
sysdev/pci/ixgbe/ixgbe_82599.c 1.23
sysdev/pci/ixgbe/ixgbe_api.c 1.25
sysdev/pci/ixgbe/ixgbe_bypass.h 1.2
sysdev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sysdev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sysdev/pci/ixgbe/ixgbe_dcb.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sysdev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sysdev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sysdev/pci/ixgbe/ixgbe_fdir.h 1.3
sysdev/pci/ixgbe/ixgbe_features.h 1.3
sysdev/pci/ixgbe/ixgbe_mbx.c 1.12
sysdev/pci/ixgbe/ixgbe_netbsd.c 1.16-1.17
sysdev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sysdev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sysdev/pci/ixgbe/ixgbe_netmap.h 1.2
sysdev/pci/ixgbe/ixgbe_osdep.c 1.7
sysdev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sysdev/pci/ixgbe/ixgbe_phy.c 1.24
sysdev/pci/ixgbe/ixgbe_rss.h 1.5
sysdev/pci/ixgbe/ixgbe_sriov.h 1.4
sysdev/pci/ixgbe/ixgbe_type.h 1.49
sysdev/pci/ixgbe/ixgbe_vf.c 1.27
sysdev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sysdev/pci/ixgbe/ixgbe_x540.h 1.9
sysdev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sysdev/pci/ixgbe/ixgbe_x550.h 1.6
sysdev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.56.2.31 11-Mar-2021  martin Pull up the following (all via patch), requested by msaitoh in ticket #1663:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.3, 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.56.2.30 05-Aug-2020  martin Pull up the following revisions, requested by msaitoh in ticket #1587:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.56.2.29 24-Jan-2020  martin Pull up the following, requested by msaitoh in ticket #1490:

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.
 1.56.2.28 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1451):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.216
sys/dev/pci/ixgbe/ixv.c: revision 1.141

Print MAC address.

XXX Should we move such type of printf() to ether_ifattach?
 1.56.2.27 14-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1435):

sys/dev/pci/ixgbe/ixv.c: revision 1.140

ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.
 1.56.2.26 08-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1403):

sys/dev/pci/ixgbe/ixv.c: revision 1.139

Set MTU correctly if mtu > 1500.
 1.56.2.25 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1389:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213 via patch
sys/dev/pci/ixgbe/ixv.c 1.131-1.138 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58 via patch
share/man/man4/ixv.4 1.5 via patch

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- Fix a bug that the multicast filter isn't correctly initialized when
the total number of the Ethernet multicast addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
 1.56.2.24 05-Sep-2019  martin Apply patch, requested by msaitoh in ticket #1367, to pull up the following
revisions:

sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixgbe.c 1.180,1.203-1.204,
1.207-1.208 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.55
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.10
sys/dev/pci/ixgbe/ixgbe_common.c 1.25
sys/dev/pci/ixgbe/ixv.c 1.129-1.130

- X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.
- An interrupt might not arrive when a module is inserted. When an link
status change interrupt occurred and the driver still regard SFP as
unplugged, issue the module softint before issuing LSC softint.
- Add 10000BASE-LX media if it's 1000BASE-BX.
- printf -> device_printf
- Avoid undefined behavior of VLAN filter setting.
- Simplify code.
- Fix typo in unused code.
- Fix typo in comment. Found by Wataru Ashihara.
 1.56.2.23 01-Aug-2019  martin Pull up the following revisions, requested by msaitoh in ticket #1313:

sys/dev/pci/ixgbe/ixgbe_type.h 1.41
sys/dev/pci/ixgbe/ixgbe.c 1.194,1.197-1.199
via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.24
sys/dev/pci/ixgbe/ixv.c 1.121,1.124-1.125

- Avoid undefined behavior of interrupt vector setting.
- Avoid undefined behavior of TX/RX queue statistics calculation.
- Avoid undefined behavior of X550EM's PHY accesses.
- Avoid undefined behavior of Flow Control Transmit Timer setting.
- Don't call {ixgbe,ixv}_stop() twice while detaching.
 1.56.2.22 22-Jul-2019  martin Pull up the following revisions (via patch), requested by msaitoh in
ticket #1301:

sys/dev/pci/ixgbe/if_sriov.c 1.5-1.6
sys/dev/pci/ixgbe/ix_txrx.c 1.53-1.54
sys/dev/pci/ixgbe/ixgbe_x550.h 1.5
sys/dev/pci/ixgbe/ixgbe.c 1.169-1.170,1.176,1.179,1.181,1.185-1.186,1.188-1.192 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.53,1.55
sys/dev/pci/ixgbe/ixgbe_82599.c 1.21
sys/dev/pci/ixgbe/ixgbe_api.c 1.22-1.23
sys/dev/pci/ixgbe/ixgbe_api.h 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_common.c 1.23
sys/dev/pci/ixgbe/ixgbe_common.h 1.14
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.11
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.2
sys/dev/pci/ixgbe/ixgbe_features.h 1.2
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.9
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.9-1.10
sys/dev/pci/ixgbe/ixgbe_phy.c 1.18
sys/dev/pci/ixgbe/ixgbe_type.h 1.37,1.39-1.40
sys/dev/pci/ixgbe/ixgbe_vf.c 1.18
sys/dev/pci/ixgbe/ixv.c 1.112-1.114,1.117,1.119 via patch

Sync ixgbe up to 20190717 except ETHERCAP or ixv's VLAN stuff:
- Add firmware recovery mode for X550, X550A(Xeon D) and X550EM(C3000).
- Remove IXGBE_DEV_ID_82599_LS(0x154f) support again.
- On X550EMU, use ixgbe_identify_sfp_module_X550em() instead of
ixgbe_identify_module_generic(). ixgbe_identify_sfp_module_X550em()
has extra check (e.g. exclude 1G copper).
- It's not required to calculate unused queues' statistics.
- Remove ETHERCAP_VLAN_HWFILTER's definition.
- Match 82598_BX(0x1508), 82599_KR(0x1517), 82599_SFP_EM(0x1507),
X550EM_X_XFI(0x15b0), X550EM_A_QSFP(0x15ca) and
X550EM_A_QSFP_N(0x15cc)
- Add missing XFI support into ixgbe_get_link_capabilities_X550em().
- Other than IXGBE_VF_RESET should wait ACK, so use
ixgbevf_write_msg_read_ack() instead of write_posted() in
ixgbe_update_mc_addr_list_vf().
- When ixv_check_link() failed in the watchdog function, reset the
interface.
- Remove RXCSUM register modification in
ixv_initialize_receive_units(). It seems it's not required.
- Remove some debug printf in ixv_print_debug_info().
- Calculate vector's bit location correctly when the vector >= 31
in ixgbe_allocate_msix().
- Fix hung queue check when the queue number >= 31.
- On ENETRESET case, not continue and quit the ifflags_cb() function
because if_init() will do the same thing.
- Fix bugs in unused code.
- Fix typo in comment.
- Fix typo in unused code.
- Whitespace fixes. KNF.
 1.56.2.21 01-Apr-2019  martin Pull up the following, requested by msaitohin ticket #1225:

sys/dev/pci/ixgbe/ixgbe.c 1.175-1.178
sys/dev/pci/ixgbe/ixv.c 1.110-1.111 via patch

- NetBSD currently uses traffic class 0 only. Other traffic classes
aren't used yet. When IXGBE_TC_COUNTER_NUM is set to lower than
IXGBE_DCB_MAX_TRAFFIC_CLASS (e.g. 1), other traffic classes' counters
are not used. It means we don't generate evcnt for them and don't
add the values in ixgbe_update_stats_counters().
- It's not required to calculate unused queues' statistics.
- Fix a bug that the VLAN HW tagging function is not correctly disabled
when all vlan is detached.
- Fix a bug that VLAN HW tagging function is not correctly controlled
on 82598.
- Control VLAN HW filter function correctly. Note that currently
VLAN HW filter function doesn't work because NetBSD doesn't support
it yet.
- Don't clear IXGBE_VLNCTRL_CFIEN bit When ETHERCAP_VLAN_HWFILTER is
set. I think it's not required (and Linux doesn't do it). This change
has no effect to NetBSD because ETHERCAP_VLAN_HWFILTER is not
supported yet.
 1.56.2.20 01-Mar-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1199):

sys/dev/pci/ixgbe/ixv.c: revision 1.109
sys/dev/pci/ixgbe/ixgbe.h: revision 1.54
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.174

Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
 1.56.2.19 27-Jan-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1172):

sys/dev/pci/nvme_pci.c: revision 1.26
sys/dev/pci/xhci_pci.c: revision 1.21
sys/dev/pci/ixgbe/ixv.c: revision 1.108
sys/dev/pci/ixgbe/ixgbe.c: revision 1.171
sys/dev/pci/if_fxp_pci.c: revision 1.84
sys/dev/pci/if_fxp_pci.c: revision 1.85
sys/dev/pci/xhci_pci.c: revision 1.16

remove #ifdef DEBUG printf, it seems to have outlived it's usefulness

-

KNF. No functional change.

-

Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them explicitly enable
decoding but others don't. Add code to enable decoding to them.

See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
 1.56.2.18 08-Nov-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1084):

sys/dev/pci/ixgbe/ixv.c: revision 1.107
sys/dev/pci/ixgbe/ixgbe.c: revision 1.167

Don't set LRO capability flag because we don't support it yet.

This doesn't change any behavior other than if_capabilities' visibility
(e.g. ifconfig).
 1.56.2.17 09-Jun-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #864):

sys/dev/pci/ixgbe/ix_txrx.c 1.40-1.47 (patch)
sys/dev/pci/ixgbe/ixgbe.c 1.148,1.149,1.151,
1.152,1.154,
1.155,1.157-1.160 (patch)
sys/dev/pci/ixgbe/ixgbe.h 1.43,1.44,1.46,1.49 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.7 (patch)
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.8 (patch)
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.22 (patch)
sys/dev/pci/ixgbe/ixv.c 1.100-1.104 (patch)
sys/dev/pci/ixgbe/ixv.c 1.94,1.95,1.99 (patch)

Remove unused structure entries. No functional change.
-
Remove unused IXGBE_FC_HI and IXGBE_FC_LO. The watermark of the flow control
is automatically calculated from the size of the packet buffer.
-
Use ixgbe_eitr_write() when writing the EITR for the link interrupt like
queue's EITR to write the register safely. This change is not relatively
so important than queue's EITR because link's EITR is written in if_init().
-
Don't free and reallocate bus_dmamem when it's not required. Currently,
the watchdog timer is completely broken and never fire (it's from FreeBSD
(pre iflib)). If the problem is fixed and watchdog fired, ixgbe_init() always
calls ixgbe_jcl_reinit() and it causes panic. The reason is that
ixgbe_local_timer1(it includes watchdog function) is softint and
xgbe_jcl_reinit() calls bus_dmamem*() functions. bus_dmamem*() can't be called
from interrupt context.

One of the way to prevent panic is use worqueue for the timer, but it's
not a small change. (I'll do it in future).

Another way is not reallocate dmamem if it's not required. If both the MTU
(rx_mbuf_sz in reality) and the number of RX descriptors are not changed, it's
not required to call bus_dmamem_{unmap,free}(). Even if we use workque, this
change save time of ixgbe_init().

I have a code to fix broken watchdog timer but it sometime causes watchdog
timeout, so I don't commit it yet.
-
Count some register correctly:
- QPRDC register is only for 82599 and newer.
- Count IXGBE_QPRDC, PX{ON,OFF}{T,R}XC[NT].
The TQSMR register is not for receiving but for transmitting, so move the
initialization from ixgbe_initialize_receive_units() to
ixgbe_initialize_transmit_units(). No functional change.
-
Whitespace fix. No functional change.
-
Add rxd_nxck (Receive Descriptor next to check) read only sysctl.
Don't check IFF_RUNNING in ixgbe_rxeof(). Doing break and leaving a deacriptor
with DD bit is worse than just processing the entry. And it's also racy to
check IFF_RUNNING in rxeof(). If you'd like to strictly obey IFF_RUNNING,
it would be better to do it in the upper layer.
Same as DragonFly (a part of 79251f5ebe4cf9dd2f3e6aed590e09d756d39922).
Add "bool txr_no_space" for TX descriptor shortage. Use it like IFF_OACTIVE.
Clear que->disabled_count in {ixgbe,ixv}_init_locked(). Without this,
interrupt mask state and EIMS may mismatch and if_init doesn't recover
from TX/RX stall problem.
This change itself doesn't fix PR#53294.
-
Add hw.ixgN.debug sysctl. "sysctl -w hw.ixgN.debug=1" dumps some registers
to console.
-
Constify several variables in ixgbe/ so that they land in .rodata (1038
bytes).
-
Don't call ixgbe_rearm_queues() in ixgbe_local_timer1().
ixgbe_enable_queue() and ixgbe_disable_queue() try to enable/disable queue
interrupt safely. It has the internal counter. When a queue's MSI-X is
received, ixgbe_msix_que() is called (IPL_NET). This function disable the
queue's interrupt by ixgbe_disable_queue() and issues an softint.
ixgbe_handle() queue is called by the softint (IPL_SOFTNET), process TX, RX
and call ixgbe_enable_queue() at the end.

ixgbe_local_timer1() is a callout and run always on CPU 0 (IPL_SOFTCLOCK).
When ixgbe_rearm_queues() called, an MSI-X interrupt is issued for a specific
queue. It may not CPU 0. If this interrupt's ixgbe_msix_que() is called and
sofint_schedule() is called before the last sofint's softint_execute() is not
called, the softint_schedule() fails because of SOFTINT_PENDING. It result
in breaking ixgbe_{enable,disable}_queue()'s internal counter.
ixgbe_local_timer1() is written not to call ixgbe_rearm_queues() if
the interrupt is disabled, but it's called because of unknown bug or a race.

One solution to avoid this problem is to not to use the internal counter,
but it's little difficult. Another solution is stop using
ixgbe_rearm_queues() at all. Essentially, ixgbe_rearm_queues() is not
required (it was added in ixgbe.c rev. 1.43 (2016/12/01)).
ixgbe_rearm_queues() helps for lost interrupt problem but I've never seen it
other than ixgbe_rearm_queues() problem.

XXX pullup-8.
 1.56.2.16 07-Jun-2018  martin Pull up following revision(s) (requested by ozaki-r in ticket #843):

sys/dev/pci/ixgbe/ixv.c: revision 1.101
sys/net/if_bridge.c: revision 1.156
sys/net/if_pppoe.c: revision 1.138
sys/dev/pci/if_wm.c: revision 1.580
sys/dev/pci/ixgbe/ixgbe.c: revision 1.156
sys/net/if_gif.c: revision 1.142

Ensure to call if_register after interface initializations finish
 1.56.2.15 15-May-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #824):

sys/dev/pci/ixgbe/ixv.c: revision 1.97

Fix panic or hangup when "sysctl -w hw.ixgN.debug=1".
XXX pullup-8
 1.56.2.14 14-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #750):

sys/dev/pci/ixgbe/ixgbe_x540.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: revision 1.6
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.18
sys/dev/pci/ixgbe/if_sriov.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.7
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_dcb.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.91
sys/dev/pci/ixgbe/ixgbe_rss.h: revision 1.4
sys/dev/pci/ixgbe/ixv.c: revision 1.92
sys/dev/pci/ixgbe/ixv.c: revision 1.93
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.4
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.12
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.33
sys/dev/pci/ixgbe/if_fdir.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.34
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.39
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.13
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.21
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_82599.h: revision 1.7
sys/dev/pci/ixgbe/ixgbe.c: revision 1.144
sys/dev/pci/ixgbe/ixgbe.c: revision 1.145
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe.c: revision 1.146
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82598.h: revision 1.8
sys/dev/pci/ixgbe/ixgbe.h: revision 1.41
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_phy.h: revision 1.11

Sync with the remaining part of FreeBSD r328265 except sfp_reinit stuff:
- Always schedule module intterrupt in ixgbe_config_link() when a device is
SFP+ based.
- Use not loop index but txr->me in ixv_initialize_{transmit,receive}_units().
It's required for VMDQ but NetBSD doesn't use it, so it's not a bug in
NetBSD.
- Simplify ixgbe_bp_wd_set(). No functional change.
- Whitespace.

Sync with FreeBSD r331224 except ixv_if_update_admin_status()'s change:
- Fix length of reading buffer when the command is Read Flash in
ixgbe_host_interface_command().
- Add missing start_hw() call in ixv_init_locked(). This is not a real bug
because start_hw just set hw->adapter_stopped to false and anyone refer it.
- Style change.
- Update comment.

Read sc_if_flags after taking core lock. Same as if_wm.c rev. 1.418.
 1.56.2.13 04-Apr-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #690):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe.c: revision 1.138
sys/dev/pci/ixgbe/ixv.c: revision 1.90
sys/dev/pci/ixgbe/ixgbe.c: revision 1.139
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.11
sys/dev/pci/ixgbe/ixgbe.h: revision 1.38
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe.h: revision 1.39
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.11
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.38
sys/dev/pci/ixgbe/ixgbe.c: revision 1.140
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.141
sys/dev/pci/ixgbe/ixgbe.c: revision 1.142
sys/dev/pci/ixgbe/ixgbe.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe.h: revision 1.40
sys/dev/pci/ixgbe/ixgbe_x550.h: revision 1.4

Fix the problem between eitr and link_speed.

In ixgbe_msix_que(), que->eitr_setting is limited to IXGBE_MIN_RSC_EITR_10G1G
when link_speed is 1Gbps or 10Gbps. However, que->eitr_setting is set to EITR
register in the *next* Tx/Rx interrupt. If link_speed changes from 100Mbps to
1Gbps ro 10Gbps, que->eitr_setting which is not limited can be set to EITR
register, that is, the problem fixed by ixgbe.c:r1.124 can occur in this case.

To fix this case, que->eitr_setting should be clear when link_speed is changed
or link state is changed.

Furthermore, expand the variants used for AIM (txr->bytes, txr->packets,
rxr->bytes and rxr->packets) from u32 to u64 to avoid wraparound which causes
que->eitr_setting calculation mistake.
XXX pullup-8

Don't write EIMC directly. It is required to manage with struct ix_queue status.
XXX pullup-8

- Add missing IFM_NONE support. If a interface support linkdown,
"ifconfig ixgN media none" drpos link. Not all interface can do link down.
Tested:
82598 AT2 (T)
92599 SF+(SFI) (X520-DA2)
X540
X550-T1
X550EM_x (X10SDV-8C-TLN4F)
X550EM_a (A2SDi-H-TP4F port 0, 1 (T))
Doesn't work:
X550EM_a (A2SDi-H-TP4F port 2, 3 (SFP+ (KR)))
X550EM_a (MA10-ST0 port 2, 3 (SFP+ (SFI)))
(Denverton SFP+ can't force link down because SFP+'s TX_DISABLE pin is
pull down. Is there a way to shutdown SFP+ cage's power?)
Not tested:
82598 fiber.
- Change some functions static.

Avoid issues caused by sending old packets at next link-up time.

This modification consists by the following two parts.
- drain packets in if_snd queue or corresponding txr->txr_interq
when link_active == false in ifp->if_start(), ifp->if_transmit(),
and deferred Tx processing
- drain packets in if_snd queue and all of txr->txr_interq's
at link-down time
ok by msaitoh@n.o.

Fix long standing bug that 82598 SFP+ panics in ixgbe_handle_mod() because
hw->mac.ops.setup_sfp is NULL. This change is a part of FreeBSD r327031.

Fix a bug that "ifconfig ixgN down up" forgot IFM_NONE setting.
- Don't assume autoneg == 0 is the first call of ixgbe_config_link().
Check ifm_media, too.
- Don't override autoneg_advertised in ixgbe_get_phy_id_fw() to not to
be inconsistent with if_media value.
 1.56.2.12 30-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #673):

sys/dev/pci/ixgbe/if_sriov.c: revision 1.2
sys/dev/pci/ixgbe/ixgbe.c: revision 1.135
sys/dev/pci/ixgbe/ixgbe.c: revision 1.136
sys/dev/pci/ixgbe/ixgbe.c: revision 1.137
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.17
sys/dev/pci/ixgbe/if_bypass.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.10
sys/dev/pci/ixgbe/ixgbe.h: revision 1.36
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.3
sys/dev/pci/ixgbe/ixgbe.h: revision 1.37
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.36
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.12
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.20
sys/dev/pci/ixgbe/ixv.c: revision 1.88
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.15
sys/dev/pci/ixgbe/ixv.c: revision 1.89
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.8
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.9

Add some changes from ix-3.2.17.tar.gz and r328265. Not fully synchronized.

Some others (e.g. sfp cage interrupt and bypass adapter stuff) will be merged
later:

- Initialize firmware command buffer correctly in ixgbe_read_ee_hostif_X550()
and ixgbe_read_ee_hostif_buffer_X550(). These functions are used when reading
NVM.
- Fix a bug that ixgbe_mng_present() misunderstand management capability on
X550 and newer on some environment. X550 changed FWSM bit definition.
See X540 document and X550's document and compare them.
- Fix checksum calculation in ixgbe_set_fw_drv_ver_generic(). This function is
not used in NetBSD.
- Add some unused funtions.
- Whitespace fix.
- Check offset correctly in ixgbe_get_oem_prod_version(). Note that this
function is not used.
- Set PHY correctly in ixgbe_setup_mac_link_sfp_x550a() if a device is a
C3000 KR SFP+.

Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.

The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()

The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().

Tested by msaitoh@n.o and me.

Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.

The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()

ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).

ok by msaitoh@n.o.

- Add link related softint's counter.
- Fix indent.
 1.56.2.11 13-Mar-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #626):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.134
sys/dev/pci/ixgbe/ixgbe.h: revision 1.35
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.35
sys/dev/pci/ixgbe/ixv.c: revision 1.87
Make some event counters MP safe. Now all of the event counters are
MP safe.
 1.56.2.10 08-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #612):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.129-1.133
sys/dev/pci/ixgbe/ixgbe.h: revision 1.34
sys/dev/pci/ixgbe/ixv.c: revision 1.85,1.86

- Make "Handled queue in softint" and "Requeued in softint" evcnt(9) per queue
and count them correctly.
- Remove #if 0'ed code.

Don't increment que->req.ev_count in MSI-X interrupt because it's not
reschedule.

Fix another poll mode assumption breaking. Implemented by msaitoh@n.o, I just commit by proxy.
ixgbe_rearm_queues() writes EICS register(s). 82599, X540 and X550
specifications say "Following a write of 1b to any bit in the EICS register
(interrupt cause set), its corresponding bit in the EIMS register is auto
set as well enabling its interrupt." in "Extended Interrupt Auto Mask Enable
(EIAM) Register" section. That is, ixgbe_rearm_queues() causes interrupts
regardless of the status managed by ixgbe_enable_queue()/ixgbe_disable_queue().

That can break poll mode assumption.

In fact, the problem occurs in the following situation
- CPU#A has high load traffic, in contrast, CPU#B has not so high load traffic
- CPU#A is occurred interrupt by its NIC queue
- CPU#A calls ixgbe_disable_queue() in interrupt handler(ixgbe_msix_que())
- CPU#A kick softint handler(ixgbe_handle_que())
- CPU#A begins softint
- CPU#A's NIC queue is set que->txr->busy flag
- With some reason, CPU#A can do ixg interrupt handler
E.g. when one of CPU#A's softnet handlers sleeps, ipl is lowered
- CPU#B starts callout
- CPU#B calls ixgbe_local_timer1()
- CPU#B writes EICS bit corresponding CPU#A's NIC queue bit
- CPU#A's NIC queue causes interrupt whie CPU#A is running in poll mode
- CPU#A calls ixgbe_disable_queue() in interrupt handler *again*
- CPU#A has done polling, and then CPU#A calls ixgbe_enable_queue() *once*
- CPU#A's NIC queue interrupt is disabled until ixg is detached as
ixgbe_disable_queue() is called twice though ixgbe_disable_queue() is
called once only
NOTE:
82598 does not say so, but it is treated in the same way because of no harm.
By the way, we will refactor ixgbe_local_timer(watchdog processing) later.

Fix INTx/MSI handler did not schedule workqueue. Pointed out by msaitoh@n.o.

Reduce duplicated code which schedule deferred packet processing. No functional change.
 1.56.2.9 06-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #605):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.32
sys/dev/pci/ixgbe/ixgbe.h: revision 1.33
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.34
sys/dev/pci/ixgbe/ixgbe.c: revision 1.128
sys/dev/pci/ixgbe/ixv.c: revision 1.83
sys/dev/pci/ixgbe/ixv.c: revision 1.84

Add hw.ixvM.q[01].{interrupt_rate,[tr]xd_head,[tr]xd_tail} sysctls as ixg(4).

ixg(4) supports workqueue poll mode, but not enabled by default yet. (that is, the default behavior is *not* changed)

At the time of high load near the wire rate, the turnaround time
of update/delete processing such as "ifconfig ixg0 inet XXX" or
"ifconfig ixg0 delete" is very long. The main reason is CPU
starvation caused by ixg(4)'s softint poll mode. ixg(4) uses
workqueue poll mode instead of softint poll mode, so that this
problem will be fix.

This change may cause performance issues, so it is not enabled
by default yet. Although there are that issues, if you want to use
workqueue poll mode, do "sysctl -w hw.ixgXX.txrx_workqueue=1" while
there is no traffic on the ixgXX.

ok by msaitoh@n.o.

ixv(4) also supports workqueue poll mode, but not enabled by default yet, either.
ok by msaitoh@n.o.

Move the location of "struct work" as FreeBSD's "struct task" in ixgbe.h.
No functional change.
 1.56.2.8 01-Mar-2018  martin Pull up following revision(s) (requested by knakahara in ticket #597):
sys/dev/pci/ixgbe/ixgbe.h: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.c: revision 1.127
sys/dev/pci/ixgbe/ixv.c: revision 1.82
Fix poll mode assumption breaking.
ixgbe_{enable,disable}_intr() forcibly enable/disable all interrupts
regardless of current state. That can break poll mode assumption,
that is, queue interrupts must not occur while polling Tx/Rx rings.
E.g. "ifconfig ixg0 delete && ifconfig ixg0 192.168.0.1" on heavy
load traffic can causes this issue.
This fix may have 1% or 2% performance impact at short packets.
XXX
ixgbe_rearm_queues() which is called only via watchdog can also break
this poll mode assumption because writing EICS casues interrupts
immediately when interrupt auto mask enabled.
We will fix it with other issues about watchdog later.
ok by msaitoh@n.o.
Apply ixgbe.c:r1.127 to ixv.c. Pointed out by msaitoh@n.o.
 1.56.2.7 26-Feb-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #592):
sys/dev/pci/ixgbe/ixv.c: revision 1.79
sys/dev/pci/ixgbe/ixgbe.h: revision 1.30
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.31
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.31
sys/dev/pci/ixgbe/ixgbe.c: revision 1.120
sys/dev/pci/ixgbe/ixgbe.c: revision 1.121
sys/dev/pci/ixgbe/ixgbe.c: revision 1.123
sys/dev/pci/ixgbe/ixgbe.c: revision 1.124
sys/dev/pci/ixgbe/ixgbe.c: revision 1.125
sys/dev/pci/ixgbe/ixgbe.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.80
sys/dev/pci/ixgbe/ixv.c: revision 1.81
CID-1427719: Integer handling issues (BAD_SHIFT). Print bus/slot info
correctly on 82599_SFP_SF_QP(DID 0x154a) and 82599_QSFP_SF_QP(DID 0x1558).
Fix a bug that RX may stall on heavy load on ixg(4). ixgbe_rxeof() has loop
limit and the function returns true if a packet are still in the RX ring.
ixgbe_handle_que() didn't check the return value. Check the return vaule
and issue a softint.
This bug is derived from FreeBSD and ixv(4) has no this bug.
XXX pullup-8
Fix a bug that the first call of ifflags_cb() causes linkdown. The first
call of ix(gbe|v)_ifflags_cb() refered uninitialized adapter->if_flags.
adapter->if_flags should be initialized in the end of xxx_init().
XXX pullup-[678] (ixgbe)
XXX pullup-8 (ixv)
- Fix a bug that RX may stall on heavy load on ixg(4) derived from FreeBSD's
AIM (Auto Interrupt Moderation) bug.
When I use a machine as a NFS client, sometimes one of queue pairs doesn't
get any interrupt other than every second tick via ixgbe_local_timer1().
When the problem occured, the queue pair's hw.ixgM.qN.interrupt_rate is
always 500000. When this problem occuring, set hw.ixgM.qN.interrupt_rate lower
than 166667 recover from stall. i.e.:
sysctl -w hw.ixgM.qN.interrupt_rate=166667 (don't revocer)
sysctl -w hw.ixgM.qN.interrupt_rate=166666 (recover)
Relatios between the interrupt_rate and EICR's ITR_INTERVAL field is as
follows:
int_rate | EICR[11:0] | interval in us | recover |
|(ITR_INTERVAL)| (10G and 1G) | |
---------+--------------+----------------+---------+
500000 | 0x008(0) | 2 | not |
166667 | 0x010(1) | 4 | not |
166666 | 0x018(2) | 6 | recover |
The reason why int_rate becomes 500000 is that xgbe_tx_eof() doesn't
increment rxr->packets(*1). Even if we fix rxr->packets' bug, interrupt_rate
might become greater than 166666 and it might cause stall.
While reading datasheets, knakahara noticed a section titled with "ITR
Affect on RSC Functionality". It says "When RSC is enabled on specific RX
queues, the associated ITR interval with these queus must be enabled and must
be larger (in time uints) than RSC delay". Currently, RSC_DELAY field in the
GPIE register is 0 and it means 4us for 10G and 1G. The greater ITR_INTERVAL
value of 4us is 6us == 166666. Yes, BINGO!
This description is noted in 82599 and newer datasheets and not in 82598
datasheet. I don't know if 82598 has this limitation but, I apply this
limitation all of chips.
(*1) Note that this bug is going to be fixed in the next commit to distinct
between two different bugs.
- The bitfield of EITR register is different between 82598 and others.
Only ixgbe_msix_que() taken care of it. Make new function ixgbe_eitr_write()
and use it in all of functions which modify ITR_INTERVAL.
XXX pullup-8
Increment rxr->packets correctly in ixgbe_rxeof() to calculate ITR value
of AIM (Auto Interrupt Moderation) correctly. See also ixgbe.c rev. 1.124.
XXX pullup-8
Improve a comment about reading EICS register defined write-only by spec.
It seems that is workaround for silicon errata.
ok by msaitoh@n.o.
- Apply ixgbe.c rev. 1.124 to ixv.c. Fix a bug that RX may stall on heavy load
on ixv(4) derived from FreeBSD's AIM (Auto Interrupt Moderation) bug.
ITR_INTERVAL value must be larger than 4us.
- The bitfield of EITR register is different between 82598 and others.
ixv.c had a bug that it accessed 82598's way even though only 82599 and
newer support virtual function. Fix it using with new ixv_eitr_write()
function.
Fix a potential bug that TX/RX might stall when TX rate limit reached.
This change is almost the same as the RX rate limit bug fix in ixgbe.c
rev. 1.121. I've never got any stall, but this must be a bug.
 1.56.2.6 26-Feb-2018  snj Pull up following revision(s) (requested by knakahara in ticket #567):
distrib/sets/lists/comp/mi: 1.2182-1.2183
sys/dev/pci/if_wm.c: 1.564
sys/dev/pci/ixgbe/ixgbe.c: 1.122
sys/dev/pci/ixgbe/ixgbe_rss.h: 1.3
sys/dev/pci/ixgbe/ixv.c: 1.78
sys/net/Makefile: 1.35-1.36
sys/net/files.net: 1.15
sys/net/rss_config.c: 1.1
sys/net/rss_config.h: 1.1
Introduce very simple Receive Side Scaling (RSS) utility.
ok by msaitoh@n.o.
--
Apply RSS utility to wm(4).
ok by msaitoh@n.o.
--
Apply RSS utility to ixg(4) and ixv(4).
ok by msaitoh@n.o.
--
Fix build failure, sorry.
--
Currently, it is not necessary to install rss_config.h. Pointed out by msaitoh@n.o.
 1.56.2.5 13-Jan-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #490):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.116-1.119
sys/dev/pci/ixgbe/ixv.c: revision 1.76-1.77
Don't panic when resource shortage occured. Fixes PR#52820 reported by
kardel@:
- Don't use if_free() because ixgbe(4) don't use if_alloc().
- Move location of {ixgbe,ixv}_setup_interface() call at a position that
any error don't occur. One of the reason is that it should be. Another
reason is that it's hard to call ether_ifdetach() and if_detach() when
cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
and maybe more).
--
Don't panic when resource shortage occured. Like ixgbe.c rev. 1.116.
- Move location of {ixgbe,ixv}_setup_interface() call at a position that
any error don't occur. One of the reason is that it should be. Another
reason is that it's hard to call ether_ifdetach() and if_detach() when
cold == 1 (because of pserialize_perform, xc_wait, timing of domaininit
and maybe more).
--
Fix panic when only link interrupt can't be established.
--
- If MSI can't be used on some environment, fallback to INTx correctly.
- Use single vector MSI when number of CPU is 1 to save interrupt slot.
--
Fallback from MSI-X to MSI or INTx if MSI-X setup failed.
 1.56.2.4 02-Jan-2018  snj Pull up following revision(s) (requested by ozaki-r in ticket #456):
sys/arch/arm/sunxi/sunxi_emac.c: 1.9
sys/dev/ic/dwc_gmac.c: 1.43-1.44
sys/dev/pci/if_iwm.c: 1.75
sys/dev/pci/if_wm.c: 1.543
sys/dev/pci/ixgbe/ixgbe.c: 1.112
sys/dev/pci/ixgbe/ixv.c: 1.74
sys/kern/sys_socket.c: 1.75
sys/net/agr/if_agr.c: 1.43
sys/net/bpf.c: 1.219
sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
sys/net/if_etherip.c: 1.40
sys/net/if_ethersubr.c: 1.243, 1.246
sys/net/if_faith.c: 1.57
sys/net/if_gif.c: 1.132
sys/net/if_l2tp.c: 1.15, 1.17
sys/net/if_loop.c: 1.98-1.101
sys/net/if_media.c: 1.35
sys/net/if_pppoe.c: 1.131-1.132
sys/net/if_spppsubr.c: 1.176-1.177
sys/net/if_tun.c: 1.142
sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
sys/net/npf/npf_ifaddr.c: 1.3
sys/net/npf/npf_os.c: 1.8-1.9
sys/net/rtsock.c: 1.230
sys/netcan/if_canloop.c: 1.3-1.5
sys/netinet/if_arp.c: 1.255
sys/netinet/igmp.c: 1.65
sys/netinet/in.c: 1.210-1.211
sys/netinet/in_pcb.c: 1.180
sys/netinet/ip_carp.c: 1.92, 1.94
sys/netinet/ip_flow.c: 1.81
sys/netinet/ip_input.c: 1.362
sys/netinet/ip_mroute.c: 1.147
sys/netinet/ip_output.c: 1.283, 1.285, 1.287
sys/netinet6/frag6.c: 1.61
sys/netinet6/in6.c: 1.251, 1.255
sys/netinet6/in6_pcb.c: 1.162
sys/netinet6/ip6_flow.c: 1.35
sys/netinet6/ip6_input.c: 1.183
sys/netinet6/ip6_output.c: 1.196
sys/netinet6/mld6.c: 1.90
sys/netinet6/nd6.c: 1.239-1.240
sys/netinet6/nd6_nbr.c: 1.139
sys/netinet6/nd6_rtr.c: 1.136
sys/netipsec/ipsec_output.c: 1.65
sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
 1.56.2.3 21-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #441):
sys/dev/pci/files.pci: 1.390
sys/dev/pci/ixgbe/if_bypass.c: new
sys/dev/pci/ixgbe/if_fdir.c: new
sys/dev/pci/ixgbe/if_sriov.c: new
sys/dev/pci/ixgbe/ixgbe_bypass.h: new
sys/dev/pci/ixgbe/ixgbe_fdir.h: new
sys/dev/pci/ixgbe/ixgbe_features.h: new
sys/dev/pci/ixgbe/ixgbe_netmap.c: new
sys/dev/pci/ixgbe/ixgbe_netmap.h: new
sys/dev/pci/ixgbe/ixgbe_rss.h: new
sys/dev/pci/ixgbe/ixgbe_sriov.h: new
sys/dev/pci/ixgbe/ix_txrx.c: 1.28, 1.30 via patch
sys/dev/pci/ixgbe/ixgbe.c: 1.97-1.105, 1.107-1.111, 1.113-1.115
sys/dev/pci/ixgbe/ixgbe.h: 1.26-1.29 via patch
sys/dev/pci/ixgbe/ixv.c: 1.57-1.58, 1.60-1.61, 1.63-1.64, 1.66-1.72, 1.75 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.17-1.18 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.26-1.30 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.15-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_api.h: 1.10-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.14-1.16 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.5-1.6
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_mbx.c: 1.7-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h: 1.11-1.12 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.c: 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.18-1.19 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.9-1.10 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.13-1.15 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h: 1.9-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c: 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_x540.h: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.c: 1.6-1.7
sys/dev/pci/ixgbe/ixgbe_x550.h: 1.3
Sync with FreeBSD's up to r326022, fix bugs and some improvements:
- Don't limit number of queue pair to 8. Take chip's max TX queues and
max RX queues into account.
- Add C3000 (Denverton) support.
- Add bypass function support for bypass adapters.
- Change EEE sysctl.
- Remove thermal test sysctl.
- ixv(4): set RSS mapping.
- ixv(4): Add TSOv6.
- ixv(4): Fix hardware counter.
- ixv(4): Make TX/RX descriptors size the same as ixg(4).
- ixv(4): Print device name in ixv_attach().
- ixv(4): Make mailbox statistic counters evcnt(9).
- ixv(4): Fix a problem that mailbox interrupt never occurred.
- ixv(4): Don't check neither VTEICR nor VTEICS same as Linux. It
seems that both registers can't be used to check which MSI-X vector
is triggered.
- ixv(4): Print Mailbox API version.
- Print driver feature capabilities and enable bits when verbose boot.
- Fix a bug that X550EM_A (Denverton) can't force 10BaseT.
- Remove all half-duplex setting because of the chip specification.
- Add 2.5GBASE-T and 5GBASE-T support.
- Set ifm_baudrate correctly.
- Protect ec_multi* with mutex like other MP safe Ethernet drivers.
- On X550 and newer, print NVM Image Version with %u.%02x.
- On X540, print PHY FW Revision with %u.%x. 0x4030 will be printed
as "Revision 4.3 ID 0x0"
- Fix value check of OEM_NVM_IMAGE_VER.
- Print PHY ID only for copper PHY.
- Fix a bug that X550 and newer didn't linkup if it forces
100BaseTX-FDX or 10BaseT-FDX.
- Fix a bug that RX may accesses freed area. It also fixes a problem
that if_init() takes long time on many core machine.
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This
change has no influence to netbsd because it's enabled by default
and NetBSD has no API to disable it.
- Whitespace fix.
 1.56.2.2 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.56.2.1 23-Sep-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #288):
sys/dev/pci/ixgbe/ixv.c: 1.59 and 1.62 via patch
- Use cprng_strong64() instead of cprng_fast64() to prevent panic.
- Set get_link_status to true before calling ixv_config_link() in
ixv_init_locked() to get the first link status correctly.
 1.84.2.11 26-Jan-2019  pgoyette Sync with HEAD
 1.84.2.10 30-Sep-2018  pgoyette Ssync with HEAD
 1.84.2.9 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.84.2.8 25-Jun-2018  pgoyette Sync with HEAD
 1.84.2.7 21-May-2018  pgoyette Sync with HEAD
 1.84.2.6 22-Apr-2018  pgoyette Sync with HEAD
 1.84.2.5 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.84.2.4 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.84.2.3 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.84.2.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.84.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.105.2.3 21-Apr-2020  martin Sync with HEAD
 1.105.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.105.2.1 10-Jun-2019  christos Sync with HEAD
 1.125.2.25 03-Feb-2024  martin Pull up the following, requested by msaitoh in ticket #1792:

sys/dev/pci/ixgbe/ix_txrx.c 1.105-1.116 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.345-1.346,1.349 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.94-1.98
sys/dev/pci/ixgbe/ixgbe_type.h 1.62
sys/dev/pci/ixgbe/ixv.c 1.193,1.195-1.196

- Clear the WTHRESH bit field before writing it.
- Optimize ixgbe_txeof().
- Use kmem_zalloc() instead of malloc(,M_ZERO).
- Add QPRDC(Queue Packet Receive Drop Count) into iqdrops.
- No functional change
- Move assignment of TXD.
- ixv(4): Remove unused IFF_OACTIVE.
- Don't include the Flow Director related members to reduce the
size of struct tx_ring. On amd64 and aarch64, the real size is
not changed because of the alignment.
- The descriptor ring size and the alignment are tested in the
attach function, so it's not required to use
roundup2(size, DBA_ALIGN).
- Use #ifdef LRO more to reduce the size of struct rx_ring.
- Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring
and rx_ring because of the alignment.
- Th RSC (hardware receive side coalescing) feature has been
disabled all along, so enclose the code with #ifdef RSC.
- Remove unused.
- Modify for the readability.
- Modify comment.
- Fix comment. Whitespace.
 1.125.2.24 18-Oct-2023  martin Pull up the following, requested by msaitoh in ticket #1753:

sys/dev/pci/ixgbe/ix_txrx.c 1.103-1.104
sys/dev/pci/ixgbe/ixgbe.c 1.334-1.338,
1.341-1.344 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.90-1.93
sys/dev/pci/ixgbe/ixgbe_82599.c 1.31-1.32
sys/dev/pci/ixgbe/ixgbe_api.c 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.5
sys/dev/pci/ixgbe/ixgbe_common.c 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_common.h 1.18
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.14-1.15
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.13
sys/dev/pci/ixgbe/ixgbe_type.h 1.59-1.61
sys/dev/pci/ixgbe/ixgbe_x540.c 1.24
sys/dev/pci/ixgbe/ixgbe_x550.c 1.28
sys/dev/pci/ixgbe/ixv.c 1.187-1.192

- ixg(4): Add 82599 LS support once again.
- ixg(4): Filter out spurious link up indication more.
- ixg(4): Print DEVICE_CAPS register.
- ixg(4): Fix a bug that the number of queues is unintentionally
limited to a small number or wrong error message may be printed
when two devices' number of MSI-X vectors are different.
- Modify error message of wrong TX/RX descriptor size.
- Enable interrupt after setting IFF_RUNNING.
- Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change
all devices all queues default interrupt rate.
- Cleanup the code.
 1.125.2.23 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1749):

sys/dev/pci/ixgbe/if_bypass.c 1.10
sys/dev/pci/ixgbe/if_fdir.c 1.6 via patch
sys/dev/pci/ixgbe/if_sriov.c 1.18 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.102 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.333,1.339 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.89
sys/dev/pci/ixgbe/ixgbe_api.h 1.17
sys/dev/pci/ixgbe/ixgbe_common.h 1.17
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.4
sys/dev/pci/ixgbe/ixgbe_common.c 1.45
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.5
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.6
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.9
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.6
sys/dev/pci/ixgbe/ixgbe_type.h 1.58
sys/dev/pci/ixgbe/ixgbe_x550.c 1.27
sys/dev/pci/ixgbe/ixv.c 1.186 via patch

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.125.2.22 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #1745):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.125.2.21 23-Jan-2023  martin Pull up the following revisions, requested by msaitoh in ticket #1579:

sys/dev/pci/files.pci 1.442
sys/dev/pci/ixgbe/ix_txrx.c 1.99-1.100
sys/dev/pci/ixgbe/ixgbe.c 1.320-1.324 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.19
sys/dev/pci/ixgbe/ixgbe_api.c 1.28
sys/dev/pci/ixgbe/ixgbe_common.c 1.43
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.17
sys/dev/pci/ixgbe/ixv.c 1.183

- Add an option for Tx to use deferred softint regardless of whether
can get txq lock or not. It's off by default.
- Call txeof first, then rxeof for the consistency.
- Make three "Unsupported SFP+ module..." messages the same.
- KNF. Modify comment. Fix typo.
 1.125.2.20 02-Jun-2022  martin Pull up the following revisions, all via patch, requested by msaitoh
in ticket #1459:

sys/dev/pci/ixgbe/ixgbe.c 1.261,1.265-1.268,1.273,1.275-1.277,
1.312,1.316-1.319 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.85 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.46-1.47
sys/dev/pci/ixgbe/ixgbe_x550.c 1.26
sys/dev/pci/ixgbe/ixv.c 1.182

- Reduce code duplication between ixgbe_msix_admin() and
ixgbe_legacy_irq().
- Add missing code which was not in ixgbe_msix_admin() from
ixgbe_legacy_irq() and vice versa.
- Reorder code.
- Disable/enable the OTHER interrupts correctly.
- Don't return in the middle of ixgbe_msix_admin() when an flow
director reinit failed. NetBSD currently doesn't support flow
director, so this is not a real bug.
- Print ECC, PHY and temp error log using with ratecheck().
- Correctly re-enable queue interrupt in ixgbe_legacy_irq().
- Correctly enter the recovery mode.
- No functional change:
- Add some debug printf()s.
- Don't use "more" flag for simplify.
- Fix typos in comment.
- KNF.
 1.125.2.19 31-May-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1458):

sys/dev/pci/ixgbe/ixv.c: revision 1.181
sys/dev/pci/ixgbe/ixgbe.c: revision 1.315
sys/dev/pci/ixgbe/ixgbe.h: revision 1.86

Fix a bug that the legacy interrupt doesn't work when MSI-X allocation failed.
Fixes PR kern/56857.

Remove unused adapter->msix_mem.
 1.125.2.18 30-May-2022  martin Pull up the following revisions, requested by msaitoh:

sys/dev/pci/ixgbe/ixgbe.c 1.270,1.280,1.307-1.311,
1.313-1.314 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.96-1.97
sys/dev/pci/ixgbe/ixv.c 1.158,1.179-1.180 via patch


- ixg(4): Print Printed Board Assembly (PBA) number.
- ixg(4): Add IFF_RUNNING check in ixgbe_legacy_irq() again. this might
fix small race but it's not so dangerous.
- Add value check for {tx,rx}_process_limit sysctl to avoid setting
wrong value.
- Add missing num_tx_desc sysctl.
- No functional change:
- KNF a bit.
- Simplify setting of EIAC register.
- Move the definition of eicr_mask variable.
- Enclose flow director stuff in ixgbe_intr_admin_common() with
IXGBE_FIR which is not defined in NetBSD.
- Modify comment for consistency.
- Use cached rx_copy_len in ixgbe_rxeof().
 1.125.2.17 02-Feb-2022  martin Pull up the following revisions (requested by msaitoh in ticket #1424):

sys/dev/pci/ixgbe/ix_txrx.c 1.95
sys/dev/pci/ixgbe/ixgbe.c 1.305 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.19
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.15-1.16
sys/dev/pci/ixgbe/ixv.c 1.178 via patch

Use atomic_{load,store}_relaxed() for event counters.
 1.125.2.16 31-Jan-2022  martin Pull up following revision(s) (requested by msaitoh in ticket #1416):

sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.19
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.23
sys/dev/pci/ixgbe/if_sriov.c: revision 1.17
sys/dev/pci/ixgbe/ixv.c: revision 1.172
sys/dev/pci/ixgbe/ixv.c: revision 1.173
sys/dev/pci/ixgbe/ixgbe.c: revision 1.301
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.55
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.16
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_mbx.c: revision 1.18

Add code to support API version 1.5. No functional change.
- This change adds almost all code to support API 1.5 except real negotiation
and upgrade mailbox functions.
- From ix-3.3.18, ix-3.3.22 and ixv-1.5.24.

Enable mailbox API 1.5 support. Tested on ESXi with ixgben 1.10.3.0.

Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_vf().
Don't clear mailbox related counters in ixgbe_upgrade_mbx_params_pf().
 1.125.2.15 30-Jan-2022  martin Pull up the following revisions, requested by msaitoh in ticket #1414:

sys/dev/pci/ixgbe/if_sriov.c 1.12-1.16
sys/dev/pci/ixgbe/ixgbe.c 1.295-1.297,1.300,1.304 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.84
sys/dev/pci/ixgbe/ixgbe_82598.c 1.17-1.18
sys/dev/pci/ixgbe/ixgbe_82598.h 1.9
sys/dev/pci/ixgbe/ixgbe_82599.c 1.24-1.28
sys/dev/pci/ixgbe/ixgbe_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_api.c 1.26-1.27
sys/dev/pci/ixgbe/ixgbe_api.h 1.16
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.3
sys/dev/pci/ixgbe/ixgbe_common.c 1.34-1.42
sys/dev/pci/ixgbe/ixgbe_common.h 1.15-1.16
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.12-1.13
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.10-1.12
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.8
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.8
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.4
sys/dev/pci/ixgbe/ixgbe_features.h 1.4
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.13-1.15
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.15-1.18
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.8
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.31
sys/dev/pci/ixgbe/ixgbe_phy.c 1.25-1.29
sys/dev/pci/ixgbe/ixgbe_phy.h 1.13
sys/dev/pci/ixgbe/ixgbe_rss.h 1.6
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.5
sys/dev/pci/ixgbe/ixgbe_type.h 1.51-1.54
sys/dev/pci/ixgbe/ixgbe_vf.c 1.28-1.29
sys/dev/pci/ixgbe/ixgbe_vf.h 1.15
sys/dev/pci/ixgbe/ixgbe_x540.c 1.20-1.22
sys/dev/pci/ixgbe/ixgbe_x540.h 1.10
sys/dev/pci/ixgbe/ixgbe_x550.c 1.21-1.25
sys/dev/pci/ixgbe/ixgbe_x550.h 1.7
sys/dev/pci/ixgbe/ixv.c 1.170, 1.174-1.175 via patch

- Add typecast for type mismatch.
- Fix retry count calculation of I2C read/write.
- Wait longer for link after fiber MAC setup.
- ixv(4): Use adapter->mta for the multicast array memory instead of
the on-stack array.
- Match X550_PHY_ID correctly on X550.
- Print NVM image version on 82598.
- Use 64bit for lxon + lxoff.
- Don't expose garbage data of hw.ixvN.debug.
- Some NetBSD unrelated changes:
- Fix infinite recursion on PCIe link down if VMDQ is used.
- Move PF mailbox initialization from ixgbe_attach() to
ixgbe_init_iov().
- Add IPv6 mask for flow director.
- Change error level in ixgbe_fc_autoneg().
- Check host interface return status when writing NVM.
- Change DCB credit parameters.
- Restore some mailbox related functions. Revert part of ixgbe_mbx.c
rev. 1.7 and ixgbe_mbx.h rev. 1.11. No functional change.
- Rename IXGBE_VT_MSGTYPE_{ACK,NACK} to
IXGBE_VT_MSGTYPE_{SUCCESS,FAILURE}. No functional change.
- Remove unused argument. Change argument.
- Remove unnecessary return value check.
- Remove debug error message.
- Remove dead code.
- Add some unused macros.
- Fix typo in comment.
- Rename some functions.
- Sort lines, modify comment.
- Whitespace fix.
 1.125.2.14 29-Jan-2022  martin Pull up the following revisions (all via patch), requested by msaitoh
in ticket #1408:

sys/dev/pci/ixgbe/ixgbe_vf.h 1.16-1.17
sys/dev/pci/ixgbe/ixv.c 1.176-1.177

Make ifconfig -z ixvN clear event counter.
 1.125.2.13 20-Nov-2021  martin Pull up the following, requested by msaitoh in ticket #1374:

sys/dev/pci/ixgbe/ixgbe.h 1.81-1.83
sys/dev/pci/ixgbe/ixgbe.c 1.291-1.292 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.50
sys/dev/pci/ixgbe/ixv.c 1.167-1.168 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.94

- Fix a bug that a near 64KB TSO segment can't send.
- Reduce bus_dmamap_sync() cost.
- Use macro. Fix typos in comment.
 1.125.2.12 15-Sep-2021  martin Pull up the following (via patch), requested by msaitoh in ticket #1346:

sys/dev/pci/ixgbe/ixgbe.c 1.252, 1.280-1.283, 1.286-1.287, 1.289-1.290 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.73, 1.76-1.80 via patch
sys/dev/pci/ixgbe/ix_txrx.c 1.68-1.93
sys/dev/pci/ixgbe/ixv.c 1.153, 1.157-1.161, 1.163-1.166 via patch
sys/dev/pci/ixgbe/if_bypass.c 1.7-1.9
sys/dev/pci/ixgbe/if_fdir.c 1.4-1.5
sys/dev/pci/ixgbe/if_sriov.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_82598.c 1.16
sys/dev/pci/ixgbe/ixgbe_82599.c 1.23
sys/dev/pci/ixgbe/ixgbe_api.c 1.25
sys/dev/pci/ixgbe/ixgbe_bypass.h 1.2
sys/dev/pci/ixgbe/ixgbe_common.c 1.30-1.33
sys/dev/pci/ixgbe/ixgbe_dcb.c 1.10-1.11
sys/dev/pci/ixgbe/ixgbe_dcb.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h 1.7
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c 1.8-1.9
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h 1.7
sys/dev/pci/ixgbe/ixgbe_fdir.h 1.3
sys/dev/pci/ixgbe/ixgbe_features.h 1.3
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.12
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.13, 1.16-1.17
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.13-1.14
sys/dev/pci/ixgbe/ixgbe_netmap.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h 1.2
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.7
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.29-1.30
sys/dev/pci/ixgbe/ixgbe_phy.c 1.24
sys/dev/pci/ixgbe/ixgbe_rss.h 1.5
sys/dev/pci/ixgbe/ixgbe_sriov.h 1.4
sys/dev/pci/ixgbe/ixgbe_type.h 1.49
sys/dev/pci/ixgbe/ixgbe_vf.c 1.27
sys/dev/pci/ixgbe/ixgbe_x540.c 1.18-1.19
sys/dev/pci/ixgbe/ixgbe_x540.h 1.9
sys/dev/pci/ixgbe/ixgbe_x550.c 1.19-1.20
sys/dev/pci/ixgbe/ixgbe_x550.h 1.6
sys/dev/pci/files.pci 1.438
share/man/man4/ixg.4 1.15
share/man/man4/ixv.4 1.8

- Use MCLGET() instead of homegrown cluster (jcl) allocation mechanism.
Before this commit, resource shortage was easily occurred because
the total number of the clusters is small.
- Improve performance:
- Use m_adj(ETHER_ALIGN) more.
- Sprinkle __predict_false() in the RX path.
- Don't pre-allocate a cluster for RXCOPY case to improve short
packet's performance.
- Call bus_dmamap_unload(9) via ixgbe_dmamap_unload(), before freeing
DMA buffer. Also, when the buffer is already freed, do not call
bus_dmamap_unload(9) (no resource leaks with this change). This
change is required to make ixg(4) work on alpha.
- Keep m_len and m_pkthdr.len consistent to prevent panic on arm.
- Fix panic when bus_dmamap_load_mbuf() failed in
ixgbe_setup_receive_ring().
- Added BUS_DMA_COHERENT flag to bus_dmamem_map() to improve stability
on aarch64.
- Use uint64_t instead of bus_addr_t for the TX descriptor's buffer
address. At least, this change is required for macppc
(sizeof(bus_addr_t) == 4) to make TX work.
- Fix little-endian dependence.
- Set rxr->next_to_refresh correctly in ixgbe_setup_receive_ring().
- Refresh unrefreshed descriptors' buffers correctly.
- Don't call bus_dmamap_sync with rx_mbuf_sz(== MCLBYTES) to prevent
panic.
- Save the discard_multidesc state to not to forget the state by
exiting rxeof().
- Add missing increment of no_mbuf error counter.
- Don't increment no_mbuf evcnt(9) when discarding multi-descriptor
packet.
- ixv: Modify error message to sync with ixgbe.c
- Print the error value of ixgbe_reset_hw() for debugging.
- Remove extra unlock/lock processing around if_percpuq_enqueue().
- Refactor rxr->next_to_check updating.
- Add new sysctl "rx_copy_len".
- Add a new sysctl to read rxr->next_to_refresh.
- Print error number when error occurred.
- Rename ix{gbe,v}_stop() with ix{gbe,v}_stop_locked(). No functional
change.
- Don't use fixed value.
- Comment out flow director processing in fast path.
- Add missing NetBSD RCS IDs and __KERNEL_RCSID()s.
- KNF.
- Fix typos.
 1.125.2.11 11-Mar-2021  martin Pull up the following (all via patch) requested by msaitoh in ticket #1231:

sys/dev/pci/ixgbe/ixgbe.c 1.259, 1.278-1.279
sys/dev/pci/ixgbe/ixgbe.h 1.75
sys/dev/pci/ixgbe/ixgbe_netbsd.h 1.12
sys/dev/pci/ixgbe/ixgbe_vf.c 1.24-1.26
sys/dev/pci/ixgbe/ixgbe_x550.c 1.17
sys/dev/pci/ixgbe/ixv.c 1.155-1.156
sys/dev/pci/ixgbe/ix_txrx.c 1.64-67
sys/dev/pci/files.pci 1.436
share/man/man4/ixg.4 1.13-1.14
share/man/man4/ixv.4 1.6-1.7

- Fix a problem that the RX path stalled when the mbuf cluster is
exhausted.
- Modify some parameters to reduce packet dropping. See also the
manual's OPTIONS section for the detail.
- ixv(4): The max number of queue(pair) is not 7 but 8. Correctly
reset the hardware.
- Add "TX " to "Queue No Descriptor Available" evcnt(9) name to make
it more understandable.
- Fix a bug that some advertise speeds can't be set with
hw.ixgN.advertise_speed if both 2.5G and 5G are set. Fix the error
message, too.
- Fix typo in comment or debug message.
 1.125.2.10 10-Jul-2020  martin Pull up the following revisions, requested by msaitoh in ticket #997:

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
sys/dev/pci/ixgbe/ixgbe_common.c 1.27
sys/dev/pci/ixgbe/ixgbe_vf.c 1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c 1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.14
sys/dev/pci/ixgbe/ixgbe_phy.c 1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
was only on X550*.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.
 1.125.2.9 26-Jan-2020  martin Pull up the following (via patch), requested by msaitoh in ticket #648

sys/dev/pci/ixgbe/if_bypass.c 1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c 1.220-1.221
sys/dev/pci/ixgbe/ixgbe.h 1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c 1.24
sys/dev/pci/ixgbe/ixgbe_common.c 1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c 1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c 1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.142,1.144

- Free RX structure correctly when detaching.
- Remove unused code.
- Fix some typos in comment.
- Remove extra spaces.
- KNF.
 1.125.2.8 24-Dec-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #580):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.217
sys/dev/pci/ixgbe/ixgbe.c: revision 1.218
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.6
sys/dev/pci/ixgbe/ixv.c: revision 1.143
sys/dev/pci/ixgbe/ixgbe_osdep.h: revision 1.25

Use bus_space_barrier() instead of x86 specific *fence instruction.
Written by riastradh@.

Add missing core lock in ixgbe_handle_mod().
 1.125.2.7 19-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #453):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.216
sys/dev/pci/ixgbe/ixv.c: revision 1.141

Print MAC address.

XXX Should we move such type of printf() to ether_ifattach?
 1.125.2.6 14-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #422):

sys/dev/pci/ixgbe/ixv.c: revision 1.140

ixv(4): disable RSS configuration on 82599 and X540 VFs.

Those VFs share their RSS configuration with PF and, thus,
they cannot be configured independently. From FreeBSD r354349.
 1.125.2.5 08-Oct-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #293):

sys/dev/pci/ixgbe/ixv.c: revision 1.139

Set MTU correctly if mtu > 1500.
 1.125.2.4 26-Sep-2019  martin Pull up the following revisions, requested by msaitoh in ticket #246:

sys/dev/pci/ixgbe/ixgbe_type.h 1.42-1.43
sys/dev/pci/ixgbe/ixgbe.c 1.209-1.213
sys/dev/pci/ixgbe/ixgbe_x550.c 1.16
sys/dev/pci/ixgbe/ixv.c 1.131-1.138
sys/dev/pci/ixgbe/ixgbe_vf.c 1.19-1.22
sys/dev/pci/ixgbe/ixgbe_vf.h 1.14
sys/dev/pci/ixgbe/ixgbe.h 1.57-1.58
share/man/man4/ixv.4 1.5

- Fix a bug that MBSDC (Bad SFD Count) isn't counted on X550EM_X and
X550EM_A. The register is for X550 and newer.
- ixv(4): Make SIOCADDMULTI returns ENOSPC and print error message
when the Ethernet multicast address list exceeds the limit(30) and
can't be ALLMULTI.
- ixv(4): SIOCZIFDATA clear the event counters as ixgbe.c.
- Reduce ixv(4)'s multicast table array size in ixv_set_multi from
MAX_NUM_MULTICAST_ADDRESSES(128) to IXGBE_MAX_VF_MC(30).
- ixv(4): Add support ALLMULTI and PROMISC.
- if_flags is neither int nor short. It's unsigned short.
- ixg(4): Fix a bug that the multicast filter isn't correctly
initialized when the total number of the Ethernet multicast
addresses is just 128.
- Make ixv_set_multi() work correctly (especially for PROMISC) when the
function is called from if_init().
- Remove *_set_promisc() and use *_set_multi(). And then, rename
*_set_multi() to *_set_rxfilter().
- ixv(4): If a multicast entry has range, use ALLMULTI like others.
- Fix typo in comment. Found by Wataru Ashihara.
 1.125.2.3 05-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #180):

sys/dev/pci/ixgbe/ixv.c: revision 1.130
sys/dev/pci/ixgbe/ixgbe.c: revision 1.207
sys/dev/pci/ixgbe/ixgbe.c: revision 1.208
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.55
sys/dev/pci/ixgbe/ixv.c: revision 1.129
sys/dev/pci/ixgbe/ixgbe_netbsd.c: revision 1.10

printf -> device_printf

Set IFM_1000_BX10 correctly.

Use aprint_*() in the attach function.
 1.125.2.2 01-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #134):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.202
sys/dev/pci/ixgbe/ixgbe.c: revision 1.203
sys/dev/pci/ixgbe/ixgbe.c: revision 1.204
sys/dev/pci/ixgbe/ixv.c: revision 1.128

Simplify ix{gbe,v}_[un]register_vlan() API suggested by knakahara.

The API was the same as FreeBSD's pre-iflib's. They use iflib now and it's
not required for us to keep the old API.
X550EM supports QSFP, so check ixgbe_media_type_fiber_qsfp too.

An interrupt might not arrive when a module is inserted. When an link status
change interrupt occurred and the driver still regard SFP as unplugged, link
becomes up and the real media type is unknown. e.g:

% ifconfig -m ixg0
(snip)
media: Ethernet autoselect (autoselect rxpause,txpause)
status: active
supported Ethernet media:
media none
media autoselect
(snip)

To resolve this problem, when an link status change interrupt occurred and the
driver still regard SFP as unplugged, issue the module softint before issuing
LSC interrupt.
 1.125.2.1 01-Sep-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #133):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.200
sys/dev/pci/ixgbe/ixgbe.c: revision 1.201
sys/dev/pci/ixgbe/ixv.c: revision 1.126
sys/dev/pci/ixgbe/ixv.c: revision 1.127
sys/net/if_vlan.c: revision 1.142
sys/net/if_vlan.c: revision 1.143
sys/net/if_vlan.c: revision 1.144
sys/net/if_vlan.c: revision 1.145
sys/net/if_vlan.c: revision 1.146

Check ec_capenable instead of ec_capabilities to control TX side of VLAN HW
tagging correctly.
XXX pullup-9

Add missing IFNET_LOCK() and IFNET_UNLOCK() in vlan_config().
XXX pullup-9

Fix a bug that VLAN HW "tagging" enable/disable may not reflect correctly.
- Always call ec_vlan_cb() if it exists.
- Some (or all?) ethernet drivers don't enable HW tagging if no any vlan is
attached. ixgbe is one of them. Check the the transition and update
VLAN HW tagging function.
XXX pullup-9

Use ETHER_LOCK()/ETHER_UNLOCK() suggested by knakahara.
- kmem_alloc(,KM_SLEEP) never return NULL, so remove NULL check.
- VLAN ID is never duplicated, so break the loop when found. Also move
kmen_free() outside of ETHER_LOCK(ec)/ETHER_UNLOCK(ec) to reduce the hold
time. suggested by ozaki-r.
- Whitespace fix.
 1.143.2.2 29-Feb-2020  ad Sync with head.
 1.143.2.1 25-Jan-2020  ad Sync with head.
 1.147.2.1 20-Apr-2020  bouyer Sync with HEAD
 1.154.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.156.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.158.2.3 01-Aug-2021  thorpej Sync with HEAD.
 1.158.2.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.158.2.1 13-May-2021  thorpej Sync with HEAD.
 1.159.2.1 31-May-2021  cjep sync with head
 1.183.4.6 03-Feb-2024  martin Pull up following revision(s) (requested by msaitoh in ticket #563):

sys/dev/pci/ixgbe/ix_txrx.c: revision 1.110
sys/dev/pci/ixgbe/ixgbe.c: revision 1.345
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.111
sys/dev/pci/ixgbe/ixgbe.c: revision 1.346
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.112
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.62
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.113
sys/dev/pci/ixgbe/ixgbe.c: revision 1.348
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.114
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.115
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.116
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.105
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.106
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.107
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.108
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.109
sys/dev/pci/ixgbe/ixv.c: revision 1.193
sys/dev/pci/ixgbe/ixv.c: revision 1.195
sys/dev/pci/ixgbe/ixv.c: revision 1.196
sys/dev/pci/ixgbe/ixgbe.h: revision 1.94
sys/dev/pci/ixgbe/ixgbe.h: revision 1.95
sys/dev/pci/ixgbe/ixgbe.h: revision 1.96
sys/dev/pci/ixgbe/ixgbe.h: revision 1.97
sys/dev/pci/ixgbe/ixgbe.h: revision 1.98

ixgbe: Fix comment. No functional change.
ixgbe: Whitespace. No functional change.
ixgbe(4): Move assignment of TXD. NFCI.
ixgbe(4): Modify comment. No functional change.
ixgbe_tx_ctx_setup() may or may not consume one TX descriptor.
ixv(4): Remove unused IFF_OACTIVE. No functional change.
ixgbe: Clear the WTHRESH bit field before writing it.
ixgbe: Modify for the readability. No functional change.
ixgbe: micro-optimize ixgbe_txeof()
Update txr->tx_avail and txr->txr_no_space outside the loop in ixgbe_txeof().
ixgbe: Update if_opackets outside the loop in ixgbe_txeof().
ixgbe: micro-optimize ixgbe_txeof()
Update txr->packets outside the loop in ixgbe_txeof().
ixgbe: Use #ifdef IXGBE_FDIR more
Don't include the Flow Director related members to reduce the size of
struct tx_ring. On amd64 and aarch64, the real size is not changed
because of the alignment.
ixgbe: Simplify. No functional change.
The descriptor ring size and the alignment are tested in the attach
function, so it's not required to use roundup2(size, DBA_ALIGN).
ixgbe: Use kmem_zalloc() instead of malloc(,M_ZERO).
ixgbe: Remove unused to reduce the size of struct rx_ring.
ixgbe: Use #ifdef LRO more to reduce the size of struct rx_ring.
ixgbe: Change "me" from 32bit to 8bit because the max is 128.
This commit doesn't change the real size of ix_queue, tx_ring and rx_ring
because of the alignment.
ixgbe: Use #ifdef RSC
This feature (hardware receive side coalescing) has been disabled all along,
so enclose the code with #ifdef RSC.
 1.183.4.5 03-Nov-2023  martin Pull up following revision(s) (requested by yamaguchi in ticket #455):
sys/dev/pci/ixgbe/ixgbe.c: revision 1.347
sys/net/if_l2tp.c: revision 1.49
tests/net/if_vlan/t_vlan.sh: revision 1.25
sys/net/if_vlan.c: revision 1.171
sys/net/if_ethersubr.c: revision 1.326
sys/dev/pci/ixgbe/ixv.c: revision 1.194
Use ether_bpf_mtap only when the device supports vlan harware tagging
The function is bpf_mtap() for ethernet devices and *currently*
it is just handling VLAN tag stripped by the hardware.
l2tp(4): use ether_ifattach() to initialize ethercom
Support vlan(4) over l2tp(4)
Added the test for vlan over l2tp
 1.183.4.4 18-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #420):

sys/dev/pci/ixgbe/ixgbe.c: revision 1.340
sys/dev/pci/ixgbe/ixgbe.c: revision 1.341
sys/dev/pci/ixgbe/ixgbe.c: revision 1.342
sys/dev/pci/ixgbe/ixgbe.c: revision 1.343
sys/dev/pci/ixgbe/ixgbe.c: revision 1.344
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.61
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.104
sys/dev/pci/ixgbe/ixv.c: revision 1.190
sys/dev/pci/ixgbe/ixv.c: revision 1.191
sys/dev/pci/ixgbe/ixv.c: revision 1.192
sys/dev/pci/ixgbe/ixgbe.h: revision 1.93

ixg(4): Print DEVICE_CAPS register.

ixgbe: Whitespace. No functional change.

ixg(4): Don't print wrong error message about ixgbe_num_queues.
Don't override the ixgbe_num_queues global variable. It's the default
value of the number of queues and should not override it because it
will be referenced by later device attach. For example, the number of
MSI-X vector is 64 on X540 and 18 on 82599. When both cards are inserted
to a machine that the number of CPU is 24 and X540 is probed earlier,
ixgbe_num_queues is overridden to 24 and the following error message is
printed when attaching 82599:
ixg2: autoconfiguration error: ixgbe_num_queues (24) is too large,
using reduced amount (17).

Note that the number of queues is in sc->num_queuss and referenced
by hw.ixgN.num_queues sysctl.

ixgbe: Don't override the {ixgbe,ixv}_max_interrupt_rate global variable.

Fix a bug that changing hw.ix[gv]X.qY.interrupt_rate would change all
devices all queues default interrupt rate.

ixgbe: Whitespace. No functional change.
 1.183.4.3 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #407):

sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.47
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.60
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.31
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.32
sys/dev/pci/ixgbe/ixv.c: revision 1.187
sys/dev/pci/ixgbe/ixv.c: revision 1.188
sys/dev/pci/ixgbe/ixv.c: revision 1.189
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.18
sys/dev/pci/ixgbe/ixgbe_x540.c: revision 1.24
sys/dev/pci/ixgbe/ixgbe.c: revision 1.334
sys/dev/pci/ixgbe/ixgbe.c: revision 1.335
sys/dev/pci/ixgbe/ixgbe.c: revision 1.336
sys/dev/pci/ixgbe/ixgbe.c: revision 1.337
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.103
sys/dev/pci/ixgbe/ixgbe.c: revision 1.338
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.59
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.14
sys/dev/pci/ixgbe/ixgbe_dcb.c: revision 1.15
sys/dev/pci/ixgbe/ixgbe_api.c: revision 1.29
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.5
sys/dev/pci/ixgbe/ixgbe.h: revision 1.90
sys/dev/pci/ixgbe/ixgbe.h: revision 1.91
sys/dev/pci/ixgbe/ixgbe.h: revision 1.92
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.46

ixg(4): Remove unused and old function. No functional change.
- From FreeBSD's ix-3.3.32.

ixg(4): Add 82599 LS once again.
- From:
FreeBSD: 9228ac3a69c4c7401a743e6465e118101a2beeb0
DPDK: 549ccd3dc01539e060597b503f2b65b272de3347
- This was removed 5 years ago. From the commit message:
> Remove IXGBE_DEV_ID_82599_LS(0x154f) support again. I don't know why. This
> was added in ix-3.2.18.tar.gz(NetBSD: ixgbe_82599.c rev. 1.20) and
> removed in ix-3.3.6.tar.gz.

ixg(4): Filter out spurious link up indication
- Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.
- From FreeBSD:
In-tree: 04a5e6d7cadd06b10169c3c3a560649e7dc7444c
Out of tree: ix-3.3.33.

ixgbe: Simplify definitions. No functional change.
Both DEFAULT_{TX,RX}D and PERFORM_{TX,RX}D are 2048. Use DEFAULT_{TX,RX}D.
Same as FreeBSD.

ixgbe: Modify error message of wrong TX/RX descriptor size.
- Based from FreeBSD ix-3.3.35. I think ix-3.3.35's RING_INCREMENT(== 32)
is wrong. It should be 8(DBA_ALIGN / sizeof(union ixgbe_adv_[tr]x_desc)).
Linux also uses 8.

ixgbe: Remove NO_82599_SUPPORT and NO_X540_SUPPORT support. NFCI.
From FreeBSD ix-3.3.35. Note that this file is not used in NetBSD.

ixgbe: Enable interrupt after setting IFF_RUNNING. Same as FreeBSD x-3.3.35.

ixgbe: Cleanup. No fucntional change.

Remove unused code, fix whitespace and modify comment to reduce against
FreeBSD(mainly from ix-3.3.35).
 1.183.4.2 13-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #405):

sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.27
sys/dev/pci/ixgbe/ixgbe_fdir.h: revision 1.5
sys/dev/pci/ixgbe/ixv.c: revision 1.186
sys/dev/pci/ixgbe/ixgbe_osdep.c: revision 1.9
sys/dev/pci/ixgbe/ixgbe_common.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe_api.h: revision 1.17
sys/dev/pci/ixgbe/ixgbe.h: revision 1.89
sys/dev/pci/ixgbe/if_fdir.c: revision 1.6
sys/dev/pci/ixgbe/if_sriov.c: revision 1.18
sys/dev/pci/ixgbe/ixgbe.c: revision 1.333
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.102
sys/dev/pci/ixgbe/ixgbe.c: revision 1.339
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.58
sys/dev/pci/ixgbe/ixgbe_sriov.h: revision 1.6
sys/dev/pci/ixgbe/if_bypass.c: revision 1.10
sys/dev/pci/ixgbe/ixgbe_bypass.h: revision 1.4
sys/dev/pci/ixgbe/ixgbe_netmap.h: revision 1.3
sys/dev/pci/ixgbe/ixgbe_netmap.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.45

ixgbe: Rename some definitions, modify comment. No functional change.
Apply changes from FreeBSD's ix-3.3.31 and ixv-1.5.32.
- struct adapter *adapter -> struct ixgbe_softc *sc
- master -> primary
- black -> block

ixg(4): Whitespace. No functional change.
 1.183.4.1 08-Oct-2023  martin Pull up following revision(s) (requested by msaitoh in ticket #395):

sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329

ixgbe: Reorder some event counters for readability.

ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.

ixg(4): Count Queue Bytes {Transmit, Receive} counter.

ixg(4): Reorder some flow control related event counters for readability.

ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.

ixgbe: Fix typo in comment. No functional change.

ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.

ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
From FreeBSD ixv-1.5.30.

ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
 1.196.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 01-Dec-2016  msaitoh ixv.h is no more.
 1.7 17-Aug-2015  knakahara branches: 1.7.2;
Add kernel code to support intrctl(8).
 1.6 05-Aug-2015  msaitoh Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some bugfixes.
TODO:
- Merge r280182 and newer. It's required to support X55x.
- MSI/MSI-X support.
 1.5 02-Apr-2015  msaitoh Update our ixg(4) driver up to FreeBSD r238149:
- Add TSO6 support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Fix a lot of bugs.
- Improve performance.
 1.4 27-Mar-2015  msaitoh Synchronize our ixg(4) driver up to FreeBSD r230775:
- Add X540 support.
- Add 100BaseTX support.
- Fix a lot of bugs.
- Improve performance.
 1.3 10-Mar-2015  msaitoh Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
 1.2 27-Oct-2012  chs branches: 1.2.12; 1.2.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.1 12-Aug-2011  dyoung branches: 1.1.2; 1.1.12;
Add sources for ixgbe(4), a Intel 82599 10-gigabit ethernet driver
ported from FreeBSD.
 1.1.12.2 03-Dec-2017  jdolecek update from HEAD
 1.1.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1.2.1 30-Oct-2012  yamt sync with head
 1.2.14.3 05-Dec-2016  skrll Sync with HEAD
 1.2.14.2 22-Sep-2015  skrll Sync with HEAD
 1.2.14.1 06-Apr-2015  skrll Sync with HEAD
 1.2.12.3 14-Jun-2016  snj Pull up following revision(s) (requested by msaitoh in ticket #1174):
sys/dev/pci/ixgbe/README: 1.2
sys/dev/pci/ixgbe/ixgbe.c: 1.30-1.33, 1.35 via patch
sys/dev/pci/ixgbe/ixgbe.h: 1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c: 1.10 via patch
sys/dev/pci/ixgbe/ixgbe_api.c: 1.8-1.11 via patch
sys/dev/pci/ixgbe/ixgbe_api.h: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_common.c: 1.6-1.7 via patch
sys/dev/pci/ixgbe/ixgbe_common.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h: 1.9 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h: 1.5 via patch
sys/dev/pci/ixgbe/ixgbe_type.h: 1.11, 1.13 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c: 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixv.c: 1.9-1.10, 1.12-1.14 via patch
sys/dev/pci/ixgbe/ixv.h: 1.6 via patch
sys/dev/pci/ixgbe/ixgbe_dcb.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82598.h: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.c: 1.1
sys/dev/pci/ixgbe/ixgbe_dcb_82599.h: 1.1
Sync ixg(4) up to ixgbe.c rev. 1.35 except MSI/MSI-X and NET_MPSAFE:
- Sync ixg(4) up to FreeBSD r279805 (or r280181) which include some
bugfixes.
- Add missing evcnt_detach(&rxr->rx_copies) in ixgbe_detach().
- Fix error path in ixgbe_attach() and ixgbe_detatch() to prevent
panic.
- Remove unreachable code.
- Remove duplicated assignment of mh->m_len.
- Reduce the diff against FreeBSD (tabs, spaces and comments)
- ixv.c: Fix unintialized data. Include vlan.h and check NVLAN.
- Avoid shadowing global `min'.
 1.2.12.2 19-Apr-2015  riz Apply patch (requested by msaitoh in ticket #697):
sys/dev/pci/files.pci 1.375 via patch
sys/dev/pci/ixgbe/ixgbe.c 1.24-1.27 via patch
sys/dev/pci/ixgbe/ixgbe.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_82598.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_82598.h 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_82599.c 1.6-1.8 via patch
sys/dev/pci/ixgbe/ixgbe_82599.h 1.1 via patch
sys/dev/pci/ixgbe/ixgbe_api.c 1.5-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_api.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_common.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_common.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_mbx.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.4-1.6 via patch
sys/dev/pci/ixgbe/ixgbe_phy.c 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_phy.h 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_type.h 1.8-1.9 via patch
sys/dev/pci/ixgbe/ixgbe_vf.c 1.2-1.3 via patch
sys/dev/pci/ixgbe/ixgbe_vf.h 1.3-1.4 via patch
sys/dev/pci/ixgbe/ixgbe_x540.c 1.1-1.2 via patch
sys/dev/pci/ixgbe/ixgbe_x540.h 1.1 via patch
sys/dev/pci/ixgbe/ixv.c 1.5-1.7 via patch
sys/dev/pci/ixgbe/ixv.h 1.4-1.5 via patch

Synchronize our ixg(4) driver up to FreeBSD r243716:
- Add X540 support.
- Add TSO6 support.
- Add 100BaseTX support.
- The max size in dma tag is changed from 65535 to 262140 (IXGBE_TSO_SIZE).
The value is the same as other *BSDs. The change might cause a address
space shortage (ixgbe_dmamap_create() might fail) on some machines.
- Show 1000Base-SX correctly.
- Fix if_baudrate from 1G to 10G.
- Fix a bug that ifconfig -z (SOICZIFDATA) doesn't work.
- Fix a lot of bugs.
- Improve performance.
[msaitoh, ticket #697]
 1.2.12.1 26-Mar-2015  martin Pull up the following revisions (via patch), requested by msaitoh in #641:

sys/dev/pci/files.pci 1.374
sys/dev/pci/ixgbe/ixgbe.h 1.3
sys/dev/pci/ixgbe/ixgbe.c 1.20-1.23
sys/dev/pci/ixgbe/ixgbe_type.h 1.3-1.7
sys/dev/pci/ixgbe/ixgbe_82599.c 1.4-1.5
sys/dev/pci/ixgbe/ixgbe_api.c 1.3-1.4
sys/dev/pci/ixgbe/ixgbe_vf.h 1.2
sys/dev/pci/ixgbe/ixv.c 1.3-1.4
sys/dev/pci/ixgbe/ixv.h 1.3

- Sync ixg(4) up to FreeBSD r230572.
- Fix in the interrupt handler to make sure the stack TX queue is processed.
(FreeBSD r222588)
- The maximum read size of incoming packets is done in 1024-byte increments.
The current code was rounding down the maximum frame size instead of
routing up, resulting in a read size of 1024 bytes, in the non-jumbo
frame case, and splitting the packets across multiple mbufs.
(FreeBSD r225045)
- Consequently the above problem exposed another issue, which is when
packets were splitted across multiple mbufs, and all of the mbufs in the
chain have the M_PKTHDR flag set. (FreeBSD r225045)
- Use the correct constant for conversion between interrupt rate
and EITR values (the previous values were off by a factor of 2)
(FreeBSD r230572)
- Make dev.ix.N.queueM.interrupt_rate a RW sysctl variable. Changing
individual values affects the queue immediately, and propagates to all
interfaces at the next reinit. (FreeBSD r230572)
- Add dev.ix.N.queueM.irqs rdonly sysctl, to export the actual interrupt
counts. (FreeBSD r230572)
- Some netmap related changes.
- Fix a bug that vlan setting may not apply to the parent interface correctly.
- Add 82599EN_SFP and 82599_SFP_SF_QP.
- Modify to make Intel Intel 10G Ethernet (ixg(4)) virtual function ixv(4)
compilable. Not completed yet. It's required to use MSI-X.
- Change comments, tabs and spaces to make difference among *BSDs small.
- Enclose macro argument correctly. Same as *BSDs. No binary change.
- Add missing parenthesis in IXGBE_CORE_LOCK_ASSERT() macro. No binary change.
 1.7.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8 22-May-2022  riastradh opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.
 1.7 06-Nov-2021  msaitoh s/allign/align/
 1.6 14-Jun-2020  riastradh qat(4): Simplify iv generation logic with cprng_fast.
 1.5 05-Mar-2020  msaitoh branches: 1.5.4;
s/Intialize/Initialize/ in comment.
 1.4 01-Feb-2020  riastradh opencrypto orders new_session -> process for us.

No need for membar_producer.

Discussed with hikaru@.
 1.3 04-Dec-2019  hikaru branches: 1.3.2;
Fix macro error if QAT_DUMP is defined for debugging.
 1.2 02-Dec-2019  msaitoh Use PCI_MSIX_"TBL"BIR_MASK instead of PCI_MSIX_"PBA"BIR_MASK for MSI-X table.
This is not a real bug because both macros have the same value.
 1.1 20-Nov-2019  hikaru Add opencrypto driver for Intel QuickAssist.
 1.3.2.1 29-Feb-2020  ad Sync with head.
 1.5.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.4.1 05-Mar-2020  martin file qat.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.2 05-Dec-2021  msaitoh s/recusive/recursive/ in comment.
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_ae.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_aevar.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.2 24-May-2022  knakahara Workaround for Atom C2000 series (Rangeley) qat, ok'ed by hikaru@n.o.

C2000 qat has two engines, however it doesn't have arbiter.
If we enable both engines, qat interrupts twice wrongly (and second
interrupt notice invalid data). So, we enable only one engine.
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_c2xxx.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_c2xxxreg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_c3xxx.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_c3xxxreg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_c62x.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_c62xreg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_d15xx.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_d15xxreg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_hw15.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_hw15reg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_hw15var.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_hw17.c was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_hw17reg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qat_hw17var.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.3 08-Apr-2022  andvar s/postion/position/
 1.2 31-Dec-2021  andvar fix few typos in comments, mainly in word "parameter".
 1.1 20-Nov-2019  hikaru branches: 1.1.8;
Add opencrypto driver for Intel QuickAssist.
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 20-Nov-2019  martin file qatreg.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.3 06-Jul-2022  andvar fix various typos in comments.
 1.2 14-Mar-2020  ad branches: 1.2.4;
- Hide the details of SPCF_SHOULDYIELD and related behind a couple of small
functions: preempt_point() and preempt_needed().

- preempt(): if the LWP has exceeded its timeslice in kernel, strip it of
any priority boost gained earlier from blocking.
 1.1 20-Nov-2019  hikaru Add opencrypto driver for Intel QuickAssist.
 1.2.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.4.1 14-Mar-2020  martin file qatvar.h was added on branch phil-wifi on 2020-04-13 08:04:46 +0000
 1.7 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.6 13-Mar-2013  macallan branches: 1.6.38; 1.6.42;
defflag VOYAGERFB_DEPTH_32
 1.5 21-Feb-2012  macallan branches: 1.5.2;
use glyphcache for anti-aliased fonts
 1.4 22-Dec-2011  macallan support running in 32bit colour with anti-aliased fonts
enable with options VOYAGERFB_ANTIALIAS
 1.3 13-Dec-2011  macallan define and use PWMCLOCK_DEBUG
 1.2 13-Dec-2011  macallan an alternative clock implementation for Loongson2F and SM502, mostly
Gdium-specific.
This supports Loongson2F frequency scaling. The problem is that Gdium has
no CPU clock independent high resolution timer we can use as a timecounter
so we use one of the SM502's PWMs to generate a 100Hz timer interrupt, use
the cp0 counter to measure time and adjust for frequency changes.
Other Loongson-based machines will need something similar but hopefully
less hackish.
 1.1 31-Aug-2011  macallan branches: 1.1.2; 1.1.6;
split up voyagerfb into the framebuffer portion and a pseudo bus that we can
attach all the other sub-devices to
while there attach an i2c bus
 1.1.6.2 24-Feb-2012  mrg sync to -current.
 1.1.6.1 18-Feb-2012  mrg merge to -current.
 1.1.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.1 17-Apr-2012  yamt sync with head
 1.5.2.1 23-Jun-2013  tls resync from head
 1.6.42.1 05-May-2019  isaki Remove obsoleted au{,rate,vol}conv and mulaw attributes.
audio provides the equivalent of them inseparably.
 1.6.38.1 10-Jun-2019  christos Sync with HEAD
 1.12 29-May-2020  rin For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.11 26-Aug-2016  skrll Adjust evbmips_iointr to pass a clockframe pointer and use it for
pwmclock @ voyager.

Suggested by matt@

Hi macallan!
 1.10 14-May-2013  macallan branches: 1.10.10;
found the missing commit so put this back
am I the only one here with a Gdium?
 1.9 13-May-2013  christos make this compile again; macallan, please commit the right fix!
 1.8 16-Apr-2013  macallan unscrew this again
 1.7 15-Apr-2013  christos make this compile again; macallan, please commit the right fix!
 1.6 02-Jun-2012  dsl branches: 1.6.2;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.5 23-Feb-2012  macallan branches: 1.5.2;
break long lines
 1.4 23-Feb-2012  macallan set the CPU clock back to full speed on shutdown
this is necessary because PMON does not touch the clock scaling register on
reboot but still reports full CPU speed which confuses the clock code
 1.3 14-Feb-2012  macallan branches: 1.3.4;
another blah() -> blah(void)
ok riz
 1.2 13-Dec-2011  macallan define and use PWMCLOCK_DEBUG
 1.1 13-Dec-2011  macallan an alternative clock implementation for Loongson2F and SM502, mostly
Gdium-specific.
This supports Loongson2F frequency scaling. The problem is that Gdium has
no CPU clock independent high resolution timer we can use as a timecounter
so we use one of the SM502's PWMs to generate a 100Hz timer interrupt, use
the cp0 counter to measure time and adjust for frequency changes.
Other Loongson-based machines will need something similar but hopefully
less hackish.
 1.3.4.3 24-Feb-2012  mrg sync to -current.
 1.3.4.2 18-Feb-2012  mrg merge to -current.
 1.3.4.1 14-Feb-2012  mrg file pwmclock.c was added on branch jmcneill-usbmp on 2012-02-18 07:34:55 +0000
 1.5.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.2.3 30-Oct-2012  yamt sync with head
 1.5.2.2 17-Apr-2012  yamt sync with head
 1.5.2.1 23-Feb-2012  yamt file pwmclock.c was added on branch yamt-pagecache on 2012-04-17 00:07:59 +0000
 1.6.2.2 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 23-Jun-2013  tls resync from head
 1.10.10.1 05-Oct-2016  skrll Sync with HEAD
 1.34 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.33 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.32 21-May-2021  macallan branches: 1.32.4;
fix wsdisplay attachment in the New Order Of Things
 1.31 21-May-2021  macallan use probed VRAM size to determine where to put the cursor instead of blindly
assuming 16MB
also make sure the glyph cache can't overlap with the cursor
 1.30 24-Apr-2021  thorpej branches: 1.30.2; 1.30.4;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.29 19-Jan-2018  macallan branches: 1.29.20;
enable font loading
 1.28 13-Jan-2016  macallan some trivial fixes:
- rearrange dmesg output so all values are printed properly
- use aprint_*
- support WSDISPLAYIO_GET_FBINFO
 1.27 11-Mar-2014  mrg branches: 1.27.6;
avoid set but unused variables.
move variables under their usage #ifdef.
 1.26 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.25 19-Mar-2013  macallan branches: 1.25.6;
rearrange things a little bit to avoid showing garbled VRAM content while
switching colour depth
 1.24 13-Mar-2013  macallan break a bunch of long lines
 1.23 13-Mar-2013  macallan support anti-aliased fonts in 8bit
while there, use the DRAM config register to figure out how much video
memory we have instead of guessing
 1.22 30-May-2012  macallan branches: 1.22.2;
fix some comments
 1.21 23-May-2012  macallan first step to fix PR 46461 - don't jump through a NULL pointer when we're
not the console but the firmware set up the graphics hardware anyway
 1.20 19-Apr-2012  macallan glyphcache_init() works best with its parameters in the right order. Doh.
While there request an RGB devcmap.
 1.19 20-Mar-2012  macallan split voyagerfb_putchar() into one method for mono fonts and one for
anti-aliased fonts
 1.18 13-Mar-2012  elad Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.17 21-Feb-2012  macallan use glyphcache for anti-aliased fonts
 1.16 11-Jan-2012  macallan use rasops_init(0,0), WSFONT_GLYPH(), FONT_IS_ALPHA()
 1.15 28-Dec-2011  macallan make anti-aliased fonts with odd widths work
The drawing engine needs lines padded to 64bit when doing colour host blits
which is of course not mentioned anywhere in the manual.
 1.14 27-Dec-2011  macallan add fastpaths for alpha == 0 and alpha == 255 - no need to do the six
multiplications dance there, just use background or foreground colour
 1.13 24-Dec-2011  macallan don't put alpha values in a variable named alpha since alpha doesn't like
variables conflicting with platform names
( just in case someone figures out how to stick an sm50x into an alpha )
 1.12 22-Dec-2011  macallan don't probe colour depth on attach - we're going to change it anyway
 1.11 22-Dec-2011  macallan don't switch to 8 bit for WSDISPLAYIO_MODE_EMUL if VOYAGERFB_ANTIALIAS
is defined
 1.10 22-Dec-2011  macallan support running in 32bit colour with anti-aliased fonts
enable with options VOYAGERFB_ANTIALIAS
 1.9 08-Nov-2011  macallan branches: 1.9.4;
switch to 32bit colour for X, switch back to 8 bit for console emulation
 1.8 08-Nov-2011  macallan run the console in 8 bit colour for additional speed
( on Gdium this scrolls more than twice as fast as the 16bit default mode )
 1.7 18-Oct-2011  macallan branches: 1.7.2;
add backlight control via sm502 PWM
 1.6 28-Sep-2011  macallan support a hardware cursor - now X with wsfb on gdium is a little less annoying
 1.5 22-Sep-2011  macallan use BUS_SPACE_MAP_PREFETCHABLE
 1.4 20-Sep-2011  macallan support ioctl(WSDISPLAYIO_SVIDEO) and friends so wsfb can turn the backlight
off
 1.3 06-Sep-2011  macallan add simple backlight control support, only on/off for now
 1.2 06-Sep-2011  macallan wsdisplayio_busid_pci() needs out parent since we don't attach directly
to a PCI bus anymore
 1.1 31-Aug-2011  macallan split up voyagerfb into the framebuffer portion and a pseudo bus that we can
attach all the other sub-devices to
while there attach an i2c bus
 1.7.2.5 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.2.4 30-Oct-2012  yamt sync with head
 1.7.2.3 23-May-2012  yamt sync with head.
 1.7.2.2 17-Apr-2012  yamt sync with head
 1.7.2.1 10-Nov-2011  yamt sync with head
 1.9.4.5 02-Jun-2012  mrg sync to latest -current.
 1.9.4.4 29-Apr-2012  mrg sync to latest -current.
 1.9.4.3 05-Apr-2012  mrg sync to latest -current.
 1.9.4.2 24-Feb-2012  mrg sync to -current.
 1.9.4.1 18-Feb-2012  mrg merge to -current.
 1.22.2.3 03-Dec-2017  jdolecek update from HEAD
 1.22.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.2.1 23-Jun-2013  tls resync from head
 1.25.6.2 18-May-2014  rmind sync with head
 1.25.6.1 28-Aug-2013  rmind sync with head
 1.27.6.1 19-Mar-2016  skrll Sync with HEAD
 1.29.20.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.30.4.1 31-May-2021  cjep sync with head
 1.30.2.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.32.4.1 04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed