All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vladyslav Tarasiuk <vladyslavt@nvidia.com>
Cc: Moshe Shemesh <moshe@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Moshe Shemesh <moshe@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>,
	Adrian Pop <pop.adrian61@gmail.com>,
	Michal Kubecek <mkubecek@suse.cz>,
	netdev@vger.kernel.org, Maxim Mikityanskiy <maximmi@nvidia.com>
Subject: Re: [PATCH net-next v2 0/2] Add support for DSFP transceiver type
Date: Tue, 29 Dec 2020 17:25:14 +0100	[thread overview]
Message-ID: <X+tYamjmow0MfFxz@lunn.ch> (raw)
In-Reply-To: <0f021f89-35d4-4d99-b0b1-451f09636e58@nvidia.com>

> Hi Andrew,
> 
> Following this conversation, I wrote some pseudocode checking if I'm on
> right path here.
> Please review:
> 
> struct eeprom_page {
>         u8 page_number;
>         u8 bank_number;
>         u16 offset;
>         u16 data_length;
>         u8 *data;
> }

I'm wondering about offset and data_length, in this context. I would
expect you always ask the kernel for the full page, not part of
it. Even when user space asks for just part of a page. That keeps you
cache management simpler. But maybe some indicator of low/high is
needed, since many pages are actually 1/2 pages?

The other thing to consider is SFF-8472 and its use of two different
i2c addresses, A0h and A2h. These are different to pages and banks.

> print_human_readable()
> {
>         spec_id = cache_get_page(0, 0, 0, 128)->data[0];
>         switch (spec_id) {
>         case sff_xxxx:
>                 print_sff_xxxx();
>         case cmis_y:
>                 print_cmis_y();
>         default:
>                 print_hex();
>         }
> }

You want to keep as much of the existing ethtool code as you can, but
the basic idea looks O.K.

> getmodule_reply_cb()
> {
>         if (offset || hex || bank_number || page number)
>                 print_hex();
>         else
>                 // if _human_readable() decoder needs more than page 00, it
> will
>                 // fetch it on demand
>                 print_human_readable();
> }

Things get interesting here. Say this is page 0, and
print_human_readable() finds a bit indicating page 1 is valid. So it
requests page 1. We go recursive. While deep down in
print_human_readable(), we send the next netlink message and call
getmodule_reply_cb() when the answer appears. I've had problems with
some of the netlink code not liking recursive calls.

So i suggest you try to find a different structure for the code. Try
to complete the netlink call before doing the decoding. So add the
page to the cache and then return. Do the decode after
nlsock_sendmsg() has returned.

> Driver
> It is required to implement get_module_eeprom_page() ndo, where it queries
> its EEPROM and copies to u8 *data array allocated by the kernel previously.
> The ndo has the following prototype:
> int get_module_eeprom_page(struct net_device *, u16 offset, u16 length,
>                            u8 page_number, u8 bank_number, u8 *data);


I would include extack here, so we can get better error messages.

  Andrew

  reply	other threads:[~2020-12-29 16:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23  9:19 [PATCH net-next v2 0/2] Add support for DSFP transceiver type Moshe Shemesh
2020-11-23  9:19 ` [PATCH net-next v2 1/2] ethtool: Add CMIS 4.0 module type to UAPI Moshe Shemesh
2020-11-23 22:40   ` Jesse Brandeburg
2020-11-25 10:41     ` Moshe Shemesh
2020-11-23  9:19 ` [PATCH net-next v2 2/2] net/mlx5e: Add DSFP EEPROM dump support to ethtool Moshe Shemesh
2020-11-24  1:14 ` [PATCH net-next v2 0/2] Add support for DSFP transceiver type Andrew Lunn
2020-11-24 21:16   ` Jakub Kicinski
2020-11-25 10:40     ` Moshe Shemesh
2020-11-25 14:18       ` Andrew Lunn
2020-11-26 14:23         ` Moshe Shemesh
2020-11-26 15:21           ` Andrew Lunn
2020-11-27 15:12             ` Moshe Shemesh
2020-11-27 15:56               ` Andrew Lunn
2020-12-29 10:23                 ` Vladyslav Tarasiuk
2020-12-29 16:25                   ` Andrew Lunn [this message]
2020-12-30 13:55                     ` Vladyslav Tarasiuk
2020-12-30 15:36                       ` Andrew Lunn
2021-01-04 15:24                         ` Vladyslav Tarasiuk
2021-01-04 15:48                           ` Andrew Lunn

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=X+tYamjmow0MfFxz@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=maximmi@nvidia.com \
    --cc=mkubecek@suse.cz \
    --cc=moshe@mellanox.com \
    --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.