History log of /haiku/src/libs/compat/freebsd_network/device.h
Revision Date Author Comments
# 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.


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

freebsd_network: Introduce USB-handling code.

It is not yet wired in to the rest of the compatibilit layer;
that will happen in the next commits.

The bulk of the implementation is in usb.cpp; most of the
rest of the new files are copied from FreeBSD to varying degrees.


# 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.)


# 7f6254d1 08-May-2019 Bruno Albuquerque <bga@bug-br.org.br>

Prevent a double softc free.

- Keep track if the softc was allocated externally or not.
- Only try to deallocate it if it was allocated internally.

Do not try to free the softc if we were not the ones allocating it.

- Avoid a double free on consecutive calls to device_set_softc.

Change-Id: Ibb38e54e9dfd2a80dbb53920970bead626da8ba1
Reviewed-on: https://review.haiku-os.org/c/1441
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


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


# 656e05ec 29-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

FreeBSD compat layer: implement MSI-X support.


# 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


# e9af5d45 23-Oct-2009 Rene Gollent <anevilyak@gmail.com>

Fix build.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33747 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


# 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


# 4b2286de 09-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: MII subsystem (needs testers, more to come).


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


# eb89c947 09-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: implemented miibus_readreg and miibus_writereg, it goes up through the tree until the driver.


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


# b6509511 09-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: split device structure to handle for miibus devices, added a new network_device.


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


# 100b6e65 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: close() and free().


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


# 3f3e58db 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: gcc 4 fixes, it seems __FUNCTION__ is variant.


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


# 859a95b6 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: taskqueue implementation.


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


# 25d42ceb 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: a few more definitions, preparing for a DMA-using driver.


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


# b27873dc 06-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added ETHER_SETPROMISC, ETHER_GET_LINK_STATE and ETHER_SET_LINK_STATE_SEM support.


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


# 0bdff524 06-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: instead of disabling the IRQ, disable the device's interrupts on real interrupt request as suggested by Travis. This solves potential issues with shared IRQs. The check & disable interrupts function is part of the required glue code.


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


# e1a99f77 06-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: use a thread for deferred interrupt handling. fixed a issue with bus_space_write_N. init the receive queue on device creation.


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


# ddcaaa61 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added open(), which calls into the driver's attach. when testing with PCNET, a interface is already presented to the stack, it is even able to obtain the MAC address from the device, but still more work to do.


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


# 244a4d1f 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: we now init the several sub-parts through init_hardware, as well as allocate the available device_ts.


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


# a23462bf 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: use m_defrag to get a contiguous mbuf when read()ing. also added write() and a partial control().


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


# 6d043beb 03-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added mii placeholders, callout implementation.


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


# 070b62bf 03-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: a few more symbols, also respect malloc's M_ZERO


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


# 522fc5d8 02-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer, a few more methods.


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


# 656e05ec86375a592c360f7f4d2ea321e74cd8ff 29-Jul-2013 Jérôme Duval <jerome.duval@gmail.com>

FreeBSD compat layer: implement MSI-X support.


# 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


# e9af5d4585e8c27ae3530100671d27aa8cad2e60 23-Oct-2009 Rene Gollent <anevilyak@gmail.com>

Fix build.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33747 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


# 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


# 4b2286de8280643f2859b280d79fcbaf56f78cae 09-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: MII subsystem (needs testers, more to come).


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


# eb89c947d34849a59a7a5dc1e3a5559d0087fb85 09-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: implemented miibus_readreg and miibus_writereg, it goes up through the tree until the driver.


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


# b650951128733ee316bb4c9b985b99363b2e72e8 09-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: split device structure to handle for miibus devices, added a new network_device.


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


# 100b6e6537752d4baa2938fff0a6d10cabc62a24 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: close() and free().


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


# 3f3e58db2051137353eb2cbba79ed579d3e30c13 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: gcc 4 fixes, it seems __FUNCTION__ is variant.


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


# 859a95b6c77ee889682b75b942af5f0300d763ff 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: taskqueue implementation.


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


# 25d42ceb99f745c136482397667bc9ebb6bd5013 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: a few more definitions, preparing for a DMA-using driver.


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


# b27873dc4ad63e9121bf32a2301389cf869e1f9b 06-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added ETHER_SETPROMISC, ETHER_GET_LINK_STATE and ETHER_SET_LINK_STATE_SEM support.


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


# 0bdff52467a7c86f9d0e33f2b4eb79bbf65aa5bb 06-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: instead of disabling the IRQ, disable the device's interrupts on real interrupt request as suggested by Travis. This solves potential issues with shared IRQs. The check & disable interrupts function is part of the required glue code.


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


# e1a99f77d48faf3bd1d0e007afebb96c34016893 06-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: use a thread for deferred interrupt handling. fixed a issue with bus_space_write_N. init the receive queue on device creation.


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


# ddcaaa6129d2c66d69c4bd3d0c238ce813ed62d7 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added open(), which calls into the driver's attach. when testing with PCNET, a interface is already presented to the stack, it is even able to obtain the MAC address from the device, but still more work to do.


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


# 244a4d1fa347dfe4c8247cea76393219eb79a8e0 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: we now init the several sub-parts through init_hardware, as well as allocate the available device_ts.


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


# a23462bfade25e327cf98d80dcf034768217d852 04-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: use m_defrag to get a contiguous mbuf when read()ing. also added write() and a partial control().


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


# 6d043beb03c572d3fd2f6995c83e13516913790a 03-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added mii placeholders, callout implementation.


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


# 070b62bf1130612f374b477db02292b5abd75426 03-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: a few more symbols, also respect malloc's M_ZERO


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


# 522fc5d8456aecd1f82fca13df7cd5249c9b3096 02-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer, a few more methods.


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