Commit graph

205 commits

Author SHA1 Message Date
Thomas Weißschuh
65ea345a5b nl80211: constify a few arrays
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 21:57:51 +02:00
Shiji Yang
d1f07cfdf3
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>
2023-05-24 00:50:42 +02:00
David Bauer
c9f5c3f7b5 devices: add MediaTek MT7981 WMAC compatible
This adds detection for the MediaTek MT7981 WMAC.

Signed-off-by: David Bauer <mail@david-bauer.net>
2023-05-17 22:41:40 +02:00
Daniel Golle
b3888b2953
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>
2023-02-08 14:33:48 +00:00
Andre Heider
c7eb8ebe33
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>
2023-02-06 21:31:45 +01:00
Christian Marangi
1e4e709d6f
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: 7e3d7ded29 ("iwinfo: reorganize iwinfo header to enum and defines")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2023-01-23 13:47:49 +01:00
Andre Heider
f766138662
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>
2023-01-20 17:27:00 +01:00
Andre Heider
8ee7971c76
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>
2023-01-20 17:26:59 +01:00
Andre Heider
81184d2763
nl80211: fix some comments
Spelling and indenting fixes.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2023-01-20 17:26:59 +01:00
Andre Heider
2c4ee842e5
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>
2023-01-20 17:26:59 +01:00
Andre Heider
6194aaf052
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>
2023-01-20 17:26:58 +01:00
Andre Heider
acbf4fe47d
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>
2023-01-20 17:26:58 +01:00
Andre Heider
0172c97759
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>
2023-01-20 17:26:58 +01:00
Andre Heider
bbe424f394
cli: print the band on the frequency list
Provide band info on frequency list dump.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2023-01-20 17:26:58 +01:00
Andre Heider
afa147c45a
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>
2023-01-20 17:26:57 +01:00
Andre Heider
0d5ea34245
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>
2023-01-20 17:26:57 +01:00
Christian Marangi
dba0f0690b
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>
2023-01-20 17:26:57 +01:00
Christian Marangi
7e3d7ded29
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>
2023-01-20 17:26:54 +01:00
Andre Heider
9b47b031c0
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>
2023-01-20 16:08:00 +01:00
Andre Heider
c0fda7cf24
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>
2023-01-20 16:08:00 +01:00
Andre Heider
dbc0ee7c57
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>
2023-01-20 16:08:00 +01:00
Andre Heider
891acee618
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>
2023-01-20 16:07:59 +01:00
Jo-Philipp Wich
fac0787ab0
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>
2023-01-10 00:26:50 +01:00
Robert Marko
c7b420a2f3
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>
2023-01-06 17:44:23 +01:00
Robert Marko
5914d7113e
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>
2023-01-06 15:13:10 +01:00
Andre Heider
8d158096a9 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>
2022-12-16 00:09:07 +01:00
Andre Heider
8f86dd69f7 cli: use IWINFO_HTMODE_COUNT
ARRAY_SIZE works too, but just the sake of consistency.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-16 00:09:07 +01:00
Andre Heider
f36b72b00d 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>
2022-12-16 00:09:07 +01:00
Andre Heider
91be7e0d28 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>
2022-12-16 00:09:07 +01:00
Andre Heider
49b6ec91e9 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>
2022-12-16 00:09:07 +01:00
Andre Heider
b1c8873e37 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>
2022-12-16 00:09:07 +01:00
Andre Heider
9e14e643c5 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>
2022-12-16 00:09:07 +01:00
Andre Heider
e084781afc 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>
2022-12-16 00:09:07 +01:00
Andre Heider
d09a77a369 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>
2022-12-16 00:09:07 +01:00
Andre Heider
87529770f6 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>
2022-12-16 00:09:07 +01:00
Andre Heider
02f433e305 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>
2022-12-16 00:09:07 +01:00
Andre Heider
1d30df1929 lib: add IWINFO_BAND_COUNT and IWINFO_BAND_NAMES
Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-16 00:09:07 +01:00
Andre Heider
aefd0ef68f 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>
2022-12-15 23:52:51 +01:00
Andre Heider
a5b30de2b8 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>
2022-12-15 23:52:27 +01:00
Andre Heider
9f29e79eea lib: constify and fixup the string array definitions
Match their declarations as per the header.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 23:52:04 +01:00
Andre Heider
fddc015704 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>
2022-12-15 23:51:47 +01:00
Andre Heider
6d50a7cc0b 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>
2022-12-15 23:44:34 +01:00
Andre Heider
4ba571370d 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>
2022-12-15 23:42:36 +01:00
Andre Heider
91b2ada787 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>
2022-12-15 23:42:32 +01:00
Andre Heider
3f619a5fbe 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>
2022-12-15 23:41:37 +01:00
Andre Heider
a77d915568 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>
2022-12-15 21:22:18 +01:00
Andre Heider
c27ce7113e 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>
2022-12-15 21:21:59 +01:00
Jo-Philipp Wich
14f864eb72 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>
2022-12-15 21:14:57 +01:00
Andre Heider
a5a75fd661 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>
2022-12-15 20:12:41 +01:00
Andre Heider
dd4e1ffeac 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>
2022-12-15 20:11:12 +01:00