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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95BBEC43334 for ; Fri, 15 Jul 2022 20:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=no5VUJr9ASCO4KE7m1iY/bOP254CGiOuKJc52yu4KMQ=; b=NTw2nz9ND5ZUff 2qUFmT13KhWHeAXHXuLhOxuAWND8X71SzPPCVvfUDIBL6y64VUlf1mOGP69NLNJ4czhS2n+9/7Ouw WfVeu52dXoBaner5OFsTg+lmZx0CEy5Ls6K64Cw2yv/LcH3IO9bLW1EhHqgR7c+eXelclSMQZSKbF vhMRevcMlFggwUMWEDsgwJ18wP0HcAe2tpNihauHp4iczYyRRByzfOxt+YRWYce5dGLenj/E3fk69 sj9E7k+PdVvxKU02NQchELxvoKh74hKihnnr0H76Ypwf2AzfqfaPV9p3TEEhQMr/Tz+c2wMLiKaL0 vHUbf19kTpWyCdfE3cyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCRev-00A4PA-0M; Fri, 15 Jul 2022 20:11:33 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCRes-00A4OZ-C1; Fri, 15 Jul 2022 20:11:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657915890; x=1689451890; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=FKJ/dIF3JDEjcdCfFHYJXRw3fJQKzGLSXIktrmv9EfU=; b=A9l5ZG6HkNzBX0AhxkYFsEvQyzgCfpu15884ol65Ff+dTI4Pk4AMqa11 CxVuhdNMoCcV7DmHU81mde/hrLoXdG7Eow23EnqmvEQOZ5kLUhnaKphQM HMwCx1FKSgyVRtaYXv1pT8eAtbH17jMhFWIxIRSndBMOjktPxkx4k5u7v aB2SwiXr4MprHmSc/6ox5RDNP+n4Q2QrtU9E/USbJLH1f2TfVfccZibVB eWByHHNrORafRmUNnECPDbIvpZTDUc9jCgtnhN+VvS5PovH1Q55L2jeTm pJipBLEkjouYYkyN7CAzrjTanuYEd4D26t6/Opf0TVxbmnvtV09s5uAw7 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10409"; a="266303734" X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="266303734" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 13:11:29 -0700 X-IronPort-AV: E=Sophos;i="5.92,274,1650956400"; d="scan'208";a="686087461" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 13:11:22 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oCReg-001JEh-2D; Fri, 15 Jul 2022 23:11:18 +0300 Date: Fri, 15 Jul 2022 23:11:18 +0300 From: Andy Shevchenko To: "Russell King (Oracle)" Cc: Andrew Lunn , Heiner Kallweit , Alexandre Belloni , Alvin __ipraga , Claudiu Manoil , Daniel Scally , "David S. Miller" , DENG Qingfang , Eric Dumazet , Florian Fainelli , George McCollister , Greg Kroah-Hartman , Hauke Mehrtens , Heikki Krogerus , Jakub Kicinski , Kurt Kanzenbach , Landen Chao , Linus Walleij , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Sean Wang , UNGLinuxDriver@microchip.com, Vivien Didelot , Vladimir Oltean , Woojung Huh , Marek =?iso-8859-1?Q?Beh=FAn?= Subject: Re: [PATCH net-next 5/6] net: dsa: use swnode fixed-link if using default params Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_131130_478347_9F77C266 X-CRM114-Status: GOOD ( 23.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 15, 2022 at 05:01:48PM +0100, Russell King (Oracle) wrote: > Create and use a swnode fixed-link specification for phylink if no > parameters are given in DT for a fixed-link. This allows phylink to > be used for "default" cases for DSA and CPU ports. Enable the use > of phylink in all cases for DSA and CPU ports. > Co-developed by Vladimir Oltean and myself. Why not to use Co-developed-by: Vladimir Oltean ? > Signed-off-by: Vladimir Oltean > Reviewed-by: Marek Beh=FAn > Signed-off-by: Russell King (Oracle) ... > +static struct { > + unsigned long mask; > + int speed; > + int duplex; > +} phylink_caps_params[] =3D { > + { MAC_400000FD, SPEED_400000, DUPLEX_FULL }, > + { MAC_200000FD, SPEED_200000, DUPLEX_FULL }, > + { MAC_100000FD, SPEED_100000, DUPLEX_FULL }, > + { MAC_56000FD, SPEED_56000, DUPLEX_FULL }, > + { MAC_50000FD, SPEED_50000, DUPLEX_FULL }, > + { MAC_40000FD, SPEED_40000, DUPLEX_FULL }, > + { MAC_25000FD, SPEED_25000, DUPLEX_FULL }, > + { MAC_20000FD, SPEED_20000, DUPLEX_FULL }, > + { MAC_10000FD, SPEED_10000, DUPLEX_FULL }, > + { MAC_5000FD, SPEED_5000, DUPLEX_FULL }, > + { MAC_2500FD, SPEED_2500, DUPLEX_FULL }, > + { MAC_1000FD, SPEED_1000, DUPLEX_FULL }, > + { MAC_100FD, SPEED_100, DUPLEX_FULL }, > + { MAC_10FD, SPEED_10, DUPLEX_FULL }, > + { MAC_1000HD, SPEED_1000, DUPLEX_HALF }, > + { MAC_100HD, SPEED_100, DUPLEX_HALF }, > + { MAC_10HD, SPEED_10, DUPLEX_HALF }, > +}; > + > +static int dsa_port_find_max_speed(unsigned long caps, int *speed, int *= duplex) > +{ > + int i; > + > + *speed =3D SPEED_UNKNOWN; > + *duplex =3D DUPLEX_UNKNOWN; > + > + for (i =3D 0; i < ARRAY_SIZE(phylink_caps_params); i++) { > + if (caps & phylink_caps_params[i].mask) { > + *speed =3D phylink_caps_params[i].speed; > + *duplex =3D phylink_caps_params[i].duplex; > + break; With the below check it's way too protective programming. return 0; > + } > + } > + > + return *speed =3D=3D SPEED_UNKNOWN ? -EINVAL : 0; return -EINVAL; > +} ... > +static struct fwnode_handle *dsa_port_get_fwnode(struct dsa_port *dp, > + phy_interface_t mode) > +{ > + struct property_entry fixed_link_props[3] =3D { }; > + struct property_entry port_props[3] =3D {}; A bit of consistency in the assignments? Also it seems you are using up to 2 for the first one and only 1 in the sec= ond one. IIUC it requires a terminator entry, so it means 3 and 2. Do we really need 3 in the second case? > + struct fwnode_handle *fixed_link_fwnode; > + struct fwnode_handle *new_port_fwnode; > + struct device_node *dn =3D dp->dn; > + struct device_node *phy_node; > + int err, speed, duplex; > + unsigned long caps; > + > + phy_node =3D of_parse_phandle(dn, "phy-handle", 0); fwnode in the name, why not to use fwnode APIs? fwnode_find_reference(); > + of_node_put(phy_node); > + if (phy_node || of_phy_is_fixed_link(dn)) > + /* Nothing broken, nothing to fix. > + * TODO: As discussed with Russell, maybe phylink could provide > + * a more comprehensive helper to determine what constitutes a > + * valid fwnode binding than this guerilla kludge. > + */ > + return of_fwnode_handle(dn); > + > + if (mode =3D=3D PHY_INTERFACE_MODE_NA) > + dsa_port_find_max_caps(dp, &mode, &caps); > + else > + caps =3D dp->pl_config.mac_capabilities & > + phylink_interface_to_caps(mode); > + > + err =3D dsa_port_find_max_speed(caps, &speed, &duplex); > + if (err) > + return ERR_PTR(err); > + > + fixed_link_props[0] =3D PROPERTY_ENTRY_U32("speed", speed); > + if (duplex =3D=3D DUPLEX_FULL) > + fixed_link_props[1] =3D PROPERTY_ENTRY_BOOL("full-duplex"); > + > + port_props[0] =3D PROPERTY_ENTRY_STRING("phy-mode", phy_modes(mode)); > + > + new_port_fwnode =3D fwnode_create_software_node(port_props, NULL); > + if (IS_ERR(new_port_fwnode)) > + return new_port_fwnode; > + > + /* Node needs to be named so that phylink's call to > + * fwnode_get_named_child_node() finds it. > + */ > + fixed_link_fwnode =3D fwnode_create_named_software_node(fixed_link_prop= s, > + new_port_fwnode, > + "fixed-link"); > + if (IS_ERR(fixed_link_fwnode)) { > + fwnode_remove_software_node(new_port_fwnode); > + return fixed_link_fwnode; > + } > + > + return new_port_fwnode; > +} -- = With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel