aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2024-04-17netlink: fix typo in coalesce_reply_cb()HEADmastergaoxingwang1-1/+1
Add missing colon in coalesce_reply_cb() Fixes: ec573f209dfd (netlink: settings: add netlink support for coalesce tx aggr params) Signed-off-by: Gao Xingwang <gaoxingwang1@huawei.com> Reviewed-by: Heng Qi <hengqi@linux.alibaba.com>
2024-04-17ethtool: add support for RSS input transformationAhmed Zaki3-2/+47
Add support for RSS input transformation [1]. Currently, only symmetric-xor is supported. The user can set the RSS input transformation via: # ethtool -X <dev> xfrm symmetric-xor and sets it off (default) by: # ethtool -X <dev> xfrm none The status of the transformation is reported by a new section at the end of "ethtool -x": # ethtool -x <dev> . . . . RSS hash function: toeplitz: on xor: off crc32: off RSS input transformation: symmetric-xor: on Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/ Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com> Acked-by: Jakub Kicinski <kuba@kernel.org>
2024-01-29update UAPI header copiesMichal Kubecek3-13/+558
Update to kernel v6.8-rc2. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2024-01-29Release version 6.7.Michal Kubecek3-2/+8
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2024-01-28changelog: fix 6.6 release entry dateMichal Kubecek1-1/+1
Drop the extra comma. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2024-01-28update UAPI header copiesMichal Kubecek1-1/+1
Update to kernel v6.7. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2024-01-28ethtool: add support for setting TCP data splitAlexander Lobakin3-0/+28
Add support for controlling header split (aka TCP data split) feature, backed by kernel commit 50d73710715d ("ethtool: add SET for TCP_DATA_SPLIT ringparam"). Command format: ethtool -G|--set-ring devname tcp-data-split [ auto|on|off ] "auto" is defined solely by device's driver. Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
2024-01-28net: ethtool: Add default branch to sff8636_show_all_ioctl switchHao Lan1-4/+5
The current sff8636_show_all_ioctl code uses a switch statement to determine the module type, and exits directly with a return statement when a match is found. However, when the module type cannot be matched, the sff8636_memory_map_init_buf and sff8636_show_all_common functions are executed. This writing style is not intuitive enough. Therefore, this patch adding a default branch in the switch statement to improve the readability of the code. Signed-off-by: Hao Lan <lanhao@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
2024-01-28ethtool: Fix SFF-8472 transceiver module identificationIdo Schimmel1-0/+2
According to table 5-1 in SFF-8472 Rev. 12.4, the Identifier Values for "GBIC" (01h) and "Module soldered to motherboard (ex: SFF)" (02h) are supported by the specification in addition to the current one. Therefore, adjust ethtool to invoke the SFF-8079 parser for them, which will in turn invoke the SFF-8472 parser if the transceiver module supports digital diagnostic monitoring. Without this patch, the EEPROM contents of such transceiver modules will be hex dumped instead of being parsed and printed in a human readable format. Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)") Reported-by: Ivar Simensen <is@datarespons.no> Closes: https://lore.kernel.org/netdev/AM0PR03MB5938EE1722EF2C75112B86F5B9B9A@AM0PR03MB5938.eurprd03.prod.outlook.com/ Tested-by: Ivar Simensen <is@datarespons.no> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2024-01-28netlink: fix -Walloc-sizeSam James1-1/+1
GCC 14 introduces a new -Walloc-size included in -Wextra which gives: ``` netlink/strset.c: In function ‘get_perdev_by_ifindex’: netlink/strset.c:121:16: warning: allocation of insufficient size ‘1’ for type ‘struct perdev_strings’ with size ‘648’ [-Walloc-size] 121 | perdev = calloc(sizeof(*perdev), 1); | ^ ``` The calloc prototype is: ``` void *calloc(size_t nmemb, size_t size); ``` So, just swap the number of members and size arguments to match the prototype, as we're initialising 1 struct of size `sizeof(*perdev)`. GCC then sees we're not doing anything wrong. This is consistent with other use in the codebase too. Signed-off-by: Sam James <sam@gentoo.org> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
2023-11-23update UAPI header copiesMichal Kubecek4-9/+53
Update to kernel v6.7-rc2. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-11-23Release version 6.6.Michal Kubecek3-2/+6
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-11-23ethtool: Add support for more CMIS transceiver modulesIdo Schimmel4-4/+23
Add three more SFF-8024 Identifier Values that according to the standard support the Common Management Interface Specification (CMIS) memory map so that ethtool will be able to dump, parse and print their EEPROM contents. Reported-by: Mark Wang <markwang@nvidia.com> Tested-by: Mark Wang <markwang@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2023-11-23Add missing header files for source distributionFlorian Fainelli1-1/+5
We were not listing all of the uapi header files in ethtool_SOURCES which prevented the proper construction of a distribution source tarball. This is noticeable with older kernel headers where the build would be breaking in such a way: /storage/buildroot/output/arm64/host/bin/aarch64-linux-gcc -DHAVE_CONFIG_H -I. -I./uapi -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wextra -D_POSIX_C_SOURCE=200809L -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=2 -std=gnu11 -c -o netlink/rings.o netlink/rings.c In file included from internal.h:45, from common.c:7: ./uapi/linux/ethtool.h:1507:19: warning: implicit declaration of function '__KERNEL_DIV_ROUND_UP' [-Wimplicit-function-declaration] __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)]; ^~~~~~~~~~~~~~~~~~~~~ ./uapi/linux/ethtool.h:1507:8: error: variably modified 'queue_mask' at file scope __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)]; ^~~~~~~~~~ make[3]: *** [Makefile:1410: common.o] Error 1 make[3]: *** Waiting for unfinished jobs.... Fixes: da2beb7afc25 ("update UAPI header copies") Reported-by: Markus Mayer <mmayer@broadcom.com> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
2023-09-12update UAPI header copiesMichal Kubecek2-0/+5
Update to kernel v6.6-rc1. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-09-12Release version 6.5.Michal Kubecek3-2/+7
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-09-11rxclass: fix a bug in rmgr when searching for empty slotYinjun Zhang1-1/+1
When reverse searching the list in rmgr for a free location the last slot (first slot searched) in the list needs special care as it might not span the full word length. This is done by building a bit-mask covering the not-active parts of the last word and using that to judge if there is a free location in the last word or not. Once that is known searching in the last slot, or to skip it, can be done by the same algorithm as for the other slots in the list. There is a bug in creating the bit-mask for the non-active parts of the last slot where the 0-indexed nature of bit addressing is not taken into account when shifting. This leads to a one-off bug, fix it. Fixes: 8d63f72ccdcb ("Add RX packet classification interface") Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com> Cc: Alexander Duyck <alexanderduyck@meta.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
2023-09-11hns3: add support dump registers for hns3 driverJijie Shao4-1/+834
Add support pretty printer for the registers of hns3 driver. This printer supports PF and VF, and is compatible with hns3 drivers of earlier versions. Sample output: $ ethtool -d eth1 [cmdq_regs] comm_nic_csq_baseaddr_l : 0x48168000 comm_nic_csq_baseaddr_h : 0x00000000 comm_nic_csq_depth : 0x00000080 comm_nic_csq_tail : 0x00000050 comm_nic_csq_head : 0x00000050 comm_nic_crq_baseaddr_l : 0x48170000 comm_nic_crq_baseaddr_h : 0x00000000 comm_nic_crq_depth : 0x00000080 comm_nic_crq_tail : 0x00000000 comm_nic_crq_head : 0x00000000 comm_vector0_cmdq_src : 0x00000000 comm_cmdq_intr_sts : 0x00000000 comm_cmdq_intr_en : 0x00000002 comm_cmdq_intr_gen : 0x00000000 [common_regs] misc_vector_base : 0x00000001 pf_other_int : 0x00000040 misc_reset_sts : 0x00000000 misc_vector_int_sts : 0x00000000 global_reset : 0x00000000 fun_rst_ing : 0x00000000 gro_en : 0x00000001 ... Signed-off-by: Jijie Shao <shaojijie@huawei.com>
2023-08-28update UAPI header copiesMichal Kubecek2-0/+5
Update to kernel v6.5. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-08-28netlink: Allow nl_sset return -EOPNOTSUPP to fallback to do_ssetGang Li1-0/+3
Currently, nl_sset treats any negative value returned by nl_parser (including -EOPNOTSUPP) as `1`. Consequently, netlink_run_handler directly calls exit without returning to main and invoking do_sset through ioctl_init. To fallback to do_sset, this commit allows nl_sset return -EOPNOTSUPP. Fixes: 6c19c0d559c8 ("netlink: use genetlink ops information to decide about fallback") Signed-off-by: Gang Li <gang.li@linux.dev>
2023-07-01Release version 6.4.Michal Kubecek3-2/+9
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-07-01update UAPI header copiesMichal Kubecek1-1/+1
Update to kernel v6.4. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-07-01netlink: fix duplex settingLadislav Michl1-1/+1
nl_parse_lookup_u8 handler is used with duplex_values defined as lookup_entry_u32. While it still works on little endian machines, duplex is always 0 (DUPLEX_HALF) on big endian ones... Fixes: 392b12e38747 ("netlink: add netlink handler for sset (-s)") Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
2023-06-14cmis: report LOL / LOS / Tx FaultJakub Kicinski2-0/+56
Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Tested-by: Ido Schimmel <idosch@nvidia.com>
2023-06-14sff-8636: report LOL / LOS / Tx FaultJakub Kicinski4-0/+57
Report whether Loss of Lock, of Signal and Tx Faults were detected. Print "None" in case no lane has the problem, and per-lane "Yes" / "No" if at least one of the lanes reports true. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Tested-by: Ido Schimmel <idosch@nvidia.com>
2023-06-05drop checks for macros provided in UAPI header copiesMichal Kubecek2-10/+0
Macros NETLINK_GENERIC and __KERNEL_DIV_ROUND_UP are now provided in UAPI header copies so that we no longer need to check if they are defined and provide fallback definitions. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-06-05do not check for strtol() functionMichal Kubecek1-1/+1
The C11 standard guarantees strtol() function to be provided. As we require C11 now, the autoconf check is no longer necessary. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-06-05actually check for C11 compilerMichal Kubecek1-0/+1
Recently added check for C11 compiler only defined macro AX_CHECK_STDC with the check but did not use it so that no check was actually performed. Fixes: 31b7b5ec7edd ("Require a compiler with support for C11 features") Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-06-05add local copies of macros from autoconf-archiveMichal Kubecek3-0/+146
To allow building on systems with old or missing autoconf-archive package, add local copies of macros AX_CHECK_COMPILE_FLAG and AX_APPEND_FLAG. These are needed for AX_CHECK_STDC. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-05-31drop check for big endian typesMichal Kubecek2-14/+0
The build time check for definition of __be16 and __be32 types and their fallback definitions are no longer needed since we added a sanitized copy of linux/types.h which does provide these types (and __be64 which we also need). These were provided to fix build on older systems with outdated system <linux/types.h> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-05-31Require a compiler with support for C11 featuresDario Binacchi1-0/+9
Just like the kernel, which has been using -std=gnu11 for about a year, we also require a C11 compiler for ethtool. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
2023-05-10Merge branch 'next' into masterMichal Kubecek7-15/+37
2023-05-08Release version 6.3.Michal Kubecek3-2/+16
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-05-08Fix argc and argp handling issuesNicholas Vinson1-1/+4
Fixes issues that were originally found using gcc's static analyzer. The flags used to invoke the analyzer are given below. Upon manual review of the results and discussion of the previous patch '[PATCH ethtool 3/3] Fix potential null-pointer deference issues.', it was determined that when using a kernel lacking the execve patch ( see https://github.com/gregkh/linux/commit/dcd46d897adb70d63e025f175a00a89797d31a43), it is possible for argc to be 0 and argp to be an array with only a single NULL entry. This scenario would cause ethtool to read beyond the bounds of the argp array. However, this scenario should not be possible for any Linux kernel released within the last two years should have the execve patch applied. CFLAGS=-march=native -O2 -pipe -fanalyzer \ -Werror=analyzer-va-arg-type-mismatch \ -Werror=analyzer-va-list-exhausted \ -Werror=analyzer-va-list-leak \ -Werror=analyzer-va-list-use-after-va-end CXXCFLAGS=-march=native -O2 \ -pipe -fanalyzer \ -Werror=analyzer-va-arg-type-mismatch \ -Werror=analyzer-va-list-exhausted \ -Werror=analyzer-va-list-leak \ -Werror=analyzer-va-list-use-after-va-end LDFLAGS="-Wl,-O1 -Wl,--as-needed" GCC version is gcc (Gentoo 13.1.0-r1 p1) 13.1.0 Additional Information: https://patchwork.kernel.org/project/netdevbpf/patch/20221208011122.2343363-8-jesse.brandeburg@intel.com/ Signed-off-by: Nicholas Vinson <nvinson234@gmail.com> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
2023-05-08update UAPI header copiesMichal Kubecek2-1/+3
Update to kernel v6.4-rc1. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-05-08Merge branch 'review/next/tx-push-buf-len-v2' into nextMichal Kubecek5-14/+34
Shay Agroskin: This patchset adds a new sub-configuration to ethtool get/set queue params (ethtool -g) called 'tx-push-buf-len'. This configuration specifies the maximum number of bytes of a transmitted packet a driver can push directly to the underlying device ('push' mode). The motivation for pushing some of the bytes to the device has the advantages of - Allowing a smart device to take fast actions based on the packet's header - Reducing latency for small packets that can be copied completely into the device This new param is practically similar to tx-copybreak value that can be set using ethtool's tunable but conceptually serves a different purpose. While tx-copybreak is used to reduce the overhead of DMA mapping and makes no sense to use if less than the whole segment gets copied, tx-push-buf-len allows to improve performance by analyzing the packet's data (usually headers) before performing the DMA operation. The configuration can be queried and set using the commands: $ ethtool -g [interface] # ethtool -G [interface] tx-push-buf-len [number of bytes]
2023-05-08ethtool: Add support for configuring tx-push-buf-lenShay Agroskin4-14/+32
This attribute, which is part of ethtool's ring param configuration allows the user to specify the maximum number of the packet's payload that can be written directly to the device. Example usage: # ethtool -G [interface] tx-push-buf-len [number of bytes] Signed-off-by: Shay Agroskin <shayagr@amazon.com>
2023-05-08update UAPI header copiesShay Agroskin2-0/+3
Update to kernel commit 233eb4e786b5. Signed-off-by: Shay Agroskin <shayagr@amazon.com>
2023-05-08rxclass: Fix return code in rxclass_rule_insDavid Ahern1-1/+1
ethtool is not exiting non-0 when -N fails. e.g., $ sudo ethtool -N eth0 flow-type tcp4 src-ip 1.2.3.4 action 3 loc 1023 rmgr: Cannot insert RX class rule: No such device $ echo $? 0 Update rxclass_rule_ins to return err. Fixes: 8d63f72ccdcb ("Add RX packet classification interface") Cc: Alexander Duyck <alexanderduyck@fb.com> Signed-off-by: David Ahern <dsahern@kernel.org> Acked-by: Alexander Duyck <alexanderduyck@fb.com>
2023-05-08Merge tag 'review/fanalyze-fixes-p2'Michal Kubecek1-6/+18
Nicolas Vinton: This patch series provides updates to correct issues found by gcc -fanalyze. The issues were found by specifying the following flags when building: CFLAGS="-march=native -O2 -pipe -fanalyzer -Werror=analyzer-va-arg-type-mismatch -Werror=analyzer-va-list-exhausted -Werror=analyzer-va-list-leak -Werror=analyzer-va-list-use-after-va-end" CXXCFLAGS="-march=native -O2 -pipe -fanalyzer -Werror=analyzer-va-arg-type-mismatch -Werror=analyzer-va-list-exhausted -Werror=analyzer-va-list-leak -Werror=analyzer-va-list-use-after-va-end" LDFLAGS="-Wl,-O1 -Wl,--as-needed" GCC version is gcc (Gentoo 13.1.0-r1 p1) 13.1.0
2023-05-08Fix reported memory leak.Nicholas Vinson1-5/+17
Found via gcc -fanalyzer. In the function nl_sfeatures() malloc() is called to allocate a block of memory; however, that memory block is never explictily freed. Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
2023-05-08Update FAM syntax to conform to std C.Nicholas Vinson1-1/+1
Found via gcc -fanalyzer. When using the non-standard FAM syntax: uint32_t req_mask[0]; gcc-13 with the -fanalyzer flag generates an internal compiler error. Updating the syntax to use the standard C syntax: uint32_t req_mask[]; works around the gcc bug. Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
2023-05-08netlink: settings: fix netlink support when PLCA is not presentJakub Kicinski1-15/+16
PLCA support threw the PLCA commands as required into the initial support check at the start of nl_gset(). That's not correct. The initial check (AFAIU) queries for the base support in the kernel i.e. support for the commands which correspond to ioctls. If those are not available (presumably very old kernel or kernel without ethtool-netlink) we're better off using the ioctl. For new functionality, however, falling back to ioctl is counterproductive. New functionality (like PLCA) isn't supported via the ioctl, anyway, and we're losing all the other netlink-only functionality (I noticed that the link down statistics are gone). After much deliberation I decided to add a second check for command support in gset_request(). Seems cleanest and if any of the non-required commands narrows the capabilities (e.g. does not support dump) we should just skip it too. Falling back to ioctl would again be a regression. Fixes: cf02fc1b1095 ("add support for IEEE 802.3cg-2019 Clause 148") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-05-08Merge branch 'review/uapi-closure'Michal Kubecek11-0/+1029
Michal Kubecek: On multiple occasion, build on older systems with system <linux/...> headers missing definitions or later changes failed which we either worked around by adding conditional defines or fixed by adding a sanitized copy of such header to uapi/ directory. To prevent these problems, add sanitized copies of all uapi headers that we include from any source file or from an already present uapi header copy (and repeat the process recursively). For this purpose, add the update scripts to the repository, update it to add missing files automatically and run the update.
2023-05-07scripts: add all included uapi files on updateMichal Kubecek1-0/+26
On multiple occasions, we had to add another uapi header copy to fix build on older system where system <linux/...> headers in /usr/include lacked recent definitions or changes. To prevent these problems, update the ethtool-import-uapi script to add all uapi headers included either from a source file or from already copied uapi header which are not present yet. Omit <asm/...> headers as those are architecture dependent so that we cannot pick one random version depending on architecture a developer runs the script on and having all versions and selecting the right one would be too complicated. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-05-07scripts: add ethtool-import-uapiMichal Kubecek1-0/+41
Add script to update sanitized uapi header copies. This script has been available on kernel.org ethtool web for some time, adding it into the repository is going to make it more at hand and will allow tracking its history publicly. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-05-07update UAPI header copiesMichal Kubecek10-0/+962
Update to kernel v6.3-rc7. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-04-19add support for Ethernet PSE and PD devicesOleksij Rempel5-0/+249
This implementation aims to provide compatibility for Ethernet PSE (Power Sourcing Equipment) and PDs (Powered Devices). In its present state, this patch offers generic PSE support for PoDL (Power over Data Lines 802.3bu) specifications while also reserving namespace for PD devices. The infrastructure can be expanded to include 802.3af and 802.3at "Power via the Media Dependent Interface" (or PoE/Power over Ethernet). Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2023-04-19netlink: settings: add netlink support for coalesce tx aggr paramsDaniele Palmas5-0/+37
Add support for getting/setting coalesce tx aggregation parameters (max bytes, max frames, max time). Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2023-02-21Merge branch 'next' into masterMichal Kubecek15-29/+1151
2023-02-21Release version 6.2.Michal Kubecek3-2/+11
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-15help: help text cleanupMichal Kubecek1-11/+11
Minor cleanup of "ethtool --help" output: - add space before closing bracket if there is a space after opening one - drop an orphaned closing bracket - fix an obvious typo in pfc-prevention-tout tunable name Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-15ethtool: add support for get/set rx push in ringparamsShannon Nelson4-0/+13
RX Push was recently added to the kernel's netlink messages along side tx push, and in use in the ionic NIC driver. Add support for "ethtool -G <dev> rx-push on|off" and "ethtool -g <dev>" to set/get rx push mode. Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
2023-02-15update UAPI header copiesMichal Kubecek2-0/+6
Update to kernel commit 1ed32ad4a3cb. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-13help: fix parameter indentationMichal Kubecek1-17/+17
Some parameters in help use spaces rather than tabs for indentation so that they look aligned in the C source but not in "ethtool --help" output. Use tabs everywhere to fix the alignment. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-13Merge branch 'review/mac-merge-v3' into nextMichal Kubecek7-7/+443
Vladimir Oltean: Add support for the following 2 new commands: $ ethtool [ --include-statistics ] --show-mm <eth> $ ethtool --set-mm <eth> [ ... ] as well as for: $ ethtool --include-statistics --show-pause <eth> --src pmac|emac|aggregate $ ethtool --include-statistics --show-pause <eth> --src pmac|emac|aggregate $ ethtool -S <eth> --groups eth-mac eth-phy eth-ctrl rmon -- --src pmac and some modest amount of documentation (the bulk of it is already distributed with the kernel's ethtool netlink rst).
2023-02-13help: document --src argument also in help textMichal Kubecek1-1/+3
New --src argument of -a and -S subcommands is documented only in the manual page, add it also to "ethtool --help" output. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-13ethtool.8: update documentation with MAC Merge related bitsVladimir Oltean1-0/+107
Update the man page with the new --src argument for --show-pause, as well as with the new --show-mm and --set-mm commands. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Pranavi Somisetty <pranavi.somisetty@amd.com>
2023-02-13netlink: pass the source of statistics for port statsVladimir Oltean1-0/+14
Use the ETHTOOL_STATS_SRC_AGGREGATE attribute for the following structured port groups, to allow looking at eMAC and pMAC counters individually: $ ethtool -S eno2 --groups eth-mac eth-phy eth-ctrl rmon -- --src pmac Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Pranavi Somisetty <pranavi.somisetty@amd.com>
2023-02-13netlink: pass the source of statistics for pause statsVladimir Oltean1-5/+28
Support adding and parsing the ETHTOOL_A_PAUSE_STATS_SRC attribute from the request header. $ ethtool -I --show-pause eno2 --src aggregate Pause parameters for eno2: Autonegotiate: on RX: off TX: off RX negotiated: on TX negotiated: on Statistics: tx_pause_frames: 0 rx_pause_frames: 0 $ ethtool -I --show-pause eno0 --src pmac $ ethtool -I --show-pause eno0 --src emac Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Pranavi Somisetty <pranavi.somisetty@amd.com>
2023-02-13netlink: add support for MAC Merge layerVladimir Oltean4-1/+291
$ ethtool --include-statistics --show-mm eno0 MAC merge layer state for eno0: pMAC enabled: on TX enabled: on TX active: on TX minimum fragment size: 60 RX minimum fragment size: 60 Verify enabled: off Verify time: 127 ms Max verify time: 127 ms Verification status: SUCCEEDED Statistics: MACMergeFrameAssErrorCount: 0 MACMergeFrameSmdErrorCount: 0 MACMergeFrameAssOkCount: 0 MACMergeFragCountRx: 0 MACMergeFragCountTx: 0 MACMergeHoldCount: 0 $ ethtool --include-statistics --json --show-mm eno0 [ { "ifname": "eno0", "pmac-enabled": true, "tx-enabled": true, "tx-active": true, "tx-min-frag-size": 60, "rx-min-frag-size": 60, "verify-enabled": true, "verify-time": 127, "max-verify-time": 127, "verify-status": "SUCCEEDED", "statistics": { "MACMergeFrameAssErrorCount": 0, "MACMergeFrameSmdErrorCount": 0, "MACMergeFrameAssOkCount": 0, "MACMergeFragCountRx": 0, "MACMergeFragCountTx": 0, "MACMergeHoldCount": 0 } } ] Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Pranavi Somisetty <pranavi.somisetty@amd.com>
2023-02-13add support for IEEE 802.3cg-2019 Clause 148Piergiorgio Beruto6-2/+480
This patch adds support for the Physical Layer Collision Avoidance Reconciliation Sublayer which was introduced in the IEEE 802.3 standard by the 802.3cg working group in 2019. The ethtool interface has been extended as follows: - show if the device supports PLCA when ethtool is invoked without FLAGS - additionally show what PLCA version is supported - show the current PLCA status - add FLAGS for getting and setting the PLCA configuration Signed-off-by: Piergiorgio Beruto <piergiorgio.beruto@gmail.com> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-01pretty: add message descriptions for PLCA and MAC MergeMichal Kubecek1-0/+49
Add message descriptions for ETHTOOL_MSG_PLCA_* and ETHTOOL_MSG_MM_* message types added recently. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-01add T1S 10Mb/s modes to link mode tablesMichal Kubecek3-0/+15
Add recently added 10baseT1S link modes to man page and ioctl and fallback code paths. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-01update UAPI header copiesMichal Kubecek3-1/+126
Update to kernel commit dd25cfab16e6. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-01pretty: fix RSS attribute constantsMichal Kubecek1-2/+2
Message descriptions for RSS messages refer to ETHTOOL_A_MODULE_* constants which have the same as corresponding ETHTOOL_A_RSS_* ones but fix them anyway to avoid confusion. Fixes: ffab99c1f382 ("netlink: add netlink handler for get rss (-x)") Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2023-02-01Merge branch 'review/get-rss-v6' into masterMichal Kubecek7-37/+294
Sudheer Mogilappagari: These patches add netlink based handler to fetch RSS information using "ethtool -x <eth> [context %d]" command. Output without --json option $ethtool -x eno2 RX flow hash indirection table for eno2 with 8 RX ring(s): 0: 0 0 0 0 0 0 0 0 8: 1 1 1 1 1 1 1 1 ...skip similar lines... 120: 7 7 7 7 7 7 7 7 RSS hash key: be:c3:13:a6:59:9a:c3:c5:d8:60:75:2b:4c:b2:12:cc:5c:4e:34: 8a:f9:ab:16:c7:19:5d:ab:1d:b5:c1:c7:57:c7:a2:e1:2b:e3:ea: 02:60:88:8e:96:ef:2d:64:d2:de:2c:16:72:b6 RSS hash function: toeplitz: on xor: off crc32: off Sample output with json option: $ethtool --json -x eno2 [ { "ifname": "eno2", "rss-indirection-table": [ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1, ...skip similar lines... 7,7,7,7,7,7,7,7 ], "rss-hash-key": [ 190,195,19,166,..], "rss-hash-function": "toeplitz" } ] Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com> --- v6: - Added break after printing hash function in json output - Coding style fixes - Add v6 changelog in cover-letter and resend v5: - Fixed use of same socket for fetching rings info and RSS info - Added checks to test if a field exists before accessing reply message - Refactor print functions and avoid use of ethtool_rxfh structure v4: -Fixed hash function values in example output of commit message. v3: -Made hash key as an array of ints. -Skip json field when not supported. -Made hash function values as true/false instead of on/off -Formatted key strings as per review comments. v2: -Added json support
2023-02-01Merge branch 'review/build-fixes-v2' into masterMichal Kubecek6-24/+415
Florian Fainelli: These 3 patches fix build issues encountered in the 6.1 release with either older kernel headers (pre v4.11) or with musl-libc. In case you want to add a prebuilt toolchain with your release procedure you can use those binaries: https://github.com/Broadcom/stbgcc-8.3/releases/tag/stbgcc-8.3-0.4 Changes in v2: - reworked the first commit to bring in if.h, this is a more invasive change but it allows us to drop the ALTIFNAMSIZ override and it might be easier to maintain moving forward - reworked the third commit to avoid using non standard integer types
2023-02-01netlink: add netlink handler for get rss (-x)Sudheer Mogilappagari5-1/+246
Add support for netlink based "ethtool -x <dev>" command using ETHTOOL_MSG_RSS_GET netlink message. It implements same functionality provided by traditional ETHTOOL_GRSSH subcommand. This displays RSS table, hash key and hash function along with JSON support. Sample output with json option: $ethtool --json -x eno2 [ { "ifname": "eno2", "rss-indirection-table": [ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1, ...skip similar lines... 7,7,7,7,7,7,7,7 ], "rss-hash-key": [ 190,195,19,166,..], "rss-hash-function": "toeplitz" } ] Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
2023-02-01Move code that print rss info into common fileSudheer Mogilappagari3-36/+48
Move function that prints rss indirection table and hash key into common file for use by both netlink and ioctl interface. Changed function argument to be ring count instead of structure. Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
2023-02-01marvell.c: Fix build with musl-libcFlorian Fainelli1-17/+17
After commit 1fa60003a8b8 ("misc: header includes cleanup") we stopped including net/if.h which resolved the proper defines to pull in sys/types.h and provide a definition for u_int32_t. With musl-libc we would need to define _GNU_SOURCE to ensure that sys/types.h does provide a definition for u_int32_t. Rather, just replace u_uint{16,32}_t with the more standard uint{16,32}_t types from stdint.h Fixes: 1fa60003a8b8 ("misc: header includes cleanup") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2023-02-01netlink: Fix maybe uninitialized 'meters' variableFlorian Fainelli1-1/+1
GCC12 warns that 'meters' may be uninitialized, initialize it accordingly. Fixes: 9561db9b76f4 ("Add cable test TDR support") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2023-02-01uapi: Bring in if.hFlorian Fainelli4-6/+397
Bring in if.h from commit eec517cdb481 ("net: Add IF_OPER_TESTING") as well as uapi/linux/hdlc/ioctl.h. Ensure that we define all of the necessary guards to provide updated definitions of ifmap, ifreq and IFNAMSIZ. This resolves build issues with kernel headers < 4.11 which lacked 2618be7dccf8739b89e1906b64bd8d551af351e6 ("uapi: fix linux/if.h userspace compilation errors"). Fixes: 1fa60003a8b8 ("misc: header includes cleanup") Reported-by: Markus Mayer <mmayer@broadcom.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2023-02-01JSON output support for Netlink implementation of --show-ring optionMaxim Georgiev2-10/+26
Add --json support for Netlink implementation of --show-ring option No changes for non-JSON output for this featire. Example output without --json: [ethtool-git]$ /ethtool -g enp9s0u2u1u2 Ring parameters for enp9s0u2u1u2: Pre-set maximums: RX: 4096 RX Mini: n/a RX Jumbo: n/a TX: n/a Current hardware settings: RX: 100 RX Mini: n/a RX Jumbo: n/a TX: n/a RX Buf Len: n/a CQE Size: n/a TX Push: off TCP data split: n/a Same output with --json: [ethtool-git]$ ./ethtool --json -g enp9s0u2u1u2 [ { "ifname": "enp9s0u2u1u2", "rx-max": 4096, "rx": 100, "tx-push": false } ] Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Maxim Georgiev <glipus@gmail.com>
2023-02-01Fixing boolean value output for Netlink reported values in JSON formatMaxim Georgiev1-1/+1
Current implementation of show_bool_val() passes "val" parameter of pointer type as a last parameter to print_bool(): https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/netlink/netlink.h#n131 ... static inline void show_bool_val(const char *key, const char *fmt, uint8_t *val) { if (is_json_context()) { if (val) > print_bool(PRINT_JSON, key, NULL, val); } else { ... print_bool() expects the last parameter to be bool: https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/json_print.c#n153 ... void print_bool(enum output_type type, const char *key, const char *fmt, bool value) { ... Current show_bool_val() implementation converts "val" pointer to bool while calling show_bool_val(). As a result show_bool_val() always prints the value as "true" as long as it gets a non-null pointer to the boolean value, even if the referred boolean value is false. Fixes: 7e5c1ddbe67d ("pause: add --json support") Signed-off-by: Maxim Georgiev <glipus@gmail.com> Reviewed-by: Simon Horman <simon.horman@corigine.com>
2022-12-20add 800Gb/s modes to link mode tablesMichal Kubecek3-0/+30
Add recently added 800000base link modes to man page and ioctl and fallback code paths. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-20JSON output support for Netlink implementation of --show-coalesce optionMaxim Georgiev5-54/+97
Add --json support for Netlink implementation of --show-coalesce option No changes for non-JSON output for this feature. Example output without --json: [ethtool-git]$ sudo ./ethtool --show-coalesce enp9s0u2u1u2 Coalesce parameters for enp9s0u2u1u2: Adaptive RX: n/a TX: n/a stats-block-usecs: n/a sample-interval: n/a pkt-rate-low: n/a pkt-rate-high: n/a rx-usecs: 15000 rx-frames: n/a rx-usecs-irq: n/a rx-frames-irq: n/a tx-usecs: 0 tx-frames: n/a tx-usecs-irq: n/a tx-frames-irq: n/a rx-usecs-low: n/a rx-frame-low: n/a tx-usecs-low: n/a tx-frame-low: n/a rx-usecs-high: n/a rx-frame-high: n/a tx-usecs-high: n/a tx-frame-high: n/a CQE mode RX: n/a TX: n/a Same output with --json: [ethtool-git]$ sudo ./ethtool --json --show-coalesce enp9s0u2u1u2 [ { "ifname": "enp9s0u2u1u2", "rx-usecs": 15000, "tx-usecs": 0 } ] Note that since show_u32() signature was changed, all show_u32() call sites had to be updated. So far only coalesce.c of all the updated files supports JSON output. It's OK for now to mix show_u32() calls with printf() calls in rings.c and channels.c since they can't print JSON yet. Something to fix in future. Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Maxim Georgiev <glipus@gmail.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org>
2022-12-19update UAPI header copiesMichal Kubecek2-1/+16
Update to kernel commit 6feb57c2fd7c. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-19Merge branch 'next' into masterMichal Kubecek4-14/+35
Conflicts: uapi/linux/if_link.h
2022-12-19Release version 6.1.Michal Kubecek3-2/+10
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-19pretty: add message descriptions for PSE and rate matchingMichal Kubecek1-0/+36
Add message descriptions for ETHTOOL_MSG_PSE_{GET,SET} message types and ETHTOOL_A_LINKMODES_RATE_MATCHING attribute, both added in 6.1 cycle. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-16update UAPI header copiesMichal Kubecek4-9/+114
Update to kernel v6.1. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-16misc: header includes cleanupMichal Kubecek4-3/+6
An attempt to build with -std=c99 or -std=c11 revealed few problems with system header includes. - strcasecmp() and strncasecmp() need <strings.h> - ioctl() needs <linux/ioctl.h> - struct ifreq needs <linux/if.h> (unless _USE_MISC is defined) - fileno() needs _POSIX_C_SOURCE - strdup() needs _POSIX_C_SOURCE >= _200809L - inet_aton() would require _DEFAULT_SOURCE Add missing includes and define _POSIX_C_SOURCE=200809L. Replace inet_aton() with inet_pton(); the latter has slightly different semantics (it does not support addresses like "1.2.3" or "1.2") but the function is only called in code which is not actually used. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-04linkstate: report the number of hard link flapsJakub Kicinski1-8/+19
Print the recently added link down event statistics when present. We need to query the netlink policy to know if the stats are supported. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-12-04update UAPI header copiesMichal Kubecek4-15/+130
Update to kernel commit 65e6af6cebef. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-12-04rings: report TCP header-data splitJakub Kicinski1-0/+19
Report if device is in HDS compatible mode or not. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-11-21ethtool.8: formatting follow-up fixMichal Kubecek1-1/+0
The "--groups ..." line describes options for -S subcommand so that it should follow the indentation of "--all-groups" rather than being indented as a new subcommand. Fixes: f9081773be8f ("ethtool.8: fix man page errors") Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-11-21ethtool.8: fix man page errorsXose Vazquez Perez1-3/+3
troff: <standard input>:82: warning: macro '.' not defined troff: <standard input>:252: warning: macro 'RN' not defined troff: <standard input>:698: warning: macro 'E' not defined Cc: Michal Kubecek <mkubecek@suse.cz> Cc: NETDEV ML <netdev@vger.kernel.org> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
2022-11-21fsl_enetc: add support for NXP ENETC driverVladimir Oltean4-2/+266
Add pretty printer for the registers which the enetc PF and VF drivers support since their introduction in kernel v5.1. The selection of registers parsed is the selection exported by the kernel as of v6.1-rc2. Unparsed registers are printed as raw. One register is printed field by field (MAC COMMAND_CONFIG), I didn't have time/interest in printing more than 1. The rest are printed in hex. Sample output: $ ethtool -d eno0 SI mode register: 0x80000000 SI primary MAC address register 0: 0x59f0400 SI primary MAC address register 1: 0x27f6 SI control BDR mode register: 0x40000000 SI control BDR status register: 0x0 SI control BDR base address register 0: 0x8262f000 SI control BDR base address register 1: 0x20 SI control BDR producer index register: 0x3a SI control BDR consumer index register: 0x3a SI control BDR length register: 0x40 SI capability register 0: 0x10080008 SI capability register 1: 0x20002 SI uncorrectable error frame drop count register: 0x0 TX BDR 0 mode register: 0x80000200 TX BDR 0 status register: 0x0 TX BDR 0 base address register 0: 0xebfa0000 TX BDR 0 base address register 1: 0x0 TX BDR 0 producer index register: 0x12 TX BDR 0 consumer index register: 0x12 TX BDR 0 length register: 0x800 TX BDR 0 interrupt enable register: 0x1 TX BDR 0 interrupt coalescing register 0: 0x80000008 TX BDR 0 interrupt coalescing register 1: 0x3a980 (repeats for other TX rings) RX BDR 0 mode register: 0x80000034 RX BDR 0 status register: 0x0 RX BDR 0 buffer size register: 0x680 RX BDR 0 consumer index register: 0x7ff RX BDR 0 base address register 0: 0xec430000 RX BDR 0 base address register 1: 0x0 RX BDR 0 producer index register: 0x0 RX BDR 0 length register: 0x800 RX BDR 0 interrupt enable register: 0x1 RX BDR 0 interrupt coalescing register 0: 0x80000100 RX BDR 0 interrupt coalescing register 1: 0x1 (repeats for other RX rings) Port mode register: 0x70200 Port status register: 0x0 Port SI promiscuous mode register: 0x0 Port SI0 primary MAC address register 0: 0x59f0400 Port SI0 primary MAC address register 1: 0x27f6 Port HTA transmit memory buffer allocation register: 0xc390 Port capability register 0: 0x10101b3c Port capability register 1: 0x2070 Port SI0 configuration register 0: 0x3080008 Port RFS capability register: 0x2 Port traffic class 0 maximum SDU register: 0x2580 Port eMAC Command and Configuration Register: 0x8813 MG 0 RXSTP 0 REG_LOWP_RXETY 0 TX_LOWP_ENA 0 SFD 0 NO_LEN_CHK 0 SEND_IDLE 0 CNT_FRM_EN 0 SWR 0 TXP 1 XGLP 0 TX_ADDR_INS 0 PAUSE_IGN 0 PAUSE_FWD 0 CRC 0 PAD 0 PROMIS 1 WAN 0 RX_EN 1 TX_EN 1 Port eMAC Maximum Frame Length Register: 0x2580 Port eMAC Interface Mode Control Register: 0x1002 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
2022-11-02fix a warning when compiling for 32-bitSergei Antonov1-1/+1
Since BNXT_PCIE_STATS_LEN is size_t: ../../ethtool/bnxt.c:66:68: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] 66 | fprintf(stdout, "Length is too short, expected 0x%lx\n", | ~~^ | | | long unsigned int | %x Fixes: a2f813eeecf1 ("bnxt: Add Broadcom driver support.") Signed-off-by: Sergei Antonov <saproj@gmail.com>
2022-11-01add 10baseT1L mode to link mode tablesMichal Kubecek3-0/+5
Add recently added 10baseT1L/Full link mode to man page and ioctl and fallback code paths. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-10-10Release version 6.0.Michal Kubecek3-2/+5
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-10-10update UAPI header copiesMichal Kubecek4-17/+19
Update to kernel v6.0. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-10-06NEWS: add missing subcommand hintsMichal Kubecek1-4/+4
The NEWS file section for 5.19 release is missing hints telling which subcommand each change is related to. Add them now. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-10-06netlink: settings: Enable link modes advertisement according to lanesIdo Schimmel1-3/+5
When user space does not pass link modes to advertise (via 'ETHTOOL_A_LINKMODES_OURS'), but enables auto-negotiation (via 'ETHTOOL_A_LINKMODES_AUTONEG'), the kernel will instruct the underlying device driver to advertise link modes according to passed speed (via 'ETHTOOL_A_LINKMODES_SPEED'), duplex (via 'ETHTOOL_A_LINKMODES_DUPLEX') or lanes (via 'ETHTOOL_A_LINKMODES_LANES'). It is not currently possible to have ethtool instruct the kernel to perform advertisement solely based on lanes, as ethtool incorrectly instructs the kernel to simply advertise all the "real" link modes [1]. This is caused by ethtool treating both of these commands as equivalent: # ethtool -s swp1 autoneg on # ethtool -s swp1 autoneg on lanes 1 Address this by having ethtool recognize that it should not advertise all the "real" link modes when only "lanes" parameter is specified. Before: # ethtool -s swp1 autoneg on lanes 1 # ethtool swp1 [...] Advertised link modes: 1000baseT/Full 10000baseT/Full 1000baseKX/Full 10000baseKR/Full 10000baseR_FEC 40000baseKR4/Full 40000baseCR4/Full 40000baseSR4/Full 40000baseLR4/Full 25000baseCR/Full 25000baseKR/Full 25000baseSR/Full 50000baseCR2/Full 50000baseKR2/Full 100000baseKR4/Full 100000baseSR4/Full 100000baseCR4/Full 100000baseLR4_ER4/Full [...] After: # ethtool -s swp1 autoneg on lanes 1 # ethtool swp1 [...] Advertised link modes: 1000baseT/Full 10000baseT/Full 1000baseKX/Full 10000baseKR/Full 10000baseR_FEC 25000baseCR/Full 25000baseKR/Full 25000baseSR/Full 10000baseCR/Full 10000baseSR/Full 10000baseLR/Full 10000baseER/Full 50000baseKR/Full 50000baseSR/Full 50000baseCR/Full 50000baseLR_ER_FR/Full 50000baseDR/Full [1] # ethtool --debug 0xff -s swp1 autoneg on lanes 1 [...] sending genetlink packet (96 bytes): msg length 96 ethool ETHTOOL_MSG_LINKMODES_SET ETHTOOL_MSG_LINKMODES_SET ETHTOOL_A_LINKMODES_HEADER ETHTOOL_A_HEADER_DEV_NAME = "swp1" ETHTOOL_A_LINKMODES_AUTONEG = on ETHTOOL_A_LINKMODES_LANES = 1 ETHTOOL_A_LINKMODES_OURS ETHTOOL_A_BITSET_SIZE = 93 ETHTOOL_A_BITSET_VALUE = 20:10:9a:87 ff:5d:f0:ff e7:03:00:00 ETHTOOL_A_BITSET_MASK = 20:10:9a:87 ff:5d:f0:ff e7:03:00:00 [...] Reported-by: Maksym Yaremchuk <maksymy@nvidia.com> Tested-by: Maksym Yaremchuk <maksymy@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2022-08-22Release version 5.19.v5.19Michal Kubecek3-2/+9
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-08-22ethtool: fix EEPROM byte writeTomasz Moń1-3/+7
ethtool since version 1.8 supports EEPROM byte write: # ethtool -E DEVNAME [ magic N ] [ offset N ] [ value N ] ethtool 2.6.33 added EEPROM block write: # ethtool -E ethX [ magic N ] [ offset N ] [ length N ] [ value N ] EEPROM block write introduced in 2.6.33 is backwards compatible, i.e. when value is specified the length is forced to 1 (commandline length value is ignored). The byte write behaviour changed in ethtool 5.9 where the value write only works when value parameter is specified together with length 1. While byte writes to any offset other than 0, without length 1, simply fail with "offset & length out of bounds" error message, writing value to offset 0 basically erased whole EEPROM. That is, the provided byte value was written at offset 0, but the rest of the EEPROM was set to 0. Fix the issue by setting length to 1 when value is specified and length is omitted. Exit with error if length is specified to value other than 1 and value is specified. Fixes: 923c3f51c444 ("ioctl: check presence of eeprom length argument properly") Signed-off-by: Tomasz Moń <tomasz.mon@camlingroup.com>
2022-08-06gitignore: ignore ctags generated tags fileYegor Yefremov1-0/+1
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2022-08-06Merge branches 'review/registers-cpsw' and 'review/registers-lan74xx'Michal Kubecek4-1/+78
Both branches add register dump support for a new class of devices so that they conflict with each other but the conflict is trivial to resolve. Conflicts: Makefile.am ethtool.c internal.h
2022-08-06ethtool: add register dump support for lan743x chiptesRaju Lakkaraju4-1/+78
Add LAN743x register dump Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
2022-08-06pretty: Add support for TI CPSW register dumpsBenedikt Spranger4-1/+198
Add pretty register dump for the ALE table of the cpsw kernel drivers. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
2022-06-23sff-8079/8472: Fix missing sff-8472 output in netlink pathIvan Vecera1-8/+46
Commit 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)") provided a netlink variant for getmodule but also introduced a regression as netlink output is different from ioctl output that provides information from A2h page via sff8472_show_all(). To fix this the netlink path should check a presence of A2h page by value of bit 6 in byte 92 of page A0h and if it is set then get A2h page and call sff8472_show_all(). Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)") Tested-by: Daniel Juarez <djuarezg@cern.ch> Tested-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Co-authored-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-06-14pretty: add ETHTOOL_A_RINGS_TX_PUSH descriptionMichal Kubecek1-0/+1
Add message description for recently added ETHTOOL_A_RINGS_TX_PUSH attribute. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-06-14Merge branch 'next' into masterMichal Kubecek7-0/+22
Merge material staged for 5.19 cycle. Update UAPI header copies to kernel v5.19-rc1.
2022-06-14Release version 5.18.v5.18Michal Kubecek3-2/+8
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-06-14ethtool: fec: Change the prompt string to adapt to current situationsYu Xiao2-2/+2
Majority upstream drivers uses `Configured FEC encodings` to report supported modes. At which point it is better to change the text in ethtool user space that changes the meaning of the field, which is better to suit for the current situations. So changing `Configured FEC encodings` to `Supported/Configured FEC encodings` to adapt to both implementations. Signed-off-by: Yu Xiao <yu.xiao@corigine.com> Signed-off-by: Simon Horman <simon.horman@corigine.com>
2022-06-14pretty: add missing message descriptions for ringsMichal Kubecek1-0/+9
Add message descriptions for recently added ETHTOOL_A_RINGS_RX_BUF_LEN, ETHTOOL_A_RINGS_TCP_DATA_SPLIT and ETHTOOL_A_RINGS_CQE_SIZE attributes. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-06-14pretty: support u8 enumerated typesMichal Kubecek2-1/+15
Similar to u32 enumerated types, we also need u8 enumerated types which only differ in an NLA_U8 attribute used for the value. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-06-13rings: add support to set/get cqe sizeSubbaraya Sundeep3-0/+12
After a packet is sent or received by NIC then NIC posts a completion queue event which consists of transmission status (like send success or error) and received status(like pointers to packet fragments). These completion events may also use a ring similar to rx and tx rings. This patch introduces cqe-size ethtool parameter to modify the size of the completion queue event if NIC hardware has that capability. With this patch in place, cqe size can be set via "ethtool -G <dev> cqe-size xxx" and get via "ethtool -g <dev>". Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
2022-06-13update UAPI header copiesMichal Kubecek4-1/+132
Update to kernel v5.18. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-05-08ethtool: add support to get/set tx push by ethtool -G/gJie Wang3-0/+12
Currently tx push is a standard feature for NICs such as Mellanox, HNS3. But there is no command to set or get this feature. So this patch adds support for "ethtool -G <dev> tx-push on|off" and "ethtool -g <dev>" to set/get tx push mode. Signed-off-by: Jie Wang <wangjie125@huawei.com>
2022-05-08update UAPI header copiesJie Wang5-1/+139
Update to kernel commit cc4bdef26ecd. Signed-off-by: Jie Wang <wangjie125@huawei.com>
2022-05-08help: fix alignment of rx-buf-len parameterMichal Kubecek1-1/+1
Recently added rx-buf-len parameter of -G (--set-ring) command uses spaces rather than tabs for alignment, resulting in misaligned help text. Replace with tabs which is what other parameters use. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-05-08ethtool.8: Fix typo in man pageVinicius Costa Gomes1-1/+1
Remove an extra 'q' in the cable-test section of the documentation. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
2022-04-04Release version 5.17.v5.17Michal Kubecek3-2/+11
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-04-04strset: do not put a pointer to a local variable to nlctxMichal Kubecek1-3/+3
Build with gcc12 complains that strset_reply_cb() puts a pointer to a local function into nlctx->devname and leaves it there on function exit. As the only reason for this assignment is a call to dev_ok() helper shortly after this, open code the check instead to avoid leaving pointer to a variable with function scope behind. We can also move the check insid the if block as ifindex cannot be non-zero otherwise. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-04-04ioctl: add the memory free operation after send_ioctl call failsJie Wang1-0/+2
The memory is not freed after send_ioctl fails in function do_gtunable and do_stunable. This will cause memory leaks. So this patch adds memory free operation after send_ioctl call fails. Fixes: b717ed22d984 ("ethtool: add support for get/set ethtool_tunable") Signed-off-by: Jie Wang <wangjie125@huawei.com>
2022-04-03ethtool: Add support for OSFP transceiver modulesDanielle Ratson4-1/+8
OSFP transceiver modules use the same management interface specification (CMIS) as QSFP-DD and DSFP modules. Allow ethtool to dump, parse and print their EEPROM contents by adding their SFF-8024 Identifier Value (0x19). This is required for future NVIDIA Spectrum-4 based systems that will be equipped with OSFP transceivers. While at it, add the DSFP identifier to the IOCTL path, as it was missing. Signed-off-by: Danielle Ratson <danieller@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
2022-04-03features: add --json supportDenys Fedoryshchenko2-7/+33
Adding json to make ethtool more machine friendly.  No change in normal text output: Features for enx0c37961ce55a: rx-checksumming: off [fixed] tx-checksumming: off tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: off [fixed] tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] scatter-gather: off tx-scatter-gather: off [fixed] tx-scatter-gather-fraglist: off [fixed] tcp-segmentation-offload: off tx-tcp-segmentation: off [fixed] tx-tcp-ecn-segmentation: off [fixed] tx-tcp-mangleid-segmentation: off [fixed] tx-tcp6-segmentation: off [fixed] generic-segmentation-offload: off [requested on] ...skip similar lines... JSON output: [ { "ifname": "enx0c37961ce55a", "rx-checksumming": { "active": false, "fixed": true, "requested": false }, "tx-checksumming": { "active": false, "fixed": null, "requested": null }, "tx-checksum-ipv4": { "active": false, "fixed": true, "requested": false }, "tx-checksum-ip-generic": { "active": false, "fixed": true, "requested": false }, "tx-checksum-ipv6": { "active": false, "fixed": true, "requested": false }, "tx-checksum-fcoe-crc": { "active": false, "fixed": true, "requested": false }, "tx-checksum-sctp": { "active": false, "fixed": true, "requested": false }, "scatter-gather": { "active": false, "fixed": null, "requested": null }, "tx-scatter-gather": { "active": false, "fixed": true, "requested": false }, ...skip similar lines... v2: - formatting fixes - show each feature as object with available attributes v3: - report "fixed" and "requested" as nil for the special features Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
2022-01-19Merge branch 'next' into masterMichal Kubecek14-2/+354
Merge material staged for 5.17 cycle.
2022-01-19Release version 5.16.v5.16Michal Kubecek3-2/+9
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-01-05man: document recently added parametersMichal Kubecek1-0/+12
Document recently added parameters also in the man page: - rx-buf-len parameter of -G (--set-ring) - tx-buf-size tunable Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2022-01-05tunables: add support to get/set tx copybreak buf sizeHao Chen1-0/+8
Add support for "ethtool --set-tunable <dev> tx-buf-size xxx" and "ethtool --get-tunable <dev> tx-buf-size" to set/get tx copybreak buf size. Signed-off-by: Hao Chen <chenhao288@hisilicon.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
2022-01-05rings: add support to set/get rx buf lenHao Chen2-0/+8
Add support for "ethtool -G <dev> rx-buf-len xxx" and "ethtool -g <dev>" to set/get rx-buf-len. Signed-off-by: Hao Chen <chenhao288@hisilicon.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
2021-12-17Merge branch 'master' into nextMichal Kubecek1-0/+2
2021-12-17monitor: do not show duplicate options in help textMichal Kubecek1-0/+2
Options "-s" and "--change" are listed multiple times in monitor_opts[] because they need to catch multiple message types. Show them only once in generated --monitor section of "ethtool --help" output. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-12-17Merge branch 'review/module-extstate' into nextMichal Kubecek13-2/+326
Ido Schimmel: Patch #1 updates the UAPI headers. Patch #2 adds the actual implementation that allows user space to control transceiver modules' power mode. See the commit message for example output. Patch #3 adds support for a new module extended state to allow user space to troubleshoot link down issues related to transceiver modules.
2021-12-17monitor: add option for --show-module/--set-moduleMichal Kubecek1-0/+4
Add an entry for ETHTOOL_MSG_MODULE_NTF to monitor_opts[] so that --show-module or --set-module can be used with --monitor to filter this message type. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-12-17ethtool: Add transceiver module extended stateIdo Schimmel1-0/+10
Add support for an extended state and an extended sub-state to describe link issues related to transceiver modules. In case "CMIS transceiver module is not in ModuleReady state" and the module is in ModuleFault state, it is possible to read the fault reason from the EEPROM dump. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-17ethtool: Add ability to control transceiver modules' power modeIdo Schimmel9-1/+260
Add ability to control transceiver modules' power mode over netlink. Example output and usage: # ip link set dev swp11 up $ ethtool --show-module swp11 Module parameters for swp11: power-mode-policy: high power-mode: high $ ethtool --json --show-module swp11 [ { "ifname": "swp11", "power-mode-policy": "high", "power-mode": "high" } ] # ethtool --set-module swp11 power-mode-policy auto $ ethtool --show-module swp11 Module parameters for swp11: power-mode-policy: auto power-mode: high # ethtool --set-module swp11 power-mode-policy auto # ethtool --set-module swp11 power-mode-policy high Despite three set commands, only two notifications were emitted, as the kernel only emits notifications when an attribute changes: $ ethtool --monitor listening... Module parameters for swp11: power-mode-policy: auto power-mode: high Module parameters for swp11: power-mode-policy: high power-mode: high Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-17Update UAPI header copiesIdo Schimmel3-1/+52
Update to kernel commit 1c5526968e27. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02Merge branch 'review/cmis-diag' into masterMichal Kubecek5-40/+702
Ido Schimmel: This patchset extends ethtool(8) to retrieve, parse and print CMIS diagnostic information. This information includes module-level monitors (e.g., temperature, voltage), channel-level monitors (e.g., Tx optical power) and related thresholds and flags. ethtool(8) already supports SFF-8636 (e.g., QSFP) and SFF-8472 (e.g., SFP) diagnostic information, but until recently CMIS diagnostic information was unavailable to ethtool(8) as it resides in optional and banked pages. Testing ======= Build tested each patch with the following configuration options: netlink | pretty-dump --------|------------ v | v x | x v | x x | v Except fields that were added, no difference in output before and after the patchset. Tested with both PC and AOC QSFP-DD modules. No reports from AddressSanitizer / valgrind. Patchset overview ================= Patches #1-#2 are small preparations. Patches #3-#4 retrieve (over netlink) and initialize the optional and banked pages in the CMIS memory map. These pages contain the previously mentioned diagnostic information. Patch #5 parses and prints the CMIS diagnostic information in a similar fashion to the way it is done for SFF-8636. Patches #6-#7 print a few additional fields from the CMIS EEPROM dump. The examples contain an ethtool command that is supported by the kernel, but not yet by ethtool(8). It will be sent as a follow-up patchset. Patch #8 prints the equivalent module-level fields for SFF-8636.
2021-12-02sff-8636: Print Power set and Power override bitsIdo Schimmel2-1/+7
Print the SFF-8636 Power set and Power override bits when dumping EEPROM contents via the '-m' option. They can be used to understand low power mode enforcement by the host. The 'SFF8636_LOW_PWR_MODE' define is renamed to 'SFF8636_LOW_PWR_SET' to reflect its naming in the standard for QSFP+/QSFP28. Example output: # ethtool -m swp13 Identifier : 0x11 (QSFP28) ... Extended identifier description : 5.0W max. Power consumption, High Power Class (> 3.5 W) enabled Power set : Off Power override : On ... Transmit avg optical power (Channel 1) : 0.7633 mW / -1.17 dBm Transmit avg optical power (Channel 2) : 0.7649 mW / -1.16 dBm Transmit avg optical power (Channel 3) : 0.7696 mW / -1.14 dBm Transmit avg optical power (Channel 4) : 0.7739 mW / -1.11 dBm Rcvr signal avg optical power(Channel 1) : 0.9240 mW / -0.34 dBm Rcvr signal avg optical power(Channel 2) : 0.9129 mW / -0.40 dBm Rcvr signal avg optical power(Channel 3) : 0.9194 mW / -0.36 dBm Rcvr signal avg optical power(Channel 4) : 0.8708 mW / -0.60 dBm # ethtool --set-module swp13 power-mode-policy auto # ethtool -m swp13 Identifier : 0x11 (QSFP28) ... Extended identifier description : 5.0W max. Power consumption, High Power Class (> 3.5 W) not enabled Power set : On Power override : On ... Transmit avg optical power (Channel 1) : 0.0000 mW / -inf dBm Transmit avg optical power (Channel 2) : 0.0000 mW / -inf dBm Transmit avg optical power (Channel 3) : 0.0000 mW / -inf dBm Transmit avg optical power (Channel 4) : 0.0000 mW / -inf dBm Rcvr signal avg optical power(Channel 1) : 0.0000 mW / -inf dBm Rcvr signal avg optical power(Channel 2) : 0.0000 mW / -inf dBm Rcvr signal avg optical power(Channel 3) : 0.0000 mW / -inf dBm Rcvr signal avg optical power(Channel 4) : 0.0000 mW / -inf dBm # ethtool --set-module swp13 power-mode-policy high # ethtool -m swp13 Identifier : 0x11 (QSFP28) ... Extended identifier description : 5.0W max. Power consumption, High Power Class (> 3.5 W) enabled Power set : Off Power override : On ... Transmit avg optical power (Channel 1) : 0.7733 mW / -1.12 dBm Transmit avg optical power (Channel 2) : 0.7754 mW / -1.10 dBm Transmit avg optical power (Channel 3) : 0.7885 mW / -1.03 dBm Transmit avg optical power (Channel 4) : 0.7886 mW / -1.03 dBm Rcvr signal avg optical power(Channel 1) : 0.9248 mW / -0.34 dBm Rcvr signal avg optical power(Channel 2) : 0.9129 mW / -0.40 dBm Rcvr signal avg optical power(Channel 3) : 0.9187 mW / -0.37 dBm Rcvr signal avg optical power(Channel 4) : 0.8785 mW / -0.56 dBm In the above example, the LPMode signal is ignored (Power override is always on) and low power mode is controlled via software only. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02cmis: Print Module-Level ControlsIdo Schimmel2-0/+20
Print the CMIS Module-Level Controls when dumping EEPROM contents via the '-m' option. It can be used to understand low power mode enforcement by the host. Example output: # ethtool -m swp11 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) ... Module State : 0x03 (ModuleReady) LowPwrAllowRequestHW : Off LowPwrRequestSW : Off ... Transmit avg optical power (Channel 1) : 1.3222 mW / 1.21 dBm Transmit avg optical power (Channel 2) : 1.2666 mW / 1.03 dBm Transmit avg optical power (Channel 3) : 1.2860 mW / 1.09 dBm Transmit avg optical power (Channel 4) : 1.2988 mW / 1.14 dBm Transmit avg optical power (Channel 5) : 1.2828 mW / 1.08 dBm Transmit avg optical power (Channel 6) : 1.2913 mW / 1.11 dBm Transmit avg optical power (Channel 7) : 1.2636 mW / 1.02 dBm Transmit avg optical power (Channel 8) : 1.3408 mW / 1.27 dBm Transmit avg optical power (Channel 9) : 1.3222 mW / 1.21 dBm Transmit avg optical power (Channel 10) : 1.2666 mW / 1.03 dBm Transmit avg optical power (Channel 11) : 1.2860 mW / 1.09 dBm Transmit avg optical power (Channel 12) : 1.2988 mW / 1.14 dBm Transmit avg optical power (Channel 13) : 1.2828 mW / 1.08 dBm Transmit avg optical power (Channel 14) : 1.2913 mW / 1.11 dBm Transmit avg optical power (Channel 15) : 1.2636 mW / 1.02 dBm Transmit avg optical power (Channel 16) : 1.3408 mW / 1.27 dBm Rcvr signal avg optical power (Channel 1) : 1.1351 mW / 0.55 dBm Rcvr signal avg optical power (Channel 2) : 1.1603 mW / 0.65 dBm Rcvr signal avg optical power (Channel 3) : 1.1529 mW / 0.62 dBm Rcvr signal avg optical power (Channel 4) : 1.1670 mW / 0.67 dBm Rcvr signal avg optical power (Channel 5) : 1.1759 mW / 0.70 dBm Rcvr signal avg optical power (Channel 6) : 1.1744 mW / 0.70 dBm Rcvr signal avg optical power (Channel 7) : 1.1188 mW / 0.49 dBm Rcvr signal avg optical power (Channel 8) : 1.1640 mW / 0.66 dBm Rcvr signal avg optical power (Channel 9) : 1.1351 mW / 0.55 dBm Rcvr signal avg optical power (Channel 10) : 1.1603 mW / 0.65 dBm Rcvr signal avg optical power (Channel 11) : 1.1529 mW / 0.62 dBm Rcvr signal avg optical power (Channel 12) : 1.1670 mW / 0.67 dBm Rcvr signal avg optical power (Channel 13) : 1.1759 mW / 0.70 dBm Rcvr signal avg optical power (Channel 14) : 1.1744 mW / 0.70 dBm Rcvr signal avg optical power (Channel 15) : 1.1188 mW / 0.49 dBm Rcvr signal avg optical power (Channel 16) : 1.1640 mW / 0.66 dBm # ethtool --set-module swp11 power-mode-policy auto # ethtool -m swp11 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) ... Module State : 0x01 (ModuleLowPwr) LowPwrAllowRequestHW : Off LowPwrRequestSW : On ... Transmit avg optical power (Channel 1) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 2) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 3) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 4) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 5) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 6) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 7) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 8) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 9) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 10) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 11) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 12) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 13) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 14) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 15) : 0.0001 mW / -40.00 dBm Transmit avg optical power (Channel 16) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 1) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 2) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 3) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 4) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 5) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 6) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 7) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 8) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 9) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 10) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 11) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 12) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 13) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 14) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 15) : 0.0001 mW / -40.00 dBm Rcvr signal avg optical power (Channel 16) : 0.0001 mW / -40.00 dBm # ethtool --set-module swp11 power-mode-policy high # ethtool -m swp11 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) ... Module State : 0x03 (ModuleReady) LowPwrAllowRequestHW : Off LowPwrRequestSW : Off ... Transmit avg optical power (Channel 1) : 1.3690 mW / 1.36 dBm Transmit avg optical power (Channel 2) : 1.3036 mW / 1.15 dBm Transmit avg optical power (Channel 3) : 1.3358 mW / 1.26 dBm Transmit avg optical power (Channel 4) : 1.3509 mW / 1.31 dBm Transmit avg optical power (Channel 5) : 1.3193 mW / 1.20 dBm Transmit avg optical power (Channel 6) : 1.3314 mW / 1.24 dBm Transmit avg optical power (Channel 7) : 1.3042 mW / 1.15 dBm Transmit avg optical power (Channel 8) : 1.3919 mW / 1.44 dBm Transmit avg optical power (Channel 9) : 1.3690 mW / 1.36 dBm Transmit avg optical power (Channel 10) : 1.3036 mW / 1.15 dBm Transmit avg optical power (Channel 11) : 1.3358 mW / 1.26 dBm Transmit avg optical power (Channel 12) : 1.3509 mW / 1.31 dBm Transmit avg optical power (Channel 13) : 1.3193 mW / 1.20 dBm Transmit avg optical power (Channel 14) : 1.3314 mW / 1.24 dBm Transmit avg optical power (Channel 15) : 1.3042 mW / 1.15 dBm Transmit avg optical power (Channel 16) : 1.3919 mW / 1.44 dBm Rcvr signal avg optical power (Channel 1) : 1.1299 mW / 0.53 dBm Rcvr signal avg optical power (Channel 2) : 1.1566 mW / 0.63 dBm Rcvr signal avg optical power (Channel 3) : 1.1484 mW / 0.60 dBm Rcvr signal avg optical power (Channel 4) : 1.1655 mW / 0.67 dBm Rcvr signal avg optical power (Channel 5) : 1.1751 mW / 0.70 dBm Rcvr signal avg optical power (Channel 6) : 1.1595 mW / 0.64 dBm Rcvr signal avg optical power (Channel 7) : 1.1158 mW / 0.48 dBm Rcvr signal avg optical power (Channel 8) : 1.1595 mW / 0.64 dBm Rcvr signal avg optical power (Channel 9) : 1.1299 mW / 0.53 dBm Rcvr signal avg optical power (Channel 10) : 1.1566 mW / 0.63 dBm Rcvr signal avg optical power (Channel 11) : 1.1484 mW / 0.60 dBm Rcvr signal avg optical power (Channel 12) : 1.1655 mW / 0.67 dBm Rcvr signal avg optical power (Channel 13) : 1.1751 mW / 0.70 dBm Rcvr signal avg optical power (Channel 14) : 1.1595 mW / 0.64 dBm Rcvr signal avg optical power (Channel 15) : 1.1158 mW / 0.48 dBm Rcvr signal avg optical power (Channel 16) : 1.1595 mW / 0.64 dBm In the above example, the LowPwrRequestHW signal is ignored and low power mode is controlled via software only. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02cmis: Print Module State and Fault CauseIdo Schimmel2-0/+86
Print the CMIS Module State when dumping EEPROM contents via the '-m' option. It can be used, for example, to test module power mode settings. Example output: # ethtool -m swp11 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) ... Module State : 0x03 (ModuleReady) # ethtool --set-module swp11 power-mode-policy auto # ethtool -m swp11 Identifier : 0x18 (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)) ... Module State : 0x01 (ModuleLowPwr) In case the module is in fault state, print the CMIS Module Fault Cause. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02cmis: Parse and print diagnostic informationIdo Schimmel2-27/+518
Like SFF-8636, CMIS has module-level monitors such as temperature and voltage and channel-level monitors such as Tx optical power. These monitors have thresholds and flags that are set when the monitors cross the thresholds. Print and parse these values in a similar fashion to SFF-8636. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02cmis: Initialize Banked Page 11h in memory mapIdo Schimmel2-2/+54
Banked Page 11h stores, among other things, lane-specific flags and monitors that are going to be parsed and displayed in subsequent patches. Request it via the 'MODULE_EEPROM_GET' netlink message and initialize it in the memory map. Only initialize it in supported Banks. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02cmis: Initialize Page 02h in memory mapIdo Schimmel1-3/+10
Page 02h stores module and lane thresholds that are going to be parsed and displayed in subsequent patches. Request it via the 'MODULE_EEPROM_GET' netlink message and initialize it in the memory map. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02sff-common: Move OFFSET_TO_U16_PTR() to common header fileIdo Schimmel2-3/+2
The define is also useful for CMIS, so move it from SFF-8636 to the common header file. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02sff-8636: Use an SFF-8636 specific define for maximum number of channelsIdo Schimmel2-5/+6
'MAX_CHANNEL_NUM' is defined in the common SFF code as 4 and used to set the size of the per-channel diagnostics array in the common 'sff_diags' structure. The CMIS parsing code is also going to use the structure, but it can have up to 32 channels, unlike SFF-8636 that only has 4. Therefore, set 'MAX_CHANNEL_NUM' to 32 and change the SFF-8636 code to use an SFF-8636 specific define instead of the common 'MAX_CHANNEL_NUM'. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-12-02cable-test: Fix premature process terminationIdo Schimmel1-0/+2
Unlike other ethtool operations, cable testing is asynchronous which allows several cables to be tested simultaneously. This is done by ethtool instructing the kernel to start the cable testing and listening to multicast notifications regarding its progress. The ethtool process terminates after receiving a notification about the completion of the test. Currently, ethtool processes all the cable test notifications, regardless of the reported device. This means that an ethtool process started for one device can terminate prematurely if completion was reported for a different device. Fix by ignoring notifications for devices other than the device for which the test was started. Fixes: 55f5e9aa3281 ("Add cable test support") Fixes: 9561db9b76f4 ("Add cable test TDR support") Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-22ethtool: Set mask correctly for dumping advertised FEC modesAlexander Duyck1-1/+1
Set the "mask" value to false when dumping the advertised FEC modes. The advertised values are stored in the value field, while the supported values are what is stored in the mask. Without this change the supported value is displayed for both the supported and advertised modes resulting in the advertised value being ignored. Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
2021-11-22Merge branch 'review/next/module-mem-map' into masterMichal Kubecek8-498/+635
Ido Schimmel: This patchset prepares ethtool(8) for retrieval and parsing of optional and banked module EEPROM pages, such as the ones present in CMIS. This is done by better integration of the recent 'MODULE_EEPROM_GET' netlink interface into ethtool(8). Background ========== ethtool(8) contains parsers for various module EEPROM memory maps such as SFF-8079, SFF-8636 and CMIS. Using the legacy IOCTL interface, ethtool(8) can ask the kernel to provide a buffer with the EEPROM contents. The buffer is then passed to the parsers that parse and print the EEPROM contents. The major disadvantage of this method is that in addition to ethtool(8), the kernel also needs to be familiar with the layout of the various memory maps, as it should not report to user space optional pages that do not exist. In addition, with the emergence of more complex layouts (e.g., CMIS) that include both optional and banked pages, the layout of the linear buffer provided by the kernel is unclear. For these reasons, kernel 5.13 was extended with the 'MODULE_EEPROM_GET' netlink message that allows user space to request specific EEPROM pages. Motivation ========== Unfortunately, the current integration of 'MODULE_EEPROM_GET' into ethtool(8) is not ideal. In the IOCTL path, a single large buffer is passed to the parsers, whereas in the netlink path, individual pages are passed. This is problematic for several reasons. First, this approach is not very scalable as standards such as CMIS support a lot of optional and banked pages. Passing them as separate arguments is not going to work. Second, the knowledge of which optional and banked pages are available should be encapsulated in the individual parsers, not in the common netlink code (i.e., netlink/module-eeprom.c). Currently, the common code is blindly requesting from the kernel optional pages that might not exist. Third, the difference in the way information is passed to the parsers propagates all the way to the individual parsing functions. For example, cmis_show_link_len() vs. cmis_show_link_len_from_page(). Implementation ============== In order to solve above mentioned problems and make it easier to integrate retrieval and parsing of optional and banked pages, this patchset reworks the EEPROM parsing code to use memory maps. For each parser, a structure describing the layout of the memory map is initialized with pointers to individual pages. In the IOCTL path, this structure contains pointers to sections of the linear buffer that was retrieved from the kernel. In the netlink path, this structure contains pointers to individual pages requested from the kernel. Care is taken to ensure that pages that do not exist are not requested from the kernel. After the structure is initialized, it is passed to the parsing code that parses and prints the information. This approach can be easily extended to support more optional and banked pages and allows us to keep the parsing code common to both the IOCTL and netlink paths. The only difference lies in how the memory map is initialized when the parser is invoked. Testing ======= Build tested each patch with the following configuration options: netlink | pretty-dump --------|------------ v | v x | x v | x x | v No differences in output before and after the patchset (*). Tested with QSFP (PC/AOC), QSFP-DD (PC/AOC), SFP (PC) and both IOCTL and netlink. No reports from AddressSanitizer / valgrind. (*) The only difference is in a few registers in CMIS that were not parsed correctly to begin with. Patchset overview ================= Patches #1-#4 move CMIS to use a memory map and consolidate the code paths between the IOCTL and netlink paths. Patches #5-#8 do the same for SFF-8636. Patch #9 does the same for SFF-8079. Patch #10 exports a function to allow parsers to request a specific EEPROM page. Patches #11-#13 change parsers to request only specific and valid EEPROM pages instead of getting potentially invalid pages from the common netlink code (i.e., netlink/module-eeprom.c). Patch #14 converts the common netlink code to simply call into individual parsers based on their SFF-8024 Identifier Value. The command context is passed to these parsers instead of potentially invalid pages.
2021-11-09Release version 5.15.v5.15Michal Kubecek3-2/+8
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-11-09update UAPI header copiesMichal Kubecek1-0/+1
Update to kernel v5.15. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-11-09netlink: settings: Correct duplicate conditionBastian Germann1-1/+1
tb's fields ETHTOOL_A_LINKINFO_TP_MDIX and ETHTOOL_A_LINKINFO_TP_MDIX_CTRL are used in this case. The condition is duplicate for the former. Fix that. Fixes: 10cc3ea337d1 ("netlink: partial netlink handler for gset (no option)") Signed-off-by: Bastian Germann <bage@linutronix.de> Acked-by: Michal Kubecek <mkubecek@suse.cz>
2021-11-08netlink: eeprom: Defer page requests to individual parsersIdo Schimmel1-288/+59
The individual EEPROM parsers (e.g., CMIS, SFF-8636) now request the EEPROM pages they intend to parse and populate their memory maps before parsing them. Therefore, there is no need for the common netlink code to request potentially invalid pages and pass them as blobs to these parsers. Instead, only query the SFF-8024 Identifier Value which is located at I2C address 0x50, byte 0 and dispatch to the relevant EEPROM parser. Tested by making sure that the output of 'ethtool -m' does not change for SFF-8079, SFF-8636 and CMIS before and after the patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8079: Request specific pages for parsing in netlink pathIdo Schimmel3-4/+20
Convert the SFF-8079 code to request the required EEPROM contents in the netlink path as was done for CMIS and SFF-8636. It will allow us to remove standard-specific code from the netlink code (i.e., netlink/module-eeprom.c). In addition, in the future, it will allow the netlink path to support parsing of SFF-8472. Tested by making sure that the output of 'ethtool -m' does not change before and after the patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8636: Request specific pages for parsing in netlink pathIdo Schimmel3-17/+49
In the netlink path, unlike the IOCTL path, user space requests specific EEPROM pages from the kernel. The presence of optional pages is advertised via various bits in the EEPROM contents. Currently, for SFF-8636, the Lower Memory, Page 00h and the optional Page 03h are requested by the netlink code (i.e., netlink/module-eeprom.c) and passed to the SFF-8636 code (i.e., qsfp.c) as two arguments for parsing. This is problematic for several reasons. First, this approach is not very scaleable as SFF-8636 supports a lot of optional pages. Passing them as separate arguments to the SFF-8636 code is not going to work. Second, the knowledge of which optional pages are available is encapsulated in the SFF-8636 parsing code. As such, the common netlink code has no business of fetching optional pages that might be invalid. Instead, pass the command context to the SFF-8636 parsing function and allow it to fetch only valid pages via the 'MODULE_EEPROM_GET' netlink message. Tested by making sure that the output of 'ethtool -m' does not change before and after the patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08cmis: Request specific pages for parsing in netlink pathIdo Schimmel3-19/+51
In the netlink path, unlike the IOCTL path, user space requests specific EEPROM pages from the kernel. The presence of optional and banked pages is advertised via various bits in the EEPROM contents. Currently, for CMIS, the Lower Memory, Page 00h and the optional Page 01h are requested by the netlink code (i.e., netlink/module-eeprom.c) and passed to the CMIS code (i.e., cmis.c) as two arguments for parsing. This is problematic for several reasons. First, this approach is not very scaleable as CMIS supports a lot of optional and banked pages. Passing them as separate arguments to the CMIS code is not going to work. Second, the knowledge of which optional and banked pages are available is encapsulated in the CMIS parsing code. As such, the common netlink code has no business of fetching optional and banked pages that might be invalid. Instead, pass the command context to the CMIS parsing function and allow it to fetch only valid pages via the 'MODULE_EEPROM_GET' netlink message. Tested by making sure that the output of 'ethtool -m' does not change before and after the patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08netlink: eeprom: Export a function to request an EEPROM pageIdo Schimmel2-0/+116
The function will be used by the EEPROM parsing code (e.g., cmis.c) to request a specific page for parsing. All the data buffers used to store EEPROM page contents are stored on a linked list that is flushed on exit. This relieves callers from the need to explicitly free the requested pages. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8079: Split SFF-8079 parsing functionIdo Schimmel4-5/+16
SFF-8079, unlike CMIS and SFF-8636, only has a single page and therefore its parsing function (i.e., sff8079_show_all()) is called from both the IOCTL and netlink paths with a buffer pointing to that single page. In future patches, the netlink code (i.e., netlink/module-eeprom.c) will no longer call the SFF-8079 code with a buffer pointing to the first 128 bytes of the EEPROM. Instead, the SFF-8079 code will need to request the needed EEPROM data, as will be done in CMIS and SFF-8636. Therefore, as a preparation for this change, split the main parsing function into IOCTL and netlink variants. No functional changes intended. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8636: Consolidate code between IOCTL and netlink pathsIdo Schimmel1-14/+15
Now that both the netlink and IOCTL paths use the same memory map structure for parsing, the code can be easily consolidated. Note that the switch-case statement is not necessary for the netlink path, as the netlink code (i.e., netlink/module-eeprom.c) already performed the check, but it is required for the IOCTL path. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8636: Use memory map during parsingIdo Schimmel1-167/+201
Instead of passing one large buffer to the individual parsing functions, use the memory map structure from the previous patch. This has the added benefit of checking which optional pages are actually available and it will also allow us to consolidate the IOCTL and netlink parsing code paths. Tested by making sure that there are no differences in output in both the IOCTL and netlink paths before and after the patch. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8636: Initialize SFF-8636 memory mapIdo Schimmel1-0/+65
The SFF-8636 memory map [1] consists of Lower Memory and Upper Memory. The content of the Lower Memory is fixed and can be addressed using an offset between 0 and 127 (inclusive). The Upper Memory is variable and optional and can be addressed by specifying a page number and an offset between 128 and 255 (inclusive). Create a structure describing this memory map and initialize it with pointers to available pages. In the IOCTL path, the structure holds pointers to regions of the continuous buffer passed to user space via the 'ETHTOOL_GMODULEEEPROM' command. In the netlink path, the structure holds pointers to individual pages passed to user space via the 'MODULE_EEPROM_GET' message. This structure will later allow us to consolidate the IOCTL and netlink parsing code paths and also easily support additional EEPROM pages, when needed. [1] SFF-8636 Rev. 2.10a, pag. 30, section 6.1, Figure 6-1 Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08sff-8636: Rename SFF-8636 parsing functionsIdo Schimmel4-9/+9
Currently, there are two SFF-8636 parsing functions. sff8636_show_all() and sff8636_show_all_paged(). The former is called from the IOCTL path with a buffer containing EEPROM contents and the latter is called from the netlink path with pointer to individual EEPROM pages. Rename them with '_ioctl' and '_nl' suffixes to make the distinction clear. In subsequent patches, these two functions will only differ in the way they initialize the SFF-8636 memory map for parsing, while the parsing code itself will be shared between the two. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08cmis: Consolidate code between IOCTL and netlink pathsIdo Schimmel1-22/+16
Now that both the netlink and IOCTL paths use the same memory map structure for parsing, the code can be easily consolidated. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08cmis: Use memory map during parsingIdo Schimmel2-88/+88
Instead of passing one large buffer to the individual parsing functions, use the memory map structure from the previous patch. This has the added benefit of checking which optional pages are actually available and it will also allow us to consolidate the IOCTL and netlink parsing code paths. Tested by making sure that the only differences in output in both the IOCTL and netlink paths before and after the patch are in a few registers in Page 01h that were previously parsed from Page 00h. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08cmis: Initialize CMIS memory mapIdo Schimmel2-0/+65
The CMIS memory map [1] consists of Lower Memory and Upper Memory. The content of the Lower Memory is fixed and can be addressed using an offset between 0 and 127 (inclusive). The Upper Memory is variable and optional and can be addressed by specifying a bank number, a page number and an offset between 128 and 255 (inclusive). Create a structure describing this memory map and initialize it with pointers to available pages. In the IOCTL path, the structure holds pointers to regions of the continuous buffer passed to user space via the 'ETHTOOL_GMODULEEEPROM' command. In the netlink path, the structure holds pointers to individual pages passed to user space via the 'MODULE_EEPROM_GET' message. This structure will later allow us to consolidate the IOCTL and netlink parsing code paths and also easily support additional EEPROM pages. [1] CMIS Rev. 5, pag. 97, section 8.1.1, Figure 8-1 Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-11-08cmis: Rename CMIS parsing functionsIdo Schimmel4-8/+8
Currently, there are two CMIS parsing functions. qsfp_dd_show_all() and cmis_show_all(). The former is called from the IOCTL path with a buffer containing EEPROM contents and the latter is called from the netlink path with pointer to individual EEPROM pages. Rename them with '_ioctl' and '_nl' suffixes to make the distinction clear. In subsequent patches, these two functions will only differ in the way they initialize the CMIS memory map for parsing, while the parsing code itself will be shared between the two. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11Merge branch 'review/module-fixes-2-v2'Michal Kubecek3-17/+19
Ido Schimmel: This patchset contains small patches for various issues I noticed while working on the module EEPROM parsing code. v2: * Patch #1: Do not assume the CLEI code is NULL terminated
2021-10-11sff-8636: Remove extra blank linesIdo Schimmel1-2/+0
Not needed, so remove them. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11sff-8636: Convert if statement to switch-caseIdo Schimmel1-3/+5
The indentation is wrong and the statement can be more clearly represented using a switch-case statement. Convert it. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11sff-8636: Fix incorrect function nameIdo Schimmel1-3/+3
The specification is called SFF-8636, not SFF-6836. Rename the function accordingly. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11sff-8636: Remove incorrect commentIdo Schimmel1-1/+1
The comment was copied from SFF-8472 (i.e., sfpdiag.c) where the diagnostic page is at I2C address 0x51. SFF-8636 only uses I2C address 0x50. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11cmis: Correct commentIdo Schimmel1-1/+1
The file is concerned with CMIS support, not QSFP-DD which is the physical form factor. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11cmis: Fix wrong define nameIdo Schimmel2-2/+2
Offset 0x10 in the Lower Memory stores the "VccMonVoltage". Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-10-11cmis: Fix CLEI code parsingIdo Schimmel2-5/+7
In CMIS, unlike SFF-8636, there is no presence indication for the CLEI code (Common Language Equipment Identification) field. The field is always present, but might not be supported. In which case, "a value of all ASCII 20h (spaces) shall be entered". Therefore, remove the erroneous check which seems to be influenced from SFF-8636 and only print the string if it is supported and has a non-zero length. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-09-15Merge branch 'review/module-fixes' into masterMichal Kubecek4-7/+24
Ido Schimmel: This patchset contains fixes for various issues I noticed while working on the module EEPROM parsing code. In addition to these fixes, I have the following submissions ready for the next branch [1]: * Trivial coding style / documentation changes * Reworking the EEPROM parsing code to use a memory map with pointers to individual pages as the current state is sub-optimal. In the IOCTL path, one large buffer is passed to parsers (e.g., SFF-8636, CMIS). In the netlink path, individual pages are passed, some of which might not be valid. With the proposed changes, the IOCTL and netlink paths only differ in the way they initialize the memory map. The parsing code is completely shared * Extending the CMIS parser to request and parse diagnostic information (already present in SFF-8636) from optional / banked pages [1] https://github.com/idosch/ethtool/commits/submit/cmis_dump_v1
2021-09-15netlink: eeprom: Fix compilation when pretty dump is disabledIdo Schimmel1-0/+4
When pretty dump is disabled (i.e., configure --disable-pretty-dump), the following errors are emitted: /usr/bin/ld: netlink/module-eeprom.o: in function `decoder_print': netlink/module-eeprom.c:330: undefined reference to `sff8636_show_all_paged' netlink/module-eeprom.c:334: undefined reference to `cmis_show_all' netlink/module-eeprom.c:325: undefined reference to `sff8079_show_all' The else clause is unreachable when pretty dump is disabled, so wrap it with ifdef directive. This will be re-worked in future patches where the netlink code only queries the SFF-8024 Identifier Value and defers page requests to individual parsers. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-09-15ethtool: Fix compilation warning when pretty dump is disabledIdo Schimmel1-5/+8
When pretty dump is disabled (i.e., configure --disable-pretty-dump), gcc 11.2.1 emits the following warning: ethtool.c: In function ‘dump_regs’: ethtool.c:1160:31: warning: comparison is always false due to limited range of data type [-Wtype-limits] 1160 | for (i = 0; i < ARRAY_SIZE(driver_list); i++) | ^ Fix it by avoiding iterating over 'driver_list' when pretty dump is disabled. Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-09-15netlink: eeprom: Fallback to IOCTL when a complete hex/raw dump is requestedIdo Schimmel1-0/+10
The IOCTL backend provides a complete hex/raw dump of the module EEPROM contents: # ethtool -m swp11 hex on | wc -l 34 # ethtool -m swp11 raw on | wc -c 512 With the netlink backend, only the first 128 bytes from I2C address 0x50 are dumped: # ethtool -m swp11 hex on | wc -l 10 # ethtool -m swp11 raw on | wc -c 128 The presence of optional / banked pages is unknown without parsing the EEPROM contents which is unavailable when pretty printing is disabled (i.e., configure --disable-pretty-dump). With the IOCTL backend, this parsing happens inside the kernel. Therefore, when a complete hex/raw dump is requested, fallback to the IOCTL backend. After the patch: # ethtool -m swp11 hex on | wc -l 34 # ethtool -m swp11 raw on | wc -c 512 This avoids breaking users that are relying on current behavior. If users want a hex/raw dump of optional/banked pages that are not returned with the IOCTL backend, they will be required to request these explicitly via the netlink backend. For example: # ethtool -m swp11 hex on page 0x2 This is desirable as that way there is no ambiguity regarding the location of optional/banked pages in the dump. Another way to implement the above would be to use the 'nlchk' callback added in commit 67a9ef551661 ("ethtool: add nlchk for redirecting to netlink"). However, it is called before the netlink instance is initialized and before the command line parameters are parsed via nl_parser(). Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)") Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-09-15cmis: Fix invalid memory access in IOCTL pathIdo Schimmel1-1/+1
Page 01h is an optional page that is not available for flat memory modules. Trying to blindly access it results in the following report from AddressSanitizer [1]. Instead, pass the base address of the Lower Memory. This results in wrong information being parsed, but this never worked correctly since CMIS support first appeared in cited commit. The information will be parsed correctly in a follow-up submission that reworks the EEPROM parsing code to use a memory map with pointers to individual pages instead of passing one large buffer. [1] ==968785==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6120000001d4 at pc 0x0000004806ee bp 0x7ffefbc977a0 sp 0x7ffefbc97798 READ of size 1 at 0x6120000001d4 thread T0 #0 0x4806ed in cmis_print_smf_cbl_len cmis.c:127 #1 0x48113e in cmis_show_link_len_from_page cmis.c:279 #2 0x4811e3 in cmis_show_link_len cmis.c:300 #3 0x481358 in qsfp_dd_show_all cmis.c:336 #4 0x47d190 in sff8636_show_all qsfp.c:861 #5 0x42130b in do_getmodule ethtool.c:4908 #6 0x42a38a in main ethtool.c:6383 #7 0x7f11db6c51e1 in __libc_start_main (/lib64/libc.so.6+0x281e1) #8 0x40258d in _start (ethtool+0x40258d) Address 0x6120000001d4 is a wild pointer. SUMMARY: AddressSanitizer: heap-buffer-overflow cmis.c:127 in cmis_print_smf_cbl_len Fixes: 88ca347ef35a ("Add QSFP-DD support"). Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-09-15sff-8636: Fix parsing of Page 03h in IOCTL pathIdo Schimmel1-1/+1
The offset of Page 03h compared to the base address of the Lower Memory is 512 bytes. However, all the offsets to the page start at address 128, which is the address that separates Lower and Upper memory (see Figure 6-1 in SFF-8636). Therefore, reading these offsets compared to the start of Page 03h results in incorrect memory accesses as can be seen in the output below. Instead, pass Page 03h with the correct offset. This is a temporary solution until SFF-8636 is refactored to use a memory map for parsing. Before patch: # ethtool -m swp13 ... Laser bias current high alarm threshold : 16.448 mA Laser bias current low alarm threshold : 16.500 mA Laser bias current high warning threshold : 16.480 mA Laser bias current low warning threshold : 61.538 mA Laser output power high alarm threshold : 1.2576 mW / 1.00 dBm Laser output power low alarm threshold : 1.0321 mW / 0.14 dBm Laser output power high warning threshold : 2.1318 mW / 3.29 dBm Laser output power low warning threshold : 2.0530 mW / 3.12 dBm Module temperature high alarm threshold : 0.00 degrees C / 32.00 degrees F Module temperature low alarm threshold : 0.00 degrees C / 32.00 degrees F Module temperature high warning threshold : 0.00 degrees C / 32.00 degrees F Module temperature low warning threshold : 0.00 degrees C / 32.00 degrees F Module voltage high alarm threshold : 0.2377 V Module voltage low alarm threshold : 2.5701 V Module voltage high warning threshold : 2.8276 V Module voltage low warning threshold : 2.6982 V Laser rx power high alarm threshold : 0.8224 mW / -0.85 dBm Laser rx power low alarm threshold : 0.8224 mW / -0.85 dBm Laser rx power high warning threshold : 0.8224 mW / -0.85 dBm Laser rx power low warning threshold : 0.8224 mW / -0.85 dBm After patch: # ethtool -m swp13 ... Laser bias current high alarm threshold : 8.500 mA Laser bias current low alarm threshold : 5.492 mA Laser bias current high warning threshold : 8.000 mA Laser bias current low warning threshold : 6.000 mA Laser output power high alarm threshold : 3.4673 mW / 5.40 dBm Laser output power low alarm threshold : 0.0724 mW / -11.40 dBm Laser output power high warning threshold : 1.7378 mW / 2.40 dBm Laser output power low warning threshold : 0.1445 mW / -8.40 dBm Module temperature high alarm threshold : 80.00 degrees C / 176.00 degrees F Module temperature low alarm threshold : -10.00 degrees C / 14.00 degrees F Module temperature high warning threshold : 70.00 degrees C / 158.00 degrees F Module temperature low warning threshold : 0.00 degrees C / 32.00 degrees F Module voltage high alarm threshold : 3.5000 V Module voltage low alarm threshold : 3.1000 V Module voltage high warning threshold : 3.4650 V Module voltage low warning threshold : 3.1350 V Laser rx power high alarm threshold : 3.4673 mW / 5.40 dBm Laser rx power low alarm threshold : 0.0467 mW / -13.31 dBm Laser rx power high warning threshold : 1.7378 mW / 2.40 dBm Laser rx power low warning threshold : 0.0933 mW / -10.30 dBm The following AddressSanitizer report is fixed: ==44670==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x617000000320 at pc 0x00000047ad93 bp 0x7ffcb4dc0070 sp 0x7ffcb4dc0068 READ of size 1 at 0x617000000320 thread T0 #0 0x47ad92 in sff8636_dom_parse qsfp.c:683 #1 0x47c5d6 in sff8636_show_dom qsfp.c:771 #2 0x47d21f in sff8636_show_all qsfp.c:870 #3 0x42130b in do_getmodule ethtool.c:4908 #4 0x42a38a in main ethtool.c:6383 #5 0x7f500bf421e1 in __libc_start_main (/lib64/libc.so.6+0x281e1) #6 0x40258d in _start (ethtool+0x40258d) 0x617000000320 is located 16 bytes to the right of 656-byte region [0x617000000080,0x617000000310) allocated by thread T0 here: #0 0x7f500c2d6527 in __interceptor_calloc (/lib64/libasan.so.6+0xab527) #1 0x420d8c in do_getmodule ethtool.c:4859 #2 0x42a38a in main ethtool.c:6383 #3 0x7f500bf421e1 in __libc_start_main (/lib64/libc.so.6+0x281e1) SUMMARY: AddressSanitizer: heap-buffer-overflow qsfp.c:683 in sff8636_dom_parse Fixes: fc47fdb7c364 ("ethtool: Refactor human-readable module EEPROM output for new API") Signed-off-by: Ido Schimmel <idosch@nvidia.com>
2021-09-12Merge branch 'next' into masterMichal Kubecek8-0/+42
Merge material staged for 5.15 cycle.
2021-09-12Release version 5.14.v5.14Michal Kubecek3-2/+6
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-09-12netlink: settings: add netlink support for coalesce cqe mode parameterYufeng Mo3-0/+20
Add support for "ethtool -C <dev> cqe-mode-rx/cqe-mode-tx on/off" for setting coalesce cqe mode and show values in "ethtool -c <dev>" output. Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
2021-08-26pretty: update message descriptions for coalescingMichal Kubecek1-0/+2
Update coalescing message descriptions to support new attributes ETHTOOL_A_COALESCE_USE_CQE_MODE_TX and ETHTOOL_A_COALESCE_USE_CQE_MODE_RX. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-26netlink: settings: add two link extended substates of bad signal integrityGuangbin Huang1-0/+4
Add two link extended substates of bad signal integrity available in the kernel. ETHTOOL_LINK_EXT_SUBSTATE_BSI_SERDES_REFERENCE_CLOCK_LOST means the input external clock signal for SerDes is too weak or lost. ETHTOOL_LINK_EXT_SUBSTATE_BSI_SERDES_ALOS means the received signal for SerDes is too weak because analog loss of signal. Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
2021-08-26update UAPI header copiesMichal Kubecek3-0/+16
Update to kernel commit e3f30ab28ac8. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-26pretty: add message descriptions for PHC virtual clocksMichal Kubecek1-0/+9
Add message descriptions for ETHTOOL_MSG_PHC_VCLOCKS_GET request and reply (PHC virtual clocks information). Note: ETHTOOL_A_PHC_VCLOCKS_INDEX is described as binary for now as we do not have support for a raw array of typed values yet. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-26pretty: add message descriptions for FEC statsMichal Kubecek1-0/+9
Update message descriptions to support FEC stats. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-26pretty: reorder to match enum valuesMichal Kubecek1-13/+13
Reorder the message descriptions to match order of the enum values. Just a cleanup, no effect on resulting code. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-26update UAPI header copiesMichal Kubecek5-7/+45
Update to kernel commit 73f3af7b4611. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-25cmdline: skip dummy args entry in find_option()Michal Kubecek1-1/+1
Commit 444f36546f53 ("ethtool: use dummy args[] entry for no-args case") introduced a gcc warning which is a false positive but it's unlikely compiler can ever recognize that. Silence the warning by skipping the dummy args[0] entry in find_option() as we do not really want to compare the command line argument against it. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-08-24Merge branch 'review/nojson-fail' into masterMichal Kubecek1-24/+28
Jakub Kicinski: This series aims to make --json fail if the output is not JSON formatted. This should make writing scripts around ethtool less error prone and give us stronger signal when produced JSON is invalid.
2021-08-24ethtool: return error if command does not support --jsonJakub Kicinski1-0/+11
The --json switch is currently best effort, which is similar to how other networking utilities treat it. Change to returning an error if selected command does not support --json. ethtool is more complex than other utilities because the JSON support depends on both user space and kernel version. Older kernel make ethtool use the IOCTL and none of the IOCTL handlers support JSON. The current behavior is counter-productive when trying to query statistics - user has to check (1) if stats (-I) are supported, (2) if json is supported (--json) and then (3) if underlying device populates the statistic. Making --json fail if not supported allows (1) and (2) to both be taken care of with simple check of ethtool's exit code. Link: https://pagure.io/centos-sig-hyperscale/package-bugs/issue/6 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-08-24ethtool: use dummy args[] entry for no-args caseJakub Kicinski1-20/+14
Simplify the code flow further by adding a struct option entry for the no-args case (e.g. "ethtool eth0"). This leads to a slight change in the help output, there will now be an extra space between FLAGS and DEVICE in that case: ethtool [ FLAGS ] DEVNAME Display standard information about device but hopefully that's okay. Note that this patch adds a false-positive warning with GCC 11: ethtool.c: In function ‘find_option’: ethtool.c:6082:29: warning: offset ‘1’ outside bounds of constant string [-Warray-bounds] 6082 | opt += len + 1; | ~~~~^~~~~~~~~~ we'll never get to that code if the string is empty. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-08-24ethtool: remove questionable gotoJakub Kicinski1-7/+6
goto opt_found can be trivially replaced by an else branch. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-08-24Remove trailing newline in perror messagesJules Maselbas1-5/+5
perror append additional text at the end of the error message, and will also include a newline. The newline in the error message it self is not needed and can be removed. This makes errors much nicer to read. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
2021-07-09build: add list.h to file list in Makefile.amv5.13Michal Kubecek1-1/+2
Newly added header file list.h needs to be listed in Makefile.am so that "make dist" and "make distcheck" add it into the generated tarball. Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)") Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-07-09Release version 5.13.Michal Kubecek3-2/+9
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-07-09netlink: work around spurious selftest failureMichal Kubecek1-3/+3
Using a global variable, guaranteed to be zero initialized, for parser results in netlink/module-eeprom.c works fine for ethtool itself but it results in a selftest (make check) failure because test-cmdline calls nl_getmodule() multiple times and parsed values from previous calls are not cleared. Rather than clearing the structure manually before each parser run, make getmodule_cmd_params a local variable of nl_getmodule() as it is not used anywhere else and this way is more consistent with rest of the netlink code. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
2021-07-08Merge branch 'review/getmodule-v4' into masterMichal Kubecek15-304/+854
Moshe Shemesh: Ethtool supports module EEPROM dumps via the `ethtool -m <dev>` command. But in current state its functionality is limited - offset and length parameters, which are used to specify a linear desired region of EEPROM data to dump, is not enough, considering emergence of complex module EEPROM layouts such as CMIS. Moreover, CMIS extends the amount of pages that may be accessible by introducing another parameter for page addressing - banks. Besides, currently module EEPROM is represented as a chunk of concatenated pages, where lower 128 bytes of all pages, except page 00h, are omitted. Offset and length are used to address parts of this fake linear memory. But in practice drivers, which implement get_module_info() and get_module_eeprom() ethtool ops still calculate page number and set I2C address on their own. This series adds support in `ethtool -m` of dumping an arbitrary page specified by page number, bank number and I2C address. Implement netlink handler for `ethtool -m` in order to make such requests to the kernel and extend CLI by adding corresponding parameters. New command line format: ethtool -m <dev> [hex on|off] [raw on|off] [offset N] [length N] [page N] [bank N] [i2c N] Netlink infrastructure works on per-page basis and allows dumps of a single page at once. But in case user requests human-readable output, which currently may require more than one page, userspace can make such additional calls to kernel on demand and place pages in a linked list. It allows to get pages from cache on demand and pass them to refactored SFF decoders. Change Log: v3 -> v4: - Fixed cmis_show_all() prototype v2 -> v3: - Removed spec version from CMIS identifiers by changing 'CMIS4' and 'cmis4' to 'CMIS' and 'cmis' respectively. v1 -> v2: - Changed offset defines to specification values. - Added default offset value (128) if page number is specified. - Fixed return values. - Removed page_available()
2021-07-08ethtool: Update manpages to reflect changes to getmodule (-m) commandVladyslav Tarasiuk1-0/+14
Add page, bank and i2c parameters and mention change in offset and length treatment if either one of new parameters is specified by the user. Signed-off-by: Vladyslav Tarasiuk <vladyslavt@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
2021-07-08ethtool: Rename QSFP-DD identifiers to use CMISVladyslav Tarasiuk6-236/+236
QSFP-DD and DSFP EEPROM layout complies to CMIS specification. As DSFP support is added, there are currently two standards, which share the same infrastructure. Rename QSFP_DD and qsfp_dd occurrences to use CMIS or cmis respectively to make function names generic for any module compliant to CMIS 4.0 or future CMIS versions. Signed-off-by: Vladyslav Tarasiuk <vladyslavt@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
2021-07-08ethtool: Refactor human-readable module EEPROM output for new APIVladyslav Tarasiuk8-102/+170
Reuse existing SFF8636 and QSFP-DD infrastructures to implement EEPROM decoders, which work with paged memory. Add support for human-readable output for QSFP, QSFP28, QSFP Plus, QSFP-DD and DSFP transreceivers from netlink 'ethtool -m' handler. Signed-off-by: Vladyslav Tarasiuk <vladyslavt@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
2021-07-08ethtool: Add netlink handler for getmodule (-m)Vladyslav Tarasiuk7-0/+468
Implement "ethtool -m <dev>" subcommand using netlink and extend the interface for new module EEPROM standards. Currently, ethtool supports module EEPROM dumps of continuous memory regions, which are specified using a pair of parameters - offset and length. But due to emergence of new standards such as CMIS 4.0, which further extends possible addressed memory, this approach shows its limitations. Extend command line interface in order to support dumps of arbitrary pages including CMIS specific banked pages: ethtool -m <dev> [page N] [bank N] [i2c N] Command example: # ethtool -m eth2 page 1 offset 0x80 length 0x20 Offset Values ------ ------ 0x0080: 11 00 23 80 00 00 00 00 00 00 00 08 ff 00 00 00 0x0090: 00 00 01 a0 4d 65 6c 6c 61 6e 6f 78 20 20 20 20 Signed-off-by: Vladyslav Tarasiuk <vladyslavt@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
2021-05-20Merge branch 'review/fec-stats-v3' into masterMichal Kubecek19-58/+1100
Jakub Kicinski: This series adds support for FEC requests via netlink and new "standard" stats. Changes from v2: - update headers - fix --disable-netlink build - rename equivalency groups to alternatives Changes from v1: - rebase on next, only conflicts in uAPI update - fix the trailing "and" in patch 6 Changes compared to RFC: - improve commit messages - fix Rx vs Tx histogram in JSON - make histograms less hardcoded to RMON - expand man page entry for -S a little - add --all-groups (last patch)
2021-05-20test: workaround for FEC encoding parser checksMichal Kubecek1-3/+4
Unlike ioctl parser, netlink parser does not validate FEC encoding names and lets kernel do it. As the command line parser test currently does not actually call kernel, tests of invalid encoding names succeed while they are supposed to fail (and actual ethtool would fail). Use previously introduced IS_NL macro to work around the failed "make check" tests. Signed-off-by: Michal Kubecek <mkubecek@suse.cz>