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

freebsd_network: Add missing case for MCLBYTES in m_get2.

The first case is really just a standard mbuf without a cluster.
MCLBYTES should be the second case. This matches what FreeBSD does.


# a68e59dd 01-Jun-2020 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Fix destruction of ref-counted ext_bufs.

The check as to whether or not the buf should be freed was wrong,
leading to incorrect frees.

Fixes double-free KDLs under the idualwifi driver that occur
on boot extremely frequently.

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


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

freebsd_network: Implement m_cljget without mbuf.

This returns an ext_buf that can be attached to an mbuf later,
which is something iflib does.


# 8267c193 29-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Lots of additions and modifications for iflib.


# 92d70a24 28-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

freebsd_network: Fix and implement some mbuf functions.

Spotted while reviewing the code during iflib porting.


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


# 4bef8ab8 27-Mar-2017 Fredrik Holmqvist <fredrik.holmqvist@gmail.com>

Function needs more void.


# 35226072 27-Mar-2017 Fredrik Holmqvist <fredrik.holmqvist@gmail.com>

__FreeBSD_version__ is always 8, remove old #if

Reduce number of todos...


# 8d1316fd 22-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and
CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager
does not wait when reserving memory or pages. The latter prevents area
operations. The new flags add a bit of flexibility. E.g. when allocating page
mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient,
i.e. the allocation will succeed as long as pages are available.


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


# 86c794e5 21-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
We allocate 8 MB areas whose pages we allocate and map when needed. An area is
divided into equally-sized chunks which form the basic units of allocation. We
have areas with three possible chunk sizes (small, medium, large), which is
basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
cache and object depot functions. E.g. object_depot_store() potentially wants
to allocate memory for a magazine. But also in pure freeing functions it
might eventually become useful to have those flags, since they could end up
deleting an area, which might not be allowable in all situations. We should
introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
areas, maintains a hash table for lookup, and maps chunks to object caches,
we can quickly find out which object cache a to be freed allocation belongs
to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
when really necessary, i.e. when the object cache for the respective
allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
contention on the heap bin locks.


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


# fafb3210 18-Dec-2009 Colin Günther <coling@gmx.de>

* Removed code duplication by merging destruct_pkt_mbuf and mb_free_ext.
This gets rid of one layer of indirection, too.
Also, this removed a potential memory leakage, when deleting external memory
in destruct_pkt_mbuf. In the case where memory of type EXT_JUMBO9 was
previously allocated, this would have been wrongly catched by the condition
(ext_type & EXT_CLUSTER) != 0.
* Renamed some variables to more human readable style.
* Commented some constants in mbuf.h to make more clear what they indicate and
to show that they should not be treatet as flags, as it was the case one
some locations before.
* Removed the EXT_PACKET constant, as it requests the same cache as
EXT_CLUSTER. EXT_PACKET is a optimizing technique from BSD, where a cache
exists holding some preallocated mbuf + cluster memory. Such a thing is not
implemented in the compat layer, at all. Though EXT_CLUSTER tells more
clearly what the size of the external data buffer is.



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


# de86f342 18-Dec-2009 Michael Lotz <mmlr@mlotz.ch>

Also call construct_mbuf() from m_getjcl() as it initializes the mbuf fields. It
also handles the M_PKTHDR flag. Before, the uninitialized fields could be left over
from earlier freed mbufs and on m_freem previous m_next fields could be returned
resulting in random mbufs being freed. This makes the iprowifi4965 work and fixes
#5089.


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


# 962b2f72 01-Dec-2009 Colin Günther <coling@gmx.de>

This function needs to handle the sJumboPageSizeCache, too.


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


# f47e4d7f 01-Dec-2009 Colin Günther <coling@gmx.de>

* Adding another mbuf cache for handling MJUMPAGESIZE sized clusters.
* This should fix ticket #5063.


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


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

* Cleanup.


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


# 855b7c29 02-Dec-2008 Jérôme Duval <korli@users.berlios.de>

added some missing functions for freebsd current


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


# 1dc91130 10-Nov-2008 Jérôme Duval <korli@users.berlios.de>

added m_cljget() with support for jumbo9 size: it should help with broadcom570x


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


# 619780e1 24-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Patch by tqh from ticket #2761 that adds max_hdr, and puts some extra
parenthesis around the mtod() definition.


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


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

freebsd compat. layer: a couple more definitions, minimal, mostly adding a new glue method to re-enable device interrupts since if_rl (rtl 8139) will require it.


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


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

freebsd compat. layer: added swi taskqueue and a couple more methods that if_xl needs. also marked some as unimplemented so its clearer what is left to be done.


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


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

freebsd compat. layer: splited freebsd original code into own files.


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


# 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


# 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


# 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


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

freebsd compat. layer: added mbuf allocation and if_media support


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


