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=-13.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 5A352C433E6 for ; Mon, 20 Jul 2020 16:26:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32A632070A for ; Mon, 20 Jul 2020 16:26:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="BoGClCp+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729959AbgGTQ0Q (ORCPT ); Mon, 20 Jul 2020 12:26:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729911AbgGTQ0M (ORCPT ); Mon, 20 Jul 2020 12:26:12 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA892C061794 for ; Mon, 20 Jul 2020 09:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RcI3fGc+LFH7IXsg15I/rJUriv3F5gq1TEvrMG1jvIk=; b=BoGClCp+CnfFKjqsu689yqoCz Q3F5pD2wcJUssSSQBQ/+jwFLD675MehyWOIy13NQz2I3OHRrjYWt4sIpxk1Wh/U3kJ/CvBNoWazSC XtWYQ2c2Kp/7kqGZrxbVMyyXio6JJsf+/PvsUSCB6YeF6vlCvz9NYD0Xki44o96yQlmWkX682otTb pDUOCwJgBnyhoRHhIM2nTlet0O4SguI1d6BVVRw86exc8ZidRem93lqgLI1y+M1k4ddqifUrr3Jhq SvUhyptHQ9fFWnY5v5XGi/hVb35inj+ZAoOx6PnKx+BTBYqpjuU6c00IvuUumvqNbgcd0qBskkqtl UI1mM4a0g==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:41956) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jxYc8-0003KL-6G; Mon, 20 Jul 2020 17:26:04 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jxYc4-00057J-SH; Mon, 20 Jul 2020 17:26:00 +0100 Date: Mon, 20 Jul 2020 17:26:00 +0100 From: Russell King - ARM Linux admin To: Ioana Ciornei Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , Claudiu Manoil , Alexandru Marginean , "michael@walle.cc" , "olteanv@gmail.com" , "David S. Miller" , Jakub Kicinski , "netdev@vger.kernel.org" Subject: Re: [PATCH RFC net-next 12/13] net: phylink: add struct phylink_pcs Message-ID: <20200720162600.GW1551@shell.armlinux.org.uk> References: <20200630142754.GC1551@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Jul 20, 2020 at 03:50:57PM +0000, Ioana Ciornei wrote: > On 6/30/20 5:29 PM, Russell King wrote: > > Add a way for MAC PCS to have private data while keeping independence > > from struct phylink_config, which is used for the MAC itself. We need > > this independence as we will have stand-alone code for PCS that is > > independent of the MAC. Introduce struct phylink_pcs, which is > > designed to be embedded in a driver private data structure. > > > > This structure does not include a mdio_device as there are PCS > > implementations such as the Marvell DSA and network drivers where this > > is not necessary. > > > > Signed-off-by: Russell King > > Reviewed-by: Ioana Ciornei > > I integrated and used the phylink_pcs structure into the Lynx PCS just > to see how everything fits. Pasting below the main parts so that we can > catch early any possible different opinions on how to integrate this: > > The basic Lynx structure looks like below and the main idea is just to > encapsulate the phylink_pcs structure and the mdio device (which in some > other cases might not be needed). > > struct lynx_pcs { > struct phylink_pcs pcs; > struct mdio_device *mdio; > phy_interface_t interface; > }; > > The lynx_pcs structure is requested by the MAC driver with: > > struct lynx_pcs *lynx_pcs_create(struct mdio_device *mdio) > { > (...) > lynx_pcs->mdio = mdio; > lynx_pcs->pcs.ops = &lynx_pcs_phylink_ops; > lynx_pcs->pcs.poll = true; > > return lynx_pcs; > } > > And then passed to phylink with something like: > > phylink_set_pcs(pl, &lynx_pcs->pcs); > > > For DSA it's a bit less straightforward because the .setup() callback > from the dsa_switch_ops is run before any phylink structure has been > created internally. For this, a new DSA helper can be created that just > stores the phylink_pcs structure per port: > > void dsa_port_phylink_set_pcs(struct dsa_switch *ds, int port, > struct phylink_pcs *pcs) > { > struct dsa_port *dp = dsa_to_port(ds, port); > > dp->pcs = pcs; but I do > } > > and at the appropriate time, from dsa_slave_setup, it can really install > the phylink_pcs with phylink_set_pcs. > The other option would be to add a new dsa_switch ops that requests the > phylink_pcs for a specific port - something like phylink_get_pcs. It is entirely possible to set the PCS in the mac_prepare() or mac_config() callbacks - but DSA doesn't yet support the mac_prepare() callback (because it needs to be propagated through the DSA way of doing things.) An example of this can be found at: http://git.armlinux.org.uk/cgit/linux-arm.git/commit/?h=mcbin&id=593d56ef8c7f7d395626752f6810210471a5f5c1 where we choose between the XLGMAC and GMAC pcs_ops structures depending on the interface mode we are configuring for. Note that this is one of the devices that the PCS does not appear as a distinctly separate entity in the register set, at least in the GMAC side of things. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!