All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Don Bollinger" <don@thebollingers.org>
To: "'Moshe Shemesh'" <moshe@nvidia.com>,
	"'David S. Miller'" <davem@davemloft.net>,
	"'Jakub Kicinski'" <kuba@kernel.org>,
	"'Andrew Lunn'" <andrew@lunn.ch>,
	"'Adrian Pop'" <pop.adrian61@gmail.com>,
	"'Michal Kubecek'" <mkubecek@suse.cz>, <netdev@vger.kernel.org>,
	<don@thebollingers.org>
Cc: "'Vladyslav Tarasiuk'" <vladyslavt@nvidia.com>
Subject: RE: [RFC PATCH V3 net-next 1/5] ethtool: Allow network drivers to dump arbitrary EEPROM data
Date: Tue, 16 Mar 2021 14:00:21 -0700	[thread overview]
Message-ID: <006b01d71aa7$619eb2d0$24dc1870$@thebollingers.org> (raw)
In-Reply-To: <0a8beb69-972b-3b00-a67e-0e97f9fda8ea@nvidia.com>

On 3/16/2021 11:24 AM, Moshe Shemesh wrote:
> On 3/16/2021 12:31 AM, Don Bollinger wrote:
> > On Mon, 15 Mar 2021 10:12:39 +0700 Moshe Shemesh wrote:
> >> From: Vladyslav Tarasiuk <vladyslavt@nvidia.com>
> >>
> >> Define get_module_eeprom_data_by_page() ethtool callback and
> >> implement netlink infrastructure.
> >>

<snip>

> >> +     request->offset =
> >> nla_get_u32(tb[ETHTOOL_A_EEPROM_DATA_OFFSET]);
> >> +     request->length =
> >> nla_get_u32(tb[ETHTOOL_A_EEPROM_DATA_LENGTH]);
> >> +     if (tb[ETHTOOL_A_EEPROM_DATA_PAGE] &&
> >> +         dev->ethtool_ops->get_module_eeprom_data_by_page &&
> >> +         request->offset + request->length >
> >> ETH_MODULE_EEPROM_PAGE_LEN)
> >> +             return -EINVAL;
> > If a request exceeds the length of EEPROM (in legacy), we truncate it
> > to EEPROM length.  I suggest if a request exceeds the length of the
> > page (in the new KAPI), then we truncate at the end of the page.  Thus
> > rather than 'return -EINVAL;' I suggest
> >
> >            request->length = ETH_MODULE_EEPROM_PAGE_LEN -
> > request->offset;
> 
> I was not sure about that, isn't it better that once user specified page he has
> to be in the page boundary and let him know the command failed ?

On further review, I agree with your original code.  Reading across a page boundary will require explicit tracking of offset and page to read from.  If you get a short read, you *might* have to update the page on the next read.  If you have to keep track of where the page boundary is and adjust the offset and page together, then you should be explicitly managing not to try to read across a page boundary.  Put another way, if you try to read across a page boundary you probably have a bug in your code and will appreciate an immediate error.

I withdraw my previous suggestion, don't change it.

Don


  reply	other threads:[~2021-03-16 21:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 17:12 [RFC PATCH V3 net-next 0/5] ethtool: Extend module EEPROM dump API Moshe Shemesh
2021-03-15 17:12 ` [RFC PATCH V3 net-next 1/5] ethtool: Allow network drivers to dump arbitrary EEPROM data Moshe Shemesh
2021-03-15 21:01   ` Jakub Kicinski
2021-03-16 17:59     ` Moshe Shemesh
2021-03-15 22:31   ` Don Bollinger
2021-03-16 18:23     ` Moshe Shemesh
2021-03-16 21:00       ` Don Bollinger [this message]
2021-03-18 22:36       ` Andrew Lunn
2021-03-18 13:03   ` Andrew Lunn
2021-03-18 14:25     ` Moshe Shemesh
2021-03-18 22:16       ` Andrew Lunn
2021-03-18 15:16     ` Michal Kubecek
2021-03-15 17:12 ` [RFC PATCH V3 net-next 2/5] net/mlx5: Refactor module EEPROM query Moshe Shemesh
2021-03-15 17:12 ` [RFC PATCH V3 net-next 3/5] net/mlx5: Implement get_module_eeprom_data_by_page() Moshe Shemesh
2021-03-15 17:12 ` [RFC PATCH V3 net-next 4/5] net/mlx5: Add support for DSFP module EEPROM dumps Moshe Shemesh
2021-03-15 17:12 ` [RFC PATCH V3 net-next 5/5] ethtool: Add fallback to get_module_eeprom from netlink command Moshe Shemesh
2021-03-15 22:31   ` Don Bollinger
2021-03-16 18:26     ` Moshe Shemesh

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='006b01d71aa7$619eb2d0$24dc1870$@thebollingers.org' \
    --to=don@thebollingers.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.