# 8d1316fd23616f6dac131a0eba5dab08acc6e76d 22-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced CACHE_DONT_SLEEP by two new flags CACHE_DONT_WAIT_FOR_MEMORY and
CACHE_DONT_LOCK_KERNEL_SPACE. If the former is given, the slab memory manager
does not wait when reserving memory or pages. The latter prevents area
operations. The new flags add a bit of flexibility. E.g. when allocating page
mapping objects for userland areas CACHE_DONT_WAIT_FOR_MEMORY is sufficient,
i.e. the allocation will succeed as long as pages are available.


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


# 86c794e5c10f1b2d99d672d424a8637639c703dd 21-Jan-2010 Ingo Weinhold <ingo_weinhold@gmx.de>

slab allocator:
* Implemented a more elaborated raw memory allocation backend (MemoryManager).
We allocate 8 MB areas whose pages we allocate and map when needed. An area is
divided into equally-sized chunks which form the basic units of allocation. We
have areas with three possible chunk sizes (small, medium, large), which is
basically what the ObjectCache implementations were using anyway.
* Added "uint32 flags" parameter to several of the slab allocator's object
cache and object depot functions. E.g. object_depot_store() potentially wants
to allocate memory for a magazine. But also in pure freeing functions it
might eventually become useful to have those flags, since they could end up
deleting an area, which might not be allowable in all situations. We should
introduce specific flags to indicate that.
* Reworked the block allocator. Since the MemoryManager allocates block-aligned
areas, maintains a hash table for lookup, and maps chunks to object caches,
we can quickly find out which object cache a to be freed allocation belongs
to and thus don't need the boundary tags anymore.
* Reworked the slab boot strap process. We allocate from the initial area only
when really necessary, i.e. when the object cache for the respective
allocation size has not been created yet. A single page is thus sufficient.

other:
* vm_allocate_early(): Added boolean "blockAlign" parameter. If true, the
semantics is the same as for B_ANY_KERNEL_BLOCK_ADDRESS.
* Use an object cache for page mappings. This significantly reduces the
contention on the heap bin locks.


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


# fafb321062bf7e9db8bc6327d4cc953e4a55db1f 18-Dec-2009 Colin Günther <coling@gmx.de>

* Removed code duplication by merging destruct_pkt_mbuf and mb_free_ext.
This gets rid of one layer of indirection, too.
Also, this removed a potential memory leakage, when deleting external memory
in destruct_pkt_mbuf. In the case where memory of type EXT_JUMBO9 was
previously allocated, this would have been wrongly catched by the condition
(ext_type & EXT_CLUSTER) != 0.
* Renamed some variables to more human readable style.
* Commented some constants in mbuf.h to make more clear what they indicate and
to show that they should not be treatet as flags, as it was the case one
some locations before.
* Removed the EXT_PACKET constant, as it requests the same cache as
EXT_CLUSTER. EXT_PACKET is a optimizing technique from BSD, where a cache
exists holding some preallocated mbuf + cluster memory. Such a thing is not
implemented in the compat layer, at all. Though EXT_CLUSTER tells more
clearly what the size of the external data buffer is.



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


# de86f3421cd7d5a2e4f5331e07e108c57d487556 18-Dec-2009 Michael Lotz <mmlr@mlotz.ch>

Also call construct_mbuf() from m_getjcl() as it initializes the mbuf fields. It
also handles the M_PKTHDR flag. Before, the uninitialized fields could be left over
from earlier freed mbufs and on m_freem previous m_next fields could be returned
resulting in random mbufs being freed. This makes the iprowifi4965 work and fixes
#5089.


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


# 962b2f7296a88df149397d95d283ee034bffb506 01-Dec-2009 Colin Günther <coling@gmx.de>

This function needs to handle the sJumboPageSizeCache, too.


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


# f47e4d7f93a90cc606d62135e5f2c6d39152d34b 01-Dec-2009 Colin Günther <coling@gmx.de>

* Adding another mbuf cache for handling MJUMPAGESIZE sized clusters.
* This should fix ticket #5063.


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


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

* Cleanup.


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


# 855b7c292e2f5a0102339980518b711e9b97922a 02-Dec-2008 Jérôme Duval <korli@users.berlios.de>

added some missing functions for freebsd current


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


# 1dc9113089f9274b2dadb6912e9d82c44706f1d2 10-Nov-2008 Jérôme Duval <korli@users.berlios.de>

added m_cljget() with support for jumbo9 size: it should help with broadcom570x


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


# 619780e1beef691fd871273276ad213ee444f72a 24-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Patch by tqh from ticket #2761 that adds max_hdr, and puts some extra
parenthesis around the mtod() definition.


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


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

freebsd compat. layer: a couple more definitions, minimal, mostly adding a new glue method to re-enable device interrupts since if_rl (rtl 8139) will require it.


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


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

freebsd compat. layer: added swi taskqueue and a couple more methods that if_xl needs. also marked some as unimplemented so its clearer what is left to be done.


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


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

freebsd compat. layer: splited freebsd original code into own files.


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


# 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


# 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


# 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


# 82256564e26214c7041963436ea6ede7fdc9706e 02-May-2007 Hugo Santos <hugosantos@nowhere.fake>

freebsd compat. layer: added mbuf allocation and if_media support


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