History log of /haiku/src/libs/compat/freebsd_network/driver.c
Revision Date Author Comments
# d621ee65 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Move up Giant ownership during attach.

device_attach can be recursed for MIIbus drivers, so avoid the complexity
and lock Giant from init_drivers() instead.


# 423ee7c6 24-Feb-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Adjust and rewrite attach code for USB support.

init_hardware now takes 2 devices arrays: one for PCI and one for USB
drivers, respectively.

The few drivers that have their own __haiku_handle_fbsd_drivers_list
are also adjusted at the same time.


# a8523a21 24-Feb-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: PCI handling cleanup in preparation for USB support.

Should not have any functional change.


# 26b95c15 22-Nov-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Completely overhaul bus_dma implementation.

The old implementation was based on an ancient copy of the FreeBSD
busdma code for x86, and did not make a bunch of assumptions that
we make basically everywhere else (for instance, that we can request
arbitrarily-aligned contiguous physical memory from the VM.)

As a consequence, it had a significant amount of code devoted to
bounce pages, which are just a waste of resources on x86, and
for that matter, probably any other architecture Haiku will ever
be ported to. (Even if we do need to run on some system where
only a small portion of system memory can be accessed by devices,
likely we would reserve that memory for just this occasion anyway.)

I was initially under the impression that the bounce-pages code
never turned on, but apparently due to the "alignment" check
(and also the "Maxmem" check, which was to defined to 32KB...?!)
it does indeed activate on a variety of systems, and maybe
(in the case of drivers that do not call sync() properly) even
is the cause of some of our ported driver breakage.

The new implementation is pretty much optimized for Haiku,
and shares almost no code or structure with the old one (save
for a few functions that really only have one proper implementation.)

Tested with ipro1000 and rtl81xx. Regressions are more than possible,
so please don't hesitate to file bugs if your network driver now
fails to come up (or you get KDLs.)


# d906fe3c 20-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Allocate a new root device for every attach.

This also means that when attach fails, we destroy the root device.
This should fix stale root devices getting left around when attach
fails.

Probably helps with or even outright fixes #15016.


# 3001575d 08-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Add child drivers directly rather than finding symbols.

This method is much less error-prone than the prior one, as that required
the driver structure to have an exported symbol identical to its "name"
field, a fact that is usually true but not always (we've had an ifdef
in the atheroswifi driver for a while now due to this.)

So when we have it, we now just use the driver_t* directly, which
should push any of these problems from the run-time stage to the
compile-time stage. It's also a significant performance
improvement.


# 8e67fd0b 07-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Unreserve the PCI device on error or driver removal.


# db4f8332 03-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Reinstate _fbsd_init_hardware and refactor probing.

Previously we just probed and then immediately attached if any devices
were found, after all initialization was done. Now we cannot do that,
as after calling SYSINIT() on certain drivers (e.g. the new ipro1000
driver), certain threads will be created that there is no good way
of tearing down.

Fortunately, it is valid to call probe() on a device before SYSINIT()
(and most other things) have been initialized, and so now we do that
in init_hardware, and then init_driver is called only if we've found
devices we support.

While we're at it, also call pci->reserve_device, which will mark us as
the driver handling said device and prevent other drivers from
using it.


# da60a673 01-Jan-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Implement SYSINIT.

Based on the already-existing linkersets framework, which seems to
work pretty well for the atheroswifi driver, so it should work for
this case also.


# dba28784 24-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

freebsd11_network -> freebsd_network.

FreeBSD 12 has no major changes to the ifnet KPIs that constitute a
source compatibility break, save a single one related to locking
which doesn't really apply to us, and so we don't need to create
a "freebsd12_network" directory to work through the upgrades.


# fc3b9496 15-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

freebsd_network: probes each driver and only attach the best probe.

* related bug #10088.


# d61f592d 29-Sep-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

freebsd_network(): call uninit_hard_clock() on uninit

Not uninstalling the timer hook could lead to a crash after unloading/
reloading the driver.


# 8f5dbad6 31-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

FreeBSD compat layer: root->softc needs to be zeroed, not root.


# d66a9a60 31-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

FreeBSD compat layer: init the struct root_device_softc.

Should help to fix things for devices without MSI or with MSI-X.


# 283db26d 20-Aug-2011 Siarzhuk Zharski <zharik@gmx.li>

* FreeBSD compatibility layer for network drivers is modified to handle
NULL-terminated list of driver_t* entries instead of single entry.
That allows to combine multiple FreeBSD drivers into single Haiku
driver add-ons;
* Support for DEC 21140 (Tulip) chipsets (provided by the 'de' driver)
incorporated into dec21xxx driver. That brings network connectivity to
Haiku systems running in MS Virtual PC VMs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e7c3a8ff 19-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

