Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8040392rwr; Wed, 10 May 2023 17:03:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xKAZAf/MYH6WUOwZgUz1kpwOEEGB5zB8ROLUwUtWr0FBpMc6jmEZ1ovUQc7p3w8THoyKq X-Received: by 2002:a05:6a00:1696:b0:633:c311:c70d with SMTP id k22-20020a056a00169600b00633c311c70dmr26378598pfc.14.1683763402914; Wed, 10 May 2023 17:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683763402; cv=none; d=google.com; s=arc-20160816; b=Ovjp7N6npvSZvtCv1khVMsFLxcRrfZo5v5X99//JzrMnCIt60Pg5BmGKfQBMbtygUE WWoQyCObntcUM9/LOqaUouCPOHysxYRVHdyOVDv4X4gifPtslsNj6NhsD+FTXzLLmFRH fgwa0KoszPEBi9mtDrqKJZBD+sUQ9mzVmPsA3h+54pPuvoDCVQUohXJUQWsyYiuYTAqd bxpe7Id8NNr5+Xe5wIfTM4V+uQPetotFD+q8If6lSqoSE/JNTH+Y/r3SJNCPcACm2EEe +e3ppaxcw70jdqRAADbqmBFW8X7b/yUzg5OR2gchM3+BlufaycD8f0hiZ0Myjq69xuWY JIbQ== 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:to:from:date; bh=xwbZ1jtHL2M3/Q8IzuP1FSlh5IPZjJl2FYQVUtS7Ugo=; b=hZ5spafieXZqWOlwsBY5AMbi4ZRKGh7kX50I87TujnQXRMNk5QsQ6SM6eiXkY+Ywwz kKh3k2R2k+Ld4kD4qUxfdkvdNxi7LPMlDRBvm80aVxYVuYqYBs+ZizVU3Gz6EBAHwmYH M46DTae2vnF5x8JH1eJlk/Eihv4eWBSm3jCVWTQ26wWkqfCe/1ieq4Kv2WL/IdF6jwwR 17wCACeBr3eWOLrhFqFYQw629FTBd0PCZ7BdczLKVgdp/pZKRlWU45vhHSZIh3T7UtvR rC/w7PW49tUxfzMgwTOJMl8TpogIubjTijK5tshE7VpMnyDM4IQfKilpCIaWhsIVQl8q nzNQ== 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 u69-20020a638548000000b0050beec2c6cdsi5405071pgd.238.2023.05.10.17.03.08; Wed, 10 May 2023 17:03:22 -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 S236753AbjEJXBU (ORCPT + 99 others); Wed, 10 May 2023 19:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236708AbjEJXBT (ORCPT ); Wed, 10 May 2023 19:01:19 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200DB40EB; Wed, 10 May 2023 16:01:07 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pwsny-0004VH-0l; Wed, 10 May 2023 23:01:06 +0000 Date: Thu, 11 May 2023 00:59:12 +0200 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , AngeloGioacchino Del Regno Subject: [PATCH net-next 6/8] net: phy: realtek: use inline functions for 10GbE advertisement Message-ID: 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 e6a46c4d97b1..cde61a30ac4c 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 val, 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; } @@ -722,12 +715,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