Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1851346rwl; Thu, 30 Mar 2023 02:19:36 -0700 (PDT) X-Google-Smtp-Source: AKy350bji6l3ULyXpIdq25YbJgrZT3/8YxAETJkeFHWfdCwETKsuLWbXBiNyx9uTs/lXrM7mNYf/ X-Received: by 2002:a17:906:224e:b0:92c:fc0:b229 with SMTP id 14-20020a170906224e00b0092c0fc0b229mr1685754ejr.0.1680167976045; Thu, 30 Mar 2023 02:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680167976; cv=none; d=google.com; s=arc-20160816; b=t4sYWTdpSgv1UMxMNVQarrnxKxzAzda3iFX3RRbTj/kN5bt3oUv5e6RlWQZLt9s929 I2JGL8Fw2UpKZEwKEdTNT+Nwwj1W8lEUOFAUrronq2whvlOCK3SmZCcaYMG24VEX4V2c HyW2cPAumn0k5r9F05iUm78XOH3seJJ1e2w2G64pxSdyBfaqnZPeEO/pqmju0v55ku4f BqWJh+HC4LXcf5buOVrwBhG38mDb5w37eMiBuoG/ZKF27RbMu3uE3TLPDPlxy8DJTB2a Xgn21LPWHfJxmzMwcoOswUIEfR2Id3+489wHTCOR1+lj3LoLVtqomUWGknRr69WRNk2i QvcA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4HPaR5A53quMi2uxB6Lwfp7K0MJyZzMxL3dhXe+02Rw=; b=LVEdUQwWcMPyJL1hfNqCn6S4cJ0ru68RoNYMjY9tyd514YDMfofusTW2NcqxYrhEBL WuWX8wMuCGMYCM5C4M4JJf3g+i642fbxieviCl1xuUTbOOJOdQJnf6O1au/3989YboTU pU4VTuFAAcgWyE+/f5hRiwhz1ehzzA/1XXybaHht9RcGj6RfIhTq0dI7gC4442suKbte Mg0TR6nQr0ayMBe+H6GCpDwNnzmFxg10YntFYOwIe26wK7caH1LYxoURd751nHy3gpBc Fp94lIr10OvGG7H+px5KHWPwXVRLhUtK4iHQql8xTsPFeCK8VaAWEjojvluzBeVRIDJu MbCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gVOX11q6; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vo9-20020a170907a80900b0093f0fced517si12797213ejc.373.2023.03.30.02.19.10; Thu, 30 Mar 2023 02:19:36 -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=@intel.com header.s=Intel header.b=gVOX11q6; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbjC3JPS (ORCPT + 99 others); Thu, 30 Mar 2023 05:15:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbjC3JPG (ORCPT ); Thu, 30 Mar 2023 05:15:06 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 476F21738; Thu, 30 Mar 2023 02:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680167705; x=1711703705; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EQDSnthQ5cFmTJaAo9m1vejrcveOKhLU44+A2MCijjk=; b=gVOX11q6H70AC9mktoatnHzTOk5Bjd35ksjMv06igVEsKFK6TrnGj5Sq 1qPpKKvIuN9D/DDM/gGmk+TVq3R7OHBehVXJsZhxG8PM5EPaI5Vt1c2Pj k3OUA8n9rlsJkeWxyUmtIc/HUwN7bywGW42VtiKuIlwZ57+bc5IPwIy8l sJ0ndKQiPJwZZ8lYDiQDpx6NXgL2O0cSxDrcKlPu7it6MlGeooiVGJCjI zYRtSNb+inpryjWPVwH55flBCJ6wpyjaSg8sx2FI4TPcD+GA4TzyQkEnf KZoxuVASUBLILcDKr7shdeegvgvJoU41aZyJ/JDQLoIElA1Dsw5VKOGUr A==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="325038866" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="325038866" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 02:15:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="678125408" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="678125408" Received: from mike-ilbpg1.png.intel.com ([10.88.227.76]) by orsmga007.jf.intel.com with ESMTP; 30 Mar 2023 02:14:52 -0700 From: Michael Sit Wei Hong To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Ong Boon Leong , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, hkallweit1@gmail.com, andrew@lunn.ch Cc: Looi Hong Aun , Voon Weifeng , Lai Peter Jun Ann Subject: [PATCH net v5 1/3] net: phylink: add phylink_expects_phy() method Date: Thu, 30 Mar 2023 17:14:02 +0800 Message-Id: <20230330091404.3293431-2-michael.wei.hong.sit@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330091404.3293431-1-michael.wei.hong.sit@intel.com> References: <20230330091404.3293431-1-michael.wei.hong.sit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Provide phylink_expects_phy() to allow MAC drivers to check if it is expecting a PHY to attach to. Since fixed-linked setups do not need to attach to a PHY. Provides a boolean value as to if the MAC should expect a PHY. Returns true if a PHY is expected. Reviewed-by: Russell King (Oracle) Signed-off-by: Michael Sit Wei Hong --- drivers/net/phy/phylink.c | 19 +++++++++++++++++++ include/linux/phylink.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 1a2f074685fa..30c166b33468 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1586,6 +1586,25 @@ void phylink_destroy(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_destroy); +/** + * phylink_expects_phy() - Determine if phylink expects a phy to be attached + * @pl: a pointer to a &struct phylink returned from phylink_create() + * + * When using fixed-link mode, or in-band mode with 1000base-X or 2500base-X, + * no PHY is needed. + * + * Returns true if phylink will be expecting a PHY. + */ +bool phylink_expects_phy(struct phylink *pl) +{ + if (pl->cfg_link_an_mode == MLO_AN_FIXED || + (pl->cfg_link_an_mode == MLO_AN_INBAND && + phy_interface_mode_is_8023z(pl->link_config.interface))) + return false; + return true; +} +EXPORT_SYMBOL_GPL(phylink_expects_phy); + static void phylink_phy_change(struct phy_device *phydev, bool up) { struct phylink *pl = phydev->phylink; diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..637698ed5cb6 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -574,6 +574,7 @@ struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *, phy_interface_t iface, const struct phylink_mac_ops *mac_ops); void phylink_destroy(struct phylink *); +bool phylink_expects_phy(struct phylink *pl); int phylink_connect_phy(struct phylink *, struct phy_device *); int phylink_of_phy_connect(struct phylink *, struct device_node *, u32 flags); -- 2.34.1