Home | History | Annotate | only in /src/sys/dev/marvell
History log of /src/sys/dev/marvell
RevisionDateAuthorComments
 1.2 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.1 05-Mar-2003  matt branches: 1.1.104; 1.1.126; 1.1.128;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.128.1 30-May-2010  rmind sync with head
 1.1.126.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.104.1 11-Aug-2010  yamt sync with head.
 1.12 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.11 11-Dec-2018  martin Remove stray ; to fix the build
 1.10 11-Dec-2018  thorpej Add a convenience function, com_init_regs_stride(), that shifts the register
offsets and size by the specified amount. Use in front-ends as appropriate.
 1.9 08-Dec-2018  thorpej Remove the COM_REGMAP option -- just use it all the time. While here,
garbage-collect the COM_FUNCMAP and COM_AU1X00 options, as there are
not used anywhere.
 1.8 08-Dec-2018  thorpej Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.7 03-Oct-2013  kiyohara branches: 1.7.28; 1.7.30;
Revirt 'Move the Marvell extension to com_mv.c' at Sun Sep 1 04:51:24 UTC 2013.
build test only.
 1.6 01-Sep-2013  kiyohara Move the Marvell extension to com_mv.c.
 1.5 28-Jan-2011  jakllsch branches: 1.5.2;
Set mva_size in the console case.
Addresses first portion of PR#43990.
 1.4 04-Sep-2010  kiyohara branches: 1.4.2; 1.4.4;
Add include opt_com.h.
 1.3 01-Aug-2010  kiyohara branches: 1.3.2; 1.3.4;
Cleanup mvuart_match().
 1.2 20-Jul-2010  kiyohara Add some Kirkwood/Discovery Innovation products.
 1.1 13-Jul-2010  kiyohara Add UART and PCIe controller for Marvell SoC.
However not define attribute *_mbus in our tree yet.
 1.3.4.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.3.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.4.1 01-Aug-2010  uebayasi file com_mv.c was added on branch uebayasi-xip on 2010-08-17 06:46:16 +0000
 1.3.2.3 09-Oct-2010  yamt sync with head
 1.3.2.2 11-Aug-2010  yamt sync with head.
 1.3.2.1 01-Aug-2010  yamt file com_mv.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.4.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.4.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.5.2.2 05-Mar-2011  rmind sync with head
 1.5.2.1 28-Jan-2011  rmind file com_mv.c was added on branch rmind-uvmplock on 2011-03-05 20:53:25 +0000
 1.7.30.1 10-Jun-2019  christos Sync with HEAD
 1.7.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 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 26-Dec-2019  msaitoh branches: 1.8.10;
s/lenght/length/
 1.7 09-Apr-2018  jakllsch branches: 1.7.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.6 23-Apr-2016  skrll branches: 1.6.16;
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.5 15-Mar-2014  kiyohara branches: 1.5.4; 1.5.6; 1.5.10;
Support Armada 370 and DDR3 tags.
 1.4 08-Sep-2013  kiyohara Fix size of EHCI register space.
 1.3 01-May-2013  rkujawa branches: 1.3.4;
Support Marvell Armada XP.

Obtained from Marvell, Semihalf.
 1.2 16-Oct-2010  kiyohara branches: 1.2.2; 1.2.8; 1.2.12; 1.2.22;
Support vendor dependent functions.
 1.1 02-Oct-2010  kiyohara branches: 1.1.2;
Add Marvell EHCI Controller wrapper.
However, because this driver has some problems now, it will not work the
way things are going.
 1.1.2.2 09-Oct-2010  yamt sync with head
 1.1.2.1 02-Oct-2010  yamt file ehci_mv.c was added on branch yamt-nfs-mp on 2010-10-09 03:32:08 +0000
 1.2.22.3 03-Dec-2017  jdolecek update from HEAD
 1.2.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.22.1 23-Jun-2013  tls resync from head
 1.2.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.2.8.2 05-Mar-2011  rmind sync with head
 1.2.8.1 16-Oct-2010  rmind file ehci_mv.c was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 1.2.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.2.2.1 16-Oct-2010  uebayasi file ehci_mv.c was added on branch uebayasi-xip on 2010-10-22 07:22:01 +0000
 1.3.4.1 18-May-2014  rmind sync with head
 1.5.10.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.5.6.3 05-Dec-2014  skrll Use int for return type for [eou]chi_init and motg_init.
 1.5.6.2 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.5.6.1 03-Dec-2014  skrll Trailing whitespace.
 1.5.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.6.16.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.7.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8.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.9.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 25-Jul-2020  riastradh Omit needless rijndael dependencies.
 1.5 22-Apr-2020  rin Make crypto/rijindael optional again as cprng_strong does no longer
depend on it. Dependency is explicitly declared in files.foo if a
component requires it.
 1.4 01-Oct-2019  chs branches: 1.4.6;
make this compile again:
- remove unused config attributes
- rename a local variable to avoid a name conflict
 1.3 03-Jun-2015  hsuenaga branches: 1.3.2; 1.3.18; 1.3.22;
add new cryptographic accelerator driver 'mvxpsec.'

this driver controls CESA unit as same as mvcesa, but uses DMA engines and
does CBC operations, HMAC operations by hardware. about 2 kbytes of data
are processed at one. supported algorithms are:

- DES-CBC, 3DES-CBC, AES-CBC
- HMAC-SHA1, HMAC-MD5

non-CBC algorithm such as AES-GCM is not supported by CESA's acceleration
engine. mvcesa is still useful to implement such algorithms as combination of
accelerated block cipher and software chaining.
 1.2 03-Jun-2015  hsuenaga separate buffer management codes 'mvxpbm.c' from if_mvxpe.c.

the buffer management(ex. fill the rx descriptors/buffers) is done by H/W in
ARMADA XP/380, and is done by S/W in ARMADA 370. the H/W BM support is not yet
implemented, so all devices use the S/W management mode at this time.
 1.1 03-Jun-2015  hsuenaga move Marvell ARMADA SoC's device driver definitions from arm/marvell
to dev/marvell.
 1.3.22.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.18.2 03-Dec-2017  jdolecek update from HEAD
 1.3.18.1 03-Jun-2015  jdolecek file files.armada was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.3.2.2 06-Jun-2015  skrll Sync with HEAD
 1.3.2.1 03-Jun-2015  skrll file files.armada was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.4.6.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.23 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.22 06-Sep-2013  matt branches: 1.22.46;
Make gttswi MI and usuable from non-Marvell SoCs.
(should rename to mvi2c but ...)
 1.21 29-Aug-2013  kiyohara Fix build failed with ofppc.
Move 'attach mvspi at mvsoc' to arch/arm/marvell/files.marvell.
 1.20 25-Aug-2013  kiyohara Move mvspi defines into sys/dev/marvell/files.discovery.
 1.19 27-Jul-2012  kiyohara branches: 1.19.2; 1.19.4;
Add Marvell CESA(Cryptographic Engines and Security Accelerator) module driver.
But support only PIO-mode now. Also AES-CBC not supported.
Don't know how to process to AES CBC in PIO-mode. I haven't found IV registers.
 1.18 02-Oct-2010  kiyohara branches: 1.18.8;
Add Marvell EHCI Controller wrapper.
However, because this driver has some problems now, it will not work the
way things are going.
 1.17 23-Sep-2010  kiyohara Add Marvell Secure Digital Input/Output (SDIO) Interface Driver.
 1.16 13-Jul-2010  kiyohara Add SATA for Marvell SC/SoC.
 1.15 13-Jul-2010  kiyohara Add UART and PCIe controller for Marvell SoC.
However not define attribute *_mbus in our tree yet.
 1.14 11-Jul-2010  kiyohara Remove unnecessary define.
Reorder.
Add necessary attributes.
 1.13 02-Jun-2010  kiyohara Add Marvell Gigabit Ethernet Controller on SC/SoC.
Will support on ofppc soon.
Tested on G4+PegasosII (kiyohara@)
G3+PegasosII (phx@)
 1.12 07-May-2010  kiyohara Enable gtidmac.
 1.11 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.10 11-Dec-2005  christos branches: 1.10.74; 1.10.96; 1.10.98;
merge ktrace-lwp.
 1.9 01-Feb-2005  matt Add entry for gti2c.c
 1.8 13-Sep-2004  drochner branches: 1.8.4; 1.8.6;
"gtpci" doesn't provide an ISA bus, so it shouldn't have an "isabus"
attribute
 1.7 01-May-2004  nisimura Typos in comment description.
 1.6 27-May-2003  scw branches: 1.6.2;
Add an option to control whether the GT's internal PCI Arbiter should
be enabled or not.
 1.5 17-May-2003  scw defflag GT_ECC.
 1.4 27-Mar-2003  matt Add GT_PCI{0,1}_{IO,MEM}{SIZE,START} options
 1.3 24-Mar-2003  matt Make gtmpsc configurable via config file. (baud rate source, frequency).
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.6.2.4 04-Feb-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.6.1 12-Feb-2005  yamt sync with head.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.10.98.3 05-Mar-2011  rmind sync with head
 1.10.98.2 03-Jul-2010  rmind sync with head
 1.10.98.1 30-May-2010  rmind sync with head
 1.10.96.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.10.96.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.10.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.74.2 09-Oct-2010  yamt sync with head
 1.10.74.1 11-Aug-2010  yamt sync with head.
 1.18.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.18.8.1 30-Oct-2012  yamt sync with head
 1.19.4.2 18-May-2014  rmind sync with head
 1.19.4.1 28-Aug-2013  rmind sync with head
 1.19.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.46.1 22-Mar-2021  thorpej No need to define interface attributes separately from the devices
that carry them if they are specific to that device; just declare the
interface on the device directly.
 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 09-Oct-2016  christos branches: 1.28.32;
PR/51540: Henning Petersen: replace , with ;
 1.27 11-Jul-2015  kamil branches: 1.27.2;
Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.26 20-Jul-2010  kiyohara branches: 1.26.18; 1.26.36;
Add notes for remembrance' sake. This is information obtained looking for
www.marvell.com.
 1.25 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.24 09-Jun-2010  kiyohara Fix debug messages.
- s/DEBUG/GT_DEBUG/.
- Indent.
- The old one is 20 bits in the mask of the address register, and the
new one is 16 bits.
 1.23 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.22 25-Feb-2010  matt branches: 1.22.2;
Adapt to <powerpc/spr.h> breakup.
 1.21 12-May-2009  cegger branches: 1.21.2;
struct device * -> device_t, no functional changes intended.
 1.20 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.19 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.18 17-Jun-2008  he branches: 1.18.4; 1.18.10; 1.18.18;
Use a local temporary struct gt_softc* so we don't try to
de-reference void*. Restores buildability of this file.
 1.17 12-Jun-2008  cegger use device_lookup_private to get softc
 1.16 08-Apr-2008  cegger branches: 1.16.2; 1.16.4; 1.16.6; 1.16.8;
use aprint_*_dev and device_xname
 1.15 03-Dec-2007  ad branches: 1.15.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.14 19-Oct-2007  ad branches: 1.14.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.13 29-Jan-2007  hubertf branches: 1.13.6; 1.13.18; 1.13.20; 1.13.24;
Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.12 24-Dec-2005  perry branches: 1.12.20;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 26-Aug-2005  drochner s/locdesc_t/int/g
 1.9 27-Feb-2005  perry branches: 1.9.4;
nuke trailing whitespace
 1.8 26-Nov-2004  jmc branches: 1.8.4; 1.8.6;
Put back a few locators.h includes that are still needed here. Now evbppc
kernels build clean once again
 1.7 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.6 20-Mar-2004  matt Add gt_dma_bus_mem_to_phys and gt_dma_phys_to_bus_mem.
 1.5 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.4 12-Jun-2003  scw branches: 1.4.2;
Disable the watchdog during autoconf of sub-devices.
Some drivers (e.g. pciide(4)) can take long enough to probe that the
watchdog barks before they're done.
 1.3 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.2 06-Mar-2003  matt Relocate Discovery first thing in initppc (if not at expected address).
This implies that if PMON tells us where the GT is, we write that address
in gtbase.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.4.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.2.4 29-Nov-2004  skrll Sync with HEAD.
 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.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 07-Dec-2007  yamt sync with head
 1.9.4.3 27-Oct-2007  yamt sync with head.
 1.9.4.2 26-Feb-2007  yamt sync with head.
 1.9.4.1 21-Jun-2006  yamt sync with head.
 1.12.20.1 01-Feb-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.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.13.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.13.6.1 23-Oct-2007  ad Sync with head.
 1.14.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.15.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.8.1 18-Jun-2008  simonb Sync with head.
 1.16.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.16.4.4 11-Aug-2010  yamt 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.16.2.1 17-Jun-2008  yamt sync with head.
 1.18.18.1 07-Jan-2011  matt Deal with the spr.h split.
 1.18.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.21.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.22.2.3 05-Mar-2011  rmind sync with head
 1.22.2.2 03-Jul-2010  rmind sync with head
 1.22.2.1 30-May-2010  rmind sync with head
 1.26.36.2 05-Dec-2016  skrll Sync with HEAD
 1.26.36.1 22-Sep-2015  skrll Sync with HEAD
 1.26.18.1 03-Dec-2017  jdolecek update from HEAD
 1.27.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.28.32.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.28.32.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.29.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 15-Jan-2016  joerg Switch to generic __BIT/__BITS macro, which doesn't depend on
left-shifting negative values.
 1.2 28-Apr-2010  kiyohara branches: 1.2.18; 1.2.36;
Clean up gt and peripherals.
This change tested compile only.
 1.1 05-Mar-2003  matt branches: 1.1.104; 1.1.126; 1.1.128;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.128.1 30-May-2010  rmind sync with head
 1.1.126.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.104.1 11-Aug-2010  yamt sync with head.
 1.2.36.1 19-Mar-2016  skrll Sync with HEAD
 1.2.18.1 03-Dec-2017  jdolecek update from HEAD
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Clean up gt and peripherals.
This change tested compile only.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file gtbrgvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtbrgvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:29 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtbrgvar.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Clean up gt and peripherals.
This change tested compile only.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file gtdevbusvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtdevbusvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:29 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtdevbusvar.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.6 10-Nov-2021  msaitoh s/endianess/endianness/
 1.5 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.96; 1.4.98;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry nuke trailing whitespace
 1.2 17-Mar-2003  matt branches: 1.2.2; 1.2.10; 1.2.12;
Use a subregion for the mac's ethernet registers. Shaves 512 bytes
from the driver.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 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.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.98.1 30-May-2010  rmind sync with head
 1.4.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.74.1 11-Aug-2010  yamt sync with head.
 1.13 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.12 12-May-2009  cegger branches: 1.12.2; 1.12.4;
