History log of /haiku/src/libs/compat/freebsd_network/device.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.


# e206b2f3 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Always hold the "Giant" lock during attaches.

Reduces patches to OpenBSD drivers slightly, and could potentially
help with some of the KDLs.


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


# a33cf10d 13-Sep-2021 Coldfirex <sakison@gmail.com>

USB Vision and FreeBSDCompat: Fix Wformat-security

Change-Id: Idd7fd80546b414c9db21bc0979412bcd4bf7878d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4460
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 8cd3603b 25-Feb-2021 Murai Takashi <tmurai01@gmail.com>

compat/freebsd_network: Fix Use of zero-allocated memory

If device is not found, 'list' is allocated to size 0.
So, modify function to return 0 as FreeBSD's subr_bus.c
when 'count' is 0.
Pointed out by Clang Static Analyzer.

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


# 2dc597d5 08-May-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

Optimize ffs() implementation

- Use gcc builtin
- Define as a static inline function in the .h so no function call overhead is needed
- Keep the function in libroot for backwards compatibility
- Remove a duplicate implementation in the freebsd compatibility layer

gcc2 does not document the builtin, but it is in fact already available
there as well.

Fixes #3281.

Change-Id: I94f8a2548637aa70e85febbfab06f07c1a427005
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2605
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 56cb682b 22-Nov-2019 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Moderate reorganization.

* Rename device.c to device_hooks.c, as this is what it really contains.
* Rename compat.c to device.c, as it implements the generic "device"
related functions, both for compat layer internals and FreeBSD
public ones.
* Move malloc and related operations out of the now-device.c,
and place them in a new "malloc.cpp", which also incorporates
compat_cpp.cpp.

No functional change intended.


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


# a549026d 27-Jun-2018 Augustin Cavalier <waddlesplash@gmail.com>

freebsd11_network: Actually set numBytes instead of silently truncating it.

If numBytes was greater than MCLBYTES (presently 1 << 11 = 2048), then the data beyond
MCLBYTES would be silently discarded instead of being written. Now, we store the
result of the min_c in numBytes, so the caller knows how much was written.

