diff options
author | Ido Schimmel <idosch@nvidia.com> | 2021-09-14 14:27:36 +0300 |
---|---|---|
committer | Michal Kubecek <mkubecek@suse.cz> | 2021-09-15 18:22:17 +0200 |
commit | 2ddb1a1f06e2892efb8a7c75739092dac8582a37 (patch) | |
tree | 82b1445fd23cb9551e898e7f8f76ad7f7fe82321 | |
parent | 7e153a7da4f1631e2e1bef023ff6db6e96653059 (diff) | |
download | ethtool-2ddb1a1f06e2892efb8a7c75739092dac8582a37.tar.gz |
netlink: eeprom: Fallback to IOCTL when a complete hex/raw dump is requested
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>
-rw-r--r-- | netlink/module-eeprom.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/netlink/module-eeprom.c b/netlink/module-eeprom.c index 38e7d2c..e9a122d 100644 --- a/netlink/module-eeprom.c +++ b/netlink/module-eeprom.c @@ -365,6 +365,16 @@ int nl_getmodule(struct cmd_context *ctx) return -EINVAL; } + /* When complete hex/raw dump of the EEPROM is requested, fallback to + * ioctl. Netlink can only request specific pages. + */ + if ((getmodule_cmd_params.dump_hex || getmodule_cmd_params.dump_raw) && + !getmodule_cmd_params.page && !getmodule_cmd_params.bank && + !getmodule_cmd_params.i2c_address) { + nlctx->ioctl_fallback = true; + return -EOPNOTSUPP; + } + request.i2c_address = ETH_I2C_ADDRESS_LOW; request.length = 128; ret = page_fetch(nlctx, &request); |