struct device * -> device_t, no functional changes intended.
 1.11 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.10 08-Apr-2008  cegger branches: 1.10.4; 1.10.18;
use aprint_*_dev and device_xname
 1.9 16-Dec-2007  he branches: 1.9.6;
Remove a local variable which is no longer used.
 1.8 05-Dec-2007  ad branches: 1.8.4;
lockmgr -> mutex
 1.7 03-Dec-2007  ad branches: 1.7.2;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.6 19-Oct-2007  ad branches: 1.6.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.5 26-Jun-2006  drochner branches: 1.5.14; 1.5.28; 1.5.30; 1.5.34;
use the "i2cbus" interface attribute rather than putting a string name
into the i2cbus attach args
 1.4 29-Mar-2006  thorpej branches: 1.4.4;
Use device_private().
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.10; 1.3.12;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry branches: 1.2.4; 1.2.6;
nuke trailing whitespace
 1.1 01-Feb-2005  matt branches: 1.1.2; 1.1.4;
Add a i2c driver for the onboard i2c/twsi controller on the GT642x0
 1.1.4.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.4.2 12-Feb-2005  yamt sync with head.
 1.1.4.1 01-Feb-2005  yamt file gti2c.c was added on branch yamt-km on 2005-02-12 18:17:46 +0000
 1.1.2.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 04-Feb-2005  skrll Sync with HEAD.
 1.1.2.1 01-Feb-2005  skrll file gti2c.c was added on branch ktrace-lwp on 2005-02-04 11:46:29 +0000
 1.2.6.5 21-Jan-2008  yamt sync with head
 1.2.6.4 07-Dec-2007  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 21-Jun-2006  yamt sync with head.
 1.2.4.2 29-Apr-2005  kent sync with -current
 1.2.4.1 27-Feb-2005  kent file gti2c.c was added on branch kent-audio2 on 2005-04-29 11:28:55 +0000
 1.3.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.3.10.1 19-Apr-2006  elad sync with head.
 1.3.8.2 11-Aug-2006  yamt sync with head
 1.3.8.1 01-Apr-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.34.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.30.2 09-Jan-2008  matt sync with HEAD
 1.5.30.1 06-Nov-2007  matt sync with HEAD
 1.5.28.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.5.28.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.14.1 23-Oct-2007  ad Sync with head.
 1.6.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.6.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.2.2 26-Dec-2007  ad Sync with head.
 1.7.2.1 08-Dec-2007  ad Sync with head.
 1.8.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.6.1 02-Jun-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.4.2 11-Aug-2010  yamt sync with head.
 1.10.4.1 16-May-2009  yamt sync with head
 1.12.4.1 30-May-2010  rmind sync with head
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.4 08-Mar-2006  lukem branches: 1.4.64; 1.4.86; 1.4.88;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.6; 1.3.8; 1.3.10;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry branches: 1.2.4; 1.2.6;
nuke trailing whitespace
 1.1 01-Feb-2005  matt branches: 1.1.2; 1.1.4;
Add a i2c driver for the onboard i2c/twsi controller on the GT642x0
 1.1.4.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.4.2 12-Feb-2005  yamt sync with head.
 1.1.4.1 01-Feb-2005  yamt file gti2creg.h was added on branch yamt-km on 2005-02-12 18:17:46 +0000
 1.1.2.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 04-Feb-2005  skrll Sync with HEAD.
 1.1.2.1 01-Feb-2005  skrll file gti2creg.h was added on branch ktrace-lwp on 2005-02-04 11:46:29 +0000
 1.2.6.1 21-Jun-2006  yamt sync with head.
 1.2.4.2 29-Apr-2005  kent sync with -current
 1.2.4.1 27-Feb-2005  kent file gti2creg.h was added on branch kent-audio2 on 2005-04-29 11:28:55 +0000
 1.3.10.1 19-Apr-2006  elad sync with head.
 1.3.8.1 13-Mar-2006  yamt sync with head.
 1.3.6.1 22-Apr-2006  simonb Sync with head.
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.4.88.1 30-May-2010  rmind sync with head
 1.4.86.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.64.1 11-Aug-2010  yamt sync with head.
 1.19 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.18 12-May-2009  cegger branches: 1.18.2; 1.18.4;
struct device * -> device_t, no functional changes intended.
 1.17 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.16 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.15 03-Jan-2009  yamt branches: 1.15.2;
remove extra semicolons.
 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 08-Apr-2008  cegger branches: 1.13.4; 1.13.6; 1.13.10;
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 29-Mar-2006  thorpej branches: 1.9.14;
Use device_private().
 1.8 24-Dec-2005  perry branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
bare asm -> __asm
 1.7 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 27-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 04-Feb-2005  perry de-__P
 1.3 14-Jul-2003  lukem branches: 1.3.8; 1.3.10;
add missing __KERNEL_RCSID()
 1.2 08-Apr-2003  thorpej branches: 1.2.2;
Use PAGE_SIZE rather than NBPG.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 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.3.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.10.1 12-Feb-2005  yamt sync with head.
 1.3.8.1 29-Apr-2005  kent sync with -current
 1.5.4.3 27-Oct-2007  yamt sync with head.
 1.5.4.2 03-Sep-2007  yamt sync with head.
 1.5.4.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.14.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.3 17-Jan-2009  mjf Sync with HEAD.
 1.12.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.12.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.10.1 19-Oct-2008  haad 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.3 11-Aug-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.14.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.14.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.2.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.21 12-Jun-2024  andvar MVXORE_XEXCDPR and MVXORE_XEXBCR macros expect two params now, thus adjust
params accordingly, needed in order to fix GTIDMAC_DEBUG build option.

Unfortunately, there few more macros in gtidmac_dump_xorereg() like
MVXORE_XETMCR, MVXORE_XETMIVR, MVXORE_XETMCVR, MVXORE_XEIVRH, MVXORE_XEIVRL
which also expect two params, but second one doesn't seem to be a channel,
thus I am leaving it unfixed for now.
 1.20 02-Feb-2024  andvar fix typos, mainly s/unsupport/unsupported/ in log messages.
 1.19 19-Jun-2023  msaitoh Fix typo. unknwon -> unknown
 1.18 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.17 27-Dec-2019  msaitoh branches: 1.17.12;
s/transfered/transferred/
 1.16 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.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 31-Mar-2017  msaitoh 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.13 07-Jan-2017  kiyohara branches: 1.13.2;
Support Marvell Dove. Use irq array. Dove's irqs not sequencial.
And remove debug printf().
 1.12 07-Jan-2017  kiyohara Remove unused function.
 1.11 15-Mar-2014  kiyohara branches: 1.11.6; 1.11.10;
Support Armada 370 and DDR3 tags.
 1.10 28-Sep-2013  kiyohara Add ARMADAXP IDs.
 1.9 10-Sep-2012  msaitoh branches: 1.9.2; 1.9.4;
Add "static".
 1.8 23-Jul-2012  kiyohara Support Kirkwoods. Kirkwoods has 4ch for XORE and not has IDMAC. tested on OpenBlockS A6 with ch0 only.
 1.7 30-Jan-2012  matt Use proper ANSI prototypes for foo() -> foo(void)
Caught when compiling with -Wold-style-definition
 1.6 01-Aug-2010  kiyohara branches: 1.6.2; 1.6.10; 1.6.14;
Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.5 20-Jul-2010  kiyohara Fix information on the product with comment-out. This was obtained from
the data sheet of Marvell.
 1.4 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.3 04-Jun-2010  kiyohara Fix sume bugs.
- Why +1 ?
- mvidmac_dump_xoredesc() -> gtidmac_dump_xoredesc().
- bitmask_snprintf() -> snprintb().
Support big endian machines with GTIDMAC_CCHR_ENDIAN_BE.
 1.2 02-Jun-2010  kiyohara Use kmem(9) instead of malloc(9) in gtidmac_attach().
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4;
Clean up gt and peripherals.
This change tested compile only.
 1.1.4.4 05-Mar-2011  rmind sync with head
 1.1.4.3 03-Jul-2010  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtidmac.c was added on branch rmind-uvmplock on 2010-05-30 05:17:29 +0000
 1.1.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtidmac.c was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.6.14.1 18-Feb-2012  mrg merge to -current.
 1.6.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.6.10.2 30-Oct-2012  yamt sync with head
 1.6.10.1 17-Apr-2012  yamt sync with head
 1.6.2.2 11-Aug-2010  yamt sync with head.
 1.6.2.1 01-Aug-2010  yamt file gtidmac.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.9.4.1 18-May-2014  rmind sync with head
 1.9.2.2 03-Dec-2017  jdolecek update from HEAD
 1.9.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.10.2 26-Apr-2017  pgoyette Sync with HEAD
 1.11.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.11.6.2 28-Aug-2017  skrll Sync with HEAD
 1.11.6.1 05-Feb-2017  skrll Sync with HEAD
 1.13.2.1 21-Apr-2017  bouyer 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 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.17.12.1 01-Aug-2021  thorpej Sync with HEAD.
 1.5 10-Nov-2021  msaitoh s/endianess/endianness/
 1.4 07-Jan-2017  kiyohara Fix macro MVXORE_CHAN2BASE(). The XORE has 2 channels per port.
 1.3 23-Jul-2012  kiyohara branches: 1.3.2; 1.3.16; 1.3.20;
Support Kirkwoods. Kirkwoods has 4ch for XORE and not has IDMAC. tested on OpenBlockS A6 with ch0 only.
 1.2 08-Jun-2010  kiyohara branches: 1.2.2; 1.2.10;
Support big endian machines.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4;
Clean up gt and peripherals.
This change tested compile only.
 1.1.4.3 03-Jul-2010  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtidmacreg.h was added on branch rmind-uvmplock on 2010-05-30 05:17:29 +0000
 1.1.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtidmacreg.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.2.10.1 30-Oct-2012  yamt sync with head
 1.2.2.2 11-Aug-2010  yamt sync with head.
 1.2.2.1 08-Jun-2010  yamt file gtidmacreg.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.3.20.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3.16.1 05-Feb-2017  skrll Sync with HEAD
 1.3.2.1 03-Dec-2017  jdolecek update from HEAD
 1.3 07-Jan-2017  kiyohara Remove unused function.
 1.2 15-Mar-2014  kiyohara branches: 1.2.6; 1.2.10;
Support Armada 370 and DDR3 tags.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14; 1.1.24; 1.1.28;
Clean up gt and peripherals.
This change tested compile only.
 1.1.28.1 18-May-2014  rmind sync with head
 1.1.24.2 03-Dec-2017  jdolecek update from HEAD
 1.1.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 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 28-Apr-2010  yamt file gtidmacvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtidmacvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:29 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtidmacvar.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.2.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2.6.1 05-Feb-2017  skrll Sync with HEAD
 1.7 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.6 08-Sep-2008  gmcgarry branches: 1.6.14; 1.6.16;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.5 16-Feb-2006  perry branches: 1.5.64; 1.5.68; 1.5.70; 1.5.74;
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.4 24-Dec-2005  perry branches: 1.4.2; 1.4.4; 1.4.6;
bare asm -> __asm
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 27-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 05-Mar-2003  matt branches: 1.1.2; 1.1.10; 1.1.12;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.10.1 29-Apr-2005  kent sync with -current
 1.1.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.4.1 21-Jun-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.4.2.1 18-Feb-2006  yamt sync with head.
 1.5.74.1 19-Oct-2008  haad Sync with HEAD.
 1.5.70.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.5.68.2 11-Aug-2010  yamt sync with head.
 1.5.68.1 04-May-2009  yamt sync with head.
 1.5.64.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.16.1 30-May-2010  rmind sync with head
 1.6.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.5 04-Mar-2007  christos branches: 1.5.40; 1.5.62; 1.5.64;
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 04-Feb-2005  perry de-__P
 1.1 05-Mar-2003  matt branches: 1.1.2; 1.1.10; 1.1.12;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.12.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 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.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.1 04-Feb-2005  skrll 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.64.1 30-May-2010  rmind sync with head
 1.5.62.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.40.1 11-Aug-2010  yamt sync with head.
 1.6 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.5 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.96; 1.4.98;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry nuke trailing whitespace
 1.2 13-Feb-2004  wiz branches: 1.2.8; 1.2.10;
Uppercase CPU, plural is CPUs.
 1.1 05-Mar-2003  matt branches: 1.1.2;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 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.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.8.1 29-Apr-2005  kent sync with -current
 1.4.98.1 30-May-2010  rmind sync with head
 1.4.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.74.1 11-Aug-2010  yamt sync with head.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Clean up gt and peripherals.
This change tested compile only.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file gtintrvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtintrvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:29 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtintrvar.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.50 10-Sep-2024  andvar Fix wrong KGDB condition and remove unused gtmpsc_kgdb_addr variable.
 1.49 12-Jun-2024  andvar branches: 1.49.2;
Make gtmpsc_intr_rx/tx always static __inline to fix DEBUG enabled build.
Currently code depends on STATIC macro which is defined as empty with DEBUG
option, thus build fails since tx method uses static inline gt_sdma_imask().

Also add missing __inline for gtmpsc_intr_rx() definition.

Fix EV64260 kernel config when DEBUG is enabled.
Fix discussed with mrg@ in irc.
 1.48 02-Nov-2022  andvar fix various typos in comments and messages.
 1.47 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.46 15-Nov-2014  christos branches: 1.46.18; 1.46.20;
centralize the dialout/call unit macros.
 1.45 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.44 16-Mar-2014  dholland branches: 1.44.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.43 24-Apr-2011  rmind branches: 1.43.4; 1.43.14; 1.43.18;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.42 14-Nov-2010  uebayasi branches: 1.42.2;
Include uvm/uvm_extern.h to access uvmexp. gtmpsc.c doesn't need
uvm(9) API at all.
 1.41 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.40 01-Aug-2010  kiyohara Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.39 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.38 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.37 12-May-2009  cegger branches: 1.37.2; 1.37.4;
struct device * -> device_t, no functional changes intended.
 1.36 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.35 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.34 18-Mar-2009  cegger bcopy -> memcpy
 1.33 18-Mar-2009  cegger bzero -> memset
 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 08-Sep-2008  gmcgarry branches: 1.31.2; 1.31.8;
Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
 1.30 12-Jun-2008  cegger branches: 1.30.2;
use device_lookup_private to get softc
 1.29 11-Jun-2008  cegger use device_lookup_private to get softc
 1.28 08-Apr-2008  cegger branches: 1.28.2; 1.28.4; 1.28.6; 1.28.8;
use aprint_*_dev and device_xname
 1.27 19-Nov-2007  ad branches: 1.27.14;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.26 19-Oct-2007  ad branches: 1.26.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.25 17-Oct-2007  garbled branches: 1.25.2;
