From patchwork Mon Jun 19 20:46:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 11002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3242863vqr; Mon, 19 Jun 2023 13:49:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55soWnNBiYGtFYaoS0tiTZzoD/TMrGyWmxIb5ZHaKWIC/fAziqJeKR5bV963ns47iJ0aNG X-Received: by 2002:a05:6a21:32a0:b0:120:80ba:3df0 with SMTP id yt32-20020a056a2132a000b0012080ba3df0mr1781172pzb.27.1687207766952; Mon, 19 Jun 2023 13:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687207766; cv=none; d=google.com; s=arc-20160816; b=LsNVl2+NLKwvWKCcCAbuiTqLy0VIJPyUrvxwdlOHImTajQwmruh+kULGLjAR+Im/Ez HrpLIVM6c+OXk/OZoLyeq9TmNkTAxWiMfP//lMuXs9ecTC2x2ThAV362u9VnATB9x0U+ Gd2mMVdGQvq8JLFI3Nf06IiTI39PDYUqYdKiV3GANbHem+eg++Om9rFaK1t2e3g1tgc+ Y+SCqRE+ZOxPqqmSLXd7IGbE+/dOmJ+B7WvoZBknQWHtX0EJQpIaJV+8kt0sEjIYY1IV W5Ca3PiPNVMSczUivg5YZf+NVKKwk0f7eAIYcfLxtVTJA22kiUhntf+ZfLdNjq0htCDT 2Wkg== 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 :message-id:date:subject:to:from:dkim-signature; bh=Aq5AJzteC4m/ndim3zRr2CGCqXNuTqzT8Bn9CWt1FW0=; b=lc60SlCwl4daOEpYWIOE4mrpdEuBHEygX/ekzymTJJS8kw9XJ++0n1KidTPXoz4zMY 7uts4c95L+E5TQEXl5hVs1nLjBCBRYScgxmgMLwQ213mvB2J1usREPasP0Ox0pNGYE/x iz3srssOVMKl8iHDphN8OUt5bGDNf7nNayfZFxHqzaxNVBw2EBLmjrEwwbDMD0tVBzMo U/nC7Ht/jlDy6HFeepEWyzrt4we1bpy6fFD4/7LU2Gic5cvDe3M09fKjJLjFHMrS3+G+ +FhbrYTEZ+6y733lSEOImjFn4VxOhetdoTAgyebPK0ivZR+F4deddjpXN7eDSE+il9nR nOew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HDDqDnTq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a1709027c0500b001b055bd62f6si435580pll.431.2023.06.19.13.49.11; Mon, 19 Jun 2023 13:49:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HDDqDnTq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229694AbjFSUrZ (ORCPT + 99 others); Mon, 19 Jun 2023 16:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjFSUrX (ORCPT ); Mon, 19 Jun 2023 16:47:23 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B62ABE63; Mon, 19 Jun 2023 13:47:20 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-30e412a852dso3342395f8f.0; Mon, 19 Jun 2023 13:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687207639; x=1689799639; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Aq5AJzteC4m/ndim3zRr2CGCqXNuTqzT8Bn9CWt1FW0=; b=HDDqDnTqUXU9qkde5k7OnBXj9v2bfadQNXJWfzJHN7vJHb/i3kiQjKt/xBIr2yF3Ar yP2bC8MaGjqM0/aHFg7nRrTkmIE8OEFlzGf6/Q/2LOnqoh1DJQLw0In/quN938DqWOnS lXKwws6KIRhY2LtbVbZTAeXBy7yH76X0USK+1dnd57+3GzjYzGEy/i3VUVmftftqzLRJ h5tWZOs79ju/vhy3sfrphmWzl16eh03eZ4k5ma9/EqvzRxNPZprLjIM3kKeE/8hf6O/e byvKOv7KUk7XRVmWQhWNz61yO89FQL3naf4DbaQNV+fR3fsfVmW9CXcE8IcFqeIhYibJ zZyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687207639; x=1689799639; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Aq5AJzteC4m/ndim3zRr2CGCqXNuTqzT8Bn9CWt1FW0=; b=b1UGgrdgbi+5s2AFAMs0W1tnCpzKNHPbKU/hLCuGMGnMEFql88ow/jnz6ytz1YD85t BlcV7T8Ez8QhEzPpPDo8Hr+y3k8MpCh4ihHdYsS/8JwdFxjfD72j6ypOEBt9NzYAgbsS 0VWFmyf9975VUcunxWSYItQNXQKhxkGG/tZWF9XE143RXFCCt0QSoVpaDhg0y7pc0Xq8 QaBc+1WvHgKSowt0czwam1kCcdOpYQEPglrS93qVTkSPvYFN6QiW8qJEcZ+qk89mxPiY Ua4860FOHwQTZPgjOToSC1Axog9XfcFna66mKCzn7HOzf/KM82Yn39NaaqCSXDry4loV hGZw== X-Gm-Message-State: AC+VfDzA1md7XnmO0UkcMUmq89bsfL70XrajCrDC272xQPt82TP1tfZ4 S+ZPC6ht3kQ3BMzfFnv2fPs= X-Received: by 2002:adf:dcc3:0:b0:311:1946:fe7d with SMTP id x3-20020adfdcc3000000b003111946fe7dmr7861005wrm.53.1687207638792; Mon, 19 Jun 2023 13:47:18 -0700 (PDT) Received: from localhost.localdomain (93-34-93-173.ip49.fastwebnet.it. [93.34.93.173]) by smtp.googlemail.com with ESMTPSA id k10-20020adff5ca000000b0030ae87bd3e3sm434043wrp.18.2023.06.19.13.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:47:18 -0700 (PDT) From: Christian Marangi To: Pavel Machek , Lee Jones , Andrew Lunn , Christian Marangi , "David S. Miller" , Dan Carpenter , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [net-next PATCH v5 0/3] leds: trigger: netdev: add additional modes Date: Mon, 19 Jun 2023 22:46:57 +0200 Message-Id: <20230619204700.6665-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769165571339194769?= X-GMAIL-MSGID: =?utf-8?q?1769165571339194769?= This is a continue of [1]. It was decided to take a more gradual approach to implement LEDs support for switch and phy starting with basic support and then implementing the hw control part when we have all the prereq done. This should be the final part for the netdev trigger. I added net-next tag and added netdev mailing list since I was informed that this should be merged with netdev branch. We collect some info around and we found a good set of modes that are common in almost all the PHY and Switch. These modes are: - Modes for dedicated link speed(10, 100, 1000 mbps). Additional mode can be added later following this example. - Modes for half and full duplex. The original idea was to add hw control only modes. While the concept makes sense in practice it would results in lots of additional code and extra check to make sure we are setting correct modes. With the suggestion from Andrew it was pointed out that using the ethtool APIs we can actually get the current link speed and duplex and this effectively removed the problem of having hw control only modes since we can fallback to software. Since these modes are supported by software, we can skip providing an user for this in the LED driver to support hw control for these new modes (that will come right after this is merged) and prevent this to be another multi subsystem series. For link speed and duplex we use ethtool APIs. To call ethtool APIs, rtnl lock is needed but this can be skipped on handling netdev events as the lock is already held. [1] https://lore.kernel.org/lkml/20230216013230.22978-1-ansuelsmth@gmail.com/ Changes v5: - Fix conflict error on rebase - Add Review-by tag by Andrew Changes v4: - Add net-next tag - Add additional patch to expose hw_control via sysfs - CC netdev mailing list Changes v3: - Add Andrew review tag - Use SPEED_UNKNOWN to init link_speed - Fix using HALF_DUPLEX as duplex init and use DUPLEX_UNKNOWN instead Changes v2: - Drop ACTIVITY patch as it can be handled internally in the LED driver - Reduce duplicate code and move the link state to a dedicated helper Christian Marangi (3): leds: trigger: netdev: add additional specific link speed mode leds: trigger: netdev: add additional specific link duplex mode leds: trigger: netdev: expose hw_control status via sysfs drivers/leds/trigger/ledtrig-netdev.c | 114 +++++++++++++++++++++++--- include/linux/leds.h | 5 ++ 2 files changed, 109 insertions(+), 10 deletions(-)