Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2103570rdb; Sun, 4 Feb 2024 15:42:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEeIg6d+z2SGn11Ujov6q/LUW/uohJqGPsCchEpck6MnevMLJz0BmtdxgNj/j2XD8BvRuq X-Received: by 2002:aa7:86cf:0:b0:6e0:41fa:7a15 with SMTP id h15-20020aa786cf000000b006e041fa7a15mr1105508pfo.22.1707090133980; Sun, 04 Feb 2024 15:42:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707090133; cv=pass; d=google.com; s=arc-20160816; b=r4ulbGu+lXOjvTmbkdSBtcOKsQKRoAamOdoJxD5brSp3YInIPPQU0cs028vizQFDe7 R4cxfyZyjFisvWCmnrS79zNbBU8NWwcNrROAqN5ruheXCoHgV7lYdRCZmm8BD0etWgHC gU0XYkGN8JvhC2tvQPDX4fPkGrqTbqgcKxAO8H3NuGHgHAtDKvYPMHQCJ/9rOYakuiBj JaHJzpMtUdFrW5QenQAM2ulWWcMf7Gp07KxlKVbi5sFxtz7kgt79INq4Rirn21235W95 cdp750KFLdbLpz+2G+alP9soc5wn7NBxt0+Hr6m3/pYnJT6dP0KJ7JIk+f6aYJ5Ez2sh HezQ== 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=IAfPboaKruj2+/KbZohonJocImP030RgEsCHwafnUlg=; b=kA+gh4Inp06M4ICSner3bRO3Bj9vww2H70nZCv+gf26o4YOhiYIVXCGLnSKSBmsJ9J vNWGAbVgtrBY5Hkiq7633Z1py6OzTcBVBF+S4PMJK0ZY0rPRfcAkw5n6re0pwHwsKrb2 OS0qVllhWr6QpAL2zkYKwDKzvZ7SiZAZGUkCaPfr79s6ErvE5NH3KDOf2tQgXQb2aPAG gOxI92x8NffSD4GwFloUH1gZkRw4npk8+qLA/k0V3wSi5K1iEQ44IfQK3pvD2SHcJ1Pk 9jK6OCsdxvZEp2Z7Czmem3Q3UtfVkn+TTjnSnxj0HKoKSpyWm+xgPlgjp3/B1QNHT3uf 2kXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="wj7U/D4/"; 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-51951-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51951-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch X-Forwarded-Encrypted: i=1; AJvYcCU77KIu8TYZ7sox2jg2D71l2ofaBRD2sQldXiXoxBnIt5FDniPlRAj0c3Sv6YTMTU7X11pK+3w34yNT5uaMECjffAxP3wsQSUGgiAXgOg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y13-20020aa79e0d000000b006e037ef1afasi1885515pfq.243.2024.02.04.15.42.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:42:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51951-linux.lists.archive=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="wj7U/D4/"; 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-51951-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51951-linux.lists.archive=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 9D502282126 for ; Sun, 4 Feb 2024 23:42:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E28F7134D3; Sun, 4 Feb 2024 23:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="wj7U/D4/" 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 59405125BC; Sun, 4 Feb 2024 23:40: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=1707090048; cv=none; b=Uifq4fAAoAfZxwQJdsc4n0dHP93Ff43fP8bXYRC/ycLllzXzp7xBtn3xkqzuw+GEP0a3RER6Uzqf7lzWAaJHmihwmXIgzsuqT7oP/lfvyWSAZmuR/joEdhB5vFKI4cjLfmd0cQKwbjXhg23MULCnXC9DMFtdrt7DcrBvC/LtFjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707090048; c=relaxed/simple; bh=w1DJYkt9FTZRnNhfN8ZM1D8JVVgGCSqPVVQnR9uVLaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cJIKG0yg32k3fF8RMJMKSWzKlZovuibjV5Aef9B8VN1VgWbWtcd6yqwp8EnfolUl61pqK3gFDGZ73BQXgAH3F97t6adiN/ktIwnpKWdEhG57NLu6vK66fIr5iXLzg+z4P8LOm9LM2WJSA8k/k59/KuxpflSIy09piNBKOIX1MfQ= 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=wj7U/D4/; 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=wj 7U/D4/09bMUQraEGSAJXfdYZo3Na1YHmFlEhuSIUn6QP88V/QDfr5Hc7TaJP1D1RS5WiDeZL/1XY2 aSyMXvDh/JlagPNT5GDKF3NFFbV/JPsaniWUz62xD8tbhe5ANvXVzzsbniKLoJA8+CwdHL/FxPHwD F207h3tU86t79LQ=; 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 1rWm6J-006z7T-R0; Mon, 05 Feb 2024 00:40:40 +0100 From: Andrew Lunn Date: Sun, 04 Feb 2024 17:40:20 -0600 Subject: [PATCH 3/8] 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240204-keee-u32-cleanup-v1-3-fb6e08329d9a@lunn.ch> References: <20240204-keee-u32-cleanup-v1-0-fb6e08329d9a@lunn.ch> In-Reply-To: <20240204-keee-u32-cleanup-v1-0-fb6e08329d9a@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/DcumaUyEAcsmYgBlwCBon+s0cfQymfK1yKJWI3CJgbZEzc2imyu6H L7upZDxOPeJAjMEAAEKAB0WIQRh+xAly1MmORb54bfmvw3LpmlMhAUCZcAgaAAKCRDmvw3LpmlM hJNLEACUectcqUkkbAM2nZU+LrkjMEu+yeWzxiAl/BthabY6sfWCMweyFwHr7e2ZGsXEVEwMAxA lst7aQCILYGVrOcttw0xtlMaGYzt7OgMO+wRyKm274hTe0t0FiszcIaWMK7mWgwLe6i8LNnDGXB UCRX0dzeZK6fWxlevwii98L4P4bpQKSyc8veZD8rFmzmawXlz1z+bzMZL3BvpLpr7sFI1wBekIB nOaeMUU9ApSxYM/NO6+9x6R2O9Z2Jxg55K/GAygI6mqA7qs1IEPQXTTdvBZzeNm0fABB41bFpYQ H1haLfnckwjLdBw6zCs+8z94Jguh9giD6aYWGNDjgnUCzWOyyqIqpgEaGIMxjEkmmq9mk448wnM cq+czs3mHS28K/056kzZrNAit9/SLNMRwZi63aO2Te6M8X+rahpcANpD0g+PYKXBnSI1/kfax6I JhaDbkGmepsMrvL/F6PP2MrJAikviJuX9fyKsLiO7FxWhKx6/l1R1tqlmCkLGBFYL821dF2fAe4 L12EuB07Fi+EVJeGgCsKw47q915MG/wY6bk8bk9VII9EIDrwPAVMx5ABmr5ZWui8FAKG7xfNxZ5 ww4cqVE7My8aRWf38hABt/pPK4t5uS0w/XR3jpuGPoHcOjpW8egnmn6+PoZWgfDYmSl76rNSkzV myrUpDkn0v4hiAQ== 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. 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; -- 2.43.0