From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04F2CC433DB for ; Thu, 18 Mar 2021 22:17:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBD4164F30 for ; Thu, 18 Mar 2021 22:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbhCRWQu (ORCPT ); Thu, 18 Mar 2021 18:16:50 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:35668 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231671AbhCRWQX (ORCPT ); Thu, 18 Mar 2021 18:16:23 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lN0wC-00Bl9u-KK; Thu, 18 Mar 2021 23:16:16 +0100 Date: Thu, 18 Mar 2021 23:16:16 +0100 From: Andrew Lunn To: Moshe Shemesh Cc: "David S. Miller" , Jakub Kicinski , Adrian Pop , Michal Kubecek , Don Bollinger , netdev@vger.kernel.org, Vladyslav Tarasiuk Subject: Re: [RFC PATCH V3 net-next 1/5] ethtool: Allow network drivers to dump arbitrary EEPROM data Message-ID: References: <1615828363-464-1-git-send-email-moshe@nvidia.com> <1615828363-464-2-git-send-email-moshe@nvidia.com> <3d8b9b2b-25e2-3812-2daf-09f1c5088eb0@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3d8b9b2b-25e2-3812-2daf-09f1c5088eb0@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org > > > +Request contents: > > > + > > > + ===================================== ====== ========================== > > > + ``ETHTOOL_A_EEPROM_DATA_HEADER`` nested request header > > > + ``ETHTOOL_A_EEPROM_DATA_OFFSET`` u32 offset within a page > > > + ``ETHTOOL_A_EEPROM_DATA_LENGTH`` u32 amount of bytes to read > > I wonder if offset and length should be u8. At most, we should only be > > returning a 1/2 page, so 128 bytes. We don't need a u32. > > > That's right when page is given, but user may have commands that > used to work on the ioctl KAPI with offset higher than one page. CMIS section 5.4.1 says: The slave maintains an internal current byte address counter containing the byte address accessed during the latest read or write operation incremented by one with roll-over as follows: The current byte address counter rolls-over after a read or write operation at the last byte address of the current 128-byte memory page (127 or 255) to the first byte address (0 or 128) of the same 128-byte memory page. This wrapping is somewhat unexpected. If the user access is for a read starting at 120 and a length of 20, they get bytes 120-127 followed by 0-11. The user is more likely to be expecting 120-139. We have two ways to address this: 1) We limit reads to a maximum of a 1/2 page, and the start and end point needs to be within that 1/2 page. 2) We detect that the read is going to go across a 1/2 page boarder, and perform two reads to the MAC driver, and glue the data back together again in the ethtool core. What i don't want is to leave the individual drivers to solve this, because i expect some of them will get it wrong. Andrew