Fix a missing include noted by Gerald Lee on tech-kern
 1.24 08-Oct-2007  ad Use the softint API.
 1.23 04-Mar-2007  christos branches: 1.23.2; 1.23.14; 1.23.16; 1.23.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.22 29-Jan-2007  hubertf branches: 1.22.2;
Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.21 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.20 21-Jul-2006  ad branches: 1.20.4; 1.20.6;
- Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.19 24-May-2006  mrg 'volatile' is not a valid return type qualifier - remove it.
 1.18 16-May-2006  he branches: 1.18.2;
Include now needed <sys/kauth.h>, and fold a long line.
 1.17 14-May-2006  elad integrate kauth.
 1.16 29-Mar-2006  thorpej Use device_private().
 1.15 28-Mar-2006  thorpej Use device_unit().
 1.14 24-Dec-2005  perry branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.13 11-Dec-2005  christos merge ktrace-lwp.
 1.12 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.11 03-Jun-2005  scw branches: 1.11.2;
Use underscores to prefix local variables in macros.
 1.10 27-Feb-2005  perry nuke trailing whitespace
 1.9 14-Jul-2003  lukem branches: 1.9.8; 1.9.10;
add missing __KERNEL_RCSID()
 1.8 12-Jun-2003  scw branches: 1.8.2;
Tickle the watchdog while doing polled console i/o.
This is especially important if we spend any time in ddb. :)
 1.7 01-May-2003  scw In gtmpscinit_stop(), don't wait for abort completion status if the
receiver is disabled. It'll never complete in this case.
 1.6 08-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.5 24-Mar-2003  matt Make reset delay depend on the baud rate.
 1.4 24-Mar-2003  matt Make gtmpsc configurable via config file. (baud rate source, frequency).
 1.3 17-Mar-2003  matt Use generic softintr. switch from consinit to explicit cnattach
framework. Use bus_space for access register access.
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.8.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.4 17-Jan-2005  skrll Adapt to branch.
 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.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.8.1 29-Apr-2005  kent sync with -current
 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.14.12.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.14.10.3 19-Apr-2006  elad sync with head.
 1.14.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.14.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.14.8.4 11-Aug-2006  yamt sync with head
 1.14.8.3 26-Jun-2006  yamt sync with head.
 1.14.8.2 24-May-2006  yamt sync with head.
 1.14.8.1 01-Apr-2006  yamt sync with head.
 1.14.6.2 01-Jun-2006  kardel 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.18.2.1 19-Jun-2006  chap Sync with head.
 1.20.6.1 22-Oct-2006  yamt sync with head
 1.20.4.2 01-Feb-2007  ad Sync with head.
 1.20.4.1 18-Nov-2006  ad Sync with head.
 1.22.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.23.18.2 18-Oct-2007  yamt sync with head.
 1.23.18.1 14-Oct-2007  yamt sync with head.
 1.23.16.2 09-Jan-2008  matt sync with HEAD
 1.23.16.1 06-Nov-2007  matt sync with HEAD
 1.23.14.2 21-Nov-2007  joerg Sync with HEAD.
 1.23.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.23.2.2 23-Oct-2007  ad Sync with head.
 1.23.2.1 17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.25.2.2 21-Nov-2007  bouyer Sync with HEAD
 1.25.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.27.14.3 28-Sep-2008  mjf Sync with HEAD.
 1.27.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.27.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.8.1 18-Jun-2008  simonb Sync with head.
 1.28.6.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.28.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28.4.3 11-Aug-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.28.2.1 17-Jun-2008  yamt sync with head.
 1.30.2.1 19-Oct-2008  haad Sync with HEAD.
 1.31.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.37.4.3 31-May-2011  rmind sync with head
 1.37.4.2 05-Mar-2011  rmind sync with head
 1.37.4.1 30-May-2010  rmind sync with head
 1.37.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.37.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.43.18.1 18-May-2014  rmind sync with head
 1.43.14.2 03-Dec-2017  jdolecek update from HEAD
 1.43.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.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.44.2.1 10-Aug-2014  tls Rebase.
 1.46.20.1 10-Jun-2019  christos Sync with HEAD
 1.46.18.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.49.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 15-Jan-2016  joerg Switch to generic __BIT/__BITS macro, which doesn't depend on
left-shifting negative values.
 1.4 28-Apr-2010  kiyohara branches: 1.4.18; 1.4.36;
Clean up gt and peripherals.
This change tested compile only.
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.96; 1.3.98;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 05-Mar-2003  matt branches: 1.1.2; 1.1.10; 1.1.12;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.10.1 29-Apr-2005  kent sync with -current
 1.1.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.98.1 30-May-2010  rmind sync with head
 1.3.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.74.1 11-Aug-2010  yamt sync with head.
 1.4.36.1 19-Mar-2016  skrll Sync with HEAD
 1.4.18.1 03-Dec-2017  jdolecek update from HEAD
 1.8 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.7 06-Mar-2006  he branches: 1.7.66; 1.7.88; 1.7.90;
Remove another instance of the SET/CLR/ISSET macro triplet, now found
in <sys/types.h>.
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.6; 1.6.8;
merge ktrace-lwp.
 1.5 27-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 24-Mar-2003  matt branches: 1.4.2; 1.4.10; 1.4.12;
Make gtmpsc configurable via config file. (baud rate source, frequency).
 1.3 18-Mar-2003  matt Derive baud rate from cpu_timebase on powerpc.
 1.2 17-Mar-2003  matt Use generic softintr. switch from consinit to explicit cnattach
framework. Use bus_space for access register access.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 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.5.4.1 21-Jun-2006  yamt sync with head.
 1.6.8.1 13-Mar-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.90.1 30-May-2010  rmind sync with head
 1.7.88.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.7.66.1 11-Aug-2010  yamt sync with head.
 1.38 25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.37 21-Jul-2022  andvar fix typos in comments and log messages, mainly s/intrrupt/interrupt/.
 1.36 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.35 24-Apr-2021  thorpej branches: 1.35.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.34 07-Jul-2020  thorpej branches: 1.34.4;
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.33 14-Jun-2020  chs replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 1.32 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.31 06-Nov-2013  mrg branches: 1.31.6;
move some variables inside their #ifdef use.
 1.30 07-Sep-2012  matt branches: 1.30.2; 1.30.4;
Fix pci_conf_hook/interrupt for ARM.
 1.29 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.28 17-May-2011  dyoung branches: 1.28.4; 1.28.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.27 01-Aug-2010  kiyohara branches: 1.27.2;
Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.26 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.25 02-Jun-2010  kiyohara Move memory protection parameters to MI part.
Gtpci believes the initialization of the firmware(boot-loader) if protection
information is not obtained.
 1.24 02-Jun-2010  kiyohara Set NULL to tag when the property doesn't get it.
 1.23 02-Jun-2010  kiyohara Remove unused gpio.h.
 1.22 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.21 12-May-2009  cegger branches: 1.21.2; 1.21.4;
struct device * -> device_t, no functional changes intended.
 1.20 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.19 11-Apr-2008  he branches: 1.19.4; 1.19.18;
Put back a %s so that the format matches again. Fixes build for evbppc.
 1.18 08-Apr-2008  cegger use aprint_*_dev and device_xname
 1.17 03-Dec-2007  ad branches: 1.17.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.16 19-Oct-2007  ad branches: 1.16.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.15 29-Jan-2007  hubertf branches: 1.15.6; 1.15.18; 1.15.20; 1.15.24;
Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.14 29-Mar-2006  thorpej branches: 1.14.8;
Use device_private().
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.10; 1.13.12;
merge ktrace-lwp.
 1.12 27-Feb-2005  perry branches: 1.12.4;
nuke trailing whitespace
 1.11 30-Aug-2004  drochner branches: 1.11.4; 1.11.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.10 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.9 12-Jun-2003  scw branches: 1.9.2;
Add basic support for non-PCI host mode.
 1.8 27-May-2003  scw Add an option to control whether the GT's internal PCI Arbiter should
be enabled or not.
 1.7 04-Apr-2003  matt Remove #define DEBUG. (this was working right. The problem I encountered
was due to a bug in PPCBOOT. It was not ordering DIMM space largest to
smallest so that you could badly alignment memory).
 1.6 01-Apr-2003  matt Cleanup PCI support.
 1.5 18-Mar-2003  matt Split PCI initialization out of attach hook.
 1.4 18-Mar-2003  matt Enable I/O & memory access too.
 1.3 18-Mar-2003  matt Do minimal initialization of PCI.
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.9.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.2 03-Sep-2004  skrll Sync with HEAD
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 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.12.4.4 07-Dec-2007  yamt sync with head
 1.12.4.3 27-Oct-2007  yamt sync with head.
 1.12.4.2 26-Feb-2007  yamt sync with head.
 1.12.4.1 21-Jun-2006  yamt sync with head.
 1.13.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.13.10.1 19-Apr-2006  elad sync with head.
 1.13.8.1 01-Apr-2006  yamt sync with head.
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.8.1 01-Feb-2007  ad Sync with head.
 1.15.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.15.20.2 09-Jan-2008  matt sync with HEAD
 1.15.20.1 06-Nov-2007  matt sync with HEAD
 1.15.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.15.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.15.6.1 23-Oct-2007  ad Sync with head.
 1.16.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.17.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.4.2 11-Aug-2010  yamt sync with head.
 1.19.4.1 16-May-2009  yamt sync with head
 1.21.4.4 31-May-2011  rmind sync with head
 1.21.4.3 05-Mar-2011  rmind sync with head
 1.21.4.2 03-Jul-2010  rmind sync with head
 1.21.4.1 30-May-2010  rmind sync with head
 1.21.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.8.1 18-Feb-2012  mrg merge to -current.
 1.28.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.28.4.2 30-Oct-2012  yamt sync with head
 1.28.4.1 17-Apr-2012  yamt sync with head
 1.30.4.1 18-May-2014  rmind sync with head
 1.30.2.2 03-Dec-2017  jdolecek update from HEAD
 1.30.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.34.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.35.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 27-Dec-2019  msaitoh s/expresion/expression/ in comment.
 1.6 02-Jun-2010  kiyohara branches: 1.6.60;
Erase the old definition macro that forgot to be erased.
 1.5 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.96; 1.4.98;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry nuke trailing whitespace
 1.2 24-Mar-2003  matt branches: 1.2.2; 1.2.10; 1.2.12;
Fix tyops. Add 2 defines.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 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.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.98.2 03-Jul-2010  rmind sync with head
 1.4.98.1 30-May-2010  rmind sync with head
 1.4.96.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.74.1 11-Aug-2010  yamt sync with head.
 1.6.60.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11 07-Sep-2012  matt Fix pci_conf_hook/interrupt for ARM.
 1.10 02-Jun-2010  kiyohara branches: 1.10.8;
Move memory protection parameters to MI part.
Gtpci believes the initialization of the firmware(boot-loader) if protection
information is not obtained.
 1.9 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.8 21-Feb-2007  thorpej branches: 1.8.42; 1.8.64; 1.8.66;
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.7 16-Feb-2006  perry branches: 1.7.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.6 24-Dec-2005  perry branches: 1.6.2; 1.6.4; 1.6.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.5 12-Jun-2003  scw branches: 1.5.18;
Add basic support for non-PCI host mode.
 1.4 01-Apr-2003  matt Cleanup PCI support.
 1.3 18-Mar-2003  matt Split PCI initialization out of attach hook.
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.5.18.1 26-Feb-2007  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.6.2.1 18-Feb-2006  yamt sync with head.
 1.7.20.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.8.66.2 03-Jul-2010  rmind sync with head
 1.8.66.1 30-May-2010  rmind sync with head
 1.8.64.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.8.64.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.42.1 11-Aug-2010  yamt sync with head.
 1.10.8.1 30-Oct-2012  yamt sync with head
 1.7 10-Nov-2021  msaitoh s/endianess/endianness/
 1.6 30-Oct-2021  andvar "no affect" -> "no effect" in man pages and comments.
 1.5 09-Jun-2010  kiyohara Fix debug messages.
- s/DEBUG/GT_DEBUG/.
- Indent.
- The old one is 20 bits in the mask of the address register, and the
new one is 16 bits.
 1.4 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.96; 1.3.98;
merge ktrace-lwp.
 1.2 27-Feb-2005  perry nuke trailing whitespace
 1.1 05-Mar-2003  matt branches: 1.1.2; 1.1.10; 1.1.12;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.10.1 29-Apr-2005  kent sync with -current
 1.1.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.3.98.2 03-Jul-2010  rmind sync with head
 1.3.98.1 30-May-2010  rmind sync with head
 1.3.96.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.74.1 11-Aug-2010  yamt sync with head.
 1.6 15-Jan-2016  joerg Switch to generic __BIT/__BITS macro, which doesn't depend on
left-shifting negative values.
 1.5 28-Apr-2010  kiyohara branches: 1.5.18; 1.5.36;
Clean up gt and peripherals.
This change tested compile only.
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.96; 1.4.98;
merge ktrace-lwp.
 1.3 27-Feb-2005  perry nuke trailing whitespace
 1.2 02-Nov-2003  wiz branches: 1.2.8; 1.2.10;
boundary, not boundry. Inspired by Tom Cosgrove.
 1.1 05-Mar-2003  matt branches: 1.1.2;
Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.1.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 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.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.8.1 29-Apr-2005  kent sync with -current
 1.4.98.1 30-May-2010  rmind sync with head
 1.4.96.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.4.74.1 11-Aug-2010  yamt sync with head.
 1.5.36.1 19-Mar-2016  skrll Sync with HEAD
 1.5.18.1 03-Dec-2017  jdolecek update from HEAD
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Clean up gt and peripherals.
This change tested compile only.
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file gtsdmavar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gtsdmavar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:30 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gtsdmavar.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.12 12-Jan-2020  thorpej Clean up gttwsi's register access stuff:
- Garbage-collect the obsolete GTTWSI_ALLWINNER option; it hasn't been
needed since FDT'ization of the Allwinner support code.
- Redefine thw "TWSI_*" register definitions to clearly call out:
-> The Marvell flavor of the offsets
-> The Allwinner flavor of the offsets
...and make the regular definitions indices into a register map.
- Pass the appropriate register map from the front-end to the core.
- Remove the customer register read/write callbacks -- they are no longer
needed now that each front-end passes an appropriate register map to
the core.
 1.11 06-Sep-2013  matt branches: 1.11.30; 1.11.38;
Make gttswi MI and usuable from non-Marvell SoCs.
(should rename to mvi2c but ...)
 1.10 05-Sep-2013  matt Make sc_started bool and true/false instead of 1/0
 1.9 03-Aug-2013  kiyohara Issue the STOP-bit if needed.
And remove #ifdef ARMADAXP.
 1.8 13-May-2013  christos branches: 1.8.2;
