project/iwinfo.git
8 months agodevices: add device id for MediaTek MT7601U
Shiji Yang [Sun, 10 Mar 2024 10:25:10 +0000 (18:25 +0800)]
devices: add device id for MediaTek MT7601U

Add device id for MediaTek MT7601U 802.11n 1x1 USB Wi-Fi adapter.

Signed-off-by: Shiji Yang <yanshiji66@qq.com>
8 months agodevices: add add Qualcomm Atheros IPQ6018 WiSoC compatible
Vladdrako [Fri, 8 Mar 2024 13:17:12 +0000 (15:17 +0200)]
devices: add add Qualcomm Atheros IPQ6018 WiSoC compatible

This adds detection for the Qualcomm Atheros IPQ6018 WiSoC.

Signed-off-by: Vladyslav Andreichykov <vladdrako007@gmail.com>
9 months agodevices: add device id for Qualcomm Atheros QCA6174
Martin Schiller [Wed, 7 Feb 2024 08:34:50 +0000 (09:34 +0100)]
devices: add device id for Qualcomm Atheros QCA6174

This adds the device id for the Qualcomm Atheros QCA6174 found on a
jjPlus JWW6051 M.2 adapter.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
12 months agodevices: add device id for Cypress CYW43455
Marty Jones [Sat, 4 Nov 2023 23:42:32 +0000 (19:42 -0400)]
devices: add device id for Cypress CYW43455

Add Cypress CYW43455 id variant found on the Raspberry Pi 5.

Signed-off-by: Marty Jones <mj8263788@gmail.com>
12 months agodevices: add device id for MediaTek MT7916AN
Dennis Schmalacker [Fri, 13 Oct 2023 17:08:53 +0000 (19:08 +0200)]
devices: add device id for MediaTek MT7916AN

MediaTek MT7916AN (Filogic 630) is a DBDC 2*2 G-Band and 3*3 B-Band
chip found on the AsiaRF AW7916-NPD mini PCIe Module.

Add the additional ID.

