From patchwork Sun Feb 18 17:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 202813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp870939dyc; Sun, 18 Feb 2024 09:08:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuMGyHSe2bcgc1Qe6RMYSE45Em4BEa8Fm//F+SgmVGjcCft+wjnr99NR9iQEcOj3cfQ4kbb7mTDrxELWZw3IPGFNZHWg== X-Google-Smtp-Source: AGHT+IFCPY2O9k3NvUNuT/5qS32Eza/nuYI+reI+Qrg6n4z4Ddosr730AX+L+zp6lsrhWzhQivPW X-Received: by 2002:a05:6a20:e198:b0:19c:a8a8:5c7b with SMTP id ks24-20020a056a20e19800b0019ca8a85c7bmr13327760pzb.56.1708276132079; Sun, 18 Feb 2024 09:08:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708276132; cv=pass; d=google.com; s=arc-20160816; b=Yhy2/zffwwpzsaEJ55Km+OjbYtrM3Gxl28ueB0OuMt+cZ7DDKdJEVWVGA3P0AB15TC DJi1vELkySkDpzCrjrzdvQ7jlABSdoIceYiWkQz+0q6QHIgjjYLshFMdwbfTyRyZ1Gy2 SKbDgSN1MTxVW9iMP05KqlKoP+0uS9aLeTQhyp5Nzun3MJzLBCG+yXQmspLLoiaKG7pl Nfb+oXVRbtCeC4TTJeKBlQGLNamck4ZQit5OngWAqZlAwmEWA0kGO013vREtf34RamU/ jErrn2alNI2bIRPqZZsjx3ZRpz+XzQsOROEvTruulWh9c8e9bYF2twu+qRiaET5Fj3Jm fbCg== 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=bgkZPYVA0V4hJb/XgJ4JlLp2dhut1zemAO++lcwUguU=; fh=7ogY8TTBnoDyVw0Ew02z/XaZICVahvk3b1eitAEneUQ=; b=SdxHhP9lmsq5xo9q+mWaNYCHFTUHm4C9VPz5EgWzCpindqU/mZfCfGl12YYDnOMZcA K6SoFT0pd2+9MIRhrsZ8GwnjWKeqmlTtbtj8f5pfI3q8HoGpRQUryPvWTm2ahMwxqc1/ E+GR24ogHj29KPDi4319/ssZhNNPHYR3qJ90XMRtIb7fFOxbJyHH4d/WKeXjbjrgAVMR 779j7WIlLRozyJdtqsbiiknYKfoLGR6D6DuOxYOSvLl4BQFR35mPXXZapfIyrnYXLWO0 Mp6iPrfxQRWc1s2cdGLaqbYPYrb984a8BQ8oggm4y83wWgvWD2wO2s5CEZoS3ewrmWI+ BJjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=1K1pI2yL; 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-70450-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70450-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i4-20020a62c104000000b006e2a6c63114si2742657pfg.98.2024.02.18.09.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 09:08:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70450-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=1K1pI2yL; 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-70450-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70450-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 DA74C2817E8 for ; Sun, 18 Feb 2024 17:08:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E93E6FBB8; Sun, 18 Feb 2024 17:07:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="1K1pI2yL" 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 8727D6F523; Sun, 18 Feb 2024 17:07:29 +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=1708276051; cv=none; b=OlblD4zTco3xEMOSqm4wstZqtoS8kTWgzfWye3LjLI2YZpRaGJW/FNps4PQIE4tZY0/tawEYcEk/tlgBJHX8mdk4kK97xx9F5l5Zxj2t/w4kX7CV80/aZtBMQa7/nQZO0Dyw1mDzk/D9S7ATo5EVDLnrJl5mjAjl+ElpZDd9umA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708276051; c=relaxed/simple; bh=w1DJYkt9FTZRnNhfN8ZM1D8JVVgGCSqPVVQnR9uVLaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HZsm3FeEX9KLQLexNunesXOKr+o3N9eQ8gN3L3gg+IXkMsU1Tlv6t11A16m2JOqZCgYq0z8SEPo5tbfrsxexH200MRhjX+SKnRpy6oqaXfo1MN9d+A87TGn69ODP5qb3WYduF/4qx32dyIcWKMK94QQ8qJkEZ29doMsy4sQbWkY= 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=1K1pI2yL; 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=bgkZPYVA0V4hJb/XgJ4JlLp2dhut1zemAO++lcwUguU=; b=1K 1pI2yL1HTdd4PpgYvUcLr1D4ZokyrE+DqWWMehQALML51P/jeuKwecCH9Cz6s1wYB6ICqJlD3akYm tBR8tae4XKVKIDACd+alPVy20u1miv9CBMohRbqBnd+NvRjJXyACirbroxQ2aqSNhwz3tndH8k5cB YTKsTCgYx+7nRzU=; 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 1rbkdi-0088HX-5y; Sun, 18 Feb 2024 18:07:42 +0100 From: Andrew Lunn Date: Sun, 18 Feb 2024 11:07:00 -0600 Subject: [PATCH net-next v4 3/9] net: qlogic: qede: 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: <20240218-keee-u32-cleanup-v4-3-71f13b7c3e60@lunn.ch> References: <20240218-keee-u32-cleanup-v4-0-71f13b7c3e60@lunn.ch> In-Reply-To: <20240218-keee-u32-cleanup-v4-0-71f13b7c3e60@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=4430; i=andrew@lunn.ch; h=from:subject:message-id; bh=w1DJYkt9FTZRnNhfN8ZM1D8JVVgGCSqPVVQnR9uVLaE=; b=owEBbQKS/ZANAwAKAea/DcumaUyEAcsmYgBl0jk/THr+M7mqP78nd5RzXdgWbvVTgHvJlsuzZ 7xMAtGlnIyJAjMEAAEKAB0WIQRh+xAly1MmORb54bfmvw3LpmlMhAUCZdI5PwAKCRDmvw3LpmlM hJmqD/9WSvEPicM7UdEiBWGqw0w4cGuTLUuz25fQ3n29OdGUaVYCr2VYuHokkMHu+iDDzeKeGs1 GFn3hbEHUEu5uO4mId0kpOshj7qnLJkRF/GJD7gfDv5MRs/gn0W8KPt6AFzo/fMVLDowRyTRYLE 0kHmInQL0X3fZ0hXnFxruoCRocDSZetF3/dhXT0aL8TilTCGdDw8PxI1Rrd04utZQjcHaRcGvtz ZOnQWCgoVBXWJEj+f1Z1EJPod/rfSgMNwUdSQr2GFqh3S0Z5RTrhdzcVjxhosv19Qo+YWZIbkYo TvSzCGxj49H5KKyUC+wrKWmT+zamSdimTgKuGQKPJzsUJDaiKhnrYSzA7OLxBgSulMF6/DNiEPo WdH/pV0G0iVvqAG3FXHW3lXUKnbJIocMv+kWbWcPFQDRLQ1cyKWf6xruDzxpobvufh3ijZUBEJn /w8PtRojxHjkDJmaVXYBrOhneeIPKknMIRrV/HOtbswVZr9oQHcF/ncYh1n5exunSw3DxajAGqb WMetkaduMV4wDiMGcuYUB49tFuJAU7EvOpGlfamHRjH41lJxUPJ6Fh/soEmxkpRcBVTHdAjEIYH ci62RNrD/fw06aWHRp+WiY8wkGdRmoQE2B/F7B/QYktOTTQgXS0HtzDx4rywQt9Tdh7iih83BpJ gn0oVlqnxxNq0TA== X-Developer-Key: i=andrew@lunn.ch; a=openpgp; fpr=61FB1025CB53263916F9E1B7E6BF0DCBA6694C84 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791257353380663071 X-GMAIL-MSGID: 1791257353380663071 Make use of the existing linkmode helpers for bit manipulation of EEE advertise, support and link partner support. The aim is to drop the restricted _u32 variants in the near future. Signed-off-by: Andrew Lunn Reviewed-by: Simon Horman --- drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 60 ++++++++++++++++--------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c index dfa15619fd78..ae3ebf0cf999 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c +++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c @@ -1789,18 +1789,26 @@ static int qede_get_eee(struct net_device *dev, struct ethtool_keee *edata) return -EOPNOTSUPP; } - if (current_link.eee.adv_caps & QED_EEE_1G_ADV) - edata->advertised_u32 = ADVERTISED_1000baseT_Full; - if (current_link.eee.adv_caps & QED_EEE_10G_ADV) - edata->advertised_u32 |= ADVERTISED_10000baseT_Full; - if (current_link.sup_caps & QED_EEE_1G_ADV) - edata->supported_u32 = ADVERTISED_1000baseT_Full; - if (current_link.sup_caps & QED_EEE_10G_ADV) - edata->supported_u32 |= ADVERTISED_10000baseT_Full; - if (current_link.eee.lp_adv_caps & QED_EEE_1G_ADV) - edata->lp_advertised_u32 = ADVERTISED_1000baseT_Full; - if (current_link.eee.lp_adv_caps & QED_EEE_10G_ADV) - edata->lp_advertised_u32 |= ADVERTISED_10000baseT_Full; + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + edata->advertised, + current_link.eee.adv_caps & QED_EEE_1G_ADV); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + edata->advertised, + current_link.eee.adv_caps & QED_EEE_10G_ADV); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + edata->supported, + current_link.sup_caps & QED_EEE_1G_ADV); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + edata->supported, + current_link.sup_caps & QED_EEE_10G_ADV); + + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + edata->lp_advertised, + current_link.eee.lp_adv_caps & QED_EEE_1G_ADV); + linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + edata->lp_advertised, + current_link.eee.lp_adv_caps & QED_EEE_10G_ADV); edata->tx_lpi_timer = current_link.eee.tx_lpi_timer; edata->eee_enabled = current_link.eee.enable; @@ -1812,9 +1820,12 @@ static int qede_get_eee(struct net_device *dev, struct ethtool_keee *edata) static int qede_set_eee(struct net_device *dev, struct ethtool_keee *edata) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = {}; + __ETHTOOL_DECLARE_LINK_MODE_MASK(tmp) = {}; struct qede_dev *edev = netdev_priv(dev); struct qed_link_output current_link; struct qed_link_params params; + bool unsupp; if (!edev->ops->common->can_link_change(edev->cdev)) { DP_INFO(edev, "Link settings are not allowed to be changed\n"); @@ -1832,21 +1843,26 @@ static int qede_set_eee(struct net_device *dev, struct ethtool_keee *edata) memset(¶ms, 0, sizeof(params)); params.override_flags |= QED_LINK_OVERRIDE_EEE_CONFIG; - if (!(edata->advertised_u32 & (ADVERTISED_1000baseT_Full | - ADVERTISED_10000baseT_Full)) || - ((edata->advertised_u32 & (ADVERTISED_1000baseT_Full | - ADVERTISED_10000baseT_Full)) != - edata->advertised_u32)) { + linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + supported); + + unsupp = linkmode_andnot(tmp, edata->advertised, supported); + if (unsupp) { DP_VERBOSE(edev, QED_MSG_DEBUG, - "Invalid advertised capabilities %d\n", - edata->advertised_u32); + "Invalid advertised capabilities %*pb\n", + __ETHTOOL_LINK_MODE_MASK_NBITS, edata->advertised); return -EINVAL; } - if (edata->advertised_u32 & ADVERTISED_1000baseT_Full) + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + edata->advertised)) params.eee.adv_caps = QED_EEE_1G_ADV; - if (edata->advertised_u32 & ADVERTISED_10000baseT_Full) - params.eee.adv_caps |= QED_EEE_10G_ADV; + if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + edata->advertised)) + params.eee.adv_caps = QED_EEE_10G_ADV; + params.eee.enable = edata->eee_enabled; params.eee.tx_lpi_enable = edata->tx_lpi_enabled; params.eee.tx_lpi_timer = edata->tx_lpi_timer;