Fixed a few regressions that were introduced during the last months:
* device_attach() must not load the network stack. Besides being completely
unbalanced, this was also one reason why the stack could not be unloaded
anymore. Instead, it's now done in compat_open(), as before.
* This also fixes network booting from FreeBSD drivers - the stack apparently
could not be initialized that early.
* Replaced the previous network stack based callout implementation with one
that mostly copies its functionality, but has no dependencies. Furthermore,
it runs at a higher priority (the one of the network timer should also be
revisited, though).
* Fixed mtx_owned() to work without KDEBUG as well. It's not a good idea to
introduce code that behaves completely different based on debug settings.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37580 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b5b2e04 13-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Implement MSI support using the x86 specific PCI module in the FreeBSD
compatibility layer. This should make some network and wireless hardware use
MSIs and therefore solve issues related to interrupt sharing and wrongly
advertised interrupt lines.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36225 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0a05bd20 03-Dec-2009 Colin Günther <coling@gmx.de>

Removing superflous functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34463 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2406849d 27-Oct-2009 Colin Günther <coling@gmx.de>

* Coding style fixes regarding whitespace usage.
* Copyright style fixes.
* Implemented FreeBSD hardclock subsystem, which is needed to update the ticks
variable. The previous usage of "#define ticks system_time()" wasn't
sufficient anymore, as there are drivers using the ticks name for local
scoped variables.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33785 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 14627e08 22-Oct-2009 Colin Günther <coling@gmx.de>

* reordering of headerfile inclusion to comply to FreeBSD 8
ordering.
this makes porting driver (especially wifi ones) more
convinient
* based on FreeBSD svn revision 196691

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33739 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30710739 29-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* compat_open() still needs to get the stack module, as the callout
functionality needs it.
* callout_init_mtx() now initializes the timer manually, since the stack
might not have been loaded yet (since a device is now attached in
init_driver()).
* Minor other fixes; the FreeBSD compatibility layer should now be functional
again.
* Accidently put pci.c into the repository, but that was never meant to happen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23026 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 053693ef 30-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Since device_add_child() needs the name of the parent driver, the root
device needs a driver_t object, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23025 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 080b265a 29-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Completely renovated the FreeBSD compatibility layer:
* Removed NETDEV() and DEVNET() macros and functionality.
* The exported devices are now attached to ifnet objects only, therefore, the
ifnet object now has the receive queue, and everything else a device could
need.
* There is now a root device where everything else is attached, it currently
only holds the pci_info structure, so it's more or less a PCI child.
* This simplified the device handling a bit everywhere.
* We now attach drivers already in init_driver() - this is needed as drivers
may publish more than one interface when being attached.
* Implemented device_delete_child(), device_attach() (which bus_generic_attach()
now uses), device_is_attached(), and device_is_alive().
* Therefore, if_initname() does now the actual job of registering the devices.
* On open, if_init() is called which comes pretty close to what our open()
is supposed to do.
* Updated ukphy.c to the one from FreeBSD 7 where used (we should probably
move that into the compat layer, anyway).
* The MII driver array must now be NULL terminated; therefore you don't need
to specify the count anymore.
* Moved PCI code from compat.c to bus.c.
* Moved the driver code from device.c to driver.c.
* Removed superfluous init_compat_layer() function.
* Fixed a few bugs, a few things weren't brought down correctly.
* The rtl8139 interrupt routine now checks if it really was the cause of the
interrupt - this code is not tested, either, it may not work (which would
then require a work-around like I did for the 3com driver).
* The HAIKU_PROTECT_INTR_REGISTER in the rtl8139 driver was pretty much useless
which is why I removed it.
* Probably introduced a lot of new bugs, though - I haven't tested this code
at all yet. It will probably just crash :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23019 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc3b9496eb2a64bf81d3abfbd551caa2e6866a2f 15-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

freebsd_network: probes each driver and only attach the best probe.

* related bug #10088.


# d61f592d9b3bdff75a45ab00e2a73ef6f717e953 29-Sep-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

freebsd_network(): call uninit_hard_clock() on uninit

Not uninstalling the timer hook could lead to a crash after unloading/
reloading the driver.


# 8f5dbad65b94e43276ad42019684fad1885a9fda 31-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

FreeBSD compat layer: root->softc needs to be zeroed, not root.


# d66a9a607266befbb2e496dd23df0690ba9e64cd 31-Jul-2013 Jerome Duval <jerome.duval@gmail.com>

FreeBSD compat layer: init the struct root_device_softc.

Should help to fix things for devices without MSI or with MSI-X.


# 283db26d5c13815ee18d3b4a9a51789db2fa98d2 20-Aug-2011 Siarzhuk Zharski <zharik@gmx.li>

