From: Andrew Lunn <andrew@lunn.ch>
To: Don Bollinger <don@thebollingers.org>
Cc: 'Moshe Shemesh' <moshe@nvidia.com>,
"'David S. Miller'" <davem@davemloft.net>,
'Jakub Kicinski' <kuba@kernel.org>,
'Adrian Pop' <pop.adrian61@gmail.com>,
'Michal Kubecek' <mkubecek@suse.cz>,
netdev@vger.kernel.org,
'Vladyslav Tarasiuk' <vladyslavt@nvidia.com>
Subject: Re: [RFC PATCH V2 net-next 1/5] ethtool: Allow network drivers to dump arbitrary EEPROM data
Date: Fri, 5 Mar 2021 02:32:52 +0100 [thread overview]
Message-ID: <YEGKRNLce9dzFkqI@lunn.ch> (raw)
In-Reply-To: <001101d71159$8721f4b0$9565de10$@thebollingers.org>
> > + * @length: Number of bytes to read.
> > + * @page: Page number to read from.
> > + * @bank: Page bank number to read from, if applicable by EEPROM spec.
> > + * @i2c_address: I2C address of a page. Value less than 0x7f expected.
> > Most
> > + * EEPROMs use 0x50 or 0x51.
>
> The standards are all very clear
Our experience so far is that manufactures of SFP modules like to
ignore the standard. And none of the standards seem to cover copper
modules, which have additional registers at some other page.
Admittedly, they cannot be mapped as pages, you need some proprietary
protocol to map MDIO onto I2C. But i would not be surprised to find
some SFP that maps the FLASH of the microcontroller onto an address,
which we might be able to read out using this API.
So i suggested we keep it generic, allowing access to these
proprietary registers at other addresses. And if there is nothing
there, you probably get a 1/2 page of 0xff.
> I suggest that 0xA0 and 0xA2 also be silently accepted, and
> translated to 0x50 and 0x51 respectively.
No, i don't like having two different values mean the same thing. It
just leads to confusion. And userspace is going to be confused when it
asks for 0xA0 but the reply says it is for 0x50.
The Linux I2C subsystem does not magically map 8bit addresses in 7bit
addresses. We should follow what the Linux I2C subsystem does.
> > +
> > + request->offset =
> > nla_get_u32(tb[ETHTOOL_A_EEPROM_DATA_OFFSET]);
> > + request->length =
> > nla_get_u32(tb[ETHTOOL_A_EEPROM_DATA_LENGTH]);
> > + if (request->length > ETH_MODULE_EEPROM_MAX_LEN)
> > + return -EINVAL;
>
> This is really problematic as there are MANY different max values, within
> the specs
I agree. We should only be returning one 1/2 page as a maximum. So it
should be limited to 128 bytes. And offset+length should not go beyond
the end of a 1/2 page.
> > + if (tb[ETHTOOL_A_EEPROM_DATA_PAGE])
> > + request->page =
> > nla_get_u32(tb[ETHTOOL_A_EEPROM_DATA_PAGE]);
> > + if (tb[ETHTOOL_A_EEPROM_DATA_BANK])
> > + request->bank =
> > nla_get_u32(tb[ETHTOOL_A_EEPROM_DATA_BANK]);
>
> Other checks:
>
> Page and bank have to be between 0 and 255 (inclusive), they
> go into an 8 bit register in the eeprom.
Yes, a u8 would be a better type here.
Andrew
next prev parent reply other threads:[~2021-03-05 1:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 18:57 [RFC PATCH V2 net-next 0/5] ethtool: Extend module EEPROM dump API Moshe Shemesh
2021-03-04 18:57 ` [RFC PATCH V2 net-next 1/5] ethtool: Allow network drivers to dump arbitrary EEPROM data Moshe Shemesh
2021-03-05 0:50 ` Don Bollinger
2021-03-05 1:32 ` Andrew Lunn [this message]
2021-03-08 8:45 ` Moshe Shemesh
2021-03-05 1:58 ` Andrew Lunn
2021-03-08 8:54 ` Moshe Shemesh
2021-03-04 18:57 ` [RFC PATCH V2 net-next 2/5] net/mlx5: Refactor module EEPROM query Moshe Shemesh
2021-03-04 18:57 ` [RFC PATCH V2 net-next 3/5] net/mlx5: Implement get_module_eeprom_data_by_page() Moshe Shemesh
2021-03-04 18:57 ` [RFC PATCH V2 net-next 4/5] net/mlx5: Add support for DSFP module EEPROM dumps Moshe Shemesh
2021-03-04 18:57 ` [RFC PATCH V2 net-next 5/5] ethtool: Add fallback to get_module_eeprom from netlink command Moshe Shemesh
2021-03-05 0:50 ` Don Bollinger
2021-03-05 1:50 ` Andrew Lunn
2021-03-05 2:44 ` Don Bollinger
2021-03-05 2:53 ` Don Bollinger
2021-03-08 9:04 ` Moshe Shemesh
2021-03-05 0:50 ` [RFC PATCH V2 net-next 0/5] ethtool: Extend module EEPROM dump API Don Bollinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YEGKRNLce9dzFkqI@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=don@thebollingers.org \
--cc=kuba@kernel.org \
--cc=mkubecek@suse.cz \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pop.adrian61@gmail.com \
--cc=vladyslavt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).