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: 55469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1061881wrn; Fri, 10 Feb 2023 08:55:49 -0800 (PST) X-Google-Smtp-Source: AK7set8RY1SCZYhxm8XZBAA9sTT0G9jyd7b6s7q5SglmQHej2Zo+REBgTn5keaVjZZ9zd/1CyM+u X-Received: by 2002:a50:cd88:0:b0:4aa:a1d4:bbd4 with SMTP id p8-20020a50cd88000000b004aaa1d4bbd4mr18094908edi.42.1676048149406; Fri, 10 Feb 2023 08:55:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676048149; cv=none; d=google.com; s=arc-20160816; b=btUs3oyb23vjX3hSL4AlGryiu+mWdHa3t5bVi0QBWOIf82JrguuJSXune5YIFwROnl iKOSHDoy3WeMX5DkY/NUnnKaILzyIGCMSw/7onmVyviABfathOdeBjrlpLbQrK/a2gzg nifZZU8593Mr2GQkVid5CPyFoB71ePhiWNhuODK1cPqKrDRquWgeVq7w3BTsvDYE3UIT jYLobC6TxNYuEtVE4dOWvrPG4nQxMnYmX0AVzyhlVVVQe0ub+fYOtNfs11LmBK5qwWrK my4VizgpCzd4KdMGN3ps6ZudsgjdMuyDuZZQ1kAZBwKJZZvhp4ehiWBNkjRFXtetTTZ4 nrfg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YrSpqlsh8UppvSjHZvi55UQBSkzStYKDyWeLj0I9FHM=; b=qZCyZ2yjulCkdVDuRImn2LcRbJOT1DRKl8iW+0SW4yaZZefJ5mVEBlBWqwiZefGQjN ZRSJQXAkTIgzW+7VW6lYxIQYR6IE52K/9l6GUmkJUhIGTTfYxzrvPIIsChL/UjZL97o7 wdHKU9J6sd/THP97NNzeVtsk3m0YDBI0cR49CuL4Ch395pkuEBN/7R19NuQ33jMO1l/Q SifpFoCS2CMXr5VT/Droc8ESIvQ5USZRLtP5UmC+bHxh/F6VLQwUe7V1EzgloQeuSKiC DqdZQlV5rNgYRVkJXTkL4WSvbyTgk2H2DsMoWEKh0YrbNfF7DWg3lGc/gMU13O+8Zdn6 Smxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@metrotek.ru header.s=mail header.b="VBJ/7MJ0"; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020a50ff17000000b004ab167c179csi3709159edu.261.2023.02.10.08.55.26; Fri, 10 Feb 2023 08:55:49 -0800 (PST) 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=fail header.i=@metrotek.ru header.s=mail header.b="VBJ/7MJ0"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232546AbjBJQrh (ORCPT + 99 others); Fri, 10 Feb 2023 11:47:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232405AbjBJQrf (ORCPT ); Fri, 10 Feb 2023 11:47:35 -0500 X-Greylist: delayed 1810 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 10 Feb 2023 08:47:33 PST Received: from mail.pr-group.ru (mail.pr-group.ru [178.18.215.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880CDE04A for ; Fri, 10 Feb 2023 08:47:33 -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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757463864174804408?= X-GMAIL-MSGID: =?utf-8?q?1757463864174804408?= 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);