summaryrefslogtreecommitdiff
path: root/src/shared/ethtool-util.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use CLEANUP_ERASE() at various placesLennart Poettering2023-01-161-7/+4
| | | | | | Let's use this new macro wherever it makes sense, as it allows us to shorten or clean-up paths, and makes it less likely to miss a return path.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* tree-wide: replace "plural(s)" by "plurals"Zbigniew Jędrzejewski-Szmek2022-10-171-1/+1
| | | | | | | | (s) is just ugly with a vibe of DOS. In most cases just using the normal plural form is more natural and gramatically correct. There are some log_debug() statements left, and texts in foreign licenses or headers. Those are not touched on purpose.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-4/+2
|
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-2/+2
|
* udev/net: support to set MDI-X modeYu Watanabe2022-02-081-3/+64
| | | | Closes #22386.
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-27/+7
|
* ethtool-util: introduce ethtool_get_permanent_hw_addr()Yu Watanabe2021-11-131-12/+9
| | | | And replaces all ethtool_get_permanent_macaddr() with it.
* ethtool-util: let's use userspace types in userspace codeLennart Poettering2021-10-111-2/+2
| | | | | | Using kernel types __u32 is fine for headers shared by the kernel, but if we define something in userspace and only use it in userspace, in our own .c files, let's stick to userspace fixed-length types.
* ethtool-util: make ethtool_set_wol() take passwordYu Watanabe2021-10-061-5/+32
|
* ethtool-util: do not try to enable unsupported WoL optionsYu Watanabe2021-10-061-0/+10
|
* ethtool-util: make wol_options_to_string() not return all flag stringsYu Watanabe2021-10-061-1/+6
|
* ethtool-util: add more network device featuresYu Watanabe2021-09-151-9/+64
| | | | | Then, we can easily add new settings to configure features in .link file.
* ethtool-util: apply tx-checksum-* features at lastYu Watanabe2021-09-151-4/+51
| | | | | | | NET_DEV_FEAT_TX matches multiple features. In the next commit, all features whose strings start with "tx-checksum-" will be added. To make them take precedence over NET_DEV_FEAT_TX, it will be applied only when each explicit feature is not applied.
* ethtool: do not set unavailable or never_changed bitsYu Watanabe2021-09-151-42/+96
|
* ethtool-util: shorten code a bitYu Watanabe2021-09-151-48/+22
| | | | Also fixes a error code in debugging log.
* ethtool-util: use sizeof()Yu Watanabe2021-09-151-10/+10
|
* ethtool: move functionYu Watanabe2021-08-261-125/+125
| | | | I'd like to locate all conf parsers at end of file.
* link: Add support for rx-gro-hw nic featureDaan De Meyer2021-08-201-7/+8
|
* udev: Add support for configuring nic coalescing settingsDaan De Meyer2021-08-201-0/+205
| | | | These are configured via the corresponding ethtool ioctl.
* udev: make RxChannels= or friends also accept "max"Yu Watanabe2021-08-181-111/+59
| | | | | | | | | | Follow-up for 406041b7de767316674eb6a2f98ad466577ce8a4. Also, this makes - the settings accept an empty string, - if the specified value is too large, also use the advertised maximum value. - mention the range of the value in the man page.
* udev: Support "max" string for BufferSize options (#20458)Daan De Meyer2021-08-181-14/+26
| | | | | | | | "max" indicates the hardware advertised maximum queue buffer size should be used. The max sizes can be checked by running `ethtool -g <dev>` (Preset maximums). Since the buffer sizes can't be set to 0 by users, internally we use 0 to indicate that the hardware advertised maximum should be used.
* ethtool: make ethtool_set_features() return earlier when nothing is requestedYu Watanabe2021-08-171-3/+13
|
* ethtool: make the size of 'features' array staticYu Watanabe2021-08-171-1/+1
|
* udev: make WakeOnLan= take multiple featuresYu Watanabe2021-06-081-73/+106
| | | | WAKE_XXX are flag, not enum.
* ethtool-util: drop unused functionYu Watanabe2021-05-231-45/+0
|
* ethtool-util: do not touch anything if nothing is requestedYu Watanabe2021-05-231-124/+130
| | | | And update settings only when it is necessary.
* ethtool-util: disable autonegotiation when speed, duplex, or port is specifiedYu Watanabe2021-05-231-3/+10
| | | | | | And if autonegotiation is enabled, speed, duplex, and port are ignored. Fixes #19625.
* ethtool-util: move and rebreak commentsYu Watanabe2021-05-231-6/+6
|
* ethtool-util: make ethtool_connect() open fd only when it is not openedYu Watanabe2021-05-231-55/+37
|
* ethtool-util: downgrade log levelYu Watanabe2021-05-221-19/+18
| | | | This just hides issue #19625. It will be fixed in later commits.
* tree-wide: use error codes in xxx_from_string()Yu Watanabe2021-02-121-1/+1
|
* ethtool: add two new link modesYu Watanabe2020-12-031-0/+2
|
* ethtool: make ethtool_get_driver() return -ENODATA if ioctl succeeds but ↵Yu Watanabe2020-11-101-0/+3
| | | | | | driver name is empty Inspired by #17532.
* ethtool: add several assertionsYu Watanabe2020-11-101-23/+77
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* Merge pull request #17185 from yuwata/ethtool-updateZbigniew Jędrzejewski-Szmek2020-10-231-15/+38
|\ | | | | ethtool: add several link modes
| * ethtool: add several new link modesYu Watanabe2020-09-281-0/+23
| |
| * ethtool: convert underscore to hyphenYu Watanabe2020-09-281-15/+15
| |
* | ethtool: constify arguments for ethtool_set_xxx()Yu Watanabe2020-09-151-4/+4
|/
* ethtool: downgrade log level when the error will be ignoredYu Watanabe2020-09-101-12/+14
|
* ethtool-util: don't pass error value that isn't used to log_syntaxLennart Poettering2020-09-091-1/+1
|
* Merge pull request #15762 from keszybz/gcc-10-buildZbigniew Jędrzejewski-Szmek2020-05-111-0/+10
|\ | | | | Fix build with -O3 with gcc 10
| * shared/ethtool-util: hush gcc warnings about array boundsZbigniew Jędrzejewski-Szmek2020-05-111-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [127/1355] Compiling C object 'src/shared/5afaae1@@systemd-shared-245@sta/ethtool-util.c.o' ../src/shared/ethtool-util.c: In function ‘ethtool_get_permanent_macaddr’: ../src/shared/ethtool-util.c:260:60: warning: array subscript 5 is outside the bounds of an interior zero-length array ‘__u8[0]’ {aka ‘unsigned char[]’} [-Wzero-length-bounds] 260 | ret->ether_addr_octet[i] = epaddr.addr.data[i]; | ~~~~~~~~~~~~~~~~^~~ In file included from ../src/shared/ethtool-util.c:5: ../src/shared/linux/ethtool.h:704:7: note: while referencing ‘data’ 704 | __u8 data[0]; | ^~~~ ../src/shared/ethtool-util.c: In function ‘ethtool_set_features’: ../src/shared/ethtool-util.c:488:31: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[]’} [-Wzero-length-bounds] 488 | len = buffer.info.data[0]; | ~~~~~~~~~~~~~~~~^~~ In file included from ../src/shared/ethtool-util.c:5: ../src/shared/linux/ethtool.h:631:8: note: while referencing ‘data’ 631 | __u32 data[0]; | ^~~~ The kernel should not define the length of the array, but it does. We can't fix that, so let's use a cast to avoid the warning. For https://github.com/systemd/systemd/issues/6119#issuecomment-626073743. v2: - use #pragma instead of a cast. It seems the cast only works in some cases, and gcc is "smart" enough to see beyond the cast. Unfortunately clang does not support this warning, so we need to do a config check whether to try to suppress.
* | networkctl: use uint64_t for link speed throughoutнаб2020-05-091-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | format-table used size_t/uint64_t interchangeably for TABLE_BPS, and ethtool-util used SIZE_MAX to indicate SPEED_UNKNOWN, which worked only on ABIs with 64-bit pointers. For example, the tg3 driver returns SPEED_UNKNOWN with no link (cf. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/broadcom/tg3.c?id=3eb2efbea193789397c36f52b17d8692ac79bf68#n12190) which on x32 (and other 32-bit ABIs, presumably) caused "networkctl status" to mark it with "Speed: 4Gbps": nabijaczleweli@szarotka:~$ networkctl --version systemd 245 (245.5-2) nabijaczleweli@szarotka:~$ file $(which networkctl) /bin/networkctl: ELF 32-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /libx32/ld-linux-x32.so.2, BuildID[sha1]=36d684cb1fc8fb5060050d32b969e5aa172fa607, for GNU/Linux 3.4.0, stripped nabijaczleweli@szarotka:~$ networkctl status onboard1 ● 4: onboard1 Driver: tg3 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express Speed: 4Gbps Whereas on 64-bit-pointer ABIs (here: amd64): nabijaczleweli@szarotka:~$ networkctl --version systemd 245 (245.5-2) nabijaczleweli@szarotka:~$ file $(which networkctl) /bin/networkctl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=7a3e406e54968d7774ad467fc3f6a9d35ff7aea2, for GNU/Linux 3.2.0, stripped nabijaczleweli@szarotka:~$ networkctl status onboard1 ● 4: onboard1 Driver: tg3 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express Speed: n/a With this patch, networkctl returns, for x32: nabijaczleweli@szarotka:~$ networkctl --version systemd 245 (245.5-2.1~networkctl-4g-v2) nabijaczleweli@szarotka:~$ file $(which networkctl) /bin/networkctl: ELF 32-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /libx32/ld-linux-x32.so.2, BuildID[sha1]=36d684cb1fc8fb5060050d32b969e5aa172fa607, for GNU/Linux 3.4.0, stripped nabijaczleweli@szarotka:~$ networkctl status onboard1 ● 4: onboard1 Driver: tg3 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express Speed: n/a And for amd64: nabijaczleweli@szarotka:~$ file $(which networkctl) /bin/networkctl: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=7a3e406e54968d7774ad467fc3f6a9d35ff7aea2, for GNU/Linux 3.2.0, stripped nabijaczleweli@szarotka:~$ networkctl status onboard1 ● 4: onboard1 Driver: tg3 Model: NetXtreme BCM5755 Gigabit Ethernet PCI Express Speed: n/a
* link: Allow configuring RX mini and jumbo ring sizes, toonabijaczleweli2020-04-291-0/+16
| | | | | This now covers all ethtool_ringparam configurables (as of v5.6; https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ethtool.h?h=v5.6#n488)
* link: Add units and fix typo in (Rx|Tx)BufferSize= manpage. Clean up the ↵nabijaczleweli2020-04-291-10/+6
| | | | implementation slightly
* udev: support to update flow control parameterYu Watanabe2020-03-071-0/+49
| | | | Closes #14770.
* udev: add {Receive,Transmit}ChecksumOffload= settingsYu Watanabe2020-02-031-24/+29
| | | | Closes #14661.
* network,udev: use uint64_t for bit rateYu Watanabe2020-01-211-2/+2
| | | | Fixes #14620.