From patchwork Fri Feb 10 15:46:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Bornyakov X-Patchwork-Id: 13136001 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69D09C636CD for ; Fri, 10 Feb 2023 16:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232647AbjBJQrk (ORCPT ); Fri, 10 Feb 2023 11:47:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbjBJQrj (ORCPT ); Fri, 10 Feb 2023 11:47:39 -0500 X-Greylist: delayed 1812 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 10 Feb 2023 08:47:37 PST Received: from mail.pr-group.ru (mail.pr-group.ru [178.18.215.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBEDEEB72 for ; Fri, 10 Feb 2023 08:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=metrotek.ru; s=mail; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding; bh=JyAhWn70jSZ6baYcHd8LQtrCGh6bwhtu+2O+5t5dzvI=; b=VBJ/7MJ0sDWiRfyXEfQBGEoFzqBjSmeksfJJYQJs/yIWjh/EkNXpVth7x8wFF1LQXBD76s2I0O5k9 o6pxvHuqUndAjp1iUEIyOD9eKkQhJH+5ihAP5TiiU3xAZAPOJzAvV43tb+8f0X2GJZxpA7YtwOMy2G RvY5PSIlD/kbtsVCxxYBfuPSJ8y7dtN0PrNKxlya22c84UwyCB1tPySohEgA/XV4I/z+WAS4Egk6FE 9HRs8BZccUaA0DvdoeULWJtn4Rs7SkRyN5gtyqNIQ42leqKY66oX1I3eiRZzLBSgHrphWAEMfgcCkC 9Xn7+v/4PMR17yVpyx9JK9I2SEM1H0g== X-Final-To: netdev@vger.kernel.org, i.bornyakov@metrotek.ru, linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, system@metrotek.ru Received: from localhost.localdomain ([78.37.166.219]) (authenticated user i.bornyakov@metrotek.ru) by mail.pr-group.ru with ESMTPSA (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)); Fri, 10 Feb 2023 18:46:46 +0300 From: Ivan Bornyakov To: netdev@vger.kernel.org Cc: Ivan Bornyakov , Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, system@metrotek.ru Subject: [PATCH net-next] net: phylink: support validated pause and autoneg in fixed-link Date: Fri, 10 Feb 2023 18:46:27 +0300 Message-Id: <20230210154627.19086-1-i.bornyakov@metrotek.ru> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In fixed-link setup phylink_parse_fixedlink() unconditionally sets Pause, Asym_Pause and Autoneg bits to "supported" bitmap, while MAC may not support these. This leads to ethtool reporting: > Supported pause frame use: Symmetric Receive-only > Supports auto-negotiation: Yes regardless of what is actually supported. Instead of unconditionally set Pause, Asym_Pause and Autoneg it is sensible to set them according to validated "supported" bitmap, i.e. the result of phylink_validate(). Signed-off-by: Ivan Bornyakov --- drivers/net/phy/phylink.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 2805b04d6402..ba5d3868604b 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -688,6 +688,7 @@ static int phylink_parse_fixedlink(struct phylink *pl, struct fwnode_handle *fwnode) { struct fwnode_handle *fixed_node; + bool pause, asym_pause, autoneg; const struct phy_setting *s; struct gpio_desc *desc; u32 speed; @@ -760,13 +761,23 @@ static int phylink_parse_fixedlink(struct phylink *pl, linkmode_copy(pl->link_config.advertising, pl->supported); phylink_validate(pl, pl->supported, &pl->link_config); + pause = phylink_test(pl->supported, Pause); + asym_pause = phylink_test(pl->supported, Asym_Pause); + autoneg = phylink_test(pl->supported, Autoneg); s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex, pl->supported, true); linkmode_zero(pl->supported); phylink_set(pl->supported, MII); - phylink_set(pl->supported, Pause); - phylink_set(pl->supported, Asym_Pause); - phylink_set(pl->supported, Autoneg); + + if (pause) + phylink_set(pl->supported, Pause); + + if (asym_pause) + phylink_set(pl->supported, Asym_Pause); + + if (autoneg) + phylink_set(pl->supported, Autoneg); + if (s) { __set_bit(s->bit, pl->supported); __set_bit(s->bit, pl->link_config.lp_advertising);