From patchwork Tue Feb 27 01:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 13573077 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 9D7C8CA6B; Tue, 27 Feb 2024 01:29:47 +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=1708997389; cv=none; b=Q4Ax2Ai8xmdQOvP4pGOWDolNuDWGvfN1Ur5Svly0px4azC8fOiVq5GNqwpdBdY7pXTgrk//Qfmwtsh37pGgsxsbllDL1D4J7a3rC2OBGGR94TYMmHozrGxrLzrzRy9IMd9KfZgH/PXDyfvnHsoI0fpEFHV/q80jwffmjilK79x8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708997389; c=relaxed/simple; bh=fCtThoZRHD+wc3a7N9uHBRhkO5QdG2fpNE4jqVzG/2k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lcCgH664KJHDgxF0dmv36+ZWFsMMetRPU5dJrldqxXVz/MNXvnoyPrSqV3Os+aEjdEPqMTNTVv7HeKMKfMGfXZagT1PxRtZnfmCtElijMnaVOHXs5BBTbeqEIT6BqxNov/T7DNlwCUfcY7qogfV/sFa5hyJ0mUO6jleArw98UFE= 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=qe02hNRj; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="qe02hNRj" 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=lERX+b3AT2q0QSGG0BM1XWJZtJMmZ3hJB7DS1cgT0BM=; b=qe 02hNRjFAoIo4TGRPmt2zxd1gF8iywmOrUYRQ0uVT+yiQBw1TGabGtAoPymcO639FYBYVb2+YXm4Ba PcRg4IZ8+I66MIIrZxQ6h+SE9pnMc1JIXcLEInM8BNYkXJ1ZEi9n11w7IOlHn+xj09j02B36t3/bR NXOKe6lgfKbqsBQ=; 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 1remIB-008mef-PO; Tue, 27 Feb 2024 02:30:00 +0100 From: Andrew Lunn Date: Mon, 26 Feb 2024 19:29:09 -0600 Subject: [PATCH net-next v5 3/9] net: qlogic: qede: Use linkmode helpers for EEE Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-keee-u32-cleanup-v5-3-9e7323c41c38@lunn.ch> References: <20240226-keee-u32-cleanup-v5-0-9e7323c41c38@lunn.ch> In-Reply-To: <20240226-keee-u32-cleanup-v5-0-9e7323c41c38@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 , Simon Horman X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4476; i=andrew@lunn.ch; h=from:subject:message-id; bh=fCtThoZRHD+wc3a7N9uHBRhkO5QdG2fpNE4jqVzG/2k=; b=owEBbQKS/ZANAwAKAea/DcumaUyEAcsmYgBl3Tr216//DHYiTUuP5od8LffVJJ5y12f7LD/iS BvbjdRPWM+JAjMEAAEKAB0WIQRh+xAly1MmORb54bfmvw3LpmlMhAUCZd069gAKCRDmvw3LpmlM hFzfEACgu81+/Q2ZXeNT0d9cJR1M62hFXup59skkANdbyASDGO9xsipT77rQp2memBMi+p+JXTH HeaPoKLnsgb3DWQD3G/OjITaF75+bIJN0/gVscxHvIIEe/0hgvxKMKsFhPE20cphna2rIxnxiQB 8pNMrUg3aBnGbdbswwh74ZtDNdyb/J9WVnea28K5m/3cJKJZPu7tn32RdgjZwgvYee9jcOmr7Nf b2YQKGY1C6jsQ4atcxAcWfxvGrELSifgyVnH2sS1MgvUX4ZA+9iOEWxho7Uwns4MT3Qb71yAlB3 0QMED9oMX0zSouWpTigti4qxddKcSQCx9AKH4f/V1e2m1HtxLy7P4I2gEPwWFQBQf/WxyGSSN79 Qzec9iMxP5bvpjtmNOto5GLkoq719pblS7NOMDWk4K4T7c6bW0ahZPG7z3m0XE47mSt8Vigs2xX 3wLKkI99SGp5HJK9c18i7UHmr/r2sIwDgpqnIRFNxdZFQuS4efFn3Yg19ZEvq7pI25PoDJKzrO2 PIGrnhex8z3dgjIDUQBB75W7QxxT7BCmyJAfQBgWepUqlwkf1MYyVhmg+AAZwgOmNlws6JMxYOo HFHXxAUIJl6BbfAv9Mnf5nxsCk6y+AAB4boVTRgl2MM9Qg5OlRr77fWu6hQRUH70f2qIIYx47AM 153+eylj40KYh6Q== X-Developer-Key: i=andrew@lunn.ch; a=openpgp; fpr=61FB1025CB53263916F9E1B7E6BF0DCBA6694C84 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. Reviewed-by: Simon Horman Signed-off-by: Andrew Lunn --- 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;