Page MenuHomeFreeBSD

Import iwx as ported from OpenBSD by Future Crew.
ClosedPublic

Authored by thj on Mar 6 2025, 4:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 6, 12:59 PM
Unknown Object (File)
Sat, Apr 5, 4:41 AM
Unknown Object (File)
Sat, Apr 5, 4:40 AM
Unknown Object (File)
Sat, Apr 5, 4:40 AM
Unknown Object (File)
Sat, Apr 5, 4:40 AM
Unknown Object (File)
Sat, Apr 5, 4:40 AM
Unknown Object (File)
Sat, Apr 5, 4:39 AM
Unknown Object (File)
Sat, Apr 5, 4:38 AM

Details

Summary

This driver originates from OpenBSD and the source release was kindly provided
by Future Crew.

iwx supports many recent Intel WiFi card and this driver should support running
these cards with legacy, HT and VHT rates. There are some issues remaining in
the port, but at this point wider testing is sought.

Known things to do:

  • Add SPDX tag for license (I could do with help figuring out what this resolves to)
  • Test on a wide range of hardware
  • Debug issues with associating to 5Ghz and 2GHz networks in the same session
  • Association issues with VHT
  • Channels wider than 40MHz
  • resume fails
  • create a package for firmware files
  • deprioritise iwx in devmatch

Looking to the future it would be good to add:

  • hw encryption support ( I have had this working in my port)
  • EHT
Test Plan

iwx testing:

This is a FreeBSD tree with iwx in sys/dev/iwx and a supporting Makefile.

You need to install firmware from OpenBSD to /boot/firmware. If you don't we
will fail to load and probably panic. To install firmware:

Grab this archive
http://firmware.openbsd.org/firmware/7.6/iwx-firmware-20240513p0.tgz
and unpack it in /boot/firmware, if you have done this correctly it will look
like:

$ ls /boot/firmware
iwx-Qu-b0-hr-b0-77      iwx-QuZ-a0-hr-b0-77     iwx-so-a0-gf-a0-77      iwx-so-a0-hr-b0-77
iwx-Qu-b0-jf-b0-77      iwx-QuZ-a0-jf-b0-77     iwx-so-a0-gf-a0.pnvm    iwx-so-a0-jf-b0-77
iwx-Qu-c0-hr-b0-77      iwx-cc-a0-77            iwx-so-a0-gf4-a0-77     iwx-ty-a0-gf-a0-77
iwx-Qu-c0-jf-b0-77      iwx-license             iwx-so-a0-gf4-a0.pnvm   iwx-ty-a0-gf-a0.pnvm

You may need to stop iwlwifi from attaching to the Wifi device in your
machine. You can do this by adding the following line to /etc/rc.conf

devmatch_blocklist="if_iwlwifi"

and then reboot.

Testing

First please verify that iwx has both loaded and attached to a device. You can
do this by looking at sysctl net.wlan.devices. If it doesn't contain iwx0
then the module hasn't loaded you can load it manuall:

  1. kldload if_iwx

Next create a wlan device as you normally do, join a network you are familiar
with the performance of and report back:

  • If iwx does or does not work
  • Performance compared to your normal measurements
  • If you know how, the results of iperf, iperf -R and iperf --bidir to a local machine
  • Please provide the output of the following commands via email to thj@freebsd.org
    • dmesg
    • pciconf -lv
    • ifconfig wlan0
    • ifconfig list sta

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

thj requested review of this revision.Mar 6 2025, 4:19 PM

I would suggest to "un-name" the firmware ad we add your needed versions (seems 77) to the iwlwifi firmware package as otherwise fwget will find the PCI IDs and will have to install both.
If iwx won't move anymore (or if it will) we can move that. I'll happily provide a patch and handle the FW port.

Thanks Tom for the patch! I have managed to test it on top of ecb3a7d43dd6:

# uname -a
FreeBSD framework 15.0-CURRENT FreeBSD 15.0-CURRENT #0 main-n275819-ecb3a7d43dd6: Thu Mar  6 21:58:02 CET 2025     khorben@:/usr/obj/home/khorben/Projects/FreeBSD/src/amd64.amd64/sys/GENERIC amd64
root

First, this time I did not observe any negative side-effects.

However, although the device was recognized, the driver failed to initialize it:

iwx0: <Wi-Fi 6 AX210> mem 0x90b00000-0x90b03fff at device 0.0 on pci1
iwx-so-a0-gf-a0-77: could not load firmware image, error 8
iwx0: could not load firmware, 35
iwx0: failed to load init firmware
iwx0: failed to stop device

This is in spite of having installed the firmware files from OpenBSD as documented:

