From patchwork Sat Feb 17 18:08:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 202669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp447589dyc; Sat, 17 Feb 2024 10:12:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbwKrpjP3XG2xZo/dzgLK4Gt5ZnY8Q+sEiQOYD7FHp1zDC6x4oUQiwpAUc6l9f8vfy+X9zEAcFTRyco9jF62kgzZgLLw== X-Google-Smtp-Source: AGHT+IEU2FWUjkHe7y5+XPYGi4CcrnTg1a+HuaUMwLNHRZ149+eCAXv9KnnPoOjH9aAV3LYBlcyS X-Received: by 2002:a92:d350:0:b0:363:c47c:f64e with SMTP id a16-20020a92d350000000b00363c47cf64emr9297209ilh.4.1708193553480; Sat, 17 Feb 2024 10:12:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708193553; cv=pass; d=google.com; s=arc-20160816; b=AGyU55EFS4AMgvvmUQnjUo2VPE/LsO1qdnQu2WmVjCn+TcWtu/3mqJFczI2oxeiY+I S5f0mjFfVwvyXfwxdJp5dfDMNp1/tNBb1KYHdoUcEpcCOlm+zQwcBwnP7K8D/yWFgXpe e7w8WNOty2INdgSnjPq+L37qtDboUbAqbhu3eo1pRt/rjsKOPFNAsp+bIkrC6EJpo+yW BAhDFS9m1MGBVqmfd8qetz9X4f9q9Gg0oATfp5LKAeMp5R1cVk53vrLEopVd8eIdI2E8 wqJ0bMlbbdKULPz2n5UWEKqnOI3GguShlE2tP4oFG+0UD8wA9IVJcDqj3MW5oUgFVYbb aZyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=4VBrx1qM6Gzjf/dZj0JHXBU4KIuERNSMCLhowQQxEkc=; fh=7ogY8TTBnoDyVw0Ew02z/XaZICVahvk3b1eitAEneUQ=; b=0ZiEMNAUHmkmpK+lqvS2Eeu4K82khn9McC539GfA+juA365np8AvGnzcyAdmDM9OIs uopDFSZ76sujT/UdyzKP+8r/L9BTBnXxMlMFfrUDQSawPUGrUQO+bkV5F/iYg7+zslEU T+4zPDw+JGDEfCGvBRDJk2UsZsJ0vgUJOx2sVvpBipqO2qpR8QHIFCL/pEgoqCxNZ/oc DO50Iiyxj1XFsi4a/34g2nWaTTZ5WHwc6Um2u+kpeZXtpaFsBFRfi+myJOgYFcVtaPSa R52hOatXfgTec7IN6lxx8JnIELUJ7XkmXkh6A+9Vlzzoy7IJ7Bq4IsoCoNfhWJ0k69UT qZVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=WLzCMe+j; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-70006-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70006-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f21-20020a633815000000b005dc529d418dsi1740118pga.750.2024.02.17.10.12.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 10:12:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70006-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=WLzCMe+j; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-70006-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70006-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2BECA28172E for ; Sat, 17 Feb 2024 18:12:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEA7C80040; Sat, 17 Feb 2024 18:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="WLzCMe+j" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 539627F7F5; Sat, 17 Feb 2024 18:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708193375; cv=none; b=CJvJ8PyMGtykXheev03l9b76oEkQbwkAfBKnya49JbgvSnKJSrUV4yW7xgD2lsBK9QkCoolJ+a2ZO/jcf1R9pttNhyOaC8T2Mk/QTwVSIhoMfqtyfDR9AfdkemKVq4uHRR39Wja7yIuCauPc7G/aEmKl33CTrccie8vqT3RfKWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708193375; c=relaxed/simple; bh=JAaXmFLPL7MF52z7W5bakKctdf1rOc6D32Y12paOGJs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sqklW8pCL45lC5GNwDsPz+G98XdLbjClVwQc+E124j1uiDUJfhvV16q1taHkL6n5lnKt5f+fCgLefCPt2LYdtFTAX3yOpO2aqegduD178sHRjwp+CQQGmXzBrvNG11GD0dk0hgecH2AYw+dlQqTCXozpOgs3BVNxM4P/iqOKWBQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=WLzCMe+j; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:From: Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Content-Disposition: In-Reply-To:References; bh=4VBrx1qM6Gzjf/dZj0JHXBU4KIuERNSMCLhowQQxEkc=; b=WL zCMe+jixLCOsxo+Y0NyK+tVSvJ8oEncWSyNjpOuE3bs1s6VaQ7NxGEctJJAhwt19Tfo7/NSK9nMPF TqZZ9G3hst3qbl/yQDtH1VzcTM6TIgXP7A+EXYfjK1S3M7q45leW+V8ZNDTn1wAjFZTmJjPL7Jk3B y3rMEmwonxzPKcw=; Received: from c-76-156-36-110.hsd1.mn.comcast.net ([76.156.36.110] helo=thinkpad.home.lunn.ch) by vps0.lunn.ch with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rbP8A-0084hf-BG; Sat, 17 Feb 2024 19:09:42 +0100 From: Andrew Lunn Date: Sat, 17 Feb 2024 12:08:28 -0600 Subject: [PATCH net-next v3 7/8] net: intel: igb: Use linkmode helpers for EEE Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240217-keee-u32-cleanup-v3-7-fcf6b62a0c7f@lunn.ch> References: <20240217-keee-u32-cleanup-v3-0-fcf6b62a0c7f@lunn.ch> In-Reply-To: <20240217-keee-u32-cleanup-v3-0-fcf6b62a0c7f@lunn.ch> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Ariel Elior , Manish Chopra , Jesse Brandeburg , Tony Nguyen Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Andrew Lunn X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3793; i=andrew@lunn.ch; h=from:subject:message-id; bh=JAaXmFLPL7MF52z7W5bakKctdf1rOc6D32Y12paOGJs=; b=owEBbQKS/ZANAwAKAea/DcumaUyEAcsmYgBl0PY7PbH9bV4ynmYdotjif8o5ti3hDTv55GCwL ySlVhIGWEWJAjMEAAEKAB0WIQRh+xAly1MmORb54bfmvw3LpmlMhAUCZdD2OwAKCRDmvw3LpmlM hK/fD/9ztCXRyyqY0vnBtz+rgygONJN/FA3Vvz4Kds2LWhg0JsLeVDrJYEi/j9aPoKRd67ANuP+ a0TAZNT/ZeG3vKikDgJrg9+vnpHvNBrVbFNwB16xfckii6GbYjgIjaOdA1eEyywz4+mMGkDDUod JRPkqbMKf3hE9uz3HrhxwxK+FNoaeF9pFDzhadnX9rE7AhfSNAAgU0tWDjoGlcL8RQic8gkPTNs A8hwNjBfO3W1z/6fm6wh2v8TBzJPjlMH7KJQnk7t4vzCPg1t+hVsV5PKA9FIPlAy230yDetX/CT xdaHGcwodGKufKtQzOsoGBhwLvZpidYdixzMutBkAulhZyc19g+wxWKdY7kF9PxGmoDO9T0D1G4 mxnSDYMH7uHqQgnfCWDcseUv6Oi3qGYQGfjC7XvtGACIj+QkhvGtauA6nI+Zv3pOR5vS07h4MJc 5FtgiWUX714Uncwp5fw3LwJIBOU7/y5HoK7cjZJIhiAqQiOn0vg9IgaGp/3CJsw4QfVTM3NZRr+ hQPckJAi/F2PQ8EOw7WMjItWLXm8afpu0r0wGITYd12vL6pDl4Bg96xcEevL+PQ6i1v6BHt08KF B2xu9/xW6HNxW/Ro41Z+MZBQlPvLYbG1sYRmW7Yf0BV1F+1lcYQBel7kzDFlaMZou3FjIpc4xIe helrL70LGOBWDtA== X-Developer-Key: i=andrew@lunn.ch; a=openpgp; fpr=61FB1025CB53263916F9E1B7E6BF0DCBA6694C84 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791170763764881417 X-GMAIL-MSGID: 1791170763764881417 Make use of the existing linkmode helpers for converting PHY EEE register values into links modes, now that ethtool_keee uses link modes, rather than u32 values. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/intel/igb/igb_ethtool.c | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index b87b23d2151c..5da50574a28c 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -3038,11 +3038,13 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_keee *edata) (hw->phy.media_type != e1000_media_type_copper)) return -EOPNOTSUPP; - edata->supported_u32 = (SUPPORTED_1000baseT_Full | - SUPPORTED_100baseT_Full); + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + edata->supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, + edata->supported); if (!hw->dev_spec._82575.eee_disable) - edata->advertised_u32 = - mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert); + mii_eee_cap1_mod_linkmode_t(edata->advertised, + adapter->eee_advert); /* The IPCNFG and EEER registers are not supported on I354. */ if (hw->mac.type == e1000_i354) { @@ -3068,7 +3070,7 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_keee *edata) if (ret_val) return -ENODATA; - edata->lp_advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(phy_data); + mii_eee_cap1_mod_linkmode_t(edata->lp_advertised, phy_data); break; case e1000_i354: case e1000_i210: @@ -3099,7 +3101,7 @@ static int igb_get_eee(struct net_device *netdev, struct ethtool_keee *edata) edata->eee_enabled = false; edata->eee_active = false; edata->tx_lpi_enabled = false; - edata->advertised_u32 &= ~edata->advertised_u32; + linkmode_zero(edata->advertised); } return 0; @@ -3109,6 +3111,8 @@ static int igb_set_eee(struct net_device *netdev, struct ethtool_keee *edata) { struct igb_adapter *adapter = netdev_priv(netdev); + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(tmp) = {}; struct e1000_hw *hw = &adapter->hw; struct ethtool_keee eee_curr; bool adv1g_eee = true, adv100m_eee = true; @@ -3138,14 +3142,21 @@ static int igb_set_eee(struct net_device *netdev, return -EINVAL; } - if (!edata->advertised_u32 || (edata->advertised_u32 & - ~(ADVERTISE_100_FULL | ADVERTISE_1000_FULL))) { + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, + supported); + if (linkmode_andnot(tmp, edata->advertised, supported)) { dev_err(&adapter->pdev->dev, "EEE Advertisement supports only 100Tx and/or 100T full duplex\n"); return -EINVAL; } - adv100m_eee = !!(edata->advertised_u32 & ADVERTISE_100_FULL); - adv1g_eee = !!(edata->advertised_u32 & ADVERTISE_1000_FULL); + adv100m_eee = linkmode_test_bit( + ETHTOOL_LINK_MODE_100baseT_Full_BIT, + edata->advertised); + adv1g_eee = linkmode_test_bit( + ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + edata->advertised); } else if (!edata->eee_enabled) { dev_err(&adapter->pdev->dev, @@ -3153,7 +3164,7 @@ static int igb_set_eee(struct net_device *netdev, return -EINVAL; } - adapter->eee_advert = ethtool_adv_to_mmd_eee_adv_t(edata->advertised_u32); + adapter->eee_advert = linkmode_to_mii_eee_cap1_t(edata->advertised); if (hw->dev_spec._82575.eee_disable != !edata->eee_enabled) { hw->dev_spec._82575.eee_disable = !edata->eee_enabled; adapter->flags |= IGB_FLAG_EEE;