<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/compat/linuxkpi, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>LinuxKPI: implement devm_kmemdup_array()</title>
<updated>2026-04-18T01:12:14+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-14T13:35:36+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f1834d03af617a93993056bb902082452673f89f'/>
<id>f1834d03af617a93993056bb902082452673f89f</id>
<content type='text'>
Implement devm_kmemdup_array() using devm_kmemdup() in order to
prepare for Linux v7.0 based drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56396
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement devm_kmemdup_array() using devm_kmemdup() in order to
prepare for Linux v7.0 based drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56396
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: add kmalloc_obj[s], kzalloc_obj[s], and kzalloc_flex</title>
<updated>2026-04-18T01:12:13+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-14T15:13:18+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=c72ac6af086962d236f4712761abacac0c62b48e'/>
<id>c72ac6af086962d236f4712761abacac0c62b48e</id>
<content type='text'>
Drivers in Linux v7.0 seem to have changed to the new allocation
macros using a sweep.  Add the ones I encountered with wireless
drivers so far.  They all take an optional argument for a gfp_t,
which default_gfp() deals with.

The plural version "objs" takes an extra nitems argument in addition
to the size.  We use size_mul() to possibly detect overflows.

The "flex" version uses an extra variable to track the variable sized
array allocations and if supported by the compiler will use
__builtin_counted_by_ref() to properly track bounds.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56395
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Drivers in Linux v7.0 seem to have changed to the new allocation
macros using a sweep.  Add the ones I encountered with wireless
drivers so far.  They all take an optional argument for a gfp_t,
which default_gfp() deals with.

The plural version "objs" takes an extra nitems argument in addition
to the size.  We use size_mul() to possibly detect overflows.

The "flex" version uses an extra variable to track the variable sized
array allocations and if supported by the compiler will use
__builtin_counted_by_ref() to properly track bounds.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56395
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: sync overflow.h from Linux v7.0</title>
<updated>2026-04-18T01:12:13+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-14T13:50:44+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=d2c85255d4fca37ec9774f85f867f8fc89a51269'/>
<id>d2c85255d4fca37ec9774f85f867f8fc89a51269</id>
<content type='text'>
overflow.h was imported directly from Linux in 3208d4ad2b8320a.
Update the file to the newer version as needed for v7.0 driver updates.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Obtained from:	git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
		028ef9c96e96197026887c0f092424679298aae8 (tag: v7.0)
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D56394
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
overflow.h was imported directly from Linux in 3208d4ad2b8320a.
Update the file to the newer version as needed for v7.0 driver updates.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Obtained from:	git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
		028ef9c96e96197026887c0f092424679298aae8 (tag: v7.0)
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D56394
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: conditionally add __flex_counter()</title>
<updated>2026-04-18T01:12:12+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-14T15:06:56+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=524df650a92f648e19ba27d6727bdc79c8efdbbb'/>
<id>524df650a92f648e19ba27d6727bdc79c8efdbbb</id>
<content type='text'>
__flex_counter() is used by overflow.h and needed for "flex allocations".
It is either a void * typed 0 (NULL) (like this for _Generic checks),
or uses __builtin_counted_by_ref.

The latter was added to gcc and llvm fairly recently and while for gcc
the __has_builtin() check suffices, clang had parts broken until recently
so needs an extra check for the next major version.  The fixed hash is
currently not part of any tag to use, so we play it save (and hope 23
will have it).  It will be a while until we will see the builting to be
used but at least we will be prepared for it.  See inline comments for
the commit hashes and versions which added the feature.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56393
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
__flex_counter() is used by overflow.h and needed for "flex allocations".
It is either a void * typed 0 (NULL) (like this for _Generic checks),
or uses __builtin_counted_by_ref.