# COLUMNS=132 ls /boot/firmware/iwx*
/boot/firmware/iwx-Qu-b0-hr-b0-77       /boot/firmware/iwx-license              /boot/firmware/iwx-so-a0-gf-a0.pnvm
/boot/firmware/iwx-Qu-b0-jf-b0-77       /boot/firmware/iwx-ma-b0-gf-a0-83       /boot/firmware/iwx-so-a0-gf4-a0-77
/boot/firmware/iwx-Qu-c0-hr-b0-77       /boot/firmware/iwx-ma-b0-gf-a0.pnvm     /boot/firmware/iwx-so-a0-gf4-a0.pnvm
/boot/firmware/iwx-Qu-c0-jf-b0-77       /boot/firmware/iwx-ma-b0-gf4-a0-83      /boot/firmware/iwx-so-a0-hr-b0-77
/boot/firmware/iwx-QuZ-a0-hr-b0-77      /boot/firmware/iwx-ma-b0-gf4-a0.pnvm    /boot/firmware/iwx-so-a0-jf-b0-77
/boot/firmware/iwx-QuZ-a0-jf-b0-77      /boot/firmware/iwx-ma-b0-hr-b0-83       /boot/firmware/iwx-ty-a0-gf-a0-77
/boot/firmware/iwx-cc-a0-77             /boot/firmware/iwx-so-a0-gf-a0-77       /boot/firmware/iwx-ty-a0-gf-a0.pnvm

Otherwise:

iwx0@pci0:1:0:0:        class=0x028000 rev=0x1a hdr=0x00 vendor=0x8086 device=0x2725 subvendor=0x8086 subdevice=0x0024
    vendor     = 'Intel Corporation'
    device     = 'Wi-Fi 6E(802.11ax) AX210/AX1675* 2x2 [Typhoon Peak]'
    class      = network

Let me know if you need more information from my side.

This is on a Framework 13 AMD laptop - after replacing the original wireless card - and using ZFS.

sys/modules/Makefile
207

Shouldn't that be ${_iwx} instead, with $_iwx being defined in the optional section near line 569 like $_iwlwifi is?

In D49259#1123434, @bz wrote:

I would suggest to "un-name" the firmware ad we add your needed versions (seems 77) to the iwlwifi firmware package as otherwise fwget will find the PCI IDs and will have to install both.
If iwx won't move anymore (or if it will) we can move that. I'll happily provide a patch and handle the FW port.

+1 we should really just roll the iwlwifi and iwx firmware in together. I did it locally and iwx worked fine for me.

  • Use iwlwifi names for firmware files
  • Parameterise iwx in the modules makefile
  • Remove a debug panic
sys/dev/iwx/if_iwx_debug.h
319

missing static?

(although at this point I'd be putting these routines in an if_iwx_debug.c file.)

sys/dev/iwx/if_iwxvar.h
809

Let's get rid of this?

858

Hm leave this one in, we'll need to go see if addba stop works right

861

And this too now?

sys/modules/iwx/Makefile
10

We really should migrate this to an opt_iwx.h file and include it in sys/conf/options . I don't mind seeing it fixed after we land though, this driver is going to need a bunch of work anyway!

11

Can we can -O0 before we land it?

thj marked 4 inline comments as done.
  • Tidy up headers
  • Split out debug.h
  • Fix build without debug
  • Manage firmware lifetimes better
  • Change probe priority
sys/modules/iwx/Makefile
10

There is no need for an opt_ for an individual driver's debug flags. Normally if single file we just define them in the .c otherwise if built as module only I also added them to the Makefile. No one but developers (or users debugging but by that they are working on code) will turn them on so no need to spam kernel configs with that.

sys/modules/Makefile
207

unlikely; iwlwifi is restricted by wrking LinuxKPI bts

574

I think given it's a native driver and not restricted by working LinuxKPI currently you ca probably build it unconditionally just as iwx; I am never sure why iwn and iwm were never added as such -- do we expect big/little endian problem with them?

sys/modules/iwx/Makefile
2

No longer needed.

11

@thj do you just want to put a # in front of DEBUG_FLAGS?

thj marked 3 inline comments as done.Wed, Mar 19, 9:43 AM
thj added inline comments.
sys/dev/iwx/if_iwx_debug.h
319

I've split debug out to its own file

sys/modules/Makefile
574

I've moved it to be with iwm. iwn and iwm are only build for systems that support sourceless drivers - i.e. things that need firmware.

I don't really know if this is needed so I default to being consistent

  • Comment out debug flags
  • Remove FreeBSD revision specifier
  • Move iwx to be in the sourcelss block with other intel drivers
  • Remove unused functions from build
This revision is now accepted and ready to land.Mon, Mar 24, 4:21 PM

I left you an email as well.

I know how it goes. Packets go in; packets come out; sometimes it crashes; good enough ;-) Get it in w/ or w/o my patch.
I'll not click on Accept Revision for review as I haven't given it a full cross-read at least but I tested it.. and got 500/250 Mbit/s in the end on an AX200.

BOFH excuse #340: We'll fix that in the next (upgrade, update, patch release, service pack).

sys/dev/iwx/if_iwx.c
3222

If anyone claims to have done 700Mbit/s with this, then the driver internally doesn't even adhere to the channel config:
ifconfig -v wlan0 list chan
shows max VHT/20.

