Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp248018imm; Thu, 14 Jun 2018 19:28:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIg+kb+HggytvboHXGHBG2eNrx/8PBBuwGlpTpWDj+lhhAAcepm6ngN6LwZ8/PXEQgOyIZp X-Received: by 2002:a62:9385:: with SMTP id r5-v6mr12042463pfk.59.1529029684747; Thu, 14 Jun 2018 19:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529029684; cv=none; d=google.com; s=arc-20160816; b=GRBcxXzEI5YimIREbLdzpZ3APB8UUkV++LRlKrMmpRewyy+xQ/tHM4+xBpkI8+O6Dn gyqSllhVrhnyioIZtnSg2UAR4fyMeqxEMh/jCGc8gE6LynLQHqKbsbksFM9WBqJB5Kjm qXBwpcWiAarNjb2Wc+ACDi9zsdHQRy7+YnO8Ba178WnAN0ZbA8iBSC8HK0BvBh2jZ3QM hij9M+tH7Z4M+E5I8yMLkBSr11YNClewPGPwhW5arDdVJNs55GKQTUPHqVMIFgSi8sZ/ j/dljF8AGSjeB18bzuHrEYFoFSRElt441b/ybg27flsipxYGciNNr7+HKGl1LGKrkUpd fDDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=LWDxt+hpfKjzV9B6FCwFt6mViw+WLMqvQpUwtiFSowM=; b=qqBDkzfinaePEyj61/Cj7rjvJYhnxpvVR7HxC2V7nVJ/zoyDwZezqhCOw4+cqx8ZAY RFQgopMH8Wi/rfkBxH4Ht7q2/drEVmcvz4gGZ4eOkHAHJbrmxYymejoJ50auFLeu42gf Y+UFY2BGyUclSps2usHjO1LlnOJXnnuKkyoDLPI+gSkpoT8lqtgvkHGCqIedELigf20F PrvKjxTRAplZbdXfSLBvM2vquxwTwYYsigLkEH6oEIE7wVfo5UVHHF8cIoUDP/SKXBYt 9htUmetg3Flg0GWnAYAjFBko7XEEzwgmq09Fd3LktuKgaCuu+32T7QJIE8q17NE7xtdf 9mDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13-v6si6768852pln.62.2018.06.14.19.27.50; Thu, 14 Jun 2018 19:28:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936171AbeFOC1A (ORCPT + 99 others); Thu, 14 Jun 2018 22:27:00 -0400 Received: from resqmta-po-08v.sys.comcast.net ([96.114.154.167]:54154 "EHLO resqmta-po-08v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936121AbeFOC07 (ORCPT ); Thu, 14 Jun 2018 22:26:59 -0400 Received: from resomta-po-08v.sys.comcast.net ([96.114.154.232]) by resqmta-po-08v.sys.comcast.net with ESMTP id TdnBfYAeouPXCTeS2fm3LG; Fri, 15 Jun 2018 02:26:58 +0000 Received: from thebollingers.org ([73.223.250.230]) by resomta-po-08v.sys.comcast.net with ESMTPA id TeRyfGJXVAsWhTeRzfNLS6; Fri, 15 Jun 2018 02:26:58 +0000 Date: Thu, 14 Jun 2018 19:26:52 -0700 From: Don Bollinger To: Andrew Lunn Cc: Tom Lendacky , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, brandon_chuang@edge-core.com, wally_wang@accton.com, roy_lee@edge-core.com, rick_burchett@edge-core.com, quentin.chang@quantatw.com, steven.noble@bigswitch.com, jeffrey.townsend@bigswitch.com, scotte@cumulusnetworks.com, roopa@cumulusnetworks.com, David Ahern , luke.williams@canonical.com, Guohan Lu , Russell King , "netdev@vger.kernel.org" Subject: Re: [PATCH] optoe: driver to read/write SFP/QSFP EEPROMs Message-ID: <20180615022652.t6oqpnwwvdmbooab@thebollingers.org> References: <20180611042515.ml6zbcmz6dlvjmrp@thebollingers.org> <496e06b9-9f02-c4ae-4156-ab6221ba23fd@amd.com> <20180612181109.GD12251@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180612181109.GD12251@lunn.ch> User-Agent: NeoMutt/20170113 (1.7.2) X-CMAE-Envelope: MS4wfK3cHkWeA3/ZrJfgGabq1vg1Y5KQPXMzTBwSM6h8CPjweRJmioGQ51D/Nsz5i+TPssqkScy9llPdvEr6uEFpqupsFKLZ+RjP/ddR96yOs2C7vwL1Y5pb VeVn2+zYYaE3OVtbh/l2RMHv55kxG9K6WHdFMiKgYKj6g9gZCRXLuLaHqSnleAwTbeA0lyLQuSEu5j7bCwpiNfsRsWgIrZeNtZy9NevnNHgDMfDjt/JS5Mxy bIv+1zsqGpkyBPkuSUvtf+NTKiVTrNXt/j8hgddIvmjR2X0KjGmu7su3jZoPC2OPtDYLn7i04mJdmeFGSuyKdvKWtT5HkguxPOmt9p+ySKeQmLddAYbieuv3 zDDhH3KqrHMB3eRtH50naI0EWSVzQ9TJjMd1oDsAIhJO0C1DJoSsCa3RgGa4DVVw+5HCu4XmNtKmjb62bz/oJxF8MWDvIdgCZgvXoOlWktQvFBXLcLuwTYuL oaoC/N31QZxaKRoiCvTDxIFORGrdp00sxL5E0gF+179jthwDrqAo4vv875t5Ts8uBFZLTHQrUO/ICFAq0zQUWEsW4jcMLX3iKxt8lxwF0SpIyW7n78Hy4E0G YNQ9DBieCXVP5tgMPCHPH/Vh5V60Kbp2I0Ox/vvdcSdJWrxAPECBq/5VH/7Y0gjf2k13SD/S/Q+PHGWhBi5jVb8C4TcuLfoWk8acKnBpt8ofuvY7W6ZUchJm zlGvWMHLPfTWMQFuCMVs+Hxu6HY3eRWuXswizm0T+f/EF0omgC+xhnbACe9XJ/GKY1UuXDn9fwwC+eFWazaoqWWVNjht5POAcLndutECnqfs7gQWyEMuttmj Qh5QI/DgEMOWvv1g7QE= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 12, 2018 at 08:11:09PM +0200, Andrew Lunn wrote: > > There's an SFP driver under drivers/net/phy. Can that driver be extended > > to provide this support? Adding Russel King who developed sfp.c, as well > > at the netdev mailing list. > > I agree, the current SFP code should be used. > > My observations seem to be there are two different ways {Q}SFP are used: > > 1) The Linux kernel has full control, as assumed by the devlink/SFP > frame work. We parse the SFP data to find the capabilities of the SFP > and use it to program the MAC to use the correct mode. The MAC can be > a NIC, but it can also be a switch. DSA is gaining support for > PHYLINK, so SFP modules should just work with most switches which DSA > support. And there is no reason a plain switchdev switch can not use > PHYLINK. > > 2) Firmware is in control of the PHY layer, but there is a wish to > expose some of the data which is available via i2c from the {Q}SFP to > linux. > > It appears this optoe supports this second case. It does not appear to > support any in kernel API to actually make use of the SFP data in the > kernel. > > We should not be duplicating code. We should share the SFP code for > both use cases above. There is also a Linux standard API for getting > access to this information. ethtool -m/--module-info. Anything which > is exporting {Q}SFP data needs to use this API. > > Andrew Actually this is better described by a third use case. The target switches are PHY-less (see various designs at www.compute.org/wiki/Networking/SpecsAndDesigns). The AS5712 for example says "The AS5712-54X is a PHY-Less design with the SFP+ and QSFP+ connections directly attaching to the Serdes interfaces of the Broadcom BCM56854 720G Trident 2 switching silicon..." The electrical controls of the {Q}SFP devices (TxDisable for example) are organized in a platform dependent way, through CPLD devices, and managed by a platform specific CPLD driver. The i2c bus is muxed from the CPU to all of the {Q}SFP devices, which are set up as standard linux i2c devices (/sys/bus/i2c/devices/i2c-xxxx). There is no MDIO bus between the CPU and the {Q}SFP devices. > 2) Firmware is in control of the PHY layer, but there is a wish to > expose some of the data which is available via i2c from the {Q}SFP to > linux. So the switch silicon is in control of the PHY layer. The platform driver is in control of the electrical interfaces. And the EEPROM data is available via I2C. And, there isn't actually 'a wish to expose' the EEPROM data to linux (the kernel). It turns out that none of the NOS partners I'm working with use that data *in the kernel*. It is all managed from user space. More generally, I think sfp.c and optoe are not actually trying to accomplish the same thing at all. sfp.c combines all three functions (PHY, electrical control, EEPROM access). optoe is only providing EEPROM access, and only to user space. This is a real need in the white box switch environment, and is not met by sfp.c. optoe isn't better, sfp.c isn't better, they're just different. Finally, sfp.c does not recognize that SFP devices have data beyond 512 bytes, accessible via a page register. It also does not recognize QSFP devices at all. QSFP devices have only 256 bytes accessible (one i2c address) before switching to paged access for the remaining data. The first design requirement for optoe was to access all the available pages, because there is information and controls that we (optics vendors) want to make available to network management applications. If sfp.c creates a standard linux i2c client for each SFP device, it should be possible to create an optoe managed device 'under' sfp.c to provide access to the full EEPROM address space: # echo optoe2 0x50 >/sys/bus/i2c/devices/i2c-xx/new_device This might prove useful to user space consumers of that data. We could also easily add a kernel API (eg the nvmem framework) to optoe to provide kernel access. In other words, sfp.c could assign EEPROM management to optoe, while managing the electrical interfaces. (This is actually pretty close to how the platfom drivers work in the switch environment.) sfp.c would get SFP page support and QSFP EEPROM access 'for free'. > There is also a Linux standard API for getting > access to this information. ethtool -m/--module-info. Anything which > is exporting {Q}SFP data needs to use this API. optoe simply provides direct access from user space to the full EEPROM data. There is more data there than ethtool knows about, and in some devices there are proprietary registers that ethtool will never know about. optoe does not interpret any of the EEPROM content (except the bare minimum to access pages correctly). optoe also does not get in the way of ethtool. It could prove to be a handy way for ethtool to access new EEPROM fields in the future. QSFP-DD/OSFP are coming soon, they will have a different (incompatible) set of new fields to be decoded. Bottom Line: sfp.c is not a useful starting point for the switch environment I'm working in. The underlying hardware architecture is quite different. optoe is not a competing alternative. Its only function is to provide user-space access to the EEPROM data in {Q}SFP devices. Don