Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp383695pxb; Mon, 8 Nov 2021 15:27:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCBf48y+vU4t6JkNKk2Rao8GArQN+eJYrr2afW/aVXq1vwrtxSx0VdLQfWLttd4rdiE5+f X-Received: by 2002:aa7:c956:: with SMTP id h22mr3926241edt.24.1636414026888; Mon, 08 Nov 2021 15:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636414026; cv=none; d=google.com; s=arc-20160816; b=YyTmh7P3atMwbKLzo9pELOi/cdPPJrm78Ob7VcU6FIMyjuTgNafVXVJ+f7BlAG8suY vF5PX71hkvFPAIs2b2npbXZ8ywGKczLJJeNhGj75/rbryXQkptGmcDQNJw15IOW/eZKv H4CTV8CcXaB8kohRi3AMEWBX+9p4+yUdeE6xjrnQcCowZHyP/IyUbmyFITH268A0xDKm 9dHcCalWwo+5zcPPBmBeNZXhrZevxwlab3BR07c9aF7r6LAaq4kr9tr1PPN+BJR+CYMj iHOEKseF7VfZQIhMMWEdgCQRR3wrhokVgjG1oZl1coWNgqslen1U+U/WUFxEmClRwbLw nmTA== 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=56hWgJ9jScVXX88pZlU2d1I728YeXdD8y7j6LgMD0yQ=; b=x95P5fjP7usuFjtLkIMlUfIGdI5s84Xy4QZi8VK381e4j6ELtKRI0P5x8+XFQBqct7 6rRAX+WnA7RW51g5Un9cWMCoJ4hGscU3W0gHa4Jb76sngVQJ/tm4uQdOiX/+YBaHEAi7 +0N/lUfHLfTitf8VdccWHxjbct4pXd8OJ51HPY/SmhMYvPVSeeBNFpYq0xIugdOBvDZ1 4ypOkENejSYbJE4Q+ux1+bHaCe0sYnbfUkBNrYOhIoK2P290qwwjNwE1PJFwfDhWu9V3 HsNsBufet+6KkENRsLFQft6Gv85JNjyWj6xNJSMfBEnicY0NpnCDkEbLPoYaq/EhgpZI QK6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aPn4nBYM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr38si23712755ejc.65.2021.11.08.15.26.43; Mon, 08 Nov 2021 15:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aPn4nBYM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240678AbhKHRia (ORCPT + 99 others); Mon, 8 Nov 2021 12:38:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:49268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240628AbhKHRi3 (ORCPT ); Mon, 8 Nov 2021 12:38:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D12C061288; Mon, 8 Nov 2021 17:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636392944; bh=VI8GHizFjqwLRi7Qw8aE1jNiA7hGriW5mAa6mKyDlgQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aPn4nBYMmjO/ZTSm24vq/CZ4kutVXNCJPFi3MRJcO06fbHS6QZJlufDsw5xeZcP91 VbTUuEod9OMGcay/TKqq+yGGiWMtC1vLdT4JnJVAxM4baA6IF7/TEyvxYna4Mt/QT+ xI7L7amngrdvjF2DO0Mah9i6IMkf0w6qPYYhbPc5fnpJn2sWIdflADODtcuxVhAQns hsYts76xCgpKxn3vmkDiHWwlP+5DVsH3St4Ax6ELaeWNaQ0yxGRmXqwKEjt2j04syh pRCvojnYiI0o9z0hd3EW7kO3o5XTVOZJID7raHE1awmoYWx8mmh6GtYiSm6gUIFLYH vVhDgRthFl4hg== Date: Mon, 8 Nov 2021 18:35:37 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Ansuel Smith Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Rob Herring , Jonathan Corbet , Pavel Machek , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [RFC PATCH v2 1/5] leds: trigger: add API for HW offloading of triggers Message-ID: <20211108183537.134ee04c@thinkpad> In-Reply-To: References: <20211108002500.19115-1-ansuelsmth@gmail.com> <20211108002500.19115-2-ansuelsmth@gmail.com> <20211108171312.0318b960@thinkpad> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Ansuel, On Mon, 8 Nov 2021 17:46:02 +0100 Ansuel Smith wrote: > > what is the purpose of adding trigger_offload() methods to LED, if you > > are not going to add support to offload the netdev trigger? That was > > the entire purpose when I wrote that patch. > > But the final step was adding LEDs support for PHY. The idea was to find > a clean way by passing the idea of offloading a trigger... But fact is > that LEDs in PHY operate by themself so it would add overhead selecting > a trigger that will use event/works just to then be ignored as the > trigger is offloaded. I don't understand what kind of overhead in events/works are you talking about. If the trigger is successfully offloaded, there are no events/works. Everything is done in hardware. If you look at my last attempt https://lore.kernel.org/linux-leds/20210601005155.27997-5-kabel@kernel.org/ which adds the offloading support to netdev trigger, you can see if (!led_trigger_offload(led_cdev)) return; so if the trigger is succesfully offloaded, the subsequen schedule_delayed_work() is not called and netdev trigger does not do anything. The blinking of the LED on rx/tx activity is done purely in hardware. No software overhead. > Also I think we are missing the fact that most of PHY can operate in > software or in hardware. NOT BOTH. So the entire concept of offloading > some trigger won't work as we were not able to simulate with SW > unsupported trigger. (not the case with netdev as it does only support > link, rx/tx but that was to explain the concept that SW and HW mode are > mutually exclusive.) I am not missing this fact, I know that there are LEDs that cannot be set into purely SW mode. Which brings another problem: Pavel currely isn't convinced that these LEDs should be exported via LED classdev API. We need to persuade him about this, because otherwise we would need to create another subsystem for this. But there are PHYs which do allow purely SW LED control, i.e. I can set the LED to be just ON or OFF. These are for example marvell PHYs. The fact that there are LEDs that can't be controlled purely in SW does not seem a good reason for to not implement it via netdev trigger. Either these LEDs shouldn't be exported as LED classdevs, or they should somehow make use of existing trigger API (so netdev). The fact that the LED cannot be controlled in SW can be simply implemented by refusing to disable the netdev trigger on the LED. > > > > If you just want to create a new trigger that will make the PHY chip do > > the blinking, there is no need at all for the offloading patch. > > > > Again the idea here is that a LED can offer a way to run by HW and then > a trigger configure them and enables the mode. I see the offload and > configure function needed anyway side from the implementation. There is already LED private trigger API for this. You don't need offloading of existing trigger if you are going to create a new trigger anyway. > > And you will also get a NACK from me and also Pavel (LED subsystem > > maintainer). > > > > Can we try to find a common way to introduce this? > > > The current plan is to: > > - add support for offloading existing LED triggers to HW (LED > > controllers (PHY chips, for example)) > > - make netdev trigger try offloading itself to HW via this new API (if > > it fails, netdev trigger will blink the LED in SW as it does now) > > Can't be done. If in HW mode, we should just declare a trigger not > supported in SW if we really want to follow the netdev expanding path. > But still that would mean filling the netdev trigger with extra code and > condition that will only apply in HW mode. At this point just create a > dedicated trigger. The netdev trigger already needs to be expanded with extra code: it doesn't allow indicating different link types, for example. For offloading, the extra code can be quite small. So I don't think this is an argument. > We can consider introducing the same sysfs used by netdev trigger but > nothing else. Not true. > > - create LED classdevices in a PHY driver that have the offload() > > methods implemented. The offload method looks at what trigger is > > being enabled for the LED, and it if it is a netdev trigger with such > > settings that are possible to offload, it will be offloaded. > > > > This whole thing makes use of the existing sysfs ABI. > > So for example if I do > > cd /sys/class/net/eth0/phydev/leds/ > > echo netdev >trigger > > echo eth0 >device_name > > How would this work in HW mode? The PHY blink only with packet in his > port. We can't tell the PHY to HW blink based on an interface. > That is the main problem by using netdev for PHYs, netdev is flexible > but an offload trigger is not and would work only based on some > condition. We should hardcode the device_name in HW and again pollute > the netdev trigger more. netdev trigger does not need to be poluted by this much. All this can be implemented by one callback to offload method, and everything else can be done in the LED driver itself. > An idea would be add tons of check to netdev on every event to check the > interface but that wouldn't go against any offload idea? The system will > be loaded anyway with all these checks. The checks are done only at the moment of configuring the trigger. Surely you don't see that as "loaded system". > > > echo 1 >rx > > echo 1 >tx > > The netdev trigger is activated, and it calls the offload() method. > > The offload() method is implemented in the PHY driver, and it checks > > that it can offload these settings (blink on rx/tx), and will enable > > this. > > - extend netdev trigger to support more settings: > > - indicate link for specific link modes only (for example 1g, 100m) > > - ... > > - extend PHY drivers to support offloading of these new settings > > > > Marek > > The rest of the implementation is very similar. Except we just NOT use > netdev. And to me it does seems the most sane way to handle offload for > a LED. (considering the specific situation of a PHY) > > From what I can see we have 2 path: > - Pollute netdev trigger to add entire different function for HW. (that > will end up in complex condition and more load/overhead) > - Introduce a new way to entirely offload some triggers. The check conditions would be all in LED driver (PHY driver in this case). The code could be a little complicated, but it only needs to be written once, and the PHY drivers can reuse it. netdev trigger is not polluted, only a few calls to offload() method are done. > Could be that here I'm just using the wrong word and I should use > hardware instead offload. But considering we are offloading some trigger > (example rx/tx/link) it's not that wrong. > > The thing is why trying to expand a trigger that will just remove some > flexibility when we can solve the problem at the source with some > additional API that currently we lack any support (leds can be > configured to run by hw) and some dedicated trigger that will do the > task in a cleaner way (and without adding extra load/overhead by really > offloading the task) ? As I explained above, there is no extra load/overhead. The only thing that is extra is that netdev trigger gets a little more new code, but that is already needed anyway. > > Again hope I didn't seem rude in this message but I just want to find a > solution and proposing a new idea/explaining my concern. > I don't think you're rude, we are just discussing a topic for which we have different opinions. Marek