From patchwork Sat Apr 22 11:49:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 86592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1653711vqo; Sat, 22 Apr 2023 04:56:43 -0700 (PDT) X-Google-Smtp-Source: AKy350asJCcu8xmghejTgBTXcsXTNDJ++7GFEfSeVPvldBESDN5V1jxTB4tXUSX0so/O2sJx3qIH X-Received: by 2002:a17:902:f547:b0:1a0:6bd4:ea9a with SMTP id h7-20020a170902f54700b001a06bd4ea9amr14703049plf.16.1682164603233; Sat, 22 Apr 2023 04:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682164603; cv=none; d=google.com; s=arc-20160816; b=HDhZJiHnTuEV0JzNgqmmxHrrYZ8TIQQN0tKkIq0G1nrBD19OwLVcFz5M/adsMiPhz3 DXHhInT9swbZ2Q5hA24VdAAKpM6Nm2Ajh1y/rc/pbXg/olsWmiHCPUfKmArLJ4634ORj f3oMSAfwH3QcH+26l2cBWtghAQssgeKtqReamytyznJ3QvK+HRTcRq9R/GPdDkrr5g0I FUc2b1CIZJDyk74CRyXLVPbuj847aKgOlNDQibvPZSLHbO+iyFxaL00FHxXciYNbac67 xMlbs1jIlOIxKaD50i+7dEIlDkgGb6lB4mWJihwC5DyS3+2Wj2m72K+N3dbF5Euj+DEG 7IFQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a17090332c800b001a64b2dc495si7321201plr.462.2023.04.22.04.56.31; Sat, 22 Apr 2023 04:56:43 -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 S229837AbjDVLtq (ORCPT + 99 others); Sat, 22 Apr 2023 07:49:46 -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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763877431151128247?= X-GMAIL-MSGID: =?utf-8?q?1763877431151128247?= 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);