I turn on the printf that's commented out here and found that in practice this
seems to never happen (it's larger than the ethernet limit), so it seems unlikely
to fix any "transmission mysteriously failed" bugs.

Also backported this to the FreeBSD 9 layer.


# 7d827cb8 18-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

FreeBSD compat layer: try 10BaseT if setting autoselect failed.

* This fixes PCnet Fast III on VirtualBox with pcn driver (#10088).


# fcc745e0 08-Aug-2013 Evgeniy Abdraimov <zelenoviy@gmail.com>

Reopening FreeBSD's compat devices was broken due to a missing flag
clear. Patch part of #7040. Thanks.


# 18004d3a 29-Mar-2013 Michael Lotz <mmlr@mlotz.ch>

Avoid trying to set the media to Ethernet for WLAN devices.

It didn't really harm, but would always try to find a corresponding
media, fail and print an error.


# 6d796a84 10-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed up network stack and drivers for x86_64.

* Various compilation fixes.
* Fixes to the FreeBSD compatibility layer (from comparing the x86-
specific bits with the equivalent amd64 sources in FreeBSD).
* Compile all the Ethernet drivers except for sis900 and wb840, these
require a bit more work to fix (will file a ticket soon). Tested
ipro1000 and rtl81xx, no issues.


# 172971a1 23-Nov-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Switch link speed unit to bit/s to support low bitrate speed too
(hello slow dialup line...)


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


# ca215dfe 02-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Replaced more occurences of EOPNOTSUPP with B_NOT_SUPPORTED.


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


# 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


# 3e9b338e 18-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied cleaned patch by Adrian: the gDevices[] can now have empty entries,
the gDeviceNameList[] entries are no longer in the same order.
* This fixes bug #3124.


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


# 7ce5cc55 18-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied patch by Adrian that let the buffer size allocated vary with what
is needed.


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


# 59795d42 11-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* Applied patch by Adrian: compat_read() was broken as it only considered the
first chunk of a possibly multi-buffer mbuf. This fixes #2840, thanks a lot!
* Fixed warning in _bus_dmamap_load_buffer().


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


# 5cb80a0c 21-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Also set the mbuf::m_pkthdr.len field before passing it to ether_output().
* This should help with bug #1874.


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


# 589e5418 01-Dec-2007 Axel Dörfler <axeld@pinc-software.de>

* We need to call if_init() before trying to set the media.
* Accidently excluded the MII bus from being probed in r23019 - in fact, now all
devices have to be probed.


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


# 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


# 6b096660 28-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

The compatibility layer was calling if_init() too early, I've now moved it to the compat_open()
function.


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


# 239239c8 25-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Updated the FreeBSD compatibility layer for network drivers to FreeBSD 7
(RELENG_7_BP).
* There are many white spots, though, most notable PCI MSI(-X) support, and
jumbo frames.
* Fixed removing interrupts for the INTR_FAST case. Since FreeBSD 7 added
a new interrupt "filter" mechanism, we can finally report if the interface
was handled by a device or not (though only very few devices support this
yet).
* Updated the 3com, rtl8139, e1000, and via_rhine drivers to the latest code
base. They all compile, but I haven't tested them after the changes yet!


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


# 13f2a5fa 04-Nov-2007 Bruno G. Albuquerque <bga@bug-br.org.br>

First cut at a fix to the FreeBSD rtl9139 driver. Some drivers require softc to
be initialized when probe(0 is called. The driver now loads and works for a
while until it hangs. Looking into it.



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


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

* Calmed down the FreeBSD drivers even more - compat_{read|write}() no longer
print anything.
* Added (commented out) debug output to compat_control().
* Renamed variables "len" to "length" where possible.
* Minor cleanup.


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


# 7242a223 03-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Added miibus_linkchg and miibus_mediainit methods to device_set_driver(); this was the actual
reason the MII bus did not work as mediainit was never called.
* Got rid of the delayed MII bus scanning again; not only did it not solve the problem, it was
also completely unnecessary.
* Minor cleanup.


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


# 84eb0b5f 02-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Delayed scanning the MII bus until the first ifm_media has been set for the
device.


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


# 31154c5c 29-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed the KASSERT() macro - it panicked without reason.
* Fixed device_set_driver(): it needs to clear the allocated buffer (it's
allocated with M_ZERO in FreeBSD).
* The first mbuf buffer needs to have the M_PKTHDR flag set.
* With these changes, the 3com driver now fails where it should have failed
before, that is in the missing interrupt handling.
* Minor cleanup.


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


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

IFT_ETHER expects an arpcom structure at if_l2com; this would actually need
to be expanded for other types, but for now, we'll probably only get IFT_ETHER
anyway.


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


# 379d5922 21-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: fixed ETHER_GETFRAMESIZE handling. possible fix for #1238.


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


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

freebsd compat. layer: when open()ing the device, and setting it up, don't clear the device flags (multicast included).


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


# 07ef8870 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: multicast support.


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


# 303a4a3d 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: a couple more changes. a DMA-using driver (FreeBSD's em, Intel Pro 1000) now works without any modifications (it has a fast interrupt mode).


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


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

freebsd compat. layer: added a requirements field so not all drivers init all subsystems. pcnet for instance doesn't need taskqueues.


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


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

freebsd compat. layer: now both receiving and sending work with PCNET.


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


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

freebsd compat. layer: couple fixes, sending now works with PCNET. enabled ifmedia_ioctl, and when opening a device, set it down, change media to ETHER/AUTO and set it back up so it sees a IFF_UP.


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


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

freebsd compat. layer: a few more methods, preparing for pcnet


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


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

freebsd compat. layer: now the glue code properly references the required methods so we have proper linkage with gcc 4


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


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

freebsd compat. layer: some initial glue code


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


# 7d827cb8646364a12a951f4555f027be0033b86d 18-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

FreeBSD compat layer: try 10BaseT if setting autoselect failed.

* This fixes PCnet Fast III on VirtualBox with pcn driver (#10088).


# fcc745e0e756f2d7700b138d435f0fabd2262d66 08-Aug-2013 Evgeniy Abdraimov <zelenoviy@gmail.com>

Reopening FreeBSD's compat devices was broken due to a missing flag
clear. Patch part of #7040. Thanks.


# 18004d3ac01f07153a6891c451f2e7e2f1ae8d3f 29-Mar-2013 Michael Lotz <mmlr@mlotz.ch>

Avoid trying to set the media to Ethernet for WLAN devices.

It didn't really harm, but would always try to find a corresponding
media, fail and print an error.


# 6d796a84bd484ccc4fb072a29c663b660180ae51 10-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Fixed up network stack and drivers for x86_64.

* Various compilation fixes.
* Fixes to the FreeBSD compatibility layer (from comparing the x86-
specific bits with the equivalent amd64 sources in FreeBSD).
* Compile all the Ethernet drivers except for sis900 and wb840, these
require a bit more work to fix (will file a ticket soon). Tested
ipro1000 and rtl81xx, no issues.


# 172971a18fc072efbbe9e3bd997bbecef4b7e31f 23-Nov-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Switch link speed unit to bit/s to support low bitrate speed too
(hello slow dialup line...)


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


# ca215dfe683e040f0a44917f26cef0d7d439e59a 02-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Replaced more occurences of EOPNOTSUPP with B_NOT_SUPPORTED.


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


# 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


# 3e9b338ea7240c7e7cba1edc46584050d2d7634d 18-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied cleaned patch by Adrian: the gDevices[] can now have empty entries,
the gDeviceNameList[] entries are no longer in the same order.
* This fixes bug #3124.


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


# 7ce5cc550522b9d41149c77d6d9ad20d7cc9c187 18-Mar-2009 Axel Dörfler <axeld@pinc-software.de>

* Applied patch by Adrian that let the buffer size allocated vary with what
is needed.


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


# 59795d428e44aa5de0a8cf59e88c36ce3cc39846 11-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* Applied patch by Adrian: compat_read() was broken as it only considered the
first chunk of a possibly multi-buffer mbuf. This fixes #2840, thanks a lot!
* Fixed warning in _bus_dmamap_load_buffer().


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


# 5cb80a0cd873e37cc886e72f3ab161ccb99b3831 21-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Also set the mbuf::m_pkthdr.len field before passing it to ether_output().
* This should help with bug #1874.


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


# 589e5418f103139d46cdc6046939ebecffe852be 01-Dec-2007 Axel Dörfler <axeld@pinc-software.de>

* We need to call if_init() before trying to set the media.
* Accidently excluded the MII bus from being probed in r23019 - in fact, now all
devices have to be probed.


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


# 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


# 6b096660341e8accfb30a289541a75f4ea8c0c52 28-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

The compatibility layer was calling if_init() too early, I've now moved it to the compat_open()
function.


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


# 239239c8a0c6a2671f8f236ba32abf03e78f0c27 25-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Updated the FreeBSD compatibility layer for network drivers to FreeBSD 7
(RELENG_7_BP).
* There are many white spots, though, most notable PCI MSI(-X) support, and
jumbo frames.
* Fixed removing interrupts for the INTR_FAST case. Since FreeBSD 7 added
a new interrupt "filter" mechanism, we can finally report if the interface
was handled by a device or not (though only very few devices support this
yet).
* Updated the 3com, rtl8139, e1000, and via_rhine drivers to the latest code
base. They all compile, but I haven't tested them after the changes yet!


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


# 13f2a5fa312feac332d202a97b55353ece1b184d 04-Nov-2007 Bruno G. Albuquerque <bga@bug-br.org.br>

First cut at a fix to the FreeBSD rtl9139 driver. Some drivers require softc to
be initialized when probe(0 is called. The driver now loads and works for a
while until it hangs. Looking into it.



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


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

* Calmed down the FreeBSD drivers even more - compat_{read|write}() no longer
print anything.
* Added (commented out) debug output to compat_control().
* Renamed variables "len" to "length" where possible.
* Minor cleanup.


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


# 7242a223a1a8d60027239e3959e03fb1958beafc 03-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Added miibus_linkchg and miibus_mediainit methods to device_set_driver(); this was the actual
reason the MII bus did not work as mediainit was never called.
* Got rid of the delayed MII bus scanning again; not only did it not solve the problem, it was
also completely unnecessary.
* Minor cleanup.


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


# 84eb0b5f5b91830d11a346db8cf39aa0dd8b95f1 02-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

Delayed scanning the MII bus until the first ifm_media has been set for the
device.


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


# 31154c5cc6e2351ebcc979bea3b7c5dc6cf5923c 29-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed the KASSERT() macro - it panicked without reason.
* Fixed device_set_driver(): it needs to clear the allocated buffer (it's
allocated with M_ZERO in FreeBSD).
* The first mbuf buffer needs to have the M_PKTHDR flag set.
* With these changes, the 3com driver now fails where it should have failed
before, that is in the missing interrupt handling.
* Minor cleanup.


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


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

IFT_ETHER expects an arpcom structure at if_l2com; this would actually need
to be expanded for other types, but for now, we'll probably only get IFT_ETHER
anyway.


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


# 379d59225ba026d761c5f8207905f6d068a7fc8a 21-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: fixed ETHER_GETFRAMESIZE handling. possible fix for #1238.


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


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

freebsd compat. layer: when open()ing the device, and setting it up, don't clear the device flags (multicast included).


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


# 07ef8870a37b1f275963aee79332df4b672335ee 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: multicast support.


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


# 303a4a3df65bdf47d29c6f7429d523a5a0e8aa1b 08-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: a couple more changes. a DMA-using driver (FreeBSD's em, Intel Pro 1000) now works without any modifications (it has a fast interrupt mode).


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


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

freebsd compat. layer: added a requirements field so not all drivers init all subsystems. pcnet for instance doesn't need taskqueues.


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


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

freebsd compat. layer: now both receiving and sending work with PCNET.


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


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

freebsd compat. layer: couple fixes, sending now works with PCNET. enabled ifmedia_ioctl, and when opening a device, set it down, change media to ETHER/AUTO and set it back up so it sees a IFF_UP.


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


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

freebsd compat. layer: a few more methods, preparing for pcnet


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


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

freebsd compat. layer: now the glue code properly references the required methods so we have proper linkage with gcc 4


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


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

freebsd compat. layer: some initial glue code


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