Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3678C64EC4 for ; Thu, 9 Mar 2023 15:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231704AbjCIPXq (ORCPT ); Thu, 9 Mar 2023 10:23:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbjCIPX1 (ORCPT ); Thu, 9 Mar 2023 10:23:27 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3489EF16AB; Thu, 9 Mar 2023 07:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date: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=TZtnq4ErD6+p46J1xiQAutyT1OfQ3UHS3Utv9OsbD3k=; b=4u643A2Y3jE+yVdrqGMaYCOOLt pUoE/QBgVG8HivDUgvuxodEqXCK/29gfplEGQEf/qEFBYL8Ii/Tir4i9ovOxmF8wVWYwl0TW0weqA ygUG5e8884d5Ik+oAh26XdFyioQdTjOlFbjCA44mXbPUSidZwDRvcnL5pPeD8JZqv7OQ=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1paI63-006t3h-Ua; Thu, 09 Mar 2023 16:22:23 +0100 Date: Thu, 9 Mar 2023 16:22:23 +0100 From: Andrew Lunn To: Linus Walleij Cc: Christian Marangi , Hans de Goede , Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Russell King , Jonathan Corbet , "Russell King (Oracle)" , Jacek Anaszewski , John Crispin , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, Tim Harvey , Alexander Stein , Rasmus Villemoes , Bagas Sanjaya , Arun.Ramadoss@microchip.com Subject: Re: [PATCH v8 00/13] Adds support for PHY LEDs with offload triggers Message-ID: <8226f000-dd9c-4774-b972-a7f1113f0986@lunn.ch> References: <20230216013230.22978-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > I am a bit reluctant on the ambition to rely on configuration from sysfs > for the triggers, and I am also puzzled to how a certain trigger on a > certain LED is going to associate itself with, say, a certain port. Hi Linus There will need to be a device tree binding for the default trigger. That is what nearly all the rejected hacks so far have been about, write registers in the PHYs LEDs registers to put it into a specific mode. I don't see that part of the overall problem too problematic, apart from the old issue, is it describing configuration, not hardware. As to 'how a certain trigger on a certain LED is going to associate itself with, say, a certain port' is clearly a property of the hardware, when offloading is supported. I've not seen a switch you can arbitrarily assign LEDs to ports. The Marvell switches have the LED registers within the port registers, for example, two LEDs per port. > > I want to draw your attention to this recently merged patch series > from Hans de Goede: > https://lore.kernel.org/linux-leds/20230120114524.408368-1-hdegoede@redhat.com/ > > This adds the devm_led_get() API which works similar to getting > regulators, clocks, GPIOs or any other resources. Interesting. Thanks for pointing this out. But i don't think it is of interest in our use case, which is hardware offload. For a purely software controlled LED, where the LED could be anywhere, devm_led_get() makes sense. But in our case, the LED is in a well defined place, either the MAC or the PHY, where it has access to the RX and TX packets, link status etc. So we don't have the problem of finding it in an arbitrary location. There is also one additional problem we have, both for MAC and PHY LEDs. The trigger is ledtrig-netdev. All trigger state revolves around a netdev. A DSA port is not a netdev. A PHY is not a netdev. Each of these three things have there own life cycle. Often, a PHY does not know what netdev it is associated to until the interface is opened, ie. ip link set eth0 up. But once it is associated, phylib knows this information, so can return it, without any additional configuration data in DT. A DSA switch port can be created before the netdev associated to it is created. But again, the DSA core does know the mapping between a netdev and a port. Using devm_led_get() does not gain us anything. Andrew