There is no opt_mvsoc.h; the #ifdef ARMADAXP should be changed to some
inherited device property.
 1.7 01-May-2013  rkujawa TWSI controller on Armada XP is a bit different. Support that.

Obtained from Marvell, Semihalf.
 1.6 21-Jul-2012  kiyohara branches: 1.6.2;
Don't send a stop bit immediately after start bit transmission.
 1.5 10-Oct-2010  kiyohara branches: 1.5.8;
Add timeout for wait.
Not send STOP, if received ACK.
 1.4 03-Oct-2010  kiyohara Fix ack/no-ack. Last data sends with stop-bit without ack.
 1.3 01-Aug-2010  kiyohara branches: 1.3.2;
Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.2 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4;
Clean up gt and peripherals.
This change tested compile only.
 1.1.4.3 05-Mar-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gttwsi.c was added on branch rmind-uvmplock on 2010-05-30 05:17:30 +0000
 1.1.2.4 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gttwsi.c was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.3.2.3 09-Oct-2010  yamt sync with head
 1.3.2.2 11-Aug-2010  yamt sync with head.
 1.3.2.1 01-Aug-2010  yamt file gttwsi.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.5.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.5.8.1 30-Oct-2012  yamt sync with head
 1.6.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.1 23-Jun-2013  tls resync from head
 1.8.2.2 18-May-2014  rmind sync with head
 1.8.2.1 28-Aug-2013  rmind sync with head
 1.11.38.1 17-Jan-2020  ad Sync with head.
 1.11.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5 06-Sep-2013  matt Make gttswi MI and usuable from non-Marvell SoCs.
(should rename to mvi2c but ...)
 1.4 03-Aug-2013  kiyohara Issue the STOP-bit if needed.
And remove #ifdef ARMADAXP.
 1.3 01-May-2013  rkujawa branches: 1.3.4;
TWSI controller on Armada XP is a bit different. Support that.

Obtained from Marvell, Semihalf.
 1.2 21-Jul-2012  kiyohara branches: 1.2.2;
TWSI size is 0x100. Not 0x1000.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14;
Clean up gt and peripherals.
This change tested compile only.
 1.1.14.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.14.1 30-Oct-2012  yamt sync with head
 1.1.6.2 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file gttwsireg.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:37 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file gttwsireg.h was added on branch rmind-uvmplock on 2010-05-30 05:17:30 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file gttwsireg.h was added on branch uebayasi-xip on 2010-04-30 14:43:27 +0000
 1.2.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.2.1 23-Jun-2013  tls resync from head
 1.3.4.2 18-May-2014  rmind sync with head
 1.3.4.1 28-Aug-2013  rmind sync with head
 1.15 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.14 12-May-2009  cegger branches: 1.14.2; 1.14.4;
struct device * -> device_t, no functional changes intended.
 1.13 21-Feb-2007  thorpej branches: 1.13.42; 1.13.58;
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.12 24-May-2006  mrg branches: 1.12.12;
'volatile' is not a valid return type qualifier - remove it.
 1.11 16-Feb-2006  perry branches: 1.11.2; 1.11.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.10 24-Dec-2005  perry branches: 1.10.2; 1.10.4; 1.10.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 01-Feb-2005  matt branches: 1.8.6;
Add I2C child hooks.
 1.7 26-Nov-2004  jmc branches: 1.7.4; 1.7.6;
Put back a few locators.h includes that are still needed here. Now evbppc
kernels build clean once again
 1.6 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.5 20-Mar-2004  matt Add gt_dma_bus_mem_to_phys and gt_dma_phys_to_bus_mem.
 1.4 12-Jun-2003  scw branches: 1.4.2;
Add basic support for non-PCI host mode.
 1.3 18-Mar-2003  matt Split PCI initialization out of attach hook.
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.4.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.4.2.4 29-Nov-2004  skrll Sync with HEAD.
 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.7.6.1 12-Feb-2005  yamt sync with head.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.8.6.2 26-Feb-2007  yamt sync with head.
 1.8.6.1 21-Jun-2006  yamt sync with head.
 1.10.6.2 01-Jun-2006  kardel 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.8.1 19-Jun-2006  chap Sync with head.
 1.11.2.1 26-Jun-2006  yamt sync with head.
 1.12.12.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.13.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.42.2 11-Aug-2010  yamt sync with head.
 1.13.42.1 16-May-2009  yamt sync with head
 1.14.4.1 30-May-2010  rmind sync with head
 1.14.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.63 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.62 02-Oct-2025  thorpej Rename property "mac-addr" -> "mac-address" to match everyone else.
 1.61 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.60 20-Aug-2022  thorpej branches: 1.60.10;
gfe_ifstart(): Replace "IF_DEQUEUE() -> IF_PREPEND() on failure" with
"IF_POLL() -> IF_DEQUEUE() on success".
 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 05-Sep-2020  riastradh branches: 1.57.4;
Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.56 05-Feb-2020  skrll Adopt <net/if_stats.h>
 1.55 04-Feb-2020  skrll Adopt <net/if_stats.h>
 1.54 28-May-2019  msaitoh branches: 1.54.4;
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.53 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.52 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.51 22-Apr-2019  msaitoh These drivers do ether_ioctl() on SIOC{ADD,DEL}MULTI, SIOC{G,S}IFMEDIA and
default case in the switch statement. Only the default case didn't check the
return value with ENETRESET. Integrate them to one ether_ioctl() with
ENETRESET test. This change might improve some other ioctl()s which return
ENETRESET by calling if_init().
 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 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 15-Dec-2016  ozaki-r branches: 1.48.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.47 10-Jun-2016  ozaki-r branches: 1.47.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.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 11-Jan-2015  joerg sizeof doesn't evaluate the expression, so increment of rxd doesn't
happen. Move it out.
 1.43 21-Sep-2014  christos branches: 1.43.2;
this is not python (add braces)
 1.42 10-Aug-2014  tls branches: 1.42.2;
Merge tls-earlyentropy branch into HEAD.
 1.41 22-Jul-2012  matt branches: 1.41.2; 1.41.12;
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-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.39 13-Nov-2010  uebayasi branches: 1.39.8; 1.39.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.38 01-Aug-2010  kiyohara Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.37 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.36 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.35 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.34 19-Jan-2010  pooka branches: 1.34.2; 1.34.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.33 12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.32 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.31 07-Nov-2008  dyoung branches: 1.31.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.30 10-Jun-2008  he branches: 1.30.2; 1.30.4;
Avoid the effects of name space pollution caused by <sys/rb.h>,
which defines rb_data, by instead naming the struct field rxb_data.
 1.29 08-Apr-2008  cegger branches: 1.29.2; 1.29.4; 1.29.6; 1.29.8;
use aprint_*_dev and device_xname
 1.28 07-Feb-2008  dyoung branches: 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 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.26 19-Oct-2007  ad branches: 1.26.2; 1.26.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.25 01-Sep-2007  dyoung branches: 1.25.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.24 26-Aug-2007  dyoung branches: 1.24.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.23 09-Jul-2007  ad branches: 1.23.2; 1.23.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.22 07-Mar-2007  he branches: 1.22.2; 1.22.4;
Cast to char* and int before doing pointer arithmetic.
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 29-Mar-2006  thorpej branches: 1.20.14;
Use device_private().
 1.19 29-Mar-2006  thorpej Use device_cfdata().
 1.18 25-Mar-2006  thorpej Use device_parent().
 1.17 11-Dec-2005  christos branches: 1.17.4; 1.17.6; 1.17.8; 1.17.10; 1.17.12;
merge ktrace-lwp.
 1.16 27-Feb-2005  perry branches: 1.16.4;
nuke trailing whitespace
 1.15 01-Feb-2005  matt Allow the driver to allocate needs resources on attach and not free
depending on cf_flags (instead of on interface up / down).
 1.14 30-Jan-2005  thorpej Eliminate use of M_HASFCS.
 1.13 05-Aug-2003  scw branches: 1.13.8; 1.13.10;
Try to drain the Tx pending queues after dealing with Rx/Tx interrupts.

This fixes a bug whereby a fast cpu with a decent cache can easily
outstrip the GT's ability to put packets on the wire, resulting in a
permanent backlog of mbufs in the Tx pending queues under heavy Tx load.

The bug was masked if the packet buffer was mapped non-cached, which
slowed down the cpu to where it couldn't keep up with the GT at 100mbit.
 1.12 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.11 12-Jun-2003  scw branches: 1.11.2;
Always pass BUS_DMA_COHERENT to bus_dmamem_map() when allocating
descriptor/buffer memory.
 1.10 30-Apr-2003  matt Update inptr *after* we do the dmasync.
 1.9 30-Apr-2003  matt Fix overrun of TX buffer dmamap.
 1.8 10-Apr-2003  scw When attaching, make sure the "Reject Broadcast Mode", "Promiscuous Mode"
and "Pass Bad Frames" bits in the EPCR register are clear.

This works around a problem where firmware sets RBM for some reason before
handing control to the NetBSD kernel.
 1.7 08-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.6 08-Apr-2003  matt Deal with discovery strangeness/timing issue. Sometimes the Ownership bit
on descriptor doesn't get reset so look beyond to the next descriptor to
see if it's been returned. If it has, then just process the current one.
 1.5 24-Mar-2003  matt Update bpf interface to current. Make output buffers aligned to a
cacheline bounary. Only put hash table and descriptors in uncached
memory, buffers are in cached memory.
 1.4 18-Mar-2003  matt remove some unneeded code.
 1.3 17-Mar-2003  matt Use a subregion for the mac's ethernet registers. Shaves 512 bytes