Try this patch as a starter... but we really want to add RADAR/DFS bits for whatever they mean in the defines here.

https://people.freebsd.org/~bz/tmp/20250327-01-iwx.diff

sys/modules/Makefile
806

I locally moved that somewhere to at least allow it on arm64 as well but I think for now it sits good where it is.

sys/modules/iwx/Makefile
8

Given this is still on I wonder why I do not get register dumps...

  • rewrite channel map with patch from bz
  • Add more printing to rate debugging
  • Add an ignore around payload_len
This revision now requires review to proceed.Fri, Mar 28, 10:22 AM
This revision is now accepted and ready to land.Fri, Mar 28, 3:05 PM

So a small note about the copyright in the if_iwx.c file. The history is a bit complicated, and there's been no attempt to clarify the extent to which the derived works have rewritten the other stuff. If there's only boilerplate and fixed register sequences that remain from the early work, that's not covered by copyright law, so the earlier licenses don't apply. If there's creative content from that earliest stuff still, then the older licenses do still have some force. It seems like the intent was to invoke the BSDL option for the Linux driver and create derived works based on BSDL, which were licensed under ISC. But there's always ambiguity in stuff like this when it's a derivative of a derivative of a derivative of a work that's been ported twice (once to OpenBSD and then to FreeBSD).

sys/dev/iwx/if_iwx.c
5

The total copyright and provenance of this driver is a little weak (though it's all there in the OpenBSD history to dig out).

All the OpenBSD stuff is ISC, as is the FreeBSD port.

It's unclear the extent to which reference driver material was included in the original iwn (or earlier?) driver and how much of that remains after it was copied to iwm and then iwx. The most favorable reading is that they just read the code and included the reference because they read it quite intensely and may have therefore had a resulting driver that was too close. It's unclear of code was copied, or just know-how and if code was copied if it was a fair use under various copyright doctrines that ensure that facts aren't covered by copyright, but creative expression is. It would take a rather extensive analysis to judge this, and the result might be ambiguous and unsatisfying.

My advice would be to add a SPDX-License-Identifier: BSD AND ISC since there's an intent to declare that the Damien and/or Stefan was opting to take whatever IP from iwlwifi using the BSD licensing only and creating the derivative work that way. If you want to be more cautious, (BSD OR GPL) AND ISC wouldn't be terrible. I'd add whatever you decide as a separate commit AFTER we push the driver in since it's advisory and we can explain the nuance of our decision in the commit message (which seems out of place for the initial port)..

I'd also consider a 2025 copyright date since this is still in 'draft' form.

  • Add spdx tags and FreeBSD Foundation Copyright
This revision now requires review to proceed.Fri, Mar 28, 4:09 PM

I'm waiting for an ack on spdx tags from @emaste or @imp and I'm not going to commit at 4 on a Friday :D

sys/dev/iwx/if_iwx.c
4

So this is wrong. You need it to describe the entire file, which is either BSD-3-Clause AND ISC (since it declares it was derived from the BSD-licensed file, opting for only BSD for the original dual licensed file, which is an option). Or it's (GPL-2.0-only OR BSD-3-Clause) AND ISC.

Note: Since there's so many licenses here, this can't be used as a shortcut for these changes.

14

This needs a license. And since we have so many other licenses in the file, the project policy is you can't use simple SPDX here.
I'd get the Foundations' permission to just use ISC copyright, since that's what all the others are (in reality).

* Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
sys/dev/iwx/if_iwxreg.h
2–4

See comments on if_iwx.c and do the same here.

13

See comments on if_iwx.c and do the same here.

sys/dev/iwx/if_iwxvar.h
2–4

See comments on if_iwx.c and do the same here.

13

See comments on if_iwx.c and do the same here.

sys/dev/iwx/if_iwx.c
4

I don't know where history of all this started, as I always said tracing any of this back to the original is virtually impossible given I am not aware of any git hashes from Linux in the OpenBSD history this was originally based on.

For what it's worth, the non-GPL-only code in iwlwifi got "GPL-2.0 OR BSD-3-Clause", no "-only". The files which are GPL-only are "SPDX-License-Identifier: GPL-2.0-only" of which there are three or so which would still be relevant for this work I assume but if started from iwn or earlier might have been almost exclusively that?

"GPL-2.0" without only isn't in the spdx license list so I would like to avoid that. I think only here means "not and later" rather than it being a file exclusively licensed with the gpl.

I have removed the foundation copyright from iwx_var.h and iwx_reg.h - on reflection I don't think I have made significant changes to these files and I was too harsh with my blanket addition. I have added spdx identifiers to them which I think matches the license content in the preamble of the files.

I think I have made the recommended changes, but I'll wait for an ack from Ed before landing.

  • Update copyright statements based on advice from review

OK for spdx/license info

sys/dev/iwx/if_iwx_debug.h
6

We could delete the extra blank line here

This revision was not accepted when it landed; it landed in state Needs Review.Mon, Mar 31, 12:43 PM
This revision was automatically updated to reflect the committed changes.