Commit graph

184 commits

Author SHA1 Message Date
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
Andre Heider
d6381634c2 fix -Wdangling-else warnings
It's less confusing with braces.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Andre Heider
4aa6c5a45c 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>
2022-12-15 20:07:49 +01:00
Andre Heider
311272660d 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>
2022-12-15 20:07:49 +01:00
Andre Heider
ebd5f84955 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>
2022-12-15 20:07:49 +01:00
Andre Heider
5469898e8b fix -Wunused-variable warnings
Remove them.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Andre Heider
462b679716 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>
2022-12-15 20:07:49 +01:00
Andre Heider
ccaabb4ea4 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>
2022-12-15 20:07:49 +01:00
Andre Heider
50380db79b enable useful compiler warnings via -Wall
There's no reason not to.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:27 +01:00
Joerg Werner
00aab871c5 Correctly identify key management algorithms starting with "FT-"
Correctly categorize FT-EAP-SHA384 as WPA3

Signed-off-by: Joerg Werner <schreibubi@gmail.com>
2022-11-01 17:11:32 +01:00
Felix Fietkau
0496c722f1 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>
2022-10-14 10:59:08 +02:00
Felix Fietkau
4a43b0d40b nl80211: look up the phy name instead of assuming name == phy<idx>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-09-22 14:42:45 +02:00
Felix Fietkau
b7f9f06e15 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>
2022-09-22 14:42:45 +02:00
Felix Fietkau
1f695d9c7f 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>
2022-09-22 13:28:59 +02:00
Felix Fietkau
b3e08c8b5a 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>
2022-09-22 13:20:17 +02:00
Daniel Golle
46f04f3808 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>
2022-08-31 14:08:39 +01:00
Joerg Werner
0dad3e6660 Add support for CCMP-256 and GCMP-256 ciphers
Signed-off-by: Joerg Werner <schreibubi@gmail.com>
2022-08-20 17:59:11 +02:00
Tjeu Kayim
705d3b5cc3 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: f8ef450652 ("iwinfo: Add support for WPA3")
Signed-off-by: Tjeu Kayim <15987676+TjeuKayim@users.noreply.github.com>
2022-08-13 16:54:41 +02:00
David Bauer
dc6847eb5e 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 562d015326 ("iwinfo: nl80211: fix hwmode parsing for multi-band NICs")

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-04-27 00:51:14 +02:00
David Bauer
a479b9b08a devices: remove whitespace
Signed-off-by: David Bauer <mail@david-bauer.net>
2022-04-24 23:04:57 +02:00
David Bauer
562d015326 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>
2022-04-23 11:59:29 +02:00
Hauke Mehrtens
90bfbb9a3a 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>
2022-03-01 20:54:37 +01:00