Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp85826imn; Thu, 28 Jul 2022 23:55:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vxn9vstfTVsLiUcRyWaqlZeC89RNKsbcHDDgkMVVcZ5F0Bjplnz/pqaZUOqNQC5Hqr5k4J X-Received: by 2002:a63:d5:0:b0:41a:58f:929e with SMTP id 204-20020a6300d5000000b0041a058f929emr1842923pga.260.1659077722647; Thu, 28 Jul 2022 23:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659077722; cv=none; d=google.com; s=arc-20160816; b=kdy2INWaHZt4HO0oIvYJIVkcYCl0CGsSGBODSNc4rimXZ8L3+TRUVHEbAf1+xvmoPs 9mPViY3ChUglgft+OV9NzqOqjQSvFhSxITz7bBY+8d0PGNM7zUNDDVG8cPFqAM5CJlX3 Ckc8529bPD9eyjcx3Es8/UWuQmBavwnZnJKjoC3Xbj0kJbvWmoCp8C6xjKEsN/WxP1OH EOq7BcvEQyENJVHl8ktrHm9KtD6lkLLfZL4UZHpf48sYmWfaP4RKYigPOYjeiwWLK9Kx PxS5XaasMuwPLvuY0OdPeltZX1lMYtqMI3HTxJTo29XxGmyoeW973LHU8+HXjaAV/o0P YhMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=VArjTbD7FSaQb0tgbNiKVH96xYPmiJmsUZgAk82eZWo=; b=WCgvRg9Yz1twNPxGS1x6eo+lYpHiIk5jNzEbQ8VBEQHHkToNyglwH45X8aVgCWeHyS 8wJ7HCEPyFvf3KgrcUAwL/H/z7Yqpzi4w+dsrX2iRRTjwBovU+nSCEPPm/FVjo2CntSy Gmev4TsV3wnm35H162R3YG+mX1pSg3T9jKKZoqHZEqUOnAVtQ1fqh0idz1sJ8Qo0r6gr 2oQySDcF9P9o0uRx2pTGKGWZVx83pQfRgJxC0SlhYgEcTHiSdHguZ4Qdu1JTQeOmBzju 553RWZbTM7H6ABdl2zuXfnrXnAUhnadlJ6ZYCoPqpE/ZKu0QLFdvV7tPD75jcGWH1AMr CoRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bEemRDID; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a056a001a4a00b00527d4769260si2959178pfv.332.2022.07.28.23.55.07; Thu, 28 Jul 2022 23:55:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bEemRDID; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234513AbiG2Gut (ORCPT + 99 others); Fri, 29 Jul 2022 02:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233434AbiG2Gup (ORCPT ); Fri, 29 Jul 2022 02:50:45 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D3020BD6; Thu, 28 Jul 2022 23:50:42 -0700 (PDT) Received: (Authenticated sender: maxime.chevallier@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 305B520003; Fri, 29 Jul 2022 06:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1659077441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VArjTbD7FSaQb0tgbNiKVH96xYPmiJmsUZgAk82eZWo=; b=bEemRDID19M43BonRh9+LrwTyv+asZ6HnYNrwN2wAs4IxK4gXZvfbOuaBOKkrjpoLX8vI1 CsIfvQ5e6EASKP6NdwohvCWw8jMkKFBo9EtHbROv71YvLESAG4ihNJiE87Vv3FNEwm2fzN S5lXlQYqAsGBcZM5IgIoQzneEZKfgULbdZ6JbeEJSw2DSh5U6r3CsAKd+HKvXL2xOSEm0n e0AtAI64jsaKmXQRRoiyRj4m/0/j/ncO2TEjHH3s0GNFayFQN5r+qBF72YDAQAN28/Tz/+ O2EgigmKSMmpI4/U1p61EZutyQ9Q0LYyN8J+MthD9tPy4b9BLyXBr8h4du9k0A== Date: Fri, 29 Jul 2022 08:50:36 +0200 From: Maxime Chevallier To: Florian Fainelli Cc: Andrew Lunn , davem@davemloft.net, Rob Herring , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Horatiu.Vultur@microchip.com, Allan.Nielsen@microchip.com, UNGLinuxDriver@microchip.com Subject: Re: [PATCH net-next 3/4] net: phy: Add helper to derive the number of ports from a phy mode Message-ID: <20220729085036.2b180478@pc-10.home> In-Reply-To: References: <20220728145252.439201-1-maxime.chevallier@bootlin.com> <20220728145252.439201-4-maxime.chevallier@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Florian, Andrew, On Thu, 28 Jul 2022 14:44:47 -0700 Florian Fainelli wrote: > On 7/28/22 14:32, Andrew Lunn wrote: > >> +int phy_interface_num_ports(phy_interface_t interface) > >> +{ > >> + switch (interface) { > >> + case PHY_INTERFACE_MODE_NA: > >> + case PHY_INTERFACE_MODE_INTERNAL: > >> + return 0; > > > > I've not yet looked at how this is used. Returning 0 could have > > interesting effects i guess? INTERNAL clearly does have some sort of > > path between the MAC and the PHY, so i think 1 would be a better > > value. NA is less clear, it generally means Don't touch. But again, > > there still needs to be a path between the MAC and PHY, otherwise > > there would not be any to touch. > > > > Why did you pick 0? My reasonning was that PHY_INTERNAL is likely a custom solution to link IPs existing on the same die, so nothing prevents vendors from multiplexing links on that interface. But it's a far-fetched reasonning, so 1 can be good, as other interfaces that are meant to be used on-die like XGMII. > I would agree that returning 1 is a more sensible default to avoid > breaking users of that function. However this makes me wonder, in > what case will we break the following common meaning: > > - Q -> quad > - P -> penta > - O -> octal > > Is the helper really needed in the sense that the phy_interface_t > enumeration is explicit enough thanks to or because of its name? -- > Florian Good question actually ! It started as a point from Russell proposing a helper to get the number of serdes lanes for a given interface, but this sisn't quite fit the use-case, which was simply to simplify if (interface == PHY_INTERFACE_MODE_QSGMII || interface == PHY_INTERFACE_MODE_QUSGMII) into if (phy_interface_num_ports(interface) == 4) But this a slim simplification at the cost of a new helper to maintain, so I can repove that if you want. Thanks for the reviews, Maxime