Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp957234lqp; Sun, 14 Apr 2024 07:24:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYa6sdzHMpj+CAaMpDN835AxQMSuIoIcoG4Ycc4iFpK6v48U9Z+eGNTsCmOYGgWwyrB9K5DHyR2SM3TGrEf2wWVGaESB8vgvSfzHlPBQ== X-Google-Smtp-Source: AGHT+IGmA7HF1Cu2uCUEseNmtRvwz8g8smSh7xermnqvIz5hvyIynO+OFmCXzUF0Ca5cY+2WqxKO X-Received: by 2002:a17:90a:5ae4:b0:2a6:f6ad:1b84 with SMTP id n91-20020a17090a5ae400b002a6f6ad1b84mr7551639pji.0.1713104679930; Sun, 14 Apr 2024 07:24:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713104679; cv=pass; d=google.com; s=arc-20160816; b=etAjbeqi6O2fG5MZ/HE+gEjkT/7zOaxWJKl6Q9R6tjRgijzr9hK7WhkQPXQIhKi3t3 /dE4aWj+Qg3E8seY1C5cNFM0Idh2wzJLlE2mNyGSYB3Zz7LfJs3A/R5N3ZS1iS2aAbzx LoxIUW9iGXflGf3Mx7VVBBwqLWJ+zzH8xzCzFJw8UV5K/P6qozTY+om5NkxpUc5pG9ga JqM76ZliMt0hvV2MMwSSpzHl/UTxoYzQNA+w/V+zQdveQ7tAR4iHqU4L0Z/BEu5E6RuM ParEYfAuDk9Zue9jyjk5UspkK1cNtZDEB1XUjyN4GT1Zy5uydyp/Q/Er+Xgny3NXFpw+ EHBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=x2h2/SifOa2nfmPr79ocv/8rZS3VlzAogGYtg+7WevQ=; fh=57ylmEJf4L+ab5JW9VDoPKBjQbUSU1WR6XAwF32mgs8=; b=Bg89b3ml+lpvtN6lmHi745nT2nwoizysz9O/j3PpeGcZoYuDz00jTGp/qUtU2zsNZQ GDIuNrCgVKC95g9arK1eH9uFoqwdfeHtSkuSCBqF3u4t5OTcKpaYTkNuaBn49sfYaez5 wtRcWGGrsd1/DVDXSkgXES81Y2VjER3zK2jnSC3h+lxETaRZgQd3M0Ylq51d2ssoelME q9At9Dx6FVguaYYB8/9i1jBttLK5jI5e9mikCgTSzyJYK9OBG22Hpj/lUY9G/SZaD99I 5Oe2WE9HBQXCQprkEstZpw3DDqkXKGoxq+Rn7qbuBmKS7vtaR0n0CJ2OVm5LX+T26UFt dZ2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aQCVfiwD; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-144196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z14-20020a17090a398e00b002a525ac649csi6401135pjb.49.2024.04.14.07.24.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 07:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aQCVfiwD; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-144196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 33F80281887 for ; Sun, 14 Apr 2024 14:24:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 461855C8ED; Sun, 14 Apr 2024 14:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="aQCVfiwD" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FF6B5B682; Sun, 14 Apr 2024 14:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713104592; cv=none; b=Aw8NKmbaqT2Agv3gBiMfOCXq5/YV0kzy//uCRdDNjLuc8PBbNxkRF+ZQhWjGs1kRDFu89LfKeBrPGS+uFZhuYwxTl49hH7zeSVeuBFBkXE25g3eQNQmvGvsCy3oEAsfq9WQjJirkQ07jqALPAVEIN3sG9cSD5CBBG59Pu1Qlurc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713104592; c=relaxed/simple; bh=dtSdtLY5S1JCjKQc288BE2kE0KGyNXIy8KTYVYnl+8k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lFTfpl8Jc7pmwh95hqMWrgLgmb8P2yTAckVCHxm/OizEZ6qXiEcBMbzWDyVsMoK3nAD/QwvDOyT/ZVLt8tH6ZdHXyXh/lXuLerkbjNeVD1sNZNFkHlabCB8toteYAyjkAG+sQOOeu6pImoGzbkTT4mLavwo+n8BseJqrBKxTOvc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=aQCVfiwD; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id F1240C0002; Sun, 14 Apr 2024 14:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713104588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x2h2/SifOa2nfmPr79ocv/8rZS3VlzAogGYtg+7WevQ=; b=aQCVfiwDEGSrqyvEYQ2+ooGXulORN5+Ui6Kza0MeChP34xq0DsB61Hnw7AwcKqCGHQzp6D dJ598cn9fv9EJee9h3fSNnWakg+qtk6NmJ4XaImRQ8GnzKTvObkfbPea35F2hZ89FFTqFr lZMRzB5IL8T4F6GoGL8CO3rUBGLuLmoQyxrqGSUkcqqcbmiH8Rx7YFGOh1Ys4xzBmSmgHC rr9Y6yP9IK5p93EStl86lmlmPWdCw35+p4nwnqau5BJDkr/Xlbq/TpCx3Wq8X/CNw1xiow ZEYzrSIH3E3nQL8Vt3dE9X1zvHtYIdIUsZRZxpQJMI7fpNFP78iu+dCla5y5xw== From: Kory Maincent Date: Sun, 14 Apr 2024 16:21:54 +0200 Subject: [PATCH net-next v8 05/17] net: pse-pd: Introduce PSE types enumeration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240414-feature_poe-v8-5-e4bf1e860da5@bootlin.com> References: <20240414-feature_poe-v8-0-e4bf1e860da5@bootlin.com> In-Reply-To: <20240414-feature_poe-v8-0-e4bf1e860da5@bootlin.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksij Rempel , Mark Brown , Frank Rowand , Andrew Lunn , Heiner Kallweit , Russell King Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, Dent Project , kernel@pengutronix.de, Maxime Chevallier , Kory Maincent X-Mailer: b4 0.14-dev X-GND-Sasl: kory.maincent@bootlin.com From: Kory Maincent (Dent Project) Introduce an enumeration to define PSE types (C33 or PoDL), utilizing a bitfield for potential future support of both types. Include 'pse_get_types' helper for external access to PSE type info. Reviewed-by: Andrew Lunn Signed-off-by: Kory Maincent --- Changes in v2: - Rename PSE_POE to PSE_C33 to have naming consistency. - Use "static inline" instead of simple static in the header Changes in v3: - Move the pse_type enum in uapi. - Replace pse_get_types helper by pse_has_podl and pse_has_c33. Changes in v5: - Move the pse types enum in ethtool. - Add ethtool prefix to the value. Changes in v6: - Fix a kdoc nit. --- drivers/net/pse-pd/pse_core.c | 12 ++++++++++++ drivers/net/pse-pd/pse_regulator.c | 1 + include/linux/pse-pd/pse.h | 15 +++++++++++++++ include/uapi/linux/ethtool.h | 12 ++++++++++++ 4 files changed, 40 insertions(+) diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c index 146b81f08a89..fed006cbc185 100644 --- a/drivers/net/pse-pd/pse_core.c +++ b/drivers/net/pse-pd/pse_core.c @@ -312,3 +312,15 @@ int pse_ethtool_set_config(struct pse_control *psec, return err; } EXPORT_SYMBOL_GPL(pse_ethtool_set_config); + +bool pse_has_podl(struct pse_control *psec) +{ + return psec->pcdev->types & ETHTOOL_PSE_PODL; +} +EXPORT_SYMBOL_GPL(pse_has_podl); + +bool pse_has_c33(struct pse_control *psec) +{ + return psec->pcdev->types & ETHTOOL_PSE_C33; +} +EXPORT_SYMBOL_GPL(pse_has_c33); diff --git a/drivers/net/pse-pd/pse_regulator.c b/drivers/net/pse-pd/pse_regulator.c index 1dedf4de296e..547af384764b 100644 --- a/drivers/net/pse-pd/pse_regulator.c +++ b/drivers/net/pse-pd/pse_regulator.c @@ -116,6 +116,7 @@ pse_reg_probe(struct platform_device *pdev) priv->pcdev.owner = THIS_MODULE; priv->pcdev.ops = &pse_reg_ops; priv->pcdev.dev = dev; + priv->pcdev.types = ETHTOOL_PSE_PODL; ret = devm_pse_controller_register(dev, &priv->pcdev); if (ret) { dev_err(dev, "failed to register PSE controller (%pe)\n", diff --git a/include/linux/pse-pd/pse.h b/include/linux/pse-pd/pse.h index be4e5754eb24..19589571157f 100644 --- a/include/linux/pse-pd/pse.h +++ b/include/linux/pse-pd/pse.h @@ -77,6 +77,7 @@ struct pse_control; * device tree to id as given to the PSE control ops * @nr_lines: number of PSE controls in this controller device * @lock: Mutex for serialization access to the PSE controller + * @types: types of the PSE controller */ struct pse_controller_dev { const struct pse_controller_ops *ops; @@ -89,6 +90,7 @@ struct pse_controller_dev { const struct of_phandle_args *pse_spec); unsigned int nr_lines; struct mutex lock; + enum ethtool_pse_types types; }; #if IS_ENABLED(CONFIG_PSE_CONTROLLER) @@ -108,6 +110,9 @@ int pse_ethtool_set_config(struct pse_control *psec, struct netlink_ext_ack *extack, const struct pse_control_config *config); +bool pse_has_podl(struct pse_control *psec); +bool pse_has_c33(struct pse_control *psec); + #else static inline struct pse_control *of_pse_control_get(struct device_node *node) @@ -133,6 +138,16 @@ static inline int pse_ethtool_set_config(struct pse_control *psec, return -ENOTSUPP; } +static inline bool pse_has_podl(struct pse_control *psec) +{ + return false; +} + +static inline bool pse_has_c33(struct pse_control *psec) +{ + return false; +} + #endif #endif diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 29ac06d66228..baf2b8e0d72f 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -752,6 +752,18 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; +/** + * enum ethtool_pse_types - Types of PSE controller. + * @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown + * @ETHTOOL_PSE_PODL: PSE controller which support PoDL + * @ETHTOOL_PSE_C33: PSE controller which support Clause 33 (PoE) + */ +enum ethtool_pse_types { + ETHTOOL_PSE_UNKNOWN = 1 << 0, + ETHTOOL_PSE_PODL = 1 << 1, + ETHTOOL_PSE_C33 = 1 << 2, +}; + /** * enum ethtool_c33_pse_admin_state - operational state of the PoDL PSE * functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState -- 2.34.1