The latter was added to gcc and llvm fairly recently and while for gcc
the __has_builtin() check suffices, clang had parts broken until recently
so needs an extra check for the next major version.  The fixed hash is
currently not part of any tag to use, so we play it save (and hope 23
will have it).  It will be a while until we will see the builting to be
used but at least we will be prepared for it.  See inline comments for
the commit hashes and versions which added the feature.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56393
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: add default_gfp()</title>
<updated>2026-04-18T01:12:12+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-14T13:40:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=35b90c21f48056e85b70dbbe2209b6c3a4927315'/>
<id>35b90c21f48056e85b70dbbe2209b6c3a4927315</id>
<content type='text'>
Various new allocation macros can take an optional gfp_t argument.
If the argument is not given we need to set the GFP_KERNEL default.
While this is only internally used and I initialy called it differently,
should this spread elsewhere having the same name as in Linux will be
good.

Sponsored by:	The FreeBSD Foundaton
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56392
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Various new allocation macros can take an optional gfp_t argument.
If the argument is not given we need to set the GFP_KERNEL default.
While this is only internally used and I initialy called it differently,
should this spread elsewhere having the same name as in Linux will be
good.

Sponsored by:	The FreeBSD Foundaton
MFC after:	3 days
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D56392
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: move hex2bin() from kernel.h to new hex.h</title>
<updated>2026-04-18T01:12:12+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-14T13:36:40+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=98297ff3cfbb42df86fa7af51a2740d5aa7236eb'/>
<id>98297ff3cfbb42df86fa7af51a2740d5aa7236eb</id>
<content type='text'>
New Linux v7.0 drivers include hex.h.  Rather than adding a dummy
header, migrate the kernel.h hex2bin() into hex.h, where it belongs.
Care needs to be taken as the _h2b() helper function is still used by
other bits in kernel.h.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D56391
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
New Linux v7.0 drivers include hex.h.  Rather than adding a dummy
header, migrate the kernel.h hex2bin() into hex.h, where it belongs.
Care needs to be taken as the _h2b() helper function is still used by
other bits in kernel.h.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D56391
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: 802.11: make sure dtim_period is set</title>
<updated>2026-04-18T01:12:10+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-17T02:34:51+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9f20a4ebf044eb0cab83397c83f13bb3958abf6a'/>
<id>9f20a4ebf044eb0cab83397c83f13bb3958abf6a</id>
<content type='text'>
When going from ASSOC to RUN LinuxKPI based wireless drivers have
certian expectations written in various ways.  I believe mac80211
waits to see a beacon before setting the vif to assoc (or the sta
to AUTHORIZED).  We have some comments in lkpi_update_dtim_tsf()
for that.
In practice we can filter out the beacons already and know when
they came in as we count them but it is hard to split up the
state machine and defer the work.

So we make sure that dtim_period is set to at least 1 before
calling the (*vif_cfg_change) after setting assoc to true;
0 is a reserved value according to the standards.

We will update it once we see a beacon and in case the value
differs from 1 shortly afterwards from the recv_mgmt callback.

While iwlwifi seems to have coped with our initial implementation,
rtw89 may hit a DIV 0 if dtim_period is 0 depending on how well
the rx path races with our unlocking in assoc_to_run.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When going from ASSOC to RUN LinuxKPI based wireless drivers have
certian expectations written in various ways.  I believe mac80211
waits to see a beacon before setting the vif to assoc (or the sta
to AUTHORIZED).  We have some comments in lkpi_update_dtim_tsf()
for that.
In practice we can filter out the beacons already and know when
they came in as we count them but it is hard to split up the
state machine and defer the work.

So we make sure that dtim_period is set to at least 1 before
calling the (*vif_cfg_change) after setting assoc to true;
0 is a reserved value according to the standards.

We will update it once we see a beacon and in case the value
differs from 1 shortly afterwards from the recv_mgmt callback.

While iwlwifi seems to have coped with our initial implementation,
rtw89 may hit a DIV 0 if dtim_period is 0 depending on how well
the rx path races with our unlocking in assoc_to_run.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: 802.11: start filling vif-&gt;cfg.ap_addr</title>
<updated>2026-04-18T01:12:10+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-16T23:42:03+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=dc886a4428712aa4fcdcf8cd9e850b048c923bbf'/>
<id>dc886a4428712aa4fcdcf8cd9e850b048c923bbf</id>
<content type='text'>
vif-&gt;cfg.ap_addr is used by various drivers now and is the BSSID for
non-MLO or the AP addr for MLO configurations.

