Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3399886rwr; Sat, 22 Apr 2023 04:51:57 -0700 (PDT) X-Google-Smtp-Source: AKy350aCF3tX7EjyjRHtkoGHqQpx94YCC22Uc3aBhO4Vek5910IYcDx5jesRiYWmJrVM6BKTeEOO X-Received: by 2002:a17:903:2304:b0:1a9:1b4:9fdd with SMTP id d4-20020a170903230400b001a901b49fddmr9431684plh.2.1682164317263; Sat, 22 Apr 2023 04:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682164317; cv=none; d=google.com; s=arc-20160816; b=ji9Q0zj7m6PBbKv268Cw5SeQSrT6kMiWv+lYEdMJtGL26wUrymribPO1dyZKd9max0 YVT9YGMEb97C2+TonKak+Lag5It/pLszrNoNoAXoCxwm8MLDwhLOY6O46TNCNZQA0oI3 6HHHUkXykggmPxU5PKc1qn+U2qfHwf6LYvuPuRI3bh8JOLcnm5Uom5kSquDDD9u1/aBI uX6Fr/V1ZLAhYL+V8VI6BK33QZR0fvnGOXsFpT0R1k8azBhoozu7wbbeE8aAo6E+6JZx /2vPnj/VxPw/0sBHqkJKy7sGz12tFFSmUr55ygMHYPwb0xgAOMwbw/dLLP745kOYfKYH Xzrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Isek/A4OtvX/p24ma3ttb5X8vJuMUeJmqbeUPAATjd4=; b=ynaZMit2+54xkRXvKKQoZ/76GWuHAG1sgkSDxatdcaHJZoif4qzvgJwP1JJjq+8ygn s/rjkt4+XhR0KiR2TqC6AP5ssCiBuUPguPiSPMjSOZbzR/CUNTvCMaQXg/OT8BfR1/Uh nffOBhqc3SaYRtcT99c2rcGRM7SKekWifbortCQ/tY2aPLDgpOzxVC9TSYe6lm4z9qrK HQqp5Nw/KjDy+kNle9iK2H7lbCIKaAvJpE5uuSlVB615rv/+drpR7nvmxSWjus/p0S5q kQ364wZpQ9GLKn55/pik65xW8IEmS24AtKAwE17fzJ+WP2f//dPCuF3RkanOL0XKfoCt 8ZjQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y12-20020a1709029b8c00b001a777c22a83si6316795plp.507.2023.04.22.04.51.44; Sat, 22 Apr 2023 04:51:57 -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; 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 S229836AbjDVLtp (ORCPT + 99 others); Sat, 22 Apr 2023 07:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbjDVLth (ORCPT ); Sat, 22 Apr 2023 07:49:37 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 323C12D58; Sat, 22 Apr 2023 04:49:16 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pqBju-000863-19; Sat, 22 Apr 2023 13:49:14 +0200 Date: Sat, 22 Apr 2023 12:49:10 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Chen Minqiang , Chukun Pan , Yevhen Kolomeiko , Alexander Couzens Subject: [RFC PATCH net-next 6/8] net: phy: realtek: use inline functions for 10GbE advertisement Message-ID: <9aec1a609fe9e67b43826537aab37081635292f2.1682163424.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Use existing generic inline functions to encode local advertisement of 10GbE link modes as well as to decode link-partner advertisement. Signed-off-by: Daniel Golle --- drivers/net/phy/realtek.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 62fb965b6d338..078f45447ddad 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -68,10 +68,6 @@ #define RTL_SUPPORTS_5000FULL BIT(14) #define RTL_SUPPORTS_2500FULL BIT(13) #define RTL_SUPPORTS_10000FULL BIT(0) -#define RTL_ADV_2500FULL BIT(7) -#define RTL_LPADV_10000FULL BIT(11) -#define RTL_LPADV_5000FULL BIT(6) -#define RTL_LPADV_2500FULL BIT(5) #define RTL9000A_GINMR 0x14 #define RTL9000A_GINMR_LINK_STATUS BIT(4) @@ -669,14 +665,11 @@ static int rtl822x_config_aneg(struct phy_device *phydev) int ret = 0; if (phydev->autoneg == AUTONEG_ENABLE) { - u16 adv2500 = 0; - - if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, - phydev->advertising)) - adv2500 = RTL_ADV_2500FULL; - ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, - RTL_ADV_2500FULL, adv2500); + MDIO_AN_10GBT_CTRL_ADV10G | + MDIO_AN_10GBT_CTRL_ADV5G | + MDIO_AN_10GBT_CTRL_ADV2_5G, + linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising)); if (ret < 0) return ret; } @@ -713,12 +706,7 @@ static int rtl822x_read_status(struct phy_device *phydev) if (lpadv < 0) return lpadv; - linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, - phydev->lp_advertising, lpadv & RTL_LPADV_10000FULL); - linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, - phydev->lp_advertising, lpadv & RTL_LPADV_5000FULL); - linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, - phydev->lp_advertising, lpadv & RTL_LPADV_2500FULL); + mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, lpadv); } ret = rtlgen_read_status(phydev); -- 2.40.0