from the driver.
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.11.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.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.16.4.5 11-Feb-2008  yamt sync with head.
 1.16.4.4 21-Jan-2008  yamt sync with head
 1.16.4.3 27-Oct-2007  yamt sync with head.
 1.16.4.2 03-Sep-2007  yamt sync with head.
 1.16.4.1 21-Jun-2006  yamt sync with head.
 1.17.12.2 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.17.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.17.10.1 19-Apr-2006  elad sync with head.
 1.17.8.1 01-Apr-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.20.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.4.1 11-Jul-2007  mjf Sync with head.
 1.22.2.3 23-Oct-2007  ad Sync with head.
 1.22.2.2 09-Oct-2007  ad Sync with head.
 1.22.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.23.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.23.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.23.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.24.2.2 23-Mar-2008  matt sync with HEAD
 1.24.2.1 06-Nov-2007  matt sync with HEAD
 1.25.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.8.1 20-Jan-2008  bouyer Sync with HEAD
 1.26.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.28.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.28.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.28.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.8.1 18-Jun-2008  simonb Sync with head.
 1.29.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.4.4 11-Aug-2010  yamt 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 04-May-2009  yamt sync with head.
 1.29.2.1 17-Jun-2008  yamt sync with head.
 1.30.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.30.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.31.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 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.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.34.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.39.12.1 18-Feb-2012  mrg merge to -current.
 1.39.8.2 30-Oct-2012  yamt sync with head
 1.39.8.1 17-Apr-2012  yamt sync with head
 1.41.12.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.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.2.2 12-Jan-2015  martin Pull up following revision(s) (requested by joerg in ticket #410):
sys/dev/marvell/if_gfe.c: revision 1.44
sizeof doesn't evaluate the expression, so increment of rxd doesn't
happen. Move it out.
 1.42.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.43.2.5 05-Feb-2017  skrll Sync with HEAD
 1.43.2.4 09-Jul-2016  skrll Sync with HEAD
 1.43.2.3 19-Mar-2016  skrll Sync with HEAD
 1.43.2.2 06-Jun-2015  skrll Sync with HEAD
 1.43.2.1 06-Apr-2015  skrll Sync with HEAD
 1.47.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.48.14.2 26-Jan-2019  pgoyette Sync with HEAD
 1.48.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.49.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.49.2.1 10-Jun-2019  christos Sync with HEAD
 1.54.4.1 29-Feb-2020  ad Sync with head.
 1.57.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.57.4.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.58.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.60.10.1 02-Aug-2025  perseant Sync with HEAD
 1.13 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.12 02-Feb-2012  tls branches: 1.12.6; 1.12.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.11 19-Nov-2011  tls branches: 1.11.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.10 28-Apr-2010  kiyohara branches: 1.10.8;
Clean up gt and peripherals.
This change tested compile only.
 1.9 10-Jun-2008  he branches: 1.9.16; 1.9.18;
Avoid the effects of name space pollution caused by <sys/rb.h>,
which defines rb_data, by instead naming the struct field rxb_data.
 1.8 04-Mar-2007  christos branches: 1.8.36; 1.8.38; 1.8.40; 1.8.42; 1.8.44;
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;
merge ktrace-lwp.
 1.6 27-Feb-2005  perry branches: 1.6.4;
nuke trailing whitespace
 1.5 01-Feb-2005  matt Allow the driver to allocate needs resources on attach and not free
depending on cf_flags (instead of on interface up / down).
 1.4 08-Apr-2003  thorpej branches: 1.4.2; 1.4.10; 1.4.12;
Use PAGE_SIZE rather than NBPG.
 1.3 17-Mar-2003  matt Use a subregion for the mac's ethernet registers. Shaves 512 bytes
from the driver.
 1.2 16-Mar-2003  matt Cleanup. Move much of the code to bus_space instead of using
private mechanisms.
 1.1 05-Mar-2003  matt Add preliminary support Marvell (Galileo) Discovery System Controllers.
This code was contributed by Allegro Networks.
 1.4.12.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.12.1 12-Feb-2005  yamt sync with head.
 1.4.10.1 29-Apr-2005  kent sync with -current
 1.4.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.6.4.1 03-Sep-2007  yamt sync with head.
 1.7.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.44.1 18-Jun-2008  simonb Sync with head.
 1.8.42.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.40.2 11-Aug-2010  yamt sync with head.
 1.8.40.1 04-May-2009  yamt sync with head.
 1.8.38.1 17-Jun-2008  yamt sync with head.
 1.8.36.1 29-Jun-2008  mjf Sync with HEAD.
 1.9.18.1 30-May-2010  rmind sync with head
 1.9.16.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.8.1 17-Apr-2012  yamt sync with head
 1.11.2.1 18-Feb-2012  mrg merge to -current.
 1.12.24.1 06-Jun-2015  skrll Sync with HEAD
 1.12.6.1 03-Dec-2017  jdolecek update from HEAD
 1.70 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.69 07-Dec-2024  andvar s/funcstions/functions/ in comment.
 1.68 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.67 04-Feb-2024  andvar branches: 1.67.2;
fix tripple/quadruple "r" letter typos in comments and log messages.
 1.66 21-May-2022  rin Correct byte-order for bufsize field of RX descriptor.

XXX
This bug affected only armeb. Unfortunately, the systems including
armel still lock up eventually with NFS root on mvgbe(4)...
 1.65 21-May-2022  rin m_freem() *after* bus_dmamap_sync() and bus_dmamap_load() for
that mbuf. This is mandatory for some archs.
 1.64 21-May-2022  rin Add DPRINTF() to catch failure of m_defrag() in mvgbe_encap().
 1.63 21-May-2022  rin Raise threshold of debug level to 3 for DPRINTF() in non-error path of
mvgbe_encap(). Without this change, debug level 2 is almost unusable...
 1.62 30-Aug-2021  rin Add ARMEB support to mvgbe(4).

For ARMEB, peripheral is configured to little-endian mode, even if
CPU itself is in big-endian mode. Therefore, we need to configure
the device to little-endian mode, and byte-swap descriptor fields
(unlike the case of powerpc).
 1.61 07-Aug-2021  thorpej 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 03-Feb-2020  skrll branches: 1.59.8;
Adopt <net/if_stats.h>
 1.58 13-Sep-2019  msaitoh branches: 1.58.2;
if_flags is neither int nor short. It's unsigned short.
 1.57 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.56 23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.55 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.54 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.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 16-Nov-2018  jmcneill Add intr_establish_xname support to arm and expose it to intrctl
 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 26-Jun-2018  msaitoh branches: 1.50.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.49 01-Jun-2017  chs branches: 1.49.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.48 07-Jan-2017  kiyohara Support Marvell Dove.
 1.47 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.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 10-Jun-2016  ozaki-r branches: 1.45.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.44 13-Feb-2016  hikaru Pass all unicast addresses if it is promisc mode.
 1.43 09-Feb-2016  kiyohara Add more #warning message 'Please use mvxpe instead of this'.
 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 15-Apr-2015  hsuenaga add u-boot argument parser for Marvell ARMADA XP/370.
use 'ethaddr' and 'eth1addr' in u-boot argument to setup MAC address of mvgbe.
 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 15-Mar-2014  kiyohara branches: 1.38.2;
Support Armada 370 and DDR3 tags.
 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-Feb-2014  msaitoh Carefully set IFF_OACTIVE in mvgbe_start(). Even if mvgbe_encap()
returns other than 0, the TX ring might not full. Check whether
the TX ring has one or more packets. If the ring is empty,
dont' set IFF_OACTIVE because an TX complete interrupt never
occur and IFF_OACTIVE flags is left. The interface's timer
isn't reset, so a device timeout desn't occur.

Fixes a bug that IFF_OACTIVE flag is left on heavy load.
Part of PR#48568.
 1.35 23-Dec-2013  kiyohara Support Basic Mode for Armada XP.
 1.34 28-Dec-2012  msaitoh branches: 1.34.2;
Fix a bug that a multicast filter entry is incorrectly overrode
on some cases.
 1.33 20-Dec-2012  msaitoh Check wheter an MII PHY is really connected or not.
This change privents panic if MII PHY port is not used.
 1.32 09-Nov-2012  msaitoh Add MVGBE_EVENT_COUNTERS for debugging. Count rxoverrrun and wdogsoft.
 1.31 08-Nov-2012  msaitoh Fix a bug that MVGBE_JLEN is miscalculated.
 1.30 08-Nov-2012  msaitoh When an interrput is link change, notify link change to mii layer using
mii_pollstat().
 1.29 08-Nov-2012  msaitoh Don't use M_HASFCS flag.
 1.28 01-Nov-2012  msaitoh No functional change.
- Change style a bit.
- use "csc" for the variable name of struct mvgbec_softc in mvgbec_attach()
for consistency.
 1.27 26-Oct-2012  msaitoh Add missing mii_tick() call.
 1.26 17-Oct-2012  msaitoh Fix a bug that kernel panics when the system get a packet while calling
mvgbe_stop (via ifconfig down).
 1.25 16-Oct-2012  msaitoh Add code to modify interrupt coalescing with sysctl.
- both TX side an RX side.
- different setting for each port
- TX side is hw.mvgbe.mvgbe*.ipginttx
- RX side is hw.mvgbe.mvgbe*.ipgintrx
- The default value is 768.
- The lowest value is 0
- For highest value, 0x3777 is used for V1, and 0xffff is used for V2.
 1.24 14-Oct-2012  msaitoh Add Interrupt Coalescing setting by Robert Swindells.
 1.23 12-Oct-2012  msaitoh - The MVGBE_RX_MAX_FRAME_LEN_ERROR bit is used to check whether a packet
is fragmented or not, so define new MVGBE_RX_IP_FRAGMENT with the same
value and use it.
- Remove the checking whether a packet length is lower than 72 octet.
This check is not used in Linux and FreeBSD. Tested with me (for Kirkwood)
and Kiyohara (for DiscoveryII).
 1.22 04-Oct-2012  msaitoh Fix udpcsum-rx bug on fragmented case this time.
- Fix the usage of a local variable for csum_flags.
- It seemd that sometimes MVGBE_RX_L4_CHECKSUM_OK bit were set to 0
even if the checksum is correct and the packet was not fragmented.
So we don't set M_CSUM_TCP_UDP_BAD even if csum bit is 0.
 1.21 02-Oct-2012  msaitoh - Fix a bug that a fragmented packet is marked as bad checksum. It causes
a real bug when HW checksum offload function is used. It was easy to
reproduce with NFS UDP mount.
- Fix a potential bug that a packet other than TCP and UDP is marked as bad
checksum.
 1.20 21-Sep-2012  msaitoh Fix device timeout problem.
- Change the synching order of descriptors. First, sync descriptors except
first and then sync the first descriptor.
- To recover from an race condition, reduce the if_timer from 5 to 1 and
when timeout occur write MVGBE_TQC_ENQ bit again.
 1.19 06-Sep-2012  msaitoh branches: 1.19.2;
Add missing bus_dmamap_sync() for the RX buffer.
 1.18 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.17 18-Jul-2012  kiyohara Add 88F6282. tested only OpenBlockS A6.
Also fix irq 11 to 15. irq of 2nd NIC is 15.
Remove white-space.
 1.16 02-Feb-2012  tls branches: 1.16.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.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-Nov-2011  jakllsch Add workaround for infrequently encountered DMA engine limitation.
 1.13 06-Sep-2011  rjs branches: 1.13.2;
Only zero MVGBE_MTU on Orion platforms.
 1.12 01-Sep-2011  jakllsch We occasionally will try to set up the multicast filter in a context that
kmem(9) is unusable (such as transmit timeout). Thus, put the filter table
on the stack instead, all 528 bytes of it.
 1.11 01-Sep-2011  jakllsch Initialize MVGBE_MTU to 0, as suggested by the Orion databook.

If the platform firmware did not initialize this to 0 for us,
we were unable to transmit frames.
 1.10 30-Jul-2011  rjs Use new style BPF calls.
 1.9 28-Jul-2011  matt Use cfdata_t
 1.8 07-Mar-2011  christos fix typo, and use the parent to determine the offset. From Dave Mills
 1.7 06-Mar-2011  christos don't abuse cf_unit, requested by phone.
 1.6 05-Mar-2011  christos From Dave Mills: It would appear that the two PHYs can only be
accessed from the registers of controller0 (mvgbec0) hence why both
PHYs are being detected on controller0. I have made the assumption
that PHY0 => controller0 (mvgbec0), PHY1 => controller1(mvgbec1)
and developed a patch accordingly. Also the irq is 15 for controller1
not 14.
 1.5 01-Feb-2011  jakllsch Various improvements to mvgbe(4). Notable is improved multicast filtering.
 1.4 29-Jan-2011  jakllsch Use macros for ring position advances, assuming a power of two ring size.
(Also, spelling correction in comment.)
 1.3 02-Oct-2010  kiyohara branches: 1.3.2; 1.3.4;
Support Kirkwood's GbE.
 1.2 11-Jul-2010  kiyohara branches: 1.2.2; 1.2.4;
Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.1 02-Jun-2010  kiyohara branches: 1.1.2;
Add Marvell Gigabit Ethernet Controller on SC/SoC.
Will support on ofppc soon.
Tested on G4+PegasosII (kiyohara@)
G3+PegasosII (phx@)
 1.1.2.5 21-Apr-2011  rmind sync with head
 1.1.2.4 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.1.2.3 05-Mar-2011  rmind sync with head
 1.1.2.2 03-Jul-2010  rmind sync with head
 1.1.2.1 02-Jun-2010  rmind file if_mvgbe.c was added on branch rmind-uvmplock on 2010-07-03 01:19:36 +0000
 1.2.4.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.2.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.4.1 11-Jul-2010  uebayasi file if_mvgbe.c was added on branch uebayasi-xip on 2010-08-17 06:46:17 +0000
 1.2.2.3 09-Oct-2010  yamt sync with head
 1.2.2.2 11-Aug-2010  yamt sync with head.
 1.2.2.1 11-Jul-2010  yamt file if_mvgbe.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.3.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.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.13.2.4 23-Jan-2013  yamt sync with head
 1.13.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.13.2.2 30-Oct-2012  yamt sync with head
 1.13.2.1 17-Apr-2012  yamt sync with head
 1.15.2.1 18-Feb-2012  mrg merge to -current.
 1.16.2.3 07-Jan-2013  riz Pull up following revision(s) (requested by msaitoh in ticket #775):
sys/dev/marvell/if_mvgbe.c: revision 1.34
Fix a bug that a multicast filter entry is incorrectly overrode
on some cases.
 1.16.2.2 05-Jan-2013  riz Pull up following revision(s) (requested by msaitoh in ticket #766):
sys/dev/marvell/if_mvgbe.c: revision 1.33
Check wheter an MII PHY is really connected or not.
This change privents panic if MII PHY port is not used.
 1.16.2.1 20-Nov-2012  riz Apply patch (requested by msaitoh in ticket #671):

sys/dev/marvell/if_mvgbe.c 1.19-1.23, 1.26-1.31
sys/dev/marvell/mvgbereg.h 1.4-1.5, 1.7

Add missing bus_dmamap_sync() for the RX buffer.
Fix device timeout problem.
Fix broken hardware checksumming.
Fix a bug that kernel panics when the system get a packet while calling
mvgbe_stop (via ifconfig down).
Add missing mii_tick() call.
Change style a bit.
Don't use M_HASFCS flag.
When an interrput is link change, notify link change to mii layer using
mii_pollstat().
Fix a bug that the alignment of jumbo buffer(MVGBE_JLEN) is miscalculated.
 1.19.2.4 03-Dec-2017  jdolecek update from HEAD
 1.19.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.2.2 25-Feb-2013  tls resync with head
 1.19.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.34.2.1 18-May-2014  rmind sync with head
 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.45.2.2 20-Mar-2017  pgoyette 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.49.8.4 26-Jan-2019  pgoyette Sync with HEAD
 1.49.8.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.49.8.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.49.8.1 28-Jul-2018  pgoyette Sync with HEAD
 1.50.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.50.2.1 10-Jun-2019  christos Sync with HEAD
 1.58.2.1 29-Feb-2020  ad Sync with head.
 1.59.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.59.8.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.60.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.67.2.1 02-Aug-2025  perseant Sync with HEAD
 1.44 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.43 19-May-2025  andvar spelling and grammar fixes in comments.
 1.42 18-May-2025  andvar s/activety/activity/ in comment.
 1.41 10-Feb-2024  andvar branches: 1.41.2;
Fix various typos in comments, log messages and documentation.
 1.40 04-Apr-2022  andvar fix various typos, mainly in comments.
 1.39 16-Feb-2022  andvar fix various typos, mainly in comments.
 1.38 12-Feb-2022  riastradh sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.
 1.37 05-Dec-2021  msaitoh s/sumary/summary/
 1.36 17-Sep-2021  andvar some love to double letters (in comments).
 1.35 13-Aug-2021  andvar s/fame/frame in mvxpe_mib_def with assumption that it was not intentional typo.
 1.34 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.33 05-Feb-2020  skrll Adopt <net/if_stats.h>
 1.32 04-Feb-2020  skrll Adopt <net/if_stats.h>
 1.31 28-Dec-2019  gutteridge branches: 1.31.2;
Fix typos in messages.
 1.30 15-Oct-2019  chs convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures.
 1.29 01-Oct-2019  chs make this compile again:
- remove unused config attributes
- rename a local variable to avoid a name conflict
 1.28 13-Sep-2019  msaitoh if_flags is neither int nor short. It's unsigned short.
 1.27 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.26 24-May-2019  msaitoh Whilespace fix. No functional change.
 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 24-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.22 18-Mar-2019  msaitoh s/pakcet/packet/ in comment.
 1.21 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.20 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.19 26-Jun-2018  msaitoh branches: 1.19.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.18 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.17 15-Dec-2016  ozaki-r branches: 1.17.14; 1.17.16;
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 20-Oct-2016  skrll Fix regisers typo
 1.14 10-Oct-2016  kiyohara The bus_dmamap_sync(PREREAD) is unnecessary for sent mbuf.
Moreover bus_dmamap_sync(POSTWRITE), before unload.
 1.13 10-Jun-2016  ozaki-r branches: 1.13.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.12 13-Feb-2016  hikaru Make all packets are enqueued into queue 0.
queue 7 is not default, it is caused by the filter tables.
The fields are including queue number, not bitfields.
So MVXPE_DF_QUEUE_ALL (b111) means queue 7.

And also, pass all unicast addresses if it is promisc mode.
MVXPE_PXC_UPM is working in almost cases,
but this change is needed for some cases; bridging frames through inter units,
using products have consecutive MAC addresses.
 1.11 13-Feb-2016  hikaru Fix typo in sysctls.
 1.10 13-Feb-2016  hikaru Count up if_{opackets,oerrors,ierrors,collisions}.
And also "MAC Transmit Error" is tx error, not rx.
 1.9 13-Feb-2016  hikaru Style.
 1.8 13-Feb-2016  hikaru Preserve rx csum bad flags.
 1.7 13-Feb-2016  hikaru Fix mitake, disable SERDES error interrupts again.
 1.6 13-Feb-2016  hikaru Don't use RXTX intr that is excess and requires another IRQ handler,
and disable SERDES error interrupts.
 1.5 13-Feb-2016  hikaru Correct bus_dmamap_sync operaion.
 1.4 13-Feb-2016  hikaru Correct locks and missing breaks.
 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 03-Jun-2015  hsuenaga branches: 1.2.2;
separate buffer management codes 'mvxpbm.c' from if_mvxpe.c.

the buffer management(ex. fill the rx descriptors/buffers) is done by H/W in
ARMADA XP/380, and is done by S/W in ARMADA 370. the H/W BM support is not yet
implemented, so all devices use the S/W management mode at this time.
 1.1 03-May-2015  hsuenaga add new ethernet driver mvxpe for recent MARVELL's SoC after ARMADA/XP.
this driver supports 'counter mode', and is disabled by default.

ARMADA SoC family has new ethernet controller acceleration mode called
'enhanced mode' or 'counter mode.' it seems that backward compatibility mode
used by if_mvgbe is still working, but the specification of the old mode
is completely disappeared from SoC's reference manual.

I tested the driver using MIRABOX(ARMADA/370).
 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 09-Jul-2016  skrll Sync with HEAD
 1.2.2.3 19-Mar-2016  skrll Sync with HEAD
 1.2.2.2 06-Jun-2015  skrll Sync with HEAD
 1.2.2.1 03-Jun-2015  skrll file if_mvxpe.c was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.13.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.13.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.17.16.4 26-Jan-2019  pgoyette Sync with HEAD
 1.17.16.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.17.16.2 28-Jul-2018  pgoyette Sync with HEAD
 1.17.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.17.14.2 03-Dec-2017  jdolecek update from HEAD
 1.17.14.1 15-Dec-2016  jdolecek file if_mvxpe.c was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.19.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.19.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.19.2.1 10-Jun-2019  christos Sync with HEAD
 1.31.2.1 29-Feb-2020  ad Sync with head.
 1.41.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 02-Feb-2024  andvar fix various typos in comments.
 1.7 10-Nov-2021  msaitoh s/Erorr/Error/ in comment.
 1.6 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.5 18-Mar-2019  msaitoh s/pakcet/packet/ in comment.
 1.4 13-Feb-2016  hikaru branches: 1.4.16; 1.4.20;
Count up if_{opackets,oerrors,ierrors,collisions}.
And also "MAC Transmit Error" is tx error, not rx.
 1.3 12-Feb-2016  hikaru Fix the bitmask of MVXPE_PMACC0_FRAMESIZELIMIT. It did no harm.
 1.2 03-Jun-2015  hsuenaga branches: 1.2.2;
separate buffer management codes 'mvxpbm.c' from if_mvxpe.c.

the buffer management(ex. fill the rx descriptors/buffers) is done by H/W in
ARMADA XP/380, and is done by S/W in ARMADA 370. the H/W BM support is not yet
implemented, so all devices use the S/W management mode at this time.
 1.1 03-May-2015  hsuenaga add new ethernet driver mvxpe for recent MARVELL's SoC after ARMADA/XP.
this driver supports 'counter mode', and is disabled by default.

ARMADA SoC family has new ethernet controller acceleration mode called
'enhanced mode' or 'counter mode.' it seems that backward compatibility mode
used by if_mvgbe is still working, but the specification of the old mode
is completely disappeared from SoC's reference manual.

I tested the driver using MIRABOX(ARMADA/370).
 1.2.2.3 19-Mar-2016  skrll Sync with HEAD
 1.2.2.2 06-Jun-2015  skrll Sync with HEAD
 1.2.2.1 03-Jun-2015  skrll file if_mvxpereg.h was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.4.20.1 10-Jun-2019  christos Sync with HEAD
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 13-Feb-2016  jdolecek file if_mvxpereg.h was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.9 04-Apr-2022  andvar fix various typos, mainly in comments.
 1.8 13-Mar-2022  andvar s/hander/handler/ and s/hader/header/ in comments and documentation.
 1.7 16-Feb-2022  andvar fix various typos, mainly in comments.
 1.6 05-Dec-2021  msaitoh s/decriptor/descriptor/ in comment.
 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 13-Feb-2016  hikaru branches: 1.3.16; 1.3.18;
Make all packets are enqueued into queue 0.
queue 7 is not default, it is caused by the filter tables.
The fields are including queue number, not bitfields.
So MVXPE_DF_QUEUE_ALL (b111) means queue 7.

And also, pass all unicast addresses if it is promisc mode.
MVXPE_PXC_UPM is working in almost cases,
but this change is needed for some cases; bridging frames through inter units,
using products have consecutive MAC addresses.
 1.2 03-Jun-2015  hsuenaga branches: 1.2.2;
separate buffer management codes 'mvxpbm.c' from if_mvxpe.c.

the buffer management(ex. fill the rx descriptors/buffers) is done by H/W in
ARMADA XP/380, and is done by S/W in ARMADA 370. the H/W BM support is not yet
implemented, so all devices use the S/W management mode at this time.
 1.1 03-May-2015  hsuenaga add new ethernet driver mvxpe for recent MARVELL's SoC after ARMADA/XP.
this driver supports 'counter mode', and is disabled by default.

ARMADA SoC family has new ethernet controller acceleration mode called
'enhanced mode' or 'counter mode.' it seems that backward compatibility mode
used by if_mvgbe is still working, but the specification of the old mode
is completely disappeared from SoC's reference manual.

I tested the driver using MIRABOX(ARMADA/370).
 1.2.2.3 19-Mar-2016  skrll Sync with HEAD
 1.2.2.2 06-Jun-2015  skrll Sync with HEAD
 1.2.2.1 03-Jun-2015  skrll file if_mvxpevar.h was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.3.18.1 22-Apr-2018  pgoyette Sync with HEAD
 1.3.16.2 03-Dec-2017  jdolecek update from HEAD
 1.3.16.1 13-Feb-2016  jdolecek file if_mvxpevar.h was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.4.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11 09-Jan-2017  kiyohara Add ATTR_AXI_DDR.
 1.10 04-Oct-2016  kiyohara Add 88AP510.
 1.9 03-Jun-2015  hsuenaga branches: 1.9.2;
reduce magic numbers. SDRAM address space attribute register has cache coherency
control bits. this bit is important for AURORA_IO_CACHE_COHERENCY.
 1.8 15-Mar-2014  kiyohara branches: 1.8.6;
Add some Armada 370 IDs.
And fix comment-out-ed ID for Discovery VI. (from Marvell USP)
 1.7 01-May-2013  rkujawa branches: 1.7.4;
Add IDs for Marvell Armada XP and ATTR_SDRAM registers used with IO cache coherency.

Obtained from Marvell, Semihalf.
 1.6 12-Jul-2012  kiyohara branches: 1.6.2;
Add 88f6282.
 1.5 20-Jul-2010  kiyohara branches: 1.5.2; 1.5.10;
Remove some attribute macros. Its specifically for Orion.
 1.4 20-Jul-2010  kiyohara Add macro MARVELL_ORION_1_88F6183.
Add some comments.
Product ID of Discovery V maybe 0x6450.
Product ID of Discovery VI maybe 0x6490.
 1.3 13-Jul-2010  kiyohara Add Kirkwood/Discovery Innovation macros.
 1.2 07-May-2010  kiyohara branches: 1.2.2;
Use macro PCI_PRODUCT_MARVELL_MV64[34]60.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2;
Clean up gt and peripherals.
This change tested compile only.
 1.1.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file marvellreg.h was added on branch uebayasi-xip on 2010-04-30 14:43:28 +0000
 1.2.2.3 05-Mar-2011  rmind sync with head
 1.2.2.2 30-May-2010  rmind sync with head
 1.2.2.1 07-May-2010  rmind file marvellreg.h was added on branch rmind-uvmplock on 2010-05-30 05:17:30 +0000
 1.5.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.5.10.1 30-Oct-2012  yamt sync with head
 1.5.2.2 11-Aug-2010  yamt sync with head.
 1.5.2.1 20-Jul-2010  yamt file marvellreg.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.6.2.3 03-Dec-2017  jdolecek update from HEAD
 1.6.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.1 23-Jun-2013  tls resync from head
 1.7.4.1 18-May-2014  rmind sync with head
 1.8.6.3 05-Feb-2017  skrll Sync with HEAD
 1.8.6.2 05-Dec-2016  skrll Sync with HEAD
 1.8.6.1 06-Jun-2015  skrll Sync with HEAD
 1.9.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.9.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.7 13-Jul-2023  riastradh marvell: Reconcile arm vs powerpc marvell_intr_establish.

If there's a better way to do this without #ifdef __powerpc__, please
have at it!
 1.6 07-Jan-2017  kiyohara branches: 1.6.48;
Add tags for AXI_CS[01].
 1.5 15-Mar-2014  kiyohara branches: 1.5.6; 1.5.10;
Add tags to marvell_attach_args.
 1.4 17-Feb-2014  kiyohara Add MARVELL_TAG_DDR3_CS[0-3] for latest SoC.
 1.3 20-Jul-2010  kiyohara branches: 1.3.2; 1.3.10; 1.3.20; 1.3.24;
Add MARVELL_TAG_MAX to enum marvell_tags.
 1.2 11-Jul-2010  kiyohara Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4;
Clean up gt and peripherals.
This change tested compile only.
 1.1.4.3 05-Mar-2011  rmind sync with head
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file marvellvar.h was added on branch rmind-uvmplock on 2010-05-30 05:17:30 +0000
 1.1.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file marvellvar.h was added on branch uebayasi-xip on 2010-04-30 14:43:28 +0000
 1.3.24.1 18-May-2014  rmind sync with head
 1.3.20.2 03-Dec-2017  jdolecek update from HEAD
 1.3.20.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.10.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.2 11-Aug-2010  yamt sync with head.
 1.3.2.1 20-Jul-2010  yamt file marvellvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.5.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.5.6.1 05-Feb-2017  skrll Sync with HEAD
 1.6.48.1 11-Aug-2023  martin Additionall pull up following revision(s) (requested by riastradh in ticket #316):

sys/dev/marvell/marvellvar.h: revision 1.7
sys/arch/arm/marvell/mvsoc_intr.h: revision 1.9

marvell: Reconcile arm vs powerpc marvell_intr_establish.

If there's a better way to do this without #ifdef __powerpc__, please
have at it!
 1.6 22-May-2022  riastradh opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.
 1.5 22-May-2022  riastradh mvcesa(4): Prune dead branches. Assert session id validity.
 1.4 05-Dec-2021  msaitoh s/decript/decrypt/ in comment.
 1.3 14-Jun-2020  riastradh mvcesa(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.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 27-Jul-2012  kiyohara branches: 1.1.4; 1.1.40; 1.1.42;
Add Marvell CESA(Cryptographic Engines and Security Accelerator) module driver.
But support only PIO-mode now. Also AES-CBC not supported.
Don't know how to process to AES CBC in PIO-mode. I haven't found IV registers.
 1.1.42.1 10-Jun-2019  christos Sync with HEAD
 1.1.40.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.4.2 30-Oct-2012  yamt sync with head
 1.1.4.1 27-Jul-2012  yamt file mvcesa.c was added on branch yamt-pagecache on 2012-10-30 17:21:18 +0000
 1.3 05-Dec-2021  msaitoh s/decript/decrypt/ in comment.
 1.2 28-Sep-2013  kiyohara Change address/size of CESA Registers.
 1.1 27-Jul-2012  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Add Marvell CESA(Cryptographic Engines and Security Accelerator) module driver.
But support only PIO-mode now. Also AES-CBC not supported.
Don't know how to process to AES CBC in PIO-mode. I haven't found IV registers.
 1.1.6.1 18-May-2014  rmind sync with head
 1.1.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.1.4.2 30-Oct-2012  yamt sync with head
 1.1.4.1 27-Jul-2012  yamt file mvcesareg.h was added on branch yamt-pagecache on 2012-10-30 17:21:18 +0000
 1.1.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10 02-Feb-2024  andvar fix various typos in comments.
 1.9 30-Aug-2021  rin Add ARMEB support to mvgbe(4).

For ARMEB, peripheral is configured to little-endian mode, even if
CPU itself is in big-endian mode. Therefore, we need to configure
the device to little-endian mode, and byte-swap descriptor fields
(unlike the case of powerpc).
 1.8 23-Dec-2013  kiyohara Support Basic Mode for Armada XP.
 1.7 08-Nov-2012  msaitoh branches: 1.7.2;
Fix a bug that MVGBE_JLEN is miscalculated.
 1.6 16-Oct-2012  msaitoh Add code to modify interrupt coalescing with sysctl.
- both TX side an RX side.
- different setting for each port
- TX side is hw.mvgbe.mvgbe*.ipginttx
- RX side is hw.mvgbe.mvgbe*.ipgintrx
- The default value is 768.
- The lowest value is 0
- For highest value, 0x3777 is used for V1, and 0xffff is used for V2.
 1.5 12-Oct-2012  msaitoh - The MVGBE_RX_MAX_FRAME_LEN_ERROR bit is used to check whether a packet
is fragmented or not, so define new MVGBE_RX_IP_FRAGMENT with the same
value and use it.
- Remove the checking whether a packet length is lower than 72 octet.
This check is not used in Linux and FreeBSD. Tested with me (for Kirkwood)
and Kiyohara (for DiscoveryII).
 1.4 04-Oct-2012  msaitoh Fix udpcsum-rx bug on fragmented case this time.
- Fix the usage of a local variable for csum_flags.
- It seemd that sometimes MVGBE_RX_L4_CHECKSUM_OK bit were set to 0
even if the checksum is correct and the packet was not fragmented.
So we don't set M_CSUM_TCP_UDP_BAD even if csum bit is 0.
 1.3 01-Feb-2011  jakllsch branches: 1.3.4; 1.3.10; 1.3.14;
Various improvements to mvgbe(4). Notable is improved multicast filtering.
 1.2 02-Oct-2010  kiyohara branches: 1.2.2; 1.2.4;
Support Kirkwood's GbE.
 1.1 02-Jun-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6;
Add Marvell Gigabit Ethernet Controller on SC/SoC.
Will support on ofppc soon.
Tested on G4+PegasosII (kiyohara@)
G3+PegasosII (phx@)
 1.1.6.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.6.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.6.1 02-Jun-2010  uebayasi file mvgbereg.h was added on branch uebayasi-xip on 2010-08-17 06:46:17 +0000
 1.1.4.3 09-Oct-2010  yamt sync with head
 1.1.4.2 11-Aug-2010  yamt sync with head.
 1.1.4.1 02-Jun-2010  yamt file mvgbereg.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.1.2.3 05-Mar-2011  rmind sync with head
 1.1.2.2 03-Jul-2010  rmind sync with head
 1.1.2.1 02-Jun-2010  rmind file mvgbereg.h was added on branch rmind-uvmplock on 2010-07-03 01:19:36 +0000
 1.2.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.2.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.3.10.2 24-Nov-2012  jdc Apply patch from msaitoh to fix pullup-6 #671.
 1.3.10.1 20-Nov-2012  riz Apply patch (requested by msaitoh in ticket #671):

sys/dev/marvell/if_mvgbe.c 1.19-1.23, 1.26-1.31
sys/dev/marvell/mvgbereg.h 1.4-1.5, 1.7

Add missing bus_dmamap_sync() for the RX buffer.
Fix device timeout problem.
Fix broken hardware checksumming.
Fix a bug that kernel panics when the system get a packet while calling
mvgbe_stop (via ifconfig down).
Add missing mii_tick() call.
Change style a bit.
Don't use M_HASFCS flag.
When an interrput is link change, notify link change to mii layer using
mii_pollstat().
Fix a bug that the alignment of jumbo buffer(MVGBE_JLEN) is miscalculated.
 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 16-Jan-2013  yamt sync with (a bit old) head
 1.3.4.1 30-Oct-2012  yamt sync with head
 1.7.2.1 18-May-2014  rmind sync with head
 1.22 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.21 24-Apr-2021  thorpej branches: 1.21.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.20 07-Jul-2020  thorpej branches: 1.20.4;
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.19 14-Jun-2020  chs replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 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 16-Nov-2018  jmcneill Add intr_establish_xname support to arm and expose it to intrctl
 1.16 27-Nov-2015  nonaka branches: 1.16.16; 1.16.18;
Use device name instead of fixed string "mvpex" for evcnt group.
 1.15 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.14 28-Jul-2015  knakahara fix: panic at doing "vmstat -ev" after a PCIe device detached.
 1.13 24-Jun-2015  knakahara fix: pexih->ih_evcnt->ev_name pointed stack address wrongly.
 1.12 30-Mar-2014  christos branches: 1.12.6;
provide a buffer for pci_intr_string()
 1.11 30-Mar-2014  htodd Fix typo.
 1.10 30-Mar-2014  christos catch up with pci_intr_string changes
 1.9 15-Mar-2014  kiyohara Support Armada 370 and DDR3 tags.
 1.8 01-May-2013  rkujawa branches: 1.8.4;
Avoid configuring root complex on MV78460.

Obtained from Marvell, Semihalf.
 1.7 07-Sep-2012  matt branches: 1.7.2;
Fix pci_conf_hook/interrupt for ARM.
 1.6 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.5 17-May-2011  dyoung branches: 1.5.4; 1.5.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.4 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.3 23-Jan-2011  jakllsch branches: 1.3.2;
Explicitly initialize sometimes-unused variable.
 1.2 01-Aug-2010  kiyohara branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.1 13-Jul-2010  kiyohara Add UART and PCIe controller for Marvell SoC.
However not define attribute *_mbus in our tree yet.
 1.2.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.2.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.4.1 01-Aug-2010  uebayasi file mvpex.c was added on branch uebayasi-xip on 2010-08-17 06:46:18 +0000
 1.2.2.2 11-Aug-2010  yamt sync with head.
 1.2.2.1 01-Aug-2010  yamt file mvpex.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.3.2.4 31-May-2011  rmind sync with head
 1.3.2.3 21-Apr-2011  rmind sync with head
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 23-Jan-2011  rmind file mvpex.c was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 1.5.8.1 18-Feb-2012  mrg merge to -current.
 1.5.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.5.4.2 30-Oct-2012  yamt sync with head
 1.5.4.1 17-Apr-2012  yamt 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 23-Jun-2013  tls resync from head
 1.8.4.1 18-May-2014  rmind sync with head
 1.12.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.12.6.1 22-Sep-2015  skrll Sync with HEAD
 1.16.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.16.18.1 10-Jun-2019  christos Sync with HEAD
 1.16.16.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.20.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.21.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 27-Dec-2019  msaitoh s/expresion/expression/ in comment.
 1.2 08-Aug-2015  kiyohara branches: 1.2.18;
Fix calculate to address for window register.
Thanks knakahara@.
 1.1 13-Jul-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.10; 1.1.24; 1.1.42;
Add UART and PCIe controller for Marvell SoC.
However not define attribute *_mbus in our tree yet.
 1.1.42.1 22-Sep-2015  skrll Sync with HEAD
 1.1.24.1 03-Dec-2017  jdolecek update from HEAD
 1.1.10.2 05-Mar-2011  rmind sync with head
 1.1.10.1 13-Jul-2010  rmind file mvpexreg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 1.1.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.4.1 13-Jul-2010  uebayasi file mvpexreg.h was added on branch uebayasi-xip on 2010-08-17 06:46:18 +0000
 1.1.2.2 11-Aug-2010  yamt sync with head.
 1.1.2.1 13-Jul-2010  yamt file mvpexreg.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.2.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7 16-Nov-2018  jmcneill Add intr_establish_xname support to arm and expose it to intrctl
 1.6 24-Jun-2015  knakahara branches: 1.6.16; 1.6.18;
fix: pexih->ih_evcnt->ev_name pointed stack address wrongly.
 1.5 30-Mar-2014  christos branches: 1.5.6;
catch up with pci_intr_string changes
 1.4 15-Mar-2014  kiyohara Support Armada 370 and DDR3 tags.
 1.3 07-Sep-2012  matt branches: 1.3.2; 1.3.4;
Fix pci_conf_hook/interrupt for ARM.
 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 13-Jul-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10;
Add UART and PCIe controller for Marvell SoC.
However not define attribute *_mbus in our tree yet.
 1.1.10.3 21-Apr-2011  rmind sync with head
 1.1.10.2 05-Mar-2011  rmind sync with head
 1.1.10.1 13-Jul-2010  rmind file mvpexvar.h was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 1.1.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.4.1 13-Jul-2010  uebayasi file mvpexvar.h was added on branch uebayasi-xip on 2010-08-17 06:46:18 +0000
 1.1.2.2 11-Aug-2010  yamt sync with head.
 1.1.2.1 13-Jul-2010  yamt file mvpexvar.h was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 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.3.4.1 18-May-2014  rmind sync with head
 1.3.2.2 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.6.1 22-Sep-2015  skrll Sync with HEAD
 1.6.18.1 10-Jun-2019  christos Sync with HEAD
 1.6.16.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.8 07-Jan-2017  kiyohara Support Marvell Dove.
 1.7 15-Mar-2014  kiyohara branches: 1.7.6; 1.7.10;
Support Armada 370 and DDR3 tags.
 1.6 28-Sep-2013  kiyohara Add ARMADAXP MV78{13,16,23,26}0.
 1.5 01-May-2013  rkujawa branches: 1.5.4;
Support SATA on Marvell Armada XP.

Obtained from Marvell, Semihalf.
 1.4 18-Jul-2012  kiyohara branches: 1.4.2;
Add 88F6282. tested only OpenBlockS A6.
 1.3 30-Oct-2010  kiyohara branches: 1.3.6; 1.3.10;
Enable product MV78100/MV78200.
 1.2 01-Aug-2010  kiyohara branches: 1.2.2; 1.2.4;
Cleanup foo_match().
+ Remove check for model.
+ Remove unnecessary null line.
 1.1 13-Jul-2010  kiyohara Add SATA for Marvell SC/SoC.
 1.2.4.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.2.4.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.4.1 01-Aug-2010  uebayasi file mvsata_mv.c was added on branch uebayasi-xip on 2010-08-17 06:46:18 +0000
 1.2.2.2 11-Aug-2010  yamt sync with head.
 1.2.2.1 01-Aug-2010  yamt file mvsata_mv.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.3.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.3.10.1 30-Oct-2012  yamt sync with head
 1.3.6.2 05-Mar-2011  rmind sync with head
 1.3.6.1 30-Oct-2010  rmind file mvsata_mv.c was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 1.4.2.3 03-Dec-2017  jdolecek update from HEAD
 1.4.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.2.1 23-Jun-2013  tls resync from head
 1.5.4.1 18-May-2014  rmind sync with head
 1.7.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.7.6.1 05-Feb-2017  skrll Sync with HEAD
 1.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 24-Apr-2021  thorpej branches: 1.7.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.6 03-Mar-2017  jakllsch branches: 1.6.30;
Add check during mvsdio_attach that CMD line is in idle state.

If the CMD line is not in idle state, the interrupt handler routine will
misbehave causing an endless interrupt handler loop. This would prevent
the the kernel from getting to mountroot.

On my Pogoplug POGO-V4-A3-01, this was caused by U-Boot routing com1's TX
and RX signals to the SD card slot's CMD and DAT[0] lines respectively.

We should probably grow Marvell SoC MPP (pinmux) configuration frobs.
 1.5 15-Mar-2014  kiyohara branches: 1.5.6; 1.5.10; 1.5.14;
Support Armada 370 and DDR3 tags.
 1.4 13-Feb-2011  nonaka branches: 1.4.2; 1.4.6; 1.4.16; 1.4.20;
- Don't switch MMC high-speed timing, if host controller isn't supported.
- Only check EXT_CSD STRUCTURE version when CSD version is 3.
- initialize width at sdmmc_function_alloc().
 1.3 05-Feb-2011  nonaka Don't switch SD high-speed timing, if host controller isn't supported.
 1.2 08-Oct-2010  kiyohara branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Add more explanation to XXXX. It value from Marvell LSP.
 1.1 23-Sep-2010  kiyohara Add Marvell Secure Digital Input/Output (SDIO) Interface Driver.
 1.2.8.2 17-Feb-2011  bouyer Sync with HEAD
 1.2.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.2.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.2.4.1 08-Oct-2010  uebayasi file mvsdio.c was added on branch uebayasi-xip on 2010-10-22 07:22:01 +0000
 1.2.2.2 09-Oct-2010  yamt sync with head
 1.2.2.1 08-Oct-2010  yamt file mvsdio.c was added on branch yamt-nfs-mp on 2010-10-09 03:32:08 +0000
 1.4.20.1 18-May-2014  rmind sync with head
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.6.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.4.2.2 05-Mar-2011  rmind sync with head
 1.4.2.1 13-Feb-2011  rmind file mvsdio.c was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 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 28-Aug-2017  skrll Sync with HEAD
 1.6.30.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.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 12-Mar-2016  jklos Add kernel configuration file for PogoPlug Pink, PogoPlug Mobile and
PogoPlug v4. Add conditional because PogoPlug v4 can't run SD interface at
50 MHz.
 1.1 23-Sep-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.10; 1.1.24; 1.1.42;
Add Marvell Secure Digital Input/Output (SDIO) Interface Driver.
 1.1.42.1 19-Mar-2016  skrll Sync with HEAD
 1.1.24.1 03-Dec-2017  jdolecek update from HEAD
 1.1.10.2 05-Mar-2011  rmind sync with head
 1.1.10.1 23-Sep-2010  rmind file mvsdioreg.h was added on branch rmind-uvmplock on 2011-03-05 20:53:26 +0000
 1.1.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.4.1 23-Sep-2010  uebayasi file mvsdioreg.h was added on branch uebayasi-xip on 2010-10-22 07:22:03 +0000
 1.1.2.2 09-Oct-2010  yamt sync with head
 1.1.2.1 23-Sep-2010  yamt file mvsdioreg.h was added on branch yamt-nfs-mp on 2010-10-09 03:32:08 +0000
 1.10 10-Sep-2025  thorpej Encapsulate what's needed to attach a SPI bus into a spibus_attach()
inline.
 1.9 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.8 12-Feb-2022  riastradh sys: Omit vestigial struct devices in softcs after device_t split.
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.2; 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 13-Aug-2019  tnn branches: 1.5.10;
ensure spibus_attach_args is zero'ed
 1.4 09-Oct-2016  christos branches: 1.4.16;
PR/51540: Henning Petersen: replace , with ;
 1.3 13-Dec-2015  christos branches: 1.3.2;
PR/50533: David Binderman: Fix incorrect logic
 1.2 06-May-2013  khorben branches: 1.2.4; 1.2.12; 1.2.16;
Removed an unused variable.

"go ahead" rkujawa@
 1.1 01-May-2013  rkujawa Add support for Marvell's SPI controller as found on Armada XP.

Obtained from Semihalf.
 1.2.16.2 05-Dec-2016  skrll Sync with HEAD
 1.2.16.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.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.2.12.1 06-May-2013  yamt file mvspi.c was added on branch yamt-pagecache on 2014-05-22 11:40:23 +0000
 1.2.4.3 03-Dec-2017  jdolecek update from HEAD
 1.2.4.2 23-Jun-2013  tls resync from head
 1.2.4.1 06-May-2013  tls file mvspi.c was added on branch tls-maxphys on 2013-06-23 06:20:17 +0000
 1.3.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.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.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6.2.1 18-May-2021  thorpej Pass the controller devhandle along to the "spi" instance.
 1.3 07-Jan-2017  kiyohara Change MVSPI_SIZE to 0x80 instead of 0x50.
 1.2 13-May-2013  christos branches: 1.2.2; 1.2.10; 1.2.14; 1.2.18;
There is no opt_mvsoc.h; the #ifdef ARMADAXP should be changed to some
inherited device property.
 1.1 01-May-2013  rkujawa Add support for Marvell's SPI controller as found on Armada XP.

Obtained from Semihalf.
 1.2.18.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2.14.1 05-Feb-2017  skrll Sync with HEAD
 1.2.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.2.10.1 13-May-2013  yamt file mvspireg.h was added on branch yamt-pagecache on 2014-05-22 11:40:23 +0000
 1.2.2.3 03-Dec-2017  jdolecek update from HEAD
 1.2.2.2 23-Jun-2013  tls resync from head
 1.2.2.1 13-May-2013  tls file mvspireg.h was added on branch tls-maxphys on 2013-06-23 06:20:18 +0000
 1.4 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.3 05-Dec-2021  msaitoh s/initialz/initializ/ in comment.
 1.2 07-May-2018  maxv Fix double-free, m_tag_delete_chain is already called by m_free.
 1.1 03-Jun-2015  hsuenaga branches: 1.1.2; 1.1.18; 1.1.20;
separate buffer management codes 'mvxpbm.c' from if_mvxpe.c.

the buffer management(ex. fill the rx descriptors/buffers) is done by H/W in
ARMADA XP/380, and is done by S/W in ARMADA 370. the H/W BM support is not yet
implemented, so all devices use the S/W management mode at this time.
 1.1.20.1 21-May-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Jun-2015  jdolecek file mvxpbm.c was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-Jun-2015  skrll file mvxpbm.c was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.4 13-Mar-2022  andvar s/hander/handler/ and s/hader/header/ in comments and documentation.
 1.3 11-Sep-2021  andvar sysinst/partitions.h: fix typos comments, also fix same typos in other files.
 1.2 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.1 03-Jun-2015  hsuenaga branches: 1.1.2; 1.1.18;
separate buffer management codes 'mvxpbm.c' from if_mvxpe.c.

the buffer management(ex. fill the rx descriptors/buffers) is done by H/W in
ARMADA XP/380, and is done by S/W in ARMADA 370. the H/W BM support is not yet
implemented, so all devices use the S/W management mode at this time.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Jun-2015  jdolecek file mvxpbmvar.h was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-Jun-2015  skrll file mvxpbmvar.h was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.20 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.19 28-May-2023  andvar s/sessoin/session/ in warning message.
 1.18 31-Dec-2022  andvar fix few typos in comments.
 1.17 08-Jul-2022  skrll alredy -> already
 1.16 01-Jun-2022  riastradh mvxpsec(4): Fix missing change to freesession return type.

Not sure how this didn't get committed before -- it was supposed to be
part of this change:

https://mail-index.netbsd.org/source-changes/2022/05/22/msg138764.html
 1.15 22-May-2022  riastradh mvxpsec(4): Prune dead branches. Assert session id validity.
 1.14 12-Apr-2022  andvar s/sould/should/ and s/shoud/should/
 1.13 09-Apr-2022  riastradh sys: Use membar_release/acquire around reference drop.

This just goes through my recent reference count membar audit and
changes membar_exit to membar_release and membar_enter to
membar_acquire -- this should make everything cheaper on most CPUs
without hurting correctness, because membar_acquire is generally
cheaper than membar_enter.
 1.12 06-Apr-2022  riastradh mvxpsec(4): Nix trailing whitespace.
 1.11 12-Mar-2022  riastradh sys: Membar audit around reference count releases.

If two threads are using an object that is freed when the reference
count goes to zero, we need to ensure that all memory operations
related to the object happen before freeing the object.

Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one
thread takes responsibility for freeing, but it's not enough to
ensure that the other thread's memory operations happen before the
freeing.

Consider:

Thread A Thread B
obj->foo = 42; obj->baz = 73;
mumble(&obj->bar); grumble(&obj->quux);
/* membar_exit(); */ /* membar_exit(); */
atomic_dec -- not last atomic_dec -- last
/* membar_enter(); */
KASSERT(invariant(obj->foo,
obj->bar));
free_stuff(obj);

The memory barriers ensure that

obj->foo = 42;
mumble(&obj->bar);

in thread A happens before

KASSERT(invariant(obj->foo, obj->bar));
free_stuff(obj);

in thread B. Without them, this ordering is not guaranteed.

So in general it is necessary to do

membar_exit();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_enter();

to release a reference, for the `last one out hit the lights' style
of reference counting. (This is in contrast to the style where one
thread blocks new references and then waits under a lock for existing
ones to drain with a condvar -- no membar needed thanks to mutex(9).)

I searched for atomic_dec to find all these. Obviously we ought to
have a better abstraction for this because there's so much copypasta.
This is a stop-gap measure to fix actual bugs until we have that. It
would be nice if an abstraction could gracefully handle the different
styles of reference counting in use -- some years ago I drafted an
API for this, but making it cover everything got a little out of hand
(particularly with struct vnode::v_usecount) and I ended up setting
it aside to work on psref/localcount instead for better scalability.

I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I
only put it on things that look performance-critical on 5sec review.
We should really adopt membar_enter_preatomic/membar_exit_postatomic
or something (except they are applicable only to atomic r/m/w, not to
atomic_load/store_*, making the naming annoying) and get rid of all
the ifdefs.
 1.10 12-Feb-2022  riastradh sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.
 1.9 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.8 13-Aug-2021  andvar s/struture/structure/ s/structre/structure/
 1.7 25-Jul-2020  riastradh Make this build with or without options IPSEC.

Not really that useful without options IPSEC, but simply uncommenting
mvxpsec in conf/ARMADAXP didn't build, and this change is trivial, so
why not.
 1.6 25-Jul-2020  riastradh Omit needless rijndael dependencies.
 1.5 27-Dec-2019  msaitoh s/transfered/transferred/
 1.4 27-Dec-2019  msaitoh s/opration/operation/
 1.3 15-Oct-2019  chs convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures.
 1.2 09-Nov-2017  christos branches: 1.2.2; 1.2.6;
use PR_NOWAIT instead of 0
 1.1 03-Jun-2015  hsuenaga branches: 1.1.2; 1.1.12;
add new cryptographic accelerator driver 'mvxpsec.'

this driver controls CESA unit as same as mvcesa, but uses DMA engines and
does CBC operations, HMAC operations by hardware. about 2 kbytes of data
are processed at one. supported algorithms are:

- DES-CBC, 3DES-CBC, AES-CBC
- HMAC-SHA1, HMAC-MD5

non-CBC algorithm such as AES-GCM is not supported by CESA's acceleration
engine. mvcesa is still useful to implement such algorithms as combination of
accelerated block cipher and software chaining.
 1.1.12.1 27-Feb-2018  martin Pull up following revision(s) (requested by mrg in ticket #593):
sys/dev/marvell/mvxpsec.c: revision 1.2
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.70
sys/opencrypto/crypto.c: revision 1.102
sys/arch/sparc64/sparc64/pmap.c: revision 1.308
sys/ufs/chfs/chfs_malloc.c: revision 1.5
sys/arch/powerpc/oea/pmap.c: revision 1.95
sys/sys/pool.h: revision 1.80,1.82
sys/kern/subr_pool.c: revision 1.209-1.216,1.219-1.220
sys/arch/alpha/alpha/pmap.c: revision 1.262
sys/kern/uipc_mbuf.c: revision 1.173
sys/uvm/uvm_fault.c: revision 1.202
sys/sys/mbuf.h: revision 1.172
sys/kern/subr_extent.c: revision 1.86
sys/arch/x86/x86/pmap.c: revision 1.266 (via patch)
sys/dev/dtv/dtv_scatter.c: revision 1.4

Allow only one pending call to a pool's backing allocator at a time.
Candidate fix for problems with hanging after kva fragmentation related
to PR kern/45718.

Proposed on tech-kern:
https://mail-index.NetBSD.org/tech-kern/2017/10/23/msg022472.html
Tested by bouyer@ on i386.

This makes one small change to the semantics of pool_prime and
pool_setlowat: they may fail with EWOULDBLOCK instead of ENOMEM, if
there is a pending call to the backing allocator in another thread but
we are not actually out of memory. That is unlikely because nearly
always these are used during initialization, when the pool is not in
use.

Define the new flag too for previous commit.

pool_grow can now fail even when sleeping is ok. Catch this case in pool_get
and retry.

Assert that pool_get failure happens only with PR_NOWAIT.
This would have caught the mistake I made last week leading to null
pointer dereferences all over the place, a mistake which I evidently
poorly scheduled alongside maxv's change to the panic message on x86
for null pointer dereferences.

Since pr_lock is now used to wait for two things now (PR_GROWING and
PR_WANTED) we need to loop for the condition we wanted.
make the KASSERTMSG/panic strings consistent as '%s: [%s], __func__, wchan'
Handle the ERESTART case from pool_grow()

don't pass 0 to the pool flags
Guess pool_cache_get(pc, 0) means PR_WAITOK here.
Earlier on in the same context we use kmem_alloc(sz, KM_SLEEP).

use PR_WAITOK everywhere.
use PR_NOWAIT.

Don't use 0 for PR_NOWAIT

use PR_NOWAIT instead of 0

panic ex nihilo -- PR_NOWAITing for zerot

Add assertions that either PR_WAITOK or PR_NOWAIT are set.
- fix an assert; we can reach there if we are nowait or limitfail.
- when priming the pool and failing with ERESTART, don't decrement the number
of pages; this avoids the issue of returning an ERESTART when we get to 0,
and is more correct.
- simplify the pool_grow code, and don't wakeup things if we ENOMEM.

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. This implements the requirement that
pmap_enter(PMAP_CANFAIL) must not fail when replacing an existing
mapping with the first mapping of a new page, which is an unintended
consequence of the changes from the rmind-uvmplock branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706, as well as the failing assertion
about "uvm_page_locked_p(old_pg)". (but only on x86, various other platforms
will need their own changes to handle this issue.)
In uvm_fault_upper_enter(), if pmap_enter(PMAP_CANFAIL) fails, assert that
the pmap did not leave around a now-stale pmap mapping for an old page.
If such a pmap mapping still existed after we unlocked the vm_map,
the UVM code would not know later that it would need to lock the
lower layer object while calling the pmap to remove or replace that
stale pmap mapping. See PR 52706 for further details.
hopefully workaround the irregularly "fork fails in init" problem.
if a pool is growing, and the grower is PR_NOWAIT, mark this.
if another caller wants to grow the pool and is also PR_NOWAIT,
busy-wait for the original caller, which should either succeed
or hard-fail fairly quickly.

implement the busy-wait by unlocking and relocking this pools
mutex and returning ERESTART. other methods (such as having
the caller do this) were significantly more code and this hack
is fairly localised.
ok chs@ riastradh@

Don't release the lock in the PR_NOWAIT allocation. Move flags setting
after the acquiring the mutex. (from Tobias Nygren)
apply the change from arch/x86/x86/pmap.c rev. 1.266 commitid vZRjvmxG7YTHLOfA:

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. If we are replacing an existing mapping,
reuse the pv structure where possible.

This implements the requirement that pmap_enter(PMAP_CANFAIL) must not fail
when replacing an existing mapping with the first mapping of a new page,
which is an unintended consequence of the changes from the rmind-uvmplock
branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706 on the remaining platforms where
this problem existed.
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-Jun-2015  skrll file mvxpsec.c was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.2.6.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.6.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 09-Nov-2017  jdolecek file mvxpsec.c was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.1 03-Jun-2015  hsuenaga branches: 1.1.2; 1.1.18;
add new cryptographic accelerator driver 'mvxpsec.'

this driver controls CESA unit as same as mvcesa, but uses DMA engines and
does CBC operations, HMAC operations by hardware. about 2 kbytes of data
are processed at one. supported algorithms are:

- DES-CBC, 3DES-CBC, AES-CBC
- HMAC-SHA1, HMAC-MD5

non-CBC algorithm such as AES-GCM is not supported by CESA's acceleration
engine. mvcesa is still useful to implement such algorithms as combination of
accelerated block cipher and software chaining.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Jun-2015  jdolecek file mvxpsecreg.h was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-Jun-2015  skrll file mvxpsecreg.h was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 1.4 02-Jun-2024  andvar fix various typos in word `interrupt', mainly in comments.
 1.3 22-May-2022  riastradh opencrypto: Make freesession callback return void.

No functional change intended: all drivers already return zero
unconditionally.
 1.2 27-Dec-2019  msaitoh s/transfered/transferred/
 1.1 03-Jun-2015  hsuenaga branches: 1.1.2; 1.1.18; 1.1.22;
add new cryptographic accelerator driver 'mvxpsec.'

this driver controls CESA unit as same as mvcesa, but uses DMA engines and
does CBC operations, HMAC operations by hardware. about 2 kbytes of data
are processed at one. supported algorithms are:

- DES-CBC, 3DES-CBC, AES-CBC
- HMAC-SHA1, HMAC-MD5

non-CBC algorithm such as AES-GCM is not supported by CESA's acceleration
engine. mvcesa is still useful to implement such algorithms as combination of
accelerated block cipher and software chaining.
 1.1.22.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Jun-2015  jdolecek file mvxpsecvar.h was added on branch tls-maxphys on 2017-12-03 11:37:05 +0000
 1.1.2.2 06-Jun-2015  skrll Sync with HEAD
 1.1.2.1 03-Jun-2015  skrll file mvxpsecvar.h was added on branch nick-nhusb on 2015-06-06 14:40:08 +0000
 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 11-Jul-2010  kiyohara branches: 1.15.76;
Add macro MVA_{UNIT,OFFSET,IRQ}_DEFAULT.
 1.14 02-Jun-2010  kiyohara Remove unused header-file.
 1.13 28-Apr-2010  kiyohara Clean up gt and peripherals.
This change tested compile only.
 1.12 12-May-2009  cegger branches: 1.12.2; 1.12.4;
struct device * -> device_t, no functional changes intended.
 1.11 12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.10 19-Oct-2007  ad branches: 1.10.20; 1.10.34;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.9 29-Jan-2007  hubertf branches: 1.9.6; 1.9.18; 1.9.20; 1.9.24;
Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.8 29-Mar-2006  thorpej branches: 1.8.8;
Use device_private().
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.6; 1.7.8; 1.7.10; 1.7.12;
merge ktrace-lwp.
 1.6 26-Aug-2005  drochner s/locdesc_t/int/g
 1.5 13-Sep-2004  drochner branches: 1.5.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.4 08-Sep-2004  drochner use interface attribute / locator passing versions
of config_search()
 1.3 14-Jul-2003  lukem add missing __KERNEL_RCSID()
 1.2 27-Mar-2003  matt branches: 1.2.2;
Only print IRQ is it's not the default value.
 1.1 16-Mar-2003  matt Add obio attachment for things like rtcs, com, and flash.
 1.2.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.5.12.3 27-Oct-2007  yamt sync with head.
 1.5.12.2 26-Feb-2007  yamt sync with head.
 1.5.12.1 21-Jun-2006  yamt sync with head.
 1.7.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.7.10.1 19-Apr-2006  elad sync with head.
 1.7.8.1 01-Apr-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.8.8.1 01-Feb-2007  ad Sync with head.
 1.9.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.9.20.1 06-Nov-2007  matt sync with HEAD
 1.9.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.9.6.1 23-Oct-2007  ad Sync with head.
 1.10.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.20.2 11-Aug-2010  yamt sync with head.
 1.10.20.1 16-May-2009  yamt sync with head
 1.12.4.3 05-Mar-2011  rmind sync with head
 1.12.4.2 03-Jul-2010  rmind sync with head
 1.12.4.1 30-May-2010  rmind sync with head
 1.12.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.12.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.15.76.6 05-Apr-2021  thorpej Treat config_probe() as if it were a boolean function; don't compare
return value > 0... except for the odd balls, which are now really easy
to spot.
 1.15.76.5 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.15.76.4 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.15.76.3 03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.15.76.2 21-Mar-2021  thorpej CFARG_IATTR usage audit:

If a device carries only one interface attribute, there is no need
to specify it when calling config_search(); that specification is
meant only to disambiguate which interface attribute (which is a
proxy for "what kind of attach args are being used") is having
children attached. cfparent_match() will take care of ensuring that
any potential children can attach to one of the parent's iterface
attributes, and if the parent only carries one, no disambiguation is
necessary.
 1.15.76.1 20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.16.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 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.1 28-Apr-2010  kiyohara branches: 1.1.2; 1.1.4; 1.1.6; 1.1.14; 1.1.24;
Clean up gt and peripherals.
This change tested compile only.
 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 11-Aug-2010  yamt sync with head.
 1.1.6.1 28-Apr-2010  yamt file pchb.c was added on branch yamt-nfs-mp on 2010-08-11 22:53:38 +0000
 1.1.4.2 30-May-2010  rmind sync with head
 1.1.4.1 28-Apr-2010  rmind file pchb.c was added on branch rmind-uvmplock on 2010-05-30 05:17:30 +0000
 1.1.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.2.1 28-Apr-2010  uebayasi file pchb.c was added on branch uebayasi-xip on 2010-04-30 14:43:28 +0000

RSS XML Feed