Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5398914rdb; Wed, 13 Dec 2023 07:38:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0Hj9AjnbBT9HUVGb264GSMl4OoPYE80LMZwe1nYVIpboMhpyOliF3x0p2iDYMVCrsyFDo X-Received: by 2002:a05:6a20:9706:b0:187:4fd9:b9bc with SMTP id hr6-20020a056a20970600b001874fd9b9bcmr3844488pzc.34.1702481893963; Wed, 13 Dec 2023 07:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702481893; cv=none; d=google.com; s=arc-20160816; b=d7ZFwqnx+SH+0ZRD+hWFizqHZWGU18BOff1HkhnjVXb13PGpnmSAVPmqLgW2XZqiBZ xGh+N4dK7xS8fVHaSF84Boxe+jaYd106S4Q82c33+T2zP9Ud4W5NCsRqkPszAqKNOa0/ TNxv3qGeLFvnPcDoIeKqtcFssJ9Haccq39BDBirFdhxtVbRIJVCvUJMcnWT0+W/Gkqe1 xsKfTBJ0IjsbJ2u/ot+VT5ODGXh86Mhk/HnbcQ8dkOb7vwbj1a6WCA35+7FS6t/JrpK5 Q9tvf7z+gkesS0fC4RNeSYfhirR6LnWmwRnnpzILVQ2Dw9lq6Z2vAGaRjPryATKQkBoW z4KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=nZjtZNjjG4tOk9QrXUApstS2gYbp84RFIEmpjy2OP5w=; fh=RRyIDtST/tn0VFOu8/r4KwXT3edRfSUw7T2wR0w54Mw=; b=vMU8G42NZ0A5LajPWmGpEGdyMvqZMU6NqAZOimB2iFcqcAw7SHc+FrM4wsfdJXYwiM ZDx172G1v8Ykkz3WeN5Cd/56EciGUtfUPCMv5hlmFWvr0+BiiKVGGssTKLDVJE85K4uC 7ga6PVchIJOS3wppzmirufIHrR8CSkVZcE3DsDiy+orKqrKeROItYIiXGTfv40G4BEiB ouZcPPL/3n6iVwtyPr3oV9wJ30gIVFvh9UaCaIuJ9NVNGPoVJXYWSzbkqCw4v+H5w+yg 5m/KJ37ZsNGA4Ydb3uXB0VG2XffgTlVPC1PeKjBy73WoRmYWU/Rx77hIL13j1LvWVQ/K VYwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T2sHLqfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ct19-20020a056a000f9300b006ce36ffa533si9749149pfb.374.2023.12.13.07.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 07:38:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T2sHLqfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 87515808A358; Wed, 13 Dec 2023 07:38:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442042AbjLMPh5 (ORCPT + 99 others); Wed, 13 Dec 2023 10:37:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442034AbjLMPh4 (ORCPT ); Wed, 13 Dec 2023 10:37:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 390B5B3 for ; Wed, 13 Dec 2023 07:38:03 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C816BC433C7; Wed, 13 Dec 2023 15:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702481882; bh=gScubWv7+ZzEnPJcCeVKQ22MVXXXNr97yRWbtv+NF0g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=T2sHLqfXvg9T3II4rQGTdcTvXulOsp7sNYJ54yV3gHU0Jgfaq31E4smT+XznySFO3 LgGM+9Z6QLRZwxj5Bu7Y/2vsNVQp9NczPM2L0nCEW1tJdKkUBJmgyUTnP+y7W0zvbE 1IwoIqbhmABGes3iWB8/e2KVEHasTZbFOlhlnJ0oaI6gg0b+EWqGc6z+kFs2KsBx92 57NvpXzl11/wqIraHM4jZFUd/aZn9rXSXXQGvAUbO2YG/hDQwH5V3SIdDraUFkrU8w mr5BQSeQUa4hFxTk2pEHhoQ/yU9RAaJHHDEUOJ2VLbhp8Bwnpk2xldeEs98fD3tfA9 Hnsrbi+hC8Zcg== Date: Wed, 13 Dec 2023 16:37:57 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Christian Marangi Cc: Pavel Machek , Lee Jones , Jakub Kicinski , Andrew Lunn , Daniel Golle , "David S. Miller" , Li Zetao , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH v2 1/2] leds: trigger: netdev: display only supported link speed attribute Message-ID: <20231213163757.1d576bb7@dellmb> In-Reply-To: <20231213150033.17057-1-ansuelsmth@gmail.com> References: <20231213150033.17057-1-ansuelsmth@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 07:38:11 -0800 (PST) > + /* Display only supported entry */ > + if (attr == &dev_attr_link_10.attr && > + (test_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, supported_link_speed) || > + test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, supported_link_speed))) > + return attr->mode; > + > + if (attr == &dev_attr_link_100.attr && > + (test_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, supported_link_speed) || > + test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, supported_link_speed))) > + return attr->mode; > + > + if (attr == &dev_attr_link_1000.attr && > + (test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, supported_link_speed) || > + test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, supported_link_speed))) > + return attr->mode; > + > + if (attr == &dev_attr_link_2500.attr && > + test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, supported_link_speed)) > + return attr->mode; > + > + if (attr == &dev_attr_link_5000.attr && > + test_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, supported_link_speed)) > + return attr->mode; > + > + if (attr == &dev_attr_link_10000.attr && > + test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, supported_link_speed)) > + return attr->mode; Why only the T modes? There are much more ethtool modes for these speeds, for example at least 5 modes for 1000 mbps speed: 1000baseT_Half 1000baseT_Full 1000baseKX_Full 1000baseX_Full 1000baseT1_Full There are also 2 possible modes for 2500 mbps 2500baseT 2500baseX Ditto for 10 mbps and 100 mbps. So if you're doing this, why not do it properly? There is an aarray static const struct phy_setting settings[] in drivers/net/phy/phy-core.c and a function phy_speeds() which will tell you which speeds are supported for a given ethtool mode bitmap. Or you can add another function there, bool phy_speed_supported(unsigned long mask, unsigned int speed) and use that one. Marek