mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nelson, Shannon" <shannon.nelson@amd.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, brett.creeley@amd.com
Subject: Re: [PATCH net-next 2/3] ionic: support ethtool get_module_eeprom_by_page
Date: Mon, 14 Apr 2025 15:55:06 -0700	[thread overview]
Message-ID: <6e6dc5e2-5af2-48a7-a017-0ebaebe989e8@amd.com> (raw)
In-Reply-To: <891f1b66-0b49-41ce-bb00-5345ef9afb5c@lunn.ch>

On 4/14/2025 3:18 PM, Andrew Lunn wrote:
> 
>>>> +static int ionic_get_module_eeprom_by_page(struct net_device *netdev,
>>>> +                                        const struct ethtool_module_eeprom *page_data,
>>>> +                                        struct netlink_ext_ack *extack)
> 
>>>> +     switch (page_data->page) {
>>>> +     case 0:
>>>> +             src = &idev->port_info->status.xcvr.sprom[page_data->offset];
>>>> +             break;
>>>> +     case 1:
>>>> +             src = &idev->port_info->sprom_page1[page_data->offset - 128];
>>>> +             break;
>>>> +     case 2:
>>>> +             src = &idev->port_info->sprom_page2[page_data->offset - 128];
>>>> +             break;
>>>> +     default:
>>>> +             return -EINVAL;
>>>
>>> It is a valid page, your firmware just does not support it. EOPNOSUPP.
>>
>> I can see the argument for this, but EINVAL seems to me to match the
>> out-of-bounds case from ionic_get_module_eprom(), as well as what other
>> drivers are reporting for an unsupported address.  It seems to me that
>> passing EOPNOSUPP back to the user is telling them that they can't get
>> eeprom data at all, not that they asked for the wrong page.
> 
> I would disagree with at. Look at the ethtool usage:
> 
> ethtool -m|--dump-module-eeprom|--module-info devname [raw on|off]
>            [hex on|off] [offset N] [length N] [page N] [bank N] [i2c N]
> 
> You can ask for any page. The only validation that can be done is,
> does the page number fit within the page selection register. And that
> is a u8. So any value < 256 is valid for page.  Some pages are
> currently defined, some pages are reserved, and pages 128-255 are for
> vendor specific functions.
> 
> The limitation here is your firmware, you don't support what the
> specification allows. So EOPNOTSUPP for a page you don't supports
> would give an indication of this.
> 
> ethtool's pretty print should handle -EOPNOTSUPP. It knows some netdev
> have limits, and don't give full access to the module data. I would
> not be too surprised to find ethtool actually interprets EINVAL for a
> valid page to be fatal, but i've not checked. EOPNOTSUPP should just
> stop it pretty printing that section of the module.
> 
>          Andrew

I still think that EINVAL is the right answer because we are complaining 
about an argument value, not an operation, but sure, EOPNOTSUPP is fine. 
  I'll update the patchset in a day or two.

sln


  reply	other threads:[~2025-04-14 22:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 18:21 [PATCH net-next 0/3] ionic: support QSFP CMIS Shannon Nelson
2025-04-11 18:21 ` [PATCH net-next 1/3] ionic: extend the QSFP module sprom for more pages Shannon Nelson
2025-04-11 18:21 ` [PATCH net-next 2/3] ionic: support ethtool get_module_eeprom_by_page Shannon Nelson
2025-04-13 20:58   ` Andrew Lunn
2025-04-14 19:55     ` Nelson, Shannon
2025-04-14 22:18       ` Andrew Lunn
2025-04-14 22:55         ` Nelson, Shannon [this message]
2025-04-11 18:21 ` [PATCH net-next 3/3] ionic: add module eeprom channel data to ionic_if and ethtool Shannon Nelson

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=6e6dc5e2-5af2-48a7-a017-0ebaebe989e8@amd.com \
    --to=shannon.nelson@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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

all inboxes | Powered by JetHome®