If this is unset rtw89 gets cranky and certain packets are likely not
going out correctly (also for iwlwifi).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
vif-&gt;cfg.ap_addr is used by various drivers now and is the BSSID for
non-MLO or the AP addr for MLO configurations.

If this is unset rtw89 gets cranky and certain packets are likely not
going out correctly (also for iwlwifi).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: 802.11: add chandef tracing</title>
<updated>2026-04-18T01:12:09+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-04-03T19:59:02+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=72b9dda511b6944068fb18c2f2e059bca48d9edd'/>
<id>72b9dda511b6944068fb18c2f2e059bca48d9edd</id>
<content type='text'>
Add chandef tracing so we can follow what is set and unset in the
chanctx emulation for drivers still needing this.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add chandef tracing so we can follow what is set and unset in the
chanctx emulation for drivers still needing this.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
</pre>
</div>
</content>
</entry>
<entry>
<title>LinuxKPI: 802.11: improve emulate chanctx implementation</title>
<updated>2026-04-18T01:12:09+00:00</updated>
<author>
<name>Bjoern A. Zeeb</name>
<email>bz@FreeBSD.org</email>
</author>
<published>2026-03-10T11:16:12+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=166a7344df582f98a88f2b37b7aa3dc4558c9438'/>
<id>166a7344df582f98a88f2b37b7aa3dc4558c9438</id>
<content type='text'>
Now that all dependencies are implemented improve our chanctx emulation.
Some drivers still rely on chandef information for channel work.

In order to only do chanctx updates within mac80211 in Linux and
likewise in the LinuxKPI 802.11 compat layer, emulation functions
were introduced which claim to support chanctx driver operation but
in reality convert these to chandef field updates and (*config)
downcalls.

This is relevant to several mt76 chipsets (at least 7615, 7915),
and rtw88 and certain rtw89 chipsets (8851b, and the ones not supporting
SCAN_OFFLOAD or BEACON_FILTER) for us.

Migrate the logic out of the header and improve it.

Make use of the introduced dflt_chandef and scan_chandef fields,
add comparison of chandefs to see if we have to update, etc.

Also add strict checks for driver settings in linuxkpi_ieee80211_alloc_hw()
to make sure all preconditions are correctly met.  Store the result
if we are using the emulation functions in a field, so we can later
check on it and also leave a note to the users if emulation is used
in order to improve debugging on possible problem reports.

Use the new field that we use emulation in lkpi_ic_set_channel() instead
of a hand crafted check.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:		ac1d519c01ca8 ("LinuxKPI: 802.11: adjustments for v6.11..")
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that all dependencies are implemented improve our chanctx emulation.
Some drivers still rely on chandef information for channel work.

In order to only do chanctx updates within mac80211 in Linux and
likewise in the LinuxKPI 802.11 compat layer, emulation functions
were introduced which claim to support chanctx driver operation but
in reality convert these to chandef field updates and (*config)
downcalls.

This is relevant to several mt76 chipsets (at least 7615, 7915),
and rtw88 and certain rtw89 chipsets (8851b, and the ones not supporting
SCAN_OFFLOAD or BEACON_FILTER) for us.

Migrate the logic out of the header and improve it.

Make use of the introduced dflt_chandef and scan_chandef fields,
add comparison of chandefs to see if we have to update, etc.

Also add strict checks for driver settings in linuxkpi_ieee80211_alloc_hw()
to make sure all preconditions are correctly met.  Store the result
if we are using the emulation functions in a field, so we can later
check on it and also leave a note to the users if emulation is used
in order to improve debugging on possible problem reports.

Use the new field that we use emulation in lkpi_ic_set_channel() instead
of a hand crafted check.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:		ac1d519c01ca8 ("LinuxKPI: 802.11: adjustments for v6.11..")
</pre>
</div>
</content>
</entry>
</feed>
