Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp283490pxb; Mon, 8 Nov 2021 13:35:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJw36mNce3j9Wf8dRqAQ8kyyYU4Dju9ygp91EMXSueGMYM0PuayU9ZAVJlqXev5RYfVhlmGR X-Received: by 2002:a6b:7705:: with SMTP id n5mr1477766iom.173.1636407359694; Mon, 08 Nov 2021 13:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636407359; cv=none; d=google.com; s=arc-20160816; b=pTgW+n7ECBGIipiFW3QCkdOdFpVrNPOBk89zjfeBmNBX64VD2tBsIf0WjaKTWgTao4 /xh8PzFj3meJgzpXEW99A/0b2Ir9GKIrf7ZvyHxNRXWzOK204rR9PjMT3/ib0AEYZJ9T MiRvxsxM50NVJSo/3MHbCFEQDVhcTEyh8bFKKoXgF0mcuUeTuzUm/8GRGdpUayFoIL++ BtE8VZ8ql1klQwVM1kZGzZIFBAQ6op+rJuZ7OaQuvZlJXP2ZlRp2YPMxPbZR8uKrrCef Y92IORa+/vesCgyH5wIUpvOAY9y/VOnPe9bQ1rknxivwEpMXT6SjJAbtiLdPItloKTTZ yh7A== 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=46JmhjmlvvBMItZqonCRb4XuU8z9QaJwJmnagDY26Xw=; b=PmrRuOSVBPEmg6WvYQoQomw9+h0bvOCni1hDRCxnUHGcpYW7d/EOjMLKW0cfd96yt3 WaYoKTkuHPue0mlyp4DTh74IIT1lp4Ndsu2uQvlAG6/nClYcJ9SLbUxuprOLkGRqpVCB rKH/jXSv+KmTjCTnjl9DZTDYGrH1Ca5WUXgQAxRUcawelkmlcoGVNByvTyyDCQXzAYMS YNFaVcrTm1XEPgL1tURjnSAETLS608d5jlAAovKE8JUAXoMEtk3bDoH3a8zs/YyRyvDI V2pCejo/O8EqFKXkBKJmnLLjcyHmNlCRy48JpMnofpeOzT3RBxSceMdfeCLQdl3t3uRc gaEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lG6VDp2T; 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 x11si446823iov.52.2021.11.08.13.35.45; Mon, 08 Nov 2021 13:35:59 -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=lG6VDp2T; 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 S238157AbhKHQQE (ORCPT + 99 others); Mon, 8 Nov 2021 11:16:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:57838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238111AbhKHQQD (ORCPT ); Mon, 8 Nov 2021 11:16:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4E1461107; Mon, 8 Nov 2021 16:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636387998; bh=Ijsj68+ZcgX66on4xNvcnNeiQfAyxcdQcTHC4K5SOXI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lG6VDp2Tre0jkggzgpKn9zvIrAhb/7shlfuxVMN99UOqioR2n7IB3e85NKwQI4CqE 4P5cUQQ3Kl9Cntyyla1RG7CZpkPTFZTkq7cKd8g8K2Sn+NjmqDkTOZLdotViKTJA0M XxC8FX8X1cEy+Reb28kjQ/3VsEbZNzsIRS3aUl1cuPVQ2fQ6473y1oh0/WbFaqgLiO z29jA75XqULm50+FN4uS8rLx2xqzVmnRs7dTetXDZAa2dsJGVD/YmDZfVjPfwyRfk3 AdV2zF03PBuqD4Eg1zKgsoP6EVcrX0vpx1FFQGa27vd1mibkfGag6kZhWyGN2TFJ1Y rpaKnkC28UAgQ== Date: Mon, 8 Nov 2021 17:13:12 +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: <20211108171312.0318b960@thinkpad> In-Reply-To: References: <20211108002500.19115-1-ansuelsmth@gmail.com> <20211108002500.19115-2-ansuelsmth@gmail.com> 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 On Mon, 8 Nov 2021 16:16:13 +0100 Ansuel Smith wrote: > On Mon, Nov 08, 2021 at 03:04:23PM +0100, Andrew Lunn wrote: > > > +static inline int led_trigger_offload(struct led_classdev *led_cdev) > > > +{ > > > + int ret; > > > + > > > + if (!led_cdev->trigger_offload) > > > + return -EOPNOTSUPP; > > > + > > > + ret = led_cdev->trigger_offload(led_cdev, true); > > > + led_cdev->offloaded = !ret; > > > + > > > + return ret; > > > +} > > > + > > > +static inline void led_trigger_offload_stop(struct led_classdev *led_cdev) > > > +{ > > > + if (!led_cdev->trigger_offload) > > > + return; > > > + > > > + if (led_cdev->offloaded) { > > > + led_cdev->trigger_offload(led_cdev, false); > > > + led_cdev->offloaded = false; > > > + } > > > +} > > > +#endif > > > > I think there should be two calls into the cdev driver, not this > > true/false parameter. trigger_offload_start() and > > trigger_offload_stop(). > > > > To not add too much function to the struct, can we introduce one > function that both enable and disable the hw mode? Dear Ansuel, 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. 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. And you will also get a NACK from me and also Pavel (LED subsystem maintainer). 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) - 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 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