* [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path
@ 2022-06-16 15:50 Ivan Vecera
2022-06-16 16:19 ` Michal Kubecek
2022-06-16 17:34 ` Ido Schimmel
0 siblings, 2 replies; 5+ messages in thread
From: Ivan Vecera @ 2022-06-16 15:50 UTC (permalink / raw)
To: netdev; +Cc: Michal Kubecek, Daniel Juarez, Ido Schimmel
Commit 5b64c66f58d ("ethtool: Add netlink handler for
getmodule\r (-m)") provided a netlink variant for getmodule
but also introduced a regression as netlink output is different
from ioctl output that provides information from A2h page
via sff8472_show_all().
To fix this the netlink path should check a presence of A2h page
by value of bit 6 in byte 92 of page A0h and if it is set then
get A2h page and call sff8472_show_all().
Fixes: 5b64c66f58d ("ethtool: Add netlink handler for getmodule\r (-m)")
Tested-by: Daniel Juarez <djuarezg@cern.ch>
Co-authored-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
sfpid.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 46 insertions(+), 8 deletions(-)
diff --git a/sfpid.c b/sfpid.c
index 621d1e86c278..1bc45c183770 100644
--- a/sfpid.c
+++ b/sfpid.c
@@ -13,8 +13,9 @@
#include "sff-common.h"
#include "netlink/extapi.h"
-#define SFF8079_PAGE_SIZE 0x80
-#define SFF8079_I2C_ADDRESS_LOW 0x50
+#define SFF8079_PAGE_SIZE 0x80
+#define SFF8079_I2C_ADDRESS_LOW 0x50
+#define SFF8079_I2C_ADDRESS_HIGH 0x51
static void sff8079_show_identifier(const __u8 *id)
{
@@ -450,18 +451,55 @@ void sff8079_show_all_ioctl(const __u8 *id)
sff8079_show_all_common(id);
}
-int sff8079_show_all_nl(struct cmd_context *ctx)
+static int sff8079_get_eeprom_page(struct cmd_context *ctx, u8 i2c_address,
+ __u8 *buf)
{
struct ethtool_module_eeprom request = {
.length = SFF8079_PAGE_SIZE,
- .i2c_address = SFF8079_I2C_ADDRESS_LOW,
+ .i2c_address = i2c_address,
};
int ret;
ret = nl_get_eeprom_page(ctx, &request);
- if (ret < 0)
- return ret;
- sff8079_show_all_common(request.data);
+ if (!ret)
+ memcpy(buf, request.data, SFF8079_PAGE_SIZE);
+
+ return ret;
+}
+
+int sff8079_show_all_nl(struct cmd_context *ctx)
+{
+ u8 *buf;
+ int ret;
+
+ /* The SFF-8472 parser expects a single buffer that contains the
+ * concatenation of the first 256 bytes from addresses A0h and A2h,
+ * respectively.
+ */
+ buf = calloc(1, ETH_MODULE_SFF_8472_LEN);
+ if (!buf)
+ return -ENOMEM;
+
+ /* Read A0h page */
+ ret = sff8079_get_eeprom_page(ctx, SFF8079_I2C_ADDRESS_LOW, buf);
+ if (ret)
+ goto out;
+
+ sff8079_show_all_common(buf);
+
+ /* Finish if A2h page is not present */
+ if (!(buf[92] & (1 << 6)))
+ goto out;
+
+ /* Read A2h page */
+ ret = sff8079_get_eeprom_page(ctx, SFF8079_I2C_ADDRESS_HIGH,
+ buf + ETH_MODULE_SFF_8079_LEN);
+ if (ret)
+ goto out;
+
+ sff8472_show_all(buf);
+out:
+ free(buf);
- return 0;
+ return ret;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path
2022-06-16 15:50 [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path Ivan Vecera
@ 2022-06-16 16:19 ` Michal Kubecek
2022-06-16 17:56 ` Ivan Vecera
2022-06-16 17:34 ` Ido Schimmel
1 sibling, 1 reply; 5+ messages in thread
From: Michal Kubecek @ 2022-06-16 16:19 UTC (permalink / raw)
To: Ivan Vecera; +Cc: netdev, Daniel Juarez, Ido Schimmel
[-- Attachment #1: Type: text/plain, Size: 799 bytes --]
On Thu, Jun 16, 2022 at 05:50:09PM +0200, Ivan Vecera wrote:
> Commit 5b64c66f58d ("ethtool: Add netlink handler for
> getmodule\r (-m)") provided a netlink variant for getmodule
> but also introduced a regression as netlink output is different
> from ioctl output that provides information from A2h page
> via sff8472_show_all().
>
> To fix this the netlink path should check a presence of A2h page
> by value of bit 6 in byte 92 of page A0h and if it is set then
> get A2h page and call sff8472_show_all().
>
> Fixes: 5b64c66f58d ("ethtool: Add netlink handler for getmodule\r (-m)")
Looks like the leading "2" in commit id got lost and "^M" got into the
subject somehow. AFAICS this should be
Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)")
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path
2022-06-16 15:50 [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path Ivan Vecera
2022-06-16 16:19 ` Michal Kubecek
@ 2022-06-16 17:34 ` Ido Schimmel
2022-06-16 17:57 ` Ivan Vecera
1 sibling, 1 reply; 5+ messages in thread
From: Ido Schimmel @ 2022-06-16 17:34 UTC (permalink / raw)
To: Ivan Vecera; +Cc: netdev, Michal Kubecek, Daniel Juarez
On Thu, Jun 16, 2022 at 05:50:09PM +0200, Ivan Vecera wrote:
> Commit 5b64c66f58d ("ethtool: Add netlink handler for
> getmodule\r (-m)") provided a netlink variant for getmodule
> but also introduced a regression as netlink output is different
> from ioctl output that provides information from A2h page
> via sff8472_show_all().
>
> To fix this the netlink path should check a presence of A2h page
> by value of bit 6 in byte 92 of page A0h and if it is set then
> get A2h page and call sff8472_show_all().
>
> Fixes: 5b64c66f58d ("ethtool: Add netlink handler for getmodule\r (-m)")
> Tested-by: Daniel Juarez <djuarezg@cern.ch>
> Co-authored-by: Ido Schimmel <idosch@nvidia.com>
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
With Michal's comment:
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Tested with both netlink and ioctl, but only with SFP modules that lack
diagnostic information, as I don't have these at hand.
Michal, note that for ethtool-next we plan to get rid of sfpdiag.c and
fold it into sfpid.c, so that the latter will be able to handle both
SFF-8079 and SFF-8472 using the same memory map. We felt that it's too
big of a change for the main branch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path
2022-06-16 16:19 ` Michal Kubecek
@ 2022-06-16 17:56 ` Ivan Vecera
0 siblings, 0 replies; 5+ messages in thread
From: Ivan Vecera @ 2022-06-16 17:56 UTC (permalink / raw)
To: Michal Kubecek; +Cc: netdev, Daniel Juarez, Ido Schimmel
On Thu, 16 Jun 2022 18:19:45 +0200
Michal Kubecek <mkubecek@suse.cz> wrote:
> On Thu, Jun 16, 2022 at 05:50:09PM +0200, Ivan Vecera wrote:
> > Commit 5b64c66f58d ("ethtool: Add netlink handler for
> > getmodule\r (-m)") provided a netlink variant for getmodule
> > but also introduced a regression as netlink output is different
> > from ioctl output that provides information from A2h page
> > via sff8472_show_all().
> >
> > To fix this the netlink path should check a presence of A2h page
> > by value of bit 6 in byte 92 of page A0h and if it is set then
> > get A2h page and call sff8472_show_all().
> >
> > Fixes: 5b64c66f58d ("ethtool: Add netlink handler for getmodule\r (-m)")
>
> Looks like the leading "2" in commit id got lost and "^M" got into the
> subject somehow. AFAICS this should be
>
> Fixes: 25b64c66f58d ("ethtool: Add netlink handler for getmodule (-m)")
>
> Michal
Will send v2
Ivan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path
2022-06-16 17:34 ` Ido Schimmel
@ 2022-06-16 17:57 ` Ivan Vecera
0 siblings, 0 replies; 5+ messages in thread
From: Ivan Vecera @ 2022-06-16 17:57 UTC (permalink / raw)
To: Ido Schimmel; +Cc: netdev, Michal Kubecek, Daniel Juarez
On Thu, 16 Jun 2022 20:34:15 +0300
Ido Schimmel <idosch@nvidia.com> wrote:
> On Thu, Jun 16, 2022 at 05:50:09PM +0200, Ivan Vecera wrote:
> > Commit 5b64c66f58d ("ethtool: Add netlink handler for
> > getmodule
> (-m)") provided a netlink variant for getmodule
> > but also introduced a regression as netlink output is different
> > from ioctl output that provides information from A2h page
> > via sff8472_show_all().
> >
> > To fix this the netlink path should check a presence of A2h page
> > by value of bit 6 in byte 92 of page A0h and if it is set then
> > get A2h page and call sff8472_show_all().
> >
> > Fixes: 5b64c66f58d ("ethtool: Add netlink handler for getmodule
> (-m)")
> > Tested-by: Daniel Juarez <djuarezg@cern.ch>
> > Co-authored-by: Ido Schimmel <idosch@nvidia.com>
> > Signed-off-by: Ivan Vecera <ivecera@redhat.com>
>
> With Michal's comment:
>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> Tested-by: Ido Schimmel <idosch@nvidia.com>
>
> Tested with both netlink and ioctl, but only with SFP modules that lack
> diagnostic information, as I don't have these at hand.
I have tested this with SFP modules with diag info...
(together with kernel fix: https://patchwork.kernel.org/project/netdevbpf/patch/20220616160856.3623273-1-ivecera@redhat.com/)
> Michal, note that for ethtool-next we plan to get rid of sfpdiag.c and
> fold it into sfpid.c, so that the latter will be able to handle both
> SFF-8079 and SFF-8472 using the same memory map. We felt that it's too
> big of a change for the main branch.
+1
Ivan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-16 17:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-16 15:50 [PATCH ethtool] sff-8079/8472: Fix missing sff-8472 output in netlink path Ivan Vecera
2022-06-16 16:19 ` Michal Kubecek
2022-06-16 17:56 ` Ivan Vecera
2022-06-16 17:34 ` Ido Schimmel
2022-06-16 17:57 ` Ivan Vecera
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).