From patchwork Wed May 10 22:59:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 92329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4012609vqo; Wed, 10 May 2023 17:26:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oXLk1FWqHZEdQt827qqYYduDIxgwr4eT3YQRLpxCe6BiAgc2Py0JtLasPjc4zwCa2Dhzy X-Received: by 2002:a05:6a20:3d09:b0:ee:f290:5b5e with SMTP id y9-20020a056a203d0900b000eef2905b5emr24772774pzi.43.1683764816451; Wed, 10 May 2023 17:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683764816; cv=none; d=google.com; s=arc-20160816; b=CEEhrFOkOFzUekmTGn5gvUfXi3alimYdPnvKGANn3rFV+CUSDei9O3NEohGw4eQupO 4iUJZiTBLVQZj01C8GJzI48X+7StCyy58bPFzIN+878u2f1pYbHuRxX2FFgdeN6Ju0E0 Of2bFtTa8QwEP66sXFJUCHBKMgtwEFelqMyzL+a8GNCAH3gUez0NvtHZaUqdstU/rwL9 +XD67kPo1b2+pZkB/xz+2RNMYTqEO66ZWeLimnmP0UTyKGVsdtq47hZEmkSwNdfjai41 0alaK9smYZ1k7Rg8HADgxcZdONdzxd9elSs2ySWTiBHCu8fF4ODSSL0sybeNKtiB0pUo KHMA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a637149000000b004c259db61fdsi5191483pgn.561.2023.05.10.17.26.39; Wed, 10 May 2023 17:26:56 -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 S236757AbjEJXBU (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-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?1765555376558060429?= X-GMAIL-MSGID: =?utf-8?q?1765555376558060429?= 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);