From patchwork Mon Jan 29 13:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 193541 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp640466dyb; Mon, 29 Jan 2024 07:27:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCscEP9ovEZJVkysH881W3OGVoqKaviYDJHZoAH8OfQsEJTm9zga3LDDkzgoXl61vbF4uz X-Received: by 2002:a17:902:ea05:b0:1d8:fafa:f923 with SMTP id s5-20020a170902ea0500b001d8fafaf923mr645176plg.10.1706542052952; Mon, 29 Jan 2024 07:27:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706542052; cv=pass; d=google.com; s=arc-20160816; b=jz9DvGcqQE5Mt2KeCFY1hmmkGET7vqe1JzM9idzlTfpQMBxO8cd4PR3caReUCt3b0L BaUBlqYFEy1JtT0BgixBYuh3ycdarkOezuraEkhBYmcQWEcavtAvvj0DulYfK1XUuC8f bmkR4Lcumnp/HUeESgps80AV9HQg3tWEUh+FkXJV4qo7Q5faZO+61qwpFz1em/rC/2jc fJNVZ0cJjH4gwPHJHGQxYDSb3mAxnl5ayFGvCuSDkc+9mg06Nc570u23LUTfiImo+BF0 Eam2vcM+bBhnDblwFy3qtYLdXxVStXAP5JGVPDABDUX8Bykd3Mk5lg5OlwCc8tsZo2vi BSpg== 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=JMcZGl2RB4R2JfGkNQK0KtUvh2qg8mov9Diw38b8QtQ=; fh=/YJd8cagnZyj8HxcDZG6YnlmNxAW8XcSWCpxhbbfMGA=; b=m/w/VDLexl9MU9EAwFcNxJFnSw0+PGSDD47XRCQSGRjJQZzvYoFyPTkrGzIHc+4Vwr jbk0V+xdWUVBKl1S2wZ9YTUr0bzzDrhxjH/8b5jRHp6T4Z6FXAIMhTJrO8VLaeie2yDo w6MWjSjYrRQHDlNuPNupM21o/sMsV2dxms09fUMMf91kvj/OEkLAG3XRLzCvQwrjquXE UgceFfCYbjCiOiYsuaeeYgl4E59O1dmRcACJYaa3i/3wz6XQO8tHRKBmBk5wQiRm07lZ A8aTKdjMZ8ldioz+akXKqhfMu56qNaOEBf5jjA+8KxmsY9Edb1mX2YV7DHQXtaSKLOnc r7SA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cmNgZKxE; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42749-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42749-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h9-20020a170902f7c900b001d8dd447e12si1991659plw.594.2024.01.29.07.27.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 07:27:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42749-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cmNgZKxE; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-42749-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42749-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9669A2874FD for ; Mon, 29 Jan 2024 13:06:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A108627F0; Mon, 29 Jan 2024 13:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cmNgZKxE" 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 2203164CC0; Mon, 29 Jan 2024 13:05:33 +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=1706533535; cv=none; b=ivfU/YSWlZ/3rULWQuzO4NRV4XRmpFfqWYadKNUwtWuMIMesHFRFdGHnPfYFAFsampDDG08mYGJZJWYpQr2832QCtpujmHa6SeAwHWUjOd3MdAi8JcjhIHE3PPlHYnKQWi3j8shtc6WSZHt9s5Q7psMiYSE4pmWMGQmhzEJqblg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706533535; c=relaxed/simple; bh=4DcfKjEUE4Q7uAyGpqdaKfRx/METmTskcQvMbEFG2So=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FAw+4n0QgjHZaoKwhU/e7HDH2cYhOl2c7300Kk69rBZmjJEoHtSoQJWmjPmTArwq3GvqFUWgLP+cIku4CIH6aTveN/0IpybbmJnt8nt9qVU7kP3Te1YUJJ0GD4oqz8YmdfkWE3UzUaiwTQAZ+9RZMshYe41ziS9fpqPptho/LOM= 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=cmNgZKxE; 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=1706533535; x=1738069535; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4DcfKjEUE4Q7uAyGpqdaKfRx/METmTskcQvMbEFG2So=; b=cmNgZKxErDCd4hL6OvkHcAFnMbFgKmE+wSHQG4WPKrlQS5wbzxNhGhGH 9Wi8XEsxLh9q5J2sFn5XUmGcTjD7b6OMtg3VsqvoyfbKUC3x81kqDkjRk s8sZh5hlnuywQ6B1mZKs7MVesjOcvBIpiYijs4AugPoW+UsiDKTO+n2yG mZu3R+oeAJ2dfXvzXkfNRXpFZFqwfnkuQlGHyX/35+qGKCqzRLomeA+sw 79JSvPo/x1xs2NYXCbgfWaLjEcj32xpt/p5XlYt02+VSD5amoCUlj9g0V /uVkWVqqSu29e5Axl5lH5H2QXpKpExpb853Ak3CIHevO4jVEldi7enQiy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="21473394" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="21473394" 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:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="907106751" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="907106751" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmsmga002.fm.intel.com with ESMTP; 29 Jan 2024 05:05:25 -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 03/11] net: phylink: provide mac_get_pcs_neg_mode() function Date: Mon, 29 Jan 2024 21:02:45 +0800 Message-Id: <20240129130253.1400707-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789439039896885975 X-GMAIL-MSGID: 1789439039896885975 Phylink invokes the 'mac_get_pcs_neg_mode' function during interface mode switching and initial startup. This function is optional; if 'phylink_pcs_neg_mode' fails to accurately reflect the current PCS negotiation mode, the MAC driver can determine the mode based on the interface mode, current link negotiation mode, and advertising link mode. For instance, if the interface switches from 2500baseX to SGMII mode, and the current link mode is MLO_AN_PHY, calling 'phylink_pcs_neg_mode' would yield PHYLINK_PCS_NEG_OUTBAND. Since the MAC and PCS driver require PHYLINK_PCS_NEG_INBAND_ENABLED, the 'mac_get_pcs_neg_mode' function will calculate the mode based on the interface, current link negotiation mode, and advertising link mode, returning PHYLINK_PCS_NEG_OUTBAND to enable the PCS to configure the correct settings. Signed-off-by: Choong Yong Liang --- drivers/net/phy/phylink.c | 14 +++++++++++--- include/linux/phylink.h | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 38ee2624169c..27aa5d0a9fc6 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1151,9 +1151,17 @@ static void phylink_major_config(struct phylink *pl, bool restart, phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); - pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, - state->interface, - state->advertising); + if (pl->mac_ops->mac_get_pcs_neg_mode) { + pl->pcs_neg_mode = pl->mac_ops->mac_get_pcs_neg_mode + (pl->config, + pl->cur_link_an_mode, + state->interface, + state->advertising); + } else { + pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, + state->interface, + state->advertising); + } if (pl->using_mac_select_pcs) { pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index b362d3231aa4..adb47d1aa67b 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -169,6 +169,7 @@ void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed); * @mac_finish: finish a major reconfiguration of the interface. * @mac_link_down: take the link down. * @mac_link_up: allow the link to come up. + * @mac_get_pcs_neg_mode: Get PCS negotiation mode for interface mode. * * The individual methods are described more fully below. */ @@ -189,6 +190,10 @@ struct phylink_mac_ops { struct phy_device *phy, unsigned int mode, phy_interface_t interface, int speed, int duplex, bool tx_pause, bool rx_pause); + unsigned int (*mac_get_pcs_neg_mode)(struct phylink_config *config, + unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising); }; #if 0 /* For kernel-doc purposes only. */