Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp519297rdb; Mon, 29 Jan 2024 09:10:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyPOColKFN9oPnPp36ymndTj3zmiUYh0XB5JPyovaNNmJSMJxOuSQE5kL+Iwq+DKC65EB+ X-Received: by 2002:a05:6358:ca8:b0:178:7630:fb4e with SMTP id o40-20020a0563580ca800b001787630fb4emr1689208rwj.60.1706548202261; Mon, 29 Jan 2024 09:10:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706548202; cv=pass; d=google.com; s=arc-20160816; b=PEjMpy42ySt/ei2z1+vPw+E3Fd3VIZu4x5vEwlD5q9PU14FgWbFaZN2KYVXZHKj74I YjR5kdkiVAAIFB0rFswxbO9HtFDpjrMOyFw2Gpyrk0201fOcmNOG/P+Q7B/863WZS1TJ JfeNisCX2GHkFfDGZB2nR0XILSbDKjGBjULhGuOAsBxokBGyTsR/omoFSCXJSw2KfpK0 yoMU0YlipddIsePoRMIBGoHSdJujn33t5nV/4M9GTfAYLoUSedgDDWJ+Ki+jaMnw6eXt BVn/UhC/2LW6J8iJm5EeuyoJxCB/4dqIDESKVaCRYPDVjZX2ndFV3EG2ES51WJcBu/V2 ZIHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NF3mmOQ6GVgsm925+kBXyiGJ2mkwAdwIdNKvhd/vV3g=; fh=/YJd8cagnZyj8HxcDZG6YnlmNxAW8XcSWCpxhbbfMGA=; b=v3djiIMt+cFprNsLH7NhqDBfvJ38ZFuQmsrJBEK4a7bqf+8Nyr6T7/psXrf+oWqkGr YtTl94CFIyZq43fHmVjqm1XwfgL9Ls3wal8U5G8wpBMTTBpiPnF9ERlZqdIDb4Uml4s0 Q19uNrgoovrEST5vNEajmNEN4nYD5Q7WlZ2grHt8XqTCVniuD2qORfdUh15WukKIbMMS TqVxQxQrzvn7bdlvh4Br2uehEZWsI6wHK4p7y0JtYVA9JMmhXNo3QXpdK+LIymkcUqQu vO4l/yLU17QLI6a55m6Q0HgeE7xtDcS3OtOoHk/he8XClQ+DIbh0e7rV5nw+p3Hhs6w7 8QRA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SF4+9r9R; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p53-20020a056a0026f500b006dbe4d086cbsi5971962pfw.45.2024.01.29.09.10.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:10:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SF4+9r9R; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42751-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6C36DB23C03 for ; Mon, 29 Jan 2024 13:07:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0395863108; Mon, 29 Jan 2024 13:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SF4+9r9R" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 845E0627F4; Mon, 29 Jan 2024 13:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706533553; cv=none; b=NLUTxdRmRvtXo6TurBDgNIbPvL9XerNHs0V48IV9b8pJLeXMz/eg/QQl0SHcfBkxHc3PqTw0USF+M0lZlI7lhW6L3Zo8MDKRkSePvED2bMNBwfDL5dWkdtw/4dnJJU9TSHFAmBKDMlgo+yRDM+vPoG7BIBFs40AiE8NhUlPR+pQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706533553; c=relaxed/simple; bh=swhxBtRu+RCpSe8dZMPl6Dv+QRyu2q9F2b9dNeHS8cM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K3f3d7Gn2GIUmeQJxQWojfFYSweQTspJZNw8Horab0f9EL/Mfc4WxBYYU5kCceX8cNHkOPjBILYo4Mwf0o4diJudn2SfXj4H+BoNntSbF0m4DpttQDEn2zJFDH/G6hWQm3JDCFaMQ7RZZnoQ3Cze04n4+N6dyd9yf5ZiNnhBXr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SF4+9r9R; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706533552; x=1738069552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=swhxBtRu+RCpSe8dZMPl6Dv+QRyu2q9F2b9dNeHS8cM=; b=SF4+9r9RT1IReowuWanzD0Ll+i904ZhLhBZ/WGPemvvmVzl0nYb3vhSe EEdaSWE+1xbsl4uZUMQQV1jxq/Rcvw1c3N2RCsM79mwA0RGaDpscDXUAz tvsEgaNHWAYTa5CNu7Lp39L/ffdG5YxoWNSUcTfM2ew4zKPEryRosv3ID LwcxGzceuYGKXefvLJSNNSuCXgrITmF0719qPMH8RqUjZO/cD9Of905wQ dG4UaFzIoyazfUDcfLBx98uEN3+vi+kMa0ggM1l8sHZamaemANKq27nUo gR69Yk3R+jCbZRX648nIucsLwV6WnT+h68KiVmF5/YQCIkc172fy4MuTy A==; X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="21473469" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="21473469" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 05:05:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="907106807" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="907106807" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmsmga002.fm.intel.com with ESMTP; 29 Jan 2024 05:05:43 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Simon Horman , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v4 05/11] net: stmmac: select PCS negotiation mode according to the interface mode Date: Mon, 29 Jan 2024 21:02:47 +0800 Message-Id: <20240129130253.1400707-6-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129130253.1400707-1-yong.liang.choong@linux.intel.com> References: <20240129130253.1400707-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The 'stmmac_get_pcs_neg_mode' is invoked during link initialization or interface mode changes. In cases where 'priv->plat->get_pcs_neg_mode' is absent, the default 'phylink_pcs_neg_mode' function is utilized. Additionally, the 'intel_get_pcs_neg_mode' function is available to determine the PCS negotiation mode based on the provided interface mode. Signed-off-by: Choong Yong Liang --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 44 +++++++++++++++---- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++ include/linux/stmmac.h | 2 + 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 60283543ffc8..5110af776c8f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -414,6 +414,39 @@ static void intel_mgbe_pse_crossts_adj(struct intel_priv_data *intel_priv, } } +static bool is_fixed_link(struct pci_dev *pdev) +{ + struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); + bool is_fixed_link = false; + + if (fwnode) { + struct fwnode_handle *fixed_node; + + fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); + if (fixed_node) + is_fixed_link = true; + + fwnode_handle_put(fixed_node); + } + + return is_fixed_link; +} + +static unsigned int intel_get_pcs_neg_mode(phy_interface_t interface, + struct pci_dev *pdev) +{ + unsigned int neg_mode; + + if ((interface == PHY_INTERFACE_MODE_SGMII || + interface == PHY_INTERFACE_MODE_1000BASEX) && + !is_fixed_link(pdev)) + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; + else + neg_mode = PHYLINK_PCS_NEG_OUTBAND; + + return neg_mode; +} + static void common_default_data(struct plat_stmmacenet_data *plat) { plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ @@ -590,15 +623,8 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, } /* For fixed-link setup, we clear xpcs_an_inband */ - if (fwnode) { - struct fwnode_handle *fixed_node; - - fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); - if (fixed_node) - plat->mdio_bus_data->xpcs_an_inband = false; - - fwnode_handle_put(fixed_node); - } + if (is_fixed_link(pdev)) + plat->mdio_bus_data->xpcs_an_inband = false; /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d1ec075ae10a..00af5a4195fd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1104,11 +1104,28 @@ static void stmmac_mac_link_up(struct phylink_config *config, stmmac_hwtstamp_correct_latency(priv, priv); } +static unsigned int stmmac_get_pcs_neg_mode(struct phylink_config *config, + unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising) +{ + struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); + unsigned int neg_mode; + + if (priv->plat->get_pcs_neg_mode) + neg_mode = priv->plat->get_pcs_neg_mode(interface, priv->plat->pdev); + else + neg_mode = phylink_pcs_neg_mode(mode, interface, advertising); + + return neg_mode; +} + static const struct phylink_mac_ops stmmac_phylink_mac_ops = { .mac_select_pcs = stmmac_mac_select_pcs, .mac_config = stmmac_mac_config, .mac_link_down = stmmac_mac_link_down, .mac_link_up = stmmac_mac_link_up, + .mac_get_pcs_neg_mode = stmmac_get_pcs_neg_mode, }; /** diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index b99d11f4ff26..778bdfc3f010 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -277,6 +277,8 @@ struct plat_stmmacenet_data { int (*serdes_powerup)(struct net_device *ndev, void *priv); void (*serdes_powerdown)(struct net_device *ndev, void *priv); void (*speed_mode_2500)(struct net_device *ndev, void *priv); + unsigned int (*get_pcs_neg_mode)(phy_interface_t interface, + struct pci_dev *pdev); void (*ptp_clk_freq_config)(struct stmmac_priv *priv); int (*init)(struct platform_device *pdev, void *priv); void (*exit)(struct platform_device *pdev, void *priv); -- 2.34.1