* FreeBSD compatibility layer for network drivers is modified to handle
NULL-terminated list of driver_t* entries instead of single entry.
That allows to combine multiple FreeBSD drivers into single Haiku
driver add-ons;
* Support for DEC 21140 (Tulip) chipsets (provided by the 'de' driver)
incorporated into dec21xxx driver. That brings network connectivity to
Haiku systems running in MS Virtual PC VMs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e7c3a8ffd7434cff9662772e1fd12d336b2073ec 19-Jul-2010 Axel Dörfler <axeld@pinc-software.de>

Fixed a few regressions that were introduced during the last months:
* device_attach() must not load the network stack. Besides being completely
unbalanced, this was also one reason why the stack could not be unloaded
anymore. Instead, it's now done in compat_open(), as before.
* This also fixes network booting from FreeBSD drivers - the stack apparently
could not be initialized that early.
* Replaced the previous network stack based callout implementation with one
that mostly copies its functionality, but has no dependencies. Furthermore,
it runs at a higher priority (the one of the network timer should also be
revisited, though).
* Fixed mtx_owned() to work without KDEBUG as well. It's not a good idea to
introduce code that behaves completely different based on debug settings.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37580 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b5b2e045a5e5c6a0bac2bcab050bdf0decc4caf 13-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Implement MSI support using the x86 specific PCI module in the FreeBSD
compatibility layer. This should make some network and wireless hardware use
MSIs and therefore solve issues related to interrupt sharing and wrongly
advertised interrupt lines.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36225 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0a05bd2063fe25875e1cf0710f7182d15465df8c 03-Dec-2009 Colin Günther <coling@gmx.de>

Removing superflous functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34463 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2406849d4a8bcb152bc992bc5c1c6ef51e783f4b 27-Oct-2009 Colin Günther <coling@gmx.de>

* Coding style fixes regarding whitespace usage.
* Copyright style fixes.
* Implemented FreeBSD hardclock subsystem, which is needed to update the ticks
variable. The previous usage of "#define ticks system_time()" wasn't
sufficient anymore, as there are drivers using the ticks name for local
scoped variables.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33785 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 14627e087b920676d05d45cec5f28688744e1fdb 22-Oct-2009 Colin Günther <coling@gmx.de>

* reordering of headerfile inclusion to comply to FreeBSD 8
ordering.
this makes porting driver (especially wifi ones) more
convinient
* based on FreeBSD svn revision 196691

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33739 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 30710739a3f1dfd2b0070fac62ecbdd8540ba4be 29-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* compat_open() still needs to get the stack module, as the callout
functionality needs it.
* callout_init_mtx() now initializes the timer manually, since the stack
might not have been loaded yet (since a device is now attached in
init_driver()).
* Minor other fixes; the FreeBSD compatibility layer should now be functional
again.
* Accidently put pci.c into the repository, but that was never meant to happen.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23026 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 053693ef2a932d8e9359d66977c3915084355a8c 30-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Since device_add_child() needs the name of the parent driver, the root
device needs a driver_t object, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23025 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 080b265acd2f9903dcaf3d1e5076b0ecb8c20c6c 29-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Completely renovated the FreeBSD compatibility layer:
* Removed NETDEV() and DEVNET() macros and functionality.
* The exported devices are now attached to ifnet objects only, therefore, the
ifnet object now has the receive queue, and everything else a device could
need.
* There is now a root device where everything else is attached, it currently
only holds the pci_info structure, so it's more or less a PCI child.
* This simplified the device handling a bit everywhere.
* We now attach drivers already in init_driver() - this is needed as drivers
may publish more than one interface when being attached.
* Implemented device_delete_child(), device_attach() (which bus_generic_attach()
now uses), device_is_attached(), and device_is_alive().
* Therefore, if_initname() does now the actual job of registering the devices.
* On open, if_init() is called which comes pretty close to what our open()
is supposed to do.
* Updated ukphy.c to the one from FreeBSD 7 where used (we should probably
move that into the compat layer, anyway).
* The MII driver array must now be NULL terminated; therefore you don't need
to specify the count anymore.
* Moved PCI code from compat.c to bus.c.
* Moved the driver code from device.c to driver.c.
* Removed superfluous init_compat_layer() function.
* Fixed a few bugs, a few things weren't brought down correctly.
* The rtl8139 interrupt routine now checks if it really was the cause of the
interrupt - this code is not tested, either, it may not work (which would
then require a work-around like I did for the 3com driver).
* The HAIKU_PROTECT_INTR_REGISTER in the rtl8139 driver was pretty much useless
which is why I removed it.
* Probably introduced a lot of new bugs, though - I haven't tested this code
at all yet. It will probably just crash :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23019 a95241bf-73f2-0310-859d-f6bbb57e9c96