Signed-off-by: Dennis Schmalacker <dennis-on-github@dclabs.de>
[ improve commit description, wrap to 75 char ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
17 months agolib: report byte counters as 64 bit values
Thomas Weißschuh [Mon, 15 May 2023 14:54:27 +0000 (16:54 +0200)]
lib: report byte counters as 64 bit values

The 32bit counter can only count to 4GiB before wrapping.
Switching to the 64bit variant avoids this issue.

In practice some users are interpreting the counter values as signed
integer bringing down the usable range for 32bit values down to only
2GiB.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
17 months agonl80211: constify a few arrays
Thomas Weißschuh [Mon, 15 May 2023 14:45:30 +0000 (16:45 +0200)]
nl80211: constify a few arrays

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
18 months agodevices: add device id for Atheros AR9287 and AR9380
Shiji Yang [Mon, 22 May 2023 14:23:39 +0000 (22:23 +0800)]
devices: add device id for Atheros AR9287 and AR9380

Atheros AR9287 is a 2*2 PCI wireless chip used in TP-Link TL-WR841N v7.
Atheros AR9380 is a 3*3 PCI wireless chip used in TP-Link TL-WR2543N v1.

Signed-off-by: Shiji Yang <yangshiji66@qq.com>
18 months agodevices: add MediaTek MT7981 WMAC compatible
David Bauer [Wed, 17 May 2023 20:41:40 +0000 (22:41 +0200)]
devices: add MediaTek MT7981 WMAC compatible

This adds detection for the MediaTek MT7981 WMAC.

Signed-off-by: David Bauer <mail@david-bauer.net>
21 months agodevices: add compatible strings for Ralink WiSoCs
Daniel Golle [Wed, 8 Feb 2023 00:41:31 +0000 (00:41 +0000)]
devices: add compatible strings for Ralink WiSoCs

Now that iwinfo_hardware_id_from_mtd() is no longer called in case
a compatible string is found we need to add those to devices.txt.
Unfortunately some WiSoCs share the same dtsi and hence also the
compatible string, so detection is now slightly wrong for those,
as they were previously identified parsing the MTD EEPROM data.
As a reminder that this will need fixing, the following entries
have been left in devices.txt:
0x1814 0x3051 0x1814 0x0007    0      0  "Ralink"   "Rt3051"
0x1814 0x3052 0x1814 0x0008    0      0  "Ralink"   "Rt3052"
0x1814 0x3350 0x1814 0x000b    0      0  "Ralink"   "Rt3350"
0x1814 0x3662 0x1814 0x000d    0      0  "Ralink"   "Rt3662"

Fixes: fac0787 ("devices: add support for declaring compatible matched devices")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
21 months agonl80211: restore iterating over all devices in nl80211_phy2ifname()
Andre Heider [Mon, 30 Jan 2023 18:57:57 +0000 (19:57 +0100)]
nl80211: restore iterating over all devices in nl80211_phy2ifname()

This reverts to the earlier behaviour, because:
* phys can be renamed, which breaks hardcoding "phy%d"
* /sys/class/ieee80211/*/device can return networks of other phys,
  since "device" is a symlink which can have multiple phys

The earlier behaviour fixes both points.

Fixes: 6194aaf0 "nl80211: simplify iterating over phy's devices"
Signed-off-by: Andre Heider <a.heider@gmail.com>
Tested-by: Olcay Korkmaz <nuke_mania@hotmail.com>
[ drop extra Fixes tag related to openwrt issue ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
22 months agoiwinfo: readd missing define for IWINFO_AUTH in header
Christian Marangi [Mon, 23 Jan 2023 12:44:22 +0000 (13:44 +0100)]
iwinfo: readd missing define for IWINFO_AUTH in header

In converting the iwinfo header to enum-define pattern the IWINFO_AUTH
define conversion was wrongly dropped. Readd the missing define to fix
iwinfo always reporting None as encryption.

Fixes: 7e3d7ded29d7 ("iwinfo: reorganize iwinfo header to enum and defines")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
22 months agocli: print the flags on the frequency list
Andre Heider [Wed, 11 Jan 2023 11:13:44 +0000 (12:13 +0100)]
cli: print the flags on the frequency list

Provide info for each flags applied to the frequency on frequency list
dump.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agolib: add IWINFO_FREQ_FLAG_NAMES
Andre Heider [Wed, 11 Jan 2023 10:39:32 +0000 (11:39 +0100)]
lib: add IWINFO_FREQ_FLAG_NAMES

The same as with the other defines/enums which allow consumers to
iterate over all known ones.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: fix some comments
Andre Heider [Sat, 24 Dec 2022 11:13:59 +0000 (12:13 +0100)]
nl80211: fix some comments

Spelling and indenting fixes.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: prefer non-supplicant-based devices
Andre Heider [Sat, 24 Dec 2022 11:03:01 +0000 (12:03 +0100)]
nl80211: prefer non-supplicant-based devices

If a phy has multiple devices, prefer non-supplicant-based ones as per
link_mode, see [0] and [1].

The nl80211 API provides more information than wpa_supplicant/hostapd does,
like HT/VHT operation, which are used by e.g. luci's channel analysis.

[0] https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
[1] https://github.com/openwrt/luci/issues/6167#issuecomment-1364500296

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: simplify iterating over phy's devices
Andre Heider [Sat, 24 Dec 2022 10:53:36 +0000 (11:53 +0100)]
nl80211: simplify iterating over phy's devices

There's no need to iterate over all devices in /sys/class/net and check
if the phy index matches, sysfs already provides per phy devices.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: remove redundant check in nl80211_phy2ifname()
Andre Heider [Sat, 24 Dec 2022 10:45:43 +0000 (11:45 +0100)]
nl80211: remove redundant check in nl80211_phy2ifname()

phyidx is already checked for <0 a few lines above.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agocli: print the frequency and band on the scan list
Andre Heider [Thu, 24 Nov 2022 16:37:16 +0000 (17:37 +0100)]
cli: print the frequency and band on the scan list

Provide band and frequency info on scan list dump.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agocli: print the band on the frequency list
Andre Heider [Tue, 22 Nov 2022 08:55:06 +0000 (09:55 +0100)]
cli: print the band on the frequency list

Provide band info on frequency list dump.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: add "mhz" and "band" to iwinfo_scanlist_entry
Andre Heider [Wed, 23 Nov 2022 14:21:57 +0000 (15:21 +0100)]
nl80211: add "mhz" and "band" to iwinfo_scanlist_entry

Providing the channel alone isn't clear as there're overlapping channels
on e.g. band 2 and 6.

Note: This changes the ABI.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: add "band" to iwinfo_freqlist_entry
Andre Heider [Mon, 21 Nov 2022 12:48:43 +0000 (13:48 +0100)]
nl80211: add "band" to iwinfo_freqlist_entry

So that consumers don't have to fiddle around with mapping frequencies
to bands, which everyone seems to do a little differently.

Note: This changes the ABI.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agonl80211: add support for radiation and indoor chan restriction
Christian Marangi [Fri, 21 Jan 2022 00:07:50 +0000 (01:07 +0100)]
nl80211: add support for radiation and indoor chan restriction

Add new 'flags' bits to declare these two channel restrictions.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
22 months agoiwinfo: reorganize iwinfo header to enum and defines
Christian Marangi [Fri, 20 Jan 2023 15:53:38 +0000 (16:53 +0100)]
iwinfo: reorganize iwinfo header to enum and defines

iwinfo.h have a mixed way to declare defines, some use enum, some define
bits in enum and other have their own special way. In all of this case
the count of all this defines is hardcoded to an arbitrary number.

To make code less error prone, convert everything to a common pattern
and use enum way to calculate the count of each flags.

Also drop defining number for each flag and just declare that the enum
starts from 0.

Move the related char array just below the define declaration to improve
code readability.

No functionl change intended.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
22 months agodevices: add USB devices supported by the mt76 driver
Andre Heider [Wed, 18 Jan 2023 13:24:38 +0000 (14:24 +0100)]
devices: add USB devices supported by the mt76 driver

A nice and stable working mainline driver deserves first class support,
and this adds all USB devices supported by it.

The PIDs/VIDs are taken directly from the driver, in the very same order
to make future syncs easy.

The single left out entry is the unknown 148f:760a.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agoutils: skip comment lines when parsing devices.txt
Andre Heider [Wed, 18 Jan 2023 13:24:37 +0000 (14:24 +0100)]
utils: skip comment lines when parsing devices.txt

Just a small optimization, skip the line early if it starts with a #.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agocli: describe USB devices as such
Andre Heider [Wed, 18 Jan 2023 13:24:36 +0000 (14:24 +0100)]
cli: describe USB devices as such

This makes it clear if the hardware is embedded or usb/pci based.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agodevices: add MediaTek MT7628 card
Andre Heider [Wed, 18 Jan 2023 13:24:35 +0000 (14:24 +0100)]
devices: add MediaTek MT7628 card

This adds the single missing compatible supported by the mt76 driver,
which is used by a bunch of ramips mt7628an devices.

Signed-off-by: Andre Heider <a.heider@gmail.com>
22 months agodevices: add support for declaring compatible matched devices
Jo-Philipp Wich [Mon, 9 Jan 2023 19:49:53 +0000 (20:49 +0100)]
devices: add support for declaring compatible matched devices

Some device have embedded wifi card that are not connected with usb or
internall with pci. Such device have fake device_id and only the
vendor_id actually reflect something real but internally they don't have
any id and are just matched by the node compatible binding in DT.

We currently match this with a big if-else to match the single devices
but this can be improved and be matched directly in devices.txt

Rework this so that we can drop the big if-else and move the matching
to devices.txt

When a device is matched using compatible in iwinfo the hardware will be
flagged as embedded and won't print empty ids.

Update devices.txt by migrating all the compatible matching device from
fake id to compatible matching.

Tested-by: Christian Marangi <ansuelsmth@gmail.com> # ipq4019
Co-developed-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Tested-by: Robert Marko <robimarko@gmail.com> # ipq8074
Reviewed-by: Andre Heider <a.heider@gmail.com>
22 months agodevices: add Qualcomm Atheros QCN6024/9024/9074 cards
Robert Marko [Fri, 6 Jan 2023 16:33:55 +0000 (17:33 +0100)]
devices: add Qualcomm Atheros QCN6024/9024/9074 cards

Add Qualcomm Atheros QCN6024/9024/9074 PCI ID, they all are compatible and
use the same ID.

Signed-off-by: Robert Marko <robimarko@gmail.com>
22 months agoiwinfo: devices: add Qualcomm Atheros IPQ8074 WiSoC
Robert Marko [Fri, 6 Jan 2023 09:56:54 +0000 (10:56 +0100)]
iwinfo: devices: add Qualcomm Atheros IPQ8074 WiSoC

Add detection of the Qualcomm Atheros IPQ8074 WiSoC using the compatible
string from device tree.

Signed-off-by: Robert Marko <robimarko@gmail.com>
23 months agocli: print current HT mode
Andre Heider [Mon, 21 Nov 2022 10:22:15 +0000 (11:22 +0100)]
cli: print current HT mode

This was present in the ubus call provided by rpcd, but not the cli.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agocli: use IWINFO_HTMODE_COUNT
Andre Heider [Mon, 21 Nov 2022 09:58:14 +0000 (10:58 +0100)]
cli: use IWINFO_HTMODE_COUNT

ARRAY_SIZE works too, but just the sake of consistency.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agocli: use IWINFO_KMGMT_NAMES
Andre Heider [Mon, 21 Nov 2022 09:12:27 +0000 (10:12 +0100)]
cli: use IWINFO_KMGMT_NAMES

There's no need to duplicate the strings or even miss new ones.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agocli: use IWINFO_CIPHER_NAMES
Andre Heider [Mon, 21 Nov 2022 08:59:09 +0000 (09:59 +0100)]
cli: use IWINFO_CIPHER_NAMES

There's no need to duplicate the strings or even miss new ones.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agocli: fix printing the scan channel width
Andre Heider [Mon, 21 Nov 2022 17:56:38 +0000 (18:56 +0100)]
cli: fix printing the scan channel width

The "chan_width" var contains an index, not a value.

While at it, make the 40 and 2040 description shorter and clearer.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agocli: fix marking the active channel
Andre Heider [Thu, 17 Nov 2022 20:59:46 +0000 (21:59 +0100)]
cli: fix marking the active channel

Match by frequency and not by channel as the radio might have the same
channel on multiple bands:

$ iwinfo radio0 freqlist
[snip]
* 2.432 GHz (Channel 5)
[snip]
* 5.975 GHz (Channel 5)
[snip]

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agoutils: add iwinfo_band2ghz() and iwinfo_ghz2band() helpers
Andre Heider [Tue, 22 Nov 2022 08:39:12 +0000 (09:39 +0100)]
utils: add iwinfo_band2ghz() and iwinfo_ghz2band() helpers

To classify bands, to be used as ubus values.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agoutils: add helper functions to get names by values
Andre Heider [Tue, 22 Nov 2022 08:45:23 +0000 (09:45 +0100)]
utils: add helper functions to get names by values

Some defines/enums use bits, while some functions only set a single one.
Make it less painful to get to a name for those.

This avoids hardcoding bit lists for consumers.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agoutils: add iwinfo_htmode_is_{ht|vht|he} helpers
Andre Heider [Mon, 21 Nov 2022 16:50:09 +0000 (17:50 +0100)]
utils: add iwinfo_htmode_is_{ht|vht|he} helpers

Small and useful functions which allow to clear up some consumers.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agoutils: add and use iwinfo_format_hwmodes()
Andre Heider [Mon, 21 Nov 2022 16:27:20 +0000 (17:27 +0100)]
utils: add and use iwinfo_format_hwmodes()

Unify how hwmodes are displayed, e.g.:
"802.11ac/ax/b/g/n" instead of "802.11bgnacax".

Luci currently uses a natural sort order, but that probably doesn't work
as intended once "be" is added, so let's do this here.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agolib: add IWINFO_80211_COUNT and IWINFO_80211_NAMES
Andre Heider [Mon, 21 Nov 2022 16:26:19 +0000 (17:26 +0100)]
lib: add IWINFO_80211_COUNT and IWINFO_80211_NAMES

The same as with the other defines/enums which allow consumers to
iterate over all known ones.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agolib: add IWINFO_BAND_COUNT and IWINFO_BAND_NAMES
Andre Heider [Mon, 21 Nov 2022 12:50:16 +0000 (13:50 +0100)]
lib: add IWINFO_BAND_COUNT and IWINFO_BAND_NAMES

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agolib: use common IWINFO_CIPHER_NAMES strings
Andre Heider [Mon, 21 Nov 2022 08:49:05 +0000 (09:49 +0100)]
lib: use common IWINFO_CIPHER_NAMES strings

Use a hyphen for the WEP cipher names, just as the others. Not that
anyone cares anymore, but this let's us use this array instead of
everyone fixing it up on their own.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agolib: add IWINFO_OPMODE_COUNT and use it for IWINFO_OPMODE_NAMES
Andre Heider [Mon, 21 Nov 2022 09:11:13 +0000 (10:11 +0100)]
lib: add IWINFO_OPMODE_COUNT and use it for IWINFO_OPMODE_NAMES

Match the other string arrays, which allows us to consistently loop over them.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agolib: constify and fixup the string array definitions
Andre Heider [Mon, 21 Nov 2022 09:07:37 +0000 (10:07 +0100)]
lib: constify and fixup the string array definitions

Match their declarations as per the header.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agonl80211: mark frequencies where HE operation in not allowed
Andre Heider [Sun, 20 Nov 2022 15:52:42 +0000 (16:52 +0100)]
nl80211: mark frequencies where HE operation in not allowed

Repurpose the IWINFO_FREQ_NO_2160MHZ define for that, which was
introduced but never used. nl80211 doesn't have such a flag either.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agonl80211: add support for HE htmodes
Andre Heider [Fri, 18 Nov 2022 11:14:47 +0000 (12:14 +0100)]
nl80211: add support for HE htmodes

Query hostapd or wpa_supplicant to determine if 802.11ax is enabled.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agonl80211: properly get available bands for the hwmode
Andre Heider [Fri, 18 Nov 2022 11:12:09 +0000 (12:12 +0100)]
nl80211: properly get available bands for the hwmode

Just use the already provided info instead of mapping frequencies.

Fixes mapping lower frequencies of the 6G band, which starts at 5935MHz.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agonl80211: update the kernel header nl80211.h
Andre Heider [Sun, 20 Nov 2022 21:48:23 +0000 (22:48 +0100)]
nl80211: update the kernel header nl80211.h

Required for NL80211_BAND_6GHZ and NL80211_FREQUENCY_ATTR_NO_HE.

Taken from the v5.15.74 release, which is the current version of the
used mac80211 package.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agonl80211: fix frequency/channel conversion for the 6G band
Andre Heider [Thu, 17 Nov 2022 20:02:16 +0000 (21:02 +0100)]
nl80211: fix frequency/channel conversion for the 6G band

Update using current linux sources, which this was apparently
based on.

Signed-off-by: Andre Heider <a.heider@gmail.com>
[don't fail if no ieee80211ax option is present]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
23 months agonl80211: don't guess if a name is an ifname
Andre Heider [Tue, 15 Nov 2022 13:12:41 +0000 (14:12 +0100)]
nl80211: don't guess if a name is an ifname

It's too slow to do it all over again and again, especially with e.g.
luci constantly polling.

Before:
$ time iwinfo phy0 info
real 0m 0.54s
$ time iwinfo radio0 info
real 0m 0.70s
$ time ubus call luci-rpc getWirelessDevices
real 0m 0.67s

After:
$ time iwinfo phy0 info
real 0m 0.04s
$ time iwinfo radio0 info
real 0m 0.09s
$ time ubus call luci-rpc getWirelessDevices
real 0m 0.17s

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agodevices: add usb device MediaTek MT7921AU
Andre Heider [Sun, 13 Nov 2022 14:39:27 +0000 (15:39 +0100)]
devices: add usb device MediaTek MT7921AU

Add USB PID/VID as found on e.g. Comfast CF-953AX.

Signed-off-by: Andre Heider <a.heider@gmail.com>
[rebase onto current master]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
23 months agonl80211: add ability to describe USB devices
Jo-Philipp Wich [Thu, 15 Dec 2022 19:45:20 +0000 (20:45 +0100)]
nl80211: add ability to describe USB devices

Treat USB vendor and product IDs like PCI subsystem vendor and device IDs
respectively to allow describing USB devices as `0000 0000 $vid $pid` in
the hardware database.

As a side effect, this also skips potentially expensive MTD lookups on
embedded devices with plugged in USB radios.

With a 5.15 kernel, such MTD lookups even spam dmesg with:

    mtdblock: MTD device 'factory' is NAND, please consider using UBI block devices instead.

This fix speeds up iwinfo considerably on affected systems:

Before:
sys     0m 3.56s

After:
sys     0m 0.09s

Suggested-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
23 months agonl80211: remove ancient wpa_supplicant ctrl socket path
Andre Heider [Sun, 20 Nov 2022 16:45:11 +0000 (17:45 +0100)]
nl80211: remove ancient wpa_supplicant ctrl socket path

This isn't required nor used anymore, and it's been +8 years.

See
"735a03be: iwinfo: adjust for changed wpa_supplicant control socket path"
on the main repository.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agonl80211: fix wpa supplicant ctrl socket permissions
Andre Heider [Sun, 13 Nov 2022 20:11:06 +0000 (21:11 +0100)]
nl80211: fix wpa supplicant ctrl socket permissions

No data at all can currently be read from the control socket.
Set up the permission exactly like hostapd's wpa_cli utility to fix it.

Among other this fixes a mesh's encryption being shown as "None".

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wdangling-else warnings
Andre Heider [Wed, 23 Nov 2022 13:43:13 +0000 (14:43 +0100)]
fix -Wdangling-else warnings

It's less confusing with braces.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wreturn-type warning
Andre Heider [Wed, 23 Nov 2022 13:40:24 +0000 (14:40 +0100)]
fix -Wreturn-type warning

The function doesn't return anything nor does any caller expect
anything.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wpointer-sign warning
Andre Heider [Wed, 23 Nov 2022 13:38:37 +0000 (14:38 +0100)]
fix -Wpointer-sign warning

sb.ssid is buf casted to unsigned char, just use that instead of casting
it back.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wmaybe-uninitialized warning
Andre Heider [Wed, 23 Nov 2022 13:26:41 +0000 (14:26 +0100)]
fix -Wmaybe-uninitialized warning

All previous cases not hit, which means no scan was possible.
Indicate that.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wunused-variable warnings
Andre Heider [Wed, 23 Nov 2022 13:15:08 +0000 (14:15 +0100)]
fix -Wunused-variable warnings

Remove them.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wduplicate-decl-specifier warnings
Andre Heider [Wed, 23 Nov 2022 13:11:58 +0000 (14:11 +0100)]
fix -Wduplicate-decl-specifier warnings

include/iwinfo.h:209:19: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
  209 | static const char const *ht_secondary_offset[4] = {
      |                   ^~~~~

Constify and move the offenders out of the header.

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agofix -Wformat-truncation warnings
Andre Heider [Fri, 18 Nov 2022 11:29:44 +0000 (12:29 +0100)]
fix -Wformat-truncation warnings

Increase buffer sizes to get rid of e.g.:
iwinfo_nl80211.c:797:41: note: 'snprintf' output between 24 and 279 bytes into a destination of size 64

Signed-off-by: Andre Heider <a.heider@gmail.com>
23 months agoenable useful compiler warnings via -Wall
Andre Heider [Wed, 23 Nov 2022 13:11:31 +0000 (14:11 +0100)]
enable useful compiler warnings via -Wall

There's no reason not to.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2 years agoCorrectly identify key management algorithms starting with "FT-"
Joerg Werner [Sun, 28 Aug 2022 15:21:20 +0000 (17:21 +0200)]
Correctly identify key management algorithms starting with "FT-"

Correctly categorize FT-EAP-SHA384 as WPA3

Signed-off-by: Joerg Werner <schreibubi@gmail.com>
2 years agonl80211: fix issues with renamed wiphy and multiple phy per device
Felix Fietkau [Fri, 14 Oct 2022 08:59:07 +0000 (10:59 +0200)]
nl80211: fix issues with renamed wiphy and multiple phy per device

Remove the assumption that phy names follow the format phy%d and instead look
up the phy index from sysfs properly

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agonl80211: look up the phy name instead of assuming name == phy<idx>
Felix Fietkau [Thu, 22 Sep 2022 12:39:43 +0000 (14:39 +0200)]
nl80211: look up the phy name instead of assuming name == phy<idx>

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agonl80211: fix phy/netdev index lookup
Felix Fietkau [Thu, 22 Sep 2022 12:22:57 +0000 (14:22 +0200)]
nl80211: fix phy/netdev index lookup

Don't assume a fixed naming pattern. Check all options in this order:

- netdev
- phy name
- wifi device in uci

Use the first one that matches

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agonl80211: allow phy names that don't start with 'phy'
Felix Fietkau [Thu, 22 Sep 2022 11:28:57 +0000 (13:28 +0200)]
nl80211: allow phy names that don't start with 'phy'

This is needed for dealing with wiphy renaming

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agoops: make support for wireless extensions optional
Felix Fietkau [Thu, 22 Sep 2022 11:20:15 +0000 (13:20 +0200)]
ops: make support for wireless extensions optional

It is usually not needed anymore and only wastes space

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agodevices: add MediaTek MT7986 WiSoC
Daniel Golle [Mon, 25 Jul 2022 02:17:44 +0000 (04:17 +0200)]
devices: add MediaTek MT7986 WiSoC

Add detection of the MediaTek MT7986 WiSoC using the compatible string
from device tree.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2 years agoAdd support for CCMP-256 and GCMP-256 ciphers
Joerg Werner [Fri, 19 Aug 2022 09:06:22 +0000 (11:06 +0200)]
Add support for CCMP-256 and GCMP-256 ciphers

Signed-off-by: Joerg Werner <schreibubi@gmail.com>
2 years agoiwinfo: Add missing auth_suites mappings for WPA3
Tjeu Kayim [Thu, 28 Jul 2022 08:47:09 +0000 (10:47 +0200)]
iwinfo: Add missing auth_suites mappings for WPA3

`iwinfo.h` says:
    #define IWINFO_KMGMT_COUNT   5
    ...
    extern const char *IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT];

Though only only 3 items are defined. The other two were forgotten
when adding WPA3 support. The `auth_suites` table exposed via Lua
never included the items "SAE" and "OWE" until this commit.

Fixes: f8ef45065207 ("iwinfo: Add support for WPA3")
Signed-off-by: Tjeu Kayim <15987676+TjeuKayim@users.noreply.github.com>
2 years agoiwinfo: nl80211: omit A-hwmode on non-5GHz hardware
David Bauer [Mon, 25 Apr 2022 23:53:51 +0000 (01:53 +0200)]
iwinfo: nl80211: omit A-hwmode on non-5GHz hardware

Don't add the hwmode A for radios which do not support 5GHz operation.
Before, this hwmode was added to all non-VHT radios regardless of their
supported bands.

Fixes commit 562d01532616 ("iwinfo: nl80211: fix hwmode parsing for multi-band NICs")

Signed-off-by: David Bauer <mail@david-bauer.net>
2 years agodevices: remove whitespace
David Bauer [Sun, 24 Apr 2022 21:04:57 +0000 (23:04 +0200)]
devices: remove whitespace

Signed-off-by: David Bauer <mail@david-bauer.net>
2 years agoiwinfo: nl80211: fix hwmode parsing for multi-band NICs
David Bauer [Fri, 22 Apr 2022 21:56:35 +0000 (23:56 +0200)]
iwinfo: nl80211: fix hwmode parsing for multi-band NICs

In case a NIC supports multiple frequency bands, the supported
hw-modelist might not contain all valid hwmodes, as B/G/AD hwmodes are
only included based on the last parsed supported frequency.

In case a radio supports multiple bands, this might result in these
hwmodes not being flagged as supported.

Circumvent this by tracking all seen frequency bands using a bitmask
which later determined which HW modes are listed as supported.

Signed-off-by: David Bauer <mail@david-bauer.net>
2 years agodevices: Add Cypress CYW43455
Hauke Mehrtens [Sun, 16 Jan 2022 19:47:30 +0000 (20:47 +0100)]
devices: Add Cypress CYW43455

This adds the Cypress CYW43455. This device was found on the Raspberry Pi 4.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2 years agodevices: fix AMD RZ608 format
David Bauer [Thu, 6 Jan 2022 01:13:37 +0000 (02:13 +0100)]
devices: fix AMD RZ608 format

Signed-off-by: David Bauer <mail@david-bauer.net>
2 years agodevices: add AMD RZ608 device-id
David Bauer [Sun, 2 Jan 2022 01:32:58 +0000 (02:32 +0100)]
devices: add AMD RZ608 device-id

Signed-off-by: David Bauer <mail@david-bauer.net>
3 years agoiwinfo: rename hardware.txt to devices.txt
Jo-Philipp Wich [Sun, 11 Jul 2021 13:56:35 +0000 (15:56 +0200)]
iwinfo: rename hardware.txt to devices.txt

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agonl80211: fix path compatibility issue
Felix Fietkau [Mon, 28 Jun 2021 13:30:28 +0000 (15:30 +0200)]
nl80211: fix path compatibility issue

The previous shell script implementation accepted shorter path values
that omitted initial parts before the pcie bus node by only checking if
the configured path is included in the determined path
Add support for doing the same thing here

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agoiwinfo: nl80211: fix typo
Felix Fietkau [Wed, 9 Jun 2021 20:12:08 +0000 (22:12 +0200)]
iwinfo: nl80211: fix typo

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agoiwinfo: nl80211: support looking up phy by path=.. and macaddr=...
Felix Fietkau [Wed, 9 Jun 2021 12:21:51 +0000 (14:21 +0200)]
iwinfo: nl80211: support looking up phy by path=.. and macaddr=...

Can be used from within mac80211.sh without the need to reference the uci
config directly

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agoiwinfo: nl80211: use new path lookup function for nl80211_phy_idx_from_uci_path
Felix Fietkau [Wed, 9 Jun 2021 12:03:29 +0000 (14:03 +0200)]
iwinfo: nl80211: use new path lookup function for nl80211_phy_idx_from_uci_path

Fixes issues with multiple phy instances of one device

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agoiwinfo: nl80211: add support for printing the device path for a phy
Felix Fietkau [Wed, 9 Jun 2021 11:57:23 +0000 (13:57 +0200)]
iwinfo: nl80211: add support for printing the device path for a phy

Will be used to replace the shell code from mac80211.sh

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agoiwinfo: add 802.11ax HE rate information
David Bauer [Sat, 17 Apr 2021 21:05:16 +0000 (23:05 +0200)]
iwinfo: add 802.11ax HE rate information

This adds 802.11ax HE specific rate information to iwinfo.

Add fields for HE status of a STA as well as DCM and guard interval
fields specific to HE operation.

Signed-off-by: David Bauer <mail@david-bauer.net>
3 years agoiwinfo: cli: fix hwmode formatting
David Bauer [Tue, 20 Apr 2021 00:22:38 +0000 (02:22 +0200)]
iwinfo: cli: fix hwmode formatting

The placeholder for the 802.11ax hwmode was missing.

Signed-off-by: David Bauer <mail@david-bauer.net>
3 years agoiwinfo: nl80211: perform split wiphy dump
David Bauer [Sun, 18 Apr 2021 23:38:15 +0000 (01:38 +0200)]
iwinfo: nl80211: perform split wiphy dump

Perform a split wiphy dump when acquiring the hw modelist of a mac80211
device. Otherwise HE capabilities are missing from the message.

This is necessary since upstream commit f8d504caa ("nl80211: reduce
non-split wiphy dump size")  (Kernel 5.9).

Signed-off-by: David Bauer <mail@david-bauer.net>
3 years agoiwinfo: add basic IEEE 802.11ax support
David Bauer [Thu, 17 Dec 2020 19:39:56 +0000 (20:39 +0100)]
iwinfo: add basic IEEE 802.11ax support

This adds basic support for IEEE 802.11ax when requesting HW or HT
Modelist for a PHY from iwinfo. This way, applications using iwinfo can
detect HE phys.

Signed-off-by: David Bauer <mail@david-bauer.net>
3 years agoiwinfo: add PCI ID for MediaTek MT7613BE
Stijn Segers [Sat, 30 Jan 2021 20:32:05 +0000 (21:32 +0100)]
iwinfo: add PCI ID for MediaTek MT7613BE

This adds the PCI ID for the MT7613BE series, found in e.g.
the TP-Link EAP235-Wall v1.

Signed-off-by: Stijn Segers <foss@volatilesystems.org>
3 years agoiwinfo: add hardware description for MediaTek MT7622
Daniel Golle [Thu, 28 Jan 2021 22:34:42 +0000 (22:34 +0000)]
iwinfo: add hardware description for MediaTek MT7622

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3 years agobuild: add ability to specify shared object version
Jo-Philipp Wich [Wed, 6 Jan 2021 22:12:46 +0000 (23:12 +0100)]
build: add ability to specify shared object version

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
3 years agoiwinfo: set center chan unsupported for not-nl80211 driver
Ansuel Smith [Wed, 6 Jan 2021 04:54:57 +0000 (05:54 +0100)]
iwinfo: set center chan unsupported for not-nl80211 driver

Declare get_center_chan1 and get_center_chan2 not supported for not
nl80211 driver.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
3 years agoiwinfo: improve center channel handling
Ansuel Smith [Wed, 6 Jan 2021 03:05:37 +0000 (04:05 +0100)]
iwinfo: improve center channel handling

- Improve iwinfo center channel struct position
- Prevent read beyond buffer on malformed data

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
3 years agoiwinfo: add hardware description for QCA MIPS WiSoCs
Daniel Golle [Wed, 6 Jan 2021 16:37:58 +0000 (16:37 +0000)]
iwinfo: add hardware description for QCA MIPS WiSoCs

Add description strings and detection logic for all 6
types of WiFi NICs integrated in QCA MIPS WiSoCs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3 years agoiwinfo: add support for GCMP cipher
Daniel Golle [Tue, 5 Jan 2021 14:21:14 +0000 (14:21 +0000)]
iwinfo: add support for GCMP cipher

Extend support for WPA ciphers by GCMP which is required for 802.11ad.
Breaks ABI as ciphers now needs to be a field of 16 bits instead of 8.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3 years agocli: account for additional digit for frequencies above 10GHz
Daniel Golle [Tue, 5 Jan 2021 15:09:40 +0000 (15:09 +0000)]
cli: account for additional digit for frequencies above 10GHz

When using 802.11ad, the frequency string will no longer fit in the
preallocated buffer of 10 bytes. In the best case this leads to the
'z' character being truncated in the CLI output:
  Mode: Client  Channel: 1 (58.320 GH)

Fix that by allocating a large enough buffer.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
3 years agoiwinfo: export center_chan info for local wifi
Ansuel Smith [Sun, 6 Dec 2020 01:11:16 +0000 (02:11 +0100)]
iwinfo: export center_chan info for local wifi

Iwinfo already export the htmode but there is no way to know where the
channel expan in case a 40Mhz+ channel width is used. Export the center
channels used by the driver to better know the channel utilizzation of
the wifi.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
3 years agoiwinfo: export ht and vht operation in scan results
Ansuel Smith [Sun, 6 Dec 2020 01:11:15 +0000 (02:11 +0100)]
iwinfo: export ht and vht operation in scan results

Export ht and vht operation data in scan results. These additional data
can be usefull to check wifi channel utilizzation by neraby stations.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
3 years agoiwinfo: detect QCA IPQ4019 WiSoC from FDT
Daniel Golle [Tue, 5 Jan 2021 22:08:46 +0000 (22:08 +0000)]
iwinfo: detect QCA IPQ4019 WiSoC from FDT

As it's the most reliable and straight forward way on modern platforms,
detect the hardware ID by checking the 'compatible'-string of non-PCI
(ie. built-in) devices.
As this is only relevant for WiSoCs, there won't be that many records,
so it's not worth making any larger structural changes. Hence just
match the compatible string and translate it into fake PCI IDs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>